]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Patch by Detlev Zundel, 30 Dec 2002:
authorwdenk <wdenk>
Thu, 2 Jan 2003 23:57:29 +0000 (23:57 +0000)
committerwdenk <wdenk>
Thu, 2 Jan 2003 23:57:29 +0000 (23:57 +0000)
Add single quote support for (old) command line parser

CHANGELOG
common/main.c

index 13ee632ad0afab1126e68340a6a9deb2c5ccf432..e16565423e131ba644823f50c286e0467b482ae0 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,8 @@
 Changes since U-Boot 0.2.0:
 ======================================================================
 
+* Add single quote support for (old) command line parser
+
 * Switch LWMON board default config from FRAM to EEPROM;
   in POST, EEPROM shows up on 8 addresses
 
index 3e92649ced3a981f932166b22899b7cab45971c0..401efcf854636ae53bff86c2a50e92a61af4bef2 100644 (file)
@@ -613,7 +613,7 @@ static void process_macros (const char *input, char *output)
        int state = 0;  /* 0 = waiting for '$'  */
                        /* 1 = waiting for '('  */
                        /* 2 = waiting for ')'  */
-
+                       /* 3 = waiting for '''  */
 #ifdef DEBUG_PARSER
        char *output_start = output;
 
@@ -626,6 +626,7 @@ static void process_macros (const char *input, char *output)
            c = *input++;
            inputcnt--;
 
+           if (state!=3) {
            /* remove one level of escape characters */
            if ((c == '\\') && (prev != '\\')) {
                if (inputcnt-- == 0)
@@ -633,9 +634,16 @@ static void process_macros (const char *input, char *output)
                prev = c;
                c = *input++;
            }
+           }
 
            switch (state) {
            case 0:                     /* Waiting for (unescaped) $    */
+               if ((c == '\'') && (prev != '\\')) {
+                       state = 3;
+                       if (inputcnt)
+                               inputcnt--;
+                       break;
+               }
                if ((c == '$') && (prev != '\\')) {
                        state++;
                } else {
@@ -683,8 +691,17 @@ static void process_macros (const char *input, char *output)
                        state = 0;
                }
                break;
+           case 3:                     /* Waiting for '        */
+               if ((c == '\'') && (prev != '\\')) {
+                       state = 0;
+                       if (inputcnt)
+                               inputcnt--;
+               } else {
+                       *(output++) = c;
+                       outputcnt--;
+               }
+               break;
            }
-
            prev = c;
        }
 
@@ -725,6 +742,7 @@ int run_command (const char *cmd, int flag)
        char *argv[CFG_MAXARGS + 1];    /* NULL terminated      */
        int argc;
        int repeatable = 1;
+       int inquotes;
 
 #ifdef DEBUG_PARSER
        printf ("[RUN_COMMAND] cmd[%p]=\"", cmd);
@@ -758,8 +776,13 @@ int run_command (const char *cmd, int flag)
                 * Find separator, or string end
                 * Allow simple escape of ';' by writing "\;"
                 */
-               for (sep = str; *sep; sep++) {
-                       if ((*sep == ';') &&    /* separator            */
+               for (inquotes = 0, sep = str; *sep; sep++) {
+                       if ((*sep=='\'') &&
+                           (*(sep-1) != '\\'))
+                               inquotes=!inquotes;
+
+                       if (!inquotes &&
+                           (*sep == ';') &&    /* separator            */
                            ( sep != str) &&    /* past string start    */
                            (*(sep-1) != '\\')) /* and NOT escaped      */
                                break;