[liblouis-liblouisxml] [liblouisutdml] push by john.bo...@xxxxxxxxxxxxxxxxx - More bug fixes for page formatting with formatFor utd on 2012-02-25 18:47 GMT

  • From: liblouisutdml@xxxxxxxxxxxxxx
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Sat, 25 Feb 2012 18:48:27 +0000

Revision: 03a312868fd9
Author:   John Boyer <john.boyer@xxxxxxxxxxxxxxxxx>
Date:     Sat Feb 25 10:46:20 2012
Log:      More bug fixes for page formatting with formatFor utd
http://code.google.com/p/liblouisutdml/source/detail?r=03a312868fd9

Modified:
 /doc/liblouisutdml.texi
 /doc/stamp-vti
 /doc/version.texi
 /lbu_files/sample-utd.cfg
 /lbu_files/viewxml.ctb
 /liblouisutdml/liblouisutdml.h
 /liblouisutdml/transcriber.c

=======================================
--- /doc/liblouisutdml.texi     Wed Feb  8 03:49:55 2012
+++ /doc/liblouisutdml.texi     Sat Feb 25 10:46:20 2012
@@ -156,13 +156,13 @@
 * License::
 * Overview::
 * Files and Paths::
-* lbx_version::
-* lbx_initialize::
-* lbx_translateString::
-* lbx_translateFile::
-* lbx_translateTextFile::
-* lbx_backTranslateFile::
-* lbx_free::
+* lbu_version::
+* lbu_initialize::
+* lbu_translateString::
+* lbu_translateFile::
+* lbu_translateTextFile::
+* lbu_backTranslateFile::
+* lbu_free::

 Example files

@@ -495,7 +495,7 @@
 settings separated by end-of-line characters. Such strings can be
 generated by the @option{-C} option on the @command{file2brl} command
 line, by the @code{configstring} and @code{configtweak} semantic
-actions, or by passing a string to the @code{lbx_initialize} function.
+actions, or by passing a string to the @code{lbu_initialize} function.

 The information below applies to @command{file2brl} as much as to
 liblouisutdml.
@@ -503,10 +503,10 @@
 Before discussing configuration files in detail it is worth noting
 that the application program has access to the information in the
 configuration files by calling the liblouisutdml function
-@code{lbx_initialize}. This function returns a pointer to a data
+@code{lbu_initialize}. This function returns a pointer to a data
 structure containing the configuration information. The calling program
 must include the header file @code{louisutdml.h}. You do not need to call
-@code{lbx_initialize} unless you need the facilities which it provides.
+@code{lbu_initialize} unless you need the facilities which it provides.

 A configuration file specification may contain more than one file name,
 separated by commas. liblouisutdml will process these files in sequence,
@@ -2008,7 +2008,7 @@
 @end example

 To perform the back-translation operation, @command{file2brl} uses the
-liblouisutdml function @code{lbx_backTranslateFile}.
+liblouisutdml function @code{lbu_backTranslateFile}.

 @node Reformatting, Interlining, Back-translation, Special Features
 @section Reformatting
@@ -2214,7 +2214,7 @@

 Four tables are used to translate xml documents containing a mixture of
 text and mathematics. They can be found in the subdirectory
-@file{lbx_files} of the liblouisutdml directory and in the @file{tables}
+@file{lbu_files} of the liblouisutdml directory and in the @file{tables}
 subdirectory of the liblouis distribution. First, the semantic-action
 file @file{ukmaths.sem} is used to interpret the mathematical portions
 of the xml document (The text portions are interpreted by another
@@ -2431,13 +2431,13 @@
 * License::
 * Overview::
 * Files and Paths::
-* lbx_version::
-* lbx_initialize::
-* lbx_translateString::
-* lbx_translateFile::
-* lbx_translateTextFile::
-* lbx_backTranslateFile::
-* lbx_free::
+* lbu_version::
+* lbu_initialize::
+* lbu_translateString::
+* lbu_translateFile::
+* lbu_translateTextFile::
+* lbu_backTranslateFile::
+* lbu_free::
 @end menu

@node License, Overview, Programming with liblouisutdml, Programming with liblouisutdml
@@ -2523,7 +2523,7 @@
 compiled first and then liblouisutdml. Wherever 16 bits are mentioned in
 this document, read 32 if you have compiled the library for 32 bits.

-@node Files and Paths, lbx_version, Overview, Programming with liblouisutdml +@node Files and Paths, lbu_version, Overview, Programming with liblouisutdml
 @section Files and Paths

 liblouisutdml uses three kinds of
@@ -2546,10 +2546,10 @@
 first filename in a configuration file list may have a path. Next, in
 Windows liblouisutdml determines the path to itself. this is the second
 path on which it will look for files. The liblouis @file{tables}
-directory and the liblouisutdml @file{lbx_files} directory are relative to
+directory and the liblouisutdml @file{lbu_files} directory are relative to
 this path. In Unix systems, including the Mac,, these directories are
 absolute paths determined at compile time. liblouisutdml searches first
-the @file{tables} directory and then the @file{lbx_files} directory.
+the @file{tables} directory and then the @file{lbu_files} directory.
 Finally, it establishes the current directory as the final path to be
 searched. If you wish the current directory to be the first path
 searched, prefix the first configuration file name with @samp{./} for
@@ -2559,24 +2559,24 @@
 function @code{set_paths}, which is called from @code{readconfig.c} and
 in turn calls @code{addPath} in the @code{paths.c} module.

-@node lbx_version, lbx_initialize, Files and Paths, Programming with liblouisutdml
-@section lbx_version
-
-@findex lbx_version
+@node lbu_version, lbu_initialize, Files and Paths, Programming with liblouisutdml
+@section lbu_version
+
+@findex lbu_version
 @example
-char *lbx_version (void)
+char *lbu_version (void)
 @end example

 This function returns a pointer to a character string containing the
 version of liblouisutdml. Other information such as the release
 date and perhaps notable changes may be added later.

-@node lbx_initialize, lbx_translateString, lbx_version, Programming with liblouisutdml
-@section lbx_initialize
-
-@findex lbx_initialize
+@node lbu_initialize, lbu_translateString, lbu_version, Programming with liblouisutdml
+@section lbu_initialize
+
+@findex lbu_initialize
 @example
-void * lbx_initialize (
+void * lbu_initialize (
 const char *configFilelist,
 const char *logFileName,
 const char *settingsString)
@@ -2598,12 +2598,12 @@
 access the information in this structure you must include
 @file{louisutdml.h}. This function is used by @command{file2brl}.

-@node lbx_translateString, lbx_translateFile, lbx_initialize, Programming with liblouisutdml
-@section lbx_translateString
-
-@findex lbx_translateString
+@node lbu_translateString, lbu_translateFile, lbu_initialize, Programming with liblouisutdml
+@section lbu_translateString
+
+@findex lbu_translateString
 @example
-int lbx_translateString (
+int lbu_translateString (
 const char *configfilelist,
 char * inbuf,
 widechar *outbuf,
@@ -2641,12 +2641,12 @@
 function returns 1 if no errors were encountered and a negative number
 if a complete translation could not be done.

-@node lbx_translateFile, lbx_translateTextFile, lbx_translateString, Programming with liblouisutdml
-@section lbx_translateFile
-
-@findex lbx_translateFile
+@node lbu_translateFile, lbu_translateTextFile, lbu_translateString, Programming with liblouisutdml
+@section lbu_translateFile
+
+@findex lbu_translateFile
 @example
-int lbx_translateFile (
+int lbu_translateFile (
 char *configfilelist,
 char *inputFileName,
 char *outputFileName,
@@ -2655,7 +2655,7 @@

 This function accepts a well-formed xml document in
 @code{inputFilename} and produces a braille translation in
-@code{outputFilename}. As for @code{lbx_translateString}, the
+@code{outputFilename}. As for @code{lbu_translateString}, the
 @code{mode} parameter specifies whether the library is to be
 initialized with new configuration information or simply prepared to
 handle a new document. In addition, the @code{mode} parameter can
@@ -2669,12 +2669,12 @@
 @code{configfilelist}. The function returns 1 if the translation was
 successful.

-@node lbx_translateTextFile, lbx_backTranslateFile, lbx_translateFile, Programming with liblouisutdml
-@section lbx_translateTextFile
-
-@findex lbx_translateTextFile
+@node lbu_translateTextFile, lbu_backTranslateFile, lbu_translateFile, Programming with liblouisutdml
+@section lbu_translateTextFile
+
+@findex lbu_translateTextFile
 @example
-int lbx_translateTextFile (
+int lbu_translateTextFile (
 char *configfilelist,
 char *inputFileName,
 char *outputFileName,
@@ -2689,16 +2689,16 @@
 blank line between paragraphs (or headers). The output file may be in
 UTF-8, UTF-16, or Ascii8, as specified by the @code{outputEncoding}
 line in the configuration file, @code{configfilelist}. As for
-@code{lbx_translateString}, the @code{mode} parameter specifies
+@code{lbu_translateString}, the @code{mode} parameter specifies
 whether complete initialization is to be done or simply initialization
 for a new document.

-@node lbx_backTranslateFile, lbx_free, lbx_translateTextFile, Programming with liblouisutdml
-@section lbx_backTranslateFile
-
-@findex lbx_backTranslateFile
+@node lbu_backTranslateFile, lbu_free, lbu_translateTextFile, Programming with liblouisutdml
+@section lbu_backTranslateFile
+
+@findex lbu_backTranslateFile
 @example
-int lbx_backTranslateFile (
+int lbu_backTranslateFile (
 char *configfilelist,
 char *inputFileName,
 char *outputFileName,
@@ -2716,21 +2716,21 @@
 line in the configuration file, @code{configfilelist}. The mode
 parameter specifies whether or not the library is to be initialized
 with new configuration information, as described in the section on
-@code{lbx_translateString} (@pxref{lbx_translateString}).
-
-@node lbx_free, , lbx_backTranslateFile, Programming with liblouisutdml
-@section lbx_free
-
-@findex lbx_free
+@code{lbu_translateString} (@pxref{lbu_translateString}).
+
+@node lbu_free, , lbu_backTranslateFile, Programming with liblouisutdml
+@section lbu_free
+
+@findex lbu_free
 @example
-void lbx_free (void)
+void lbu_free (void)
 @end example

 This function should be called at the end of the application to free
 all memory allocated by liblouisutdml and liblouis. If you wish to
 change configuration files during your application, use a @code{mode}
 parameter of 0 on the function call using the new configuration
-information. This will call the @code{lbx_free} function automatically.
+information. This will call the @code{lbu_free} function automatically.

@node Example files, Configuration Settings Index, Programming with liblouisutdml, Top
 @appendix Example files
=======================================
--- /doc/stamp-vti      Wed Feb  8 03:49:55 2012
+++ /doc/stamp-vti      Sat Feb 25 10:46:20 2012
@@ -1,4 +1,4 @@
-@set UPDATED 3 February 2012
+@set UPDATED 24 February 2012
 @set UPDATED-MONTH February 2012
 @set EDITION 2.1.0
 @set VERSION 2.1.0
=======================================
--- /doc/version.texi   Wed Feb  8 03:49:55 2012
+++ /doc/version.texi   Sat Feb 25 10:46:20 2012
@@ -1,4 +1,4 @@
-@set UPDATED 3 February 2012
+@set UPDATED 24 February 2012
 @set UPDATED-MONTH February 2012
 @set EDITION 2.1.0
 @set VERSION 2.1.0
=======================================
--- /lbu_files/sample-utd.cfg   Thu Feb  2 02:19:06 2012
+++ /lbu_files/sample-utd.cfg   Sat Feb 25 10:46:20 2012
@@ -2,7 +2,7 @@
 formatfor utd
 newEntries no
 #mode notUC
-paperWidth 11.5
+paperWidth 9.5
 paperheight 11
 leftMargin 1
 rightMargin 0.5
=======================================
--- /lbu_files/viewxml.ctb      Fri Jan 27 14:00:37 2012
+++ /lbu_files/viewxml.ctb      Sat Feb 25 10:46:20 2012
@@ -1,4 +1,4 @@
-# liblouis: U.S. English 8 dot Computer braille table
+# liblouis: Modified U.S. English 8 dot Computer braille table

 space \t 9 tab
 space \s 0 blank
@@ -73,7 +73,6 @@
 sign | 1256
 math / 34
 sign * 16
-repeated \s 0

 pass2 @3-3 @3-0-3

=======================================
--- /liblouisutdml/liblouisutdml.h      Wed Jan  4 05:51:14 2012
+++ /liblouisutdml/liblouisutdml.h      Sat Feb 25 10:46:20 2012
@@ -52,12 +52,12 @@
   char *EXPORT_CALL lbu_version (void);
 /* Returns the version of liblouisutdml and liblouis. */

-  void *EXPORT_CALL lbu_initialize (const char *configFileName,
+  void *EXPORT_CALL lbu_initialize (const char *configFileList,
                                    const char *logFileName,
                                    const char *settingsString);

-/* This function initializes the libxml2 library, runs canonical.cfg and
-processes the configuration file given in configFileName, sets up a log
+/* This function initializes the libxml2 library, runs liblouisutdml.ini and
+processes the configuration file given in configFileList, sets up a log
 file if logFileName is not NULL and processes the settings in
 settingsString if this is not null. It returns a pointer to the UserData
 structure. This pointer is void and must be cast to (UserData *) in the
@@ -78,7 +78,7 @@
   } ProcessingModes;

   int EXPORT_CALL lbu_translateString
-    (const char *configFileName,
+    (const char *configFileList,
      const char *inbuf, int inlen, widechar *outbuf, int *outlen,
const char *logFileName, const char *settingsString, unsigned int mode);

@@ -88,8 +88,8 @@
 null byte. If it does not begin with an xul header, one is added. The
 header is specified by the xmlHeader line in the configuration file. If
 no such line is present, a default header specifying UTF-8 encoding is
-used. The configFileName parameter points to a configuration file.
-canonical.cfg is processed before this file. Note that the *outlen
+used. The configFileList parameter points to a configuration file.
+liblouisutdml.ini is processed before this file. Note that the *outlen
 parameter is a pointer to an integer. When the function is called, this
 integer contains the maximum output length. When it returns, it is set
 to the actual length used.  The mode parameter is used to pass options
@@ -101,24 +101,24 @@


   int EXPORT_CALL lbu_backTranslateString
-    (const char *configFileName,
+    (const char *configFileList,
      const char *inbuf, int inlen, widechar *outbuf, int *outlen,
const char *logFileName, const char *settingsString, unsigned int mode);

-  int EXPORT_CALL lbu_translateFile (const char *configFileName, const char
+  int EXPORT_CALL lbu_translateFile (const char *configFileList, const char
                                     *inputFileName,
                                     const char *outputFileName,
                                     const char *logFileName,
                                     const char *settingsString,
                                     unsigned int mode);

-  int EXPORT_CALL lbu_translateTextFile (const char *configFileName,
+  int EXPORT_CALL lbu_translateTextFile (const char *configFileList,
                                         const char *inputFileName,
                                         const char *outputFileName,
                                         const char *logFileName,
                                         const char *settingsString,
                                         unsigned int mode);
-  int EXPORT_CALL lbu_backTranslateFile (const char *configFileName,
+  int EXPORT_CALL lbu_backTranslateFile (const char *configFileList,
                                         const char *inputFileName,
                                         const char *outputFileName,
                                         const char *logFileName,
=======================================
--- /liblouisutdml/transcriber.c        Fri Feb 24 05:27:33 2012
+++ /liblouisutdml/transcriber.c        Sat Feb 25 10:46:20 2012
@@ -3911,7 +3911,7 @@
 static int
 addBrlOnly (xmlNode * node, ShortBrlOnlyStrings * sbstr)
 {
-  int wcLength = sbstr->origTextLength;
+  int wcLength = sbstr->prefixedOrigTextLength;
   xmlChar buf[2 * MAXNAMELEN];
   int utf8Length = sizeof (buf) - 4;
   makeDotsTextNode (node, sbstr->prefixedTransText,
@@ -3920,24 +3920,6 @@
   xmlAddPrevSibling (node, xmlNewText (buf));
   return 1;
 }
-
-static int
-addSpaces (ShortBrlOnlyStrings *sbstr, int howMany)
-{
-  int k;
-  int kk = 0;
-  for (k = 0; k < howMany && k < MAXNAMELEN; k++)
-    sbstr->prefixedTransText[k] = SPACE;
-  for (; k < MAXNAMELEN; k++)
-    {
-      if (kk > sbstr->transTextLength)
-       break;
-      sbstr->prefixedTransText[k] = sbstr->transText[kk++];
-    }
-  memcpy (sbstr->transText, sbstr->prefixedTransText, k * CHARSIZE);
-  sbstr->transTextLength = k;
-  return 1;
-}

 static int
 addPrefixes (ShortBrlOnlyStrings * sbstr, widechar dots, widechar
@@ -3965,6 +3947,19 @@
     }
   sbstr->prefixedOrigTextLength = k;
 }
+
+static int
+addSpaces (ShortBrlOnlyStrings * sbstr, int howMany)
+{
+  addPrefixes (sbstr, SPACE, ' ', howMany);
+  memcpy (sbstr->origText, sbstr->prefixedOrigText,
+         sbstr->prefixedOrigTextLength * CHARSIZE);
+  memcpy (sbstr->transText, sbstr->prefixedTransText,
+         sbstr->prefixedTransTextLength * CHARSIZE);
+  sbstr->origTextLength = sbstr->prefixedOrigTextLength;
+  sbstr->transTextLength = sbstr->prefixedTransTextLength;
+  return 1;
+}

 static int utd_fillPage ();
 static int makeNewline (xmlNode * parent, int start);
@@ -3975,7 +3970,7 @@
 {
   if (howMany < 0)
     howMany = 1;
-  addPrefixes (&pageNumber, howMany, SPACE, ' ');
+  addPrefixes (&pageNumber, SPACE, ' ', howMany);
   makeBrlOnlyNode ();
   if (!addBrlOnly (brlOnlyNode, &pageNumber))
     return 0;
@@ -3998,11 +3993,11 @@
     strcat (setup, ud->letsign);
   strcat (setup, printPageNumber);
   length = strlen (setup);
-  for (k = 0; k < length; k++)
-    ud->print_page_number[k] = setup[k];
-  ud->print_page_number[k] = 0;
   memset (&sb, 0, sizeof (sb));
   setOrigTextChar (&sb, setup, length);
+  memcpy (ud->print_page_number, sb.origText, sb.origTextLength *
+  CHARSIZE);
+  ud->print_page_number[sb.origTextLength] = 0;
   translateShortBrlOnly (&sb);
   if (curPageStatus == topOfPage)
     return 1;
@@ -4035,12 +4030,10 @@
       return 1;
     default:
     case normal:
-      sprintf (brlPageString, "%d",
-              ud->braille_page_number);
+      sprintf (brlPageString, "%d", ud->braille_page_number);
       break;
     case p:
-      sprintf (brlPageString, "p%d",
-              ud->braille_page_number);
+      sprintf (brlPageString, "p%d", ud->braille_page_number);
       break;
     case roman:
       strcpy (brlPageString, ud->letsign);
@@ -4059,7 +4052,7 @@
   widechar printPageString[40];
   int k;
   for (k = 0; ud->print_page_number[k]; k++)
-  printPageString[k] = ud->print_page_number[k];
+    printPageString[k] = ud->print_page_number[k];
   setOrigTextWidechar (&pageNumber, printPageString, k);
   translateShortBrlOnly (&pageNumber);
   addSpaces (&pageNumber, 3);
@@ -4124,8 +4117,8 @@
     sb.transTextLength = numCells - 4;
   leadingBlanks = (numCells - sb.transTextLength) / 2;
   trailingBlanks = numCells - leadingBlanks - sb.transTextLength;
-  addPrefixes (&sb, leadingBlanks, SPACE, ' ');
-  addPrefixes (&pageNumber, trailingBlanks, SPACE, ' ');
+  addPrefixes (&sb, SPACE, ' ', leadingBlanks);
+  addPrefixes (&pageNumber, SPACE, ' ', trailingBlanks);
   return 1;
 }

@@ -4421,23 +4414,23 @@
       if (curPageStatus == topOfPage)
        {
          if (ud->running_head_length > 0
-             || (style->skip_number_lines && pageNumberLength > 0))
+             || (style->skip_number_lines && pageNumber.transTextLength > 0))
            {
              utd_finishLine (0, 0);
              setNewlineNode ();
              continue;
            }
-         availableCells = ud->cells_per_line - pageNumberLength;
+         availableCells = ud->cells_per_line - pageNumber.transTextLength;
        }
       else if (curPageStatus == lastLine)
        {
          if (ud->footer_length > 0 ||
-             (style->skip_number_lines && pageNumberLength > 0))
+             (style->skip_number_lines && pageNumber.transTextLength > 0))
            {
              utd_finishLine (0, 0);
              continue;
            }
-         availableCells = ud->cells_per_line - pageNumberLength;
+         availableCells = ud->cells_per_line - pageNumber.transTextLength;
        }
       else
        availableCells = ud->cells_per_line;
@@ -4466,8 +4459,8 @@
        }
       if (cellsOnLine > 0 && pageNumber.transTextLength > 0)
        {
-         cellsToWrite = ud->cells_per_line - pageNumber.transTextLength
-         - cellsOnLine;
+         cellsToWrite = ud->cells_per_line - pageNumber.transTextLength
+           - cellsOnLine;
          if (!insertPageNumber (cellsToWrite))
            return 0;
        }
@@ -4479,8 +4472,8 @@
            {
              if (pageNumber.transTextLength)
                {
-                 cellsToWrite = ud->cells_per_line -
-                 pageNumber.transTextLength;
+                 cellsToWrite = ud->cells_per_line -
+                   pageNumber.transTextLength;
                  if (!insertPageNumber (cellsToWrite))
                    return 0;
                }
@@ -4494,10 +4487,8 @@
            {
              if (pageNumber.transTextLength)
                {
-               int k = ud->cells_per_line -
-               pageNumber.transTextLength;
-                 horizLinePos = k *
-                                 ud->cell_width;
+                 int k = ud->cells_per_line - pageNumber.transTextLength;
+                 horizLinePos = k * ud->cell_width;
                  if (!insertPageNumber (k))
                    return 0;
                }
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts:

  • » [liblouis-liblouisxml] [liblouisutdml] push by john.bo...@xxxxxxxxxxxxxxxxx - More bug fixes for page formatting with formatFor utd on 2012-02-25 18:47 GMT - liblouisutdml