[fpc-devel] How to clearly shutdown ThreadManager
Hi. If I check my multithreaded program with valgrind in linux I get these memoryleaks: ==27262== 32 bytes in 1 blocks are still reachable in loss record 1 of 2 ==27262==at 0x4C27480: calloc (vg_replace_malloc.c:467) ==27262==by 0x504C31F: _dlerror_run (dlerror.c:142) ==27262==by 0x504BEE0: dlopen@@GLIBC_2.2.5 (dlopen.c:88) ==27262==by 0x43E368: CTHREADS_LOADPTHREADS$$BOOLEAN (pthread.inc:261) ==27262==by 0x43FC38: CTHREADS_CINITTHREADS$$BOOLEAN (cthreads.pp:960) ==27262==by 0x4324D0: SYSTEM_SETTHREADMANAGER$TTHREADMANAGER$$BOOLEAN (thread.inc:241) ==27262==by 0x43FF96: CTHREADS_SETCTHREADMANAGER (cthreads.pp:1025) ==27262==by 0x440023: CTHREADS_init (cthreads.pp:1036) ==27262==by 0x42E8FE: fpc_initializeunits (system.inc:794) ==27262==by 0x417F16: main (xmlrpcserver.dpr:21) ==27262== ==27262== 56 bytes in 1 blocks are still reachable in loss record 2 of 2 ==27262==at 0x4C2815C: malloc (vg_replace_malloc.c:236) ==27262==by 0x400D624: _dl_map_object_deps (dl-deps.c:506) ==27262==by 0x4013964: dl_open_worker (dl-open.c:263) ==27262==by 0x400ED35: _dl_catch_error (dl-error.c:178) ==27262==by 0x4013329: _dl_open (dl-open.c:555) ==27262==by 0x504BF65: dlopen_doit (dlopen.c:67) ==27262==by 0x400ED35: _dl_catch_error (dl-error.c:178) ==27262==by 0x504C2AB: _dlerror_run (dlerror.c:164) ==27262==by 0x504BEE0: dlopen@@GLIBC_2.2.5 (dlopen.c:88) ==27262==by 0x43E368: CTHREADS_LOADPTHREADS$$BOOLEAN (pthread.inc:261) ==27262==by 0x43FC38: CTHREADS_CINITTHREADS$$BOOLEAN (cthreads.pp:960) ==27262==by 0x4324D0: SYSTEM_SETTHREADMANAGER$TTHREADMANAGER$$BOOLEAN (thread.inc:241) ==27262==by 0x43FF96: CTHREADS_SETCTHREADMANAGER (cthreads.pp:1025) ==27262==by 0x440023: CTHREADS_init (cthreads.pp:1036) ==27262==by 0x42E8FE: fpc_initializeunits (system.inc:794) ==27262==by 0x417F16: main (xmlrpcserver.dpr:21) IMHO it is because CThreadManager.DoneManager (calls UnLoadPthreads) is not called at the end of program. Is any way how to shutdown threading and satisfy valgrind by dlclose()? Thanks Petr -- Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] RangeCheck error in SetResourceStrings
Hi. After upgrade fpc to trunk rev. 17622 I get in function SetResourceStrings line 333 fpc_rangeerror. s:=SetFunction(ResStr^.Name,ResStr^.DefaultValue,ResStr^.HashValue,arg); This occurs on translation resource: ResStr^ = {NAME = 0x9e7410 'rtlconsts.smcinil', CURRENTVALUE = 0x0, DEFAULTVALUE = 0x0, HASHVALUE = 4294967295, DUMMY = 0} Definition of resourcestring I found in: rtl/objpas/rtlconst.inc: SMCINil = ''; But in rst file is not '' but this: rtl/units/i386-win32/rtlconsts.rst # hash value = 4294967295 rtlconsts.smcinil= I tried manualy repair rtlconsts.rst rtlconsts.smcinil='' And after rebuild everything was ok. I assume that file is generated, but cannot found how. In order to try repair it. Petr -- Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Heaptrace + cwstring cause SIGSEGV at the end
Hi. I use heaptrc and cwstring units in Linux. If memoryleak occurs and program ends, then i get SIGSEGV in cwstring.pp:481 (iconv call) because cwstring unit is finalized before heaptrc. #1 iconv(, 0x7fffd738, 0x7fffd760, 0x7fffd730, 0x7fffd748) at iconv.c:53 #2 ANSI2WIDEMOVE(0x7fffef7cf038 '/home/petr/obis4/bin/obis-linux', 65001, 0x7fffee687dd8 '', 31) at ../unix/cwstring.pp:481 #3 fpc_ansistr_to_widechararray(0x7fffd830 #43472#63484#32767, 255, 0x7fffef7cf038 '/home/petr/obis4/bin/obis-linux') at ../inc/ustrings.inc:820 #4 ASSIGN({}, 0x7fffef7cf038 '/home/petr/obis4/bin/obis-linux') at ../inc/file.inc:58 #5 ASSIGN({}, '/home/petr/obis4/bin/obis-linux') at ../inc/file.inc:71 #6 OPENEXEFILE({F = {}, SIZE = 0, ISOPEN = false, NSECTS = 0, SECHDROFS = 0, SECSTROFS = 0, PROCESSADDRESS = 0, FUNCTIONRELATIVE = false, IMGOFFSET = 0, FILENAME = ... #7 OPENDWARF(0x4633a2) at ../inc/lnfodwrf.pp:152 #8 GETLINEINFO(4600738, '', '', 0) at ../inc/lnfodwrf.pp:734 #9 DWARFBACKTRACESTR(0x4633a2) at ../inc/lnfodwrf.pp:767 #10 CALL_STACK(0x7fffeea43d00, {}) at ../inc/heaptrc.pp:307 #11 DUMPHEAP at ../inc/heaptrc.pp:1233 #12 TRACEEXIT at ../inc/heaptrc.pp:1486 #13 HEAPTRC_$$_finalize at :1615 #14 FINALIZEUNITS at ../inc/system.inc:907 #15 INTERNALEXIT at ../inc/system.inc:960 #16 DO_EXIT at ../inc/system.inc:1024 #17 main at obis.lpr:63 Heaptrace is switched on by -gl fpc option. obis.lpr: uses cthreads, cwstring ... fpc 2.7.1 and lazarus 1.3 Exists some solution for this problem? Thanks Petr -- Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401Czech Republic (Eastern Europe) fax: +420 461101481 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[fpc-devel] Need heap manager -gv explanation
Hi I have some application with huge usage ReAllocMem and I found the big performance difference if application is compiled with -gv option (cca 20x faster) then without -gv option. I suspect fpc heap manager. Is possible to tune fpc heap manager? Is some difference in heap manager if application is comiled with -gv or without -gv option? Thanks Petr -- Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401Czech Republic (Eastern Europe) fax: +420 461101481 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Need heap manager -gv explanation
On Mon, Apr 28, 2014 at 06:12:18PM +0200, Tomas Hajny wrote: > On Mon, April 28, 2014 17:56, Mattias Gaertner wrote: > > On Mon, 28 Apr 2014 17:20:17 +0200 > > Petr Kristan wrote: > > > >> Hi > >> > >> I have some application with huge usage ReAllocMem and I found the big > >> performance difference if application is compiled with -gv option (cca > >> 20x faster) then without -gv option. > > > > -gv generates code for valgrind. > > It should be slower with -gv. > > > >> I suspect fpc heap manager. Is possible to tune fpc heap manager? > >> Is some difference in heap manager if application is comiled with -gv or > >> without -gv option? > > Use of valgrind requires/triggers use of cmem. Depending on the particular > use case (and potentially also the target platform), cmem may indeed be > faster. Platform is x86_64 Linux. > Others would be better positioned for more detailed comparison among > various heap managers with regard to speed in different use cases, overall > memory requirements achieved by reuse of previously allocated memory, etc. Reuse of previously allocated memory - it really can be my problem. Here is about 200x call ReAllocMem increasing buffer from 4kB to 80MB. It looks like as buffer is increasing ReAllocMem is slowing. But I must verify this feeling. Petr -- Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401Czech Republic (Eastern Europe) fax: +420 461101481 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Need heap manager -gv explanation [tests]
On Mon, Apr 28, 2014 at 09:29:50PM +0200, Mattias Gaertner wrote: > On Mon, 28 Apr 2014 21:14:14 +0200 > Petr Kristan wrote: > > >[...] > > > Others would be better positioned for more detailed comparison among > > > various heap managers with regard to speed in different use cases, overall > > > memory requirements achieved by reuse of previously allocated memory, etc. > > Reuse of previously allocated memory - it really can be my problem. > > Here is about 200x call ReAllocMem increasing buffer from 4kB to 80MB. > > Check if you are increasing buffers in constant steps. > Change the increment to exponentially. I use "inteligent" block increasing. I can optimize program, but why is fpc heap manager to slow? Here is the sample stress program compilable with fpc, delphi and kylix: program m; {$IFDEF MSWINDOWS} {$APPTYPE CONSOLE} {$ENDIF} uses {$IFDEF MSWINDOWS} Windows, {$ELSE} {$IFDEF FPC} Unix, {$ELSE} Libc, {$ENDIF} {$ENDIF} SysUtils; {$IFDEF MSWINDOWS} function GetTickCount: Cardinal; begin GetTickCount := Windows.GetTickCount; end; {$ELSE} {$IFDEF FPC} function GetTickCount: Cardinal; var tp: TTimeVal; begin fpgettimeofday(@tp, nil); GetTickCount := (Int64(tp.tv_sec) * 1000) + (tp.tv_usec div 1000); end; {$ELSE} function GetTickCount: Cardinal; var ts: TTimeSpec; i: Int64; const CLOCK_MONOTONIC = 1; begin if clock_gettime(CLOCK_MONOTONIC, ts) <> 0 then begin Result := 0; Exit; end; i := ts.tv_sec; i := i*1000 + ts.tv_nsec div 100; Result := i and $; end; {$ENDIF} {$ENDIF} var p1, p2: Pointer; i, j: integer; ms, sum: Cardinal; const base = 100; begin sum := GetTickCount; for i := 0 to 10 do begin ms := GetTickCount; for j := 1 to 9 do begin ReAllocMem(p1, base*(i*10+j)); ReAllocMem(p2, base*(i*10+j)); end; Writeln(Format('Grow %d-%d %dms', [base*i*10, base*(i*10+9), GetTickCount-ms])); end; FreeMem(p1); FreeMem(p2); Writeln(Format('Sum %dms', [GetTickCount-sum])); end. And here are results: ppcx64 m.pas Free Pascal Compiler version 2.7.1 [2014/02/17] for x86_64 Target OS: Linux for x86-64 Grow 0-900 89ms Grow 1000-1900 281ms Grow 2000-2900 488ms Grow 3000-3900 716ms Grow 4000-4900 898ms Grow 5000-5900 1085ms Grow 6000-6900 1294ms Grow 7000-7900 1470ms Grow 8000-8900 1652ms Grow 9000-9900 1916ms Grow 1-10900 2099ms Sum 12007ms ppcx64 -gv m.pas Free Pascal Compiler version 2.7.1 [2014/02/17] for x86_64 Target OS: Linux for x86-64 Grow 0-900 0ms Grow 1000-1900 0ms Grow 2000-2900 1ms Grow 3000-3900 0ms Grow 4000-4900 0ms Grow 5000-5900 0ms Grow 6000-6900 2ms Grow 7000-7900 3ms Grow 8000-8900 2ms Grow 9000-9900 0ms Grow 1-10900 0ms Sum 10ms ppc386 m.pas Free Pascal Compiler version 2.7.1 [2013/06/28] for i386 Target OS: Linux for i386 Grow 0-900 86ms Grow 1000-1900 247ms Grow 2000-2900 417ms Grow 3000-3900 595ms Grow 4000-4900 781ms Grow 5000-5900 964ms Grow 6000-6900 1128ms Grow 7000-7900 1288ms Grow 8000-8900 1438ms Grow 9000-9900 1612ms Grow 1-10900 1767ms Sum 10341ms ppc386 -gv m.pas Free Pascal Compiler version 2.7.1 [2013/06/28] for i386 Target OS: Linux for i386 Grow 0-900 0ms Grow 1000-1900 0ms Grow 2000-2900 0ms Grow 3000-3900 0ms Grow 4000-4900 0ms Grow 5000-5900 0ms Grow 6000-6900 1ms Grow 7000-7900 0ms Grow 8000-8900 0ms Grow 9000-9900 0ms Grow 1-10900 0ms Sum 1ms dcc m.pas Borland Delphi for Linux Version 14.5 Grow 0-900 0ms Grow 1000-1900 0ms Grow 2000-2900 0ms Grow 3000-3900 0ms Grow 4000-4900 0ms Grow 5000-5900 0ms Grow 6000-6900 0ms Grow 7000-7900 0ms Grow 8000-8900 0ms Grow 9000-9900 0ms Grow 1-10900 0ms Sum 2ms fpc m.pas Free Pascal Compiler version 2.7.1 [2013/12/27] for i386 Target OS: Win32 for i386 Grow 0-900 47ms Grow 1000-1900 157ms Grow 2000-2900 359ms Grow 3000-3900 531ms Grow 4000-4900 656ms Grow 5000-5900 797ms Grow 6000-6900 985ms Grow 7000-7900 1109ms Grow 8000-8900 1250ms Grow 9000-9900 1406ms Grow 1-10900 1532ms Sum 8829ms dcc m.pas Borland Delphi Version 15.0 Grow 0-900 16ms Grow 1000-1900 31ms Grow 2000-2900 47ms Grow 3000-3900 47ms Grow 4000-4900 109ms Grow 5000-5900 63ms Grow 6000-6900 62ms Grow 7000-7900 250ms Grow 8000-8900 266ms
Re: [fpc-devel] Need heap manager -gv explanation [tests]
On Tue, Apr 29, 2014 at 11:49:20AM +0200, Tomas Hajny wrote: > On Tue, April 29, 2014 10:30, Petr Kristan wrote: > . > . > > I use "inteligent" block increasing. I can optimize program, but why is > > fpc heap manager to slow? > > > > Here is the sample stress program compilable with fpc, delphi and kylix: > . > . > > And here are results: > . > . > > Is possible to speedup heap manager? > > Well, results of your test program on my machine (physical machine, MS Win > 7 32-bit) show something different: > > Grow 0-900 31ms > Grow 1000-1900 109ms > Grow 2000-2900 172ms > Grow 3000-3900 250ms > Grow 4000-4900 327ms > Grow 5000-5900 406ms > Grow 6000-6900 483ms > Grow 7000-7900 546ms > Grow 8000-8900 625ms > Grow 9000-9900 702ms > Grow 1-10900 764ms > Sum 4431ms > > (compiled without cmem / without valgrind) > > Grow 0-900 31ms > Grow 1000-1900 125ms > Grow 2000-2900 203ms > Grow 3000-3900 265ms > Grow 4000-4900 375ms > Grow 5000-5900 436ms > Grow 6000-6900 531ms > Grow 7000-7900 624ms > Grow 8000-8900 733ms > Grow 9000-9900 796ms > Grow 1-10900 873ms > Sum 5008ms > > (compiled with -gv; as expected, adding CMem to the uses clause and > compiling without -gv gives basically the same result). Are you sure that -gv in windows has any effect? I think, that valgrind can be used only in unix systems. Isn't -gv option silently ignored in windows? > Tests performed with trunk compiler based on SVN from about 10 days ago. > Results for 2.6.4 are more or less the same. Approve, I tested in 2.6. too. > I don't know the reason of your difference, but no time necessary at all > (0 ms) for the valgrind variant looks very suspicious to me. But compiling by kylix compiler, i get the same results as by fpc with -gv option in linux. This is the reason why I start to hunt where is my program to slow if compiled by fpc against kylix. Petr -- Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401Czech Republic (Eastern Europe) fax: +420 461101481 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Need heap manager -gv explanation [tests]
On Tue, Apr 29, 2014 at 11:41:59AM +0200, Mattias Gaertner wrote: > On Tue, 29 Apr 2014 10:30:43 +0200 > Petr Kristan wrote: > > >[...] > > > Check if you are increasing buffers in constant steps. > > > Change the increment to exponentially. > > I use "inteligent" block increasing. I can optimize program, but why is > > fpc heap manager to slow? > >[...] > > const > > base = 100; > > begin > > sum := GetTickCount; > > for i := 0 to 10 do begin > > ms := GetTickCount; > > for j := 1 to 9 do begin > > ReAllocMem(p1, base*(i*10+j)); > > ReAllocMem(p2, base*(i*10+j)); > > end; > > Writeln(Format('Grow %d-%d %dms', [base*i*10, base*(i*10+9), > > GetTickCount-ms])); > > end; > > Reallocmen checks if there is enough free mem behind. If not it > allocates a new mem and copies the content. > > The fpc heap manager allocates new mem behind the > already allocated mem. Running two Reallocmem have almost never enough > free mem behind and they have to copy often. > > cmem leaves more space behind the blocks, so that calling Reallocmen > with small increases needs less copies. AFAIK the cmem algorithm depends > on OS. Is possible to tune this space behind the blocks? Petr -- Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401Czech Republic (Eastern Europe) fax: +420 461101481 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Need heap manager -gv explanation [tests]
On Tue, Apr 29, 2014 at 03:02:44PM +0400, Sergei Gorelkin wrote: > On 29.04.2014 14:37, Tomas Hajny wrote: > > >>>I don't know the reason of your difference, but no time necessary at all > >>>(0 ms) for the valgrind variant looks very suspicious to me. > >>But compiling by kylix compiler, i get the same results as by fpc with > >>-gv option in linux. > >>This is the reason why I start to hunt where is my program to slow if > >>compiled by fpc against kylix. > > > >Can't it be somehow related to the method used for measuring the time > >under Linux? Is the result shown inside consistent to the overall time > >necessary for the program run? > > > Time measurement appears to be correct. Strace shows that > reallocation happens using mremap syscalls, which apparently > rearranges pages within address space without actual moving the > data. This indeed can be done with almost zero overhead, but is > hardly portable. Thanks for the fast and perfect explanation. Resolution for me is that heap manager cannot be multiplatformly improved. I do some optimatization in my code. Petr -- Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401Czech Republic (Eastern Europe) fax: +420 461101481 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[fpc-devel] StrToDateTime and ShortDateFormat = 'd. M. yyyy'
Hi In our country in Windows 8 is preset default short date format "d. M. " In fpc: DefaultFormatSettings.ShortDateFormat is set to 'd. M. ' DefaultFormatSettings.DateSeparator = '.' StrToDateTime('1. 1. 2000 12:00') has problem because func SplitDateTimeStr scans input string forward to find WhiteSpace. I Delphi7 StrToDateTime works correctly. After short look at rtl code I do not see any solution with SplitDateTimeStr. I think that correct solution is to first try parse date without splitting and then parse remaining optional time. I can try to do that, but are there any StrToDateTime tests? I do not want to break what is working until now. Petr -- Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401Czech Republic (Eastern Europe) fax: +420 461101481 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Console encoding on Windows, output to file with ">"
On Wed, May 03, 2017 at 08:34:14AM +0200, Ondrej Pokorny wrote: > Hello, > > I have a simple FPC program: > > --- > program GermanTest; > > {$codepage utf8} > begin > Writeln('ÄäÖöÜüß'); > end. > --- > > If I run it in the console, I see correct characters: > > BUT when I redirect the output to a file with ">" : > > GermanTest.exe > GermanTest.txt I get corrupted characters "Ž„™”š?á" (see > attachment). > > I tried various possibilities but either the console output is correct or > the file output is correct. Never both of them. > > E.g. > --- > program GermanTest; > > {$codepage utf8} > > uses > Windows, SysUtils, Classes; > > begin > SetConsoleOutputCP(CP_UTF8); > > Writeln('ÄäÖöÜüß'); Try: Writeln(UTF8ToSys('ÄäÖöÜüß')); > end. > --- > > Works fine for file output but the console shows wrong characters. > > What should I do so that both outputs are correct? Or is it an FPC bug? > Delphi works fine - both outputs are correct. > > FPC version: current trunk 3.1.1 Windows, 32bit. > OS: Windows 10, 64bit > > Ondrej > > УУЄУУЖУУМУ > ___ > fpc-devel maillist - fpc-devel@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel -- Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401Czech Republic (Eastern Europe) fax: +420 461101481 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[fpc-devel] libc patch
imer_t; __flags:longint; const __value: titimerspec; var __ovalue:titimerspec):longint;cdecl;external clib name 'timer_settime'; +function timer_settime(__timerid:timer_t; __flags:longint; const __value: titimerspec; __ovalue:Pitimerspec):longint;cdecl;external clib name 'timer_settime'; function timer_gettime(__timerid:timer_t; var __value: titimerspec):longint;cdecl;external clib name 'timer_gettime'; -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Linux ELF linking problem
Linux i386 system, fpc from svn rev 10506. Simple program for retrive system charset: program b; uses Libc; begin writeln(nl_langinfo(CODESET)); end. Prints: ANSI_X3.4-1968 I think, libc is not inicialized. ltrace ./b: nl_langinfo(14, None of __libc_start_main(... at begining. objdump -R b None jump slot __libc_start_main It looks like some ELF linking problem. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Linux ELF linking problem
On Wed, Mar 19, 2008 at 11:50:29AM +0100, Jonas Maebe wrote: > > On 19 Mar 2008, at 11:20, [EMAIL PROTECTED] wrote: > > >Linux i386 system, fpc from svn rev 10506. > > Did this work before? If so, between which and which revision did it > stop working? No, it was first experiment. > >Simple program for retrive system charset: > > > >program b; > >uses > > Libc; > >begin > > writeln(nl_langinfo(CODESET)); > >end. > > > >Prints: ANSI_X3.4-1968 > > You are normally required to initialise the locale yourself before > calling nl_langinfo(CODESET), by calling setlocal(LC_ALL,'') (at least > on non-Linux this is always needed). I'am very sorry, I do not know about initializing (setlocale(LC_ALL,'')). With this it works ok. Thanks. With kylix compiler it works without initializing, now I found why. In sysutils initialization they call setlocale. It confused me. But missing __libc_start_main do not mind? I think that it initializes malloc and threads. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] TComponent.Tag type
Hi. I'am porting some code from 32 to 64 bit. And I found that TComponent.Tag is longint tj. 32bit. In my code is common to store Pointer into Tag, but this is in 64bit inpossible. What about to change Tag type to SizeInt. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] TComponent.Tag type
On Thu, Mar 20, 2008 at 03:05:36PM +0700, Paul Ishenin wrote: > [EMAIL PROTECTED] wrote: > >Hi. > > > >I'am porting some code from 32 to 64 bit. And I found that > >TComponent.Tag is longint tj. 32bit. In my code is common to store > >Pointer into Tag, but this is in 64bit inpossible. > > > >What about to change Tag type to SizeInt. > > Inspired by borland.delphi.public.non-technical? No, this is necessity. I do not know how to effectively change my code to not use Tag property. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Variants patch
Enables inserting variants arrays into variant. Index: rtl/inc/variants.pp === --- rtl/inc/variants.pp (revision 10368) +++ rtl/inc/variants.pp (working copy) @@ -3166,7 +3166,7 @@ Result:=true else begin -Result:=(aVarType and not(varByRef)) in [varEmpty,varNull,varSmallInt,varInteger,varSingle,varDouble, +Result:=(aVarType and not(varByRef) and not(varArray)) in [varEmpty,varNull,varSmallInt,varInteger,varSingle,varDouble, varCurrency,varDate,varOleStr,varDispatch,varError,varBoolean, varVariant,varUnknown,varShortInt,varByte,varWord,varLongWord,varInt64]; end; -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Little fcl-db patch
Only creates and destroys Constraints, ZEOS depends on it. Index: packages/fcl-db/src/base/dataset.inc === --- packages/fcl-db/src/base/dataset.inc(revision 10368) +++ packages/fcl-db/src/base/dataset.inc(working copy) @@ -27,6 +27,7 @@ FFieldDefs:=TFieldDefs.Create(Self); FFieldList:=TFields.Create(Self); FDataSources:=TList.Create; + FConstraints:=TCheckConstraints.Create(Self); // FBuffer must be allocated on create, to make Activebuffer return nil ReAllocMem(FBuffers,SizeOf(PChar)); @@ -58,6 +59,7 @@ end; for i := 0 to FBufferCount do FreeRecordBuffer(FBuffers[i]); + FConstraints.Free; FreeMem(FBuffers); Inherited Destroy; end; -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Variants patch
On Sat, Mar 22, 2008 at 05:22:43PM +0100, Florian Klaempfl wrote: > [EMAIL PROTECTED] schrieb: > > Enables inserting variants arrays into variant. > > Do you have a test which shows how this works? Is this delphi > compatible? Are you sure that it is enough just to allow it? I tested it on our delphi application, which uses deeply nested variant arrays. Results are the same compiled by delphi or fpc. I will continue with testnig this week. > > > > Index: rtl/inc/variants.pp > > === > > --- rtl/inc/variants.pp (revision 10368) > > +++ rtl/inc/variants.pp (working copy) > > @@ -3166,7 +3166,7 @@ > >Result:=true > > else > >begin > > -Result:=(aVarType and not(varByRef)) in > > [varEmpty,varNull,varSmallInt,varInteger,varSingle,varDouble, > > +Result:=(aVarType and not(varByRef) and not(varArray)) in > > [varEmpty,varNull,varSmallInt,varInteger,varSingle,varDouble, > >varCurrency,varDate,varOleStr,varDispatch,varError,varBoolean, > > > > varVariant,varUnknown,varShortInt,varByte,varWord,varLongWord,varInt64]; > >end; > > > > > > _______ > fpc-devel maillist - fpc-devel@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-devel -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] AllocMem(0)<>nil
Hi. I discovered some Delphi incompatibility. Call AllocMem(0) do not return nil. Fpc from svn. In SysGetMem are some comments about it: if size=0 then { we always need to allocate something, using heapend is not possible, because heappend can be changed by growheap (PFV) } size := 1; Is this behaviour essential, or is possible make it compatible with Delphi? Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] AllocMem(0)<>nil
On Tue, Mar 25, 2008 at 06:58:28PM +0100, Jonas Maebe wrote: > > On 25 Mar 2008, at 18:54, Vincent Snijders wrote: > > >Jonas Maebe schreef: > >>On 25 Mar 2008, at 18:30, Peter Vreman wrote: > >>>Current behaviour is compatible with TP7 that gave a valid pointer > >>>back pointing to heapend. See > >>>also the comment. > >>I thought so too, but I tested and TP7 stores nil in p when doing > >>getmem(p,0) (under DosBox). > > > >But AllocMem(0)? > > AllocMem does not exist in TP7. And the code posted by the original > poster comes from SysGetMem, not from AllocMem (which is just a > wrapper for getmem+fillchar). Yes. I tested GetMem and AllocMem in TP7.0, Delphi1, Delphi7, Kylix and all compillers returns nil when size is zero. This patch solves it. Index: inc/heap.inc === --- inc/heap.inc(revision 10368) +++ inc/heap.inc(working copy) @@ -991,10 +991,11 @@ function SysGetMem(size : ptruint):pointer; begin { Something to allocate ? } - if size=0 then -{ we always need to allocate something, using heapend is not possible, - because heappend can be changed by growheap (PFV) } -size := 1; + if size<=0 then +begin + result := nil; + exit; +end; { calc to multiple of 16 after adding the needed bytes for memchunk header } if size <= (maxblocksize - sizeof(tmemchunk_fixed_hdr)) then begin But heaptrc will show unfreeed blocks with zero size. And this helps. Index: inc/heaptrc.pp === --- inc/heaptrc.pp (revision 10368) +++ inc/heaptrc.pp (working copy) @@ -406,6 +406,11 @@ pp : pheap_mem_info; loc_info: pheap_info; begin + if size<=0 then +begin + TraceGetMem:=nil; + exit; +end; loc_info := @heap_info; try_finish_heap_free_todo_list(loc_info); inc(loc_info^.getmem_size,size); Are these patches acceptable? Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] MSecsToTimeStamp patch
Aritmetic Owerflow, for example MSecsToTimeStamp(6325058880) //1.5.2005 Repaired bad typecasting. Index: objpas/sysutils/dati.inc === --- objpas/sysutils/dati.inc(revision 10368) +++ objpas/sysutils/dati.inc(working copy) @@ -75,7 +75,7 @@ function MSecsToTimeStamp(MSecs: comp): TTimeStamp; begin result.Date := Trunc(msecs / msecsperday); - msecs:= comp(msecs-result.date*msecsperday); + msecs:= msecs-comp(result.date)*msecsperday; result.Time := Round(MSecs); end ; -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] TVarRec.VAnsiString memory leak?
Hi. This construction of setup vr.VAnsiString cause memoryleak: program str; uses heaptrc; var s: ansistring; vr: TVarRec; begin SetString(s, 'xxx', 3); //ok vr.VType := vtAnsiString; SetString(AnsiString(vr.VAnsiString), 'yyy', 3); //Memory leak. end. Heap dump by heaptrc unit 2 memory blocks allocated : 24/32 1 memory blocks freed : 12/16 1 unfreed memory blocks : 12 True heap size : 32768 True free heap : 32672 Should be : 32688 Call trace for block $B7FEE0C0 size 12 $08050E82 $fpc_ansistr_setlength, line 569 of /home/common/fpc/rtl/inc/astrings.inc $080480DF main, line 10 of str.pas $080678B1 _FPC_proc_start, line 67 of ./i386/si_prc.inc Is right that in destroying TVarRec is not decremented ansistring reference? If so, how to correctly set TVarRec.VAnsiString without memoryleak? I need to fill "a: array of TVarRec" with ansistrings. Thanks. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] TVarRec.VAnsiString memory leak? - solved
On Fri, Mar 28, 2008 at 10:17:01AM +0100, Michael Van Canneyt wrote: > This is a correct way: > > program str; > > uses > heaptrc; > > var > s,t: ansistring; > vr: TVarRec; > > begin > SetString(s, 'xxx', 3); //ok > vr.VType := vtAnsiString; > t:='yyy'; > vr.VAnsiString:=Pointer(T); > end. > Final solution is not to use VAnsiString because reference counting little confusing. My problem was to fill "array of const" with strings. And these strings must be somewere stored. Then i use vr.VPChar = StrNew(PChar(s)); ... StrDispose(vr.VPChar); Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Valgrind Val
This program runed in valgrind brings on error: program val; var n, e: Integer; begin System.Val('', n, e); end. ==18377== Conditional jump or move depends on uninitialised value(s) ==18377==at 0x804EDC5: SYSTEM_INITVAL$SHORTSTRING$BOOLEAN$BYTE$$LONGINT (sstrings.inc:768) ==18377==by 0x804EEDA: fpc_val_sint_shortstr (sstrings.inc:819) ==18377==by 0x805171A: fpc_val_sint_ansistr (astrings.inc:881) ==18377==by 0x804827C: main (val.pas:5) Problem is that InitVal does not take into account empty string. And this little patch solves this for me. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 Index: inc/sstrings.inc === --- inc/sstrings.inc (revision 10368) +++ inc/sstrings.inc (working copy) @@ -759,12 +759,18 @@ var Code : SizeInt; begin + code:=1; + negativ:=false; + base:=10; + if length(s)=0 then +begin + InitVal:=code; + Exit; +end; {Skip Spaces and Tab} - code:=1; while (code<=length(s)) and (s[code] in [' ',#9]) do inc(code); {Sign} - negativ:=false; case s[code] of '-' : begin negativ:=true; @@ -773,7 +779,6 @@ '+' : inc(code); end; {Base} - base:=10; if code<=length(s) then begin case s[code] of ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] TDataset.ClearCalcFields
Hi. Valgrind uncover me error in TDataset.ClearCalcFields. I think that this code is entirely bad. Procedure TDataset.ClearCalcFields(Buffer: PChar); begin if FCalcFieldsSize > 0 then FillByte((Buffer+RecordSize)^,FCalcFieldsSize,0); end; With ZEOSDB this code clears data behind allocated buffer. Buffer size is here RecordSize. For allocating buffers is responsible overrided method AllocRecordBuffer. And I think that for clearing calc fields must be responsible overrided method ClearCalcFields too if driver requires it. Not this code in base class. I suggest this patch: Index: packages/fcl-db/src/base/dataset.inc === --- packages/fcl-db/src/base/dataset.inc(revision 10565) +++ packages/fcl-db/src/base/dataset.inc(working copy) @@ -180,8 +180,6 @@ Procedure TDataset.ClearCalcFields(Buffer: PChar); begin - if FCalcFieldsSize > 0 then -FillByte((Buffer+RecordSize)^,FCalcFieldsSize,0); end; Procedure TDataset.CloseBlob(Field: TField); For me this solves problems with SIGSEGV. I look into Borland TDataset.ClearCalcFields implementation and here is this method empty too. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Invalid compiler warning
Hi. Compiling this code throws in my opinion invalid warning. program res; {$mode objfpc} uses Classes, SysUtils; function r: string; begin raise Exception.Create('Invalid call'); end; begin r; end. Compiling res.pas res.pas(6,12) Warning: Function result does not seem to be set Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] How to convert Double to Comp without warning
Compiling this code: var t: TDateTime; m: Comp; begin t := 1000.999; m := t; end. Throws: Warning: Automatic type conversion from floating type to COMP which is an integer type How I can make this conversion without warning? Overtyping m := Comp(t) is confusing and not delphi compatible. Thanks. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] How to convert Double to Comp without warning
On Fri, Apr 04, 2008 at 11:53:03AM +0200, Marco van de Voort wrote: > > How I can make this conversion without warning? > > Overtyping m := Comp(t) is confusing and not delphi compatible. > > FPC is not warning compatible with FPC. Proposed solution looks fine to me. program co; uses Classes, SysUtils; var t: TDateTime; m: Comp; begin t := 1000.999; m := Comp(t); writeln(m); end. #fpc -S2 co.pas #./co 1.001000E+0003 #fpc -Sd co.pas #./co 4.65201609613812E+0018 #dcc co.pas 4.65201609613812E+0018 Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] sysstr patch
Hi. Sysstr comparing routines does not work correct if two strings were empty. Example: program comp; uses SysUtils; var a, b: array[0..1] of char; begin a[0] := #0; a[1] := #1; b[0] := #0; b[1] := #0; writeln(AnsiStrComp(a, b)=0); // '',''=0 end This program returns false and theoreticaly repeat..until may SIGSEGV because overflows empty PChar boundary after first cycle. Patch is in the attachment. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 Index: objpas/sysutils/sysstr.inc === --- objpas/sysutils/sysstr.inc (revision 10368) +++ objpas/sysutils/sysstr.inc (working copy) @@ -307,11 +307,12 @@ Result:=1; exit; end; - Repeat + While (Result=0) and (S1^<>#0) and (S2^<>#0) do +begin Result:=Ord(S1^)-Ord(S2^); //!! Must be replaced by ansi characters !! Inc(S1); Inc(S2); - Until (Result<>0) or (S1^=#0) or (S2^=#0); +end; if (Result=0) and (S1^<>S2^) then // loop ended because exactly one has #0 if S1^=#0 then // shorter string is smaller result:=-1 @@ -335,11 +336,12 @@ Result:=1; exit; end; - Repeat + While (Result=0) and (S1^<>#0) and (S2^<>#0) do +begin Result:=Ord(LowerCaseTable[Ord(S1[0])])-Ord(LowerCaseTable[Ord(S2[0])]); //!! Must be replaced by ansi characters !! Inc(S1); Inc(S2); - Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0)) +end; end; @@ -362,12 +364,13 @@ exit; end; I:=0; - Repeat + While (Result=0) and (S1^<>#0) and (S2^<>#0) and (I0) or ((S1[0]=#0) or (S2[0]=#0)) or (I=MaxLen) +end; end; @@ -390,12 +393,13 @@ exit; end; I:=0; - Repeat + While (Result=0) and (S1^<>#0) and (S2^<>#0) and (I0) or ((S1[0]=#0) or (S2[0]=#0)) or (I=MaxLen) +end; end; ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] sysstr patch
On Fri, Apr 04, 2008 at 07:38:26PM +0200, Micha Nelissen wrote: > [EMAIL PROTECTED] wrote: > > @@ -335,11 +336,12 @@ > > Result:=1; > > exit; > > end; > > - Repeat > > + While (Result=0) and (S1^<>#0) and (S2^<>#0) do > > You only have to check one of S1 or S2 being unequal to zero. (Otherwise > they would be different anyway). And what about case S1='' and S2='' in the first check? Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] TDataSet.FieldDefs patch
Hi. We need to copy FieldDefs if programmer assigns to this property. For example RxMemoryDataset expect this behaviour. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 Index: packages/fcl-db/src/base/dataset.inc === --- packages/fcl-db/src/base/dataset.inc (revision 10597) +++ packages/fcl-db/src/base/dataset.inc (working copy) @@ -824,6 +822,12 @@ end; end; +Procedure TDataSet.SetFieldDefs(AFieldDefs: TFieldDefs); + +begin + FFieldDefs.Assign(AFieldDefs); +end; + procedure TDataSet.InitFieldDefsFromfields; var i : integer; begin Index: packages/fcl-db/src/base/db.pas === --- packages/fcl-db/src/base/db.pas (revision 10565) +++ packages/fcl-db/src/base/db.pas (working copy) @@ -1130,6 +1130,7 @@ Function GetActive : boolean; Procedure UnRegisterDataSource(ADatasource : TDatasource); Procedure UpdateFieldDefs; +Procedure SetFieldDefs(AFieldDefs: TFieldDefs); protected procedure RecalcBufListSize; procedure ActivateBuffers; virtual; @@ -1312,7 +1313,7 @@ property DefaultFields: Boolean read FDefaultFields; property EOF: Boolean read FEOF; property FieldCount: Longint read GetFieldCount; -property FieldDefs: TFieldDefs read FFieldDefs write FFieldDefs; +property FieldDefs: TFieldDefs read FFieldDefs write SetFieldDefs; //property Fields[Index: Longint]: TField read GetField write SetField; property Found: Boolean read FFound; property Modified: Boolean read FModified write SetModified; ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Unix internationalization patch
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 466335223Czech Republic (Eastern Europe) fax: +420 466510709 Index: unix/sysutils.pp === --- unix/sysutils.pp(revision 10611) +++ unix/sysutils.pp(working copy) @@ -793,7 +793,201 @@ end ; {$endif} +Const + clib = 'c'; + __LC_CTYPE= 0; + __LC_NUMERIC = 1; + __LC_TIME = 2; + __LC_COLLATE = 3; + __LC_MONETARY = 4; + __LC_MESSAGES = 5; + __LC_ALL = 6; + + + ABDAY_1 = (__LC_TIME shl 16); + DAY_1 = (ABDAY_1)+7; + ABMON_1 = (ABDAY_1)+14; + MON_1 = (ABDAY_1)+26; + AM_STR = (ABDAY_1)+38; + PM_STR = (ABDAY_1)+39; + D_T_FMT = (ABDAY_1)+40; + D_FMT = (ABDAY_1)+41; + T_FMT = (ABDAY_1)+42; + T_FMT_AMPM = (ABDAY_1)+43; + + __DECIMAL_POINT = (__LC_NUMERIC shl 16); + RADIXCHAR = __DECIMAL_POINT; + __THOUSANDS_SEP = (__DECIMAL_POINT)+1; + + __INT_CURR_SYMBOL = (__LC_MONETARY shl 16); + __CURRENCY_SYMBOL = (__INT_CURR_SYMBOL)+1; + __MON_DECIMAL_POINT = (__INT_CURR_SYMBOL)+2; + __MON_THOUSANDS_SEP = (__INT_CURR_SYMBOL)+3; + __MON_GROUPING = (__INT_CURR_SYMBOL)+4; + __POSITIVE_SIGN = (__INT_CURR_SYMBOL)+5; + __NEGATIVE_SIGN = (__INT_CURR_SYMBOL)+6; + __INT_FRAC_DIGITS = (__INT_CURR_SYMBOL)+7; + __FRAC_DIGITS = (__INT_CURR_SYMBOL)+8; + __P_CS_PRECEDES = (__INT_CURR_SYMBOL)+9; + __P_SEP_BY_SPACE = (__INT_CURR_SYMBOL)+10; + __N_CS_PRECEDES = (__INT_CURR_SYMBOL)+11; + __N_SEP_BY_SPACE = (__INT_CURR_SYMBOL)+12; + __P_SIGN_POSN = (__INT_CURR_SYMBOL)+13; + __N_SIGN_POSN = (__INT_CURR_SYMBOL)+14; + _NL_MONETARY_CRNCYSTR = (__INT_CURR_SYMBOL)+15; + +function setlocale(category: cint; locale: pchar): pchar; cdecl; external clib name 'setlocale'; +function nl_langinfo(__item: cint):Pchar;cdecl;external clib name 'nl_langinfo'; + +procedure GetFormatSettings; + + function GetLocaleStr(item: cint): string; + begin +GetLocaleStr := AnsiString(nl_langinfo(item)); + end; + + function GetLocaleChar(item: cint): char; + begin +GetLocaleChar := nl_langinfo(item)^; + end; + + function FindSeparator(const s: string; Def: char): char; + var +i, l: 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 + FindSeparator := s[i]; + end; + + function TransformFormatStr(const s: string): string; + var +i, l: integer; + begin +TransformFormatStr := ''; +i := 1; +l := Length(s); +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); +if i>l then + Exit; +case s[i] of + 'a': TransformFormatStr := TransformFormatStr + 'ddd'; + 'A': TransformFormatStr := TransformFormatStr + ''; + 'b': TransformFormatStr := TransformFormatStr + 'mmm'; + 'B': TransformFormatStr := TransformFormatStr + ''; + 'c': TransformFormatStr := TransformFormatStr + 'c'; + //'C': + 'd': TransformFormatStr := TransformFormatStr + 'dd'; + 'D': TransformFormatStr := TransformFormatStr + 'mm"/"dd"/"yy'; + 'e': TransformFormatStr := TransformFormatStr + 'd'; + 'F': TransformFormatStr := TransformFormatStr + '-mm-dd'; + 'g': TransformFormatStr := TransformFormatStr + 'yy'; + 'G': TransformFormatStr := TransformFormatStr + ''; + 'h': TransformFormatStr := TransformFormatStr + 'mmm'; + 'H': TransformFormatStr := TransformFormatStr + 'hh'; + 'I': TransformFormatStr := TransformFormatStr + 'hhampm'; + //'j': + 'k': TransformFormatStr := TransformFormatStr + 'h'; + 'l': TransformFormatStr := TransformFormatStr + 'hampm'; + 'm': TransformFormatStr := TransformFormatStr + 'mm'; + 'M': TransformFormatStr := TransformFormatStr + 'nn'; + 'n': TransformFormatStr := TransformFormatStr + sLineBreak; + 'p': TransformFormatStr := TransformFormatStr + 'ampm'; + 'P': TransformFormatStr :=
[fpc-devel] TimeReFormat in FormatDateTime
I do no know exact reason use TimeReFormat (replacing 'm'->'n' in time formating). But we cannot use this, because this breaks 'am/pm' and 'ampm' formating request. And we get 'Illegal character in format string'. Here is little patch, which disables this behaviour. Index: objpas/sysutils/dati.inc === --- objpas/sysutils/dati.inc(revision 10597) +++ objpas/sysutils/dati.inc(working copy) @@ -569,13 +569,13 @@ Function TimeReFormat(Const S : string) : string; // Change m into n for time formatting. - Var i : longint; + //Var i : longint; begin Result:=S; - For I:=1 to Length(Result) do + {For I:=1 to Length(Result) do //We cannot do that am/pm does not then work If Result[i]='m' then - result[i]:='n'; + result[i]:='n';} end; var Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Unix internationalization patch
On Tue, Apr 08, 2008 at 04:29:51PM +0200, Michael Van Canneyt wrote: > > > On Tue, 8 Apr 2008, [EMAIL PROTECTED] 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 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] TimeReFormat in FormatDateTime
On Tue, Apr 08, 2008 at 04:32:30PM +0200, Michael Van Canneyt wrote: > > > On Tue, 8 Apr 2008, [EMAIL PROTECTED] wrote: > > > I do no know exact reason use TimeReFormat (replacing 'm'->'n' in time > > formating). But we cannot use this, because this breaks 'am/pm' and 'ampm' > > formating request. > > And we get 'Illegal character in format string'. > > > > Here is little patch, which disables this behaviour. > > It should not be disabled, but fixed properly. > This code is there for a reason: > > Normal time formatting is hh:nn (n = minutes). But Delphi explicitly > allows also hh:mm for time, even though mm is the placeholder for month. But this feature works without TimeReFormat hack. Here is piece of code from dati.inc: 'M': begin if lastformattoken='H' then begin if Count = 1 then StoreInt(Minute, 0) else StoreInt(Minute, 2); end else begin case Count of 1: StoreInt(Month, 0); 2: StoreInt(Month, 2); 3: StoreString(ShortMonthNames[Month]); 4: StoreString(LongMonthNames[Month]); end; end; end; Next TimeReFormat cannot work correctly, because FormatString is case insensitive and comparison "If Result[i]='m'" leaves this out of account. Petr > > Index: objpas/sysutils/dati.inc > > === > > --- objpas/sysutils/dati.inc(revision 10597) > > +++ objpas/sysutils/dati.inc(working copy) > > @@ -569,13 +569,13 @@ > > > > Function TimeReFormat(Const S : string) : string; > > // Change m into n for time formatting. > > - Var i : longint; > > + //Var i : longint; > > > > begin > > Result:=S; > > - For I:=1 to Length(Result) do > > + {For I:=1 to Length(Result) do //We cannot do that am/pm does not > > then work > > If Result[i]='m' then > > - result[i]:='n'; > > + result[i]:='n';} > > end; > > > > var -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] TimeReFormat in FormatDateTime
On Tue, Apr 08, 2008 at 05:23:04PM +0200, Michael Van Canneyt wrote: > > > On Tue, 8 Apr 2008, [EMAIL PROTECTED] wrote: > > > On Tue, Apr 08, 2008 at 04:32:30PM +0200, Michael Van Canneyt wrote: > > > > > > > > > On Tue, 8 Apr 2008, [EMAIL PROTECTED] wrote: > > > > > > > I do no know exact reason use TimeReFormat (replacing 'm'->'n' in time > > > > formating). But we cannot use this, because this breaks 'am/pm' and > > > > 'ampm' formating request. > > > > And we get 'Illegal character in format string'. > > > > > > > > Here is little patch, which disables this behaviour. > > > > > > It should not be disabled, but fixed properly. > > > This code is there for a reason: > > > > > > Normal time formatting is hh:nn (n = minutes). But Delphi explicitly > > > allows also hh:mm for time, even though mm is the placeholder for month. > > But this feature works without TimeReFormat hack. Here is piece of code > > from dati.inc: > > > > > 'M': begin > >if lastformattoken='H' then > > begin > >if Count = 1 then > > StoreInt(Minute, 0) > >else > > StoreInt(Minute, 2); > > > > end > >else > > begin > >case Count of > > 1: StoreInt(Month, 0); > > 2: StoreInt(Month, 2); > > 3: StoreString(ShortMonthNames[Month]); > > 4: StoreString(LongMonthNames[Month]); > >end; > > end; > > end; > > > > Next TimeReFormat cannot work correctly, because FormatString is case > > insensitive and comparison "If Result[i]='m'" leaves this out of account. > > Did you test it ? If you can confirm that hh:mm:ss works correctly, then > I'll apply the patch. Sure, I tested it. hh:mm:ss and hh:nn:ss works identically. But isn't cleaner solution remove TimeReFormat completly? I can redone the patch. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] TimeReFormat in FormatDateTime
On Tue, Apr 08, 2008 at 05:54:40PM +0200, Michael Van Canneyt wrote: > > > On Tue, 8 Apr 2008, [EMAIL PROTECTED] wrote: > > > On Tue, Apr 08, 2008 at 05:23:04PM +0200, Michael Van Canneyt wrote: > > > > > > > > > On Tue, 8 Apr 2008, [EMAIL PROTECTED] wrote: > > > > > > > On Tue, Apr 08, 2008 at 04:32:30PM +0200, Michael Van Canneyt wrote: > > > > > > > > > > > > > > > On Tue, 8 Apr 2008, [EMAIL PROTECTED] wrote: > > > > > > > > > > > I do no know exact reason use TimeReFormat (replacing 'm'->'n' in > > > > > > time > > > > > > formating). But we cannot use this, because this breaks 'am/pm' and > > > > > > 'ampm' formating request. > > > > > > And we get 'Illegal character in format string'. > > > > > > > > > > > > Here is little patch, which disables this behaviour. > > > > > > > > > > It should not be disabled, but fixed properly. > > > > > This code is there for a reason: > > > > > > > > > > Normal time formatting is hh:nn (n = minutes). But Delphi explicitly > > > > > allows also hh:mm for time, even though mm is the placeholder for > > > > > month. > > > > But this feature works without TimeReFormat hack. Here is piece of code > > > > from dati.inc: > > > > > > > > > > > 'M': begin > > > >if lastformattoken='H' then > > > > begin > > > >if Count = 1 then > > > > StoreInt(Minute, 0) > > > >else > > > > StoreInt(Minute, 2); > > > > > > > > end > > > >else > > > > begin > > > >case Count of > > > > 1: StoreInt(Month, 0); > > > > 2: StoreInt(Month, 2); > > > > 3: StoreString(ShortMonthNames[Month]); > > > > 4: StoreString(LongMonthNames[Month]); > > > >end; > > > > end; > > > > end; > > > > > > > > Next TimeReFormat cannot work correctly, because FormatString is case > > > > insensitive and comparison "If Result[i]='m'" leaves this out of > > > > account. > > > > > > Did you test it ? If you can confirm that hh:mm:ss works correctly, then > > > I'll apply the patch. > > Sure, I tested it. hh:mm:ss and hh:nn:ss works identically. > > But isn't cleaner solution remove TimeReFormat completly? > > I meant: did you test with TimeReFormat removed ? :) Yes. I tested it with dissabled functionality of TimeReFormat: Function TimeReFormat(Const S : string) : string; // Change m into n for time formatting. //Var i : longint; begin Result:=S; {For I:=1 to Length(Result) do //We cannot do that, am/pm does not then work If Result[i]='m' then result[i]:='n';} end; But I think, that cleaner will be remove function TimeReFormat completly not only dissable functionality (superfluous call). Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] TimeReFormat in FormatDateTime
On Tue, Apr 08, 2008 at 06:12:15PM +0200, [EMAIL PROTECTED] wrote: > On Tue, Apr 08, 2008 at 05:54:40PM +0200, Michael Van Canneyt wrote: > > > > > > On Tue, 8 Apr 2008, [EMAIL PROTECTED] wrote: > > > > > On Tue, Apr 08, 2008 at 05:23:04PM +0200, Michael Van Canneyt wrote: > > > > > > > > > > > > On Tue, 8 Apr 2008, [EMAIL PROTECTED] wrote: > > > > > > > > > On Tue, Apr 08, 2008 at 04:32:30PM +0200, Michael Van Canneyt wrote: > > > > > > > > > > > > > > > > > > On Tue, 8 Apr 2008, [EMAIL PROTECTED] wrote: > > > > > > > > > > > > > I do no know exact reason use TimeReFormat (replacing 'm'->'n' in > > > > > > > time > > > > > > > formating). But we cannot use this, because this breaks 'am/pm' > > > > > > > and 'ampm' formating request. > > > > > > > And we get 'Illegal character in format string'. > > > > > > > > > > > > > > Here is little patch, which disables this behaviour. > > > > > > > > > > > > It should not be disabled, but fixed properly. > > > > > > This code is there for a reason: > > > > > > > > > > > > Normal time formatting is hh:nn (n = minutes). But Delphi explicitly > > > > > > allows also hh:mm for time, even though mm is the placeholder for > > > > > > month. > > > > > But this feature works without TimeReFormat hack. Here is piece of > > > > > code > > > > > from dati.inc: > > > > > > > > > > > > > > 'M': begin > > > > >if lastformattoken='H' then > > > > > begin > > > > >if Count = 1 then > > > > > StoreInt(Minute, 0) > > > > >else > > > > > StoreInt(Minute, 2); > > > > > > > > > > end > > > > >else > > > > > begin > > > > >case Count of > > > > > 1: StoreInt(Month, 0); > > > > > 2: StoreInt(Month, 2); > > > > > 3: StoreString(ShortMonthNames[Month]); > > > > > 4: StoreString(LongMonthNames[Month]); > > > > >end; > > > > > end; > > > > > end; > > > > > > > > > > Next TimeReFormat cannot work correctly, because FormatString is case > > > > > insensitive and comparison "If Result[i]='m'" leaves this out of > > > > > account. > > > > > > > > Did you test it ? If you can confirm that hh:mm:ss works correctly, then > > > > I'll apply the patch. > > > Sure, I tested it. hh:mm:ss and hh:nn:ss works identically. > > > But isn't cleaner solution remove TimeReFormat completly? > > > > I meant: did you test with TimeReFormat removed ? :) > Yes. I tested it with dissabled functionality of TimeReFormat: > >Function TimeReFormat(Const S : string) : string; >// Change m into n for time formatting. >//Var i : longint; > >begin > Result:=S; > {For I:=1 to Length(Result) do //We cannot do that, am/pm does not then > work >If Result[i]='m' then > result[i]:='n';} >end; > > But I think, that cleaner will be remove function TimeReFormat completly > not only dissable functionality (superfluous call). In the attachment is patch with TimeReFormat removed. Patch is tested, hh:mm:ss and hh:nn:ss works identically. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 Index: objpas/sysutils/dati.inc === --- objpas/sysutils/dati.inc(revision 10597) +++ objpas/sysutils/dati.inc(working copy) @@ -567,17 +567,6 @@ StoreStr(pchar(@S[1]), Len); end ; - Function TimeReFormat(Const S : string) : string; - // Change m into n for time formatting. - Var i : longint; - - begin - Result:=S; - For I:=1 to Length(Result) do - If Result[i]='m' then - result[i]:='n'; - end; - var Year, Month, Day, DayOfWeek, Hour, Minute, Second, MilliSecond: word; @@ -716,8 +705,8 @@ else StoreInt(MilliSecond, 3); end ; 'T': begin - if Count = 1 then StoreFormat(timereformat(ShortTimeFormat)) - else StoreFormat(TimeReformat(LongTimeFormat)); + if Count = 1 then StoreFormat(ShortTimeFormat) + else StoreFormat(LongTimeFormat); end ; 'C': begin @@ -725,7 +714,7 @@ if (Hour<>0) or (Minute<>0) or (Second<>0) then begin StoreString(' '); - StoreFormat(TimeReformat(LongTimeFormat)); + StoreFormat(LongTimeFormat); end; end; end; ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Unix internationalization patch
On Tue, Apr 08, 2008 at 05:19:34PM +0200, Jonas Maebe wrote: > > On 08 Apr 2008, at 17:03, [EMAIL PROTECTED] 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 466335223Czech Republic (Eastern Europe) fax: +420 466510709 { This file is part of the Free Pascal run time library. Copyright (c) 2005 by Florian Klaempfl, member of the Free Pascal development team. Init rtl formating variables based on libc locales See the file COPYING.FPC, included in this distribution, for details about the copyright. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **} unit clocale; {$mode objfpc} interface implementation {$linklib c} Uses SysUtils, unixtype, initc; Const __LC_CTYPE= 0; __LC_NUMERIC = 1; __LC_TIME = 2; __LC_COLLATE = 3; __LC_MONETARY = 4; __LC_MESSAGES = 5; __LC_ALL = 6; ABDAY_1 = (__LC_TIME shl 16); DAY_1 = (ABDAY_1)+7; ABMON_1 = (ABDAY_1)+14; MON_1 = (ABDAY_1)+26; AM_STR = (ABDAY_1)+38; PM_STR = (ABDAY_1)+39; D_T_FMT = (ABDAY_1)+40; D_FMT = (ABDAY_1)+41; T_FMT = (ABDAY_1)+42; T_FMT_AMPM = (ABDAY_1)+43; __DECIMAL_POINT = (__LC_NUMERIC shl 16); RADIXCHAR = __DECIMAL_POINT; __THOUSANDS_SEP = (__DECIMAL_POINT)+1; __INT_CURR_SYMBOL = (__LC_MONETARY shl 16); __CURRENCY_SYMBOL = (__INT_CURR_SYMBOL)+1; __MON_DECIMAL_POINT = (__INT_CURR_SYMBOL)+2; __MON_THOUSANDS_SEP = (__INT_CURR_SYMBOL)+3; __MON_GROUPING = (__INT_CURR_SYMBOL)+4; __POSITIVE_SIGN = (__INT_CURR_SYMBOL)+5; __NEGATIVE_SIGN = (__INT_CURR_SYMBOL)+6; __INT_FRAC_DIGITS = (__INT_CURR_SYMBOL)+7; __FRAC_DIGITS = (__INT_CURR_SYMBOL)+8; __P_CS_PRECEDES = (__INT_CURR_SYMBOL)+9; __P_SEP_BY_SPACE = (__INT_CURR_SYMBOL)+10; __N_CS_PRECEDES = (__INT_CURR_SYMBOL)+11; __N_SEP_BY_SPACE = (__INT_CURR_SYMBOL)+12; __P_SIGN_POSN = (__INT_CURR_SYMBOL)+13; __N_SIGN_POSN = (__INT_CURR_SYMBOL)+14; _NL_MONETARY_CRNCYSTR = (__INT_CURR_SYMBOL)+15; function setlocale(category: cint; locale: pchar): pchar; cdecl; external clib name 'setlocale'; function nl_langinfo(__item: cint):Pchar;cdecl;external clib name 'nl_langinfo'; procedure GetFormatSettings; function GetLocaleStr(item: cint): string; begin GetLocaleStr := AnsiString(nl_langinfo(item)); end; function GetLocaleChar(item: cint): char; begin GetLocaleChar := nl_langinfo(item)^; end; function FindSeparator(const s: string; Def: char): char; var i, l: 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 FindSeparator := s[i]; end; function TransformFormatStr(const s: string): string; var i, l: integer; begin TransformFormatStr := ''; i := 1; l := Length(s); 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); if i>l then Exit; case s[i] of 'a': TransformFormatStr := TransformFormatStr + 'ddd'; 'A': TransformFormatStr := TransformFormatStr + ''; 'b': TransformFormatStr := TransformFormatStr + 'mmm'; 'B': TransformFormatStr := TransformFormatStr + ''; 'c': TransformFormatStr := TransformFormatStr + 'c'; //'C': 'd': TransformFormatStr := Tra
[fpc-devel] Valgrind strscan
Hi. In the morning I was hunting valgrind "Invalid read of size 4" in my code and finally I found it. Example: program str; uses SysUtils; var p: PChar; begin GetMem(p, 1); p^ := #0; StrScan(p, 'x'); FreeMem(p); end. ==14379== Invalid read of size 4 ==14379==at 0x80708F0: SYSUTILS_STRSCAN$PCHAR$CHAR$$PCHAR (strings.inc:439) ==14379==by 0x804828A: main (str.pas:9) ==14379== Address 0x416A494 is 4 bytes inside a block of size 5 alloc'd ==14379==at 0x401D38B: malloc (vg_replace_malloc.c:149) ==14379==by 0x8063398: CMEM_CGETMEM$LONGWORD$$POINTER (cmem.pp:50) ==14379==by 0x805AFA6: SYSTEM_GETMEM$POINTER$LONGWORD (heap.inc:235) ==14379==by 0x8048276: main (str.pas:7) Problem is in assembler code for i386. rtl/i386/strings.inc. This routine reads always 4 bytes alligned by 4 regardless string length. function strscan(p : pchar;c : char) : pchar;assembler; ... // load new 4 bytes movl (%edi),%edx <-here valgrind report Invalid read ... Problem was discovered aleady here http://bugs.freepascal.org/view.php?id=6314 My assembler knowledge is unfortunately not so good yet to effectively repair it. Besides routine is very sophisticated. :) But I think that solving this cosmetic error will save many developers hours during valgrind code checking. And preparing testcases fo fpc developers. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Valgrind strscan
On Thu, Apr 10, 2008 at 03:09:34PM +0200, Jonas Maebe wrote: > > On 10 Apr 2008, at 14:50, [EMAIL PROTECTED] wrote: > > >==14379== Invalid read of size 4 > >==14379==at 0x80708F0: SYSUTILS_STRSCAN$PCHAR$CHAR$$PCHAR > >(strings.inc:439) > >==14379==by 0x804828A: main (str.pas:9) > >==14379== Address 0x416A494 is 4 bytes inside a block of size 5 > >alloc'd > >==14379==at 0x401D38B: malloc (vg_replace_malloc.c:149) > >==14379==by 0x8063398: CMEM_CGETMEM$LONGWORD$$POINTER (cmem.pp:50) > >==14379==by 0x805AFA6: SYSTEM_GETMEM$POINTER$LONGWORD (heap.inc: > >235) > >==14379==by 0x8048276: main (str.pas:7) > > > >Problem is in assembler code for i386. rtl/i386/strings.inc. > >This routine reads always 4 bytes alligned by 4 regardless string > >length. > > > >function strscan(p : pchar;c : char) : pchar;assembler; > >... > >// load new 4 bytes > > movl (%edi),%edx <-here valgrind report Invalid read > >... > > > >Problem was discovered aleady here > >http://bugs.freepascal.org/view.php?id=6314 > > > >My assembler knowledge is unfortunately not so good yet to > >effectively repair it. > >Besides routine is very sophisticated. :) > >But I think that solving this cosmetic error will save many developers > >hours during valgrind code checking. And preparing testcases fo fpc > >developers. > > It is a false positive by Valgrind. That code intentionally does not > care about reading uninitialised memory from time to time, and treats > that situation correctly. There is similar code in glibc, but Valgrind > comes with standard suppression files for glibc which suppress these > false positives. I'm not aware of any suppression files for FPC. I think that this is not false positive. We allocate 1 byte and read 4, report is right. But obviously effective solution do not exists. What about to establish valgind suppressions file in fpc tree? Here is first record. { Assembler routine always reads 4 bytes alligned by 4 regardles str length Memcheck:Addr4 fun:SYSUTILS_STRSCAN$PCHAR$CHAR$$PCHAR } Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Valgrind strscan
On Thu, Apr 10, 2008 at 03:52:42PM +0200, Jonas Maebe wrote: > > On 10 Apr 2008, at 15:32, [EMAIL PROTECTED] wrote: > >On Thu, Apr 10, 2008 at 03:09:34PM +0200, Jonas Maebe wrote: > >> > > > >>It is a false positive by Valgrind. That code intentionally does not > >>care about reading uninitialised memory from time to time, and treats > >>that situation correctly. There is similar code in glibc, but > >>Valgrind > >>comes with standard suppression files for glibc which suppress these > >>false positives. I'm not aware of any suppression files for FPC. > > > >I think that this is not false positive. We allocate 1 byte and read > >4, > >report is right. But obviously effective solution do not exists. > > It is a false positive because users read Valgrind reports as lists of > error locations in their program (which is indeed how the MemCheck > backend of Valgrind is supposed to be used). > > >What about to establish valgind suppressions file in fpc tree? > >Here is first record. > >{ > > Assembler routine always reads 4 bytes alligned by 4 regardles str > >length > > Memcheck:Addr4 > > fun:SYSUTILS_STRSCAN$PCHAR$CHAR$$PCHAR > >} > > If you submit such a file, we can add it to svn. No problem. Here it is. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 { Assembler routine always reads 4 bytes alligned by 4 regardles str length Memcheck:Addr4 fun:SYSUTILS_STRSCAN$PCHAR$CHAR$$PCHAR } ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Unix internationalization patch
On Thu, Apr 24, 2008 at 10:38:19AM +0200, Jonas Maebe wrote: > > On 08 Apr 2008, at 15:54, [EMAIL PROTECTED] 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 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] VarArray 64bit clean patch
Hi. Today I worked on VarArrays. Here is 64-bit friendly VariantArray patch. Testing program is attached too. Implementation was tested on i386 and AMD64 linux with valgrind. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 Index: rtl/inc/variants.pp === --- rtl/inc/variants.pp (revision 10780) +++ rtl/inc/variants.pp (working copy) @@ -2618,10 +2618,7 @@ begin GetVariantManager(variantmanager); variantmanager.varcast(tempvar,value,arrayelementtype); - if arrayelementtype in [varOleStr,varDispatch,varUnknown] then -VarResultCheck(SafeArrayPutElement(p,PVarArrayCoorArray(indices),TVarData(tempvar).vPointer)) - else -VarResultCheck(SafeArrayPutElement(p,PVarArrayCoorArray(indices),@TVarData(tempvar).vPointer)); + VarResultCheck(SafeArrayPutElement(p,PVarArrayCoorArray(indices),@TVarData(tempvar).vPointer)); end; end else @@ -3211,7 +3208,7 @@ varSingle,varDouble,varDate, {$endif} varCurrency,varOleStr,varDispatch,varError,varBoolean, - varVariant,varUnknown,varShortInt,varByte,varWord,varLongWord]; + varVariant,varUnknown,varShortInt,varByte,varWord,varLongWord,varInt64,varQWord]; end; @@ -3223,7 +3220,7 @@ Result:=true else begin -Result:=(aVarType and not(varByRef)) in [varEmpty,varNull,varSmallInt,varInteger, +Result:=(aVarType and not(varByRef) and not(varArray)) in [varEmpty,varNull,varSmallInt,varInteger, {$ifndef FPUNONE} varSingle,varDouble,varDate, {$endif} Index: rtl/objpas/varutils.inc === --- rtl/objpas/varutils.inc (revision 10661) +++ rtl/objpas/varutils.inc (working copy) @@ -379,22 +379,17 @@ end; end; -Type - TVartypes = varEmpty..varByte; - Const - Supportedpsas : set of TVarTypes = -[varSmallint,varInteger, + Supportedpsas = [varSmallint,varInteger, {$ifndef FPUNONE} varSingle,varDouble,varCurrency,varDate, {$endif} - varOleStr,varDispatch,varError,varBoolean,varVariant,varUnknown,varByte]; - psaElementSizes : Array [varEmpty..varByte] of Byte = -(0,0,2,4,4,8,8,8,4,4,4,2,16,4,0,0,0,1); - psaElementFlags : Array [varEmpty..varByte] of Longint = + varOleStr,varDispatch,varError,varBoolean,varVariant,varUnknown,varShortInt,varByte, + varWord,varLongWord,varInt64,varQWord]; + psaElementFlags : Array [varEmpty..varQWord] of Longint = (ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE, ARR_OLESTR,ARR_DISPATCH,ARR_NONE,ARR_NONE,ARR_VARIANT,ARR_UNKNOWN, - ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE); + ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE); Function SafeArrayCreate(VarType, Dim: DWord; const Bounds: TVarArrayBoundArray): PVarArray;stdcall; var @@ -409,7 +404,31 @@ exit; Result^.DimCount:=Dim; Result^.Flags:=psaElementFlags[VarType]; -Result^.ElementSize:=psaElementSizes[VarType]; +case VarType of + varEmpty: Result^.ElementSize:=0; + varNull: Result^.ElementSize:=0; + varSmallInt: Result^.ElementSize:=SizeOf(SmallInt); + varInteger: Result^.ElementSize:=SizeOf(Integer); +{$ifndef FPUNONE} + varSingle: Result^.ElementSize:=SizeOf(Single); + varDouble: Result^.ElementSize:=SizeOf(double); + varCurrency: Result^.ElementSize:=SizeOf(Currency); + varDate: Result^.ElementSize:=SizeOf(TDatetime); +{$endif} + varOleStr: Result^.ElementSize:=SizeOf(PWideString); + varDispatch: Result^.ElementSize:=SizeOf(IInterface); + varError: Result^.ElementSize:=SizeOf(TError); + varBoolean: Result^.ElementSize:=SizeOf(Boolean); + varVariant: Result^.ElementSize:=SizeOf(TVarData); + varUnknown: Result^.ElementSize:=SizeOf(IUnknown); + varDecimal: Result^.ElementSize:=0; //??? + varShortInt: Result^.ElementSize:=SizeOf(ShortInt); + varByte: Result^.ElementSize:=SizeOf(Byte); + varWord: Result^.ElementSize:=SizeOf(Word); + varLongWord: Result^.ElementSize:=SizeOf(LongWord); + varInt64: Result^.ElementSize:=SizeOf(Int64); + varQWord: Result^.ElementSize:=SizeOf(QWord); +end; Result^.LockCount := 0; for i:=0 to Dim-1 do begin @@ -722,7 +741,7 @@ vatInterface: NoInterfaces; // Just assign... vatWideString: -NoWideStrings; // Just assign... +CopyAsWideString(PWideChar(Data^), PWideChar(P^)); end; except On E : Exception do @@ -747,7 +766,7 @@ vatInterface: NoInterfaces; vatWideString: -NoWideStrings; +CopyAsWideString(PWideChar(P^), PWideChar(Data^)); end; except On E : Exception do program vari; {$mode objfpc} {$assertions on} uses SysUtils
Re: [fpc-devel] VarArray 64bit clean patch
nt := 0; for i:=0 to Dim-1 do begin Enables varOleStr Get/Put into VarArray @@ -722,7 +741,7 @@ vatInterface: NoInterfaces; // Just assign... vatWideString: -NoWideStrings; // Just assign... +CopyAsWideString(PWideChar(Data^), PWideChar(P^)); end; except On E : Exception do @@ -747,7 +766,7 @@ vatInterface: NoInterfaces; vatWideString: -NoWideStrings; +CopyAsWideString(PWideChar(P^), PWideChar(Data^)); end; except On E : Exception do Attached test program tries to create VariantArray of every supported type. Copy array and then compare inserted values. I test this patch on 32-bit and 64-bit linux. Program vas run in valgrind without errors. All my patches are also tested with our ported (delphi->fpc) ERP software self testing routines. 32-bit port already completes all tests without errors. Now I'am working on 64-bit port. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Unix internationalization patch
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 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] VarArray 64bit clean patch
On Mon, Apr 28, 2008 at 10:19:37AM +0200, [EMAIL PROTECTED] wrote: > On Sat, Apr 26, 2008 at 07:28:46PM +0200, Florian Klaempfl wrote: > > [EMAIL PROTECTED] schrieb: > > >Hi. > > > > > >Today I worked on VarArrays. Here is 64-bit friendly VariantArray > > patch. > > >Testing program is attached too. Implementation was tested on i386 > > and > > >AMD64 linux with valgrind. > > > > The patch is contains more changes. Are they tested too? What's > > their > > purpose? My previous version of patch breaks windows VarArray implementation using oleaut32.dll. In attachment is new commented patch. Patch leaves varInt64 and varQWord disabled in variants.pp (VarTypeIsValidArrayType), but internally supports them. Patch was tested on Linux i386, AMD64 and Win32 by attached program vari.pas. Behaviour is the same on all platforms. Test was compilled with Delphi and Kylix with the same results. Comments are welcome. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 Index: rtl/inc/variants.pp === --- rtl/inc/variants.pp (revision 10840) +++ rtl/inc/variants.pp (working copy) # Enables inserting variants arrays into variant -- my old patch from 21.03. @@ -3223,7 +3223,7 @@ Result:=true else begin -Result:=(aVarType and not(varByRef)) in [varEmpty,varNull,varSmallInt,varInteger, +Result:=(aVarType and not(varByRef) and not(varArray)) in [varEmpty,varNull,varSmallInt,varInteger, {$ifndef FPUNONE} varSingle,varDouble,varDate, {$endif} Index: rtl/objpas/varutils.inc === --- rtl/objpas/varutils.inc (revision 10840) +++ rtl/objpas/varutils.inc (working copy) # Enables internally varShortInt,varWord,varLongWord,varInt64,varQWord elements in VarArray @@ -379,22 +379,17 @@ end; end; -Type - TVartypes = varEmpty..varByte; - Const - Supportedpsas : set of TVarTypes = -[varSmallint,varInteger, + Supportedpsas = [varSmallint,varInteger, {$ifndef FPUNONE} varSingle,varDouble,varCurrency,varDate, {$endif} - varOleStr,varDispatch,varError,varBoolean,varVariant,varUnknown,varByte]; - psaElementSizes : Array [varEmpty..varByte] of Byte = -(0,0,2,4,4,8,8,8,4,4,4,2,16,4,0,0,0,1); - psaElementFlags : Array [varEmpty..varByte] of Longint = + varOleStr,varDispatch,varError,varBoolean,varVariant,varUnknown,varShortInt,varByte, + varWord,varLongWord,varInt64,varQWord]; + psaElementFlags : Array [varEmpty..varQWord] of Longint = (ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE, ARR_OLESTR,ARR_DISPATCH,ARR_NONE,ARR_NONE,ARR_VARIANT,ARR_UNKNOWN, - ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE); + ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE,ARR_NONE); Function SafeArrayCreate(VarType, Dim: DWord; const Bounds: TVarArrayBoundArray): PVarArray;stdcall; var # Remake calculating ElementSize from static const array psaElementSizes to 64-bit friendly SizeOf function @@ -409,7 +404,31 @@ exit; Result^.DimCount:=Dim; Result^.Flags:=psaElementFlags[VarType]; -Result^.ElementSize:=psaElementSizes[VarType]; +case VarType of + varEmpty: Result^.ElementSize:=0; + varNull: Result^.ElementSize:=0; + varSmallInt: Result^.ElementSize:=SizeOf(SmallInt); + varInteger: Result^.ElementSize:=SizeOf(Integer); +{$ifndef FPUNONE} + varSingle: Result^.ElementSize:=SizeOf(Single); + varDouble: Result^.ElementSize:=SizeOf(double); + varCurrency: Result^.ElementSize:=SizeOf(Currency); + varDate: Result^.ElementSize:=SizeOf(TDatetime); +{$endif} + varOleStr: Result^.ElementSize:=SizeOf(PWideString); + varDispatch: Result^.ElementSize:=SizeOf(IInterface); + varError: Result^.ElementSize:=SizeOf(TError); + varBoolean: Result^.ElementSize:=SizeOf(Boolean); + varVariant: Result^.ElementSize:=SizeOf(TVarData); + varUnknown: Result^.ElementSize:=SizeOf(IUnknown); + varDecimal: Result^.ElementSize:=0; //??? + varShortInt: Result^.ElementSize:=SizeOf(ShortInt); + varByte: Result^.ElementSize:=SizeOf(Byte); + varWord: Result^.ElementSize:=SizeOf(Word); + varLongWord: Result^.ElementSize:=SizeOf(LongWord); + varInt64: Result^.ElementSize:=SizeOf(Int64); + varQWord: Result^.ElementSize:=SizeOf(QWord); +end; Result^.LockCount := 0; for i:=0 to Dim-1 do begin # Enables varOleStr Get/Put into VarArray @@ -722,7 +741,7 @@ vatInterface: NoInterfaces; // Just assign... vatWideString: -NoWideStrings; // Just assign... +CopyAsWideString(PWideChar(Data^), PWideChar(P^)); end; except On E : Ex
[fpc-devel] sysstr patch once more
Hi. sysstr.inc r10846 does not include my patch, which solves problem when both strings are empty and differs after null character. Then I'am sending it again merged against trunk. Here is testcase: program comp; uses SysUtils; var a, b: array[0..1] of char; begin a[0] := #0; a[1] := #1; //Empty string b[0] := #0; b[1] := #0; //Empty string with different char after end writeln(AnsiStrComp(a, b)); //should be zero because a=b writeln(AnsiStrIComp(a, b)); /should be zero because a=b end. And here is patch. Construction with "repeat" overflows strings boundary in the first cycle, "while" solves this problem. The same construction is used in GenericAnsiCompareText. Index: rtl/objpas/sysutils/sysstr.inc === --- rtl/objpas/sysutils/sysstr.inc (revision 10891) +++ rtl/objpas/sysutils/sysstr.inc (working copy) @@ -307,11 +307,11 @@ Result:=1; exit; end; - Repeat + While (Result=0) and (S1^<>#0) and (S2^<>#0) do begin Result:=Ord(S1^)-Ord(S2^); //!! Must be replaced by ansi characters !! Inc(S1); Inc(S2); - Until (Result<>0) or (S1^=#0) or (S2^=#0); + end; if (Result=0) and (S1^<>S2^) then // loop ended because exactly one has #0 if S1^=#0 then // shorter string is smaller result:=-1 @@ -335,11 +335,11 @@ Result:=1; exit; end; - Repeat + While (Result=0) and (S1^<>#0) and (S2^<>#0) do begin Result:=Ord(LowerCaseTable[Ord(S1[0])])-Ord(LowerCaseTable[Ord(S2[0])]); //!! Must be replaced by ansi characters !! Inc(S1); Inc(S2); - Until (Result<>0) or ((S1[0]=#0) or (S2[0]=#0)); + end; if (Result=0) and (s1[0]<>s2[0]) then //length(s1)<>length(s2) if s1[0]=#0 then Result:=-1 //s1 shorter than s2 -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Extended in Win64
Hi. Why on Win64 on AMD64 is Extended type 64bit same as double and on Win32, Linux32 and Linux64 is 80bit. It breaks for example this construction: procedure Swap(var X, Y: Double); overload; procedure Swap(var X, Y: Extended); overload; (I know that extended type is defined as float with the best precision on the given platform.) Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Extended in Win64
On Tue, May 06, 2008 at 03:02:19PM +0200, [EMAIL PROTECTED] wrote: > Hi. > > Why on Win64 on AMD64 is Extended type 64bit same as double and on Win32, > Linux32 and > Linux64 is 80bit. It breaks for example this construction: > > procedure Swap(var X, Y: Double); overload; > procedure Swap(var X, Y: Extended); overload; > > (I know that extended type is defined as float with the best precision on the > given platform.) I now found some explanations: http://www.mail-archive.com/fpc-devel@lists.freepascal.org/msg08690.html And explanation that 80-bit precision on AMD64 is depracated and should be replaced by SIMD. http://developer.amd.com/documentation/articles/Pages/62720069_4.aspx Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Optimization -O2 on Linux AMD64
Hi. Today i was hunting malicious error. System: AMD64 Linux, fpc from svn rev 11355. program o2; uses sysutils; function MSecsToTimeStamp(MSecs: comp): TTimeStamp; begin result.Date := Trunc(msecs / msecsperday); msecs:= msecs-comp(result.date)*msecsperday; writeln(result.Date); //732067 result.Time := Round(MSecs); writeln(result.Date); //0 end ; begin MSecsToTimeStamp(6325058880); end. Compiled with optimization: fpc -S2 -O2 o2.pas Result is: 732067 0 and should be 732067 732067 This occurs only on Linux AMD64. Linux i386, win32 and win64 is ok. Problem is, that rtl (sysutils) is compiled with -O2 implicitly. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Locale solution for Linux (and maybe *nix)
On Mon, Aug 04, 2008 at 09:31:35AM +0200, Graeme Geldenhuys wrote: > Hi, > > In FPC the locale information is all hard-coded for Linux and other > Unix based systems. We don't all live in the USA. ;-) This is very > annoying. I also know we may not use glibc calls in FPC to get the > locale information, because glibc is not always available on systems > other than Linux. > > Today I found the following on my Linux system which could possibly > solve this issues. Could other Linux distros and Unix users (*BSD, > etc) confirm if they also have the following directory? > > Under Ubuntu 7.10 I have the follow directory: /usr/share/i18n/locales/ > > Inside that directory are files like en_GB, en_US, es_ES, de_DE etc > They are plain text files that should be fairly easy to parse and > extract the locale information. Couldn't we use that to populate the > locale information inside FPC, without the need of glibc? > > For example, here are some of the content of the en_ZA (English South > Africa) file: > > -[ en_ZA ] > <snip> > LC_MONETARY > % ISO 4217 Currency and fund codes > % > http://www.bsi-global.com/Technical+Information/Publications/_Publications/tig90.xalter > % "ZAR " > int_curr_symbol "" > > % "R" > currency_symbol "" > > % "." > mon_decimal_point "" > > % "," > mon_thousands_sep "" > mon_grouping3;3 > positive_sign "" > > % "-" > negative_sign "" > int_frac_digits 2 > frac_digits 2 > p_cs_precedes 1 > p_sep_by_space 0 > n_cs_precedes 1 > n_sep_by_space 0 > p_sign_posn 1 > n_sign_posn 1 > END LC_MONETARY > > LC_NUMERIC > % "." > decimal_point "" > > % "," > thousands_sep "" > grouping3;3 > END LC_NUMERIC > > LC_TIME > % abday - The abbreviations for the week days: > % - Sun, Mon, Tue, Wed, Thu, Fri, Sat > abday "";"";/ > "";"";/ > "";"";/ > "" > <...snip...> > % Date representation to be referenced by the "%x" field descriptor - > % "%d/%m/%Y", day/month/year as decimal numbers (01/01/2000). > d_fmt "" > <...snip...> > first_weekday 1 > END LC_TIME > > LC_PAPER > <...snip...> > END LC_PAPER > > LC_TELEPHONE > <...snip...> > END LC_TELEPHONE > [ end ]- > Include rtl/unix/clocale.pp into your project. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] an observation about GetMem
On Sat, Sep 06, 2008 at 11:25:19AM +0100, Jonas Maebe wrote: > > On 05 Sep 2008, at 17:25, Peter Popov wrote: > > >>In FPC it is done by design. If 0 bytes are asked we allocate at > >>least the minimum alignment to > >>get a valid pointer. This is done for compatibility with TP7.0 that > >>returns the value of heapptr > >>which is also a valid pointer. > > > >Thanks for the clarification! > >I guess if you switch to reallocmem entirely, there will be delphi > >compatibility, yes? > > reallocmem indeed frees the memory and sets the pointer to nil if you > specify "0" as the memory size. Look at thread "AllocMem(0)<>nil" at 25.03.08. I had the same problem. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Overloaded Pos bug
In fpc revision 11746 i cannot compile this construction: program posx; var s, s1: WideString; begin Pos(s[1], s1); end. fpc -vh posx.pas Hint: Start of reading config file /etc/fpc.cfg Hint: End of reading config file /etc/fpc.cfg Free Pascal Compiler version 2.3.1 [2008/09/11] for i386 Copyright (c) 1993-2008 by Florian Klaempfl posx.pas(5,3) Error: Can't determine which overloaded function to call ustrings.inc(1524,10) Hint: Found declaration: Pos(UnicodeChar,const UnicodeString):LongInt ustrings.inc(1497,10) Hint: Found declaration: Pos(const UnicodeString,const UnicodeString):LongInt posx.pas(7) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Kylix and about month erlier fpc was ok. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] clocale glibc extension patch
On Mon, Sep 15, 2008 at 08:44:24AM +0200, Michael Van Canneyt wrote: > > > On Mon, 15 Sep 2008, [EMAIL PROTECTED] wrote: > > > On Thu, Sep 11, 2008 at 06:47:42PM +0100, Jonas Maebe wrote: > > > > > > On 11 Sep 2008, at 16:10, [EMAIL PROTECTED] wrote: > > > > > > >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. > > > > > > It's best to use the bug reporting system, then things can't be > > > forgotten: http://bugs.freepascal.org > > Is something wrong with my patch, that cannot be applied? > > Nono, I just didn't have time. > > > > > Or I have to place it into http://bugs.freepascal.org? > > Please do, and assign it to me. I'll try to do it later today, > but if I don't find the time, at least it won't be forgotten. I made record in bug tracker no. 0012148, but I cannot assign it (probably rights). Patch is included. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Howto hide Hint: Parameter "xxx" not used
Hi. Is there any posibility to hide compiler hint: Hint: Parameter "xxx" not used Other hints I want to see, but this is by my opinion useless and only makes dirty compiler output. I cannot effectively suppres it in my code. For examle: procedure TObj.OnEvent(Sender: TObject); Sometimes I need Sender, sometimes not. Now I use this hack: make | grep -v 'Hint: Parameter ".*" not used' but some plain solution is welcome. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Howto hide Hint: Parameter "yyy" not used
On Mon, Sep 29, 2008 at 11:49:29AM +0200, Jonas Maebe wrote: > > On 29 Sep 2008, at 11:41, Paul Ishenin wrote: > >> Jonas Maebe ??: >>> That's just a hack, and you have to regenerate the message file for every >>> new FPC release. >> >> Ofcource, but what can we do simple fpc users ;) > > Submit a patch. The message handling code really isn't rocket science. It's > pretty much all in compiler/verbose.pas In the attachment is a little patch. With cmdline option -vm05024,05025 you can suppress messages with idx 05024 and 05025. But I'am not sure if really realized msgtxt.inc rocket science :). That is why I do not change fpc help message in the patch. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 Index: verbose.pas === --- verbose.pas (revision 11839) +++ verbose.pas (working copy) @@ -68,6 +68,7 @@ var msg : pmessage; paraprintnodetree : byte; + suppres_messages_array : array [0..9] of longint; type tmsgqueueevent = procedure(s:string;v,w:longint) of object; @@ -177,7 +178,45 @@ writeln(status.reportbugfile,'FPC bug report file'); end; +procedure FillSuppressMessagesArray(const s: string; var i: integer); + var +c : char; +j, code, idx : integer; +w: longint; + procedure InsertW; + begin +val(copy(s, j, i-j), w, code); +if (code=0) and (idx<=High(suppres_messages_array)) then +begin + suppres_messages_array[idx] := w; + inc(idx); +end; +j := i + 1; + end; + + begin +inc(i); + +idx := 0; +FillChar(suppres_messages_array, SizeOf(suppres_messages_array), 0); + +j := i; +while i<=length(s) do +begin + case s[i] of +',': InsertW; +'0'..'9':; + else +Break; + end; + inc(i); +end; +InsertW; + +dec(i); + end; + function CheckVerbosity(v:longint):boolean; begin result:=do_checkverbosity(v); @@ -296,6 +335,7 @@ else status.verbosity:=status.verbosity or V_TimeStamps; 'V' : PrepareReport; + 'M' : FillSuppressMessagesArray(s, i); end; inc(i); end; @@ -512,6 +552,7 @@ idx,i,v : longint; dostop : boolean; doqueue : boolean; +showcomment : boolean; begin {Reset} dostop:=false; @@ -603,8 +644,17 @@ onqueue(s,v,w); exit; end; + { Check messages suppresion array } +showcomment := true; +for i := 0 to High(suppres_messages_array) do + if suppres_messages_array[i] = 0 then +Break + else if suppres_messages_array[i] = w then begin +showcomment := false; +Break; + end; { show comment } -if do_comment(v,s) or dostop then +if (showcomment and do_comment(v,s)) or dostop then raise ECompilerAbort.Create; if (status.errorcount>=status.maxerrorcount) and not status.skip_error then begin ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Howto hide Hint: Parameter "yyy" not used
On Wed, Oct 01, 2008 at 08:25:54PM +0200, Jonas Maebe wrote: > It's a good start, but this patch is not ready to be committed: > a) it is limited to 10 suppressions > b) people have to look up the error number in the message file first > c) if you change the limitation in a), the code will become exponentially > slower do to having to go over the entire suppression array every time a > message has to be shown > > A better approach may be to add a method to TMessage (in the cmsg.pas unit) > to clear the verbosity level (replace all verbosity indicators with '_'). > And to add an option to the compiler to also show the message number when > printing output (so people can use this to get the numbers of the messages > they want to suppress). > >> But I'am not sure if really realized msgtxt.inc rocket science :). That is >> why I do not >> change fpc help message in the patch. > > It is automatically generated from compiler/msg/errore.msg (a plain text > file) when you make the compiler. So just a patch to > compiler/msg/errore.msg is fine. Hi Here is another attempt which respects your comments. Cmdline option: -vm showns msg numbers in listing -vm11004m1018 disables showing msg numbers 11004 and 1018 Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 Index: verbose.pas === --- verbose.pas (revision 11839) +++ verbose.pas (working copy) @@ -74,6 +74,7 @@ const msgfilename : string = ''; + ShowMsgNo : boolean = false; procedure SetRedirectFile(const fn:string); function SetVerbosity(const s:string):boolean; @@ -177,7 +178,34 @@ writeln(status.reportbugfile,'FPC bug report file'); end; +procedure ClearMessagesVerbosity(const s: string; var i: integer); + var +j, code : integer; +w: longint; + begin +inc(i); + +if (s[i]<'0') or (s[i]>'9') then +begin + ShowMsgNo := true; + Exit; +end; + +j := i; +while i<=length(s) do +begin + if (s[i]<'0') or (s[i]>'9') then +Break; + inc(i); +end; +val(copy(s, j, i-j), w, code); +if code=0 then + msg^.ClearVerbosity(w); + +dec(i); + end; + function CheckVerbosity(v:longint):boolean; begin result:=do_checkverbosity(v); @@ -296,6 +324,7 @@ else status.verbosity:=status.verbosity or V_TimeStamps; 'V' : PrepareReport; + 'M' : ClearMessagesVerbosity(s, i); end; inc(i); end; @@ -512,6 +541,7 @@ idx,i,v : longint; dostop : boolean; doqueue : boolean; +s1: ansistring; begin {Reset} dostop:=false; @@ -520,7 +550,7 @@ {Parse options} idx:=pos('_',s); if idx=0 then - v:=V_Normal + v:=V_None else if (idx >= 1) And (idx <= 5) then begin @@ -598,6 +628,11 @@ UpdateStatus; { Fix replacements } DefaultReplacements(s); +if ShowMsgNo then +begin + Str(w, s1); + s := s1 + ' ' + s; +end; if doqueue then begin onqueue(s,v,w); Index: cmsgs.pas === --- cmsgs.pas (revision 11839) +++ cmsgs.pas (working copy) @@ -52,6 +52,7 @@ procedure ClearIdx; procedure CreateIdx; function GetPChar(nr:longint):pchar; +function ClearVerbosity(nr:longint):pchar; function Get(nr:longint;const args:array of string):ansistring; end; @@ -374,6 +375,14 @@ GetPChar:=msgidx[nr div 1000]^[nr mod 1000]; end; +function TMessage.ClearVerbosity(nr:longint):pchar; +var + hp: pchar; +begin + hp := GetPChar(nr); + if hp<>nil then +hp^ := '_'; +end; function TMessage.Get(nr:longint;const args:array of string):ansistring; var Index: comphook.pas === --- comphook.pas (revision 11839) +++ comphook.pas (working copy) @@ -375,7 +375,7 @@ function def_CheckVerbosity(v:longint):boolean; begin result:=status.use_bugreport or - ((status.verbosity and (v and V_LevelMask))=(v and V_LevelMask)); + ((status.verbosity and (v and V_LevelMask))<>0); end; procedure def_initsymbolinfo; Index: msg/errore.msg === --- msg/errore.msg (revision 11839) +++ msg/errore.msg (wo
Re: [fpc-devel] Parallel Computing
On Tue, Nov 04, 2008 at 09:39:23AM +0100, Michael Schnell wrote: > >> You still didn't show any example which shows the real power of parallel >> which cannot be solved by a T(Pooled)Thread.Create and >> T(Pooled)Thread.WaitFor statements. >> > As I said several times, I don't suggest that any other implementation (be > it OpenMP or whatever) would provide better results than you can achieve > with using what we already have (TThread and friends). > > But using TThread - especially for this kind of "technical improvement" > stuff - is beyond the scope of the average application programmer and now > Oxygen/Prism with the "parallel" (and other) keywords and GCC with the > "#pragma ocm_..." are here to help the common application programmer with > that. This might - or might not - be considered a challenge. Michael. How many MT programs you really made? Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Compiler message verbosity remapping
Hi. I little extend compiler parametr -m. Now we can remap message verbosity. Parametr -m5024_,5025w,5026e means: do not show message 5024, 5025 is warning and 5026 is error. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 Index: verbose.pas === --- verbose.pas (revision 11896) +++ verbose.pas (working copy) @@ -177,11 +177,13 @@ end; -function ClearMessageVerbosity(s: string; var i: integer): boolean; +function SetMessageVerbosity(s: string; var i: integer): boolean; var tok : string; code : longint; msgnr: longint; +len : longint; +ch : char; begin { delete everything up to and including 'm' } delete(s,1,i); @@ -192,10 +194,13 @@ tok:=GetToken(s,','); if (tok='') then break; + len := length(tok); + ch := tok[len]; + delete(tok, len, 1); val(tok, msgnr, code); if (code<>0) then exit; - if not msg^.clearverbosity(msgnr) then + if not msg^.setverbosity(msgnr, ch) then exit; until false; result:=true; @@ -247,7 +252,7 @@ status.print_source_path:=true; end; 'M' : if inverse or - not ClearMessageVerbosity(s, i) then + not SetMessageVerbosity(s, i) then begin result:=false; exit Index: cmsgs.pas === --- cmsgs.pas (revision 11896) +++ cmsgs.pas (working copy) @@ -52,7 +52,7 @@ procedure ClearIdx; procedure CreateIdx; function GetPChar(nr:longint):pchar; -function ClearVerbosity(nr:longint):boolean; +function SetVerbosity(nr:longint; ch:char):boolean; function Get(nr:longint;const args:array of string):ansistring; end; @@ -375,7 +375,7 @@ GetPChar:=msgidx[nr div 1000]^[nr mod 1000]; end; -function TMessage.ClearVerbosity(nr:longint):boolean; +function TMessage.SetVerbosity(nr:longint; ch:char):boolean; var hp: pchar; i, txtbegin: longint; @@ -399,7 +399,7 @@ end; end; for i:=0 to txtbegin-1 do -hp[i]:='_'; +hp[i]:=ch; result:=true; end; Index: msg/errore.msg === --- msg/errore.msg (revision 11896) +++ msg/errore.msg (working copy) @@ -2755,7 +2755,8 @@ **2*_b : Write file names messages with full path **2*_v : Write fpcdebug.txt with p : Write tree.log with parse tree **2*_lots of debugging info q : Show message numbers -**2*_m, : Don't show messages numbered and +**2*_m_,w : Messages verbosity remaping. +**2*_Don't show message numbered , msg treat as warning 3*1W_Target-specific options (targets) A*1W_Target-specific options (targets) P*1W_Target-specific options (targets) ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Parallel Computing
On Tue, Nov 04, 2008 at 10:08:09AM +0100, Michael Schnell wrote: > >> Michael. How many MT programs you really made? >> > I don't know what you exactly mean here. > > If MT just stands for Multi-Threading. Lots of them as well in Pascal > (usually Delphi) as in GNU C. Multi-Processing or Calculation speed never > was an issue but providing low latency to some of the tasks (GUI serial and > TCP/IP communication tasks, you name it). > > As I already said, I never used OpenMP or similar tools but just TThread > (in Pascal) or my own stuff (in C). My question was only for thought-provoking. Every programer which works with threads, knows that is necessary give attention many things -- shared memory, locking, deadlocks, race conditions, only thread safe calls... I think that some keyword _parallel_ cannot solve this. In the hand of unexperienced programer brings more problems than profit. _parallel_ can be maybe used for lightweight threads. But here we must keep in mind that thread creation is quite expensive. Depending on memory architecture, number of CPUs and selected number of threads we can get different speedup or slowdown too. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Re: Unicode support (again)
On Tue, Nov 11, 2008 at 10:11:10AM +0100, Michael Schnell wrote: > >> See (including comments) http://www.jacobthurman.com/?p=30 > > So it seems that the Type "String" in D2009 in fact is "WideString" and > same _does_ use surrogate pairs. This asks for even more unexpected > behavior that with FPC, with String seemingly still being ANSIString ;). Yes. In D2009 String is UTF16String and Char is WideChar, sizeof(Char)=2. I personally do not like this solution. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Unicode support - for the 20th time... ;-)
On Thu, Nov 20, 2008 at 10:39:00AM +0100, Daniël Mantione wrote: > > > Op Thu, 20 Nov 2008, schreef Graeme Geldenhuys: > >> On Thu, Nov 20, 2008 at 11:12 AM, Florian Klaempfl >> <[EMAIL PROTECTED]> wrote: >>> >>> Ok, two questions for the example above: >>> - how do you maintain backward compatibility? >>> - how do you load a plain old ansi file? >> >> >> If the file is UTF-8 or ANSI, the above should work. UTF-8 was >> designed to be backward compatible with ANSI. One of the beauties of >> UTF-8. > > Wrong. It was designed to be compatible with ASCII, but incompatible with > ANSI. A CP1250 encoded file won't show correctly in an UTF-8 encoded > environment. > > That's why you have to convert. In the current FPC, the compiler can infer > the right conversion from type information only if the string is ansi > encoded or UCS2/UTF16 encoded. It simply hasn't type information to do the > other transformations correct. Therefore you have to call a function, there > is nothing we can change about that. > >> But yes, with other encodings it's a problem. And exactly the reason I >> think TStrings and the whole FPC for that matter should start >> supporting Unicode somehow. And that's why I urge all core FPC >> developers to try and finalize a Unicode design. Otherwise you leave >> it up to developers to keep adding such shitty hacks which could cause >> more issues in the long term - instead of solving issues. > > Design is almost final. Just give us time to implement. Can you summarize design in some document. For us developpers is important to see the future. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Unicode and Lazarus
On Thu, Nov 20, 2008 at 12:35:03PM +0200, Graeme Geldenhuys wrote: > As for loading files. It's 99.9% that all files are in ANSI or UTF8 > encoding and UTF8 being fulling backward compatible with ANSI makes > this a good thing. UTF-8 is not compatible with ANSI, but only with ASCII. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Compiler message verbosity remapping patch
Hi. I extend my patch for suppressing compiler messages. Now it is possible to remap compiler message verbosity by command parametr: -vm5024_,5025w,5026e which means: suppress message 5024, 5025 is warning and 5026 is error -vq shows compiler message numbers Is better to send extension patches here, or add it into bugtracker? Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 Index: compiler/verbose.pas === --- compiler/verbose.pas (revision 13256) +++ compiler/verbose.pas (working copy) @@ -177,11 +177,13 @@ end; -function ClearMessageVerbosity(s: string; var i: integer): boolean; +function SetMessageVerbosity(s: string; var i: integer): boolean; var tok : string; code : longint; msgnr: longint; +len : longint; +ch : char; begin { delete everything up to and including 'm' } delete(s,1,i); @@ -192,10 +194,13 @@ tok:=GetToken(s,','); if (tok='') then break; + len := length(tok); + ch := tok[len]; + delete(tok, len, 1); val(tok, msgnr, code); if (code<>0) then exit; - if not msg^.clearverbosity(msgnr) then + if not msg^.setverbosity(msgnr, ch) then exit; until false; result:=true; @@ -247,7 +252,7 @@ status.print_source_path:=true; end; 'M' : if inverse or - not ClearMessageVerbosity(s, i) then + not SetMessageVerbosity(s, i) then begin result:=false; exit Index: compiler/cmsgs.pas === --- compiler/cmsgs.pas (revision 13256) +++ compiler/cmsgs.pas (working copy) @@ -52,7 +52,7 @@ procedure ClearIdx; procedure CreateIdx; function GetPChar(nr:longint):pchar; -function ClearVerbosity(nr:longint):boolean; +function SetVerbosity(nr:longint; ch:char):boolean; function Get(nr:longint;const args:array of string):ansistring; end; @@ -375,7 +375,7 @@ GetPChar:=msgidx[nr div 1000]^[nr mod 1000]; end; -function TMessage.ClearVerbosity(nr:longint):boolean; +function TMessage.SetVerbosity(nr:longint; ch:char):boolean; var hp: pchar; i, txtbegin: longint; @@ -399,7 +399,7 @@ end; end; for i:=0 to txtbegin-1 do -hp[i]:='_'; +hp[i]:=ch; result:=true; end; Index: compiler/msg/errore.msg === --- compiler/msg/errore.msg (revision 13256) +++ compiler/msg/errore.msg (working copy) @@ -2888,7 +2888,8 @@ **2*_b : Write file names messages with full path **2*_v : Write fpcdebug.txt with p : Write tree.log with parse tree **2*_lots of debugging info q : Show message numbers -**2*_m, : Don't show messages numbered and +**2*_m_,w : Messages verbosity remaping. +**2*_Don't show message numbered , msg treat as warning 3*1W_Target-specific options (targets) A*1W_Target-specific options (targets) P*1W_Target-specific options (targets) Index: packages/fcl-db/src/base/dataset.inc ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Compiler message verbosity remapping patch
On Thu, Jun 11, 2009 at 02:15:15PM +0200, Joost van der Sluis wrote: > Op donderdag 11-06-2009 om 14:04 uur [tijdzone +0200], schreef > petr.kris...@epos.cz: > > I extend my patch for suppressing compiler messages. Now it is possible > > to remap compiler message verbosity by command parametr: > > -vm5024_,5025w,5026e which means: > > suppress message 5024, 5025 is warning and 5026 is error > > -vq shows compiler message numbers > > > > Is better to send extension patches here, or add it into bugtracker? > > Bug-tracker in general. Ok. I add it into bug-tracker. -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] ThousandSeparator and UTF-8
On Linux and cs_CZ.UTF-8 locale is thousand separator set to NO-BREAK SPACE (UTF-8: 0xC2 0xA0). But ThousandSeparator variable is defined as Char. Fpc sets ThousandSeparator=0xA0 and kylix ThousandSeparator=0xC2. Any ideas how to correctly solve it? Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] ThousandSeparator and UTF-8
On Fri, Oct 02, 2009 at 04:42:51PM +0200, Graeme Geldenhuys wrote: > 2009/10/2 : > > On Linux and cs_CZ.UTF-8 locale is thousand separator set to > > NO-BREAK SPACE (UTF-8: 0xC2 0xA0). > > > > But ThousandSeparator variable is defined as Char. Fpc sets > > ThousandSeparator=0xA0 and kylix ThousandSeparator=0xC2. > > > > Any ideas how to correctly solve it? > > > This is a know problem reported by me some months ago. Unfortunately > there is no fix in FPC until it full supports unicode with a char > 1 > byte. Why not use IFDEF-ed definition *Separators as strings for backward compatibility. {$IFDEF SEPARATORS_AS_STRINGS} ThousandSeparator: string; ... {$ELSE} ThousandSeparator: Char; {$ENDIF} Perhaps somebody do not want to use Char=WideChar in whole project. Maybe I. > In the mean time, you will have to define your own locale constants > with correct type sizes and manually do formatting. A pain in the > butt, I know. For me I solve it by hack replacing 0xC2 or 0xA0 to normal space 0x20. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Contribution
Hi. Now I'm working on porting our Delphi database application (cca 100 000 lines) to FreePascal. I have some little patches principally around TDataset. Where can I send this patches? Our application is now possible to translate in fpc, but first problem was unfunctional VarArrayCreate([0, 1], varVariant). Is here somebody who is working on Variants or may I try to penetrate into source and try to track down this bug? Petr Kristan -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Contribution
On Wed, Jun 01, 2005 at 03:22:10PM +0200, Florian Klaempfl wrote: > Michael Van Canneyt wrote: > > > > > > > On Wed, 1 Jun 2005 [EMAIL PROTECTED] wrote: > > > >> Hi. > >> > >> Now I'm working on porting our Delphi database application (cca 100 > >> 000 lines) to FreePascal. I > >> have some little patches principally around TDataset. Where can I send > >> this patches? > > > > > > Send them to me. > > > >> Our application is now possible to translate in fpc, but first problem > >> was > >> unfunctional VarArrayCreate([0, 1], varVariant). Is here somebody who is > >> working on Variants or may I try to penetrate into source and try to > >> track down this bug? > > > > > > Maybe Jason Southwell is working on it, but go ahead and change whatever > > you think needs changing. Patches can be sent to me. > > VarArrayCreate should basically work with 2.0.0. Yes VarArrayCreate(..., varInteger) works, but VarArrayCreate(..., varVariant) emits "VarArray is locked". Unfortunately my knowledge about variants internals is zero. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Contribution
On Wed, Jun 01, 2005 at 04:11:37PM +0200, Florian Klaempfl wrote: > [EMAIL PROTECTED] wrote: > > > On Wed, Jun 01, 2005 at 03:22:10PM +0200, Florian Klaempfl wrote: > > > >>Michael Van Canneyt wrote: > >> > >> > >>> > >>>On Wed, 1 Jun 2005 [EMAIL PROTECTED] wrote: > >>> > >>> > >>>>Hi. > >>>> > >>>>Now I'm working on porting our Delphi database application (cca 100 > >>>>000 lines) to FreePascal. I > >>>>have some little patches principally around TDataset. Where can I send > >>>>this patches? > >>> > >>> > >>>Send them to me. > >>> > >>> > >>>>Our application is now possible to translate in fpc, but first problem > >>>>was > >>>>unfunctional VarArrayCreate([0, 1], varVariant). Is here somebody who is > >>>>working on Variants or may I try to penetrate into source and try to > >>>>track down this bug? > >>> > >>> > >>>Maybe Jason Southwell is working on it, but go ahead and change whatever > >>>you think needs changing. Patches can be sent to me. > >> > >>VarArrayCreate should basically work with 2.0.0. > > > > Yes VarArrayCreate(..., varInteger) works, but VarArrayCreate(..., > > varVariant) emits "VarArray is locked". > > Unfortunately my knowledge about variants internals is zero. > > Can you create a small example which shows the problem? BTW: Which OS do you > use? Win or other? OS: Linux fpc 2.1.1 from svn. program pokus; uses Variants; var v: Variant; begin v := VarArrayCreate([0, 1], varVariant); end. emits EVariantBadVarTypeError : Invalid variant type Sorry for "VarArray is locked" mistake. It was another problem. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Range check error in cthreads (make debug)
If i compile rtl with debug info (make debug), then i get at start of my multithreaded app: An unhandled exception occurred at $08062B3C : ERangeError : Range check error $08062B3C CGETCURRENTTHREADID, line 310 of ../unix/cthreads.pp $0805ADAD GETCURRENTTHREADID, line 136 of /mnt/progs/devel/fpc/rtl/inc/thread.inc $08140367 COMMONINIT, line 1519 of /mnt/progs/devel/fpc/rtl/objpas/classes/classes.inc without debug info (make) it is ok. Linux, fpc from svn Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] units precedence cthreads, variants
Hi I'm trying to track down 'Variant Array is locked' bug and during simulation on simple program i found the unit precedence problem. -- program pokus1; uses cthreads, variants, Classes; type TTr = class(TThread) procedure Execute; override; end; procedure TTr.Execute; var v: Variant; begin writeln('before'); v := VarArrayOf(['1','2','3']); writeln('after'); end; var tr: TTr; begin tr:=TTr.Create(False); end. -- If unit cthreads are before variants then i get: -- before Program needs probably the variants unit. Include the variants unit in your uses statements as one of the first units. -- If unit variants are before cthreads then: -- Threading has been used before cthreads was initialized. Make cthreads one of the first units in your uses clause. Runtime error 211 at $08065B87 $08065B87 $080551CE $08048440 ---------- Linux, fpc from svn Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] units precedence cthreads, variants
On Thu, Jun 02, 2005 at 02:58:11PM +0200, [EMAIL PROTECTED] wrote: > Hi > > I'm trying to track down 'Variant Array is locked' bug and during > simulation on simple program i found the unit precedence problem. > > -- > program pokus1; > > uses > cthreads, variants, Classes; > > type > TTr = class(TThread) > procedure Execute; override; > end; > > procedure TTr.Execute; > var > v: Variant; > begin > writeln('before'); > v := VarArrayOf(['1','2','3']); > writeln('after'); > end; > > var > tr: TTr; > begin > tr:=TTr.Create(False); > end. > -- > > If unit cthreads are before variants then i get: > -- > before > > Program needs probably the variants unit. > Include the variants unit in your uses statements > as one of the first units. > > -- > > If unit variants are before cthreads then: > -- > Threading has been used before cthreads was initialized. > Make cthreads one of the first units in your uses clause. > Runtime error 211 at $08065B87 > $08065B87 > $080551CE > $08048440 > > > -- > > Linux, fpc from svn > > Petr Please, can somebody advise me how I can make program with threads and variants simultaneously. Thanks Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] cross-compiling (linux program from Win32 platform)
On Tue, Aug 02, 2005 at 01:46:11PM +0200, Marco van de Voort wrote: > > >> Sorry, Where I can found them? > > > > > > > > > I don't know; normally you must compile them yourself, but I suppose > > > they can be downloaded from various sites. > > > > Including the fpc ftp server: > > ftp://ftp.freepascal.org/pub/fpc/contrib/cross/mingw/ > > > > win32crossbinutils2005.zip contains cross binutils from win32 to many > > different targets. > > > > Read the BuildFAQ (google buildfaq.pdf) for an HOWTO setup a correct > > build environment (fpc.cfg). And what about linuxcrossbinutils2005.tar.gz :) Exists similar collection of cross bin utils on linux? Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Some Dataset and Variants patches
Index: rtl/objpas/varutils.inc Aded forgotten initialization === --- rtl/objpas/varutils.inc (revision 1083) +++ rtl/objpas/varutils.inc (working copy) @@ -359,6 +359,7 @@ if Res<>VAR_OK then exit; Result^.DimCount:=Dim; +Result^.LockCount:=0; Result^.Flags:=psaElementFlags[VarType]; Result^.ElementSize:=psaElementSizes[VarType]; for i:=0 to Dim-1 do Index: rtl/objpas/sysutils/sysstr.inc Repaired AnsiCompareStr === --- rtl/objpas/sysutils/sysstr.inc (revision 1083) +++ rtl/objpas/sysutils/sysstr.inc (working copy) @@ -299,7 +299,7 @@ Inc(S1); Inc(S2); Until (Result<>0) or (S1^=#0) or (S2^=#0); - if Result=0 then + if Result<>0 then if s1=#0 then result:=1 else Index: fcl/db/dataset.inc Aded FConstraints and TempBuffer only for possibility to compile my big project ported to fpc === --- fcl/db/dataset.inc (revision 1083) +++ fcl/db/dataset.inc (working copy) @@ -27,6 +27,7 @@ FFieldDefs:=TFieldDefs.Create(Self); FFieldList:=TFields.Create(Self); FDataSources:=TList.Create; + FConstraints := TCheckConstraints.Create(Self); end; @@ -40,6 +41,7 @@ Active:=False; FFieldDefs.Free; FFieldList.Free; + FreeAndNil(FConstraints); With FDatasources do begin While Count>0 do @@ -1882,3 +1884,9 @@ FDataSources.Remove(ADataSource); end; +Function TDataset.TempBuffer: PChar; + +begin + //!! To be implemented +end; + Index: fcl/db/db.pp === --- fcl/db/db.pp(revision 1083) +++ fcl/db/db.pp(working copy) @@ -1044,6 +1044,7 @@ procedure SetRecNo(Value: Longint); virtual; procedure SetState(Value: TDataSetState); function SetTempState(const Value: TDataSetState): TDataSetState; +function TempBuffer: PChar; procedure UpdateIndexDefs; virtual; property ActiveRecord: Longint read FActiveRecord; property CurrentRecord: Longint read FCurrentRecord; -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] VarArray bug
Hi. If I compile this program I get error --- program pokus; uses variants; procedure a(v: variant); begin end; var v: Variant; begin v := VarArrayCreate([0, 0], varVariant); a(v); end. -- An unhandled exception occurred at $0806418E : EVariantInvalidOpError : Invalid variant operation $0806418E VARINVALIDOP, line 2767 of ../inc/variants.pp $08064849 RAISEVAREXCEPTION, line 2878 of ../inc/variants.pp $080648FA VARRESULTCHECK, line 2903 of ../inc/variants.pp $080617A5 SYSVARCLEARPROC, line 1405 of ../inc/variants.pp $0805353F VARIANT_CLEAR, line 73 of /mnt/progs/devel/fpc/rtl/inc/variant.inc $08054C94 fpc_finalize, line 171 of /mnt/progs/devel/fpc/rtl/inc/rtti.inc $0804826E P$POKUS_finalize_implicit, line 333 of pokus.dpr $080554DF FINALIZEUNITS, line 612 of /mnt/progs/devel/fpc/rtl/inc/system.inc $08055548 INTERNALEXIT, line 635 of /mnt/progs/devel/fpc/rtl/inc/system.inc -- Linux and fpc from svn 1083. I think that problem is somewhere in fpc_finalize. But I realy do not understand to variants memory management. Helps to declare procedure a(const v: variant); But it is not a solution. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Some Dataset and Variants patches
On Fri, Sep 16, 2005 at 04:21:16PM +0200, Joost van der Sluis wrote: > Any reason to re-implement the tempbuffer? Or were you just using an > older version? Please give me more datails (history) about "tempbuffer". I can look deeply into ZeosLib and find out why it needs tempbuffer. Patch with constraints and tempbuffer is really not important. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Some Dataset and Variants patches
On Mon, Sep 19, 2005 at 01:29:16PM +0200, Joost van der Sluis wrote: > > > Any reason to re-implement the tempbuffer? Or were you just using an > > > older version? > > Please give me more datails (history) about "tempbuffer". > > Well, it was an empty procedure. But no-one had a clue where it was used > for. Probably it had something to do with some very old fpc-TDataset- > descendents. So it got removed. > > But if you can find a reason to keep it there... Maybe that ZEOS uses > it? Now i look at it. No ZEOS, but TRxMemoryData use it for record filtering. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Sets and delphi compatibility
Hi. I found, that this code does not work like in Delphii (-Sd). var v: variant; begin v := 'hi'; writeln(VarType(v)); writeln(varEmpty); writeln(varNull); if VarType(v) in [varEmpty, varNull] then writeln('NULL') else writeln(v); end. FPC output: 256 0 1 NULL DCC output: 256 0 1 hi I think that compiler makes set [varEmpty, varNull] only 8-bit. Is't any switch here to increase Delphi compatibility? Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Problems with variants calling convenction
Please, is here anybody who can help me with variants internals? I have still problems with VariantArrays and calling convenctions. Example: function A(): Variant; begin end; var V: variant; begin V:=A(); end; Why Result of the function a() is'nt a pointer to variable V, but is copied in fpc_finalize to variable V Isn't it unneeded slowing down??? And there is futhermore some bug in the returning VarArray. I have some free time to help with developement, but i need some support from community. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Problems with variants calling convenction
On Tue, Oct 04, 2005 at 03:04:43PM +0200, [EMAIL PROTECTED] wrote: > Please, > > is here anybody who can help me with variants internals? > I have still problems with VariantArrays and calling convenctions. > > Example: > > function A(): Variant; > begin > end; > > var > V: variant; > begin > V:=A(); > end; > > Why Result of the function a() is'nt a pointer to variable V, but is > copied in fpc_finalize to variable V Isn't it unneeded slowing > down??? And there is futhermore some bug in the returning VarArray. > > I have some free time to help with developement, but i need some > support from community. Now i read in compiler/nld.pas: { call helpers for variant, they can contain non ref. counted types like vararrays which must be really copied } But in Kylix aren't Variant results copied. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Variant compiling errors
Hi. After a few hours with gdb was isolated errors and strangeness in compiler at work with variants: Example: function c(const vv: variant): variant; begin result := vv; end; function b(vv: variant): variant; begin result := vv; end; function a(var vv: variant): variant; begin result := vv; end; procedure start; var v, v1: Variant; begin v := VarArrayCreate([0, 0], varVariant); a(v); //if variant result of a() isn't assigned, fpc_finalize() at end of a(v) //destroys temporary result. But when start() ends fpc_finalize() tryes //to destroy it again b(v); //if b() is called then variant param is copied but not whole (deeply), vv.varray //points to the same place as v.array. At end of b(v) is pointer //vv.array destroyed by fpc_decref() and then v.array points to the //destroyed memory c(v); //At the start of func c() is v copied to the vv deeply but i think //that behaviour of "var" and "const" calling should be the same (by //reference) not vy value like c() end; I try to understand compiler code and repair it, but this is "very long distance race". But like I see the responses to my previous reports (absolutely no interest), this will be fastest solution :(. Really here isn't anybody who understand to compiler code and help me with repair? Or is anywhere another e-mail list or another comunication channel where i can talk about this problem? Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Variant compiling errors
On Mon, Oct 10, 2005 at 02:11:04PM +0200, Florian Klaempfl wrote: > [EMAIL PROTECTED] wrote: > > > Hi. > > > > After a few hours with gdb was isolated errors and strangeness in compiler > > at work with variants: > > > > Example: > > > > function c(const vv: variant): variant; > > begin > > result := vv; > > end; > > > > function b(vv: variant): variant; > > begin > > result := vv; > > end; > > > > function a(var vv: variant): variant; > > begin > > result := vv; > > end; > > > > procedure start; > > var > > v, v1: Variant; > > begin > > v := VarArrayCreate([0, 0], varVariant); > > > > a(v); > > //if variant result of a() isn't assigned, fpc_finalize() at end of a(v) > > //destroys temporary result. But when start() ends fpc_finalize() tryes > > //to destroy it again > > > > b(v); > > //if b() is called then variant param is copied but not whole (deeply), > > vv.varray > > //points to the same place as v.array. At end of b(v) is pointer > > //vv.array destroyed by fpc_decref() and then v.array points to the > > //destroyed memory > > > > c(v); > > //At the start of func c() is v copied to the vv deeply but i think > > //that behaviour of "var" and "const" calling should be the same (by > > //reference) not vy value like c() > > end; > > > > I try to understand compiler code and repair it, but this is "very long > > distance race". But like I see the responses to my previous reports > > (absolutely no interest), this will be fastest solution :(. Really here > > isn't anybody who understand to compiler code and help me with repair? > > Or is anywhere another e-mail list or another comunication channel where > > i can talk about this problem? > > > > Petr > > > > The var arrays problems are known, see also > http://www.freepascal.org/bugs/showrec.php3?ID=3830 > > It requires some design changes though that's why it isn't fixed yet. The > problem is that the compiler handles variants as ref. counted types when > passing > them as parameters etc. However, this is wrong behaviour as soon as a variant > contains an array. Thanks for explanation. Yesterday i looked at compiler code and fpc internals documentation. I must recognize that fixing this is beyond my strength. Is somebody working on it? I can help with debugging. Vararray problem stopped my work -- porting big information system to fpc. In Rtl/fcl i can repair or fill missing, but here i'am helpless. For that reason i hurry on fixing this. Petr -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] libc bug on Linux
Linux, fpc from svn. program pokus; uses Libc; begin writeln(CODESET,', ', nl_langinfo(CODESET)); end. If I compile with Borland dcc, then I get right answer: 14, ISO-8859-2 but with fpc I get: 14, ANSI_X3.4-1968 If I try to modify program to eliminate the rtl errors: program pokus; const CODESET = 14; function nl_langinfo(__item: Integer): pchar;cdecl; external 'libc.so.6' name 'nl_langinfo'; begin writeln(CODESET,', ', nl_langinfo(CODESET)); end. Result is the same as above. Some linking problem ??? -- Ing. Petr Kristan . EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice tel: +420 466335223Czech Republic (Eastern Europe) fax: +420 466510709 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] String constant without code page
Hi. I compile whole project with -FcUTF8, but sometimes should be useful to define string constant with CP_NONE to prevent conversions. Example: DefaultSystemCodePage:=1250 variable s contains text with cp=1250 s := s + '#'; //conversion because '#' has cp=65001 Is possible to define '#' without cp? Or is possible to do fast string concatenation without conversion? Thanks Petr -- Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401Czech Republic (Eastern Europe) fax: +420 461101481 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel