summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter <peter@pmikkelsen.com>2026-09-22 20:05:28 +0000
committerpeter <peter@pmikkelsen.com>2026-09-22 20:05:28 +0000
commita4c65d3fa539b8e07a617977d11eb781ebc7dce5 (patch)
treef625bdd40bc913459b41081f01ae6321304862a8 /src
parent21b0e188e5677d5d98882650dd925f1a3cc2f8a0 (diff)
Start writing a genunicode program to process the unicode data files. While we are here, add some missing copyright/license notices.
FossilOrigin-Name: 72aa02406da41a413284af19d52bcc1a091cac210b64f9887b123a95f20128e0
Diffstat (limited to 'src')
-rw-r--r--src/lib/Makefile.am3
-rw-r--r--src/lib/unicode.c1
-rw-r--r--src/tools/Makefile.am10
-rw-r--r--src/tools/genboot.c19
-rw-r--r--src/tools/genunicode.c68
5 files changed, 98 insertions, 3 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index c95fe1c..9cbbfae 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -8,6 +8,7 @@ libaplwc_a_SOURCES = \
src/lib/module.c \
src/lib/string.c \
src/lib/symtab.c \
- src/lib/syntax.c
+ src/lib/syntax.c \
+ src/lib/unicode.c
EXTRA_DIST += src/lib/boot.aplwc
diff --git a/src/lib/unicode.c b/src/lib/unicode.c
index 862dd5f..a913b6d 100644
--- a/src/lib/unicode.c
+++ b/src/lib/unicode.c
@@ -18,3 +18,4 @@
*/
#include "aplwc_internal.h"
+#include "unicode.h"
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 <petermikkelsen10@gmail.com>
+ *
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+
#include <stdio.h>
#include <assert.h>
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 <petermikkelsen10@gmail.com>
+ *
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+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;
+}