nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 94812d17c8440ad4f6677961081963c19ef1d76e
parent 7681090c12d7553083e8aeff5bf74b7b28fa5692
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu, 23 Feb 2023 17:08:45 +0100

tweaks: rename a struct element, to avoid a theoretical name collision

The <term.h> header file form ncurses defines the name "tab".

Diffstat:
Msrc/definitions.h | 2+-
Msrc/nano.c | 2+-
Msrc/rcfile.c | 4++--
Msrc/text.c | 14+++++++-------
4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/definitions.h b/src/definitions.h @@ -432,7 +432,7 @@ typedef struct syntaxtype { /* The command with which to lint this type of file. */ char *formatter; /* The command with which to format/modify/arrange this type of file. */ - char *tab; + char *tabstring; /* What the Tab key should produce; NULL for default behavior. */ #ifdef ENABLE_COMMENT char *comment; diff --git a/src/nano.c b/src/nano.c @@ -1107,7 +1107,7 @@ void toggle_this(int flag) refresh_needed = TRUE; break; case TABS_TO_SPACES: - if (openfile->syntax && openfile->syntax->tab) { + if (openfile->syntax && openfile->syntax->tabstring) { statusline(AHEM, _("Current syntax determines Tab")); TOGGLE(flag); return; diff --git a/src/rcfile.c b/src/rcfile.c @@ -674,7 +674,7 @@ void begin_new_syntax(char *ptr) live_syntax->magics = NULL; live_syntax->linter = NULL; live_syntax->formatter = NULL; - live_syntax->tab = NULL; + live_syntax->tabstring = NULL; #ifdef ENABLE_COMMENT live_syntax->comment = copy_of(GENERAL_COMMENT_CHARACTER); #endif @@ -1325,7 +1325,7 @@ bool parse_syntax_commands(char *keyword, char *ptr) pick_up_name("comment", ptr, &live_syntax->comment); #endif } else if (strcmp(keyword, "tabgives") == 0) { - pick_up_name("tabgives", ptr, &live_syntax->tab); + pick_up_name("tabgives", ptr, &live_syntax->tabstring); } else if (strcmp(keyword, "linter") == 0) pick_up_name("linter", ptr, &live_syntax->linter); else if (strcmp(keyword, "formatter") == 0) diff --git a/src/text.c b/src/text.c @@ -65,8 +65,8 @@ void do_mark(void) void do_tab(void) { #ifdef ENABLE_COLOR - if (openfile->syntax && openfile->syntax->tab) - inject(openfile->syntax->tab, strlen(openfile->syntax->tab)); + if (openfile->syntax && openfile->syntax->tabstring) + inject(openfile->syntax->tabstring, strlen(openfile->syntax->tabstring)); else #endif #ifndef NANO_TINY @@ -134,8 +134,8 @@ void do_indent(void) indentation = nmalloc(tabsize + 1); #ifdef ENABLE_COLOR - if (openfile->syntax && openfile->syntax->tab) - indentation = mallocstrcpy(indentation, openfile->syntax->tab); + if (openfile->syntax && openfile->syntax->tabstring) + indentation = mallocstrcpy(indentation, openfile->syntax->tabstring); else #endif /* Set the indentation to either a bunch of spaces or a single tab. */ @@ -173,10 +173,10 @@ size_t length_of_white(const char *text) size_t white_count = 0; #ifdef ENABLE_COLOR - if (openfile->syntax && openfile->syntax->tab) { - size_t thelength = strlen(openfile->syntax->tab); + if (openfile->syntax && openfile->syntax->tabstring) { + size_t thelength = strlen(openfile->syntax->tabstring); - while (text[white_count] == openfile->syntax->tab[white_count]) + while (text[white_count] == openfile->syntax->tabstring[white_count]) if (++white_count == thelength) return thelength;