diff --git a/Programs/.gitignore b/Programs/.gitignore index c832c06fa7..39aeb35111 100644 --- a/Programs/.gitignore +++ b/Programs/.gitignore @@ -2,6 +2,7 @@ /brltty /brltty-atb +/brltty-cldr /brltty-ctb /brltty-ktb /brltty-lscmds diff --git a/Programs/Makefile.in b/Programs/Makefile.in index 25c4b4098c..495c870c2b 100644 --- a/Programs/Makefile.in +++ b/Programs/Makefile.in @@ -532,7 +532,7 @@ ctb_louis.$O: BRLTTY_CTB_OBJECTS = brltty-ctb.$O $(PROGRAM_OBJECTS) $(PREFS_OBJECTS) dataarea.$O $(TTB_OBJECTS) $(CTB_OBJECTS) brltty-ctb$X: $(BRLTTY_CTB_OBJECTS) - $(CC) $(LDFLAGS) -o $@ $(BRLTTY_CTB_OBJECTS) $(LOUIS_LIBS) $(LDLIBS) + $(CC) $(LDFLAGS) -o $@ $(BRLTTY_CTB_OBJECTS) $(LOUIS_LIBS) $(EXPAT_LIBS) $(LDLIBS) brltty-ctb.$O: $(CC) $(CFLAGS) -c $(SRC_DIR)/brltty-ctb.c @@ -666,7 +666,7 @@ uninstall-api-bindings: BRLTTY_CLDR_OBJECTS = brltty-cldr.$O cldr.$O $(PROGRAM_OBJECTS) brltty-cldr$X: $(BRLTTY_CLDR_OBJECTS) - $(CC) $(LDFLAGS) -o $@ $(BRLTTY_CLDR_OBJECTS) -lexpat $(LDLIBS) + $(CC) $(LDFLAGS) -o $@ $(BRLTTY_CLDR_OBJECTS) $(EXPAT_LIBS) $(LDLIBS) brltty-cldr.$O: $(CC) $(LIBCFLAGS) -c $(SRC_DIR)/brltty-cldr.c @@ -775,7 +775,7 @@ learn.$O: ############################################################################### BRLTTY_OBJECTS = brltty.$O $(CORE_OBJECTS) -BRLTTY_LIBRARIES = $(BRAILLE_DRIVER_LIBRARIES) $(SPEECH_DRIVER_LIBRARIES) $(SCREEN_DRIVER_LIBRARIES) $(SERVICE_LIBS) $(PCM_LIBS) $(MIDI_LIBS) $(USB_LIBS) $(BLUETOOTH_LIBS) $(LOUIS_LIBS) $(POLKIT_LIBS) $(LDLIBS) +BRLTTY_LIBRARIES = $(BRAILLE_DRIVER_LIBRARIES) $(SPEECH_DRIVER_LIBRARIES) $(SCREEN_DRIVER_LIBRARIES) $(SERVICE_LIBS) $(PCM_LIBS) $(MIDI_LIBS) $(USB_LIBS) $(BLUETOOTH_LIBS) $(LOUIS_LIBS) $(EXPAT_LIBS) $(POLKIT_LIBS) $(LDLIBS) brltty$X: $(BRLTTY_OBJECTS) $(CC) $(LDFLAGS) -o $@ $(BRLTTY_OBJECTS) $(BRLTTY_LIBRARIES) @@ -952,11 +952,11 @@ xbrlapi.$O: ############################################################################### -TBL2HEX_OBJECTS_FOR_BUILD = tbl2hex.$(O_FOR_BUILD) $(PROGRAM_OBJECTS_FOR_BUILD) dataarea.$(O_FOR_BUILD) ttb_compile.$(O_FOR_BUILD) ttb_native.$(O_FOR_BUILD) atb_compile.$(O_FOR_BUILD) ctb_compile.$(O_FOR_BUILD) +TBL2HEX_OBJECTS_FOR_BUILD = tbl2hex.$(O_FOR_BUILD) $(PROGRAM_OBJECTS_FOR_BUILD) dataarea.$(O_FOR_BUILD) ttb_compile.$(O_FOR_BUILD) ttb_native.$(O_FOR_BUILD) atb_compile.$(O_FOR_BUILD) ctb_compile.$(O_FOR_BUILD) cldr.$(O_FOR_BUILD) TBL2HEX_OBJECTS = $(TBL2HEX_OBJECTS_FOR_BUILD:.$(O_FOR_BUILD)=.$B) tbl2hex$(X_FOR_BUILD): $(TBL2HEX_OBJECTS) - $(CC_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ $(TBL2HEX_OBJECTS) $(LDLIBS_FOR_BUILD) + $(CC_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ $(TBL2HEX_OBJECTS) $(EXPAT_LIBS_FOR_BUILD) $(LDLIBS_FOR_BUILD) ############################################################################### diff --git a/Programs/cldr.c b/Programs/cldr.c index b0432a08b5..cbf84ebb48 100644 --- a/Programs/cldr.c +++ b/Programs/cldr.c @@ -22,12 +22,14 @@ #include #include #include -#include #include "log.h" #include "cldr.h" #include "file.h" +#ifdef HAVE_EXPAT +#include + const char cldrDefaultDirectory[] = "/usr/share/unicode/cldr/common/annotations"; const char cldrDefaultExtension[] = ".xml"; @@ -160,9 +162,11 @@ handleElementEnd (void *userData, const char *name) { dpo->document.depth -= 1; } +#endif /* HAVE_EXPAT */ CLDR_DocumentParserObject * cldrNewDocumentParser (CLDR_AnnotationHandler *handler, void *data) { +#ifdef HAVE_EXPAT CLDR_DocumentParserObject *dpo; if ((dpo = malloc(sizeof(*dpo)))) { @@ -190,12 +194,14 @@ cldrNewDocumentParser (CLDR_AnnotationHandler *handler, void *data) { } else { logMallocError(); } +#endif /* HAVE_EXPAT */ return NULL; } void cldrDestroyDocumentParser (CLDR_DocumentParserObject *dpo) { +#ifdef HAVE_EXPAT if (dpo->annotation.sequence) { free(dpo->annotation.sequence); dpo->annotation.sequence = NULL; @@ -208,10 +214,12 @@ cldrDestroyDocumentParser (CLDR_DocumentParserObject *dpo) { XML_ParserFree(dpo->document.parser); free(dpo); +#endif /* HAVE_EXPAT */ } int cldrParseText (CLDR_DocumentParserObject *dpo, const char *text, size_t size, int final) { +#ifdef HAVE_EXPAT enum XML_Status status = XML_Parse(dpo->document.parser, text, size, final); switch (status) { @@ -226,6 +234,7 @@ cldrParseText (CLDR_DocumentParserObject *dpo, const char *text, size_t size, in logMessage(LOG_WARNING, "unrecognized CLDR parse status: %d", status); break; } +#endif /* HAVE_EXPAT */ return 0; } @@ -255,6 +264,7 @@ cldrParseFile ( char *path = makeFilePath(cldrDefaultDirectory, name, cldrDefaultExtension); if (path) { + logMessage(LOG_DEBUG, "processing CLDR annotations file: %s", path); int fd = open(path, O_RDONLY); if (fd != -1) { diff --git a/config.h.in b/config.h.in index 1fb856ba32..51b217abf1 100644 --- a/config.h.in +++ b/config.h.in @@ -83,6 +83,9 @@ extern "C" { /* Define this if the header file iconv.h exists. */ #undef HAVE_ICONV_H +/* Define this if XML parsing support is to be included. */ +#undef HAVE_EXPAT + /* Define this if the header file pwd.h exists. */ #undef HAVE_PWD_H diff --git a/config.mk.in b/config.mk.in index 942e09a425..0c1449bbc7 100644 --- a/config.mk.in +++ b/config.mk.in @@ -106,6 +106,9 @@ POLKIT_PACKAGE = @polkit_package@ POLKIT_INCLUDES = @polkit_includes@ POLKIT_LIBS = @polkit_libs@ +EXPAT_INCLUDES = @expat_includes@ +EXPAT_LIBS = @expat_libs@ + LOUIS_INCLUDES = @louis_includes@ LOUIS_LIBS = @louis_libs@ diff --git a/configure.ac b/configure.ac index d9b8376c57..1e2774abf7 100644 --- a/configure.ac +++ b/configure.ac @@ -1105,6 +1105,21 @@ BRLTTY_ARG_PACKAGE([system], [base system], [], [dnl ;; ]) +expat_includes="" +expat_libs="" +BRLTTY_ARG_DISABLE( + [expat], + [support for XML parsing (CLDR)], + [], +[dnl + BRLTTY_HAVE_PACKAGE([expat], [expat], [dnl + AC_DEFINE_UNQUOTED([HAVE_EXPAT], [1], + [Define this if XML parsing support is to be included.]) + ]) +]) +AC_SUBST([expat_includes]) +AC_SUBST([expat_libs]) + BRLTTY_ARG_DISABLE( [contracted-braille], [in-line contracted braille], @@ -1116,7 +1131,7 @@ BRLTTY_ARG_DISABLE( all_brltty_ctb="all-brltty-ctb" install_brltty_ctb="install-brltty-ctb" - contracted_braille_objects='ctb_compile.$O ctb_translate.$O ctb_native.$O ctb_external.$O' + contracted_braille_objects='ctb_compile.$O cldr.$O ctb_translate.$O ctb_native.$O ctb_external.$O' install_contraction_tables=install-contraction-tables louis_includes=""