]> git.sur5r.net Git - i3/i3/blobdiff - generate-command-parser.pl
Bugfix: Properly parse commands like “move workspace torrent” (Thanks rasi)
[i3/i3] / generate-command-parser.pl
index f69f715e569594f479d1458493f5d935cbaebfcf..b76d5e5512f8215ffec637103c8c9686c7dc97ef 100755 (executable)
@@ -84,14 +84,14 @@ for my $line (@lines) {
         # Cleanup the identifier (if any).
         $identifier =~ s/^\s*(\S+)\s*=\s*$/$1/g;
 
-        # Cleanup the tokens (remove whitespace).
-        $tokens =~ s/\s*//g;
-
         # The default action is to stay in the current state.
         $action = $current_state if length($action) == 0;
 
         #say "identifier = *$identifier*, token = *$tokens*, action = *$action*";
         for my $token (split(',', $tokens)) {
+            # Cleanup trailing/leading whitespace.
+            $token =~ s/^\s*//g;
+            $token =~ s/\s*$//g;
             my $store_token = {
                 token => $token,
                 identifier => $identifier,
@@ -158,7 +158,6 @@ for my $state (@keys) {
         $fmt =~ s/$_/%d/g for @keys;
         $fmt =~ s/\$([a-z_]+)/%s/g;
         $fmt =~ s/\&([a-z_]+)/%ld/g;
-        $fmt =~ s/NULL/%s/g;
         $fmt =~ s/"([a-z0-9_]+)"/%s/g;
         $fmt =~ s/(?:-?|\b)[0-9]+\b/%d/g;
 
@@ -177,6 +176,7 @@ for my $state (@keys) {
         $cmd =~ s/[^(]+\(//;
         $cmd =~ s/\)$//;
         $cmd = ", $cmd" if length($cmd) > 0;
+        $cmd =~ s/, NULL//g;
         say $callfh qq|           fprintf(stderr, "$fmt\\n"$cmd);|;
         # The cfg_criteria functions have side-effects which are important for
         # testing. They are implemented as stubs in the test parser code.
@@ -193,7 +193,6 @@ say $callfh '        default:';
 say $callfh '            printf("BUG in the parser. state = %d\n", call_identifier);';
 say $callfh '            assert(false);';
 say $callfh '    }';
-say $callfh '    state = result->next_state;';
 say $callfh '}';
 close($callfh);