From 1de337de9c4a732e4ec32c06ca0ad7af1299003d Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 4 Jun 2014 16:02:51 +0000 Subject: [PATCH] Normalizing whitespace, comments and interpunction, in various places. Patch by David Lawrence Ramsey. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4938 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 4 ++++ doc/nanorc.sample.in | 6 +++--- src/browser.c | 3 +-- src/files.c | 6 +++--- src/global.c | 2 +- src/nano.c | 4 ++-- src/text.c | 6 +++--- src/utils.c | 21 +++++++++++---------- src/winio.c | 24 ++++++++++++++---------- 9 files changed, 42 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 76eee7c5..aa24a3b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-06-04 David Lawrence Ramsey + * src/*.c: Adjustments of whitespace and comments. + * doc/nanorc.sample.in: Interpunction tweaks. + 2014-06-02 Chris Allegretta * doc/syntax/default.nanorc: Can't do trailing spaces in the default syntax or it will hilight the spaces as you type diff --git a/doc/nanorc.sample.in b/doc/nanorc.sample.in index d2dc9661..beafe490 100644 --- a/doc/nanorc.sample.in +++ b/doc/nanorc.sample.in @@ -61,7 +61,7 @@ ## Enable vim-style lock-files. This is just to let a vim user know you ## are editing a file [s]he is trying to edit and vice versa. There are -## no plans to implement vim-style undo state in these files +## no plans to implement vim-style undo state in these files. # set locking ## The opening and closing brackets that can be found by bracket @@ -162,7 +162,7 @@ ## Convert typed tabs to spaces. # set tabstospaces -## Save automatically on exit, don't prompt. +## Save automatically on exit; don't prompt. # set tempfile ## Enable the new (EXPERIMENTAL) generic undo code, not just for line @@ -186,7 +186,7 @@ ## Paint the interface elements of nano. -## This is an example, by default there are no colors. +## This is an example; by default there are no colors. # set titlecolor brightwhite,blue # set statuscolor brightwhite,green # set keycolor green diff --git a/src/browser.c b/src/browser.c index 722dc9f6..a97b9f85 100644 --- a/src/browser.c +++ b/src/browser.c @@ -127,8 +127,7 @@ char *do_browser(char *path, DIR *dir) kbinput = get_kbinput(edit, &meta_key, &func_key); #ifndef DISABLE_MOUSE - if (kbinput == KEY_MOUSE) { - + if (kbinput == KEY_MOUSE) { int mouse_x, mouse_y; /* We can click on the edit window to select a diff --git a/src/files.c b/src/files.c index 834bba3d..0fb7708c 100644 --- a/src/files.c +++ b/src/files.c @@ -3133,7 +3133,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos) } /* Didn't find it, make a new node yo! */ - posptr = (poshiststruct *) nmalloc(sizeof(poshiststruct)); + posptr = (poshiststruct *)nmalloc(sizeof(poshiststruct)); posptr->filename = mallocstrcpy(NULL, fullpath); posptr->lineno = lineno; posptr->xno = xpos; @@ -3207,7 +3207,7 @@ void load_poshistory(void) lineno = atoi(lineptr); xno = atoi(xptr); if (poshistory == NULL) { - poshistory = (poshiststruct *) nmalloc(sizeof(poshiststruct)); + poshistory = (poshiststruct *)nmalloc(sizeof(poshiststruct)); poshistory->filename = mallocstrcpy(NULL, line); poshistory->lineno = lineno; poshistory->xno = xno; @@ -3215,7 +3215,7 @@ void load_poshistory(void) } else { for (posptr = poshistory; posptr->next != NULL; posptr = posptr->next) ; - posptr->next = (poshiststruct *) nmalloc(sizeof(poshiststruct)); + posptr->next = (poshiststruct *)nmalloc(sizeof(poshiststruct)); posptr->next->filename = mallocstrcpy(NULL, line); posptr->next->lineno = lineno; posptr->next->xno = xno; diff --git a/src/global.c b/src/global.c index 08370aea..dbaf94e0 100644 --- a/src/global.c +++ b/src/global.c @@ -344,7 +344,7 @@ void add_to_sclist(int menu, const char *scstring, void (*func)(void), int toggl sc *s; if (sclist == NULL) { - sclist = (sc *) nmalloc(sizeof(sc)); + sclist = (sc *)nmalloc(sizeof(sc)); s = sclist; s->next = NULL; } else { diff --git a/src/nano.c b/src/nano.c index d495ab39..9f782608 100644 --- a/src/nano.c +++ b/src/nano.c @@ -616,7 +616,7 @@ void finish(void) if (!no_rcfiles && ISSET(HISTORYLOG)) save_history(); if (!no_rcfiles && ISSET(POS_HISTORY)) { - update_poshistory(openfile->filename, openfile->current->lineno, xplustabs()+1); + update_poshistory(openfile->filename, openfile->current->lineno, xplustabs() + 1); save_poshistory(); } #endif @@ -1825,7 +1825,7 @@ int do_mouse(void) void alloc_multidata_if_needed(filestruct *fileptr) { if (!fileptr->multidata) - fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short)); + fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short)); } /* Precalculate the multi-line start and end regex info so we can diff --git a/src/text.c b/src/text.c index 29d9fb07..66142d3c 100644 --- a/src/text.c +++ b/src/text.c @@ -1011,7 +1011,7 @@ void update_undo(undo_type action) #endif char *char_buf = charalloc(mb_cur_max()); size_t char_buf_len = parse_mbchar(&fs->current->data[u->mark_begin_x], char_buf, NULL); - u->strdata = addstrings(u->strdata, u->strdata?strlen(u->strdata):0, char_buf, char_buf_len); + u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0, char_buf, char_buf_len); #ifdef DEBUG fprintf(stderr, "current undo data now \"%s\"\n", u->strdata); #endif @@ -1022,11 +1022,11 @@ void update_undo(undo_type action) case DEL: { char *char_buf = charalloc(mb_cur_max()); size_t char_buf_len = parse_mbchar(&fs->current->data[fs->current_x], char_buf, NULL); - if (fs->current_x == u->begin) { + if (fs->current_x == u->begin) { /* They're deleting. */ u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_buf_len); u->mark_begin_x = fs->current_x; - } else if (fs->current_x == u->begin - char_buf_len){ + } else if (fs->current_x == u->begin - char_buf_len) { /* They're backspacing. */ u->strdata = addstrings(char_buf, char_buf_len, u->strdata, strlen(u->strdata)); u->begin = fs->current_x; diff --git a/src/utils.c b/src/utils.c index 3aab3fc0..de565e89 100644 --- a/src/utils.c +++ b/src/utils.c @@ -261,7 +261,8 @@ bool regexp_bol_or_eol(const regex_t *preg, const char *string) /* Fix the regex if we're on platforms which require an adjustment * from GNU-style to BSD-style word boundaries. */ -const char *fixbounds(const char *r) { +const char *fixbounds(const char *r) +{ #ifndef GNU_WORDBOUNDS int i, j = 0; char *r2 = charalloc(strlen(r) * 5); @@ -272,15 +273,15 @@ const char *fixbounds(const char *r) { #endif for (i = 0; i < strlen(r); i++) { - if (r[i] != '\0' && r[i] == '\\' && (r[i+1] == '>' || r[i+1] == '<')) { - strcpy(&r2[j], "[[:"); - r2[j+3] = r[i+1]; - strcpy(&r2[j+4], ":]]"); - i++; - j += 6; - } else - r2[j] = r[i]; - j++; + if (r[i] != '\0' && r[i] == '\\' && (r[i + 1] == '>' || r[i + 1] == '<')) { + strcpy(&r2[j], "[[:"); + r2[j + 3] = r[i + 1]; + strcpy(&r2[j + 4], ":]]"); + i++; + j += 6; + } else + r2[j] = r[i]; + j++; } r2[j] = '\0'; r3 = mallocstrcpy(NULL, r2); diff --git a/src/winio.c b/src/winio.c index 0357b934..b5a66149 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1053,7 +1053,7 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len) break; case '6': /* Esc [ 6 ~ == PageDown on VT220/VT320/ * Linux console/xterm/Terminal; - * Esc [ 6 ^ == PageDown on Eterm. */ + * Esc [ 6 ^ == PageDown on Eterm. */ retval = sc_seq_or(do_page_down, 0); break; case '7': /* Esc [ 7 ~ == Home on rxvt. */ @@ -2495,10 +2495,11 @@ void edit_draw(filestruct *fileptr, const char *converted, int /* First simply paint the line -- then we'll add colors or the * marking highlight on just the pieces that need it. */ mvwaddstr(edit, line, 0, converted); - /* Tell ncurses to really redraw the line without trying to optimize - for what it thinks is already there, because it gets it wrong in - the case of a wide character in column zero. See bug #31743. */ + #ifndef USE_SLANG + /* Tell ncurses to really redraw the line without trying to optimize + * for what it thinks is already there, because it gets it wrong in + * the case of a wide character in column zero. See bug #31743. */ wredrawln(edit, line, 1); #endif @@ -2508,13 +2509,15 @@ void edit_draw(filestruct *fileptr, const char *converted, int if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) { const colortype *tmpcolor = openfile->colorstrings; - /* Set up multi-line color data for this line if it's not yet calculated. */ - if (fileptr->multidata == NULL && openfile->syntax + /* Set up multi-line color data for this line if it's not yet + * calculated. */ + if (fileptr->multidata == NULL && openfile->syntax && openfile->syntax->nmultis > 0) { int i; - fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short)); - for (i = 0; i < openfile->syntax->nmultis; i++) - fileptr->multidata[i] = -1; /* Assume this applies until we know otherwise. */ + fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short)); + for (i = 0; i < openfile->syntax->nmultis; i++) + /* Assume this applies until we know otherwise. */ + fileptr->multidata[i] = -1; } for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) { int x_start; @@ -2601,7 +2604,8 @@ void edit_draw(filestruct *fileptr, const char *converted, int short md = fileptr->multidata[tmpcolor->id]; if (md == -1) - fileptr->multidata[tmpcolor->id] = CNONE; /* until we find out otherwise */ + /* Assume this until we know otherwise. */ + fileptr->multidata[tmpcolor->id] = CNONE; else if (md == CNONE) goto end_of_loop; else if (md == CWHOLELINE) { -- 2.39.5