Parse " and \ escaping in binds
authorunc0rr
Mon, 13 Jan 2014 23:07:27 +0400
changeset 9981 94f5e5cd151b
parent 9979 710e0f92c2ab
child 9983 1b62d993cd2f
Parse " and \ escaping in binds
hedgewars/uInputHandler.pas
--- a/hedgewars/uInputHandler.pas	Mon Jan 13 19:34:39 2014 +0100
+++ b/hedgewars/uInputHandler.pas	Mon Jan 13 23:07:27 2014 +0400
@@ -486,16 +486,17 @@
             i:= 1;
             while (i <= length(l)) and (l[i] <> '=') do
                 begin
-                if l[i] <> '%' then
-                    begin
-                    p:= p + l[i];
-                    inc(i)
-                    end else
+                if l[i] = '%' then
                     begin
                     l[i]:= '$';
                     val(copy(l, i, 3), b);
                     p:= p + char(b);
                     inc(i, 3)
+                    end 
+                else
+                    begin
+                    p:= p + l[i];
+                    inc(i)
                     end;
                 end;
 
@@ -504,6 +505,11 @@
                 l:= copy(l, i + 1, length(l) - i);
                 if l <> 'default' then
                     begin
+                    if (length(l) = 2) and (l[1] = '\') then 
+                        l:= l[1]
+                    else if (l[1] = '"') and (l[length(l)] = '"') then
+                        l:= copy(l, 2, length(l) - 2);
+
                     p:= cmd + ' ' + l + ' ' + p;
                     ParseCommand(p, true)
                     end