From: wdenk Date: Wed, 1 Nov 2000 10:49:44 +0000 (+0000) Subject: Allow to use '\' to escape control characters (';' and '$') while X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d93c1ec91ab69773773f74a212317abcd6000577;p=users%2Frw%2Fppcboot.git Allow to use '\' to escape control characters (';' and '$') while parsing input - needed to be able to enter a `bootcmd' which contains more than one command and/or references to variables. --- diff --git a/CHANGELOG b/CHANGELOG index 345c2b0..0909c4e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -56,6 +56,11 @@ To do: Modifications since 0.6.0: ====================================================================== +* Allow to use '\' to escape control characters (';' and '$') while + parsing input - needed to be able to enter a `bootcmd' which + contains more than one command and/or references to variables, + which are resolved not before when running the command. + * MBX8xx support (thanks to Marius Gröger) * Fix violation of BOOTP message format. diff --git a/README b/README index 821f4fb..a1f77fc 100644 --- a/README +++ b/README @@ -76,6 +76,7 @@ Directory Hierarchy: - cogent Files specific to Cogent boards (need further configuration) - fads Files specific to Motorola FADS boards +- mbx8xx Files specific to Motorola MBX boards Software Configuration: @@ -139,9 +140,9 @@ The following options need to be configured: CONFIG_TQM823L, CONFIG_TQM850L, CONFIG_TQM855L, CONFIG_TQM860L, CONFIG_ETX094, CONFIG_ADCIOP, CONFIG_CPCI405, CONFIG_COGENT, CONFIG_FADS, - CONFIG_SPD823TS,CONFIG_FPS850L + CONFIG_SPD823TS,CONFIG_FPS850L, CONFIG_MBX --- FIXME --- not tested yet: - CONFIG_TQM860, CONFIG_MBX, CONFIG_ADS, + CONFIG_TQM860, CONFIG_ADS, CONFIG_RPXLITE, CONFIG_RPXCLASSIC, CONFIG_BSEIP @@ -379,6 +380,7 @@ configurations; the following names are suported: FADS850SAR_config SPD823TS_config cogent_mpc8xx_config + MBX_config If the system board that you have is not listed, then you will need diff --git a/common/main.c b/common/main.c index 53ae690..b7ac76c 100644 --- a/common/main.c +++ b/common/main.c @@ -253,7 +253,7 @@ int parse_line (char *line, char *argv[]) static void process_macros (char *input, char *output) { - char c, *varname_start; + char c, prev, *varname_start; int inputcnt = strlen (input); int outputcnt = CFG_CBSIZE; int state = 0; /* 0 = waiting for '$' */ @@ -266,13 +266,23 @@ static void process_macros (char *input, char *output) printf ("[PROCESS_MACROS] INPUT=%s\n", input); #endif + prev = '\0'; /* previous character */ + while (inputcnt && outputcnt) { c = *input++; inputcnt--; + /* remove one level of escape characters */ + if ((c == '\\') && (prev != '\\')) { + if (inputcnt-- == 0) + break; + prev = c; + c = *input++; + } + switch (state) { - case 0: /* Waiting for $ */ - if (c == '$') { + case 0: /* Waiting for (unescaped) $ */ + if ((c == '$') && (prev != '\\')) { state++; } else { *(output++) = c; @@ -320,6 +330,8 @@ static void process_macros (char *input, char *output) } break; } + + prev = c; } if (outputcnt) @@ -353,19 +365,29 @@ static int process_separators (char *s, int len, char *sep; char *t; - /* find separator, or string end */ + /* + * Find separator, or string end + * Allow simple escape of ';' by writing "\;" + */ for (sep = str; *sep; sep++) { - if (*sep == ';') + if ((*sep == ';') && /* separator */ + ( sep != str) && /* past string start */ + (*(sep-1) != '\\')) /* and NOT escaped */ break; } - /* extract the token between separators */ + /* + * Extract the token between separators + */ for (t = token; str < sep;) { *t++ = *str++; if (t >= token + CFG_CBSIZE - 1) break; /* just in case */ } *t = '\0'; +#ifdef DEBUG_PARSER + printf ("token: \"%s\"\n", token); +#endif /* Process macros into this token and replace them */ process_macros (token, finaltoken); diff --git a/include/config_TQM850L.h b/include/config_TQM850L.h index 3a07464..35a2684 100644 --- a/include/config_TQM850L.h +++ b/include/config_TQM850L.h @@ -49,7 +49,7 @@ #undef CONFIG_BOOTARGS #define CONFIG_BOOTCOMMAND \ "bootp; " \ - "setenv bootargs root=/dev/nfs nfsroot=$(serverip):$(rootpath) " \ + "setenv bootargs root=/dev/nfs rw nfsroot=$(serverip):$(rootpath) " \ "ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off; " \ "bootm"