Description: This patch contains a fix to the problem of commas used 
 as decimal identifiers in certain locales.
Origin: Bill Cheng <bill.cheng@usc.edu> - Upstream
Author: Carlo Segre <segre@debian.org>
Bugs: 595795
Last-Update: 2010-09-10

--- a/file.c
+++ b/file.c
@@ -1078,6 +1078,22 @@
    }
 }
 
+int FixDecimalPoint(buf)
+   char *buf;
+{
+   char *psz=strchr(buf, ','), *psz2=NULL;
+
+   if (psz == NULL) {
+      return TRUE;
+   }
+   psz2 = strchr(&psz[1], ',');
+   if (psz2 == NULL) {
+      *psz = '.';
+      return TRUE;
+   }
+   return FALSE;
+}
+
 void Save(FP, BotObjPtr, Level, PageNumber)
    FILE *FP;
    struct ObjRec *BotObjPtr;
@@ -2540,6 +2556,26 @@
    return ok;
 }
 
+static
+int NumFieldsToFontStr(buf)
+   char *buf;
+   /* 300.000,0,0,0,16,1,0,1,1,0,0,1,0,1,0,'...' */
+{
+   char *psz=NULL, *psz_single_quote=strchr(buf, '\'');
+   int count=0;
+
+   if (psz_single_quote == NULL) {
+      return (-1);
+   }
+   *psz_single_quote = '\0';
+   for (psz=strchr(buf, ','); psz != NULL; psz=strchr(&psz[1], ',')) {
+      count++;
+   }
+   *psz_single_quote = '\'';
+
+   return count;
+}
+
 static int gnCannotFindColorMsg=FALSE;
 
 static
@@ -2583,6 +2619,8 @@
             break;
          }
       } else {
+         int num_fields_to_font_str=0;
+
          if (page_style != PORTRAIT && page_style != LANDSCAPE) {
             sprintf(gszMsgBox, TgLoadString(STID_UNRECOG_PAGE_STYLE),
                   page_style);
@@ -2590,6 +2628,21 @@
             page_style = PORTRAIT;
          }
          s = FindChar((int)',', s);
+         /* begin locale bug fix kluge */
+         num_fields_to_font_str = NumFieldsToFontStr(s);
+         if (num_fields_to_font_str == (-1)) {
+             /* cannot find single quote */
+         } else if (num_fields_to_font_str == 15) {
+             /* normal case */
+         } else if (num_fields_to_font_str == 16) {
+             /* extra one, must be the locale bug, fix it! */
+             char *psz_comma=strchr(s, ',');
+
+             *psz_comma = '.';
+         } else {
+             /* don't know what happened */
+         }
+         /* end locale bug fix kluge */
          sscanf(s, "%f", &printMag);
       }
       pageStyle = page_style;
@@ -3494,6 +3547,11 @@
       c_ptr = FindChar((int)'"', s);
       s = ReadString(c_ptr);
       *(--s) = '\0';
+      if (!FixDecimalPoint(c_ptr)) {
+#ifdef _TGIF_DBG /* debug, do not translate */
+         fprintf(stderr, "FixDecimalPoint() failed in ReadScriptFracObj().\n");
+#endif /* _TGIF_DBG */
+      }
       if (SetScriptFractionValue(c_ptr)) {
          return TRUE;
       } else {
