[liblouis-liblouisxml] [liblouis commit] r96 - in trunk: . liblouis tools

  • From: codesite-noreply@xxxxxxxxxx
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Wed, 21 Jan 2009 01:59:43 +0000

Author: john.boyer@xxxxxxxxxxxxxxxx
Date: Tue Jan 20 17:54:08 2009
New Revision: 96

Modified:
   trunk/ChangeLog
   trunk/liblouis/liblouis.h
   trunk/liblouis/lou_backTranslateString.c
   trunk/liblouis/lou_translateString.c
   trunk/tools/lou_allround.c

Log:
Implemented pass1Only mode bit. Can now set pass1Only in lou_allround.



Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog     (original)
+++ trunk/ChangeLog     Tue Jan 20 17:54:08 2009
@@ -1,5 +1,8 @@
+2009-01-20 (2) John J. Boyer <john.boyer@xxxxxxxxxxxxxxxx>
+       * Implemented pass1Only mode bit
+       * Can now set pass1Only in lou_allround
 2009-01-20 John J. Boyer <john.boyer@xxxxxxxxxxxxxxxx>
-       Change version in configure.ac to 1.5.2
+       * Change version in configure.ac to 1.5.2

 2009-01-20  James Teh <jamie@xxxxxxxxxxx>


Modified: trunk/liblouis/liblouis.h
==============================================================================
--- trunk/liblouis/liblouis.h   (original)
+++ trunk/liblouis/liblouis.h   Tue Jan 20 17:54:08 2009
@@ -61,7 +61,8 @@
     noContractions = 1,
     compbrlAtCursor = 2,
     dotsIO = 4,
-    comp8Dots = 8
+    comp8Dots = 8,
+    pass1Only = 16
   } translationModes;

 char *lou_version ();

Modified: trunk/liblouis/lou_backTranslateString.c
==============================================================================
--- trunk/liblouis/lou_backTranslateString.c    (original)
+++ trunk/liblouis/lou_backTranslateString.c    Tue Jan 20 17:54:08 2009
@@ -57,7 +57,7 @@

 int
 lou_backTranslateString (const char *trantab, const widechar
-                        *inbuf,
+                        * inbuf,
                         int *inlen, widechar * outbuf, int *outlen, char
                         *typeform, char *spacing, int modex)
 {
@@ -68,7 +68,7 @@
 int
 lou_backTranslate (const char *trantab, const
                   widechar
-                  *inbuf,
+                  * inbuf,
                   int *inlen, widechar * outbuf, int *outlen,
                   char *typeform, char *spacing, int
                   *outputPos, int *inputPos, int *cursorPos, int modex)
@@ -105,161 +105,167 @@
       passbuf1[k] = getDotsForChar (inbuf[k]);
   passbuf1[srcmax] = getDotsForChar (' ');
   currentInput = passbuf1;
-  if (table->numPasses > 1 || table->corrections)
+ if ((!(mode & pass1Only)) && (table->numPasses > 1 || table->corrections))
     {
if (!(passbuf2 = liblouis_allocMem (alloc_passbuf2, srcmax, destmax)))
        return 0;
     }
   currentPass = table->numPasses;
-  switch (table->numPasses + (table->corrections << 3))
+  if ((mode & pass1Only))
     {
-    case 1:
       currentOutput = outbuf;
       goodTrans = backTranslateString ();
-      break;
-    case 2:
-      currentOutput = passbuf2;
-      goodTrans = translatePass ();
-      if (!goodTrans)
-       break;
-      currentPass--;
-      srcmax = dest;
-      currentInput = passbuf2;
-      currentOutput = outbuf;
-      goodTrans = backTranslateString ();
-      break;
-    case 3:
-      currentOutput = passbuf2;
-      goodTrans = translatePass ();
-      if (!goodTrans)
-       break;
-      currentPass--;
-      srcmax = dest;
-      currentInput = passbuf2;
-      currentOutput = passbuf1;
-      goodTrans = translatePass ();
-      if (!goodTrans)
-       break;
-      currentInput = passbuf1;
-      currentOutput = outbuf;
-      currentPass--;
-      srcmax = src;
-      goodTrans = backTranslateString ();
-      break;
-    case 4:
-      currentOutput = passbuf2;
-      goodTrans = translatePass ();
-      if (!goodTrans)
-       break;
-      currentPass--;
-      srcmax = dest;
-      currentInput = passbuf2;
-      currentOutput = passbuf1;
-      goodTrans = translatePass ();
-      if (!goodTrans)
-       break;
-      currentInput = passbuf1;
-      currentOutput = passbuf2;
-      srcmax = dest;
-      currentPass--;
-      goodTrans = translatePass ();
-      if (!goodTrans)
-       break;
-      currentInput = passbuf2;
-      currentOutput = outbuf;
-      currentPass--;
-      srcmax = dest;
-      goodTrans = backTranslateString ();
-      break;
-    case 9:
-      currentOutput = passbuf2;
-      goodTrans = backTranslateString ();
-      if (!goodTrans)
-       break;
-      currentInput = passbuf2;
-      currentOutput = outbuf;
-      currentPass--;
-      srcmax = dest;
-      goodTrans = makeCorrections ();
-      break;
-    case 10:
-      currentOutput = passbuf2;
-      goodTrans = translatePass ();
-      if (!goodTrans)
-       break;
-      currentPass--;
-      srcmax = dest;
-      currentInput = passbuf2;
-      currentOutput = passbuf1;
-      goodTrans = backTranslateString ();
-      if (!goodTrans)
-       break;
-      currentInput = passbuf1;
-      currentOutput = outbuf;
-      currentPass--;
-      srcmax = dest;
-      goodTrans = makeCorrections ();
-      break;
-    case 11:
-      currentOutput = passbuf2;
-      goodTrans = translatePass ();
-      if (!goodTrans)
-       break;
-      currentPass--;
-      srcmax = dest;
-      currentInput = passbuf2;
-      currentOutput = passbuf1;
-      goodTrans = translatePass ();
-      if (!goodTrans)
-       break;
-      currentInput = passbuf1;
-      currentOutput = passbuf2;
-      currentPass--;
-      srcmax = dest;
-      goodTrans = backTranslateString ();
-      if (!goodTrans)
+    }
+  else
+    switch (table->numPasses + (table->corrections << 3))
+      {
+      case 1:
+       currentOutput = outbuf;
+       goodTrans = backTranslateString ();
+       break;
+      case 2:
+       currentOutput = passbuf2;
+       goodTrans = translatePass ();
+       if (!goodTrans)
+         break;
+       currentPass--;
+       srcmax = dest;
+       currentInput = passbuf2;
+       currentOutput = outbuf;
+       goodTrans = backTranslateString ();
+       break;
+      case 3:
+       currentOutput = passbuf2;
+       goodTrans = translatePass ();
+       if (!goodTrans)
+         break;
+       currentPass--;
+       srcmax = dest;
+       currentInput = passbuf2;
+       currentOutput = passbuf1;
+       goodTrans = translatePass ();
+       if (!goodTrans)
+         break;
+       currentInput = passbuf1;
+       currentOutput = outbuf;
+       currentPass--;
+       srcmax = src;
+       goodTrans = backTranslateString ();
+       break;
+      case 4:
+       currentOutput = passbuf2;
+       goodTrans = translatePass ();
+       if (!goodTrans)
+         break;
+       currentPass--;
+       srcmax = dest;
+       currentInput = passbuf2;
+       currentOutput = passbuf1;
+       goodTrans = translatePass ();
+       if (!goodTrans)
+         break;
+       currentInput = passbuf1;
+       currentOutput = passbuf2;
+       srcmax = dest;
+       currentPass--;
+       goodTrans = translatePass ();
+       if (!goodTrans)
+         break;
+       currentInput = passbuf2;
+       currentOutput = outbuf;
+       currentPass--;
+       srcmax = dest;
+       goodTrans = backTranslateString ();
+       break;
+      case 9:
+       currentOutput = passbuf2;
+       goodTrans = backTranslateString ();
+       if (!goodTrans)
+         break;
+       currentInput = passbuf2;
+       currentOutput = outbuf;
+       currentPass--;
+       srcmax = dest;
+       goodTrans = makeCorrections ();
+       break;
+      case 10:
+       currentOutput = passbuf2;
+       goodTrans = translatePass ();
+       if (!goodTrans)
+         break;
+       currentPass--;
+       srcmax = dest;
+       currentInput = passbuf2;
+       currentOutput = passbuf1;
+       goodTrans = backTranslateString ();
+       if (!goodTrans)
+         break;
+       currentInput = passbuf1;
+       currentOutput = outbuf;
+       currentPass--;
+       srcmax = dest;
+       goodTrans = makeCorrections ();
+       break;
+      case 11:
+       currentOutput = passbuf2;
+       goodTrans = translatePass ();
+       if (!goodTrans)
+         break;
+       currentPass--;
+       srcmax = dest;
+       currentInput = passbuf2;
+       currentOutput = passbuf1;
+       goodTrans = translatePass ();
+       if (!goodTrans)
+         break;
+       currentInput = passbuf1;
+       currentOutput = passbuf2;
+       currentPass--;
+       srcmax = dest;
+       goodTrans = backTranslateString ();
+       if (!goodTrans)
+         break;
+       currentInput = passbuf2;
+       currentOutput = outbuf;
+       currentPass--;
+       srcmax = dest;
+       goodTrans = makeCorrections ();
+       break;
+      case 12:
+       currentOutput = passbuf2;
+       goodTrans = translatePass ();
+       if (!goodTrans)
+         break;
+       currentPass--;
+       srcmax = dest;
+       currentInput = passbuf2;
+       currentOutput = passbuf1;
+       goodTrans = translatePass ();
+       if (!goodTrans)
+         break;
+       currentInput = passbuf1;
+       currentOutput = passbuf2;
+       srcmax = dest;
+       currentPass--;
+       goodTrans = translatePass ();
+       if (!goodTrans)
+         break;
+       currentInput = passbuf2;
+       currentOutput = passbuf1;
+       currentPass--;
+       srcmax = dest;
+       goodTrans = backTranslateString ();
+       if (!goodTrans)
+         break;
+       currentInput = passbuf1;
+       currentOutput = outbuf;
+       currentPass--;
+       srcmax = dest;
+       goodTrans = makeCorrections ();
        break;
-      currentInput = passbuf2;
-      currentOutput = outbuf;
-      currentPass--;
-      srcmax = dest;
-      goodTrans = makeCorrections ();
-      break;
-    case 12:
-      currentOutput = passbuf2;
-      goodTrans = translatePass ();
-      if (!goodTrans)
-       break;
-      currentPass--;
-      srcmax = dest;
-      currentInput = passbuf2;
-      currentOutput = passbuf1;
-      goodTrans = translatePass ();
-      if (!goodTrans)
-       break;
-      currentInput = passbuf1;
-      currentOutput = passbuf2;
-      srcmax = dest;
-      currentPass--;
-      goodTrans = translatePass ();
-      if (!goodTrans)
-       break;
-      currentInput = passbuf2;
-      currentOutput = passbuf1;
-      currentPass--;
-      srcmax = dest;
-      goodTrans = backTranslateString ();
-      if (!goodTrans)
+      default:
        break;
-      currentInput = passbuf1;
-      currentOutput = outbuf;
-      currentPass--;
-      srcmax = dest;
-      goodTrans = makeCorrections ();
-      break;
-    default:
-      break;
-    }
+      }
   if (src < *inlen)
     *inlen = src;
   *outlen = dest;
@@ -754,7 +760,8 @@
     return 0;
   if (nextUpper)
     {
- currentOutput[dest++] = (back_findCharOrDots (chars[k++], 0))->uppercase;
+      currentOutput[dest++] =
+       (back_findCharOrDots (chars[k++], 0))->uppercase;
       nextUpper = 0;
     }
   if (!allUpper)
@@ -861,7 +868,8 @@
 putCharacter (widechar dots)
 {
 /*Output character(s) corresponding to a Unicode braille Character*/
- TranslationTableOffset offset = (back_findCharOrDots (dots, 0))->definitionRule;
+  TranslationTableOffset offset =
+    (back_findCharOrDots (dots, 0))->definitionRule;
   if (offset)
     {
       widechar c;
@@ -905,9 +913,8 @@
   if (!count)
     return 0;
   for (k = 0; k < count; k++)
- if ((back_findCharOrDots (address1[k], m))->lowercase != (back_findCharOrDots
-                                                        (address2[k],
-                                                         m))->lowercase)
+    if ((back_findCharOrDots (address1[k], m))->lowercase !=
+       (back_findCharOrDots (address2[k], m))->lowercase)
       return 0;
   return 1;
 }

Modified: trunk/liblouis/lou_translateString.c
==============================================================================
--- trunk/liblouis/lou_translateString.c        (original)
+++ trunk/liblouis/lou_translateString.c        Tue Jan 20 17:54:08 2009
@@ -139,7 +139,7 @@
     }
   if (!(passbuf1 = liblouis_allocMem (alloc_passbuf1, srcmax, destmax)))
     return 0;
-  if (table->numPasses > 1 || table->corrections)
+ if ((!(mode & pass1Only)) && (table->numPasses > 1 || table->corrections))
     {
if (!(passbuf2 = liblouis_allocMem (alloc_passbuf2, srcmax, destmax)))
        return 0;
@@ -153,6 +153,12 @@
        memset (destSpacing, '*', destmax);
     }
   currentPass = 0;
+  if ((mode & pass1Only))
+    {
+      currentOutput = passbuf1;
+      goodTrans = translateString ();
+      currentPass = 5;         /*Certainly > table->numPasses */
+    }
   while (currentPass <= table->numPasses && goodTrans)
     {
       switch (currentPass)
@@ -645,13 +651,13 @@
       ruleChar = for_findCharOrDots (transRule->charsdots[kk++], 0);
       if ((currentInputChar->lowercase != ruleChar->lowercase)
          || (typebuf != NULL && (typebuf[k] & mask) != (typebuf[src] & mask))
-         || (k != (src + 1) && (prevAttr &
-CTC_Letter) && (currentInputChar->attributes & CTC_Letter) &&
-((currentInputChar->attributes &
-                                 (CTC_LowerCase | CTC_UpperCase))
-                                !=
-                                (prevAttr &
-                                 (CTC_LowerCase | CTC_UpperCase)))))
+         || (k != (src + 1) && (prevAttr &
+                                CTC_Letter)
+             && (currentInputChar->attributes & CTC_Letter)
+             &&
+             ((currentInputChar->
+               attributes & (CTC_LowerCase | CTC_UpperCase)) !=
+              (prevAttr & (CTC_LowerCase | CTC_UpperCase)))))
        return 0;
       prevAttr = currentInputChar->attributes;
     }
@@ -1853,8 +1859,10 @@
        case CTO_UpperCase:
          /* Only needs special handling if not within compbrl and
           *the table defines a capital sign. */
- if (!(mode & compbrlAtCursor && src >= compbrlStart && src <= compbrlEnd)
-             && (transRule->dotslen == 1 && table->capitalSign))
+         if (!
+             (mode & compbrlAtCursor && src >= compbrlStart
+              && src <= compbrlEnd) && (transRule->dotslen == 1
+                                        && table->capitalSign))
            {
              putCharacter (curCharDef->lowercase);
              src++;
@@ -1904,16 +1912,17 @@
              {
                /* Map skipped input positions to the previous output position. 
*/
                if (outputPositions != NULL)
-               {
-                 int tcc;
-                 for (tcc = 0; tcc < transCharslen; tcc++)
-                   outputPositions[src + tcc] = dest - 1;
-               }
- if (!cursorStatus && src <= cursorPosition && cursorPosition < src + transCharslen)
-               {
-                 cursorStatus = 1;
-                 cursorPosition = dest - 1;
-               }
+                 {
+                   int tcc;
+                   for (tcc = 0; tcc < transCharslen; tcc++)
+                     outputPositions[src + tcc] = dest - 1;
+                 }
+               if (!cursorStatus && src <= cursorPosition
+                   && cursorPosition < src + transCharslen)
+                 {
+                   cursorStatus = 1;
+                   cursorPosition = dest - 1;
+                 }
                src += transCharslen;
              }
            break;

Modified: trunk/tools/lou_allround.c
==============================================================================
--- trunk/tools/lou_allround.c  (original)
+++ trunk/tools/lou_allround.c  Tue Jan 20 17:54:08 2009
@@ -59,7 +59,7 @@
   inputBuffer[0] = 0;
   fgets (inputBuffer, sizeof (inputBuffer), stdin);
   inputLength = strlen (inputBuffer) - 1;
-  if (inputLength < 0) /*EOF on script*/
+  if (inputLength < 0)              /*EOF on script */
     exit (0);
   inputBuffer[inputLength] = 0;
   return inputLength;
@@ -126,6 +126,8 @@
          mode |= 4 * getYN ();
          printf ("8-dot computer braille");
          mode |= 8 * getYN ();
+         printf ("Pass1 only");
+         mode |= 16 * getYN ();
          break;
        case 'l':
          printf ("Do you want to test input and output lengths");
@@ -349,9 +351,8 @@
                  printf ("%c", outbuf[k]);
                printf ("\n");
                if (showSizes)
-                 printf ("input length = %d; output length = %d\n",
-translen,
-                         outlen);
+                 printf ("input length = %d; output length = %d\n",
+                         translen, outlen);
                if (cursorPos != -1)
                  printf ("Cursor position: %d\n", cursorPos);
                if (enteredEmphasis[0])
For a description of the software and to download it go to
http://www.jjb-software.com

Other related posts:

  • » [liblouis-liblouisxml] [liblouis commit] r96 - in trunk: . liblouis tools - codesite-noreply