X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Foptions.c;h=a212d1c63ee5190c752a7a007087df6338c47087;hb=cb08510bbbab7646bc1031427243489024d22a3b;hp=8d15d1cc4a7162b57b034443c46eb44d266b4ab5;hpb=b4410895ac55fd413a146e95fc75e7c4ade380b5;p=pspp diff --git a/src/output/options.c b/src/output/options.c index 8d15d1cc4a..a212d1c63e 100644 --- a/src/output/options.c +++ b/src/output/options.c @@ -51,8 +51,8 @@ driver_option_create (const char *driver_name, const char *name, struct driver_option *o = xmalloc (sizeof *o); o->driver_name = xstrdup (driver_name); o->name = xstrdup (name); - o->value = value != NULL ? xstrdup (value) : NULL; - o->default_value = default_value ? xstrdup (default_value) : NULL; + o->value = xstrdup_if_nonnull (value); + o->default_value = xstrdup_if_nonnull (default_value); return o; } @@ -516,7 +516,7 @@ lookup_color_name (const char *s) return -1; } -static bool +bool parse_color__ (const char *s, struct cell_color *color) { /* #rrrrggggbbbb */ @@ -607,20 +607,15 @@ parse_color__ (const char *s, struct cell_color *color) struct cell_color parse_color (struct driver_option *o) { + struct cell_color color = CELL_COLOR_BLACK; + parse_color__ (o->default_value, &color); if (o->value) { - struct cell_color color; - if (parse_color__ (o->value, &color)) - return color; - - msg (MW, _("%s: `%s' is `%s', which could not be parsed as a color"), - o->driver_name, o->name, o->value); + if (!parse_color__ (o->value, &color)) + msg (MW, _("%s: `%s' is `%s', which could not be parsed as a color"), + o->driver_name, o->name, o->value); } - - struct cell_color color; - if (parse_color__ (o->default_value, &color)) - return color; - - return (struct cell_color) CELL_COLOR_BLACK; + driver_option_destroy (o); + return color; }