]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Correct string/quoted string parsing for the commands exec, workspace, nop...
authorMichael Stapelberg <michael@stapelberg.de>
Thu, 12 May 2011 05:09:06 +0000 (07:09 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Thu, 12 May 2011 05:09:06 +0000 (07:09 +0200)
Fixes: #380
src/cmdparse.l
testcases/t/20-multiple-cmds.t

index ebd466afa795061a7fe80ddcb93f0d6bb476e3e4..f07420d3e9d34b254adcf337773354e6729b71e9 100644 (file)
@@ -65,16 +65,16 @@ EOL (\r?\n)
     cmdyycolumn = 1;
 }
 
-<WANT_STRING>[^\n]+             { BEGIN(INITIAL); cmdyylval.string = sstrdup(yytext); return STR; }
 <WANT_WS_STRING>[ \t]*          { BEGIN(WANT_STRING); return WHITESPACE; }
-<WANT_QSTRING>\"[^\"]+\"        {
+<WANT_STRING>\"[^\"]+\"         {
                                   BEGIN(INITIAL);
                                   /* strip quotes */
                                   char *copy = sstrdup(yytext+1);
                                   copy[strlen(copy)-1] = '\0';
                                   cmdyylval.string = copy;
                                   return STR;
-                                }
+                                 }
+<WANT_STRING>[^;\n]+             { BEGIN(INITIAL); cmdyylval.string = sstrdup(yytext); return STR; }
 
 [ \t]*                          { return WHITESPACE; }
 attach                          { return TOK_ATTACH; }
index 379d08ee496208e076db279240a5ab300d2e86b7..784329fbe2a82b80667b5109e5bcd25f63cfdefe 100644 (file)
@@ -30,6 +30,27 @@ multiple_cmds("kill\t ;\tkill");
 multiple_cmds("kill\t ;\t kill");
 multiple_cmds("kill \t ; \t kill");
 
+#####################################################################
+# test if un-quoted strings are handled correctly
+#####################################################################
+
+$tmp = fresh_workspace;
+cmd 'open';
+my $unused = get_unused_workspace;
+ok(!($unused ~~ @{get_workspace_names()}), 'workspace does not exist yet');
+cmd "move workspace $unused; nop parser test";
+ok(($unused ~~ @{get_workspace_names()}), 'workspace exists after moving');
+
+#####################################################################
+# quote the workspace name and use a ; (command separator) in its name
+#####################################################################
+
+$unused = get_unused_workspace;
+$unused .= ';a';
+ok(!($unused ~~ @{get_workspace_names()}), 'workspace does not exist yet');
+cmd qq|move workspace "$unused"; nop parser test|;
+ok(($unused ~~ @{get_workspace_names()}), 'workspace exists after moving');
+
 # TODO: need a non-invasive command before implementing a test which uses ','
 
 done_testing;