#define DEBUG_FILE "debug.txt"
-#define MAX_ATTRIBUTE_CHARS (5 * 2)
+#define MAX_ATTRIBUTE_CHARS (6 * 2)
-#define VERSION "0.61"
+#define VERSION "0.62"
typedef enum { false, true } bool;
}
}
if (!valid_attr)
- vfprintf_fail (formats[FMT_GENERIC], "--attr switch must be provided valid attribute names");
+ {
+ char *attr_invalid = xmalloc ((p - s) + 1);
+ STACK_VAR (attr_invalid);
+ strncpy (attr_invalid, s, p - s);
+ attr_invalid[p - s] = '\0';
+ vfprintf_fail ("--attr switch attribute '%s' is not valid", attr_invalid);
+ RELEASE_VAR (attr_invalid); /* never reached */
+ }
}
if (*p)
p++;
const char *short_opt = NULL;
unsigned int i;
for (i = 0; i < sizeof (short_opts) / sizeof (struct short_opt); i++)
- {
- if (streq (opt->name, short_opts[i].name))
- {
- short_opt = short_opts[i].short_opt;
- break;
- }
- }
+ if (streq (opt->name, short_opts[i].name))
+ {
+ short_opt = short_opts[i].short_opt;
+ break;
+ }
if (short_opt)
printf ("\t\t-%s, --%s\n", short_opt, opt->name);
else
#endif
const char *version_prefix, *version_string;
const char *c_flags, *ld_flags, *cpp_flags;
+ const char *const desc_flags_unknown = "unknown";
struct bytes_size bytes_size;
bool debug;
#ifdef CFLAGS
c_flags = to_str (CFLAGS);
#else
- c_flags = "unknown";
+ c_flags = desc_flags_unknown;
#endif
#ifdef LDFLAGS
ld_flags = to_str (LDFLAGS);
#else
- ld_flags = "unknown";
+ ld_flags = desc_flags_unknown;
#endif
#ifdef CPPFLAGS
cpp_flags = to_str (CPPFLAGS);
#else
- cpp_flags = "unknown";
+ cpp_flags = desc_flags_unknown;
#endif
#if DEBUG
debug = true;
const char *color_string = arg_cnt >= 1 ? arg_strings[0] : NULL;
const char *file_string = arg_cnt == 2 ? arg_strings[1] : NULL;
- assert (color_string);
+ assert (color_string != NULL);
if (streq (color_string, "-"))
{
gather_color_names (color_string, attr, color_names);
- assert (color_names[FOREGROUND]);
+ assert (color_names[FOREGROUND] != NULL);
if (color_names[BACKGROUND])
{
}
find_color_entries (color_names, colors);
+ assert (colors[FOREGROUND] != NULL);
free_color_names (color_names);
if (!colors[FOREGROUND]->code && colors[BACKGROUND] && colors[BACKGROUND]->code)
*file = "stdin";
}
- assert (*stream);
- assert (*file);
+ assert (*stream != NULL);
+ assert (*file != NULL);
}
static void
}
else
p = color + strlen (color);
- assert (p);
+ assert (p != NULL);
for (ch = color; *ch; ch++)
if (!isalpha (*ch))