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
master
David Lawrence Ramsey 2004-08-01 22:35:31 +00:00
parent 8bf9ba0c16
commit 4d44d2de0e
6 changed files with 25 additions and 25 deletions

View File

@ -1,8 +1,8 @@
CVS code - CVS code -
- General: - General:
- More minor comment cleanups. (DLR) - More minor comment cleanups. (DLR)
- Convert more ints used as boolean values to use TRUE and - Convert more ints using 0 and 1 to bools using TRUE and FALSE.
FALSE. (David Benbennick and DLR) (David Benbennick and DLR)
- Change more instances of ints that have large enough upper - Change more instances of ints that have large enough upper
bounds and which can never be negative to size_t's, and bounds and which can never be negative to size_t's, and
convert nano to handle them properly. (DLR) convert nano to handle them properly. (DLR)

View File

@ -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 /* 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 * assume there is room for one more character on the end of buf. The
* return value says whether buf is a directory. */ * 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); char *dirptr = real_dir_from_tilde(buf);
struct stat fileinfo; struct stat fileinfo;
@ -2019,7 +2019,7 @@ int append_slash_if_dir(char *buf, int *lastwastab, int *place)
strncat(buf, "/", 1); strncat(buf, "/", 1);
(*place)++; (*place)++;
/* now we start over again with # of tabs so far */ /* now we start over again with # of tabs so far */
*lastwastab = 0; *lastwastab = FALSE;
ret = 1; ret = 1;
} }
@ -2059,7 +2059,7 @@ char **username_tab_completion(char *buf, int *num_matches)
while ((userdata = getpwent()) != NULL) { 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 /* Cool, found a match. Add it to the list
* This makes a lot more sense to me (Chris) this way... * 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); fprintf(stderr, "Comparing \'%s\'\n", next->d_name);
#endif #endif
/* See if this matches */ /* 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 /* Cool, found a match. Add it to the list
* This makes a lot more sense to me (Chris) this way... * 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 /* This function now has an arg which refers to how much the statusbar
* (place) should be advanced, i.e. the new cursor pos. */ * (place) should be advanced, i.e. the new cursor pos. */
char *input_tab(char *buf, int place, int *lastwastab, int *newplace, char *input_tab(char *buf, int place, bool *lastwastab, int *newplace,
int *list) bool *list)
{ {
/* Do TAB completion */ /* Do TAB completion */
static int num_matches = 0, match_matches = 0; 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; int longestname = 0, is_dir = 0;
char *foo; char *foo;
*list = 0; *list = FALSE;
if (*lastwastab == FALSE) { if (*lastwastab == FALSE) {
char *tmp, *copyto, *matchbuf; char *tmp, *copyto, *matchbuf;
*lastwastab = 1; *lastwastab = TRUE;
/* Make a local copy of the string -- up to the position of the /* Make a local copy of the string -- up to the position of the
cursor */ cursor */
@ -2407,14 +2407,14 @@ char *input_tab(char *buf, int place, int *lastwastab, int *newplace,
} }
free(foo); free(foo);
wrefresh(edit); wrefresh(edit);
*list = 1; *list = TRUE;
} else } else
beep(); beep();
} }
/* Only refresh the edit window if we don't have a list of filename /* Only refresh the edit window if we don't have a list of filename
matches on it */ matches on it */
if (*list == 0) if (*list == FALSE)
edit_refresh(); edit_refresh();
curs_set(1); curs_set(1);
return buf; return buf;

View File

@ -880,7 +880,7 @@ void do_mouse(void)
{ {
int mouse_x, mouse_y; 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 /* Click in the edit window to move the cursor, but only when
we're not in a subfunction. */ we're not in a subfunction. */
if (wenclose(edit, mouse_y, mouse_x) && currshortcut == main_list) { if (wenclose(edit, mouse_y, mouse_x) && currshortcut == main_list) {
@ -3511,7 +3511,7 @@ int main(int argc, char *argv[])
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput); fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput);
#endif #endif
if (meta_key == TRUE) { if (meta_key) {
/* Check for the metaval and miscval defs... */ /* Check for the metaval and miscval defs... */
for (s = for (s =
#if !defined(DISABLE_BROWSER) || !defined (DISABLE_HELP) || !defined(DISABLE_MOUSE) #if !defined(DISABLE_BROWSER) || !defined (DISABLE_HELP) || !defined(DISABLE_MOUSE)

View File

@ -207,11 +207,11 @@ int do_writeout(int exiting);
void do_writeout_void(void); void do_writeout_void(void);
char *real_dir_from_tilde(const char *buf); char *real_dir_from_tilde(const char *buf);
#ifndef DISABLE_TABCOMP #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 **username_tab_completion(char *buf, int *num_matches);
char **cwd_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, char *input_tab(char *buf, int place, bool *lastwastab, int *newplace,
int *list); bool *list);
#endif #endif
const char *tail(const char *foo); const char *tail(const char *foo);
#ifndef DISABLE_BROWSER #ifndef DISABLE_BROWSER
@ -522,7 +522,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
#endif #endif
const shortcut *s const shortcut *s
#ifndef DISABLE_TABCOMP #ifndef DISABLE_TABCOMP
, int *list , bool *list
#endif #endif
); );
void titlebar(const char *path); void titlebar(const char *path);

View File

@ -437,10 +437,10 @@ int check_wildcard_match(const char *text, const char *pattern)
found = TRUE; found = TRUE;
} }
len = strlen(text); len = strlen(text);
if (found == FALSE && len != 0) { if (!found && len != 0) {
return FALSE; return FALSE;
} }
if (found == TRUE) { if (found) {
if (strlen(pattern) == 0 && len == 1) { if (strlen(pattern) == 0 && len == 1) {
return TRUE; return TRUE;
} }

View File

@ -1536,7 +1536,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
#endif #endif
const shortcut *s const shortcut *s
#ifndef DISABLE_TABCOMP #ifndef DISABLE_TABCOMP
, int *list , bool *list
#endif #endif
) )
{ {
@ -1546,7 +1546,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
/* the cursor position in 'answer' */ /* the cursor position in 'answer' */
int xend; int xend;
/* length of 'answer', the status bar text */ /* length of 'answer', the status bar text */
int tabbed = 0; bool tabbed = FALSE;
/* used by input_tab() */ /* used by input_tab() */
const shortcut *t; 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)); assert(0 <= x && x <= xend && xend == strlen(answer));
if (kbinput != '\t') if (kbinput != '\t')
tabbed = 0; tabbed = FALSE;
switch (kbinput) { switch (kbinput) {
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
@ -1820,7 +1820,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
fprintf(stderr, "Aha! \'%c\' (%d)\n", kbinput, fprintf(stderr, "Aha! \'%c\' (%d)\n", kbinput,
kbinput); kbinput);
#endif #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 /* We hit a meta key. Do like above. We don't
* just ungetch() the letter and let it get * just ungetch() the letter and let it get
* caught above cause that screws the * 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); char *foo = charalloc(COLS - 3);
int ret; int ret;
#ifndef DISABLE_TABCOMP #ifndef DISABLE_TABCOMP
int list = 0; bool list = FALSE;
#endif #endif
bottombars(s); bottombars(s);