Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-04

Unix internationalization patch

12 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Hi.

Today i wrote code for filling formating variables in unix. I tested it only on Linux. I'm not sure with integration into unix/sysutils.pp and using libc. Patch is in the attachment.

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

Reply by email

Michael Van Canneyt
to Unknown author
Show quoted text 5 lines
Hi. Today i wrote code for filling formating variables in unix. I tested it only on Linux. I'm not sure with integration into unix/sysutils.pp and using libc. Patch is in the attachment.

This is not correct, it makes sysutils dependent on (g)libc and that is not allowed. The correct way of doing this is to make it a separate unit that links to libc, and fills all variables in it's initialization section.

Michael.

Reply by email

Unknown author
to Michael Van Canneyt
Michael Van Canneyt wrote 13 lines
On Tue, 8 Apr 2008, wrote: > Hi. > > Today i wrote code for filling formating variables in unix. I tested it > only on Linux. I'm not sure with integration into unix/sysutils.pp and using > libc. Patch is in the attachment. This is not correct, it makes sysutils dependent on (g)libc and that is not allowed. The correct way of doing this is to make it a separate unit that links to libc, and fills all variables in it's initialization section.

Ok. But where in rtl place this unit in the uses clause?

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

Reply by email

Jonas Maebe
to Unknown author
Show quoted text 9 lines
On Tue, Apr 08, 2008 at 04:29:51PM +0200, Michael Van Canneyt wrote: > > This is not correct, it makes sysutils dependent on (g)libc and > that is not > allowed. The correct way of doing this is to make it a separate unit > that links to libc, and fills all variables in it's initialization > section. Ok. But where in rtl place this unit in the uses clause?

Nowhere. You'll have to manually add it to the uses-clause of your programs, like the cwstring (widestring support for unix) and cthreads (threading support for unix) units.

Jonas

Reply by email

Unknown author
to Jonas Maebe
Jonas Maebe wrote 15 lines
On 08 Apr 2008, at 17:03, wrote: >On Tue, Apr 08, 2008 at 04:29:51PM +0200, Michael Van Canneyt wrote: >> > >>This is not correct, it makes sysutils dependent on (g)libc and >>that is not >>allowed. The correct way of doing this is to make it a separate unit >>that links to libc, and fills all variables in it's initialization >>section. >Ok. But where in rtl place this unit in the uses clause? Nowhere. You'll have to manually add it to the uses-clause of your programs, like the cwstring (widestring support for unix) and cthreads (threading support for unix) units.

Here is attached separated clocale.pp. I think that it should be placed into rtl/unix directory. Unit is tested only in Linux environment, but I assume that on other unices will be necessary to add some $IFDEFs.

Finally a little question. I'am here new, do not know context and my english is bad. But why rtl/win/sysutils.pp can depend on windows and rtl/unix/sysutils.pp cannot depend on libc?

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

Reply by email

Michael Van Canneyt
to Unknown author
Show quoted text 23 lines
On Tue, Apr 08, 2008 at 05:19:34PM +0200, Jonas Maebe wrote: > > On 08 Apr 2008, at 17:03, wrote: > >On Tue, Apr 08, 2008 at 04:29:51PM +0200, Michael Van Canneyt wrote: > >> > > > >>This is not correct, it makes sysutils dependent on (g)libc and > >>that is not > >>allowed. The correct way of doing this is to make it a separate unit > >>that links to libc, and fills all variables in it's initialization > >>section. > >Ok. But where in rtl place this unit in the uses clause? > > Nowhere. You'll have to manually add it to the uses-clause of your > programs, like the cwstring (widestring support for unix) and cthreads > (threading support for unix) units. Here is attached separated clocale.pp. I think that it should be placed into rtl/unix directory. Unit is tested only in Linux environment, but I assume that on other unices will be necessary to add some $IFDEFs. Finally a little question. I'am here new, do not know context and my english is bad. But why rtl/win/sysutils.pp can depend on windows and rtl/unix/sysutils.pp cannot depend on libc?

Because on windows you know what is there and what not. Microsoft keeps everything reasonly stable and backwards compatible. There is also only 1 architecture to support (well, now it is 2)

On Linux (or other unixes), libc is commonly glibc, but sometimes not, it is different on all CPU platforms, and often breaks backwards compatibility. We would be continuously play catch-up with the libc team.

So the rule is that we only rely on direct Kernel calls, which does stay reasonably backwards (or forwards, whatever you want to call it) compatible.

Michael.

Reply by email

Michael Van Canneyt
to Unknown author: Here is attached separated clocale.pp. I think that it should be placed into rtl/unix…
Show quoted text 19 lines
On Tue, Apr 08, 2008 at 05:19:34PM +0200, Jonas Maebe wrote: > > On 08 Apr 2008, at 17:03, wrote: > >On Tue, Apr 08, 2008 at 04:29:51PM +0200, Michael Van Canneyt wrote: > >> > > > >>This is not correct, it makes sysutils dependent on (g)libc and > >>that is not > >>allowed. The correct way of doing this is to make it a separate unit > >>that links to libc, and fills all variables in it's initialization > >>section. > >Ok. But where in rtl place this unit in the uses clause? > > Nowhere. You'll have to manually add it to the uses-clause of your > programs, like the cwstring (widestring support for unix) and cthreads > (threading support for unix) units. Here is attached separated clocale.pp. I think that it should be placed into rtl/unix directory. Unit is tested only in Linux environment, but I assume that on other unices will be necessary to add some $IFDEFs.

I'll first ask in the core team, where to put it.

Michael.

Reply by email

Florian Klaempfl
to Unknown author: Here is attached separated clocale.pp. I think that it should be placed into rtl/unix…
Finally a little question. I'am here new, do not know context and my english is bad. But why rtl/win/sysutils.pp can depend on windows and rtl/unix/sysutils.pp cannot depend on libc?

Because when depending on libc it's virtually impossible to build an executable which runs on all current linuxes for one architecture. Not to mention somewhat older linuxes.

Reply by email

Unknown author
to Jonas Maebe
Jonas Maebe wrote 11 lines
On 08 Apr 2008, at 15:54, wrote: >Today i wrote code for filling formating variables in unix. I tested >it >only on Linux. I'm not sure with integration into unix/sysutils.pp >and using >libc. Patch is in the attachment. Can you also supply your test program? (it's no problem if it requires manual inspection of the output)

I easy diff output this procedure compilled by kylix and fpc.

procedure PrintSettings;
var
  i: integer;
begin
  for i := 1 to 12 do
    begin
    writeln(ShortMonthNames[i]);
    writeln(LongMonthNames[i]);
    end;
  for i := 1 to 7 do
    begin
    writeln(ShortDayNames[i]);
    writeln(LongDayNames[i]);
    end;
  writeln(DateSeparator);
  writeln(ShortDateFormat);
  writeln(LongDateFormat);
  { Time stuff }
  writeln(TimeSeparator);
  writeln(TimeAMString);
  writeln(TimePMString);
  // No support for 12 hour stuff at the moment...
  writeln(ShortTimeFormat);
  writeln(LongTimeFormat);
  { Currency stuff }
  writeln(CurrencyString);
  writeln(CurrencyFormat);
  writeln(NegCurrFormat);
  { Number stuff }
  writeln(ThousandSeparator);
  writeln(DecimalSeparator);
  writeln(CurrencyDecimals);
end;

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

Reply by email

Jonas Maebe
to Unknown author
Show quoted text 8 lines
On Thu, Apr 24, 2008 at 10:38:19AM +0200, Jonas Maebe wrote: > > Can you also supply your test program? (it's no problem if it > requires > manual inspection of the output) I easy diff output this procedure compilled by kylix and fpc.

Thanks!

Jonas

Reply by email

Unknown author
to Unknown author: Hi. Today i wrote code for filling formating variables in unix. I tested it only on…

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

Reply by email