From ab41ab92466cd64692e655162bdd683cb2b8b23a Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Wed, 15 Jun 2005 06:30:05 +0000 Subject: [PATCH] fix #ifdefs so that nano compiles with NANO_SMALL defined and DISABLE_TABCOMP undefined git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2670 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 3 +++ src/chars.c | 6 +++--- src/files.c | 26 +++++++++++++------------- src/proto.h | 6 +++--- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ee0537a..8e330305 100644 --- a/ChangeLog +++ b/ChangeLog @@ -79,6 +79,9 @@ CVS code - is_punct_mbchar() and is_word_mbchar(); changes to do_next_word(), do_prev_word(), is_whole_word(), do_statusbar_next_word(), and do_statusbar_prev_word(). (DLR) + - Fix #ifdefs so that nano compiles with NANO_SMALL defined and + DISABLE_TABCOMP undefined. Changes to revstrstr() and + free_charptrarray() (renamed free_chararray()). (DLR) - chars.c: make_mbstring() - Change erroneous ENABLE_EXTRA #ifdef to NANO_EXTRA to fix a diff --git a/src/chars.c b/src/chars.c index 209e9754..e35a06f4 100644 --- a/src/chars.c +++ b/src/chars.c @@ -597,8 +597,7 @@ const char *mbstrcasestr(const char *haystack, const char *needle) return strcasestr(haystack, needle); } -#ifndef NANO_SMALL -#ifndef DISABLE_TABCOMP +#if !defined(NANO_SMALL) || !defined(DISABLE_TABCOMP) /* This function is equivalent to strstr(), except in that it scans the * string in reverse, starting at rev_start. */ const char *revstrstr(const char *haystack, const char *needle, const @@ -618,8 +617,9 @@ const char *revstrstr(const char *haystack, const char *needle, const return NULL; } -#endif /* !DISABLE_TABCOMP */ +#endif /* !NANO_SMALL || !DISABLE_TABCOMP */ +#ifndef NANO_SMALL /* This function is equivalent to strcasestr(), except in that it scans * the string in reverse, starting at rev_start. */ const char *revstrcasestr(const char *haystack, const char *needle, diff --git a/src/files.c b/src/files.c index b805504a..183bbe26 100644 --- a/src/files.c +++ b/src/files.c @@ -2010,6 +2010,15 @@ int diralphasort(const void *va, const void *vb) return strcasecmp(a, b); } + +/* Free the memory allocated for array, which should contain len + * elements. */ +void free_chararray(char **array, size_t len) +{ + for (; len > 0; len--) + free(array[len - 1]); + free(array); +} #endif #ifndef DISABLE_TABCOMP @@ -2337,7 +2346,7 @@ char *input_tab(char *buf, size_t *place, bool *lastwastab, bool *list) free(mzero); } - free_charptrarray(matches, num_matches); + free_chararray(matches, num_matches); /* Only refresh the edit window if we don't have a list of filename * matches on it. */ @@ -2366,15 +2375,6 @@ const char *tail(const char *foo) } #ifndef DISABLE_BROWSER -/* Free our malloc()ed memory. */ -void free_charptrarray(char **array, size_t len) -{ - for (; len > 0; len--) - free(array[len - 1]); - - free(array); -} - /* Strip one directory from the end of path. */ void striponedir(char *path) { @@ -2651,7 +2651,7 @@ char *do_browser(char *path, DIR *dir) path = mallocstrcpy(path, filelist[selected]); /* Start over again with the new path value. */ - free_charptrarray(filelist, numents); + free_chararray(filelist, numents); goto change_browser_directory; /* Refresh the screen. */ @@ -2711,7 +2711,7 @@ char *do_browser(char *path, DIR *dir) /* Start over again with the new path value. */ free(path); path = new_path; - free_charptrarray(filelist, numents); + free_chararray(filelist, numents); goto change_browser_directory; /* Abort the browser. */ @@ -2821,7 +2821,7 @@ char *do_browser(char *path, DIR *dir) SET(CONSTUPDATE); /* Clean up. */ - free_charptrarray(filelist, numents); + free_chararray(filelist, numents); free(path); return retval; diff --git a/src/proto.h b/src/proto.h index 59620e0f..5dde503d 100644 --- a/src/proto.h +++ b/src/proto.h @@ -199,11 +199,11 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n); const char *nstrcasestr(const char *haystack, const char *needle); #endif const char *mbstrcasestr(const char *haystack, const char *needle); -#ifndef NANO_SMALL -#ifndef DISABLE_TABCOMP +#if !defined(NANO_SMALL) || !defined(DISABLE_TABCOMP) const char *revstrstr(const char *haystack, const char *needle, const char *rev_start); #endif +#ifndef NANO_SMALL const char *revstrcasestr(const char *haystack, const char *needle, const char *rev_start); const char *mbrevstrcasestr(const char *haystack, const char *needle, @@ -305,6 +305,7 @@ void do_writeout_void(void); char *real_dir_from_tilde(const char *buf); #if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER) int diralphasort(const void *va, const void *vb); +void free_chararray(char **array, size_t len); #endif #ifndef DISABLE_TABCOMP char **username_tab_completion(const char *buf, size_t *num_matches, @@ -315,7 +316,6 @@ char *input_tab(char *buf, size_t *place, bool *lastwastab, bool *list); #endif const char *tail(const char *foo); #ifndef DISABLE_BROWSER -void free_charptrarray(char **array, size_t len); void striponedir(char *path); char **browser_init(const char *path, int *longest, size_t *numents, DIR *dir);