View Issue Details

IDProjectCategoryView StatusLast Update
0000737luatexluatex bugpublic2015-11-16 17:56
Reporterpatrick Assigned Toluigi scarso  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformApple/Intel/64bitOSOS XOS Version10.6
Product Version0.70.1 
Summary0000737: Mapfile parser uses current locale
Description(From Herbert Voss) The following file gives lots of Mapfile errors:

\documentclass{minimal}
\usepackage{luacode}
\begin{luacode*}
function Datum()
 os.setlocale("de_DE")
 tex.print(os.date("Heute ist der \%A im Monat \%B."))
end
\end{luacode*}

\begin{document}
\directlua{Datum()}
\end{document}
Additional InformationNow my idea, why this fails, but I am such a C-sucker, that this could be completely wrong: in mapfile.w around line 390 the call to "sscanf(r, "%f %n", &d, &j) > 0) {" uses the current locale and fails if the decimal point is _not_ a dot, but a comma.

TagsNo tags attached.

Activities

patrick

2012-01-23 11:46

reporter  

locale_mapfile_patch (4,958 bytes)   
diff --git a/source/texk/web2c/luatexdir/font/mapfile.w b/source/texk/web2c/luatexdir/font/mapfile.w
index b9947f9..7672d45 100644
--- a/source/texk/web2c/luatexdir/font/mapfile.w
+++ b/source/texk/web2c/luatexdir/font/mapfile.w
@@ -28,6 +28,7 @@ static const char _svn_version[] =
 #include <kpathsea/c-auto.h>
 #include <kpathsea/c-memstr.h>
 #include <string.h>
+#include <locale.h>
 
 #define FM_BUF_SIZE     1024
 
@@ -334,10 +335,12 @@ static void fm_scan_line(void)
 {
     int a, b, c, j, u = 0, v = 0;
     char cc;
+    char* oldloc;
     float d;
     fm_entry *fm;
     char fm_line[FM_BUF_SIZE], buf[FM_BUF_SIZE];
     char *p, *q, *r, *s;
+    oldloc = setlocale(LC_NUMERIC,"C");
     switch (mitem->type) {
     case MAPFILE:
         p = fm_line;
@@ -361,8 +364,10 @@ static void fm_scan_line(void)
     default:
         assert(0);
     }
-    if (*r == '\0' || is_cfg_comment(*r))
-        return;
+    if (*r == '\0' || is_cfg_comment(*r)) {
+      setlocale(LC_NUMERIC,oldloc);
+      return;
+    }
     fm = new_fm_entry();
     read_field(r, q, buf);
     set_field(tfm_name);
@@ -484,12 +489,17 @@ static void fm_scan_line(void)
        fm points to a valid, freshly filled-out fm_entry structure.
        Now follows the actual work of registering/deleting.
      */
-    if (handle_subfont_fm(fm, mitem->mode))     /* is this a subfont? */
-        return;
-    if (avl_do_entry(fm, mitem->mode) == 0)
-        return;
+    if (handle_subfont_fm(fm, mitem->mode)) {     /* is this a subfont? */
+      setlocale(LC_NUMERIC,oldloc);
+      return;
+    }
+    if (avl_do_entry(fm, mitem->mode) == 0) {
+      setlocale(LC_NUMERIC,oldloc);
+      return;
+    }
   bad_line:
     delete_fm_entry(fm);
+    setlocale(LC_NUMERIC,oldloc);
 }
 
 /**********************************************************************/
diff --git a/source/texk/web2c/luatexdir/luascripts/pdflua.c b/source/texk/web2c/luatexdir/luascripts/pdflua.c
index 3da37ec..de42772 100644
--- a/source/texk/web2c/luatexdir/luascripts/pdflua.c
+++ b/source/texk/web2c/luatexdir/luascripts/pdflua.c
@@ -20,25 +20,19 @@
 
 #include "ptexlib.h"
 
-static const Byte compr[250] = {
-    0x78, 0x9c, 0xad, 0x51, 0xc1, 0x4a, 0xc4, 0x30, 0x14, 0xbc, 0xbf, 0xaf, 0x78, 0x87, 0x1e, 0x14,
-    0xb6, 0x49, 0xba, 0x0a, 0xd2, 0x82, 0x1f, 0x20, 0x78, 0x12, 0xbc, 0x78, 0xeb, 0xa6, 0xaf, 0x6d,
-    0x68, 0x48, 0xc2, 0x4b, 0xe2, 0xba, 0x88, 0xff, 0x6e, 0x0a, 0x45, 0x57, 0xc5, 0xdb, 0x86, 0x97,
-    0x30, 0xcc, 0x4c, 0x32, 0x03, 0xa9, 0x6b, 0xac, 0x1e, 0x86, 0x0e, 0xc3, 0x30, 0xda, 0xdc, 0x8b,
-    0xb2, 0xf1, 0xa6, 0xbd, 0x6d, 0x71, 0xaf, 0x1a, 0x55, 0x37, 0x4d, 0xad, 0xee, 0x50, 0xa9, 0x4e,
-    0xb5, 0x5d, 0xd3, 0xbe, 0xe0, 0x3c, 0x93, 0x5b, 0xc8, 0x62, 0x05, 0x75, 0xb9, 0xf6, 0xfc, 0xf4,
-    0xd8, 0xe1, 0x9c, 0x52, 0xe8, 0xa4, 0x1c, 0x7d, 0x76, 0x03, 0x9f, 0x44, 0xcc, 0x81, 0x2c, 0x69,
-    0x31, 0xb2, 0x8c, 0xaf, 0x4e, 0x96, 0xe7, 0x12, 0xbd, 0xc9, 0xc4, 0xd9, 0x2d, 0x32, 0xfa, 0xcc,
-    0x9a, 0x64, 0x21, 0x16, 0x79, 0xa4, 0xc3, 0x5e, 0x6f, 0xf2, 0x60, 0x78, 0x45, 0x51, 0xb3, 0x09,
-    0x29, 0xca, 0xb3, 0x26, 0x15, 0xac, 0x41, 0x69, 0x36, 0x11, 0xcb, 0x50, 0xcf, 0xf6, 0x84, 0x47,
-    0xcf, 0x0b, 0x1a, 0x87, 0x81, 0xfd, 0xc4, 0x14, 0xa3, 0x10, 0x62, 0x75, 0x5d, 0x66, 0x01, 0x1c,
-    0x68, 0x32, 0x2e, 0xf4, 0x13, 0xe1, 0x3d, 0x8e, 0xd9, 0xe9, 0x64, 0xbc, 0xbb, 0xea, 0xaf, 0x81,
-    0xdc, 0x00, 0xeb, 0xf1, 0x9f, 0xe4, 0x73, 0x0a, 0x65, 0x8a, 0x1a, 0x13, 0xd3, 0x0f, 0xcb, 0xe6,
-    0xb8, 0x5c, 0x47, 0xeb, 0x75, 0x6f, 0xb7, 0x1f, 0x2b, 0x41, 0xef, 0x80, 0x78, 0x5e, 0xfb, 0x0b,
-    0xef, 0x8a, 0xf0, 0x5d, 0x79, 0x43, 0x2b, 0xf9, 0xb7, 0xec, 0x2f, 0x66, 0x07, 0x1f, 0x00, 0x4c,
-    0x29, 0xb3, 0xdb, 0x72, 0xe0, 0x13, 0x6d, 0xe3, 0xa0, 0x0e
+static const Byte compr[156] = {
+    0x78, 0x9c, 0xad, 0x4e, 0x4b, 0x0a, 0x42, 0x31, 0x0c, 0xdc, 0xe7, 0x14, 0x59, 0x74, 0xa1, 0xf0,
+    0xfa, 0x6e, 0xe0, 0x01, 0x04, 0x57, 0x82, 0x07, 0xa8, 0xaf, 0x79, 0xb5, 0x58, 0xda, 0x92, 0xb6,
+    0x88, 0x88, 0x77, 0xb7, 0x85, 0xe2, 0x17, 0x77, 0x2f, 0x0c, 0xc9, 0x90, 0x19, 0x98, 0x91, 0x12,
+    0xc5, 0x56, 0x0b, 0x90, 0xf5, 0x1e, 0xf6, 0x3b, 0x01, 0x8d, 0xe5, 0x93, 0x4d, 0x58, 0x41, 0x8a,
+    0xdd, 0x15, 0x2f, 0x81, 0xcf, 0x68, 0x3d, 0x46, 0x0e, 0x86, 0x29, 0xa5, 0x71, 0x1c, 0x9b, 0x6b,
+    0x99, 0x01, 0x38, 0x92, 0xb1, 0x3e, 0x2a, 0x43, 0xb8, 0xc1, 0xb9, 0xf8, 0x29, 0xdb, 0xe0, 0x57,
+    0x6a, 0x0d, 0xe4, 0x35, 0xb4, 0xf5, 0x4f, 0x0a, 0x25, 0xc7, 0x8a, 0xaa, 0xa6, 0xcc, 0xf4, 0x61,
+    0xe9, 0x8e, 0xe5, 0x3a, 0xba, 0x30, 0x29, 0x87, 0x51, 0xcf, 0xae, 0xa8, 0x1a, 0x74, 0x03, 0xc4,
+    0xf7, 0xda, 0x4f, 0x3e, 0x54, 0xe1, 0x55, 0xb9, 0xb3, 0xf6, 0xfc, 0x2d, 0xfb, 0xf5, 0x19, 0xe0,
+    0x0e, 0xc0, 0x94, 0x0b, 0xfb, 0x9e, 0x03, 0x0f, 0x2e, 0x3f, 0x6f, 0x9e
 };
 
-static const zlib_struct compr_struct = { 553, 250, compr };
+static const zlib_struct compr_struct = { 411, 156, compr };
 
 const zlib_struct *pdflua_zlib_struct_ptr = &compr_struct;
locale_mapfile_patch (4,958 bytes)   

patrick

2012-01-23 11:47

reporter   ~0000920

The patch is just a proof of concept. I don't have the feeling that I know what I am doing, so you probably should ignore it.

patrick

2012-01-23 11:51

reporter  

locale_mapfile_patch_without_junk (1,839 bytes)   
diff --git a/source/texk/web2c/luatexdir/font/mapfile.w b/source/texk/web2c/luatexdir/font/mapfile.w
index b9947f9..7672d45 100644
--- a/source/texk/web2c/luatexdir/font/mapfile.w
+++ b/source/texk/web2c/luatexdir/font/mapfile.w
@@ -28,6 +28,7 @@ static const char _svn_version[] =
 #include <kpathsea/c-auto.h>
 #include <kpathsea/c-memstr.h>
 #include <string.h>
+#include <locale.h>
 
 #define FM_BUF_SIZE     1024
 
@@ -334,10 +335,12 @@ static void fm_scan_line(void)
 {
     int a, b, c, j, u = 0, v = 0;
     char cc;
+    char* oldloc;
     float d;
     fm_entry *fm;
     char fm_line[FM_BUF_SIZE], buf[FM_BUF_SIZE];
     char *p, *q, *r, *s;
+    oldloc = setlocale(LC_NUMERIC,"C");
     switch (mitem->type) {
     case MAPFILE:
         p = fm_line;
@@ -361,8 +364,10 @@ static void fm_scan_line(void)
     default:
         assert(0);
     }
-    if (*r == '\0' || is_cfg_comment(*r))
-        return;
+    if (*r == '\0' || is_cfg_comment(*r)) {
+      setlocale(LC_NUMERIC,oldloc);
+      return;
+    }
     fm = new_fm_entry();
     read_field(r, q, buf);
     set_field(tfm_name);
@@ -484,12 +489,17 @@ static void fm_scan_line(void)
        fm points to a valid, freshly filled-out fm_entry structure.
        Now follows the actual work of registering/deleting.
      */
-    if (handle_subfont_fm(fm, mitem->mode))     /* is this a subfont? */
-        return;
-    if (avl_do_entry(fm, mitem->mode) == 0)
-        return;
+    if (handle_subfont_fm(fm, mitem->mode)) {     /* is this a subfont? */
+      setlocale(LC_NUMERIC,oldloc);
+      return;
+    }
+    if (avl_do_entry(fm, mitem->mode) == 0) {
+      setlocale(LC_NUMERIC,oldloc);
+      return;
+    }
   bad_line:
     delete_fm_entry(fm);
+    setlocale(LC_NUMERIC,oldloc);
 }
 
 /**********************************************************************/

luigi scarso

2015-10-22 22:30

developer   ~0001469

I will see it asap.

luigi scarso

2015-10-23 12:25

developer   ~0001475

I see
Heute ist der Friday im Monat October.
but not mapfile errors.

luigi scarso

2015-10-23 13:06

developer   ~0001476

The patch doesn't match anymore.

Hans Hagen

2015-11-16 17:56

manager   ~0001547

just reset the local eafterwards

os.setlocale("de_DE.utf8")
tex.print(os.date("Heute ist der %A im Monat %B."))
os.setlocale("C")

Issue History

Date Modified Username Field Change
2012-01-23 11:36 patrick New Issue
2012-01-23 11:46 patrick File Added: locale_mapfile_patch
2012-01-23 11:47 patrick Note Added: 0000920
2012-01-23 11:51 patrick File Added: locale_mapfile_patch_without_junk
2012-01-23 13:36 Taco Summary Makefile parser uses current locale => Mapfile parser uses current locale
2015-10-22 22:28 Hans Hagen Assigned To => luigi scarso
2015-10-22 22:28 Hans Hagen Status new => assigned
2015-10-22 22:30 luigi scarso Note Added: 0001469
2015-10-23 12:25 luigi scarso Note Added: 0001475
2015-10-23 13:06 luigi scarso Note Added: 0001476
2015-11-03 23:38 Hans Hagen Status assigned => closed
2015-11-03 23:38 Hans Hagen Resolution open => fixed
2015-11-16 17:56 Hans Hagen Note Added: 0001547