From: David Lawrence Ramsey Date: Sun, 1 Aug 2004 22:35:31 +0000 (+0000) Subject: make lastwastab and list use TRUE and FALSE instead of 1 and 0, make X-Git-Tag: v1.3.4~26 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=4d44d2de0e92772ec2b18e55dcf6246e32727a40;p=nano.git make lastwastab and list use TRUE and FALSE instead of 1 and 0, make them bools in the process, and make a few other minor cosmetic cleanups git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1880 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 5028ce20..82534de6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,8 @@ CVS code - - General: - More minor comment cleanups. (DLR) - - Convert more ints used as boolean values to use TRUE and - FALSE. (David Benbennick and DLR) + - Convert more ints using 0 and 1 to bools using TRUE and FALSE. + (David Benbennick and DLR) - Change more instances of ints that have large enough upper bounds and which can never be negative to size_t's, and convert nano to handle them properly. (DLR) diff --git a/src/files.c b/src/files.c index 22fea15c..dcbcbf8c 100644 --- a/src/files.c +++ b/src/files.c @@ -2007,7 +2007,7 @@ char *real_dir_from_tilde(const char *buf) /* Tack a slash onto the string we're completing if it's a directory. We * assume there is room for one more character on the end of buf. The * return value says whether buf is a directory. */ -int append_slash_if_dir(char *buf, int *lastwastab, int *place) +int append_slash_if_dir(char *buf, bool *lastwastab, int *place) { char *dirptr = real_dir_from_tilde(buf); struct stat fileinfo; @@ -2019,7 +2019,7 @@ int append_slash_if_dir(char *buf, int *lastwastab, int *place) strncat(buf, "/", 1); (*place)++; /* now we start over again with # of tabs so far */ - *lastwastab = 0; + *lastwastab = FALSE; ret = 1; } @@ -2059,7 +2059,7 @@ char **username_tab_completion(char *buf, int *num_matches) while ((userdata = getpwent()) != NULL) { - if (check_wildcard_match(userdata->pw_name, &buf[1]) == TRUE) { + if (check_wildcard_match(userdata->pw_name, &buf[1])) { /* Cool, found a match. Add it to the list * This makes a lot more sense to me (Chris) this way... @@ -2160,7 +2160,7 @@ char **cwd_tab_completion(char *buf, int *num_matches) fprintf(stderr, "Comparing \'%s\'\n", next->d_name); #endif /* See if this matches */ - if (check_wildcard_match(next->d_name, tmp) == TRUE) { + if (check_wildcard_match(next->d_name, tmp)) { /* Cool, found a match. Add it to the list * This makes a lot more sense to me (Chris) this way... @@ -2205,8 +2205,8 @@ char **cwd_tab_completion(char *buf, int *num_matches) /* This function now has an arg which refers to how much the statusbar * (place) should be advanced, i.e. the new cursor pos. */ -char *input_tab(char *buf, int place, int *lastwastab, int *newplace, - int *list) +char *input_tab(char *buf, int place, bool *lastwastab, int *newplace, + bool *list) { /* Do TAB completion */ static int num_matches = 0, match_matches = 0; @@ -2215,12 +2215,12 @@ char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int longestname = 0, is_dir = 0; char *foo; - *list = 0; + *list = FALSE; if (*lastwastab == FALSE) { char *tmp, *copyto, *matchbuf; - *lastwastab = 1; + *lastwastab = TRUE; /* Make a local copy of the string -- up to the position of the cursor */ @@ -2407,14 +2407,14 @@ char *input_tab(char *buf, int place, int *lastwastab, int *newplace, } free(foo); wrefresh(edit); - *list = 1; + *list = TRUE; } else beep(); } /* Only refresh the edit window if we don't have a list of filename matches on it */ - if (*list == 0) + if (*list == FALSE) edit_refresh(); curs_set(1); return buf; diff --git a/src/nano.c b/src/nano.c index cc6c7ca3..e7ae45b9 100644 --- a/src/nano.c +++ b/src/nano.c @@ -880,7 +880,7 @@ void do_mouse(void) { int mouse_x, mouse_y; - if (get_mouseinput(&mouse_x, &mouse_y, TRUE) == FALSE) { + if (!get_mouseinput(&mouse_x, &mouse_y, TRUE)) { /* Click in the edit window to move the cursor, but only when we're not in a subfunction. */ if (wenclose(edit, mouse_y, mouse_x) && currshortcut == main_list) { @@ -3511,7 +3511,7 @@ int main(int argc, char *argv[]) #ifdef DEBUG fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput); #endif - if (meta_key == TRUE) { + if (meta_key) { /* Check for the metaval and miscval defs... */ for (s = #if !defined(DISABLE_BROWSER) || !defined (DISABLE_HELP) || !defined(DISABLE_MOUSE) diff --git a/src/proto.h b/src/proto.h index 43a77c84..9fa4d361 100644 --- a/src/proto.h +++ b/src/proto.h @@ -207,11 +207,11 @@ int do_writeout(int exiting); void do_writeout_void(void); char *real_dir_from_tilde(const char *buf); #ifndef DISABLE_TABCOMP -int append_slash_if_dir(char *buf, int *lastwastab, int *place); +int append_slash_if_dir(char *buf, bool *lastwastab, int *place); char **username_tab_completion(char *buf, int *num_matches); char **cwd_tab_completion(char *buf, int *num_matches); -char *input_tab(char *buf, int place, int *lastwastab, int *newplace, - int *list); +char *input_tab(char *buf, int place, bool *lastwastab, int *newplace, + bool *list); #endif const char *tail(const char *foo); #ifndef DISABLE_BROWSER @@ -522,7 +522,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def, #endif const shortcut *s #ifndef DISABLE_TABCOMP - , int *list + , bool *list #endif ); void titlebar(const char *path); diff --git a/src/utils.c b/src/utils.c index 3cb91748..39b08b90 100644 --- a/src/utils.c +++ b/src/utils.c @@ -437,10 +437,10 @@ int check_wildcard_match(const char *text, const char *pattern) found = TRUE; } len = strlen(text); - if (found == FALSE && len != 0) { + if (!found && len != 0) { return FALSE; } - if (found == TRUE) { + if (found) { if (strlen(pattern) == 0 && len == 1) { return TRUE; } diff --git a/src/winio.c b/src/winio.c index 65345b9a..eb8a961c 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1536,7 +1536,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def, #endif const shortcut *s #ifndef DISABLE_TABCOMP - , int *list + , bool *list #endif ) { @@ -1546,7 +1546,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def, /* the cursor position in 'answer' */ int xend; /* length of 'answer', the status bar text */ - int tabbed = 0; + bool tabbed = FALSE; /* used by input_tab() */ const shortcut *t; @@ -1630,7 +1630,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def, assert(0 <= x && x <= xend && xend == strlen(answer)); if (kbinput != '\t') - tabbed = 0; + tabbed = FALSE; switch (kbinput) { #ifndef DISABLE_MOUSE @@ -1820,7 +1820,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def, fprintf(stderr, "Aha! \'%c\' (%d)\n", kbinput, kbinput); #endif - if (meta_key == TRUE && (kbinput == t->metaval || kbinput == t->miscval)) + if (meta_key && (kbinput == t->metaval || kbinput == t->miscval)) /* We hit a meta key. Do like above. We don't * just ungetch() the letter and let it get * caught above cause that screws the @@ -2744,7 +2744,7 @@ int statusq(int allowtabs, const shortcut *s, const char *def, char *foo = charalloc(COLS - 3); int ret; #ifndef DISABLE_TABCOMP - int list = 0; + bool list = FALSE; #endif bottombars(s);