tweaks: remove an annoying conditional compilation of an argument

Also remove some unneeded prototypes, adjust some comments, and
move a constant definition to the top of the file.
master
Benno Schulenberg 2016-11-27 16:34:34 +01:00
parent 1762920808
commit 77023a749b
2 changed files with 15 additions and 38 deletions

View File

@ -522,21 +522,11 @@ int do_yesno_prompt(bool all, const char *msg);
char *parse_next_word(char *ptr); char *parse_next_word(char *ptr);
#endif #endif
#ifndef DISABLE_NANORC #ifndef DISABLE_NANORC
void rcfile_error(const char *msg, ...);
char *parse_argument(char *ptr);
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
char *parse_next_regex(char *ptr);
void parse_syntax(char *ptr);
void parse_includes(char *ptr);
short color_to_short(const char *colorname, bool *bright);
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright); bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage); void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
#endif #endif
void parse_rcfile(FILE *rcstream void parse_rcfile(FILE *rcstream, bool syntax_only);
#ifndef DISABLE_COLOR
, bool syntax_only
#endif
);
void do_rcfile(void); void do_rcfile(void);
#endif /* !DISABLE_NANORC */ #endif /* !DISABLE_NANORC */

View File

@ -33,6 +33,10 @@
#ifndef DISABLE_NANORC #ifndef DISABLE_NANORC
#ifndef RCFILE_NAME
#define RCFILE_NAME ".nanorc"
#endif
static const rcoption rcopts[] = { static const rcoption rcopts[] = {
{"boldtext", BOLD_TEXT}, {"boldtext", BOLD_TEXT},
#ifdef ENABLE_LINENUMBERS #ifdef ENABLE_LINENUMBERS
@ -899,8 +903,8 @@ void pick_up_name(const char *kind, char *ptr, char **storage)
} }
#endif /* !DISABLE_COLOR */ #endif /* !DISABLE_COLOR */
/* Check whether the user has unmapped every shortcut for a /* Verify that the user has not unmapped every shortcut for a
* sequence we consider 'vital', like the exit function. */ * function that we consider 'vital' (such as "Exit"). */
static void check_vitals_mapped(void) static void check_vitals_mapped(void)
{ {
subnfunc *f; subnfunc *f;
@ -927,13 +931,9 @@ static void check_vitals_mapped(void)
} }
/* Parse the rcfile, once it has been opened successfully at rcstream, /* Parse the rcfile, once it has been opened successfully at rcstream,
* and close it afterwards. If syntax_only is TRUE, only allow the file * and close it afterwards. If syntax_only is TRUE, allow the file to
* to contain color syntax commands. */ * to contain only color syntax commands. */
void parse_rcfile(FILE *rcstream void parse_rcfile(FILE *rcstream, bool syntax_only)
#ifndef DISABLE_COLOR
, bool syntax_only
#endif
)
{ {
char *buf = NULL; char *buf = NULL;
ssize_t len; ssize_t len;
@ -1224,8 +1224,7 @@ void parse_rcfile(FILE *rcstream
return; return;
} }
/* The main rcfile function. It tries to open the system-wide rcfile, /* First read the system-wide rcfile, then the user's rcfile. */
* followed by the current user's rcfile. */
void do_rcfile(void) void do_rcfile(void)
{ {
struct stat rcinfo; struct stat rcinfo;
@ -1249,16 +1248,11 @@ void do_rcfile(void)
/* Try to open the system-wide nanorc. */ /* Try to open the system-wide nanorc. */
rcstream = fopen(nanorc, "rb"); rcstream = fopen(nanorc, "rb");
if (rcstream != NULL) if (rcstream != NULL)
parse_rcfile(rcstream parse_rcfile(rcstream, FALSE);
#ifndef DISABLE_COLOR
, FALSE
#endif
);
/* When configured with --disable-wrapping-as-root, turn wrapping off
* for root, so that only root's .nanorc or --fill can turn it on. */
#ifdef DISABLE_ROOTWRAPPING #ifdef DISABLE_ROOTWRAPPING
/* We've already read SYSCONFDIR/nanorc, if it's there. If we're
* root, and --disable-wrapping-as-root is used, turn wrapping off
* now. */
if (geteuid() == NANO_ROOT_UID) if (geteuid() == NANO_ROOT_UID)
SET(NO_WRAP); SET(NO_WRAP);
#endif #endif
@ -1268,9 +1262,6 @@ void do_rcfile(void)
if (homedir == NULL) if (homedir == NULL)
rcfile_error(N_("I can't find my home directory! Wah!")); rcfile_error(N_("I can't find my home directory! Wah!"));
else { else {
#ifndef RCFILE_NAME
#define RCFILE_NAME ".nanorc"
#endif
nanorc = charealloc(nanorc, strlen(homedir) + strlen(RCFILE_NAME) + 2); nanorc = charealloc(nanorc, strlen(homedir) + strlen(RCFILE_NAME) + 2);
sprintf(nanorc, "%s/%s", homedir, RCFILE_NAME); sprintf(nanorc, "%s/%s", homedir, RCFILE_NAME);
@ -1291,11 +1282,7 @@ void do_rcfile(void)
rcfile_error(N_("Error reading %s: %s"), nanorc, rcfile_error(N_("Error reading %s: %s"), nanorc,
strerror(errno)); strerror(errno));
} else } else
parse_rcfile(rcstream parse_rcfile(rcstream, FALSE);
#ifndef DISABLE_COLOR
, FALSE
#endif
);
} }
free(nanorc); free(nanorc);