if (errno != ENOENT) {
/* Don't save history when we quit. */
UNSET(HISTORYLOG);
- rcfile_error(N_("Unable to open ~/.nano_history file: %s"), strerror(errno));
+ rcfile_error(N_("Unable to open ~/.nano_history file: %s\n"), strerror(errno));
}
free(nanohist);
} else {
if (homenv != NULL || userage != NULL) {
hist = fopen(nanohist, "wb");
if (hist == NULL)
- rcfile_error(N_("Unable to write ~/.nano_history file: %s"), strerror(errno));
+ rcfile_error(N_("Unable to write ~/.nano_history file: %s\n"), strerror(errno));
else {
/* set rw only by owner for security ?? */
chmod(nanohist, S_IRUSR | S_IWUSR);
h->data = charealloc(h->data, strlen(h->data) + 2);
strcat(h->data, "\n");
if (fputs(h->data, hist) == EOF) {
- rcfile_error(N_("Unable to write ~/.nano_history file: %s"), strerror(errno));
+ rcfile_error(N_("Unable to write ~/.nano_history file: %s\n"), strerror(errno));
goto come_from;
}
}
if (fputs("\n", hist) == EOF) {
- rcfile_error(N_("Unable to write ~/.nano_history file: %s"), strerror(errno));
+ rcfile_error(N_("Unable to write ~/.nano_history file: %s\n"), strerror(errno));
goto come_from;
}
for (h = replace_history.tail; h->prev; h = h->prev) {
h->data = charealloc(h->data, strlen(h->data) + 2);
strcat(h->data, "\n");
if (fputs(h->data, hist) == EOF) {
- rcfile_error(N_("Unable to write ~/.nano_history file: %s"), strerror(errno));
+ rcfile_error(N_("Unable to write ~/.nano_history file: %s\n"), strerror(errno));
goto come_from;
}
}
{NULL, 0}
};
+static bool errors = FALSE;
static int lineno = 0;
static char *nanorc;
va_list ap;
fprintf(stderr, "\n");
- if (lineno > 0)
+ if (lineno > 0) {
+ errors = TRUE;
fprintf(stderr, _("Error in %s on line %d: "), nanorc, lineno);
+ }
va_start(ap, msg);
vfprintf(stderr, _(msg), ap);
va_end(ap);
- fprintf(stderr, _("\nPress Return to continue\n"));
-
- while (getchar() != '\n')
- ;
}
/* Parse the next word from the string. Returns NULL if we hit EOL. */
ptr = NULL;
else
*ptr++ = '\0';
- rcfile_error(N_("Argument %s has unterminated \""), ptr_bak);
+ rcfile_error(N_("Argument %s has unterminated \"\n"), ptr_bak);
} else {
*last_quote = '\0';
ptr = last_quote + 1;
char *str = charalloc(len);
regerror(rc, preg, str, len);
- rcfile_error(N_("Bad regex \"%s\": %s"), regex, str);
+ rcfile_error(N_("Bad regex \"%s\": %s\n"), regex, str);
free(str);
}
return rc != 0;
ptr = parse_next_regex(ptr);
if (ptr == NULL) {
- rcfile_error(N_("Missing syntax name"));
+ rcfile_error(N_("Missing syntax name\n"));
return;
}
ptr = parse_next_word(ptr);
if (ptr == NULL) {
- rcfile_error(N_("Missing color name"));
+ rcfile_error(N_("Missing color name\n"));
return;
}
strtok(fgstr, ",");
bgcolorname = strtok(NULL, ",");
if (!strncasecmp(bgcolorname, "bright", 6)) {
- rcfile_error(N_("Background color %s cannot be bright"), bgcolorname);
+ rcfile_error(N_("Background color %s cannot be bright\n"), bgcolorname);
return;
}
bg = colortoint(bgcolorname, &bright);
return;
if (syntaxes == NULL) {
- rcfile_error(N_("Cannot add a color directive without a syntax line"));
+ rcfile_error(N_("Cannot add a color directive without a syntax line\n"));
return;
}
if (expectend) {
if (ptr == NULL || strncasecmp(ptr, "end=", 4)) {
- rcfile_error(N_("\"start=\" requires a corresponding \"end=\""));
+ rcfile_error(N_("\"start=\" requires a corresponding \"end=\"\n"));
return;
}
parse_colors(ptr);
#endif /* ENABLE_COLOR */
else {
- rcfile_error(N_("Command %s not understood"), keyword);
+ rcfile_error(N_("Command %s not understood\n"), keyword);
continue;
}
#endif
) {
if (*ptr == '\n' || *ptr == '\0') {
- rcfile_error(N_("Option %s requires an argument"), rcopts[i].name);
+ rcfile_error(N_("Option %s requires an argument\n"), rcopts[i].name);
continue;
}
option = ptr;
#ifndef DISABLE_WRAPJUSTIFY
if (!strcasecmp(rcopts[i].name, "fill")) {
if (parse_num(option, &wrap_at) == -1) {
- rcfile_error(N_("Requested fill size %s invalid"), option);
+ rcfile_error(N_("Requested fill size %s invalid\n"), option);
wrap_at = -CHARS_FROM_EOL;
}
} else
whitespace = mallocstrcpy(NULL, option);
ws_len = strlen(whitespace);
if (ws_len != 2 || (ws_len == 2 && (is_cntrl_char(whitespace[0]) || is_cntrl_char(whitespace[1])))) {
- rcfile_error(N_("Two non-control characters required"));
+ rcfile_error(N_("Two non-control characters required\n"));
free(whitespace);
whitespace = NULL;
}
if (!strcasecmp(rcopts[i].name, "punct")) {
punct = mallocstrcpy(NULL, option);
if (strchr(punct, '\t') != NULL || strchr(punct, ' ') != NULL) {
- rcfile_error(N_("Non-tab and non-space characters required"));
+ rcfile_error(N_("Non-tab and non-space characters required\n"));
free(punct);
punct = NULL;
}
} else if (!strcasecmp(rcopts[i].name, "brackets")) {
brackets = mallocstrcpy(NULL, option);
if (strchr(brackets, '\t') != NULL || strchr(brackets, ' ') != NULL) {
- rcfile_error(N_("Non-tab and non-space characters required"));
+ rcfile_error(N_("Non-tab and non-space characters required\n"));
free(brackets);
brackets = NULL;
}
#endif
if (!strcasecmp(rcopts[i].name, "tabsize")) {
if (parse_num(option, &tabsize) == -1 || tabsize <= 0)
- rcfile_error(N_("Requested tab size %s invalid"), option);
+ rcfile_error(N_("Requested tab size %s invalid\n"), option);
tabsize = -1;
}
} else
}
}
free(buf);
+
+ if (errors) {
+ errors = FALSE;
+ fprintf(stderr, _("\nPress Return to continue starting nano\n"));
+ while (getchar() != '\n')
+ ;
+ }
+
return;
}
endpwent();
if (userage == NULL) {
- rcfile_error(N_("I can't find my home directory! Wah!"));
+ rcfile_error(N_("I can't find my home directory! Wah!\n"));
SET(NO_RCFILE);
} else {
nanorc = charealloc(nanorc, strlen(userage->pw_dir) + 9);
if ((rcstream = fopen(nanorc, "r")) == NULL) {
/* Don't complain about the file not existing */
if (errno != ENOENT) {
- rcfile_error(N_("Unable to open ~/.nanorc file: %s"), strerror(errno));
+ rcfile_error(N_("Unable to open ~/.nanorc file: %s\n"), strerror(errno));
SET(NO_RCFILE);
}
} else {