Changeset 1fe7324 in rtems


Ignore:
Timestamp:
Mar 11, 2010, 3:35:24 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
7209b4c5
Parents:
355a836
Message:

2010-03-11 Andrei Mozzhuhin <nopscmn@…>

PR 1496/shell

  • libmisc/shell/shell_makeargs.c: Add support for quoted arguments.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r355a836 r1fe7324  
     12010-03-11      Andrei Mozzhuhin <nopscmn@gmail.com>
     2
     3        PR 1496/shell
     4        * libmisc/shell/shell_makeargs.c: Add support for quoted arguments.
     5
    162010-03-10      Joel Sherrill <joel.sherrill@oarcorp.com>
    27
  • cpukit/libmisc/shell/shell_makeargs.c

    r355a836 r1fe7324  
    2626{
    2727  int   argc;
    28   char *command;
     28  char *ch;
    2929  int   status = 0;
     30 
     31  argc = 0;
     32  ch = commandLine;
    3033
    31   argc = 0;
    32   command = commandLine;
     34  while ( *ch ) {
    3335
    34   while ( 1 ) {
    35     command = strtok( command, " \t\r\n" );
    36     if ( command == NULL )
     36    while ( isspace(*ch) ) ch++;
     37
     38    if ( *ch == '\0' )
    3739      break;
    38     argv_p[ argc++ ] = command;
    39     command = '\0';
     40
     41    if ( *ch == '"' ) {
     42      argv_p[ argc++ ] = ++ch;
     43      while ( ( *ch == '\0' ) && ( *ch != '"' ) ) ch++;
     44    } else {
     45      argv_p[ argc++ ] = ch;
     46      while ( ( *ch == '\0' ) && ( !isspace(*ch) ) ) ch++;
     47    }
     48
     49    if ( *ch == '\0' )
     50      break;
     51
     52    *ch++ = '\0';
     53
    4054    if ( argc == (max_args-1) ) {
    41       status = -1;
    42       break;
     55        status = -1;
     56        break;
    4357    }
     58
     59
    4460  }
    4561  argv_p[ argc ] = NULL;
Note: See TracChangeset for help on using the changeset viewer.