Changeset 6939edb in mainline for uspace/app/bdsh/input.c


Ignore:
Timestamp:
2011-06-11T19:40:17Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
28ee877e
Parents:
659e9473
Message:

Add more powerful tokenizer to bdsh

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/input.c

    r659e9473 r6939edb  
    5050#include "errors.h"
    5151#include "exec.h"
     52#include "tok.h"
    5253
    5354extern volatile unsigned int cli_quit;
     
    5657static tinput_t *tinput;
    5758
     59/* Private helpers */
    5860static int run_command(char **, cliuser_t *);
    5961
     
    6466{
    6567        char *cmd[WORD_MAX];
    66         int n = 0;
    6768        int rc = 0;
    68         char *tmp;
     69        tokenizer_t tok;
    6970
    7071        if (NULL == usr->line)
    7172                return CL_EFAIL;
    7273
    73         tmp = str_dup(usr->line);
    74 
    75         cmd[n] = strtok(tmp, " ");
    76         while (cmd[n] && n < WORD_MAX) {
    77                 cmd[++n] = strtok(NULL, " ");
     74        rc = tok_init(&tok, usr->line, cmd, WORD_MAX);
     75        if (rc != EOK) {
     76                goto finit;
    7877        }
    79 
     78       
     79        rc = tok_tokenize(&tok);
     80        if (rc != EOK) {
     81                goto finit;
     82        }
     83       
    8084        rc = run_command(cmd, usr);
    81 
     85       
     86finit:
    8287        if (NULL != usr->line) {
    8388                free(usr->line);
    8489                usr->line = (char *) NULL;
    8590        }
    86         if (NULL != tmp)
    87                 free(tmp);
     91        tok_fini(&tok);
    8892
    8993        return rc;
Note: See TracChangeset for help on using the changeset viewer.