Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2004-05

quoted arguments in StringToPPChar()

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jeff Pohlmeyer

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;
+       ;
+       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

Reply by email

Marco van de Voort
to Jeff Pohlmeyer
Show quoted text 6 lines
How many args here? nedit "i hate filenames with spaces" bash says two, but StringToPPChar() says six. - this patch should solve the problem:

Which FPC version are you using? Afaik this has been reworked in 1.9.3.

Reply by email