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

Mailing lists / fpc-devel / 2008-04
12 messages · 4 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
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
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.
Ok. But where in rtl place this unit in the uses clause?
Petr
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
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
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.
Here is attached separated clocale.pp. I think that it should be placed into rtl/unix…
I'll first ask in the core team, where to put it.
Michael.
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.
Hi. Today i wrote code for filling formating variables in unix. I tested it only on…
Can you also supply your test program? (it's no problem if it requires manual inspection of the output)
Jonas
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
Thanks!
Jonas
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