[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]

Re: [BUG REPORT] WML 1.7.2 and current CVS snapshot, SunOS 5.5.1



On Tue, 29 Jun 1999 simes@bpfh.net wrote:

> BUG REPORT
> 
> Package: WML 1.7.2 and current CVS snapshot
> Operating System: SunOS 5.5.1
> 
> Problem Description:
> | The processing of the -D option always strips off a
> | trailing " on the option, even if that quote has been
> | escaped by a \. Thus the option
> | 
> |  -DFOO="moo \"bar\""
> | 
> | Results in things like
> | 
> |   --set "FOO" "moo \"bar\"
> | 
> | Being sent into meta-html. The problem was with the
> | regex which splits the values from @opt_D up for the
> | backends which use it. The regex was:
> | 
> |   ($var, $val) = ($d =~ m|^(.+?)="?(.*?)"?$|);
> | 
> | I have corrected this to the following, which handles
> | trailing " correctly and leaves escaped " along so that
> | the correct thing happens. The new regex is:
> | 
> | ($var, $val) = ($d =~ m|^(.+?)="?(.*?(?:\\")?)"?$|);

Hi again,

i think i find something :-)
Could you please tell me if this works for you, I check it with this
file (test.wml)
  #!wml -DBAZ="foo \"bar\""
  pass 1: $(OOF)
  pass 2: <get-var OOF>
  pass 3: m4_OOF
  pass 1: $(FOO)
  pass 2: <get-var FOO>
  pass 3: m4_FOO
  pass 1: $(BAR)
  pass 2: <get-var BAR>
  pass 3: m4_BAR
  pass 1: $(BAZ)
  pass 2: <get-var BAZ>
  pass 3: m4_BAZ
## EOF ##
In .wmlrc:
    -DBAR="foo \"bar\""

prompt$ export WMLOPTS="-DOOF=\"foo \\\"bar\\\"\""
prompt$ wml -DFOO="foo \\\"bar\\\"" test.wml
prompt$ wml -s -DFOO="foo \\\"bar\\\"" test.wml

Yes, there are 3 backslashes. It's a first try, so there could be a
solution with just one.
I believe i try all combinations, but there are always people on this
list having strange desires ;-)

Here comes the patch

Denis

--- wml_frontend/wml.src	1999/06/09 20:15:23	1.24
+++ wml_frontend/wml.src	1999/06/30 22:19:38
@@ -192,8 +192,8 @@
     my ($r) = '';
 
     while (1) {
-        next if $str =~ s|^"([^"]*)"(.*)$|$r .= $1, $2|e; 
-        next if $str =~ s|^'([^']*)'(.*)$|$r .= $1, $2|e; 
+        next if $str =~ s|^"(.*?(?!\\).)"(.*)$|$r .= $1, $2|e; 
+        next if $str =~ s|^'(.*?)'(.*)$|$r .= $1, $2|e; 
         next if $str =~ s|^([^\s"']+)(.*)$|$r .= $1, $2|e;
         if ($str =~ m|^[\s\n]+| || $str eq '') {
             if ($r ne '') {
@@ -450,15 +450,8 @@
     }
     close(TMP);
     if ($shebang =~ m|^#!wml\s+(.+\S)\s*$|is) {
-        $opts = $1;
-
         #   split opts into arguments and process them
-        if ($opts =~ m|\s+|) {
-            @ARGV = split(/\s+/, $opts);
-        }
-        else {
-            @ARGV = ( $opts );
-        }
+        @ARGV = &split_argv($1);
         &ProcessOptions();
     }
 }
@@ -567,12 +560,17 @@
 
     &verbose(9, "splitting from args: $args\n");
     @argv = ();
+    sub evaluate {
+        my ($string) = @_;
+        $string =~ s/\\//g;
+        return $string;
+    }
     while ($args) {
-        redo if $args =~ s|^\s*(-[a-zA-Z0-9]\S+)|push(@argv, $1), ''|iges;
-        redo if $args =~ s|^\s*(-[a-zA-Z0-9])|push(@argv, $1), ''|iges;
-        redo if $args =~ s|^\s*"([^"]*)"|push(@argv, $1), ''|iges;
-        redo if $args =~ s|^\s*'([^']*)'|push(@argv, $1), ''|iges;
-        redo if $args =~ s|^\s*(\S+)|push(@argv, $1), ''|iges;
+        redo if $args =~ s|^\s*(-[a-zA-Z0-9]\S+)|push(@argv, &evaluate($1)), ''|iges;
+        redo if $args =~ s|^\s*(-[a-zA-Z0-9])|push(@argv, &evaluate($1)), ''|iges;
+        redo if $args =~ s|^\s*"(.*?(?!\\).)"|push(@argv, &evaluate($1)), ''|iges;
+        redo if $args =~ s|^\s*'([^']*)'|push(@argv, &evaluate($1)), ''|iges;
+        redo if $args =~ s|^\s*(\S+)|push(@argv, &evaluate($1)), ''|iges;
         redo if $args =~ s|^\s+$|''|iges;
     }
     &verbose(9, "splitting to argv: ".join("|", @argv)."\n");
@@ -951,14 +949,15 @@
 }
 
 $defipp = '';
+my $dummy;
 foreach $d (@opt_D) {
-    ($var, $val) = ($d =~ m|^(.+?)="?(.*?)"?$|);
+    ($var, $dummy, $val) = ($d =~ m|^(.+?)=("?)(.*)\2\n*$|);
     $defipp .= " \"-D$var=$val\"";
 }
 $defipp .= " -M$opt_M" if $opt_M ne '-';
 $defmhtml = '';
 foreach $d (@opt_D) {
-    ($var, $val) = ($d =~ m|^(.+?)="?(.*?)"?$|);
+    ($var, $dummy, $val) = ($d =~ m|^(.+?)=("?)(.*)\2\n*$|);
     $defmhtml .= " --set \"$var\" \"$val\"";
 }
 $cnt=0;
@@ -968,12 +967,12 @@
 }
 $defeperl = '';
 foreach $d (@opt_D) {
-    ($var, $val) = ($d =~ m|^(.+?)="?(.*?)"?$|);
+    ($var, $dummy, $val) = ($d =~ m|^(.+?)=("?)(.*)\2\n*$|);
     $defeperl .= " \"-d$var=$val\"";
 }
 $defgm4 = '';
 foreach $d (@opt_D) {
-    ($var, $val) = ($d =~ m|^(.+?)="?(.*?)"?$|);
+    ($var, $dummy, $val) = ($d =~ m|^(.+?)=("?)(.*)\2\n*$|);
     $defgm4 .= " \"-Dm4_$var=$val\"";
 }
 
--- wml_backend/p1_ipp/ipp.src	1999/06/28 10:18:03	1.14
+++ wml_backend/p1_ipp/ipp.src	1999/06/30 21:40:08
@@ -448,7 +448,7 @@
 #
 %arg = ();
 foreach $str (@opt_D) {
-    if ($str =~ m|^([a-zA-Z][a-zA-Z0-9_]*)="([^"]*)"$|) {
+    if ($str =~ m|^([a-zA-Z][a-zA-Z0-9_]*)="(.*)"$|) {
         $arg{$1} = $2;
     }
     elsif ($str =~ m|^([a-zA-Z][a-zA-Z0-9_]*)=(['"]['"])?$|) {



______________________________________________________________________
Website META Language (WML)                www.engelschall.com/sw/wml/
Official Support Mailing List                   sw-wml@engelschall.com
Automated List Manager                       majordomo@engelschall.com