From edab0cc0a5e5bff57d00aa93ea32786e80ab645b Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Sat, 3 Jul 2004 03:09:12 +0000 Subject: [PATCH] a few cleanups and consistency fixes git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1837 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 10 +++++++++- src/files.c | 4 ++-- src/global.c | 2 +- src/nano.c | 6 +++--- src/nano.h | 2 +- src/proto.h | 5 ++--- src/rcfile.c | 10 +++++----- src/search.c | 7 ++++--- 8 files changed, 27 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9fbdffbe..e69e30ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,10 +6,14 @@ CVS code - - Change more instances of ints that can never be negative to size_t's. (DLR) - Convert the shortcut list functions and most related functions - to return void instead of int, as the return values of all + to return void instead of int, as the return values of all those functions are essentially unused. Changes to sc_init_one(), shortcut_init(), etc. (David Benbennick and DLR) + - Make flags and all variables meant to store the value of flags + longs for consistency. (David Benbennick) + - Rename the TEMP_OPT flags to TEMP_FILE, as it's more + descriptive. (DLR) - files.c: close_open_file() - Tweak to no longer rely on the return values of @@ -25,10 +29,14 @@ CVS code - - Change the last variables in the prototypes for do_justify() and get_mouseinput() to match the ones used in the actual functions. (DLR) + - Remove unused declaration of temp_opt. (David Benbennick) - rcfile.c: parse_rcfile() - Have whitespace display default to off instead of on. (Mike Frysinger) + nregcomp() + - Rename the variable flags to eflags so as not to conflict with + the global flags. (DLR) - winio.c: get_control_kbinput() - Fix erroneous debugging statement so that nano compiles with diff --git a/src/files.c b/src/files.c index 8f0b7837..abc0cfbe 100644 --- a/src/files.c +++ b/src/files.c @@ -1794,7 +1794,7 @@ int do_writeout(int exiting) currshortcut = writefile_list; #endif - if (exiting && filename[0] != '\0' && ISSET(TEMP_OPT)) { + if (exiting && filename[0] != '\0' && ISSET(TEMP_FILE)) { i = write_file(filename, FALSE, 0, FALSE); if (i == 1) { /* Write succeeded. */ @@ -1901,7 +1901,7 @@ int do_writeout(int exiting) #endif #ifdef NANO_EXTRA - if (exiting && !ISSET(TEMP_OPT) && !strcasecmp(answer, "zzy") + if (exiting && !ISSET(TEMP_FILE) && !strcasecmp(answer, "zzy") && !did_cred) { do_credits(); did_cred = TRUE; diff --git a/src/global.c b/src/global.c index 50ab559c..15f87d65 100644 --- a/src/global.c +++ b/src/global.c @@ -39,7 +39,7 @@ char *last_replace = NULL; /* Last replacement string */ int search_last_line; /* Is this the last search line? */ int search_offscreen; /* Search lines not displayed */ -int flags = 0; /* Our new flag containing many options */ +long flags = 0; /* Our flag containing many options */ WINDOW *edit; /* The file portion of the editor */ WINDOW *topwin; /* Top line of screen */ WINDOW *bottomwin; /* Bottom buffer */ diff --git a/src/nano.c b/src/nano.c index c49c06d3..f5f2df83 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2387,7 +2387,7 @@ void do_justify(int full_justify) * unjustifies. Note we don't need to save totlines. */ int current_x_save = current_x; int current_y_save = current_y; - int flags_save = flags; + long flags_save = flags; long totsize_save = totsize; filestruct *current_save = current; filestruct *edittop_save = edittop; @@ -2715,7 +2715,7 @@ void do_exit(void) if (!ISSET(MODIFIED)) i = 0; /* Pretend the user chose not to save. */ - else if (ISSET(TEMP_OPT)) + else if (ISSET(TEMP_FILE)) i = 1; else i = do_yesno(FALSE, @@ -3234,7 +3234,7 @@ int main(int argc, char *argv[]) break; #endif case 't': - SET(TEMP_OPT); + SET(TEMP_FILE); break; case 'v': SET(VIEW_MODE); diff --git a/src/nano.h b/src/nano.h index 1ef4f137..669c172c 100644 --- a/src/nano.h +++ b/src/nano.h @@ -264,7 +264,7 @@ typedef struct historyheadtype { #define VIEW_MODE (1<<9) #define USE_MOUSE (1<<10) #define USE_REGEXP (1<<11) -#define TEMP_OPT (1<<12) +#define TEMP_FILE (1<<12) #define CUT_TO_END (1<<13) #define REVERSE_SEARCH (1<<14) #define MULTIBUFFER (1<<15) diff --git a/src/proto.h b/src/proto.h index 89ca63f9..f65a1a53 100644 --- a/src/proto.h +++ b/src/proto.h @@ -39,8 +39,7 @@ extern int placewewant; extern int mark_beginx; #endif extern long totsize; -extern int temp_opt; -extern int flags; +extern long flags; extern int tabsize; extern int search_last_line; extern int search_offscreen; @@ -370,7 +369,7 @@ char *parse_argument(char *ptr); #ifdef ENABLE_COLOR int colortoint(const char *colorname, int *bright); char *parse_next_regex(char *ptr); -int nregcomp(regex_t *preg, const char *regex, int flags); +int nregcomp(regex_t *preg, const char *regex, int eflags); void parse_syntax(char *ptr); void parse_colors(char *ptr); #endif /* ENABLE_COLOR */ diff --git a/src/rcfile.c b/src/rcfile.c index de5ec4a1..e25fd259 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -92,7 +92,7 @@ const static rcoption rcopts[] = { #endif {"suspend", SUSPEND}, {"tabsize", 0}, - {"tempfile", TEMP_OPT}, + {"tempfile", TEMP_FILE}, {"view", VIEW_MODE}, #ifndef NANO_SMALL {"whitespace", 0}, @@ -253,11 +253,11 @@ char *parse_next_regex(char *ptr) return ptr; } -/* Compile the regular expression regex to preg. Returns FALSE on success, - TRUE if the expression is invalid. */ -int nregcomp(regex_t *preg, const char *regex, int flags) +/* Compile the regular expression regex to preg. Returns FALSE on + * success, or TRUE if the expression is invalid. */ +int nregcomp(regex_t *preg, const char *regex, int eflags) { - int rc = regcomp(preg, regex, REG_EXTENDED | flags); + int rc = regcomp(preg, regex, REG_EXTENDED | eflags); if (rc != 0) { size_t len = regerror(rc, preg, NULL, 0); diff --git a/src/search.c b/src/search.c index 55f295b3..0a0c8917 100644 --- a/src/search.c +++ b/src/search.c @@ -899,7 +899,8 @@ void do_find_bracket(void) char ch_under_cursor, wanted_ch; const char *pos, *brackets = "([{<>}])"; char regexp_pat[] = "[ ]"; - int old_pww = placewewant, current_x_save, flagsave, count = 1; + int old_pww = placewewant, current_x_save, count = 1; + long flags_save; filestruct *current_save; ch_under_cursor = current->data[current_x]; @@ -915,7 +916,7 @@ void do_find_bracket(void) current_x_save = current_x; current_save = current; - flagsave = flags; + flags_save = flags; SET(USE_REGEXP); /* Apparent near redundancy with regexp_pat[] here is needed. @@ -958,7 +959,7 @@ void do_find_bracket(void) } regexp_cleanup(); - flags = flagsave; + flags = flags_save; } #endif -- 2.39.5