[fpc-devel] clocale glibc extension patch

petr.kristan at epos.cz petr.kristan at epos.cz
Thu Sep 11 17:10:58 CEST 2008


Hi.

I'am author of initial implementation clocale. On Ubuntu I found some incompatibilities.
And here is little patch, which reflects some glibc extensions to strftime.
We need to omit some more modifiers than 'E' and 'O'.

I send this patch 28.04.2008 but was probably forgotten.

Index: rtl/unix/clocale.pp
===================================================================
--- rtl/unix/clocale.pp (revision 11355)
+++ rtl/unix/clocale.pp (working copy)
@@ -104,20 +104,31 @@
     GetLocaleChar := nl_langinfo(item)^;
   end;
 
+  procedure OmitModifiers(const s: string; var i: integer);
+  var
+    l: Integer;
+  begin
+    l := Length(s);
+    if (i<=l) and (s[i] in ['E', 'O']) then //possible modifier
+      inc(i);
+    if (i<=l) and (s[i] in ['_', '-', '0', '^', '#']) then //possible flag - glibc extension
+      inc(i);
+    while (i<=l) and (s[i] in ['0'..'9']) do //possible with specifier - glibc exension
+      inc(i);
+  end;
+
   function FindSeparator(const s: string; Def: char): char;
   var
-    i, l: integer;
+    i: integer;
   begin
     FindSeparator := Def;
     i := Pos('%', s);
     if i=0 then
       Exit;
-    l := Length(s);
     inc(i);
-    if (i<=l) and (s[i] in ['E', 'O']) then //possible modifier
-      inc(i);
-    inc(i); 
-    if i<=l then
+    OmitModifiers(s, i);
+    inc(i);
+    if i<=Length(s) then
       FindSeparator := s[i];
   end;
 
@@ -133,8 +144,7 @@
     while i<=l do begin
       if s[i]='%' then begin
         inc(i);
-        if (i<=l) and (s[i] in ['E', 'O']) then //ignore modifier
-          inc(i);
+        OmitModifiers(s, i);
         if i>l then
           Exit;
         case s[i] of

Petr

-- 
Ing. Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223    Czech Republic (Eastern Europe) 
fax: +420 466510709



More information about the fpc-devel mailing list