From cfc8b0c03ef14c9570e244b32a7b78aa07f364be Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Thu, 17 Apr 2014 10:01:48 +0000 Subject: [PATCH 01/54] Add a section about the history to the README also converted the README to markdown --- README | 69 ---------------------------------------------- README.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 69 deletions(-) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index a79bdba8c9..0000000000 --- a/README +++ /dev/null @@ -1,69 +0,0 @@ -INTRODUCTION - -Liblouis is an open-source braille translator and back-translator. It -features support for computer and literary braille, supports -contracted and uncontracted translation for many, many languages -(Arabic, Armenian, Bulgarian, Chinese, Croatian, Czech, Danish, Dutch, -English, Esperanto, Estonian, Finish, French, Gaelic, German, Greek, -Icelandic, Italian, Lithuanian, Norwegian, Polish, Portuguese, -Romanian, Russian, Slovakian, Spanish, Swedish, Turkish, Vietnamese, -Welsh) and has support for hyphenation. New languages can easily be -added through tables that support a rule- or dictionary based -approach. Included are also tools for testing and debugging tables. -Liblouis also supports math braille (Nemeth and Marburg). The -formatting of braille is provided by the companion projects -liblouisxml and liblouisutdml. - -Liblouis has features to support screen-reading programs. This has led -to its use in two Open Source screenreaders, NVDA and Orca. It is also -used in some commercial assistive technology applications. - -Liblouis is based on the translation routines in the BRLTTY -screenreader for Linux. It has, however, gone far beyond these -routines. It is named in honor of Louis Braille. In Linux and Mac OSX -it is a shared library, and in Windows it is a DLL. - -The library is licensed under the GNU Lesser General Public License -version 3 or later. See the file COPYING.LIB. - -The command line tools, are licensed under the GNU General Public -License version 3.0 or later. See the file COPYING. - -DOCUMENTATION - -For documentation, see the liblouis documentation (either as info -file, html, txt or pdf[1]) in the doc directory. For examples of -translation tables, see en-us-g2.ctb en-us-g1.ctb chardefs.cti, and -whatever other files they may include in the tables directory. This -directory contains tables for many languages. The Nemeth files will -only work with the sister libraries liblouisxml and liblouisutdml. - -INSTALLATION - -After unpacking the distribution tarball go to the directory it creates. -You now have the choice to compile liblouis for either 16- or 32-bit -unicode. By default it is compiled for the former. To get 32-bit Unicode -run configure with --enable-ucs4 . - -After running configure run "make" and then "make install". You must -have root privileges for the installation step. - -This will produce the liblouis library and the programs lou_allround, -lou_checkhyphens, lou_ checktable, lou_debug and lou_translate. - -If you wish to have man pages for the programs you might want to -install help2man before running configure. - -RELEASE NOTES - -The program lou_allround is for testing the library. It is completely -interactive. lou_checktable is for checking translation tables for -errors. lou_debug is for debugging translation tables. lou_translate -is for extensive testing of the translation and back-translation -capabilities. For more details see the liblouis documentation. - - -FOOTNOTES: -[1] You can create the pdf version of the liblouis documentation with `make pdf'. - - diff --git a/README.md b/README.md new file mode 100644 index 0000000000..fbaf739a9c --- /dev/null +++ b/README.md @@ -0,0 +1,82 @@ +# Introduction + +Liblouis is an open-source braille translator and back-translator +named in honor of [Louis Braille][]. It features support for computer +and literary braille, supports contracted and uncontracted translation +for [many languages][] and has support for hyphenation. New languages +can easily be added through tables that support a rule- or dictionary +based approach. Tools for testing and debugging tables are also +included. Liblouis also supports math braille (Nemeth and Marburg). + +Liblouis has features to support screen-reading programs. This has led +to its use in two open-source screenreaders, [NVDA][] and [Orca][]. It +is also used in some commercial assistive technology applications for +example by [ViewPlus][]. + +Liblouis is based on the translation routines in the [BRLTTY][] +screenreader for Linux. It has, however, gone far beyond these +routines. In Linux and Mac OSX it is a shared library, and in Windows +it is a DLL. + +Liblouis is free software licensed under the [GNU Lesser GPL][] (see +the file COPYING.LIB). + +The command line tools, are licensed under the [GNU GPL][] (see the +file COPYING). + +# Documentation + +For documentation, see the [liblouis documentation][] (either as info +file, html, txt or pdf) in the doc directory. For examples +of translation tables, see `en-us-g2.ctb`, `en-us-g1.ctb`, +`chardefs.cti`, and whatever other files they may include in the +tables directory. This directory contains tables for many languages. +The Nemeth files will only work with the sister library +[liblouisutdml][]. + +# Installation + +After unpacking the distribution tarball go to the directory it creates. +You now have the choice to compile liblouis for either 16- or 32-bit +unicode. By default it is compiled for the former. To get 32-bit Unicode +run configure with `--enable-ucs4`. + +After running configure run `make` and then `make install`. You must +have root privileges for the installation step. + +This will produce the liblouis library and the programs `lou_allround` +(for testing the library), `lou_checkhyphens`, `lou_checktable` (for +checking translation tables), `lou_debug` (for debugging translation +tables), `lou_translate` (for extensive testing of forward and +backwards translation) and `lou_trace` (for tracing if individual +translations). For more details see the liblouis documentation. + +If you wish to have man pages for the programs you might want to +install `help2man` before running configure. + +# Release Notes + +For notes on the newest and older releases see the file NEWS. + +# History + +Liblouis was begun in 2002 largely as a business decision by +[ViewPlus][]. They believed that they could never have good braille +except as part of an open source effort and knew that John Boyer was +dying to start just such a project. So ViewPlus did start it on the +agreement that they would give a small monthly stipend to John Boyer +that allowed him to pay for sighted assistants. While ViewPlus has not +contributed much to the coding, it certainly has contributed and +continues to contribute to liblouis through that support of John +Boyer. + +[Louis Braille]: http://en.wikipedia.org/wiki/Louis_Braille +[many languages]: https://code.google.com/p/liblouis/source/browse/trunk/tables/ +[NVDA]: http://www.nvda-project.org/ +[Orca]: http://live.gnome.org/Orca +[ViewPlus]: http://www.viewplus.com +[BRLTTY]: http://mielke.cc/brltty/ +[GNU Lesser GPL]: https://www.gnu.org/licenses/lgpl.html +[GNU GPL]: https://www.gnu.org/licenses/gpl.html +[liblouisutdml]: http://liblouis.org/ +[liblouis documentation]: http://www.liblouis.org/documentation/liblouis.html From 92277ee46a65ec9b251e9ddedb8f69dbdb854510 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Thu, 17 Apr 2014 13:05:00 +0000 Subject: [PATCH 02/54] Automake needs a README file at least in GNU mode. So now we have a README in org mode and generate the text version from it. --- README | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 82 ---------------------------------- README.org | 72 ++++++++++++++++++++++++++++++ 3 files changed, 198 insertions(+), 82 deletions(-) create mode 100644 README delete mode 100644 README.md create mode 100644 README.org diff --git a/README b/README new file mode 100644 index 0000000000..08435a6df6 --- /dev/null +++ b/README @@ -0,0 +1,126 @@ + __________ + + LIBLOUIS + __________ + + +Table of Contents +_________________ + +1 Introduction +2 Documentation +3 Installation +4 Release Notes +5 History + + + + + +1 Introduction +============== + + Liblouis is an open-source braille translator and back-translator + named in honor of [Louis Braille]. It features support for computer + and literary braille, supports contracted and uncontracted translation + for [many languages] and has support for hyphenation. New languages + can easily be added through tables that support a rule- or dictionary + based approach. Tools for testing and debugging tables are also + included. Liblouis also supports math braille (Nemeth and Marburg). + + Liblouis has features to support screen-reading programs. This has led + to its use in two open-source screenreaders, [NVDA] and [Orca]. It is + also used in some commercial assistive technology applications for + example by [ViewPlus]. + + Liblouis is based on the translation routines in the [BRLTTY] + screenreader for Linux. It has, however, gone far beyond these + routines. In Linux and Mac OSX it is a shared library, and in Windows + it is a DLL. + + Liblouis is free software licensed under the [GNU Lesser GPL] (see the + file COPYING.LIB). + + The command line tools, are licensed under the [GNU GPL] (see the file + COPYING). + + + [Louis Braille] http://en.wikipedia.org/wiki/Louis_Braille + + [many languages] + https://code.google.com/p/liblouis/source/browse/trunk/tables/ + + [NVDA] http://www.nvda-project.org/ + + [Orca] http://live.gnome.org/Orca + + [ViewPlus] http://www.viewplus.com + + [BRLTTY] http://mielke.cc/brltty/ + + [GNU Lesser GPL] https://www.gnu.org/licenses/lgpl.html + + [GNU GPL] https://www.gnu.org/licenses/gpl.html + + +2 Documentation +=============== + + For documentation, see the [liblouis documentation] (either as info + file, html, txt or pdf) in the doc directory. For examples of + translation tables, see `en-us-g2.ctb', `en-us-g1.ctb', + `chardefs.cti', and whatever other files they may include in the + tables directory. This directory contains tables for many languages. + The Nemeth files will only work with the sister library + [liblouisutdml]. + + + [liblouis documentation] + http://www.liblouis.org/documentation/liblouis.html + + [liblouisutdml] http://liblouis.org/ + + +3 Installation +============== + + After unpacking the distribution tarball go to the directory it + creates. You now have the choice to compile liblouis for either 16- or + 32-bit unicode. By default it is compiled for the former. To get + 32-bit Unicode run configure with `--enable-ucs4'. + + After running configure run `make' and then `make install'. You must + have root privileges for the installation step. + + This will produce the liblouis library and the programs `lou_allround' + (for testing the library), `lou_checkhyphens', `lou_checktable' (for + checking translation tables), `lou_debug' (for debugging translation + tables), `lou_translate' (for extensive testing of forward and + backwards translation) and `lou_trace' (for tracing if individual + translations). For more details see the liblouis documentation. + + If you wish to have man pages for the programs you might want to + install `help2man' before running configure. + + +4 Release Notes +=============== + + For notes on the newest and older releases see the file NEWS. + + +5 History +========= + + Liblouis was begun in 2002 largely as a business decision by + [ViewPlus]. They believed that they could never have good braille + except as part of an open source effort and knew that John Boyer was + dying to start just such a project. So ViewPlus did start it on the + agreement that they would give a small monthly stipend to John Boyer + that allowed him to pay for sighted assistants. While ViewPlus has not + contributed much to the coding, it certainly has contributed and + continues to contribute to liblouis through that support of John + Boyer. + + + [ViewPlus] http://www.viewplus.com diff --git a/README.md b/README.md deleted file mode 100644 index fbaf739a9c..0000000000 --- a/README.md +++ /dev/null @@ -1,82 +0,0 @@ -# Introduction - -Liblouis is an open-source braille translator and back-translator -named in honor of [Louis Braille][]. It features support for computer -and literary braille, supports contracted and uncontracted translation -for [many languages][] and has support for hyphenation. New languages -can easily be added through tables that support a rule- or dictionary -based approach. Tools for testing and debugging tables are also -included. Liblouis also supports math braille (Nemeth and Marburg). - -Liblouis has features to support screen-reading programs. This has led -to its use in two open-source screenreaders, [NVDA][] and [Orca][]. It -is also used in some commercial assistive technology applications for -example by [ViewPlus][]. - -Liblouis is based on the translation routines in the [BRLTTY][] -screenreader for Linux. It has, however, gone far beyond these -routines. In Linux and Mac OSX it is a shared library, and in Windows -it is a DLL. - -Liblouis is free software licensed under the [GNU Lesser GPL][] (see -the file COPYING.LIB). - -The command line tools, are licensed under the [GNU GPL][] (see the -file COPYING). - -# Documentation - -For documentation, see the [liblouis documentation][] (either as info -file, html, txt or pdf) in the doc directory. For examples -of translation tables, see `en-us-g2.ctb`, `en-us-g1.ctb`, -`chardefs.cti`, and whatever other files they may include in the -tables directory. This directory contains tables for many languages. -The Nemeth files will only work with the sister library -[liblouisutdml][]. - -# Installation - -After unpacking the distribution tarball go to the directory it creates. -You now have the choice to compile liblouis for either 16- or 32-bit -unicode. By default it is compiled for the former. To get 32-bit Unicode -run configure with `--enable-ucs4`. - -After running configure run `make` and then `make install`. You must -have root privileges for the installation step. - -This will produce the liblouis library and the programs `lou_allround` -(for testing the library), `lou_checkhyphens`, `lou_checktable` (for -checking translation tables), `lou_debug` (for debugging translation -tables), `lou_translate` (for extensive testing of forward and -backwards translation) and `lou_trace` (for tracing if individual -translations). For more details see the liblouis documentation. - -If you wish to have man pages for the programs you might want to -install `help2man` before running configure. - -# Release Notes - -For notes on the newest and older releases see the file NEWS. - -# History - -Liblouis was begun in 2002 largely as a business decision by -[ViewPlus][]. They believed that they could never have good braille -except as part of an open source effort and knew that John Boyer was -dying to start just such a project. So ViewPlus did start it on the -agreement that they would give a small monthly stipend to John Boyer -that allowed him to pay for sighted assistants. While ViewPlus has not -contributed much to the coding, it certainly has contributed and -continues to contribute to liblouis through that support of John -Boyer. - -[Louis Braille]: http://en.wikipedia.org/wiki/Louis_Braille -[many languages]: https://code.google.com/p/liblouis/source/browse/trunk/tables/ -[NVDA]: http://www.nvda-project.org/ -[Orca]: http://live.gnome.org/Orca -[ViewPlus]: http://www.viewplus.com -[BRLTTY]: http://mielke.cc/brltty/ -[GNU Lesser GPL]: https://www.gnu.org/licenses/lgpl.html -[GNU GPL]: https://www.gnu.org/licenses/gpl.html -[liblouisutdml]: http://liblouis.org/ -[liblouis documentation]: http://www.liblouis.org/documentation/liblouis.html diff --git a/README.org b/README.org new file mode 100644 index 0000000000..cafaa76d98 --- /dev/null +++ b/README.org @@ -0,0 +1,72 @@ +#+OPTIONS: author:nil +#+TITLE: Liblouis + +* Introduction + +Liblouis is an open-source braille translator and back-translator +named in honor of [[http://en.wikipedia.org/wiki/Louis_Braille][Louis Braille]]. It features support for computer and +literary braille, supports contracted and uncontracted translation for +[[https://code.google.com/p/liblouis/source/browse/trunk/tables/][many languages]] and has support for hyphenation. New languages can +easily be added through tables that support a rule- or dictionary +based approach. Tools for testing and debugging tables are also +included. Liblouis also supports math braille (Nemeth and Marburg). + +Liblouis has features to support screen-reading programs. This has led +to its use in two open-source screenreaders, [[http://www.nvda-project.org/][NVDA]] and [[http://live.gnome.org/Orca][Orca]]. It is also +used in some commercial assistive technology applications for example +by [[http://www.viewplus.com][ViewPlus]]. + +Liblouis is based on the translation routines in the [[http://mielke.cc/brltty/][BRLTTY]] +screenreader for Linux. It has, however, gone far beyond these +routines. In Linux and Mac OSX it is a shared library, and in Windows +it is a DLL. + +Liblouis is free software licensed under the [[https://www.gnu.org/licenses/lgpl.html][GNU Lesser GPL]] (see the +file COPYING.LIB). + +The command line tools, are licensed under the [[https://www.gnu.org/licenses/gpl.html][GNU GPL]] (see the file +COPYING). + +* Documentation + +For documentation, see the [[http://www.liblouis.org/documentation/liblouis.html][liblouis documentation]] (either as info +file, html, txt or pdf) in the doc directory. For examples of +translation tables, see =en-us-g2.ctb=, =en-us-g1.ctb=, +=chardefs.cti=, and whatever other files they may include in the +tables directory. This directory contains tables for many languages. +The Nemeth files will only work with the sister library [[http://liblouis.org/][liblouisutdml]]. + +* Installation + +After unpacking the distribution tarball go to the directory it +creates. You now have the choice to compile liblouis for either 16- or +32-bit unicode. By default it is compiled for the former. To get +32-bit Unicode run configure with =--enable-ucs4=. + +After running configure run =make= and then =make install=. You must +have root privileges for the installation step. + +This will produce the liblouis library and the programs =lou_allround= +(for testing the library), =lou_checkhyphens=, =lou_checktable= (for +checking translation tables), =lou_debug= (for debugging translation +tables), =lou_translate= (for extensive testing of forward and +backwards translation) and =lou_trace= (for tracing if individual +translations). For more details see the liblouis documentation. + +If you wish to have man pages for the programs you might want to +install =help2man= before running configure. + +* Release Notes + +For notes on the newest and older releases see the file NEWS. + +* History + +Liblouis was begun in 2002 largely as a business decision by [[http://www.viewplus.com][ViewPlus]]. +They believed that they could never have good braille except as part +of an open source effort and knew that John Boyer was dying to start +just such a project. So ViewPlus did start it on the agreement that +they would give a small monthly stipend to John Boyer that allowed him +to pay for sighted assistants. While ViewPlus has not contributed much +to the coding, it certainly has contributed and continues to +contribute to liblouis through that support of John Boyer. From bed33a8da16689c9768d61bdec816f3ea3cd94de Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Mon, 21 Apr 2014 08:53:06 +0000 Subject: [PATCH 03/54] Updated the header file for windows, fixes building on windows. --- windows/include/liblouis.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/windows/include/liblouis.h b/windows/include/liblouis.h index 8cd914d602..9654ba617d 100644 --- a/windows/include/liblouis.h +++ b/windows/include/liblouis.h @@ -131,6 +131,25 @@ int EXPORT_CALL lou_compileString (const char *tableList, const char *inString); char * EXPORT_CALL lou_setDataPath (char *path); char * EXPORT_CALL lou_getDataPath (void); + +typedef void (*logcallback)(int level, const char *message); + void EXPORT_CALL lou_registerLogCallback(logcallback callback); +/* Register logging callbacks */ + + typedef enum + { + LOG_ALL = -2147483648, + LOG_DEBUG = 10000, + LOG_INFO = 20000, + LOG_WARN = 30000, + LOG_ERROR = 40000, + LOG_FATAL = 50000, + LOG_OFF = 2147483647 + } logLevels; + void EXPORT_CALL lou_setLogLevel(int level); + void lou_log(int level, const char *format, ...); +/* General log function for callback logging */ + void EXPORT_CALL lou_free (void); /* This function should be called at the end of * the application to free all memory allocated by liblouis. */ From 61e798e0038eae418fac32363392737c8096a963 Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Mon, 21 Apr 2014 09:19:39 +0000 Subject: [PATCH 04/54] More windows build fixes --- liblouis/liblouis.h.in | 2 +- windows/configure.mk | 2 +- windows/include/liblouis.h | 2 +- windows/liblouis.def | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/liblouis/liblouis.h.in b/liblouis/liblouis.h.in index 5258aa4c97..307677b1fc 100644 --- a/liblouis/liblouis.h.in +++ b/liblouis/liblouis.h.in @@ -168,7 +168,7 @@ typedef void (*logcallback)(int level, const char *message); LOG_OFF = 2147483647 } logLevels; void EXPORT_CALL lou_setLogLevel(int level); - void lou_log(int level, const char *format, ...); + void EXPORT_CALL lou_log(int level, const char *format, ...); /* General log function for callback logging */ void EXPORT_CALL lou_free (); diff --git a/windows/configure.mk b/windows/configure.mk index 003f30c2a9..45737cd10f 100644 --- a/windows/configure.mk +++ b/windows/configure.mk @@ -1,2 +1,2 @@ -UCS=2 +UCS=4 diff --git a/windows/include/liblouis.h b/windows/include/liblouis.h index 9654ba617d..32fa180c59 100644 --- a/windows/include/liblouis.h +++ b/windows/include/liblouis.h @@ -147,7 +147,7 @@ typedef void (*logcallback)(int level, const char *message); LOG_OFF = 2147483647 } logLevels; void EXPORT_CALL lou_setLogLevel(int level); - void lou_log(int level, const char *format, ...); + void EXPORT_CALL lou_log(int level, const char *format, ...); /* General log function for callback logging */ void EXPORT_CALL lou_free (void); diff --git a/windows/liblouis.def b/windows/liblouis.def index e9689a6873..db84cd4004 100644 --- a/windows/liblouis.def +++ b/windows/liblouis.def @@ -18,6 +18,9 @@ EXPORTS lou_setDataPath lou_getTable lou_getDataPath + lou_registerLogCallback + lou_setLogLevel + lou_log lou_free getDotsForChar getCharFromDots From 79470693f845365548ead70a6f0af40c0e14e371 Mon Sep 17 00:00:00 2001 From: Mesar Hameed Date: Tue, 22 Apr 2014 13:43:03 +0000 Subject: [PATCH 05/54] lou_translateString.c: internal function translateString() Replace tab with 8 spaces. --- liblouis/lou_translateString.c | 404 ++++++++++++++++----------------- 1 file changed, 202 insertions(+), 202 deletions(-) diff --git a/liblouis/lou_translateString.c b/liblouis/lou_translateString.c index 3a588adc47..9706d63ad0 100644 --- a/liblouis/lou_translateString.c +++ b/liblouis/lou_translateString.c @@ -1809,7 +1809,7 @@ translateString () int k; markSyllables (); srcword = 0; - destword = 0; /* last word translated */ + destword = 0; /* last word translated */ dontContract = 0; prevTransOpcode = CTO_None; wordsMarked = 0; @@ -1821,72 +1821,72 @@ translateString () if (typebuf && table->capitalSign) for (k = 0; k < srcmax; k++) if (checkAttr (currentInput[k], CTC_UpperCase, 0)) - typebuf[k] |= capsemph; + typebuf[k] |= capsemph; while (src < srcmax) - { /*the main translation loop */ + { /*the main translation loop */ setBefore (); if (!insertBrailleIndicators (0)) - goto failure; + goto failure; if (src >= srcmax) - break; + break; if (!insertIndicators ()) - goto failure; + goto failure; for_selectRule (); if (appliedRules != NULL && appliedRulesCount < maxAppliedRules) - appliedRules[appliedRulesCount++] = transRule; + appliedRules[appliedRulesCount++] = transRule; srcIncremented = 1; prevSrc = src; - switch (transOpcode) /*Rules that pre-empt context and swap */ - { - case CTO_CompBrl: - case CTO_Literal: - if (!doCompbrl ()) - goto failure; - continue; - default: - break; - } + switch (transOpcode) /*Rules that pre-empt context and swap */ + { + case CTO_CompBrl: + case CTO_Literal: + if (!doCompbrl ()) + goto failure; + continue; + default: + break; + } if (!insertBrailleIndicators (1)) - goto failure; + goto failure; if (transOpcode == CTO_Context || findAttribOrSwapRules ()) - switch (transOpcode) - { - case CTO_Context: - if (appliedRules != NULL && appliedRulesCount < maxAppliedRules) - appliedRules[appliedRulesCount++] = transRule; - if (!passDoAction ()) - goto failure; - if (endReplace == src) - srcIncremented = 0; - src = endReplace; - continue; - default: - break; - } + switch (transOpcode) + { + case CTO_Context: + if (appliedRules != NULL && appliedRulesCount < maxAppliedRules) + appliedRules[appliedRulesCount++] = transRule; + if (!passDoAction ()) + goto failure; + if (endReplace == src) + srcIncremented = 0; + src = endReplace; + continue; + default: + break; + } /*Processing before replacement*/ switch (transOpcode) - { - case CTO_EndNum: - if (table->letterSign && checkAttr (currentInput[src], - CTC_Letter, 0)) - dest--; - break; - case CTO_Repeated: - case CTO_Space: - dontContract = 0; - break; - case CTO_LargeSign: - if (prevTransOpcode == CTO_LargeSign) + { + case CTO_EndNum: + if (table->letterSign && checkAttr (currentInput[src], + CTC_Letter, 0)) + dest--; + break; + case CTO_Repeated: + case CTO_Space: + dontContract = 0; + break; + case CTO_LargeSign: + if (prevTransOpcode == CTO_LargeSign) { int hasEndSegment = 0; - while (dest > 0 && checkAttr (currentOutput[dest - 1], CTC_Space, 1)) + while (dest > 0 && checkAttr (currentOutput[dest - 1], CTC_Space, 1)) { if (currentOutput[dest - 1] == ENDSEGMENT) { hasEndSegment = 1; } - dest--; + dest--; } if (hasEndSegment != 0) { @@ -1894,168 +1894,168 @@ translateString () dest++; } } - break; - case CTO_DecPoint: - if (table->numberSign) - { - TranslationTableRule *numRule = (TranslationTableRule *) - & table->ruleArea[table->numberSign]; - if (!for_updatePositions - (&numRule->charsdots[numRule->charslen], - numRule->charslen, numRule->dotslen)) - goto failure; - } - transOpcode = CTO_MidNum; - break; - case CTO_NoCont: - if (!dontContract) - doNocont (); - continue; - default: - break; - } /*end of action */ + break; + case CTO_DecPoint: + if (table->numberSign) + { + TranslationTableRule *numRule = (TranslationTableRule *) + & table->ruleArea[table->numberSign]; + if (!for_updatePositions + (&numRule->charsdots[numRule->charslen], + numRule->charslen, numRule->dotslen)) + goto failure; + } + transOpcode = CTO_MidNum; + break; + case CTO_NoCont: + if (!dontContract) + doNocont (); + continue; + default: + break; + } /*end of action */ /* replacement processing */ switch (transOpcode) - { - case CTO_Replace: - src += transCharslen; - if (!putCharacters - (&transRule->charsdots[transCharslen], transRule->dotslen)) - goto failure; - break; - case CTO_None: - if (!undefinedCharacter (currentInput[src])) - goto failure; - src++; - break; - case CTO_UpperCase: - /* Only needs special handling if not within compbrl and - *the table defines a capital sign. */ - if (! - (mode & (compbrlAtCursor | compbrlLeftCursor) && src >= - compbrlStart - && src <= compbrlEnd) && (transRule->dotslen == 1 - && table->capitalSign)) - { - putCharacter (curCharDef->lowercase); - src++; - break; - } - default: - if (cursorStatus == 2) - cursorStatus = 1; - else - { - if (transRule->dotslen) - { - if (!for_updatePositions - (&transRule->charsdots[transCharslen], - transCharslen, transRule->dotslen)) - goto failure; - } - else - { - for (k = 0; k < transCharslen; k++) - { - if (!putCharacter (currentInput[src])) - goto failure; - src++; - } - } - if (cursorStatus == 2) - cursorStatus = 1; - else if (transRule->dotslen) - src += transCharslen; - } - break; - } + { + case CTO_Replace: + src += transCharslen; + if (!putCharacters + (&transRule->charsdots[transCharslen], transRule->dotslen)) + goto failure; + break; + case CTO_None: + if (!undefinedCharacter (currentInput[src])) + goto failure; + src++; + break; + case CTO_UpperCase: + /* Only needs special handling if not within compbrl and + *the table defines a capital sign. */ + if (! + (mode & (compbrlAtCursor | compbrlLeftCursor) && src >= + compbrlStart + && src <= compbrlEnd) && (transRule->dotslen == 1 + && table->capitalSign)) + { + putCharacter (curCharDef->lowercase); + src++; + break; + } + default: + if (cursorStatus == 2) + cursorStatus = 1; + else + { + if (transRule->dotslen) + { + if (!for_updatePositions + (&transRule->charsdots[transCharslen], + transCharslen, transRule->dotslen)) + goto failure; + } + else + { + for (k = 0; k < transCharslen; k++) + { + if (!putCharacter (currentInput[src])) + goto failure; + src++; + } + } + if (cursorStatus == 2) + cursorStatus = 1; + else if (transRule->dotslen) + src += transCharslen; + } + break; + } /* processing after replacement */ switch (transOpcode) - { - case CTO_Repeated: - { - /* Skip repeated characters. */ - int srclim = srcmax - transCharslen; - if (mode & (compbrlAtCursor | compbrlLeftCursor) && - compbrlStart < srclim) - /* Don't skip characters from compbrlStart onwards. */ - srclim = compbrlStart - 1; - while ((src <= srclim) - && compareChars (&transRule->charsdots[0], - ¤tInput[src], transCharslen, 0)) - { - /* Map skipped input positions to the previous output position. */ - if (outputPositions != NULL) - { - int tcc; - for (tcc = 0; tcc < transCharslen; tcc++) - outputPositions[prevSrcMapping[src + tcc]] = dest - 1; - } - if (!cursorStatus && src <= cursorPosition - && cursorPosition < src + transCharslen) - { - cursorStatus = 1; - cursorPosition = dest - 1; - } - src += transCharslen; - } - break; - } - case CTO_RepWord: - { - /* Skip repeated characters. */ - int srclim = srcmax - transCharslen; - if (mode & (compbrlAtCursor | compbrlLeftCursor) && - compbrlStart < srclim) - /* Don't skip characters from compbrlStart onwards. */ - srclim = compbrlStart - 1; - while ((src <= srclim) - && compareChars (repwordStart, - ¤tInput[src], repwordLength, 0)) - { - /* Map skipped input positions to the previous output position. */ - if (outputPositions != NULL) - { - int tcc; - for (tcc = 0; tcc < transCharslen; tcc++) - outputPositions[prevSrcMapping[src + tcc]] = dest - 1; - } - if (!cursorStatus && src <= cursorPosition - && cursorPosition < src + transCharslen) - { - cursorStatus = 1; - cursorPosition = dest - 1; - } - src += repwordLength + transCharslen; - } - src -= transCharslen; - break; - } - case CTO_JoinNum: - case CTO_JoinableWord: - while (src < srcmax - && checkAttr (currentInput[src], CTC_Space, 0) && - currentInput[src] != ENDSEGMENT) - src++; - break; - default: - break; - } + { + case CTO_Repeated: + { + /* Skip repeated characters. */ + int srclim = srcmax - transCharslen; + if (mode & (compbrlAtCursor | compbrlLeftCursor) && + compbrlStart < srclim) + /* Don't skip characters from compbrlStart onwards. */ + srclim = compbrlStart - 1; + while ((src <= srclim) + && compareChars (&transRule->charsdots[0], + ¤tInput[src], transCharslen, 0)) + { + /* Map skipped input positions to the previous output position. */ + if (outputPositions != NULL) + { + int tcc; + for (tcc = 0; tcc < transCharslen; tcc++) + outputPositions[prevSrcMapping[src + tcc]] = dest - 1; + } + if (!cursorStatus && src <= cursorPosition + && cursorPosition < src + transCharslen) + { + cursorStatus = 1; + cursorPosition = dest - 1; + } + src += transCharslen; + } + break; + } + case CTO_RepWord: + { + /* Skip repeated characters. */ + int srclim = srcmax - transCharslen; + if (mode & (compbrlAtCursor | compbrlLeftCursor) && + compbrlStart < srclim) + /* Don't skip characters from compbrlStart onwards. */ + srclim = compbrlStart - 1; + while ((src <= srclim) + && compareChars (repwordStart, + ¤tInput[src], repwordLength, 0)) + { + /* Map skipped input positions to the previous output position. */ + if (outputPositions != NULL) + { + int tcc; + for (tcc = 0; tcc < transCharslen; tcc++) + outputPositions[prevSrcMapping[src + tcc]] = dest - 1; + } + if (!cursorStatus && src <= cursorPosition + && cursorPosition < src + transCharslen) + { + cursorStatus = 1; + cursorPosition = dest - 1; + } + src += repwordLength + transCharslen; + } + src -= transCharslen; + break; + } + case CTO_JoinNum: + case CTO_JoinableWord: + while (src < srcmax + && checkAttr (currentInput[src], CTC_Space, 0) && + currentInput[src] != ENDSEGMENT) + src++; + break; + default: + break; + } if (((src > 0) && checkAttr (currentInput[src - 1], CTC_Space, 0) - && (transOpcode != CTO_JoinableWord))) - { - srcword = src; - destword = dest; - } + && (transOpcode != CTO_JoinableWord))) + { + srcword = src; + destword = dest; + } if (srcSpacing != NULL && srcSpacing[src] >= '0' && srcSpacing[src] <= - '9') - destSpacing[dest] = srcSpacing[src]; + '9') + destSpacing[dest] = srcSpacing[src]; if ((transOpcode >= CTO_Always && transOpcode <= CTO_None) || - (transOpcode >= CTO_Digit && transOpcode <= CTO_LitDigit)) - prevTransOpcode = transOpcode; - } /*end of translation loop */ + (transOpcode >= CTO_Digit && transOpcode <= CTO_LitDigit)) + prevTransOpcode = transOpcode; + } /*end of translation loop */ if (haveEmphasis && !wordsMarked && prevPrevType != plain_text) insertBrailleIndicators (2); failure: @@ -2068,12 +2068,12 @@ translateString () if (src < srcmax) { while (checkAttr (currentInput[src], CTC_Space, 0)) - if (++src == srcmax) - break; + if (++src == srcmax) + break; } realInlen = src; return 1; -} /*first pass translation completed */ +} /*first pass translation completed */ int EXPORT_CALL lou_hyphenate (const char *tableList, const widechar From 52f51b45f4b0d0e628073782b406da324599e019 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Fri, 25 Apr 2014 12:29:27 +0000 Subject: [PATCH 06/54] Move back to just one README --- README | 212 ++++++++++++++++++++++------------------------------- README.org | 72 ------------------ 2 files changed, 86 insertions(+), 198 deletions(-) delete mode 100644 README.org diff --git a/README b/README index 08435a6df6..8a7d44a05b 100644 --- a/README +++ b/README @@ -1,126 +1,86 @@ - __________ - - LIBLOUIS - __________ - - -Table of Contents -_________________ - -1 Introduction -2 Documentation -3 Installation -4 Release Notes -5 History - - - - - -1 Introduction -============== - - Liblouis is an open-source braille translator and back-translator - named in honor of [Louis Braille]. It features support for computer - and literary braille, supports contracted and uncontracted translation - for [many languages] and has support for hyphenation. New languages - can easily be added through tables that support a rule- or dictionary - based approach. Tools for testing and debugging tables are also - included. Liblouis also supports math braille (Nemeth and Marburg). - - Liblouis has features to support screen-reading programs. This has led - to its use in two open-source screenreaders, [NVDA] and [Orca]. It is - also used in some commercial assistive technology applications for - example by [ViewPlus]. - - Liblouis is based on the translation routines in the [BRLTTY] - screenreader for Linux. It has, however, gone far beyond these - routines. In Linux and Mac OSX it is a shared library, and in Windows - it is a DLL. - - Liblouis is free software licensed under the [GNU Lesser GPL] (see the - file COPYING.LIB). - - The command line tools, are licensed under the [GNU GPL] (see the file - COPYING). - - - [Louis Braille] http://en.wikipedia.org/wiki/Louis_Braille - - [many languages] - https://code.google.com/p/liblouis/source/browse/trunk/tables/ - - [NVDA] http://www.nvda-project.org/ - - [Orca] http://live.gnome.org/Orca - - [ViewPlus] http://www.viewplus.com - - [BRLTTY] http://mielke.cc/brltty/ - - [GNU Lesser GPL] https://www.gnu.org/licenses/lgpl.html - - [GNU GPL] https://www.gnu.org/licenses/gpl.html - - -2 Documentation -=============== - - For documentation, see the [liblouis documentation] (either as info - file, html, txt or pdf) in the doc directory. For examples of - translation tables, see `en-us-g2.ctb', `en-us-g1.ctb', - `chardefs.cti', and whatever other files they may include in the - tables directory. This directory contains tables for many languages. - The Nemeth files will only work with the sister library - [liblouisutdml]. - - - [liblouis documentation] - http://www.liblouis.org/documentation/liblouis.html - - [liblouisutdml] http://liblouis.org/ - - -3 Installation -============== - - After unpacking the distribution tarball go to the directory it - creates. You now have the choice to compile liblouis for either 16- or - 32-bit unicode. By default it is compiled for the former. To get - 32-bit Unicode run configure with `--enable-ucs4'. - - After running configure run `make' and then `make install'. You must - have root privileges for the installation step. - - This will produce the liblouis library and the programs `lou_allround' - (for testing the library), `lou_checkhyphens', `lou_checktable' (for - checking translation tables), `lou_debug' (for debugging translation - tables), `lou_translate' (for extensive testing of forward and - backwards translation) and `lou_trace' (for tracing if individual - translations). For more details see the liblouis documentation. - - If you wish to have man pages for the programs you might want to - install `help2man' before running configure. - - -4 Release Notes -=============== - - For notes on the newest and older releases see the file NEWS. - - -5 History -========= - - Liblouis was begun in 2002 largely as a business decision by - [ViewPlus]. They believed that they could never have good braille - except as part of an open source effort and knew that John Boyer was - dying to start just such a project. So ViewPlus did start it on the - agreement that they would give a small monthly stipend to John Boyer - that allowed him to pay for sighted assistants. While ViewPlus has not - contributed much to the coding, it certainly has contributed and - continues to contribute to liblouis through that support of John - Boyer. - - - [ViewPlus] http://www.viewplus.com +# Introduction + +Liblouis is an open-source braille translator and back-translator +named in honor of [Louis Braille][]. It features support for computer +and literary braille, supports contracted and uncontracted translation +for [many languages][] and has support for hyphenation. New languages +can easily be added through tables that support a rule- or dictionary +based approach. Tools for testing and debugging tables are also +included. Liblouis also supports math braille (Nemeth and Marburg). + +Liblouis has features to support screen-reading programs. This has led +to its use in two open-source screenreaders, [NVDA][] and [Orca][]. It +is also used in some commercial assistive technology applications for +example by [ViewPlus][]. + +Liblouis is based on the translation routines in the [BRLTTY][] +screenreader for Linux. It has, however, gone far beyond these +routines. In Linux and Mac OSX it is a shared library, and in Windows +it is a DLL. + +Liblouis is free software licensed under the [GNU Lesser GPL][] (see +the file COPYING.LIB). + +The command line tools, are licensed under the [GNU GPL][] (see the +file COPYING). + +# Documentation + +For documentation, see the [liblouis documentation][] (either as info +file, html, txt or pdf) in the doc directory. For examples +of translation tables, see `en-us-g2.ctb`, `en-us-g1.ctb`, +`chardefs.cti`, and whatever other files they may include in the +tables directory. This directory contains tables for many languages. +The Nemeth files will only work with the sister library +[liblouisutdml][]. + +# Installation + +After unpacking the distribution tarball go to the directory it creates. +You now have the choice to compile liblouis for either 16- or 32-bit +unicode. By default it is compiled for the former. To get 32-bit Unicode +run configure with `--enable-ucs4`. + +After running configure run `make` and then `make install`. You must +have root privileges for the installation step. + +This will produce the liblouis library and the programs `lou_allround` +(for testing the library), `lou_checkhyphens`, `lou_checktable` (for +checking translation tables), `lou_debug` (for debugging translation +tables), `lou_translate` (for extensive testing of forward and +backwards translation) and `lou_trace` (for tracing if individual +translations). For more details see the liblouis documentation. + +If you wish to have man pages for the programs you might want to +install `help2man` before running configure. + +# Release Notes + +For notes on the newest and older releases see the file NEWS. + +# History + +Liblouis was begun in 2002 largely as a business decision by +[ViewPlus][]. They believed that they could never have good braille +except as part of an open source effort and knew that John Boyer was +dying to start just such a project. So ViewPlus did start it on the +agreement that they would give a small monthly stipend to John Boyer +that allowed him to pay for sighted assistants. While ViewPlus has not +contributed much to the coding, it certainly has contributed and +continues to contribute to liblouis through that support of John +Boyer. + +[Louis Braille]: http://en.wikipedia.org/wiki/Louis_Braille +[many languages]: https://code.google.com/p/liblouis/source/browse/trunk/tables/ +[NVDA]: http://www.nvda-project.org/ +[Orca]: http://live.gnome.org/Orca +[ViewPlus]: http://www.viewplus.com +[BRLTTY]: http://mielke.cc/brltty/ +[GNU Lesser GPL]: https://www.gnu.org/licenses/lgpl.html +[GNU GPL]: https://www.gnu.org/licenses/gpl.html +[liblouisutdml]: http://liblouis.org/ +[liblouis documentation]: http://www.liblouis.org/documentation/liblouis.html + + + + diff --git a/README.org b/README.org deleted file mode 100644 index cafaa76d98..0000000000 --- a/README.org +++ /dev/null @@ -1,72 +0,0 @@ -#+OPTIONS: author:nil -#+TITLE: Liblouis - -* Introduction - -Liblouis is an open-source braille translator and back-translator -named in honor of [[http://en.wikipedia.org/wiki/Louis_Braille][Louis Braille]]. It features support for computer and -literary braille, supports contracted and uncontracted translation for -[[https://code.google.com/p/liblouis/source/browse/trunk/tables/][many languages]] and has support for hyphenation. New languages can -easily be added through tables that support a rule- or dictionary -based approach. Tools for testing and debugging tables are also -included. Liblouis also supports math braille (Nemeth and Marburg). - -Liblouis has features to support screen-reading programs. This has led -to its use in two open-source screenreaders, [[http://www.nvda-project.org/][NVDA]] and [[http://live.gnome.org/Orca][Orca]]. It is also -used in some commercial assistive technology applications for example -by [[http://www.viewplus.com][ViewPlus]]. - -Liblouis is based on the translation routines in the [[http://mielke.cc/brltty/][BRLTTY]] -screenreader for Linux. It has, however, gone far beyond these -routines. In Linux and Mac OSX it is a shared library, and in Windows -it is a DLL. - -Liblouis is free software licensed under the [[https://www.gnu.org/licenses/lgpl.html][GNU Lesser GPL]] (see the -file COPYING.LIB). - -The command line tools, are licensed under the [[https://www.gnu.org/licenses/gpl.html][GNU GPL]] (see the file -COPYING). - -* Documentation - -For documentation, see the [[http://www.liblouis.org/documentation/liblouis.html][liblouis documentation]] (either as info -file, html, txt or pdf) in the doc directory. For examples of -translation tables, see =en-us-g2.ctb=, =en-us-g1.ctb=, -=chardefs.cti=, and whatever other files they may include in the -tables directory. This directory contains tables for many languages. -The Nemeth files will only work with the sister library [[http://liblouis.org/][liblouisutdml]]. - -* Installation - -After unpacking the distribution tarball go to the directory it -creates. You now have the choice to compile liblouis for either 16- or -32-bit unicode. By default it is compiled for the former. To get -32-bit Unicode run configure with =--enable-ucs4=. - -After running configure run =make= and then =make install=. You must -have root privileges for the installation step. - -This will produce the liblouis library and the programs =lou_allround= -(for testing the library), =lou_checkhyphens=, =lou_checktable= (for -checking translation tables), =lou_debug= (for debugging translation -tables), =lou_translate= (for extensive testing of forward and -backwards translation) and =lou_trace= (for tracing if individual -translations). For more details see the liblouis documentation. - -If you wish to have man pages for the programs you might want to -install =help2man= before running configure. - -* Release Notes - -For notes on the newest and older releases see the file NEWS. - -* History - -Liblouis was begun in 2002 largely as a business decision by [[http://www.viewplus.com][ViewPlus]]. -They believed that they could never have good braille except as part -of an open source effort and knew that John Boyer was dying to start -just such a project. So ViewPlus did start it on the agreement that -they would give a small monthly stipend to John Boyer that allowed him -to pay for sighted assistants. While ViewPlus has not contributed much -to the coding, it certainly has contributed and continues to -contribute to liblouis through that support of John Boyer. From 907c6b4ce6dac7655c882c0027f5755ce88d4d0b Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Tue, 6 May 2014 12:18:59 +0000 Subject: [PATCH 07/54] Let's call the next release 2.6 --- NEWS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 0357a20eca..6e5ab7eba9 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ liblouis NEWS -- history of user-visible changes. -*- org -*- -* Noteworthy changes in release 2.5.5 (2014-??-??) -**New features +* Noteworthy changes in release 2.6.0 (2014-??-??) +** New features - Added a callback system for logging purposes. ** Bug fixes From 84b1a81e2b5cdbff0bd7ded83b3f8ac007113550 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Tue, 6 May 2014 14:28:14 +0000 Subject: [PATCH 08/54] Autoconf upgrade - Set the version number to 2.6.0 - Upgrade to autoconf 2.68 - Set the bug report address to the liblouis list - Set the package url to the new web site --- configure.ac | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index b15a1b6889..2e8019d786 100644 --- a/configure.ac +++ b/configure.ac @@ -1,20 +1,13 @@ # Process this file with autoconf to produce a configure script. -AC_PREREQ(2.59) -AC_INIT(liblouis, 2.5.4, john.boyer@abilitiessoft.com) +AC_PREREQ(2.68) +AC_INIT([Liblouis], [2.6.0], [liblouis-liblouisxml@freelists.org], [liblouis], [http://www.liblouis.org]) AC_CONFIG_SRCDIR([liblouis/lou_backTranslateString.c]) AM_CONFIG_HEADER(liblouis/config.h) -dnl backwards compatibility for autoconf <= 2.64 -dnl PACKAGE_URL should be the fifth argument of AC_INIT -m4_define([AC_PACKAGE_URL], [http://code.google.com/p/liblouis/]) -AC_DEFINE(PACKAGE_URL, "AC_PACKAGE_URL", [Package URL]) -AC_SUBST(PACKAGE_URL, AC_PACKAGE_URL) - AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) -#AM_INIT_AUTOMAKE([color-tests]) +AM_INIT_AUTOMAKE # Checks for programs. AC_PROG_CC From 12348066c64647b89e21f8ba0ed048c92bd37a0c Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Mon, 28 Apr 2014 09:25:53 +0000 Subject: [PATCH 09/54] Some logging callback updates and way for logging widechar buffers --- liblouis/compileTranslationTable.c | 34 +++++++++++++++++++++++++++++- liblouis/liblouis.h.in | 1 + liblouis/lou_translateString.c | 4 ++++ liblouis/louis.h | 3 +++ windows/include/liblouis.h | 1 + 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index dc6e8530e0..9571503fa6 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -5163,7 +5163,12 @@ debugHook () printf ("%s\n", hook); } -static logcallback logCallbackFunction; +static void defaultLogCallback(int level, const char *message) +{ + lou_logPrint(message); +} + +static logcallback logCallbackFunction = defaultLogCallback; void EXPORT_CALL lou_registerLogCallback(logcallback callback) { logCallbackFunction = callback; @@ -5199,3 +5204,30 @@ void EXPORT_CALL lou_log(int level, const char *format, ...) } } } + +void EXPORT_CALL lou_setDefaultLogCallback() +{ + logCallbackFunction = defaultLogCallback; +} + +void logWidecharBuf(int level, const char *msg, widechar *wbuf, int wlen) +{ + int logBufSize = (wlen * ((sizeof(widechar) * 2) + 3)) + 1 + strlen(msg); + char *logMessage = malloc(logBufSize); + char *p = logMessage; + char *formatString; + if (sizeof(widechar) == 2) + formatString = "0x%04X "; + else + formatString = "0x%08X "; + for (int i = 0; i < strlen(msg); i++) + logMessage[i] = msg[i]; + p += strlen(msg); + for (int i = 0; i < wlen; i++) + { + p += sprintf(p, formatString, wbuf[i]); + } + p = '\0'; + lou_log(level, logMessage); + free(logMessage); +} diff --git a/liblouis/liblouis.h.in b/liblouis/liblouis.h.in index 307677b1fc..2f80a42210 100644 --- a/liblouis/liblouis.h.in +++ b/liblouis/liblouis.h.in @@ -168,6 +168,7 @@ typedef void (*logcallback)(int level, const char *message); LOG_OFF = 2147483647 } logLevels; void EXPORT_CALL lou_setLogLevel(int level); + void EXPORT_CALL lou_setDefaultCallback(); void EXPORT_CALL lou_log(int level, const char *format, ...); /* General log function for callback logging */ diff --git a/liblouis/lou_translateString.c b/liblouis/lou_translateString.c index 9706d63ad0..7a1010a844 100644 --- a/liblouis/lou_translateString.c +++ b/liblouis/lou_translateString.c @@ -78,6 +78,8 @@ trace_translate (const char *tableList, const widechar * inbufx, if (tableList == NULL || inbufx == NULL || inlen == NULL || outbuf == NULL || outlen == NULL) return 0; + lou_log(LOG_INFO, "Performing translation: tableList=%s, inlen=%d", tableList, *inlen); + logWidecharBuf(LOG_INFO, "Inbuf=", inbufx, *inlen); if ((modex & otherTrans)) return other_translate (tableList, inbufx, inlen, outbuf, outlen, @@ -271,6 +273,8 @@ trace_translate (const char *tableList, const widechar * inbufx, } if (rulesLen != NULL) *rulesLen = appliedRulesCount; + lou_log(LOG_INFO, "Translation complete: outlen=%d", *outlen); + logWidecharBuf(LOG_INFO, "Outbuf=", outbuf, *outlen); return goodTrans; } diff --git a/liblouis/louis.h b/liblouis/louis.h index 885d39fdb6..4d3abe3779 100644 --- a/liblouis/louis.h +++ b/liblouis/louis.h @@ -565,6 +565,9 @@ extern "C" void outOfMemory (); /* Priknts an out-of-memory message and exits*/ +void logWidecharBuf(int level, const char *msg, widechar *wbuf, int wlen); +/* Helper for logging a widechar buffer */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/windows/include/liblouis.h b/windows/include/liblouis.h index 32fa180c59..d2f3a42993 100644 --- a/windows/include/liblouis.h +++ b/windows/include/liblouis.h @@ -147,6 +147,7 @@ typedef void (*logcallback)(int level, const char *message); LOG_OFF = 2147483647 } logLevels; void EXPORT_CALL lou_setLogLevel(int level); + void EXPORT_CALL lou_setDefaultLogCallback(); void EXPORT_CALL lou_log(int level, const char *format, ...); /* General log function for callback logging */ From 285dd414acb22ee5420cef262ab5b75d07b36155 Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Mon, 28 Apr 2014 17:08:29 +0000 Subject: [PATCH 10/54] Changed logging callback system to set default when registering NULL for callback and to turn off one should use LOG_OFF --- liblouis/compileTranslationTable.c | 13 +++++-------- liblouis/liblouis.h.in | 10 ++++++---- windows/include/liblouis.h | 10 ++++++---- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index 9571503fa6..777a7c0b53 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -5171,16 +5171,18 @@ static void defaultLogCallback(int level, const char *message) static logcallback logCallbackFunction = defaultLogCallback; void EXPORT_CALL lou_registerLogCallback(logcallback callback) { + if (callback == 0) + logCallbackFunction = defaultLogCallback; logCallbackFunction = callback; } -static int logLevel = LOG_INFO; -void EXPORT_CALL lou_setLogLevel(int level) +static logLevels logLevel = LOG_INFO; +void EXPORT_CALL lou_setLogLevel(logLevels level) { logLevel = level; } -void EXPORT_CALL lou_log(int level, const char *format, ...) +void EXPORT_CALL lou_log(logLevels level, const char *format, ...) { if (format == NULL) return; @@ -5205,11 +5207,6 @@ void EXPORT_CALL lou_log(int level, const char *format, ...) } } -void EXPORT_CALL lou_setDefaultLogCallback() -{ - logCallbackFunction = defaultLogCallback; -} - void logWidecharBuf(int level, const char *msg, widechar *wbuf, int wlen) { int logBufSize = (wlen * ((sizeof(widechar) * 2) + 3)) + 1 + strlen(msg); diff --git a/liblouis/liblouis.h.in b/liblouis/liblouis.h.in index 2f80a42210..c3cb9e91ad 100644 --- a/liblouis/liblouis.h.in +++ b/liblouis/liblouis.h.in @@ -155,7 +155,9 @@ void EXPORT_CALL lou_registerTableResolver (char ** (* resolver) (const char *ta typedef void (*logcallback)(int level, const char *message); void EXPORT_CALL lou_registerLogCallback(logcallback callback); -/* Register logging callbacks */ +/* Register logging callbacks + * Set to NULL for default callback. + */ typedef enum { @@ -167,9 +169,9 @@ typedef void (*logcallback)(int level, const char *message); LOG_FATAL = 50000, LOG_OFF = 2147483647 } logLevels; - void EXPORT_CALL lou_setLogLevel(int level); - void EXPORT_CALL lou_setDefaultCallback(); - void EXPORT_CALL lou_log(int level, const char *format, ...); + void EXPORT_CALL lou_setLogLevel(logLevels level); + + void EXPORT_CALL lou_log(logLevels level, const char *format, ...); /* General log function for callback logging */ void EXPORT_CALL lou_free (); diff --git a/windows/include/liblouis.h b/windows/include/liblouis.h index d2f3a42993..a442a3c5d5 100644 --- a/windows/include/liblouis.h +++ b/windows/include/liblouis.h @@ -134,7 +134,9 @@ int EXPORT_CALL lou_compileString (const char *tableList, const char typedef void (*logcallback)(int level, const char *message); void EXPORT_CALL lou_registerLogCallback(logcallback callback); -/* Register logging callbacks */ +/* Register logging callbacks, + * Set to NULL for default callback. + */ typedef enum { @@ -146,9 +148,9 @@ typedef void (*logcallback)(int level, const char *message); LOG_FATAL = 50000, LOG_OFF = 2147483647 } logLevels; - void EXPORT_CALL lou_setLogLevel(int level); - void EXPORT_CALL lou_setDefaultLogCallback(); - void EXPORT_CALL lou_log(int level, const char *format, ...); + void EXPORT_CALL lou_setLogLevel(logLevels level); + + void EXPORT_CALL lou_log(logLevels level, const char *format, ...); /* General log function for callback logging */ void EXPORT_CALL lou_free (void); From f7b474a9b9724f773e566095da00fb6c38830ad6 Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Tue, 29 Apr 2014 10:29:41 +0000 Subject: [PATCH 11/54] Fixed a error where logging callback could be set to NULL and added some explaining comments. --- liblouis/compileTranslationTable.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index 777a7c0b53..c55c176612 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -5173,7 +5173,8 @@ void EXPORT_CALL lou_registerLogCallback(logcallback callback) { if (callback == 0) logCallbackFunction = defaultLogCallback; - logCallbackFunction = callback; + else + logCallbackFunction = callback; } static logLevels logLevel = LOG_INFO; @@ -5209,6 +5210,14 @@ void EXPORT_CALL lou_log(logLevels level, const char *format, ...) void logWidecharBuf(int level, const char *msg, widechar *wbuf, int wlen) { + /* When calculating output size: + * Each wdiechar is represented in hex, thus needing two bytes for each + * byte in the widechar (sizeof(widechar) * 2) + * Allow space for the "0x%X " formatting (+ 3) + * Number of characters in widechar buffer (wlen * ) + * Give space for additional message (+ strlen(msg)) + * Remember the null terminator (+ 1) + */ int logBufSize = (wlen * ((sizeof(widechar) * 2) + 3)) + 1 + strlen(msg); char *logMessage = malloc(logBufSize); char *p = logMessage; From 6c943db4f4be75ed62b4e134484bac4e259a14e6 Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Tue, 29 Apr 2014 10:35:58 +0000 Subject: [PATCH 12/54] Use NULL where NULL is meant --- liblouis/compileTranslationTable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index c55c176612..dbe2836e4e 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -5171,7 +5171,7 @@ static void defaultLogCallback(int level, const char *message) static logcallback logCallbackFunction = defaultLogCallback; void EXPORT_CALL lou_registerLogCallback(logcallback callback) { - if (callback == 0) + if (callback == NULL) logCallbackFunction = defaultLogCallback; else logCallbackFunction = callback; @@ -5189,7 +5189,7 @@ void EXPORT_CALL lou_log(logLevels level, const char *format, ...) return; if (level < logLevel) return; - if (logCallbackFunction != 0) + if (logCallbackFunction != NULL) { char *s; size_t len; From 5fe1a630e5766f8852181e317c53c755ea593383 Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Tue, 29 Apr 2014 14:44:24 +0000 Subject: [PATCH 13/54] Change lou_logPrint calls to use new logging API --- liblouis/compileTranslationTable.c | 22 +++++++++++----------- liblouis/wrappers.c | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index dbe2836e4e..a2c96c6ec1 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -710,10 +710,10 @@ compileError (FileInfo * nested, char *format, ...) #endif va_end (arguments); if (nested) - lou_logPrint ("%s:%d: error: %s", nested->fileName, + lou_log (LOG_ERROR, "%s:%d: error: %s", nested->fileName, nested->lineNumber, buffer); else - lou_logPrint ("error: %s", buffer); + lou_log (LOG_ERROR, "error: %s", buffer); errorCount++; #endif } @@ -732,10 +732,10 @@ compileWarning (FileInfo * nested, char *format, ...) #endif va_end (arguments); if (nested) - lou_logPrint ("%s:%d: warning: %s", nested->fileName, + lou_log (LOG_WARN, "%s:%d: warning: %s", nested->fileName, nested->lineNumber, buffer); else - lou_logPrint ("warning: %s", buffer); + lou_log (LOG_WARN, "warning: %s", buffer); warningCount++; #endif } @@ -4477,7 +4477,7 @@ lou_readCharFromFile (const char *fileName, int *mode) nested.lineNumber = 0; if (!(nested.in = fopen (nested.fileName, "r"))) { - lou_logPrint ("Cannot open file '%s'", nested.fileName); + lou_log (LOG_ERROR, "Cannot open file '%s'", nested.fileName); *mode = 1; return EOF; } @@ -4704,7 +4704,7 @@ defaultTableResolver (const char *tableList, const char *base) *cp = '\0'; if (!(tableFiles[k++] = resolveSubtable (subTable, base, searchPath))) { - lou_logPrint ("Cannot resolve table '%s'", subTable); + lou_log (LOG_ERROR, "Cannot resolve table '%s'", subTable); free (tableFiles); return NULL; } @@ -4761,7 +4761,7 @@ compileFile (const char *fileName) return 1; } else - lou_logPrint ("Cannot open table '%s'", nested.fileName); + lou_log (LOG_ERROR, "Cannot open table '%s'", nested.fileName); errorCount++; return 0; } @@ -4788,7 +4788,7 @@ includeFile (FileInfo * nested, CharsString * includedFile) if (tableFiles[1] != NULL) { errorCount++; - lou_logPrint ("Table list not supported in include statement: 'include %s'", includeThis); + lou_log (LOG_ERROR, "Table list not supported in include statement: 'include %s'", includeThis); return 0; } return compileFile (*tableFiles); @@ -4841,7 +4841,7 @@ compileTranslationTable (const char *tableList) if (ruleNames) deallocateRuleNames (); if (warningCount) - lou_logPrint ("%d warnings issued", warningCount); + lou_log (LOG_WARN, "%d warnings issued", warningCount); if (!errorCount) { setDefaults (); @@ -4850,7 +4850,7 @@ compileTranslationTable (const char *tableList) } else { - lou_logPrint ("%d errors found.", errorCount); + lou_log (LOG_ERROR, "%d errors found.", errorCount); if (table) free (table); table = NULL; @@ -4938,7 +4938,7 @@ lou_getTable (const char *tableList) errorCount = fileCount = 0; table = getTable (tableList); if (!table) - lou_logPrint ("%s could not be found", tableList); + lou_log (LOG_ERROR, "%s could not be found", tableList); return table; } diff --git a/liblouis/wrappers.c b/liblouis/wrappers.c index 0b5237f019..133069f97a 100644 --- a/liblouis/wrappers.c +++ b/liblouis/wrappers.c @@ -93,7 +93,7 @@ other_translate (const char *trantab, const widechar switch (action) { case -1: - lou_logPrint ("There is no translator called '%s'", transSpec); + lou_log (LOG_ERROR, "There is no translator called '%s'", transSpec); return 0; case 1: return 1; @@ -123,7 +123,7 @@ other_backTranslate (const char *trantab, const widechar switch (action) { case -1: - lou_logPrint ("There is no translator called '%s'", transSpec); + lou_log (LOG_ERROR, "There is no translator called '%s'", transSpec); return 0; case 1: return 1; From c568487833a2b6a2735e4e59640dc867c9b49b44 Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Tue, 29 Apr 2014 14:53:29 +0000 Subject: [PATCH 14/54] Changed for loop style to work with MSVC. --- liblouis/compileTranslationTable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index a2c96c6ec1..e15daaffb2 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -5222,11 +5222,12 @@ void logWidecharBuf(int level, const char *msg, widechar *wbuf, int wlen) char *logMessage = malloc(logBufSize); char *p = logMessage; char *formatString; + int i = 0; if (sizeof(widechar) == 2) formatString = "0x%04X "; else formatString = "0x%08X "; - for (int i = 0; i < strlen(msg); i++) + for (i = 0; i < strlen(msg); i++) logMessage[i] = msg[i]; p += strlen(msg); for (int i = 0; i < wlen; i++) From fd69a94ff1940ba6203b5f923e1eb53a109a4b9f Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Tue, 29 Apr 2014 15:22:19 +0000 Subject: [PATCH 15/54] Corrected another for loop to work with MSVC --- liblouis/compileTranslationTable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index e15daaffb2..6c86ae046e 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -5230,7 +5230,7 @@ void logWidecharBuf(int level, const char *msg, widechar *wbuf, int wlen) for (i = 0; i < strlen(msg); i++) logMessage[i] = msg[i]; p += strlen(msg); - for (int i = 0; i < wlen; i++) + for (i = 0; i < wlen; i++) { p += sprintf(p, formatString, wbuf[i]); } From d86fc75f7316771edb14e606605263d5780d35eb Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Tue, 6 May 2014 08:23:50 +0000 Subject: [PATCH 16/54] Fix a warning --- liblouis/compileTranslationTable.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index 6c86ae046e..6ea8a18664 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -5165,7 +5165,13 @@ debugHook () static void defaultLogCallback(int level, const char *message) { - lou_logPrint(message); + char *tmpMsg = malloc(strlen(message)+1); + if (tmpMsg) + { + strcpy(tmpMsg, message); + lou_logPrint(message); + free(tmpMsg); + } } static logcallback logCallbackFunction = defaultLogCallback; @@ -5208,7 +5214,7 @@ void EXPORT_CALL lou_log(logLevels level, const char *format, ...) } } -void logWidecharBuf(int level, const char *msg, widechar *wbuf, int wlen) +void logWidecharBuf(logLevels level, const char *msg, widechar *wbuf, int wlen) { /* When calculating output size: * Each wdiechar is represented in hex, thus needing two bytes for each From 0393165c06def22da4cd778dc0cafaeb292e23fd Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Tue, 6 May 2014 08:27:43 +0000 Subject: [PATCH 17/54] Actual fix to warning --- liblouis/compileTranslationTable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index 6ea8a18664..f14eeab082 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -5169,7 +5169,7 @@ static void defaultLogCallback(int level, const char *message) if (tmpMsg) { strcpy(tmpMsg, message); - lou_logPrint(message); + lou_logPrint(tmpMsg); free(tmpMsg); } } From bf519d6cd81149b090318e322324a456927b5bba Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Tue, 6 May 2014 09:15:32 +0000 Subject: [PATCH 18/54] Another warning fix --- liblouis/compileTranslationTable.c | 2 +- liblouis/lou_translateString.c | 2 +- liblouis/louis.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index f14eeab082..5ea5abd319 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -5214,7 +5214,7 @@ void EXPORT_CALL lou_log(logLevels level, const char *format, ...) } } -void logWidecharBuf(logLevels level, const char *msg, widechar *wbuf, int wlen) +void logWidecharBuf(logLevels level, const char *msg, const widechar *wbuf, int wlen) { /* When calculating output size: * Each wdiechar is represented in hex, thus needing two bytes for each diff --git a/liblouis/lou_translateString.c b/liblouis/lou_translateString.c index 7a1010a844..bc08f75b07 100644 --- a/liblouis/lou_translateString.c +++ b/liblouis/lou_translateString.c @@ -274,7 +274,7 @@ trace_translate (const char *tableList, const widechar * inbufx, if (rulesLen != NULL) *rulesLen = appliedRulesCount; lou_log(LOG_INFO, "Translation complete: outlen=%d", *outlen); - logWidecharBuf(LOG_INFO, "Outbuf=", outbuf, *outlen); + logWidecharBuf(LOG_INFO, "Outbuf=", (const widechar *)outbuf, *outlen); return goodTrans; } diff --git a/liblouis/louis.h b/liblouis/louis.h index 4d3abe3779..cda7eb80d2 100644 --- a/liblouis/louis.h +++ b/liblouis/louis.h @@ -565,7 +565,7 @@ extern "C" void outOfMemory (); /* Priknts an out-of-memory message and exits*/ -void logWidecharBuf(int level, const char *msg, widechar *wbuf, int wlen); +void logWidecharBuf(int level, const char *msg, const widechar *wbuf, int wlen); /* Helper for logging a widechar buffer */ #ifdef __cplusplus From d8ab7a53fe1e8a394a539716e2212884367599ed Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Tue, 6 May 2014 17:09:19 +0000 Subject: [PATCH 19/54] Change lou_logPrint to accept const char * --- liblouis/compileTranslationTable.c | 10 ++-------- liblouis/liblouis.h.in | 2 +- windows/include/liblouis.h | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index 5ea5abd319..30b8435db3 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -184,7 +184,7 @@ lou_logFile (const char *fileName) } void EXPORT_CALL -lou_logPrint (char *format, ...) +lou_logPrint (const char *format, ...) { #ifndef __SYMBIAN32__ va_list argp; @@ -5165,13 +5165,7 @@ debugHook () static void defaultLogCallback(int level, const char *message) { - char *tmpMsg = malloc(strlen(message)+1); - if (tmpMsg) - { - strcpy(tmpMsg, message); - lou_logPrint(tmpMsg); - free(tmpMsg); - } + lou_logPrint(message); } static logcallback logCallbackFunction = defaultLogCallback; diff --git a/liblouis/liblouis.h.in b/liblouis/liblouis.h.in index c3cb9e91ad..971e213605 100644 --- a/liblouis/liblouis.h.in +++ b/liblouis/liblouis.h.in @@ -116,7 +116,7 @@ mode); int *outlen, formtype *typeform, char *spacing, int *outputPos, int *inputPos, int *cursorPos, int mode); - void EXPORT_CALL lou_logPrint (char *format, ...); + void EXPORT_CALL lou_logPrint (const char *format, ...); /* prints error messages to a file */ void EXPORT_CALL lou_logFile (const char *filename); diff --git a/windows/include/liblouis.h b/windows/include/liblouis.h index a442a3c5d5..48eeb479e7 100644 --- a/windows/include/liblouis.h +++ b/windows/include/liblouis.h @@ -105,7 +105,7 @@ int EXPORT_CALL lou_charToDots (const char *tableList, const widechar formtype *typeform, char *spacing, int *outputPos, int *inputPos, int *cursorPos, int mode); - void EXPORT_CALL lou_logPrint (char *format, ...); + void EXPORT_CALL lou_logPrint (const char *format, ...); /* prints error messages to a file */ void EXPORT_CALL lou_logFile (const char *filename); From f1d1265fcfee250e53b8f27f8a8840d354cf7fbe Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Wed, 7 May 2014 06:37:55 +0000 Subject: [PATCH 20/54] Fix a linker warning --- windows/liblouis.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/liblouis.def b/windows/liblouis.def index db84cd4004..f0a900a6c3 100644 --- a/windows/liblouis.def +++ b/windows/liblouis.def @@ -1,4 +1,4 @@ -LIBRARY liblouis +LIBRARY liblouis-2 EXPORTS lou_getProgramPath From 29a37011a3287fbc1f332455f634a8acf8b009c5 Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Wed, 7 May 2014 07:07:05 +0000 Subject: [PATCH 21/54] Revert last change as it broke BrailleBlaster --- windows/liblouis.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/liblouis.def b/windows/liblouis.def index f0a900a6c3..db84cd4004 100644 --- a/windows/liblouis.def +++ b/windows/liblouis.def @@ -1,4 +1,4 @@ -LIBRARY liblouis-2 +LIBRARY liblouis EXPORTS lou_getProgramPath From df1095fe51d24194f78cf7cc926d1e93f47f5dfd Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Wed, 7 May 2014 09:18:54 +0000 Subject: [PATCH 22/54] Fix for VC++ runtime issue with floating support not being loaded --- liblouis/compileTranslationTable.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index 30b8435db3..a78b1697f0 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -5191,6 +5191,9 @@ void EXPORT_CALL lou_log(logLevels level, const char *format, ...) return; if (logCallbackFunction != NULL) { +#ifdef _WIN32 + float f = 2.3; // Needed to force VC++ runtime floating point support +#endif char *s; size_t len; va_list argp; From 00a4aa3a486f436505ba836b884dab12faac150a Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Wed, 7 May 2014 10:09:22 +0000 Subject: [PATCH 23/54] Change VC nmake file to build liblouis.dll and liblouis.lib instead of version suffix --- windows/Makefile.nmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/windows/Makefile.nmake b/windows/Makefile.nmake index 7ed7bc5244..a89168420f 100755 --- a/windows/Makefile.nmake +++ b/windows/Makefile.nmake @@ -9,7 +9,7 @@ CC = cl.exe CFLAGS = /nologo /O2 /W1 /c CFLAGS = $(CFLAGS) /Iinclude HEADERS = $(SRCDIR)\louis.h include\liblouis.h include\config.h -DLLFLAGS = /dll /nologo /DEF:liblouis.def /OUT:liblouis-2.dll +DLLFLAGS = /dll /nologo /DEF:liblouis.def /OUT:liblouis.dll OBJ = compileTranslationTable.obj lou_translateString.obj \ lou_backTranslateString.obj wrappers.obj !if "$(UCS)" == "2" @@ -20,10 +20,10 @@ CFLAGS = $(CFLAGS) /DWIDECHAR_TYPE="unsigned int" CFLAGS = $(CFLAGS) /DUNICODEBITS=32 !endif -all: liblouis-2.lib liblouis.def +all: liblouis.lib liblouis.def link $(DLLFLAGS) $(OBJ) -liblouis-2.lib: $(OBJ) - lib /nologo $(OBJ) /out:liblouis-2.lib +liblouis.lib: $(OBJ) + lib /nologo $(OBJ) /out:liblouis.lib compileTranslationTable.obj: $(SRCDIR)\compileTranslationTable.c \ $(HEADERS) From 84277cb5a7e59ea237c54ed0419c7b5526e15783 Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Thu, 8 May 2014 11:00:35 +0100 Subject: [PATCH 24/54] Fix a critical bug where logging was not protecting against % in format strings. --- liblouis/compileTranslationTable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index a78b1697f0..73ef58b078 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -5165,7 +5165,7 @@ debugHook () static void defaultLogCallback(int level, const char *message) { - lou_logPrint(message); + lou_logPrint("%s", message); // lou_logPrint takes formatting, protect against % in message } static logcallback logCallbackFunction = defaultLogCallback; From a9a5f46c97081a2045310ba25ebf1fb10faba5d6 Mon Sep 17 00:00:00 2001 From: Mesar Hameed Date: Fri, 9 May 2014 13:49:11 +0200 Subject: [PATCH 25/54] Added empty logging.c and modified Makefile.am, Makefile.nmake to include it when building. --- liblouis/Makefile.am | 1 + liblouis/logging.c | 0 windows/Makefile.nmake | 5 ++++- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 liblouis/logging.c diff --git a/liblouis/Makefile.am b/liblouis/Makefile.am index 41187e8bed..87e743deac 100644 --- a/liblouis/Makefile.am +++ b/liblouis/Makefile.am @@ -17,6 +17,7 @@ liblouis_la_SOURCES = \ compileTranslationTable.c \ louis.h \ liblouis.h \ + logging.c \ lou_translateString.c \ transcommon.ci \ wrappers.c diff --git a/liblouis/logging.c b/liblouis/logging.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/windows/Makefile.nmake b/windows/Makefile.nmake index a89168420f..bfa0096f60 100755 --- a/windows/Makefile.nmake +++ b/windows/Makefile.nmake @@ -11,7 +11,7 @@ CFLAGS = $(CFLAGS) /Iinclude HEADERS = $(SRCDIR)\louis.h include\liblouis.h include\config.h DLLFLAGS = /dll /nologo /DEF:liblouis.def /OUT:liblouis.dll OBJ = compileTranslationTable.obj lou_translateString.obj \ - lou_backTranslateString.obj wrappers.obj + lou_backTranslateString.obj wrappers.obj logging.obj !if "$(UCS)" == "2" CFLAGS = $(CFLAGS) /DWIDECHAR_TYPE="unsigned short int" CFLAGS = $(CFLAGS) /DUNICODEBITS=16 @@ -36,5 +36,8 @@ lou_backTranslateString.obj: $(SRCDIR)\lou_backTranslateString.c \ $(HEADERS) $(CC) $(CFLAGS) $(SRCDIR)\lou_backTranslateString.c +logging.obj: $(SRCDIR)\logging.c $(HEADERS) + $(CC) $(CFLAGS) $(SRCDIR)\logging.c + wrappers.obj: $(SRCDIR)\wrappers.c $(HEADERS) $(CC) $(CFLAGS) $(SRCDIR)\wrappers.c From a091dc19c27ad619498113d0f7b5261531dad7f7 Mon Sep 17 00:00:00 2001 From: Mesar Hameed Date: Fri, 9 May 2014 20:50:19 +0200 Subject: [PATCH 26/54] TODO file: Remove translatable table name item, its now listed on website. Remove add python-nose to configure.ac, now listed on website. Remove old item re danish, work being done with Bue succeeds this item. --- TODO | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/TODO b/TODO index ca1f1b9f2d..68ced5b9f7 100644 --- a/TODO +++ b/TODO @@ -8,15 +8,6 @@ file, with a bit of extra info. ** Extend and document the scripting language http://www.freelists.org/post/liblouis-liblouisxml/Very-preliminary-documentation-of-scripting-language -** configure.ac does not check for nose now. -Instead it is done with a try except in the python script. Need to be -added to configure.ac so that debian packages can automatically pick -up dependencies. - -** Mapping between table filenames, human readable names, and translatable strings, needs to be accessible from bindings. -Will remove the need of redefining translatable names for the tables -in orca, nvda, blaster etc. - * near term ** (google issue 9) bindings should provide variable to pick up table location at runtime. @@ -41,10 +32,6 @@ other tables too. ** Esperanto table should not be blacklisted, work out whats wrong and make sure it is usable. -** [mh] According to the harness, Danish table isn't producing correct output. -From memory of Swedish, the actual output is correct, but the harness -might be wrong, best to check with Danish users. - * unallocated ** (google issue 16) infinite loop in lou_backtranslate. From 4a0fa5ebd90323b974aee80a458e4922d715abe5 Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Mon, 12 May 2014 12:22:22 +0100 Subject: [PATCH 27/54] Moved some logging code into logging.c --- liblouis/compileTranslationTable.c | 128 +--------------------- liblouis/logging.c | 170 +++++++++++++++++++++++++++++ liblouis/louis.h | 2 + 3 files changed, 173 insertions(+), 127 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index 73ef58b078..ed37fcb048 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -163,52 +163,6 @@ lou_getDataPath () /* End of dataPath code.*/ -static FILE *logFile = NULL; -static char initialLogFileName[256]; - -void EXPORT_CALL -lou_logFile (const char *fileName) -{ - if (fileName == NULL || fileName[0] == 0) - return; - if (initialLogFileName[0] == 0) - strcpy (initialLogFileName, fileName); - logFile = fopen (fileName, "wb"); - if (logFile == NULL && initialLogFileName[0] != 0) - logFile = fopen (initialLogFileName, "wb"); - if (logFile == NULL) - { - fprintf (stderr, "Cannot open log file %s\n", fileName); - logFile = stderr; - } -} - -void EXPORT_CALL -lou_logPrint (const char *format, ...) -{ -#ifndef __SYMBIAN32__ - va_list argp; - if (format == NULL) - return; - if (logFile == NULL && initialLogFileName[0] != 0) - logFile = fopen (initialLogFileName, "wb"); - if (logFile == NULL) - logFile = stderr; - va_start (argp, format); - vfprintf (logFile, format, argp); - fprintf (logFile, "\n"); - va_end (argp); -#endif -} - -void EXPORT_CALL -lou_logEnd () -{ - if (logFile != NULL) - fclose (logFile); - logFile = NULL; -} - static int eqasc2uni (const unsigned char *a, const widechar * b, const int len) { @@ -5053,8 +5007,7 @@ lou_free () { ChainEntry *currentEntry; ChainEntry *previousEntry; - if (logFile != NULL) - fclose (logFile); + closeLogFile(); if (tableChain != NULL) { currentEntry = tableChain; @@ -5162,82 +5115,3 @@ debugHook () char *hook = "debug hook"; printf ("%s\n", hook); } - -static void defaultLogCallback(int level, const char *message) -{ - lou_logPrint("%s", message); // lou_logPrint takes formatting, protect against % in message -} - -static logcallback logCallbackFunction = defaultLogCallback; -void EXPORT_CALL lou_registerLogCallback(logcallback callback) -{ - if (callback == NULL) - logCallbackFunction = defaultLogCallback; - else - logCallbackFunction = callback; -} - -static logLevels logLevel = LOG_INFO; -void EXPORT_CALL lou_setLogLevel(logLevels level) -{ - logLevel = level; -} - -void EXPORT_CALL lou_log(logLevels level, const char *format, ...) -{ - if (format == NULL) - return; - if (level < logLevel) - return; - if (logCallbackFunction != NULL) - { -#ifdef _WIN32 - float f = 2.3; // Needed to force VC++ runtime floating point support -#endif - char *s; - size_t len; - va_list argp; - va_start(argp, format); - len = vsnprintf(0, 0, format, argp); - va_end(argp); - if ((s = malloc(len+1)) != 0) - { - va_start(argp, format); - vsnprintf(s, len+1, format, argp); - va_end(argp); - logCallbackFunction(level, s); - free(s); - } - } -} - -void logWidecharBuf(logLevels level, const char *msg, const widechar *wbuf, int wlen) -{ - /* When calculating output size: - * Each wdiechar is represented in hex, thus needing two bytes for each - * byte in the widechar (sizeof(widechar) * 2) - * Allow space for the "0x%X " formatting (+ 3) - * Number of characters in widechar buffer (wlen * ) - * Give space for additional message (+ strlen(msg)) - * Remember the null terminator (+ 1) - */ - int logBufSize = (wlen * ((sizeof(widechar) * 2) + 3)) + 1 + strlen(msg); - char *logMessage = malloc(logBufSize); - char *p = logMessage; - char *formatString; - int i = 0; - if (sizeof(widechar) == 2) - formatString = "0x%04X "; - else - formatString = "0x%08X "; - for (i = 0; i < strlen(msg); i++) - logMessage[i] = msg[i]; - p += strlen(msg); - for (i = 0; i < wlen; i++) - { - p += sprintf(p, formatString, wbuf[i]); - } - p = '\0'; - lou_log(level, logMessage); - free(logMessage); -} diff --git a/liblouis/logging.c b/liblouis/logging.c index e69de29bb2..3b1e26cc3a 100644 --- a/liblouis/logging.c +++ b/liblouis/logging.c @@ -0,0 +1,170 @@ +/* liblouis Braille Translation and Back-Translation +Library + + Based on the Linux screenreader BRLTTY, copyright (C) 1999-2006 by + The BRLTTY Team + + Copyright (C) 2004, 2005, 2006 + ViewPlus Technologies, Inc. www.viewplus.com + and + JJB Software, Inc. www.jjb-software.com + All rights reserved + + This file is free software; you can redistribute it and/or modify it + under the terms of the Lesser or Library GNU General Public License + as published by the + Free Software Foundation; either version 3, or (at your option) any + later version. + + This file 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 + Library GNU General Public License for more details. + + You should have received a copy of the Library GNU General Public + License along with this program; see the file COPYING. If not, write to + the Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + Maintained by John J. Boyer john.boyer@jjb-software.com + */ + +#include +#include +#include +#include +#include + +#include "louis.h" + +void logWidecharBuf(logLevels level, const char *msg, const widechar *wbuf, int wlen) +{ + /* When calculating output size: + * Each wdiechar is represented in hex, thus needing two bytes for each + * byte in the widechar (sizeof(widechar) * 2) + * Allow space for the "0x%X " formatting (+ 3) + * Number of characters in widechar buffer (wlen * ) + * Give space for additional message (+ strlen(msg)) + * Remember the null terminator (+ 1) + */ + int logBufSize = (wlen * ((sizeof(widechar) * 2) + 3)) + 1 + strlen(msg); + char *logMessage = malloc(logBufSize); + char *p = logMessage; + char *formatString; + int i = 0; + if (sizeof(widechar) == 2) + formatString = "0x%04X "; + else + formatString = "0x%08X "; + for (i = 0; i < strlen(msg); i++) + logMessage[i] = msg[i]; + p += strlen(msg); + for (i = 0; i < wlen; i++) + { + p += sprintf(p, formatString, wbuf[i]); + } + p = '\0'; + lou_log(level, logMessage); + free(logMessage); +} + +static void defaultLogCallback(int level, const char *message) +{ + lou_logPrint("%s", message); // lou_logPrint takes formatting, protect against % in message +} + +static logcallback logCallbackFunction = defaultLogCallback; +void EXPORT_CALL lou_registerLogCallback(logcallback callback) +{ + if (callback == NULL) + logCallbackFunction = defaultLogCallback; + else + logCallbackFunction = callback; +} + +static logLevels logLevel = LOG_INFO; +void EXPORT_CALL lou_setLogLevel(logLevels level) +{ + logLevel = level; +} + +void EXPORT_CALL lou_log(logLevels level, const char *format, ...) +{ + if (format == NULL) + return; + if (level < logLevel) + return; + if (logCallbackFunction != NULL) + { +#ifdef _WIN32 + float f = 2.3; // Needed to force VC++ runtime floating point support +#endif + char *s; + size_t len; + va_list argp; + va_start(argp, format); + len = vsnprintf(0, 0, format, argp); + va_end(argp); + if ((s = malloc(len+1)) != 0) + { + va_start(argp, format); + vsnprintf(s, len+1, format, argp); + va_end(argp); + logCallbackFunction(level, s); + free(s); + } + } +} + + +static FILE *logFile = NULL; +static char initialLogFileName[256]; + +void EXPORT_CALL +lou_logFile (const char *fileName) +{ + if (fileName == NULL || fileName[0] == 0) + return; + if (initialLogFileName[0] == 0) + strcpy (initialLogFileName, fileName); + logFile = fopen (fileName, "wb"); + if (logFile == NULL && initialLogFileName[0] != 0) + logFile = fopen (initialLogFileName, "wb"); + if (logFile == NULL) + { + fprintf (stderr, "Cannot open log file %s\n", fileName); + logFile = stderr; + } +} + +void EXPORT_CALL +lou_logPrint (const char *format, ...) +{ +#ifndef __SYMBIAN32__ + va_list argp; + if (format == NULL) + return; + if (logFile == NULL && initialLogFileName[0] != 0) + logFile = fopen (initialLogFileName, "wb"); + if (logFile == NULL) + logFile = stderr; + va_start (argp, format); + vfprintf (logFile, format, argp); + fprintf (logFile, "\n"); + va_end (argp); +#endif +} + +void EXPORT_CALL +lou_logEnd () +{ + if (logFile != NULL) + fclose (logFile); + logFile = NULL; +} + +void closeLogFile() +{ + if (logFile != NULL) + fclose (logFile); +} \ No newline at end of file diff --git a/liblouis/louis.h b/liblouis/louis.h index cda7eb80d2..29af2abb97 100644 --- a/liblouis/louis.h +++ b/liblouis/louis.h @@ -568,6 +568,8 @@ void outOfMemory (); void logWidecharBuf(int level, const char *msg, const widechar *wbuf, int wlen); /* Helper for logging a widechar buffer */ +void closeLogFile(); +/* Function for closing loggin file */ #ifdef __cplusplus } #endif /* __cplusplus */ From 7272885b8c6044c04fbdb4aa878535a0a40aca98 Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Mon, 12 May 2014 13:54:43 +0100 Subject: [PATCH 28/54] Changed a printf statement to logging --- liblouis/compileTranslationTable.c | 53 +----------------------------- 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index ed37fcb048..4d259025f5 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -68,57 +68,7 @@ strdupWrapper (const char *string) return address; } -char *EXPORT_CALL -lou_getProgramPath () -{ - char *path = NULL; - HMODULE handle; - - if ((handle = GetModuleHandle (NULL))) - { - size_t size = 0X80; - char *buffer = NULL; - - while (1) - { - buffer = reallocWrapper (buffer, size <<= 1); - - { - DWORD length = GetModuleFileName (handle, buffer, size); - - if (!length) - { - printf ("GetModuleFileName\n"); - exit (3); - 3; - } - - if (length < size) - { - buffer[length] = 0; - path = strdupWrapper (buffer); - while (length > 0) - if (path[--length] == '\\') - break; - - strncpy (path, path, length + 1); - path[length + 1] = '\0'; - break; - } - } - } - - free (buffer); - } - else - { - printf ("GetModuleHandle\n"); - exit (3); - } - - return path; -} #define PATH_SEP ';' #define DIR_SEP '\\' @@ -131,8 +81,7 @@ lou_getProgramPath () void outOfMemory () { - fprintf (stderr, - "liblouis: Insufficient memory\n"); + lou_log(LOG_FATAL, "liblouis: Insufficient memory\n"); exit (3); } From 619b6f56785a224c7f7a34cbe1a42e68a11d2295 Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Mon, 12 May 2014 22:24:53 +0100 Subject: [PATCH 29/54] Restored some code accidentally removed and removal of some nonsense code. --- liblouis/compileTranslationTable.c | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index 4d259025f5..461f0015a2 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -69,6 +69,56 @@ strdupWrapper (const char *string) } +char *EXPORT_CALL +lou_getProgramPath () +{ + char *path = NULL; + HMODULE handle; + + if ((handle = GetModuleHandle (NULL))) + { + size_t size = 0X80; + char *buffer = NULL; + + while (1) + { + buffer = reallocWrapper (buffer, size <<= 1); + + { + DWORD length = GetModuleFileName (handle, buffer, size); + + if (!length) + { + printf ("GetModuleFileName\n"); + exit (3); + } + + if (length < size) + { + buffer[length] = 0; + path = strdupWrapper (buffer); + + while (length > 0) + if (path[--length] == '\\') + break; + + strncpy (path, path, length + 1); + path[length + 1] = '\0'; + break; + } + } + } + + free (buffer); + } + else + { + printf ("GetModuleHandle\n"); + exit (3); + } + + return path; +} #define PATH_SEP ';' #define DIR_SEP '\\' From 056b7e21c1aafc1f1916ed4fa7b8af9633b41691 Mon Sep 17 00:00:00 2001 From: Mesar Hameed Date: Thu, 15 May 2014 10:11:19 +0200 Subject: [PATCH 30/54] logging.c: corrected metadata. --- liblouis/logging.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/liblouis/logging.c b/liblouis/logging.c index 3b1e26cc3a..d85a97465f 100644 --- a/liblouis/logging.c +++ b/liblouis/logging.c @@ -1,13 +1,7 @@ -/* liblouis Braille Translation and Back-Translation -Library +/* liblouis Braille Translation and Back-Translation Library - Based on the Linux screenreader BRLTTY, copyright (C) 1999-2006 by - The BRLTTY Team - - Copyright (C) 2004, 2005, 2006 - ViewPlus Technologies, Inc. www.viewplus.com - and - JJB Software, Inc. www.jjb-software.com + Copyright (C) 2014 ViewPlus Technologies, Inc. www.viewplus.com + and the liblouis team. http://liblouis.org All rights reserved This file is free software; you can redistribute it and/or modify it @@ -25,8 +19,6 @@ Library License along with this program; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Maintained by John J. Boyer john.boyer@jjb-software.com */ #include @@ -167,4 +159,4 @@ void closeLogFile() { if (logFile != NULL) fclose (logFile); -} \ No newline at end of file +} From 2e8f4bb2e390c369f622557969aba9f71b79e3f6 Mon Sep 17 00:00:00 2001 From: Bert Frees Date: Thu, 15 May 2014 10:48:01 +0200 Subject: [PATCH 31/54] Update documentation with Michael's new logging stuff. --- doc/liblouis.texi | 88 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 22 deletions(-) diff --git a/doc/liblouis.texi b/doc/liblouis.texi index fc07c456c9..c95839fe2c 100644 --- a/doc/liblouis.texi +++ b/doc/liblouis.texi @@ -148,6 +148,8 @@ Programming with liblouis * lou_compileString:: * lou_dotsToChar:: * lou_charToDots:: +* lou_registerLogCallback:: +* lou_setLogLevel:: * lou_logFile:: * lou_logPrint:: * lou_logEnd:: @@ -1948,6 +1950,8 @@ inverse of forward translation. * lou_compileString:: * lou_dotsToChar:: * lou_charToDots:: +* lou_registerLogCallback:: +* lou_setLogLevel:: * lou_logFile:: * lou_logPrint:: * lou_logEnd:: @@ -1992,21 +1996,19 @@ License along with Liblouis. If not, see You use the liblouis library by calling the following functions, @code{lou_translateString}, @code{lou_backTranslateString}, -@code{lou_logFile}, @code{lou_logPrint}, -@code{lou_endLog}, @code{lou_getTable}, -@code{lou_translate}, @code{lou_backTranslate}, @code{lou_hyphenate}, -@code{lou_charToDots}, -@code{lou_dotsToChar}, -@code{lou_compileString}, @code{lou_readCharFromFile}, -@code{lou_version} and @code{lou_free}. -These are described below. The header file, @file{liblouis.h}, also -contains brief descriptions. Liblouis is written in straight C. It has -just three code modules, @file{compileTranslationTable.c}, +@code{lou_registerLogCallback}, @code{lou_setLogLevel}, +@code{lou_logFile}, @code{lou_logPrint}, @code{lou_logEnd}, +@code{lou_getTable}, @code{lou_translate}, @code{lou_backTranslate}, +@code{lou_hyphenate}, @code{lou_charToDots}, @code{lou_dotsToChar}, +@code{lou_compileString}, @code{lou_readCharFromFile}, +@code{lou_version} and @code{lou_free}. These are described +below. The header file, @file{liblouis.h}, also contains brief +descriptions. Liblouis is written in straight C. It has four code +modules, @file{compileTranslationTable.c}, @file{logging.c}, @file{lou_translateString.c} and @file{lou_backTranslateString.c}. In addition, there are two header files, @file{liblouis.h}, which defines -the API, and @file{louis.h}, used only internally and by liblouisxml. -The latter includes -@file{liblouis.h}. +the API, and @file{louis.h}, used only internally and by liblouisxml. +The latter includes @file{liblouis.h}. Persons who wish to use liblouis from Python may want to skip ahead to @ref{Python bindings}. @@ -2018,9 +2020,9 @@ yet been compiled @file{compileTranslationTable.c} checks it for correctness and compiles it into an efficient internal representation. The main entry point is @code{lou_getTable}. Since it is the module that keeps track of memory usage, it also contains the @code{lou_free} -function. In addition, it contains the @code{lou_logFile}, -@code{lou_logPrint} and @code{lou_endLog} functions, plus some utility -functions which are +function. In addition, it contains the @code{lou_registerLogCallback}, +@code{lou_setLogLevel}, @code{lou_logFile}, @code{lou_logPrint} and +@code{lou_logEnd} functions, plus some utility functions which are used by the other modules. By default, liblouis handles all characters internally as 16-bit @@ -2396,7 +2398,7 @@ consisting of characters according to the specifications in liblouis format or Unicode braille. The function returns 1 on success and 0 on failure. -@node lou_charToDots, lou_logFile, lou_dotsToChar, Programming with liblouis +@node lou_charToDots, lou_registerLogCallback, lou_dotsToChar, Programming with liblouis @section lou_charToDots @findex lou_charToDots @@ -2414,7 +2416,49 @@ length of both @code{inbuf} and @code{outbuf}. The dot patterns in not set and in Unicode format if it is set. The function returns 1 on success and 0 on failure. -@node lou_logFile, lou_logPrint, lou_charToDots, Programming with liblouis +@node lou_registerLogCallback, lou_setLogLevel, lou_charToDots, Programming with liblouis +@section lou_registerLogCallback +@findex lou_registerLogCallback + +@example +typedef void (*logcallback)(int level, const char *message); +void lou_registerLogCallback(logcallback callback); +@end example + +This function can be used to register a custom logging callback. The +callback must take a single argument, the message string. By default +log messages are printed to stderr, or if a filename was specified +with @code{lou_logFile} then messages are logged to that +file. @code{lou_registerLogCallback} overrides the default +callback. Passing NULL resets to the default callback. + +@node lou_setLogLevel, lou_logFile, lou_registerLogCallback, Programming with liblouis +@section lou_setLogLevel +@findex lou_setLogLevel + +@example +typedef enum +{ + LOG_ALL = -2147483648, + LOG_DEBUG = 10000, + LOG_INFO = 20000, + LOG_WARN = 30000, + LOG_ERROR = 40000, + LOG_FATAL = 50000, + LOG_OFF = 2147483647 +} logLevels; +void lou_setLogLevel(logLevels level); +@end example + +This function can be used to influence the amount of logging, from +fatal error messages only to detailed debugging messages. Supported +values are @code{LOG_DEBUG}, @code{LOG_INFO}, @code{LOG_WARN}, +@code{LOG_ERROR}, @code{LOG_FATAL} and @code{LOG_OFF}. Enabling +logging at a given level also enables logging at all higher +levels. Setting the level to @code{LOG_OFF} disables logging. The +default level is @code{LOG_INFO}. + +@node lou_logFile, lou_logPrint, lou_setLogLevel, Programming with liblouis @section lou_logFile @findex lou_logFile @@ -2489,10 +2533,10 @@ void *lou_getTable (char *tablelist); commas, as explained previously (@pxref{translation-tables,,@code{tableList} parameter in @code{lou_translateString}}). If no errors are found this function -returns a pointer to the compiled table. If errors are found messages -are printed to the log file, which is stderr unless a different -filename has been given using the @code{lou_logFile} function. -Errors result in a @code{NULL} pointer being returned. +returns a pointer to the compiled table. If errors are found error +messages are logged to the log callback (see +@code{lou_registerLogCallback}). Errors result in a @code{NULL} +pointer being returned. @node lou_readCharFromFile, lou_free, lou_getTable, Programming with liblouis @section lou_readCharFromFile From d0ccc463dc255049cfe0321d506a8837fa7af955 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Thu, 15 May 2014 14:37:49 +0200 Subject: [PATCH 32/54] Ignore generated files --- .gitignore | 120 +++++++++++++++-------------------------------------- 1 file changed, 34 insertions(+), 86 deletions(-) diff --git a/.gitignore b/.gitignore index 2496b149c7..389cc5116d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,22 @@ +.libs +.deps +*.o +*.lo +*.la +*.pyc +*~ +Makefile +Makefile.in +TAGS # / /configure -/Makefile.in /liblouis.pc /config.log /depcomp /config.guess /ltmain.sh /config.sub -/Makefile /config.status /libtool /autom4te.cache @@ -16,13 +24,6 @@ /aclocal.m4 /install-sh /INSTALL -/TAGS -.libs -*.o -*.lo -*.la -*.pyc -*~ # Eclipse .cproject @@ -31,6 +32,7 @@ # /build-aux/ /build-aux/config.guess /build-aux/config.sub +/build-aux/compile /build-aux/depcomp /build-aux/install-sh /build-aux/ltmain.sh @@ -46,8 +48,6 @@ /contrib/liblouis.elc # /doc/ -/doc/Makefile -/doc/Makefile.in /doc/mdate-sh /doc/texinfo.tex /doc/version.texi @@ -71,20 +71,12 @@ /doc/liblouis.cp # /gnulib/ -/gnulib/Makefile.in -/gnulib/Makefile -/gnulib/.deps /gnulib/getopt.h /gnulib/stdlib.h /gnulib/unistd.h -/gnulib/TAGS # /liblouis/ -/liblouis/Makefile.in -/liblouis/.deps -/liblouis/Makefile /liblouis/stamp-h1 -/liblouis/TAGS /liblouis/config.h.in /liblouis/config.h /liblouis/liblouis.h @@ -95,90 +87,54 @@ /m4/ltsugar.m4 /m4/ltversion.m4 /m4/lt~obsolete.m4 -/m4/Makefile.in -/m4/Makefile # /man/ -/man/Makefile.in -/man/Makefile -/man/lou_checktable.1 -/man/lou_translate.1 +/man/lou_allround.1 /man/lou_checkhyphens.1 +/man/lou_checktable.1 /man/lou_debug.1 -/man/lou_allround.1 +/man/lou_trace.1 +/man/lou_translate.1 # /python/ -/python/Makefile -/python/Makefile.in /python/build # /python/louis/ -/python/louis/Makefile -/python/louis/Makefile.in /python/louis/__init__.py -# /tables/ -/tables/Makefile -/tables/Makefile.in - # /tests/ -/tests/Makefile -/tests/Makefile.in -/tests/.deps -/tests/capitalized_word -/tests/capitalized_with_sentance -/tests/inpos_compbrl -/tests/present_progressive /tests/*.exe /tests/*.log /tests/*.trs -/tests/TAGS -/tests/lastworditalafter +/tests/backtranslate_with_letsign +/tests/capitalized_with_sentance +/tests/capitalized_word /tests/en_gb_g1_italics -/tests/pass2 -/tests/letterDefTest -/tests/pass2_inpos -/tests/uplow_with_unicode -/tests/inpos -/tests/inpos_match_replace -/tests/squash_space -/tests/hyphenate -/tests/pass1Only -/tests/outpos /tests/getTable -/tests/typeform -/tests/pass0_typebuf /tests/hash_collision +/tests/hyphenate /tests/hyphenate_achena /tests/hyphenate_alderen /tests/hyphenate_straightforward /tests/hyphenate_xxx +/tests/inpos +/tests/inpos_compbrl +/tests/inpos_match_replace +/tests/lastworditalafter +/tests/letterDefTest +/tests/outpos +/tests/pass0_typebuf +/tests/pass1Only +/tests/pass2 +/tests/pass2_inpos +/tests/present_progressive /tests/resolve_table - -# /tests/doctests/ -/tests/doctests/Makefile -/tests/doctests/Makefile.in - -# /tests/harness/ -/tests/harness/Makefile.in -/tests/harness/Makefile - -# /tests/harnessSources/ -/tests/harnessSources/Makefile.in -/tests/harnessSources/Makefile - -# /tests/tables/ -/tests/tables/Makefile.in -/tests/tables/Makefile - -# /tests/tables/moreTables/ -/tests/tables/moreTables/Makefile.in -/tests/tables/moreTables/Makefile +/tests/resolve_table.h +/tests/squash_space +/tests/typeform +/tests/uplow_with_unicode # /tools/ -/tools/Makefile -/tools/Makefile.in -/tools/.deps /tools/lou_allround /tools/lou_checkhyphens /tools/lou_checktable @@ -186,12 +142,4 @@ /tools/lou_trace /tools/lou_translate /tools/*.exe -/tools/TAGS - -# /windows/ -/windows/Makefile.in -/windows/Makefile -# /windows/include/ -/windows/include/Makefile.in -/windows/include/Makefile From ae99f4cf754499be58e343e3c11c5ef38bf1d478 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Thu, 15 May 2014 14:39:51 +0200 Subject: [PATCH 33/54] Ignore files generated when building pdf documentation --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 389cc5116d..c54ce256b4 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,7 @@ TAGS /doc/liblouis.opcodes /doc/liblouis.aux /doc/liblouis.cp +/doc/liblouis.t2p/ # /gnulib/ /gnulib/getopt.h @@ -142,4 +143,3 @@ TAGS /tools/lou_trace /tools/lou_translate /tools/*.exe - From f8cf73d5be37e18443fcc9ab0c70ad79e96e1cd2 Mon Sep 17 00:00:00 2001 From: Bert Frees Date: Thu, 15 May 2014 19:53:56 +0200 Subject: [PATCH 34/54] Escape curly braces in liblouis.texi --- doc/liblouis.texi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/liblouis.texi b/doc/liblouis.texi index c95839fe2c..c42ea22aee 100644 --- a/doc/liblouis.texi +++ b/doc/liblouis.texi @@ -2430,7 +2430,7 @@ callback must take a single argument, the message string. By default log messages are printed to stderr, or if a filename was specified with @code{lou_logFile} then messages are logged to that file. @code{lou_registerLogCallback} overrides the default -callback. Passing NULL resets to the default callback. +callback. Passing @code{NULL} resets to the default callback. @node lou_setLogLevel, lou_logFile, lou_registerLogCallback, Programming with liblouis @section lou_setLogLevel @@ -2438,7 +2438,7 @@ callback. Passing NULL resets to the default callback. @example typedef enum -{ +@{ LOG_ALL = -2147483648, LOG_DEBUG = 10000, LOG_INFO = 20000, @@ -2446,7 +2446,7 @@ typedef enum LOG_ERROR = 40000, LOG_FATAL = 50000, LOG_OFF = 2147483647 -} logLevels; +@} logLevels; void lou_setLogLevel(logLevels level); @end example From 5723e9635a533f3d25b363cccdd4200e896a7556 Mon Sep 17 00:00:00 2001 From: Bert Frees Date: Thu, 15 May 2014 20:08:52 +0200 Subject: [PATCH 35/54] Set level of some debug messages to LOG_DEBUG --- liblouis/lou_translateString.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/liblouis/lou_translateString.c b/liblouis/lou_translateString.c index bc08f75b07..f6ff708496 100644 --- a/liblouis/lou_translateString.c +++ b/liblouis/lou_translateString.c @@ -78,8 +78,8 @@ trace_translate (const char *tableList, const widechar * inbufx, if (tableList == NULL || inbufx == NULL || inlen == NULL || outbuf == NULL || outlen == NULL) return 0; - lou_log(LOG_INFO, "Performing translation: tableList=%s, inlen=%d", tableList, *inlen); - logWidecharBuf(LOG_INFO, "Inbuf=", inbufx, *inlen); + lou_log(LOG_DEBUG, "Performing translation: tableList=%s, inlen=%d", tableList, *inlen); + logWidecharBuf(LOG_DEBUG, "Inbuf=", inbufx, *inlen); if ((modex & otherTrans)) return other_translate (tableList, inbufx, inlen, outbuf, outlen, @@ -273,8 +273,8 @@ trace_translate (const char *tableList, const widechar * inbufx, } if (rulesLen != NULL) *rulesLen = appliedRulesCount; - lou_log(LOG_INFO, "Translation complete: outlen=%d", *outlen); - logWidecharBuf(LOG_INFO, "Outbuf=", (const widechar *)outbuf, *outlen); + lou_log(LOG_DEBUG, "Translation complete: outlen=%d", *outlen); + logWidecharBuf(LOG_DEBUG, "Outbuf=", (const widechar *)outbuf, *outlen); return goodTrans; } From c8424a5f9f1101b4d8a3b438eb6655fcc061afce Mon Sep 17 00:00:00 2001 From: Bert Frees Date: Thu, 15 May 2014 20:41:24 +0200 Subject: [PATCH 36/54] Add a test for logging --- .gitignore | 1 + tests/Makefile.am | 6 ++++- tests/logging.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 tests/logging.c diff --git a/.gitignore b/.gitignore index 2496b149c7..1ffe12da88 100644 --- a/.gitignore +++ b/.gitignore @@ -154,6 +154,7 @@ /tests/hyphenate_straightforward /tests/hyphenate_xxx /tests/resolve_table +/tests/logging # /tests/doctests/ /tests/doctests/Makefile diff --git a/tests/Makefile.am b/tests/Makefile.am index adbca8cd25..9e26249b5f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -122,6 +122,9 @@ hash_collision_SOURCES = \ resolve_table_SOURCES = \ resolve_table.c +logging_SOURCES = \ + logging.c + check_PROGRAMS = \ pass2 \ pass2_inpos \ @@ -147,7 +150,8 @@ check_PROGRAMS = \ typeform \ pass0_typebuf \ hash_collision \ - resolve_table + resolve_table \ + logging dist_check_SCRIPTS = \ diff --git a/tests/logging.c b/tests/logging.c new file mode 100644 index 0000000000..b04319f743 --- /dev/null +++ b/tests/logging.c @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include "louis.h" + +static char log_buffer[1024]; +static int log_buffer_pos = 0; + +static void +log_to_buffer(int level, const char *message) +{ + switch(level) { + case LOG_DEBUG: + log_buffer_pos += sprintf(&log_buffer[log_buffer_pos], "[DEBUG] %s\n", message); + break; + case LOG_INFO: + log_buffer_pos += sprintf(&log_buffer[log_buffer_pos], "[INFO] %s\n", message); + break; + case LOG_WARN: + log_buffer_pos += sprintf(&log_buffer[log_buffer_pos], "[WARN] %s\n", message); + break; + case LOG_ERROR: + log_buffer_pos += sprintf(&log_buffer[log_buffer_pos], "[ERROR] %s\n", message); + break; + case LOG_FATAL: + log_buffer_pos += sprintf(&log_buffer[log_buffer_pos], "[FATAL] %s\n", message); + break; + } +} + +static int +assert_string_equals(char * expected, char * actual) +{ + if (strcmp(expected, actual)) + { + printf("Expected \"%s\" but received \"%s\"\n", expected, actual); + return 1; + } + return 0; +} + +static int +assert_log_buffer_equals(char * expected) +{ + return assert_string_equals(expected, log_buffer); +} + +int +main(int argc, char **argv) +{ + lou_registerLogCallback(log_to_buffer); + log_buffer_pos = 0; + lou_setLogLevel(LOG_WARN); + lou_log(LOG_ERROR, "foo"); + lou_log(LOG_INFO, "bar"); + lou_setLogLevel(LOG_INFO); + lou_log(LOG_INFO, "baz"); + return assert_log_buffer_equals("[ERROR] foo\n[INFO] baz\n"); +} From 983d5235b0d3967b2e6605cb570d739227fe7fc4 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Tue, 20 May 2014 09:19:50 +0200 Subject: [PATCH 37/54] Change the download link to point to liblouis.org --- ANNOUNCEMENT | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ANNOUNCEMENT b/ANNOUNCEMENT index 9b33d08523..9f236302a1 100644 --- a/ANNOUNCEMENT +++ b/ANNOUNCEMENT @@ -3,7 +3,7 @@ liblouis 2.5.4 has been released The liblouis developer team is proud to announce the liblouis release 2.5.4. The release is available for download at: - http://liblouis.github.io/downloads/ + http://liblouis.org/downloads/ Introduction ------------ @@ -13,7 +13,7 @@ features support for computer, literary and math braille, supports contracted and uncontracted translation for many, many languages[1]. It plays an important role in an open source accessibility stack and is used by screenreaders such as NVDA and Orca. A companion project -liblouisutdml/liblouisxml[2] deals with formatting of braille. +liblouisutdml[2] deals with formatting of braille. Changes in this release ----------------------- @@ -124,7 +124,6 @@ Share and Enjoy! Footnotes --------- -[1] See http://code.google.com/p/liblouis/ -[2] See http://code.google.com/p/liblouisutdml/ and - http://code.google.com/p/liblouisxml/ +[1] See https://github.com/liblouis/liblouis/tree/master/tables +[2] See http://code.google.com/p/liblouisutdml/ From 71647d64baea4a737783ddca56640372a316eaeb Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Tue, 20 May 2014 09:20:28 +0200 Subject: [PATCH 38/54] Adapt the build instructions to the git repo i.e. you'll have to fetch from git instead of svn now and when building a release you'll have to tag via git. --- HACKING | 66 +++++++++++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/HACKING b/HACKING index 42141657af..c7907f7774 100644 --- a/HACKING +++ b/HACKING @@ -1,7 +1,7 @@ This HACKING file describes the development environment. -*- org -*- Copyright (C) 2008, 2009, 2011 ViewPlus Technologies, Inc. and Abilitiessoft, Inc. - Copyright (C) 2012, 2013 Swiss Library for the Blind, Visually Impaired and Print Disabled + Copyright (C) 2012, 2013, 2014 Swiss Library for the Blind, Visually Impaired and Print Disabled Copying and distribution of this file, with or without modification, @@ -13,24 +13,21 @@ when hacking liblouis. * Developing ** Where to get it -The development sources are available through anonymous svn at Google -Code: +The development sources are available through git at github.com: - http://code.google.com/p/liblouis/ + https://github.com/liblouis/liblouis ** Build requirements This distribution uses Automake, Autoconf, and Libtool. If you are -getting the sources from svn (or change configure.ac), you'll need to +getting the sources from git (or change configure.ac), you'll need to have these tools installed to (re)build. Optionally (if you want to generate man pages) you'll also need help2man. All of these programs are available from ftp://ftp.gnu.org/gnu. ** Gnulib -This distribution also uses Gnulib (http://www.gnu.org/software/gnulib) -to share common files, with the files being checked in to svn. If you -want to update from the current gnulib, install gnulib, and then run - gnulib-tool --import -in the top-level directory. +This distribution also uses Gnulib (http://www.gnu.org/software/gnulib). If +you want to update from the current gnulib, install gnulib, and then run +gnulib-tool --import in the top-level directory. For the record, the first time invocation was gnulib-tool --import --lib=libgnu --source-base=gnulib \ @@ -42,9 +39,9 @@ gnulib/m4/gnulib-cache.m4. Given a source checkout of gnulib, you can update the files with gnulib-tool --import. ** How to build -After getting the sources from svn, with +After getting the sources from git, with - svn checkout http://liblouis.googlecode.com/svn/trunk/ liblouis + git clone https://github.com/liblouis/liblouis.git and installing the tools above, change to the liblouis directory and and bootstrap the project with the following command @@ -153,13 +150,13 @@ i.e. LIBLOUIS_REVISION and possibly LIBLOUIS_CURRENT and LIBLOUIS_AGE. ** Commit and tag Commit the changes and tag this version - svn cp https://liblouis.googlecode.com/svn/trunk \ - https://liblouis.googlecode.com/svn/tags/liblouis_1_3_8 + git tag -s liblouis_2_6_0 -m "Release 2.6.0" + git push origin liblouis_2_6_0 If you know the exact version number that needs to be tagged use - svn cp https://liblouis.googlecode.com/svn/trunk \ - https://liblouis.googlecode.com/svn/tags/liblouis_1_3_8 -r 109 + git tag -s liblouis_2_6_0 -m "Release 2.6.0" + git push origin liblouis_2_6_0 ** Make the release Check out a clean copy in a different directory, like /tmp. Run @@ -170,32 +167,31 @@ general sanity check. Run make dist. This will produce a tarball. ./autogen.sh && ./configure && make && make distcheck && make dist ** Upload -Upload tarball to Google project page, tag as "featured". This will -put the link on the main project page. Remove "featured" tag from -previous tarball release. +Add the tarball to the liblouis web site, i.e. add it under +$WEBSITE/downloads and add a link to it in $WEBSITE/downloads/index.textile. +See below for instructions on how to update the web site. ** Online documentation -The online documentation is hosted out of subversion of the Google -code site. To check it out - - svn co https://liblouis.googlecode.com/svn/documentation \ - liblouis-online-documentation - -then move the latest built documentation into this directory and check -it in - - cd liblouis-online-documentation - cp ../liblouis/doc/liblouis.html . - svn ci liblouis.html -m "Update online documentation" +The online documentation is part of the liblouis web site. To add it to the +site simply copy doc/liblouis.html to $WEBSITE/documentation/liblouis.html. +Make sure you add the proper YAML front matter. Again see below for +instructions on how to update the web site. + +** Web site maintenance +The liblouis web site at liblouis.org is maintained with the help of +github pages (https://pages.github.com/). To edit the site just check +out the repo at https://github.com/liblouis/liblouis.github.io. You'll +need to know a few things about Jekyll (http://jekyllrb.com/) and +textile (http://redcloth.org/textile/) the markup that is used to edit +the content. In order to update the site simply edit, commit and push. + +For the new release update the project web site. Add a post containing +the current NEWS to the _posts directory. ** Other web updates -Update the Google project page. Add the current NEWS to the front -page. - Also update the page on freshmeat (http://freshmeat.net/projects/liblouis/). ** Announce Send an announcement to the liblouis list liblouis-liblouisxml@freelists.org. See ANNOUNCEMENT for an example. - From 23079f315614def4c8eca82581a738ab2159f536 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Tue, 20 May 2014 12:16:46 +0200 Subject: [PATCH 39/54] Add a symlink so that github displays the README is a nice way --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 120000 README.md diff --git a/README.md b/README.md new file mode 120000 index 0000000000..100b93820a --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +README \ No newline at end of file From f726afa492623967ebb4bb3a3212ecb2795ef7ff Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Tue, 20 May 2014 16:53:02 +0200 Subject: [PATCH 40/54] Fix a memory leak When copying a string you need to hold on to the original reference so you can free it after. --- liblouis/compileTranslationTable.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index dc6e8530e0..ad4af77864 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -4627,7 +4627,8 @@ resolveSubtable (const char *table, const char *base, const char *searchPath) char *dir; int last; char *cp; - for (dir = strdup (searchPath + 1); ; dir = cp + 1) + char *searchPath_copy = strdup (searchPath + 1); + for (dir = searchPath_copy; ; dir = cp + 1) { for (cp = dir; *cp != '\0' && *cp != ','; cp++) ; @@ -4636,11 +4637,15 @@ resolveSubtable (const char *table, const char *base, const char *searchPath) if (dir == cp) dir = "."; sprintf (tableFile, "%s%c%s", dir, DIR_SEP, table); - if (stat (tableFile, &info) == 0 && !(info.st_mode & S_IFDIR)) - return tableFile; + if (stat (tableFile, &info) == 0 && !(info.st_mode & S_IFDIR)) + { + free(searchPath_copy); + return tableFile; + } if (last) break; } + free(searchPath_copy); } free (tableFile); return NULL; @@ -4666,6 +4671,7 @@ defaultTableResolver (const char *tableList, const char *base) char searchPath[MAXSTRING]; char **tableFiles; char *subTable; + char *tableList_copy; char *cp; char *path; int last; @@ -4697,7 +4703,8 @@ defaultTableResolver (const char *tableList, const char *base) /* Resolve subtables */ k = 0; - for (subTable = strdup (tableList); ; subTable = cp + 1) + tableList_copy = strdup (tableList); + for (subTable = tableList_copy; ; subTable = cp + 1) { for (cp = subTable; *cp != '\0' && *cp != ','; cp++); last = (*cp == '\0'); @@ -4705,6 +4712,7 @@ defaultTableResolver (const char *tableList, const char *base) if (!(tableFiles[k++] = resolveSubtable (subTable, base, searchPath))) { lou_logPrint ("Cannot resolve table '%s'", subTable); + free(tableList_copy); free (tableFiles); return NULL; } @@ -4713,6 +4721,7 @@ defaultTableResolver (const char *tableList, const char *base) if (last) break; } + free(tableList_copy); tableFiles[k] = NULL; return tableFiles; } From 63dd6761195b9b3ea28fbe067f7a2b7e9e17162d Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Tue, 20 May 2014 16:56:27 +0200 Subject: [PATCH 41/54] Also free the tableFiles array While this frees parts of the memory we neglect to free the strings inside the array. This still needs to be done. --- liblouis/compileTranslationTable.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index ad4af77864..80edbd493f 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -4785,6 +4785,7 @@ includeFile (FileInfo * nested, CharsString * includedFile) int k; char includeThis[MAXSTRING]; char **tableFiles; + int rv; for (k = 0; k < includedFile->length; k++) includeThis[k] = (char) includedFile->chars[k]; includeThis[k] = 0; @@ -4792,15 +4793,19 @@ includeFile (FileInfo * nested, CharsString * includedFile) if (tableFiles == NULL) { errorCount++; + free(tableFiles); return 0; } if (tableFiles[1] != NULL) { errorCount++; + free(tableFiles); lou_logPrint ("Table list not supported in include statement: 'include %s'", includeThis); return 0; } - return compileFile (*tableFiles); + rv = compileFile (*tableFiles); + free(tableFiles); + return rv; } /** @@ -4845,6 +4850,7 @@ compileTranslationTable (const char *tableList) /* Clean up after compiling files */ cleanup: + free(tableFiles); if (characterClasses) deallocateCharacterClasses (); if (ruleNames) From 22b7ecd3f2461c6bbf148a8c7250ef0b2ad0e23e Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Tue, 20 May 2014 17:15:19 +0200 Subject: [PATCH 42/54] Ignore valgrind log files --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index c54ce256b4..045c12fc98 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,9 @@ TAGS /install-sh /INSTALL +# valgrind +/valgrind.log + # Eclipse .cproject .project @@ -143,3 +146,4 @@ TAGS /tools/lou_trace /tools/lou_translate /tools/*.exe + From 15622794eb22dfdbb10e5c52e507bafc03e2be93 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Wed, 21 May 2014 08:21:15 +0200 Subject: [PATCH 43/54] Also free the tableList With this patch all the leaks should be gone --- liblouis/compileTranslationTable.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index 80edbd493f..f1d75d25fe 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -4775,7 +4775,17 @@ compileFile (const char *fileName) return 0; } -/* +/** + * Macro to free a char** array + */ +#define free_tablelist(list) { \ + char **string; \ + for (string = list; *string; string++) \ + free(*string); \ + free(list); \ + } + +/** * Implement include opcode * */ @@ -4804,7 +4814,7 @@ includeFile (FileInfo * nested, CharsString * includedFile) return 0; } rv = compileFile (*tableFiles); - free(tableFiles); + free_tablelist(tableFiles); return rv; } @@ -4850,7 +4860,7 @@ compileTranslationTable (const char *tableList) /* Clean up after compiling files */ cleanup: - free(tableFiles); + free_tablelist(tableFiles); if (characterClasses) deallocateCharacterClasses (); if (ruleNames) From 9cec8663ec2ac8af2e5507064facdbdd432d2745 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Wed, 21 May 2014 08:33:24 +0200 Subject: [PATCH 44/54] Do not free tableFiles when it is NULL and improve the naming --- liblouis/compileTranslationTable.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index f1d75d25fe..7f7e9f42c8 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -4778,11 +4778,11 @@ compileFile (const char *fileName) /** * Macro to free a char** array */ -#define free_tablelist(list) { \ - char **string; \ - for (string = list; *string; string++) \ - free(*string); \ - free(list); \ +#define free_tablefiles(tables) { \ + char **table; \ + for (table = tables; *table; table++) \ + free(*table); \ + free(tables); \ } /** @@ -4803,18 +4803,17 @@ includeFile (FileInfo * nested, CharsString * includedFile) if (tableFiles == NULL) { errorCount++; - free(tableFiles); return 0; } if (tableFiles[1] != NULL) { errorCount++; - free(tableFiles); + free_tablefiles(tableFiles) lou_logPrint ("Table list not supported in include statement: 'include %s'", includeThis); return 0; } rv = compileFile (*tableFiles); - free_tablelist(tableFiles); + free_tablefiles(tableFiles); return rv; } @@ -4860,7 +4859,7 @@ compileTranslationTable (const char *tableList) /* Clean up after compiling files */ cleanup: - free_tablelist(tableFiles); + free_tablefiles(tableFiles); if (characterClasses) deallocateCharacterClasses (); if (ruleNames) From a53250d5c89e82a0b289073c6fd509e2eaab1ee0 Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Wed, 21 May 2014 11:36:30 +0200 Subject: [PATCH 45/54] Do not free NULL When tableFiles is NULL the macro tried to free it anyway. Change the macro into a function and test for NULL before freeing. This fixes a segfault in the tests. --- liblouis/compileTranslationTable.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index 7f7e9f42c8..2113698f32 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -4776,14 +4776,16 @@ compileFile (const char *fileName) } /** - * Macro to free a char** array + * Free a char** array */ -#define free_tablefiles(tables) { \ - char **table; \ - for (table = tables; *table; table++) \ - free(*table); \ - free(tables); \ - } +static void +free_tablefiles(char **tables) { + char **table; + if (!tables) return; + for (table = tables; *table; table++) + free(*table); + free(tables); +} /** * Implement include opcode @@ -4808,7 +4810,7 @@ includeFile (FileInfo * nested, CharsString * includedFile) if (tableFiles[1] != NULL) { errorCount++; - free_tablefiles(tableFiles) + free_tablefiles(tableFiles); lou_logPrint ("Table list not supported in include statement: 'include %s'", includeThis); return 0; } From 0e8d4e3870d65e7696cedf739a325506f8ef7e8d Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Wed, 21 May 2014 11:48:49 +0200 Subject: [PATCH 46/54] Add a NEWS entry for the fix of the memory leak --- NEWS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 6e5ab7eba9..a951ad242f 100644 --- a/NEWS +++ b/NEWS @@ -7,8 +7,10 @@ liblouis NEWS -- history of user-visible changes. -*- org -*- ** Bug fixes - Fixed bug to prevent removal of \xffff between largesign rules. This solves a LibLouisUTDML bug where \xffff is used as a segment delimiter. -_ Fixed a bug in backtranslation, when a letsign was encountered, the +- Fixed a bug in backtranslation, when a letsign was encountered, the letsign was being applied beyond the element it applied to. +- Fix memory leaks in the default table resolver introduced in the + previous release. ** Braille table improvements - Fix for Norwegian where letsign is affecting some extra characters From f01a14db0f9b4fe67ce1af503b39db43966c38ba Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Wed, 21 May 2014 12:57:43 +0100 Subject: [PATCH 47/54] Changed logging to make lou_log and lou_logPrint not public --- liblouis/compileTranslationTable.c | 24 +++++++++++------------ liblouis/liblouis.h.in | 7 +------ liblouis/logging.c | 31 +++++++++++------------------- liblouis/lou_translateString.c | 4 ++-- liblouis/louis.h | 1 + liblouis/wrappers.c | 4 ++-- 6 files changed, 29 insertions(+), 42 deletions(-) diff --git a/liblouis/compileTranslationTable.c b/liblouis/compileTranslationTable.c index 461f0015a2..383fb13607 100644 --- a/liblouis/compileTranslationTable.c +++ b/liblouis/compileTranslationTable.c @@ -131,7 +131,7 @@ lou_getProgramPath () void outOfMemory () { - lou_log(LOG_FATAL, "liblouis: Insufficient memory\n"); + logMessage(LOG_FATAL, "liblouis: Insufficient memory\n"); exit (3); } @@ -663,10 +663,10 @@ compileError (FileInfo * nested, char *format, ...) #endif va_end (arguments); if (nested) - lou_log (LOG_ERROR, "%s:%d: error: %s", nested->fileName, + logMessage (LOG_ERROR, "%s:%d: error: %s", nested->fileName, nested->lineNumber, buffer); else - lou_log (LOG_ERROR, "error: %s", buffer); + logMessage (LOG_ERROR, "error: %s", buffer); errorCount++; #endif } @@ -685,10 +685,10 @@ compileWarning (FileInfo * nested, char *format, ...) #endif va_end (arguments); if (nested) - lou_log (LOG_WARN, "%s:%d: warning: %s", nested->fileName, + logMessage (LOG_WARN, "%s:%d: warning: %s", nested->fileName, nested->lineNumber, buffer); else - lou_log (LOG_WARN, "warning: %s", buffer); + logMessage (LOG_WARN, "warning: %s", buffer); warningCount++; #endif } @@ -4430,7 +4430,7 @@ lou_readCharFromFile (const char *fileName, int *mode) nested.lineNumber = 0; if (!(nested.in = fopen (nested.fileName, "r"))) { - lou_log (LOG_ERROR, "Cannot open file '%s'", nested.fileName); + logMessage (LOG_ERROR, "Cannot open file '%s'", nested.fileName); *mode = 1; return EOF; } @@ -4657,7 +4657,7 @@ defaultTableResolver (const char *tableList, const char *base) *cp = '\0'; if (!(tableFiles[k++] = resolveSubtable (subTable, base, searchPath))) { - lou_log (LOG_ERROR, "Cannot resolve table '%s'", subTable); + logMessage (LOG_ERROR, "Cannot resolve table '%s'", subTable); free (tableFiles); return NULL; } @@ -4714,7 +4714,7 @@ compileFile (const char *fileName) return 1; } else - lou_log (LOG_ERROR, "Cannot open table '%s'", nested.fileName); + logMessage (LOG_ERROR, "Cannot open table '%s'", nested.fileName); errorCount++; return 0; } @@ -4741,7 +4741,7 @@ includeFile (FileInfo * nested, CharsString * includedFile) if (tableFiles[1] != NULL) { errorCount++; - lou_log (LOG_ERROR, "Table list not supported in include statement: 'include %s'", includeThis); + logMessage (LOG_ERROR, "Table list not supported in include statement: 'include %s'", includeThis); return 0; } return compileFile (*tableFiles); @@ -4794,7 +4794,7 @@ compileTranslationTable (const char *tableList) if (ruleNames) deallocateRuleNames (); if (warningCount) - lou_log (LOG_WARN, "%d warnings issued", warningCount); + logMessage (LOG_WARN, "%d warnings issued", warningCount); if (!errorCount) { setDefaults (); @@ -4803,7 +4803,7 @@ compileTranslationTable (const char *tableList) } else { - lou_log (LOG_ERROR, "%d errors found.", errorCount); + logMessage (LOG_ERROR, "%d errors found.", errorCount); if (table) free (table); table = NULL; @@ -4891,7 +4891,7 @@ lou_getTable (const char *tableList) errorCount = fileCount = 0; table = getTable (tableList); if (!table) - lou_log (LOG_ERROR, "%s could not be found", tableList); + logMessage (LOG_ERROR, "%s could not be found", tableList); return table; } diff --git a/liblouis/liblouis.h.in b/liblouis/liblouis.h.in index 971e213605..9ca993905b 100644 --- a/liblouis/liblouis.h.in +++ b/liblouis/liblouis.h.in @@ -116,8 +116,6 @@ mode); int *outlen, formtype *typeform, char *spacing, int *outputPos, int *inputPos, int *cursorPos, int mode); - void EXPORT_CALL lou_logPrint (const char *format, ...); -/* prints error messages to a file */ void EXPORT_CALL lou_logFile (const char *filename); /* Specifies the name of the file to be used by lou_logPrint. If it is @@ -170,10 +168,7 @@ typedef void (*logcallback)(int level, const char *message); LOG_OFF = 2147483647 } logLevels; void EXPORT_CALL lou_setLogLevel(logLevels level); - - void EXPORT_CALL lou_log(logLevels level, const char *format, ...); -/* General log function for callback logging */ - +/* Set the level for logging callback to be called at */ void EXPORT_CALL lou_free (); /* This function should be called at the end of * the application to free all memory allocated by liblouis. */ diff --git a/liblouis/logging.c b/liblouis/logging.c index d85a97465f..fdb58e1a8f 100644 --- a/liblouis/logging.c +++ b/liblouis/logging.c @@ -40,8 +40,8 @@ void logWidecharBuf(logLevels level, const char *msg, const widechar *wbuf, int * Remember the null terminator (+ 1) */ int logBufSize = (wlen * ((sizeof(widechar) * 2) + 3)) + 1 + strlen(msg); - char *logMessage = malloc(logBufSize); - char *p = logMessage; + char *logMsg = malloc(logBufSize); + char *p = logMsg; char *formatString; int i = 0; if (sizeof(widechar) == 2) @@ -49,21 +49,18 @@ void logWidecharBuf(logLevels level, const char *msg, const widechar *wbuf, int else formatString = "0x%08X "; for (i = 0; i < strlen(msg); i++) - logMessage[i] = msg[i]; + logMsg[i] = msg[i]; p += strlen(msg); for (i = 0; i < wlen; i++) { p += sprintf(p, formatString, wbuf[i]); } p = '\0'; - lou_log(level, logMessage); - free(logMessage); + logMessage(level, logMsg); + free(logMsg); } -static void defaultLogCallback(int level, const char *message) -{ - lou_logPrint("%s", message); // lou_logPrint takes formatting, protect against % in message -} +static void defaultLogCallback(int level, const char *message); static logcallback logCallbackFunction = defaultLogCallback; void EXPORT_CALL lou_registerLogCallback(logcallback callback) @@ -80,7 +77,7 @@ void EXPORT_CALL lou_setLogLevel(logLevels level) logLevel = level; } -void EXPORT_CALL lou_log(logLevels level, const char *format, ...) +void logMessage(logLevels level, const char *format, ...) { if (format == NULL) return; @@ -129,22 +126,16 @@ lou_logFile (const char *fileName) } } -void EXPORT_CALL -lou_logPrint (const char *format, ...) +static void +defaultLogCallback (logLevels level, const char *message) { -#ifndef __SYMBIAN32__ - va_list argp; - if (format == NULL) + if (message == NULL) return; if (logFile == NULL && initialLogFileName[0] != 0) logFile = fopen (initialLogFileName, "wb"); if (logFile == NULL) logFile = stderr; - va_start (argp, format); - vfprintf (logFile, format, argp); - fprintf (logFile, "\n"); - va_end (argp); -#endif + fprintf (logFile, "%s\n", message); } void EXPORT_CALL diff --git a/liblouis/lou_translateString.c b/liblouis/lou_translateString.c index f6ff708496..935bd02ca3 100644 --- a/liblouis/lou_translateString.c +++ b/liblouis/lou_translateString.c @@ -78,7 +78,7 @@ trace_translate (const char *tableList, const widechar * inbufx, if (tableList == NULL || inbufx == NULL || inlen == NULL || outbuf == NULL || outlen == NULL) return 0; - lou_log(LOG_DEBUG, "Performing translation: tableList=%s, inlen=%d", tableList, *inlen); + logMessage(LOG_DEBUG, "Performing translation: tableList=%s, inlen=%d", tableList, *inlen); logWidecharBuf(LOG_DEBUG, "Inbuf=", inbufx, *inlen); if ((modex & otherTrans)) return other_translate (tableList, inbufx, @@ -273,7 +273,7 @@ trace_translate (const char *tableList, const widechar * inbufx, } if (rulesLen != NULL) *rulesLen = appliedRulesCount; - lou_log(LOG_DEBUG, "Translation complete: outlen=%d", *outlen); + logMessage(LOG_DEBUG, "Translation complete: outlen=%d", *outlen); logWidecharBuf(LOG_DEBUG, "Outbuf=", (const widechar *)outbuf, *outlen); return goodTrans; } diff --git a/liblouis/louis.h b/liblouis/louis.h index 29af2abb97..43c3c19781 100644 --- a/liblouis/louis.h +++ b/liblouis/louis.h @@ -568,6 +568,7 @@ void outOfMemory (); void logWidecharBuf(int level, const char *msg, const widechar *wbuf, int wlen); /* Helper for logging a widechar buffer */ +void logMessage(logLevels level, const char *format, ...); void closeLogFile(); /* Function for closing loggin file */ #ifdef __cplusplus diff --git a/liblouis/wrappers.c b/liblouis/wrappers.c index 133069f97a..9ea8c83230 100644 --- a/liblouis/wrappers.c +++ b/liblouis/wrappers.c @@ -93,7 +93,7 @@ other_translate (const char *trantab, const widechar switch (action) { case -1: - lou_log (LOG_ERROR, "There is no translator called '%s'", transSpec); + logMessage (LOG_ERROR, "There is no translator called '%s'", transSpec); return 0; case 1: return 1; @@ -123,7 +123,7 @@ other_backTranslate (const char *trantab, const widechar switch (action) { case -1: - lou_log (LOG_ERROR, "There is no translator called '%s'", transSpec); + logMessage (LOG_ERROR, "There is no translator called '%s'", transSpec); return 0; case 1: return 1; From 4c6f9fefcfa2013c947cfddef7278c67ce44693e Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Mon, 26 May 2014 13:16:30 +0100 Subject: [PATCH 48/54] Changed type definition --- liblouis/louis.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liblouis/louis.h b/liblouis/louis.h index 43c3c19781..4c696ce486 100644 --- a/liblouis/louis.h +++ b/liblouis/louis.h @@ -565,7 +565,7 @@ extern "C" void outOfMemory (); /* Priknts an out-of-memory message and exits*/ -void logWidecharBuf(int level, const char *msg, const widechar *wbuf, int wlen); +void logWidecharBuf(logLevels level, const char *msg, const widechar *wbuf, int wlen); /* Helper for logging a widechar buffer */ void logMessage(logLevels level, const char *format, ...); From 6ec7e58df5cfb28e10788b047ae2ed8a14f9c259 Mon Sep 17 00:00:00 2001 From: Michael Whapples Date: Mon, 26 May 2014 13:58:36 +0100 Subject: [PATCH 49/54] Update some function exports --- windows/liblouis.def | 2 -- 1 file changed, 2 deletions(-) diff --git a/windows/liblouis.def b/windows/liblouis.def index db84cd4004..fd19cf6d42 100644 --- a/windows/liblouis.def +++ b/windows/liblouis.def @@ -11,7 +11,6 @@ EXPORTS lou_charToDots lou_backTranslateString lou_backTranslate - lou_logPrint lou_logFile lou_logEnd lou_compileString @@ -20,7 +19,6 @@ EXPORTS lou_getDataPath lou_registerLogCallback lou_setLogLevel - lou_log lou_free getDotsForChar getCharFromDots From 9767b4fa74e288005ebca3dab81e70f745712dd0 Mon Sep 17 00:00:00 2001 From: Bert Frees Date: Mon, 26 May 2014 17:57:55 +0200 Subject: [PATCH 50/54] Make lou_logPrint public but deprecated Updated documentation accordingly. We decided to postpone the removal of lou_logPrint to a later time so that we can do several backwards incompatible changes at once. --- doc/liblouis.texi | 4 +++- liblouis/liblouis.h.in | 4 ++++ liblouis/logging.c | 19 ++++++++++++++----- windows/liblouis.def | 1 + 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/doc/liblouis.texi b/doc/liblouis.texi index c42ea22aee..6a8d6ab0ab 100644 --- a/doc/liblouis.texi +++ b/doc/liblouis.texi @@ -2473,7 +2473,7 @@ will be printed to the file given in this call. The entire path name of the file must be given. @node lou_logPrint, lou_logEnd, lou_logFile, Programming with liblouis -@section lou_logPrint +@section lou_logPrint (deprecated) @findex lou_logPrint @example @@ -2485,6 +2485,8 @@ libraries to print messages to the file specified by the call to @code{lou_logFile}. In particular, it is used by the companion library liblouisxml. +This function is deprecated as of version 2.6.0. + @node lou_logEnd, lou_setDataPath, lou_logPrint, Programming with liblouis @section lou_logEnd @findex lou_logEnd diff --git a/liblouis/liblouis.h.in b/liblouis/liblouis.h.in index 9ca993905b..7ec1ed3f65 100644 --- a/liblouis/liblouis.h.in +++ b/liblouis/liblouis.h.in @@ -116,6 +116,10 @@ mode); int *outlen, formtype *typeform, char *spacing, int *outputPos, int *inputPos, int *cursorPos, int mode); + void EXPORT_CALL lou_logPrint (const char *format, ...); +/* Prints error messages to a file + @deprecated As of 2.6.0, applications using liblouis should implement + their own logging system. */ void EXPORT_CALL lou_logFile (const char *filename); /* Specifies the name of the file to be used by lou_logPrint. If it is diff --git a/liblouis/logging.c b/liblouis/logging.c index fdb58e1a8f..0c764a3679 100644 --- a/liblouis/logging.c +++ b/liblouis/logging.c @@ -60,7 +60,10 @@ void logWidecharBuf(logLevels level, const char *msg, const widechar *wbuf, int free(logMsg); } -static void defaultLogCallback(int level, const char *message); +static void defaultLogCallback(int level, const char *message) +{ + lou_logPrint("%s", message); // lou_logPrint takes formatting, protect against % in message +} static logcallback logCallbackFunction = defaultLogCallback; void EXPORT_CALL lou_registerLogCallback(logcallback callback) @@ -126,16 +129,22 @@ lou_logFile (const char *fileName) } } -static void -defaultLogCallback (logLevels level, const char *message) +void EXPORT_CALL +lou_logPrint (const char *format, ...) { - if (message == NULL) +#ifndef __SYMBIAN32__ + va_list argp; + if (format == NULL) return; if (logFile == NULL && initialLogFileName[0] != 0) logFile = fopen (initialLogFileName, "wb"); if (logFile == NULL) logFile = stderr; - fprintf (logFile, "%s\n", message); + va_start (argp, format); + vfprintf (logFile, format, argp); + fprintf (logFile, "\n"); + va_end (argp); +#endif } void EXPORT_CALL diff --git a/windows/liblouis.def b/windows/liblouis.def index fd19cf6d42..f71349a1d7 100644 --- a/windows/liblouis.def +++ b/windows/liblouis.def @@ -11,6 +11,7 @@ EXPORTS lou_charToDots lou_backTranslateString lou_backTranslate + lou_logPrint lou_logFile lou_logEnd lou_compileString From 052282d6c4201aa7c22102862db9453d47718301 Mon Sep 17 00:00:00 2001 From: Bert Frees Date: Mon, 26 May 2014 18:02:59 +0200 Subject: [PATCH 51/54] Update a test --- tests/logging.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/logging.c b/tests/logging.c index b04319f743..962f776602 100644 --- a/tests/logging.c +++ b/tests/logging.c @@ -52,9 +52,9 @@ main(int argc, char **argv) lou_registerLogCallback(log_to_buffer); log_buffer_pos = 0; lou_setLogLevel(LOG_WARN); - lou_log(LOG_ERROR, "foo"); - lou_log(LOG_INFO, "bar"); + logMessage(LOG_ERROR, "foo"); + logMessage(LOG_INFO, "bar"); lou_setLogLevel(LOG_INFO); - lou_log(LOG_INFO, "baz"); + logMessage(LOG_INFO, "baz"); return assert_log_buffer_equals("[ERROR] foo\n[INFO] baz\n"); } From 2dce6aab07052bfafae76de62f36e4755543281f Mon Sep 17 00:00:00 2001 From: Christian Egli Date: Wed, 28 May 2014 12:23:10 +0200 Subject: [PATCH 52/54] Remove cruft that isn't needed with autoconf 2.68 --- doc/Makefile.am | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index 170f222eda..afefb06776 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,6 +1,3 @@ -# docdir is only needed if you have Autoconf older than 2.60 -docdir = $(datadir)/doc/${PACKAGE} - doc_DATA = \ liblouis.html \ liblouis.txt From 079641427dc92a7289e400649527afd5dd5b8422 Mon Sep 17 00:00:00 2001 From: Bert Frees Date: Tue, 3 Jun 2014 12:14:52 +0200 Subject: [PATCH 53/54] Complete AUTHORS file - went through the NEWS file - went through all table headers - did some grep searches on commit messages --- AUTHORS | 194 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 161 insertions(+), 33 deletions(-) diff --git a/AUTHORS b/AUTHORS index 64dccd44a0..0cef278aa6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,33 +1,161 @@ -John J. Boyer of Abilitiessoft, Inc. -Dave Mielke and other BRLTTY team members -Leon Ungier of ViewPlus Technologies -John Gardner of ViewPlus Technologies -Yuemei Sun of ViewPlus Technologies -Mike Sivill of ViewPlus Technologies -Eitan Isaacson -Alastair Irving -Christian Egli -James Teh -Michel Such -Samuel Thibault -Lars Bjørndal -Carlos Ferreira -Michael Whapples -Birkir Gunnarsson -Coscell Kao -Peter Engström -Juan Carlos Buño Suárez -Mesar Hameed -Timothy Lee -Bert Frees -Hammer Attila of IT Foundation for the Visually Impaired - Hungary -Aaron Cannon -Greg Kearney -Joseph Lee -Paul Wood -David Reynolds -Knut Arne Bjørndal -Igor B. Poretsky -Ken Perry -Jožef Gregorc -Peter Nilsson Lundblad +MAIN AUTHOR + + John J. Boyer from Abilitiessoft, Inc. + - is the founder, creator and original author of the liblouis + project(s) + - has put his heart and soul into liblouis + - has written the bulk of the code + - was the former project maintainer + +CODE CONTRIBUTORS + +A team of three developers has taken over maintenance work since John +Boyer did a step back in 2014: + + Christian Egli from SBS + - maintains the build and version control systems and does releases + on a regular basis + - has done code contributions + - is one of the project maintainers + + Mesar Hameed , + - has done a lot of table maintenance + - was the main developer of the test harness + - is one of the project maintainers + + Bert Frees for DocArch and SBS + - has done code contributions + - has done table contributions as well + - is one of the project maintainers + +Considerable coding was done by: + + Eitan Isaacson + James Teh + Michael Whapples + +Patches were provided by: + + Jeremy Roman + Peter Nilsson Lundblad + Timothy Lee + Vincent Untz + Volker Bijewitz + +BRLTTY AUTHORS + +Liblouis was derived from the Linux screen reader BRLTTY. Because it +is rather difficult to trace back exactly which parts of BRLTTY ended +up in liblouis we just list all BRLTTY contributors here (see also +mielke.cc/brltty/contact.html). + +The team: + + Dave Mielke + Nicolas Pitre + Stéphane Doyon + +Other contributors: + + Andreas Gross + August Hörandl + Brailcom o.p.s. + Christian Comaschi + Coscell Kao + James Bowden + John Boyer + Jos Lemmens + Mario Lang + Nikhil Nair + Oscar Fernandez + Per Lejontand + Samuel Thibault + Sébastien Hinderer + Stephane Dalton + Wolfgang Astleitner + Yannick Plassiard + +TABLE CONTRIBUTORS + + Aaron Cannon + Abdolamir Banisaeid + Alex Ho + André-Abush Clause + Birkir Gunnarsson + Brailcom, o.p.s. + Bue Vester-Andersen + Carles Sadurní Anguita + Carlos Ferreira + Caterina Avoledo + Chennai Shankar from Braille Section Team, Anna Centenary Library + Christian Waldvogel from SBS + Coscell Kao + Danko Butorac + Dave Mielke + David Hole + David Reynolds + Dinakar T.D. + Dinesh Kaushal + Dipendra Manocha + Eric Yip + Frédéric Schwebel + Greg Kearney + International league of Blind Esperantists (LIBE) + Igor B. Poretsky + Jan Halousek from MERIT + Jan Hegr + Joseph Lee + José Enrique Fernández del Campo + Jožef Gregorc + Juan Carlos Buño Suárez + Jürgen Dengo + Halim Sahin + Hammer Attila , from IT Foundation for the Visually Impaired in Hungary + Hans Schou + Him Prasad Gautam + Ken Perry + Keny Yuen + KM Yuen + Knut Arne Bjørndal + Lars Bjørndal , + Leon Ungier from ViewPlus Technologies, Inc. + Leona Holloway from Vision Australia + Mateja Jenčič + Michel Such + Mike Sivill from ViewPlus Technologies, Inc. + Mohammed R. Ramadan + Monk Jeremiah from Visoki Dečani + Neil Soiffer + Nicolas Pitre + Nicolai Svendsen + Patrick Zajda + Paul Wood + Peter Engström from Index Braille + Rui Batista + Rui Fontes + Rumiana Kamenska + Samuel Thibault + Sébastien Sablé + Simone Dal Maso + Sreeja Parameswaran + Stefan Moisei + Tamru E. Belay , from Adaptive Technology Center for the Blind (ATCB) + Tom Johnston + Yuemei Sun from ViewPlus Technologies, Inc. + + + +OTHER CONTRIBUTORS + +These are contributions not in the form of code or tables. + + John Gardner from ViewPlus Technologies, Inc. + +Bug reports by: + + Corand van Strien + Milan Zamazal + +[FIXME] unknown contribution by: + + Alastair Irving \ No newline at end of file From a96b7987f19924bdc57c913f23de331acb79331b Mon Sep 17 00:00:00 2001 From: Bert Frees Date: Tue, 10 Jun 2014 11:39:22 +0200 Subject: [PATCH 54/54] Added Hyphen authors to AUTHORS file and some rearrangements --- AUTHORS | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/AUTHORS b/AUTHORS index 0cef278aa6..4522696d44 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,7 +5,7 @@ MAIN AUTHOR project(s) - has put his heart and soul into liblouis - has written the bulk of the code - - was the former project maintainer + - maintainer emeritus CODE CONTRIBUTORS @@ -37,6 +37,7 @@ Considerable coding was done by: Patches were provided by: Jeremy Roman + Milan Zamazal Peter Nilsson Lundblad Timothy Lee Vincent Untz @@ -145,17 +146,24 @@ TABLE CONTRIBUTORS +HYPHEN AUTHORS + +Code was borrowed from the hyphenation library Hyphen, which is based +on Libhnj. + + Raph Levien + ALTLinux, Moscow + Peter Novodvorsky + László Németh + +Hyphenation dictionaries were copied from OpenOffice.org. + OTHER CONTRIBUTORS These are contributions not in the form of code or tables. John Gardner from ViewPlus Technologies, Inc. -Bug reports by: - - Corand van Strien - Milan Zamazal - -[FIXME] unknown contribution by: +Unknown contribution: Alastair Irving \ No newline at end of file