- rcfile.c:
parse_argument()
- Rename variable ptr_bak to ptr_save, for consistency. (DLR)
+ - Add quotes around invalid string arguments in error messages,
+ for consistency. (DLR)
parse_syntax()
- Don't generate an error if we find a duplicate syntax name,
since we might be trying to override a syntax in the global
nanorc with one in our local nanorc. Instead, free any
duplicate syntaxes we find, so that we always use the last
syntax with a given name. (DLR)
+ color_to_short()
+ - Add quotes around invalid string arguments in error messages,
+ for consistency. (DLR)
parse_colors()
- Check for a color command's not following a syntax line before
anything else. (DLR)
+ - Add quotes around invalid string arguments in error messages,
+ for consistency. (DLR)
parse_rcfile()
- Properly generate an error if we've read in a syntax without
any associated color commands. (DLR)
- Change variable i from an int to a size_t, for consistency.
(DLR)
- Properly handle rcfiles that don't end in newlines. (DLR)
+ - Add quotes around invalid string arguments in error messages,
+ for consistency. (DLR)
do_rcfile()
- Check for the rcfile's being a directory or device file and
reject it if it is, for consistency with file handling
ptr = NULL;
else
*ptr++ = '\0';
- rcfile_error(N_("Argument %s has unterminated \""), ptr_save);
+ rcfile_error(N_("Argument \"%s\" has unterminated \""), ptr_save);
} else {
*last_quote = '\0';
ptr = last_quote + 1;
}
#ifdef ENABLE_COLOR
-/* Return the short value corresponding to the color named in colorname,
- * and set bright to TRUE if that color is bright. */
-short color_to_short(const char *colorname, bool *bright)
-{
- short mcolor = -1;
-
- assert(colorname != NULL && bright != NULL);
-
- if (strncasecmp(colorname, "bright", 6) == 0) {
- *bright = TRUE;
- colorname += 6;
- }
-
- if (strcasecmp(colorname, "green") == 0)
- mcolor = COLOR_GREEN;
- else if (strcasecmp(colorname, "red") == 0)
- mcolor = COLOR_RED;
- else if (strcasecmp(colorname, "blue") == 0)
- mcolor = COLOR_BLUE;
- else if (strcasecmp(colorname, "white") == 0)
- mcolor = COLOR_WHITE;
- else if (strcasecmp(colorname, "yellow") == 0)
- mcolor = COLOR_YELLOW;
- else if (strcasecmp(colorname, "cyan") == 0)
- mcolor = COLOR_CYAN;
- else if (strcasecmp(colorname, "magenta") == 0)
- mcolor = COLOR_MAGENTA;
- else if (strcasecmp(colorname, "black") == 0)
- mcolor = COLOR_BLACK;
- else
- rcfile_error(N_("Color %s not understood.\n"
- "Valid colors are \"green\", \"red\", \"blue\",\n"
- "\"white\", \"yellow\", \"cyan\", \"magenta\" and\n"
- "\"black\", with the optional prefix \"bright\"\n"
- "for foreground colors."), colorname);
-
- return mcolor;
-}
-
/* Parse the next regex string from the line at ptr, and return it. */
char *parse_next_regex(char *ptr)
{
free(full_option);
}
+/* Return the short value corresponding to the color named in colorname,
+ * and set bright to TRUE if that color is bright. */
+short color_to_short(const char *colorname, bool *bright)
+{
+ short mcolor = -1;
+
+ assert(colorname != NULL && bright != NULL);
+
+ if (strncasecmp(colorname, "bright", 6) == 0) {
+ *bright = TRUE;
+ colorname += 6;
+ }
+
+ if (strcasecmp(colorname, "green") == 0)
+ mcolor = COLOR_GREEN;
+ else if (strcasecmp(colorname, "red") == 0)
+ mcolor = COLOR_RED;
+ else if (strcasecmp(colorname, "blue") == 0)
+ mcolor = COLOR_BLUE;
+ else if (strcasecmp(colorname, "white") == 0)
+ mcolor = COLOR_WHITE;
+ else if (strcasecmp(colorname, "yellow") == 0)
+ mcolor = COLOR_YELLOW;
+ else if (strcasecmp(colorname, "cyan") == 0)
+ mcolor = COLOR_CYAN;
+ else if (strcasecmp(colorname, "magenta") == 0)
+ mcolor = COLOR_MAGENTA;
+ else if (strcasecmp(colorname, "black") == 0)
+ mcolor = COLOR_BLACK;
+ else
+ rcfile_error(N_("Color \"%s\" not understood.\n"
+ "Valid colors are \"green\", \"red\", \"blue\",\n"
+ "\"white\", \"yellow\", \"cyan\", \"magenta\" and\n"
+ "\"black\", with the optional prefix \"bright\"\n"
+ "for foreground colors."), colorname);
+
+ return mcolor;
+}
+
/* Parse the color string in the line at ptr, and add it to the current
* file's associated colors. If icase is TRUE, treat the color string
* as case insensitive. */
}
if (strncasecmp(bgcolorname, "bright", 6) == 0) {
rcfile_error(
- N_("Background color %s cannot be bright"),
+ N_("Background color \"%s\" cannot be bright"),
bgcolorname);
return;
}
#ifdef ENABLE_COLOR
if (syntax_only)
rcfile_error(
- N_("Command %s not allowed in included file"),
+ N_("Command \"%s\" not allowed in included file"),
keyword);
else
#endif
#ifdef ENABLE_COLOR
if (syntax_only)
rcfile_error(
- N_("Command %s not allowed in included file"),
+ N_("Command \"%s\" not allowed in included file"),
keyword);
else
#endif
else if (strcasecmp(keyword, "include") == 0) {
if (syntax_only)
rcfile_error(
- N_("Command %s not allowed in included file"),
+ N_("Command \"%s\" not allowed in included file"),
keyword);
else
parse_include(ptr);
} else if (strcasecmp(keyword, "syntax") == 0) {
if (endsyntax != NULL && endcolor == NULL)
- rcfile_error(N_("Syntax %s has no color commands"),
+ rcfile_error(N_("Syntax \"%s\" has no color commands"),
endsyntax->desc);
parse_syntax(ptr);
} else if (strcasecmp(keyword, "color") == 0)
parse_colors(ptr, TRUE);
#endif /* ENABLE_COLOR */
else
- rcfile_error(N_("Command %s not understood"), keyword);
+ rcfile_error(N_("Command \"%s\" not understood"), keyword);
if (set == 0)
continue;
* an argument. */
if (*ptr == '\0') {
rcfile_error(
- N_("Option %s requires an argument"),
+ N_("Option \"%s\" requires an argument"),
rcopts[i].name);
break;
}
if (strcasecmp(rcopts[i].name, "fill") == 0) {
if (!parse_num(option, &wrap_at)) {
rcfile_error(
- N_("Requested fill size %s invalid"),
+ N_("Requested fill size \"%s\" invalid"),
option);
wrap_at = -CHARS_FROM_EOL;
} else
if (!parse_num(option, &tabsize) ||
tabsize <= 0) {
rcfile_error(
- N_("Requested tab size %s invalid"),
+ N_("Requested tab size \"%s\" invalid"),
option);
tabsize = -1;
} else
} else if (rcopts[i].flag != 0)
UNSET(rcopts[i].flag);
else
- rcfile_error(N_("Cannot unset flag %s"),
+ rcfile_error(N_("Cannot unset flag \"%s\""),
rcopts[i].name);
break;
}
}
if (rcopts[i].name == NULL)
- rcfile_error(N_("Unknown flag %s"), option);
+ rcfile_error(N_("Unknown flag \"%s\""), option);
}
if (endsyntax != NULL && endcolor == NULL)
- rcfile_error(N_("Syntax %s has no color commands"),
+ rcfile_error(N_("Syntax \"%s\" has no color commands"),
endsyntax->desc);
free(buf);