GitHub PullRequestReviewCommentEvent at 2014-02-22 09:00:33
Repository: RIOT
Actor: LudwigOrtmann
Payload: {"comment":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments/9970609","id":9970609,"diff_hunk":"@@ -90,25 +90,74 @@ static void print_help(const shell_command_t *command_list)\n \n static void handle_input_line(shell_t *shell, char *line)\n {\n-    char *saveptr;\n-    char *command = strtok_r(line, \" \", &saveptr);\n+    static const char *INCORRECT_QUOTING = \"shell: incorrect quoting\";\n+\n+    /* first we need to calculate the number of arguments */\n+    unsigned argc = 0;\n+    char *pos;\n+    for (pos = line; *pos; ++pos) {\n+        if (*pos <= ' ') {\n+            *pos = 0;\n+            continue;\n+        }\n+        else if (*pos == '\"') {\n+            do {\n+                ++pos;\n+                if (!*pos) {\n+                    puts(INCORRECT_QUOTING);\n+                    return;\n+                }\n+            } while (*pos != '\"');\n+            if (pos[1] > ' ') {\n+                puts(INCORRECT_QUOTING);\n+                return;\n+            }\n+        }\n+        else {\n+            do {\n+                ++pos;\n+                if (*pos == '\"') {\n+                    puts(INCORRECT_QUOTING);\n+                    return;\n+                }\n+            } while (*pos > ' ');\n+        }\n+        ++argc;\n+        *pos = 0;\n+    }\n \n-    void (*handler)(char *) = NULL;\n+    if (!argc) {\n+        return;\n+    }\n \n-    if (command) {\n-        handler = find_handler(shell->command_list, command);\n+    /* then we fill the argv array */\n+    char *argv[argc + 1];\n+    argv[argc] = NULL;\n+    pos = line;\n+    for (unsigned i = 0; i < argc; ++i) {\n+        while (!*pos) {\n+            ++pos;\n+        }\n+        if (*pos == '\"') {\n+            ++pos;\n+        }\n+        argv[i] = pos;\n+        while (*pos) {\n+            ++pos;\n+        }\n+    }\n \n-        if (handler != NULL) {\n-            line[strlen(command)] = ' ';\n-            handler(line);\n+    /* then we call the appropriate handler */\n+    shell_command_handler_t handler = handler = find_handler(shell->command_list, argv[0]);","path":"sys/shell/shell.c","position":79,"original_position":79,"commit_id":"0c5766da74c8ec43e261e1f4930afa6feac8fdcf","original_commit_id":"0c5766da74c8ec43e261e1f4930afa6feac8fdcf","user":{"login":"LudwigOrtmann","id":3739173,"avatar_url":"https://gravatar.com/avatar/fba9545bea0c863ebdd89284f23c5dad?d=https%3A%2F%2Fidenticons.github.com%2F129f2bc349a7629c5587be0c54ab282d.png&r=x","gravatar_id":"fba9545bea0c863ebdd89284f23c5dad","url":"https://api.github.com/users/LudwigOrtmann","html_url":"https://github.com/LudwigOrtmann","followers_url":"https://api.github.com/users/LudwigOrtmann/followers","following_url":"https://api.github.com/users/LudwigOrtmann/following{/other_user}","gists_url":"https://api.github.com/users/LudwigOrtmann/gists{/gist_id}","starred_url":"https://api.github.com/users/LudwigOrtmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LudwigOrtmann/subscriptions","organizations_url":"https://api.github.com/users/LudwigOrtmann/orgs","repos_url":"https://api.github.com/users/LudwigOrtmann/repos","events_url":"https://api.github.com/users/LudwigOrtmann/events{/privacy}","received_events_url":"https://api.github.com/users/LudwigOrtmann/received_events","type":"User","site_admin":false},"body":"The comment does not match the line that immediately follows it?","created_at":"2014-02-22T09:00:33Z","updated_at":"2014-02-22T09:00:33Z","html_url":"https://github.com/RIOT-OS/RIOT/pull/760#discussion_r9970609","pull_request_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/760","_links":{"self":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments/9970609"},"html":{"href":"https://github.com/RIOT-OS/RIOT/pull/760#discussion_r9970609"},"pull_request":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/760"}}}}