Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/modutils/modutils.c

    r2725 r3232  
    6363}
    6464
    65 char* FAST_FUNC parse_cmdline_module_options(char **argv)
     65char* FAST_FUNC parse_cmdline_module_options(char **argv, int quote_spaces)
    6666{
    6767    char *options;
     
    7171    optlen = 0;
    7272    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'; */
    8098    return options;
    8199}
Note: See TracChangeset for help on using the changeset viewer.