#include "system.h"
+#include "poptint.h"
+
#define POPT_ARGV_ARRAY_GROW_DELTA 5
/*@-boundswrite@*/
if (*src != quote) *buf++ = '\\';
}
*buf++ = *src;
- } else if (isspace(*src)) {
+ } else if (isSpace(src)) {
if (*argv[argc] != '\0') {
buf++, argc++;
if (argc == argvAlloced) {
p = line;
/* loop until first non-space char or EOL */
- while( *p != '\0' && isspace(*p) )
+ while( *p != '\0' && isSpace(p) )
p++;
linelen = strlen(p);
- if (linelen >= maxlinelen-1)
+ if (linelen >= maxlinelen-1) {
+ free(argstr);
return POPT_ERROR_OVERFLOW; /* XXX line too long */
+ }
if (*p == '\0' || *p == '\n') continue; /* line is empty */
if (*p == '#') continue; /* comment line */
q = p;
- while (*q != '\0' && (!isspace(*q)) && *q != '=')
+ while (*q != '\0' && (!isSpace(q)) && *q != '=')
q++;
- if (isspace(*q)) {
+ if (isSpace(q)) {
/* a space after the name, find next non space */
*q++='\0';
- while( *q != '\0' && isspace((int)*q) ) q++;
+ while( *q != '\0' && isSpace(q) ) q++;
}
if (*q == '\0') {
/* single command line option (ie, no name=val, just name) */
argstr = realloc(argstr, maxargvlen);
if (argstr == NULL) return POPT_ERROR_MALLOC;
}
- strcat(argstr, " --");
- strcat(argstr, p);
+ strlcat(argstr, " --", maxargvlen);
+ strlcat(argstr, p, maxargvlen);
continue;
}
if (*q != '=')
*q++ = '\0';
/* find next non-space letter of value */
- while (*q != '\0' && isspace(*q))
+ while (*q != '\0' && isSpace(q))
q++;
if (*q == '\0')
continue; /* XXX silently ignore missing value */
/* now, loop and strip all ending whitespace */
x = p + linelen;
- while (isspace(*--x))
+ while (isSpace(--x))
*x = 0; /* null out last char if space (including fgets() NL) */
/* rest of line accept */
argstr = realloc(argstr, maxargvlen);
if (argstr == NULL) return POPT_ERROR_MALLOC;
}
- strcat(argstr, " --");
- strcat(argstr, p);
- strcat(argstr, "=\"");
- strcat(argstr, q);
- strcat(argstr, "\"");
+ strlcat(argstr, " --", maxargvlen);
+ strlcat(argstr, p, maxargvlen);
+ strlcat(argstr, "=\"", maxargvlen);
+ strlcat(argstr, q, maxargvlen);
+ strlcat(argstr, "\"", maxargvlen);
}
*argstrp = argstr;