Re: [fpc-pascal] TDOMElement and multiple attributes
On Sun, 27 Mar 2011 22:56:16 -0300 Flávio Etrusco wrote: > > > > > >> someone@somewhere:~/pascal/Projects/xmldemo$ cat test.xml > >> > >> > >> >> aaaAttribute="1"/> > >> > >> > >> Looks like the order is governed by the length of the attribute name first > >> and then alphabetically. > >> > Actually it isn't sorted by length, but it's case-sensitive. No. See 2.4.2/fpc/packages/fcl-xml/src/dom.pp function CompareDOMStrings(const s1, s2: DOMPChar; l1, l2: integer): integer; var i: integer; begin Result:=l1-l2; i:=0; while (i Mattias wrote: > > Yes, that is what CompareDOMStrings does. > > Probably for speed reasons. > > > Indeed, laz_xmlwrite and laz2_xmlwrite both do this, but the example > is using xmlwrite.pas from fcl-xml. No. laz_xmlwrite and laz2_xmlwrite use laz_dom, laz2_dom. > > This function is fixed in the code. > > > What do you mean? The user can not change this behavior. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TDOMElement and multiple attributes
> > >> someone@somewhere:~/pascal/Projects/xmldemo$ cat test.xml >> >> >> >> >> >> Looks like the order is governed by the length of the attribute name first >> and then alphabetically. >> Actually it isn't sorted by length, but it's case-sensitive. Mattias wrote: > Yes, that is what CompareDOMStrings does. > Probably for speed reasons. > Indeed, laz_xmlwrite and laz2_xmlwrite both do this, but the example is using xmlwrite.pas from fcl-xml. > This function is fixed in the code. > What do you mean? Best regards. Flávio ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] run pascal programs as scripts
On Sun, 27 Mar 2011 23:59:11 +0200 (CEST) Michael Van Canneyt wrote: > > > On Sun, 27 Mar 2011, Mattias Gaertner wrote: > > > On Sun, 27 Mar 2011 21:16:58 +0200 (CEST) > > Michael Van Canneyt wrote: > > > >> > >> > >> On Sun, 27 Mar 2011, Mattias Gaertner wrote: > >> > >>> On Sun, 27 Mar 2011 19:05:12 +0200 (CEST) > >>> Michael Van Canneyt wrote: > >>> > > > On Sun, 27 Mar 2011, Mattias Gaertner wrote: > > > I wrote a little tool: > > > > http://wiki.lazarus.freepascal.org/InstantFPC > > Nice job. OK to include in FPC as one of the utils ? > >>> > >>> Yes. > >> > >> Thank you. But please, fix a couple of bugs first: > >> > >> 1. I get a stream read error each time I execute a script the first time > >> (i.e. it's not yet in the cache) : > >> home: >./helloworld.pas > >> An unhandled exception occurred at $00425556 : > >> EReadError : Stream read error > >>$00425556 > >>$004256FA > >>$00469E8A > >>$00400A25 > > > > It works here. > > I assume you use FPC 2.4.x. In FPC 2.5.1 your code > >repeat > Count:=ss.CopyFrom(Proc.Output,4096); >until Count=0; > > Fails. > > This is because CopyFrom assumes that at least 4096 bytes are present. > If it doesn't get 4096 bytes, an exception is thrown. > > (see recent change in trunk: > r16992 | sergei | 2011-02-24 04:25:40 +0100 (Thu, 24 Feb 2011) | 5 lines > > * Rework TStream.CopyFrom (see Mantis #17980): > a) Use significantly larger buffer (128k instead of 1k) > b) When Count=0, do not try to determine the source size. Just copy until the > source can be read. This should improve performance with limited seek > capability sources (e.g. a decompression stream will be decompressed once > rather than twice). > c) Use ReadBuffer/WriteBuffer, so an exception is raised when something goes > wrong. This conforms to Delphi behavior. > ) > > My FPC outputs nothing, so CopyFrom does not get 4096 bytes and therefor > raises an exception: > > Breakpoint 1, 0x0041396c in fpc_raiseexception () > (gdb) bt > #0 0x0041396c in fpc_raiseexception () > #1 0x00425565 in CLASSES_TSTREAM_$__READBUFFER$formal$LONGINT () > #2 0x004256fa in CLASSES_TSTREAM_$__COPYFROM$TSTREAM$INT64$$INT64 () > #3 0x00469e8a in INSTANTFPTOOLS_COMPILE$ANSISTRING$ANSISTRING () > #4 0x00400a25 in main () > > since the compilation is already done, the binary is in the cache, and the > second run works. > > Changing the code to > >buf : Array[1..4096] of byte; > > begin >// snip >ss:=TStringStream.Create(''); >repeat > Count:=Proc.Output.Read(Buf,4096); > if Count>0 then >ss.write(buf,count); >until Count=0; > > it works always. Will you change it, or do I change it once it is in FPC ? I changed it on sf. > This change may affect other things in Lazarus. > Sergei (hope you are reading this), I think you should put this in the > user_changes wiki page. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] run pascal programs as scripts
On Sun, 27 Mar 2011, Mattias Gaertner wrote: On Sun, 27 Mar 2011 21:16:58 +0200 (CEST) Michael Van Canneyt wrote: On Sun, 27 Mar 2011, Mattias Gaertner wrote: On Sun, 27 Mar 2011 19:05:12 +0200 (CEST) Michael Van Canneyt wrote: On Sun, 27 Mar 2011, Mattias Gaertner wrote: I wrote a little tool: http://wiki.lazarus.freepascal.org/InstantFPC Nice job. OK to include in FPC as one of the utils ? Yes. Thank you. But please, fix a couple of bugs first: 1. I get a stream read error each time I execute a script the first time (i.e. it's not yet in the cache) : home: >./helloworld.pas An unhandled exception occurred at $00425556 : EReadError : Stream read error $00425556 $004256FA $00469E8A $00400A25 It works here. I assume you use FPC 2.4.x. In FPC 2.5.1 your code repeat Count:=ss.CopyFrom(Proc.Output,4096); until Count=0; Fails. This is because CopyFrom assumes that at least 4096 bytes are present. If it doesn't get 4096 bytes, an exception is thrown. (see recent change in trunk: r16992 | sergei | 2011-02-24 04:25:40 +0100 (Thu, 24 Feb 2011) | 5 lines * Rework TStream.CopyFrom (see Mantis #17980): a) Use significantly larger buffer (128k instead of 1k) b) When Count=0, do not try to determine the source size. Just copy until the source can be read. This should improve performance with limited seek capability sources (e.g. a decompression stream will be decompressed once rather than twice). c) Use ReadBuffer/WriteBuffer, so an exception is raised when something goes wrong. This conforms to Delphi behavior. ) My FPC outputs nothing, so CopyFrom does not get 4096 bytes and therefor raises an exception: Breakpoint 1, 0x0041396c in fpc_raiseexception () (gdb) bt #0 0x0041396c in fpc_raiseexception () #1 0x00425565 in CLASSES_TSTREAM_$__READBUFFER$formal$LONGINT () #2 0x004256fa in CLASSES_TSTREAM_$__COPYFROM$TSTREAM$INT64$$INT64 () #3 0x00469e8a in INSTANTFPTOOLS_COMPILE$ANSISTRING$ANSISTRING () #4 0x00400a25 in main () since the compilation is already done, the binary is in the cache, and the second run works. Changing the code to buf : Array[1..4096] of byte; begin // snip ss:=TStringStream.Create(''); repeat Count:=Proc.Output.Read(Buf,4096); if Count>0 then ss.write(buf,count); until Count=0; it works always. Will you change it, or do I change it once it is in FPC ? This change may affect other things in Lazarus. Sergei (hope you are reading this), I think you should put this in the user_changes wiki page. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] run pascal programs as scripts
On Sun, 27 Mar 2011 21:16:58 +0200 (CEST) Michael Van Canneyt wrote: > > > On Sun, 27 Mar 2011, Mattias Gaertner wrote: > > > On Sun, 27 Mar 2011 19:05:12 +0200 (CEST) > > Michael Van Canneyt wrote: > > > >> > >> > >> On Sun, 27 Mar 2011, Mattias Gaertner wrote: > >> > >>> I wrote a little tool: > >>> > >>> http://wiki.lazarus.freepascal.org/InstantFPC > >> > >> Nice job. OK to include in FPC as one of the utils ? > > > > Yes. > > Thank you. But please, fix a couple of bugs first: > > 1. I get a stream read error each time I execute a script the first time > (i.e. it's not yet in the cache) : > home: >./helloworld.pas > An unhandled exception occurred at $00425556 : > EReadError : Stream read error >$00425556 >$004256FA >$00469E8A >$00400A25 It works here. > home: >./helloworld.pas > Hello world 2 > > > 2. passing options on the commandline does not work on my Kubuntu 10.04: > > home: >./envvars.pas > /usr/bin/env: instantfpc -Mobjfpc -Sh: No such file or directory Fixed. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] run pascal programs as scripts
On Sun, 27 Mar 2011, Mattias Gaertner wrote: On Sun, 27 Mar 2011 19:05:12 +0200 (CEST) Michael Van Canneyt wrote: On Sun, 27 Mar 2011, Mattias Gaertner wrote: I wrote a little tool: http://wiki.lazarus.freepascal.org/InstantFPC Nice job. OK to include in FPC as one of the utils ? Yes. Thank you. But please, fix a couple of bugs first: 1. I get a stream read error each time I execute a script the first time (i.e. it's not yet in the cache) : home: >./helloworld.pas An unhandled exception occurred at $00425556 : EReadError : Stream read error $00425556 $004256FA $00469E8A $00400A25 home: >./helloworld.pas Hello world 2 2. passing options on the commandline does not work on my Kubuntu 10.04: home: >./envvars.pas /usr/bin/env: instantfpc -Mobjfpc -Sh: No such file or directory Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] run pascal programs as scripts
On Sun, 27 Mar 2011 19:05:12 +0200 (CEST) Michael Van Canneyt wrote: > > > On Sun, 27 Mar 2011, Mattias Gaertner wrote: > > > I wrote a little tool: > > > > http://wiki.lazarus.freepascal.org/InstantFPC > > Nice job. OK to include in FPC as one of the utils ? Yes. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] run pascal programs as scripts
On Sun, 27 Mar 2011, Mattias Gaertner wrote: I wrote a little tool: http://wiki.lazarus.freepascal.org/InstantFPC Nice job. OK to include in FPC as one of the utils ? Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] run pascal programs as scripts
I wrote a little tool: http://wiki.lazarus.freepascal.org/InstantFPC Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal