aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--colorize.c31
2 files changed, 15 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index b786e05..33b66a7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: check check_valgrind install clean release
+.PHONY: check check_valgrind install clean release readme
.SUFFIXES:
.SUFFIXES: .c .o
diff --git a/colorize.c b/colorize.c
index 9a6a6f9..a1e1398 100644
--- a/colorize.c
+++ b/colorize.c
@@ -359,8 +359,6 @@ static void vfprintf_fail (const char *, ...);
static void stack (struct var_list **, unsigned int *, unsigned int, void *, enum var_type);
static void release (struct var_list *, unsigned int, void **);
-extern int optind;
-
int
main (int argc, char **argv)
{
@@ -455,7 +453,7 @@ main (int argc, char **argv)
{
if (arg_cnt == 0 || arg_cnt > 2)
{
- vfprintf_diag ("%u arguments provided, expected 1-2 arguments or clean option", arg_cnt);
+ vfprintf_diag ("%u arguments provided, expected 1-2 arguments or --clean[-all]", arg_cnt);
print_hint ();
exit (EXIT_FAILURE);
}
@@ -513,8 +511,6 @@ print_tstamp (FILE *log)
print_version (); \
exit (EXIT_SUCCESS);
-extern char *optarg;
-
static void
process_opts (int argc, char **argv, char **conf_file)
{
@@ -588,6 +584,7 @@ conf_file_path (char **conf_file)
perror ("getpwuid");
exit (EXIT_FAILURE);
}
+ /* getpwuid() leaks memory */
size = strlen (passwd->pw_dir) + 1 + strlen (CONF_FILE) + 1;
path = xmalloc (size);
snprintf (path, size, "%s/%s", passwd->pw_dir, CONF_FILE);
@@ -613,10 +610,10 @@ process_opt_attr (const char *p, const bool is_opt)
while (*p)
{
const char *s;
- if (!isalnum (*p))
+ if (!isalnum ((unsigned char)*p))
vfprintf_fail ("%s must be provided a string", desc_type[DESC_TYPE]);
s = p;
- while (isalnum (*p))
+ while (isalnum ((unsigned char)*p))
p++;
if (*p != '\0' && *p != ',')
vfprintf_fail ("%s must have strings separated by ,", desc_type[DESC_TYPE]);
@@ -751,7 +748,7 @@ parse_conf (const char *conf_file, struct conf *config)
/* NAME PARSING (end) */
/* NAME VALIDATION (start) */
for (p = opt; *p; p++)
- if (!isalnum (*p) && *p != '-')
+ if (!isalnum ((unsigned char)*p) && *p != '-')
vfprintf_fail (formats[FMT_CONF], conf_file, opt, "cannot be made of non-option characters");
/* NAME VALIDATION (end) */
/* VALUE PARSING (start) */
@@ -858,7 +855,7 @@ print_help (void)
const char *code = entry->code;
if (code)
printf ("\t\t{\033[%s#\033[0m} [%c%c]%s%*s%s\n",
- code, toupper (*name), *name, name + 1, 10 - (int)strlen (name), " ", name);
+ code, toupper ((unsigned char)*name), *name, name + 1, 10 - (int)strlen (name), " ", name);
else
printf ("\t\t{-} %s%*s%s\n", name, 13 - (int)strlen (name), " ", name);
}
@@ -1206,17 +1203,17 @@ gather_color_names (const char *color_string, char *attr, struct color_name **co
assert (p != NULL);
for (ch = color; *ch; ch++)
- if (!isalpha (*ch))
+ if (!isalpha ((unsigned char)*ch))
vfprintf_fail (formats[FMT_COLOR], tables[index].desc, color, "cannot be made of non-alphabetic characters");
for (ch = color + 1; *ch; ch++)
- if (!islower (*ch))
+ if (!islower ((unsigned char)*ch))
vfprintf_fail (formats[FMT_COLOR], tables[index].desc, color, "cannot be in mixed lower/upper case");
if (streq (color, "None"))
vfprintf_fail (formats[FMT_COLOR], tables[index].desc, color, "cannot be bold");
- if (isupper (*color))
+ if (isupper ((unsigned char)*color))
{
switch (index)
{
@@ -1238,7 +1235,7 @@ gather_color_names (const char *color_string, char *attr, struct color_name **co
STACK_VAR (color_names[index]->orig);
for (ch = color; *ch; ch++)
- *ch = tolower (*ch);
+ *ch = tolower ((unsigned char)*ch);
color_names[index]->name = xstrdup (color);
STACK_VAR (color_names[index]->name);
@@ -1604,10 +1601,10 @@ gather_esc_offsets (const char *p, const char **start, const char **end)
do {
check_values = false;
iter++;
- if (!isdigit (*p))
+ if (!isdigit ((unsigned char)*p))
break;
digit = p;
- while (isdigit (*p))
+ while (isdigit ((unsigned char)*p))
p++;
if (p - digit > 2)
break;
@@ -1640,7 +1637,7 @@ gather_esc_offsets (const char *p, const char **start, const char **end)
static bool
validate_esc_clean_all (const char **p)
{
- while (isdigit (**p) || **p == ';')
+ while (isdigit ((unsigned char)**p) || **p == ';')
(*p)++;
return (**p == 'm');
}
@@ -1848,7 +1845,7 @@ has_color_name (const char *str, const char *name)
assert (strlen (str) > 0);
assert (strlen (name) > 0);
- if (!(*str == *name || *str == toupper (*name)))
+ if (!(*str == *name || *str == toupper ((unsigned char)*name)))
return false;
else if (*(name + 1) != '\0'
&& !((p = strstr (str + 1, name + 1)) && p == str + 1))