[fpc-devel]quoted arguments in StringToPPChar()
Jeff Pohlmeyer
yetanothergeek at yahoo.com
Sun May 2 11:09:07 CEST 2004
How many args here?
nedit "i hate filenames with spaces"
bash says two, but StringToPPChar() says six.
- this patch should solve the problem:
[PATCH]
--- unixutil.pp.OLD Sun May 2 02:48:19 2004
+++ unixutil.pp.NEW Sun May 2 03:04:56 2004
@@ -99,7 +99,7 @@
nr : longint;
Buf : ^char;
p : ppchar;
-
+ Q:char;
begin
buf:=s;
nr:=0;
@@ -108,7 +108,16 @@
while (buf^ in [' ',#9,#10]) do
inc(buf);
inc(nr);
- while not (buf^ in [' ',#0,#9,#10]) do
+ if (buf^ in [#34,#39]) then
+ begin
+ Q:=buf^; { opening quote mark }
+ repeat
+ inc(buf); { scan for closing quote }
+ until ( buf^ in [#0,Q]);
+ if buf^ = Q then
+ inc(buf);
+ end;
+ while not (buf^ in [' ',#0,#9,#10,#34,#39]) do
inc(buf);
end;
getmem(p,nr*4);
@@ -128,10 +137,25 @@
buf^:=#0;
inc(buf);
end;
- p^:=buf;
+ if (buf^ in [#34,#39]) then
+ begin
+ Q:=buf^; { opening quote mark }
+ buf^:=#0;
+ p^:=@buf[1];
+ repeat
+ inc(buf); {scan for closing quote}
+ until ( buf^ in [#0,Q]);
+ if (buf^=Q) then
+ begin
+ buf^:=#0;
+ inc(buf);
+ end;
+ end
+ else
+ p^:=buf;
inc(p);
p^:=nil;
- while not (buf^ in [' ',#0,#9,#10]) do
+ while not (buf^ in [' ',#0,#9,#10,#34,#39]) do
inc(buf);
end;
end;
[/PATCH]
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover
More information about the fpc-devel
mailing list