[fpc-devel] Unix internationalization patch
petr.kristan at epos.cz
petr.kristan at epos.cz
Mon Apr 28 15:50:32 CEST 2008
Hi
Here is little patch, which reflects some glibc extensions to strftime.
We need to omit some more modifiers.
Petr
Index: unix/clocale.pp
===================================================================
--- unix/clocale.pp (revision 10833)
+++ 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
--
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