Re: [fpc-devel] Unicodestring branch, please test and help fixing
On Saturday 06 September 2008 21.08:50 Florian Klaempfl wrote: Martin Schreiber schrieb: Next problem is that pmsechar(msestring) returns a NIL pointer if msestring = ''. As designed? The behaviour of ansistring and widestring was very useful, I'd like if UnicodeString would behave the same. Do you have some example code which shows this? See attachment. Test result: F:\proj\testcase\fpc\unicode\punicodecharpunicodechartest.exe 4288048 4288048 0 0 0 An unhandled exception occurred at $004016C5 : EAccessViolation : Access violation $004016C5 main, line 25 of punicodechartest.pas Martin program punicodechartest; {$ifdef FPC}{$mode objfpc}{$h+}{$endif} {$ifdef mswindows}{$apptype console}{$endif} uses {$ifdef FPC}{$ifdef linux}cthreads,{$endif}{$endif} sysutils; var astr: ansistring; wstr: widestring; ustr: unicodestring; begin astr:= ''; wstr:= ''; ustr:= ''; writeln(ptrint(pansichar(astr))); flush(output); writeln(ptrint(pwidechar(wstr))); flush(output); writeln(ptrint(punicodechar(ustr))); flush(output); writeln(ord(pansichar(astr)^)); flush(output); writeln(ord(pwidechar(wstr)^)); flush(output); writeln(ord(punicodechar(ustr)^)); flush(output); end. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Unicodestring branch, please test and help fixing
Martin Schreiber schrieb: On Saturday 06 September 2008 21.08:50 Florian Klaempfl wrote: Martin Schreiber schrieb: Next problem is that pmsechar(msestring) returns a NIL pointer if msestring = ''. As designed? The behaviour of ansistring and widestring was very useful, I'd like if UnicodeString would behave the same. Do you have some example code which shows this? Fixed. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] patch for ReadInteger in sysformt.inc
Hi, latest profiling of one of our FPC applications showed ReadInteger (in rtl/objpas/sysutils/sysformt.inc) to be a performance bottleneck. Using Pos(Fmt[chpos],'1234567890')0 to check if Fmt[chpos] is a digit is somewhat time consuming. I replaced it with two char comparisons with '0' and '9'. The rest of the patch only unifies the casing of the variable chpos. Markus diff -Naur fpc-20080907/rtl/objpas/sysutils/sysformt.inc fpc-readintegerpatch/rtl/objpas/sysutils/sysformt.inc --- fpc-20080907/rtl/objpas/sysutils/sysformt.inc 2008-04-07 01:00:27.0 +0200 +++ fpc-readintegerpatch/rtl/objpas/sysutils/sysformt.inc 2008-09-07 13:40:56.527074445 +0200 @@ -23,14 +23,14 @@ begin If Value-1 then exit; // Was already read. - OldPos:=chPos; - While (Chpos=Len) and -(Pos(Fmt[chpos],'1234567890')0) do inc(chpos); - If Chposlen then + OldPos:=ChPos; + While (ChPos=Len) and +(Fmt[ChPos]='9') and (Fmt[ChPos]='0') do inc(ChPos); + If ChPoslen then DoFormatError(feInvalidFormat); - If Fmt[Chpos]='*' then + If Fmt[ChPos]='*' then begin -If (ChposOldPos) or (ArgPosHigh(Args)) then +If (ChPosOldPos) or (ArgPosHigh(Args)) then DoFormatError(feInvalidFormat); case Args[ArgPos].Vtype of vtInteger: Value := Args[ArgPos].VInteger; @@ -40,11 +40,11 @@ DoFormatError(feInvalidFormat); end; Inc(ArgPos); -Inc(chPos); +Inc(ChPos); end else begin -If (OldPoschPos) Then +If (OldPosChPos) Then begin Val (Copy(Fmt,OldPos,ChPos-OldPos),value,code); // This should never happen !! @@ -67,7 +67,7 @@ If Value=-1 then DoFormatError(feMissingArgument); Index:=Value; Value:=-1; -Inc(Chpos); +Inc(ChPos); end; {$ifdef fmtdebug} Log ('Read index'); @@ -77,10 +77,10 @@ Procedure ReadLeft; begin - If Fmt[chpos]='-' then + If Fmt[ChPos]='-' then begin left:=True; -Inc(chpos); +Inc(ChPos); end else Left:=False; @@ -106,9 +106,9 @@ Procedure ReadPrec; begin - If Fmt[chpos]='.' then + If Fmt[ChPos]='.' then begin -inc(chpos); +inc(ChPos); ReadInteger; If Value=-1 then Value:=0; @@ -132,8 +132,8 @@ Width:=-1; Prec:=-1; Value:=-1; -inc(chpos); -If Fmt[Chpos]='%' then +inc(ChPos); +If Fmt[ChPos]='%' then begin Result:='%'; exit; // VP fix @@ -198,15 +198,15 @@ begin Result:=''; Len:=Length(Fmt); - Chpos:=1; + ChPos:=1; OldPos:=1; ArgPos:=0; - While chpos=len do + While ChPos=len do begin -While (ChPos=Len) and (Fmt[chpos]'%') do - inc(chpos); +While (ChPos=Len) and (Fmt[ChPos]'%') do + inc(ChPos); If ChPosOldPos Then - Result:=Result+Copy(Fmt,OldPos,Chpos-Oldpos); + Result:=Result+Copy(Fmt,OldPos,ChPos-Oldpos); If ChPosLen then begin FChar:=ReadFormat; @@ -348,7 +348,7 @@ ToAdd:=ToAdd+space(Width-Length(ToAdd)); Result:=Result+ToAdd; end; -inc(chpos); -Oldpos:=chpos; +inc(ChPos); +Oldpos:=ChPos; end; end; ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Sdf / Fixed maximum line length flexibilization
Hello, Sdf / Fixed datasets have a constant for the maximum line size, but this one is too small for me, so I changed the constant into a field in the class so it can be customized. I tested and it works for me. I just thougth someone may have a better idea, so I am showing the patch here for review and will apply in some days if noone has a better idea. Index: sdfdata.pp === --- sdfdata.pp (revision 11718) +++ sdfdata.pp (working copy) @@ -125,9 +125,6 @@ uses DB, Classes, SysUtils; -const - MAXSTRLEN = 250; - type //- // TRecInfo @@ -199,6 +196,7 @@ function BufToStore(Buffer: PChar): String; virtual; function StoreToBuf(Source: String): String; virtual; public +MAXSTRLEN: Integer; constructor Create(AOwner: TComponent); override; destructor Destroy; override; function GetFieldData(Field: TField; Buffer: Pointer): Boolean; override; @@ -274,6 +272,7 @@ //- constructor TFixedFormatDataSet.Create(AOwner : TComponent); begin + MAXSTRLEN := 250; FFileMustExist := TRUE; FLoadfromStream := False; FRecordSize := 0; ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Sdf / Fixed maximum line length flexibilization
Felipe Monteiro de Carvalho wrote: function StoreToBuf(Source: String): String; virtual; public +MAXSTRLEN: Integer; If you don't object, this is a bit ugly to my taste. Why not 'FMaxStrLen', and have a property MaxStrLen: read FMaxStrLen ? Looks better to me. Micha ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Sdf / Fixed maximum line length flexibilization
Hi Felipe Monteiro de Carvalho wrote: function StoreToBuf(Source: String): String; virtual; public +MAXSTRLEN: Integer; If you don't object, this is a bit ugly to my taste. Why not 'FMaxStrLen', and have a property MaxStrLen: read FMaxStrLen ? Looks better to me. I second the property declaration with a little modification to make it more readable : property MaxStringLength read FMaxStringLength write FMaxStringLength default 250; -- Inoussa O. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Unicodestring branch, please test and help fixing
On Sunday 07 September 2008 10.58:03 Florian Klaempfl wrote: Martin Schreiber schrieb: On Saturday 06 September 2008 21.08:50 Florian Klaempfl wrote: Martin Schreiber schrieb: Next problem is that pmsechar(msestring) returns a NIL pointer if msestring = ''. As designed? The behaviour of ansistring and widestring was very useful, I'd like if UnicodeString would behave the same. Do you have some example code which shows this? Fixed. Trunk 11723 does not compile: make[7]: Entering directory `E:/FPC/svn/trunk/rtl/win32' C:/FPC/2.2.2/bin/i386-Win32/gmkdir.exe -p E:/FPC/svn/trunk/rtl/units/i386-win32 C:/FPC/2.2.2/bin/i386-Win32/ppc386.exe -Ur -Xs -O2 -n -Fi../inc -Fi../i386 -Fi.. /win -FE. -FUE:/FPC/svn/trunk/rtl/units/i386-win32 -di386 -dRELEASE -Us -Sg system.pp -Fi../win wustring22.inc(699,27) Fatal: Unknown compilerproc fpc_char_to_wchar. Check if you use the correct run time library. Fatal: Compilation aborted make[7]: *** [system.ppu] Fehler 1 make[7]: Leaving directory `E:/FPC/svn/trunk/rtl/win32' make[6]: *** [win32_all] Fehler 2 make[6]: Leaving directory `E:/FPC/svn/trunk/rtl' make[5]: *** [rtl] Fehler 2 make[5]: Leaving directory `E:/FPC/svn/trunk/compiler' make[4]: *** [next] Fehler 2 make[4]: Leaving directory `E:/FPC/svn/trunk/compiler' make[3]: *** [ppc1.exe] Fehler 2 make[3]: Leaving directory `E:/FPC/svn/trunk/compiler' make[2]: *** [cycle] Fehler 2 make[2]: Leaving directory `E:/FPC/svn/trunk/compiler' make[1]: *** [compiler_cycle] Fehler 2 make[1]: Leaving directory `E:/FPC/svn/trunk' make: *** [build-stamp.i386-win32] Fehler 2 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Sdf / Fixed maximum line length flexibilization
On 9/7/08, Inoussa OUEDRAOGO [EMAIL PROTECTED] wrote: property MaxStringLength read FMaxStringLength write FMaxStringLength default 250; I went for this, but named it MaxRecordLength. Always good to hear other oppinions =) Commited to trunk. I don't know if there are plans for a 2.2.4, but this would be a nice addition to it. -- Felipe Monteiro de Carvalho ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Unicodestring branch, please test and help fixing
Martin Schreiber schrieb: On Sunday 07 September 2008 10.58:03 Florian Klaempfl wrote: Martin Schreiber schrieb: On Saturday 06 September 2008 21.08:50 Florian Klaempfl wrote: Martin Schreiber schrieb: Next problem is that pmsechar(msestring) returns a NIL pointer if msestring = ''. As designed? The behaviour of ansistring and widestring was very useful, I'd like if UnicodeString would behave the same. Do you have some example code which shows this? Fixed. Trunk 11723 does not compile: Trunk or unicodestring branch? Strange, because here it works? ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Sdf / Fixed maximum line length flexibilization
2008/9/7 Felipe Monteiro de Carvalho [EMAIL PROTECTED]: On 9/7/08, Inoussa OUEDRAOGO [EMAIL PROTECTED] wrote: property MaxStringLength read FMaxStringLength write FMaxStringLength default 250; I went for this, but named it MaxRecordLength. even better. -- Inoussa O. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] TSdfDataset does not work with records larger then 255 chars
Hello, Using TSdfDataset my records are cut to fit 255 chars, even when I change the new MaxRecordLength property to 2048. This is a very elusive bug, and I am searching all over for the cause without success =( I searched everywhere for a shortstring, which could be the cause, but didn't find any. Any ideas? I was not able to debug inside FCL, maybe the standard build comes without debug info? I was able to debug the sdfdata unit because I am using it locally in my project, because I am using FPC 2.2.2 and when the flow of events comes to TFIXEDFORMATDATASET__SETFIELDDATA the string is already cutted and in TDBDRAWINGCODEMEMO__UPDATEDATA it was correct, so it must have been cutted in the FCL somewhere in between. My data is comming from a modifyed TDBMemo, and I already certified that my Memo is giving a correct string to the dataset. Here is the chain of events that happen when I click in a button that will call Post for the dataset: #0 TFIXEDFORMATDATASET__SETFIELDDATA((^TFIELD) 0x14f358, (POINTER) 0x6d430, (TFIXEDFORMATDATASET) 0xbede0) at sdfdata.pp:674 - String is cutted to 255 chars #1 DB_TDATASET_$__SETFIELDDATA$TFIELD$POINTER$BOOLEAN at :0 #2 DB_TFIELD_$__SETDATA$POINTER$BOOLEAN at :0 #3 DB_TFIELD_$__SETDATA$POINTER at :0 #4 DB_TSTRINGFIELD_$__SETASSTRING$ANSISTRING at :0 #5 TDBDRAWINGCODEMEMO__UPDATEDATA((^TOBJECT) 0x159490, (TDBDRAWINGCODEMEMO) 0x10a750) at dbcomponents.pas:340 -- String is correct #6 TFIELDDATALINK__UPDATEDATA((TFIELDDATALINK) 0x159490) at dbctrls.pp:1312 #7 DB_TDATALINK_$__UPDATERECORD at :0 #8 TDBDRAWINGCODEMEMO__EDITINGDONE((TDBDRAWINGCODEMEMO) 0x10a750) at dbcomponents.pas:372 #9 TCONTROL__MOUSEDOWN(MBLEFT, [SSLEFT], 8, 13, (TCONTROL) 0x11d280) at control.inc:3219 #10 TCUSTOMSPEEDBUTTON__MOUSEDOWN(MBLEFT, [SSLEFT], 8, 13, (TCUSTOMSPEEDBUTTON) 0x11d280) at speedbutton.inc:635 -- Felipe Monteiro de Carvalho ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Unicodestring branch, please test and help fixing
On Sunday 07 September 2008 21.23:24 Florian Klaempfl wrote: Trunk 11723 does not compile: Trunk or unicodestring branch? Strange, because here it works? Unicodestring branch, sorry, I should change the directory name of my switched checkout. Does your unicodestring branch compile? Martin ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel