From 5f36c3760ff90b5ef57d68cb9f0ef173f93f480f Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Mon, 16 Jul 2001 00:48:53 +0000 Subject: [PATCH] Fixes for the nano.h #defines, shortcut_init() lists and search.c reverse search stuff when NANO_SMALL is used git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@733 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 12 ++++++++++++ global.c | 43 +++++++++++++++++++++++-------------------- nano.h | 54 ++++++++++++++++++++++++++++++------------------------ utils.c | 25 +++++++++++++++++++------ winio.c | 2 +- 5 files changed, 85 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9bec626..9f6958f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,13 +2,25 @@ CVS code - - nano.c: main() - Change the getop option to 'F' (David Lawrence Ramsey) +- global.c: + shortcut_init() + - Rewrote the whereis and replace lists to put CANCEL at the end + of the list, and not include the toggle functions when using + NANO_SMALL. - nano.h: - Fix type in INSERTFILE_LIST_LEN. + - Rewrote all the macro definitions to be a little less messy, + for the #ifdefs anyway. - rcfile.c: - Update for the multibuffer option (oops) (David Lawrence Ramsey). - search.c: + - Added #ifdef NANO_SMALLs around the REVERSE_SEARCH code. search_init() - add #ifdef NANO_SMALL around toggles code. +- winio.c: + bottombars() + - Fixed an off by one that wasn't letting lines with odd # + shortcuts work in certain cases. nano-1.1.0 - 07/15/2001 - General diff --git a/global.c b/global.c index 66acb218..8f5d9642 100644 --- a/global.c +++ b/global.c @@ -226,14 +226,12 @@ void shortcut_init(int unjustify) "", *nano_lastline_msg = "", *nano_refresh_msg = "", *nano_mark_msg = "", *nano_delete_msg = "", *nano_backspace_msg = "", *nano_tab_msg = - "", *nano_enter_msg = "", *nano_case_msg = - "", *nano_cancel_msg = "", *nano_unjustify_msg = - "", *nano_append_msg = "", *nano_reverse_msg = - "", *nano_regexp_msg = ""; + "", *nano_enter_msg = "", *nano_cancel_msg = + "", *nano_unjustify_msg = "", *nano_append_msg = ""; #ifndef NANO_SMALL - char *nano_tofiles_msg = ""; - char *nano_gotodir_msg = ""; + char *nano_tofiles_msg = "", *nano_gotodir_msg = "", *nano_case_msg = + "", *nano_reverse_msg = "", *nano_regexp_msg = ""; nano_help_msg = _("Invoke the help menu"); nano_writeout_msg = _("Write the current file to disk"); @@ -414,19 +412,22 @@ void shortcut_init(int unjustify) _("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW, do_gotoline_void); - sc_init_one(&whereis_list[4], NANO_CANCEL_KEY, _("Cancel"), - nano_cancel_msg, 0, 0, 0, VIEW, 0); - - sc_init_one(&whereis_list[5], TOGGLE_CASE_KEY, _("Case Sens"), +#ifndef NANO_SMALL + sc_init_one(&whereis_list[4], TOGGLE_CASE_KEY, _("Case Sens"), nano_case_msg, 0, 0, 0, VIEW, 0); - sc_init_one(&whereis_list[6], TOGGLE_BACKWARDS_KEY, _("Backward"), + sc_init_one(&whereis_list[5], TOGGLE_BACKWARDS_KEY, _("Backward"), nano_reverse_msg, 0, 0, 0, VIEW, 0); #ifdef HAVE_REGEX_H - sc_init_one(&whereis_list[7], TOGGLE_REGEXP_KEY, _("Regexp"), - nano_regexp_msg, 0, 0, 0, VIEW, 0); + sc_init_one(&whereis_list[REPLACE_LIST_LEN - 2], TOGGLE_REGEXP_KEY, + _("Regexp"), nano_regexp_msg, 0, 0, 0, VIEW, 0); #endif +#endif /* NANO_SMALL */ + + sc_init_one(&whereis_list[REPLACE_LIST_LEN - 1], NANO_CANCEL_KEY, + _("Cancel"), nano_cancel_msg, 0, 0, 0, VIEW, 0); + sc_init_one(&replace_list[0], NANO_FIRSTLINE_KEY, _("First Line"), nano_firstline_msg, 0, 0, 0, VIEW, do_first_line); @@ -441,19 +442,21 @@ void shortcut_init(int unjustify) _("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW, do_gotoline_void); - sc_init_one(&replace_list[4], NANO_CANCEL_KEY, _("Cancel"), - nano_cancel_msg, 0, 0, 0, VIEW, 0); - - sc_init_one(&replace_list[5], TOGGLE_CASE_KEY, _("Case Sens"), +#ifndef NANO_SMALL + sc_init_one(&replace_list[4], TOGGLE_CASE_KEY, _("Case Sens"), nano_case_msg, 0, 0, 0, VIEW, 0); - sc_init_one(&replace_list[6], TOGGLE_BACKWARDS_KEY, _("Backward"), + sc_init_one(&replace_list[5], TOGGLE_BACKWARDS_KEY, _("Backward"), nano_reverse_msg, 0, 0, 0, VIEW, 0); #ifdef HAVE_REGEX_H - sc_init_one(&replace_list[7], TOGGLE_REGEXP_KEY, _("Regexp"), - nano_regexp_msg, 0, 0, 0, VIEW, 0); + sc_init_one(&replace_list[REPLACE_LIST_LEN - 2], TOGGLE_REGEXP_KEY, + _("Regexp"), nano_regexp_msg, 0, 0, 0, VIEW, 0); #endif +#endif /* NANO_SMALL */ + + sc_init_one(&replace_list[REPLACE_LIST_LEN - 1], NANO_CANCEL_KEY, + _("Cancel"), nano_cancel_msg, 0, 0, 0, VIEW, 0); sc_init_one(&replace_list_2[0], NANO_FIRSTLINE_KEY, _("First Line"), diff --git a/nano.h b/nano.h index c3d05759..8ff945a3 100644 --- a/nano.h +++ b/nano.h @@ -276,28 +276,40 @@ know what you're doing */ /* Toggle stuff, these static lengths need to go away RSN */ +#ifndef HAVE_REGEX_H +#define NO_REGEX 1 +#else +#define NO_REGEX 0 +#endif + +#ifdef DISABLE_BROWSER +#define NO_BROWSER 1 +#else +#define NO_BROWSER 0 +#endif + +#ifdef NANO_SMALL #ifdef HAVE_REGEX_H +#define NO_TOGGLES 3 +#else +#define NO_TOGGLES 2 +#endif /* HAVE_REGEX_H */ +#else +#define NO_TOGGLES 0 +#endif /* NANO_SMALL */ #ifdef ENABLE_MULTIBUFFER -#define TOGGLE_LEN 14 +#define MULTI_TOGGLES 3 #else -#define TOGGLE_LEN 11 -#endif - -#define WHEREIS_LIST_LEN 8 -#define REPLACE_LIST_LEN 8 -#else - -#ifdef ENABLE_MULTIBUFFER -#define TOGGLE_LEN 13 -#else -#define TOGGLE_LEN 10 -#endif - -#define WHEREIS_LIST_LEN 7 -#define REPLACE_LIST_LEN 7 +#define MULTI_TOGGLES 0 #endif +#define WHEREIS_LIST_LEN (8 - NO_REGEX - NO_TOGGLES) +#define REPLACE_LIST_LEN (8 - NO_REGEX - NO_TOGGLES) +#define TOGGLE_LEN (11 - NO_REGEX + MULTI_TOGGLES) +#define WRITEFILE_LIST_LEN (3 - NO_BROWSER) +#define INSERTFILE_LIST_LEN (2 - NO_BROWSER) +#define BROWSER_LIST_LEN 4 #define MAIN_LIST_LEN 26 #define MAIN_VISIBLE 12 #define REPLACE_LIST_2_LEN 3 @@ -306,14 +318,8 @@ know what you're doing */ #define HELP_LIST_LEN 3 #define SPELL_LIST_LEN 1 -#ifndef DISABLE_BROWSER -#define WRITEFILE_LIST_LEN 3 -#define INSERTFILE_LIST_LEN 2 -#define BROWSER_LIST_LEN 4 -#else -#define WRITEFILE_LIST_LEN 3 -#define INSERTFILE_LIST_LEN 1 -#endif + + #define VIEW 1 #define NOVIEW 0 diff --git a/utils.c b/utils.c index 1e6c2518..112e8c45 100644 --- a/utils.c +++ b/utils.c @@ -47,6 +47,8 @@ void lowercase(char *src) } } +/* None of this is needed if we're using NANO_SMALL! */ +#ifndef NANO_SMALL char *revstrstr(char *haystack, char *needle, char *rev_start) { char *p, *q, *r; @@ -72,6 +74,7 @@ char *revstrcasestr(char *haystack, char *needle, char *rev_start) } return 0; } +#endif /* NANO_SMALL */ /* This is now mutt's version (called mutt_stristr) because it doesn't use memory allocation to do a simple search (yuck). */ @@ -103,11 +106,13 @@ char *strstrwrapper(char *haystack, char *needle, char *rev_start) char *i, *j; if (ISSET(USE_REGEXP)) { +#ifndef NANO_SMALL if (!ISSET(REVERSE_SEARCH)) { result = regexec(&search_regexp, haystack, 10, regmatches, 0); if (!result) return haystack + regmatches[0].rm_so; } else { +#endif /* do quick check first */ if (!(regexec(&search_regexp, haystack, 10, regmatches, 0))) { /* there is a match */ @@ -117,21 +122,29 @@ char *strstrwrapper(char *haystack, char *needle, char *rev_start) if (j <= rev_start) return j; } + } +#ifndef NANO_SMALL } +#endif return 0; } #endif if (ISSET(CASE_SENSITIVE)) { - if (!ISSET(REVERSE_SEARCH)) - return strstr(haystack,needle); - else +#ifndef NANO_SMALL + if (ISSET(REVERSE_SEARCH)) return revstrstr(haystack, needle, rev_start); + else +#endif + return strstr(haystack,needle); + } else { - if (!ISSET(REVERSE_SEARCH)) - return strcasestr(haystack, needle); - else +#ifndef NANO_SMALL + if (ISSET(REVERSE_SEARCH)) return revstrcasestr(haystack, needle, rev_start); + else +#endif + return strcasestr(haystack, needle); } } diff --git a/winio.c b/winio.c index 4337e7f1..3181c86d 100644 --- a/winio.c +++ b/winio.c @@ -607,7 +607,7 @@ void bottombars(shortcut s[], int slen) clear_bottomwin(); wmove(bottomwin, 1, 0); - for (i = 0; i <= slen - 2; i += 2) { + for (i = 0; i <= slen - 1; i += 2) { if (s[i].val < 97) snprintf(keystr, 10, "^%c", s[i].val + 64);