From a4c65d3fa539b8e07a617977d11eb781ebc7dce5 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 22 Sep 2026 20:05:28 +0000 Subject: Start writing a genunicode program to process the unicode data files. While we are here, add some missing copyright/license notices. FossilOrigin-Name: 72aa02406da41a413284af19d52bcc1a091cac210b64f9887b123a95f20128e0 --- src/tools/Makefile.am | 10 ++++++-- src/tools/genboot.c | 19 ++++++++++++++ src/tools/genunicode.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 src/tools/genunicode.c (limited to 'src/tools') diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am index b1079e7..1930970 100644 --- a/src/tools/Makefile.am +++ b/src/tools/Makefile.am @@ -1,10 +1,16 @@ -noinst_PROGRAMS += genboot +noinst_PROGRAMS += genboot genunicode genboot_SOURCES = src/tools/genboot.c +genunicode_SOURCES = src/tools/genunicode.c BUILT_SOURCES += $(top_builddir)/generated/boot.h -CLEANFILES += $(top_builddir)/generated/boot.h +BUILT_SOURCES += $(top_builddir)/generated/unicode.h $(top_builddir)/generated/boot.h: genboot src/lib/boot.aplwc $(MKDIR_P) $(top_builddir)/generated ./genboot $(top_srcdir)/src/lib/boot.aplwc > $@ + +$(top_builddir)/generated/unicode.h: genunicode src/unicode/DerivedCoreProperties.txt src/unicode/PropList.txt + $(MKDIR_P) $(top_builddir)/generated + ./genunicode $(top_srcdir)/src/unicode > $@ + diff --git a/src/tools/genboot.c b/src/tools/genboot.c index e89b3aa..9d0a7e4 100644 --- a/src/tools/genboot.c +++ b/src/tools/genboot.c @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2026 Peter Mikkelsen + * + * This file is part of aplwc. + * + * Aplwc is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Aplwc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with aplwc. If not, see . + */ + #include #include diff --git a/src/tools/genunicode.c b/src/tools/genunicode.c new file mode 100644 index 0000000..0329ace --- /dev/null +++ b/src/tools/genunicode.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2026 Peter Mikkelsen + * + * This file is part of aplwc. + * + * Aplwc is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Aplwc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with aplwc. If not, see . + */ + +#include +#include +#include +#include + +static char *files[] = { + "DerivedCoreProperties.txt", + "PropList.txt" +}; + +int +main(int argc, char *argv[]) +{ + FILE *f; + char *dir, *buf; + size_t dir_size, tmp_size, max_size, i, nfiles; + + assert(argc == 2); + dir = argv[1]; + dir_size = strlen(dir); + + if(dir[dir_size-1] == '/') + dir_size--; + + nfiles = sizeof(files)/sizeof(files[0]); + + max_size = 0; + for(i = 0; i < nfiles; i++){ + tmp_size = strlen(files[i]); + if(tmp_size > max_size) + max_size = tmp_size; + } + max_size += dir_size + 2; + buf = malloc(max_size); + assert(buf != NULL); + memcpy(buf, dir, dir_size); + buf[dir_size] = '/'; + + for(i = 0; i < sizeof(files)/sizeof(files[0]); i++){ + memcpy(buf+dir_size+1, files[i], strlen(files[i])+1); + f = fopen(buf, "r"); + assert(f != NULL); + fclose(f); + + printf("/* Unicode file %s read from %s */\n", files[i], buf); + } + + return 0; +} -- cgit v1.2.3