Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/modutils/modutils.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/modutils/modutils.c
r2725 r3232 63 63 } 64 64 65 char* FAST_FUNC parse_cmdline_module_options(char **argv )65 char* FAST_FUNC parse_cmdline_module_options(char **argv, int quote_spaces) 66 66 { 67 67 char *options; … … 71 71 optlen = 0; 72 72 while (*++argv) { 73 options = xrealloc(options, optlen + 2 + strlen(*argv) + 2); 74 /* Spaces handled by "" pairs, but no way of escaping quotes */ 75 //TODO: module-init-tools version 3.11.1 quotes only value: 76 //it generates var="val with spaces", not "var=val with spaces" 77 //(and it won't quote var *name* even if it has spaces) 78 optlen += sprintf(options + optlen, (strchr(*argv, ' ') ? "\"%s\" " : "%s "), *argv); 79 } 73 const char *fmt; 74 const char *var; 75 const char *val; 76 77 var = *argv; 78 options = xrealloc(options, optlen + 2 + strlen(var) + 2); 79 fmt = "%.*s%s "; 80 val = strchrnul(var, '='); 81 if (quote_spaces) { 82 /* 83 * modprobe (module-init-tools version 3.11.1) compat: 84 * quote only value: 85 * var="val with spaces", not "var=val with spaces" 86 * (note: var *name* is not checked for spaces!) 87 */ 88 if (*val) { /* has var=val format. skip '=' */ 89 val++; 90 if (strchr(val, ' ')) 91 fmt = "%.*s\"%s\" "; 92 } 93 } 94 optlen += sprintf(options + optlen, fmt, (int)(val - var), var, val); 95 } 96 /* Remove trailing space. Disabled */ 97 /* if (optlen != 0) options[optlen-1] = '\0'; */ 80 98 return options; 81 99 }
Note:
See TracChangeset
for help on using the changeset viewer.