diff --git a/ChangeLog b/ChangeLog index 81e067ae..cd831402 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ 'file_bot' from copy_from_filestruct(), and rename the other. * src/*: Remove the unused parameter 'func_key' from get_shortcut(), and subsequently from parse_browser_input() and parse_help_input(). + * src/*: Whitespace adjustments, plus a few comment tweaks. 2014-04-13 Benno Schulenberg * proto.h, global.c, rcfile.c: Remove the unused parameter 'menu' diff --git a/src/color.c b/src/color.c index 93bf05e5..737dba95 100644 --- a/src/color.c +++ b/src/color.c @@ -161,9 +161,9 @@ void color_update(void) if (stat(openfile->filename, &fileinfo) == 0) { m = magic_open(MAGIC_SYMLINK | #ifdef DEBUG - MAGIC_DEBUG | MAGIC_CHECK | + MAGIC_DEBUG | MAGIC_CHECK | #endif - MAGIC_ERROR); + MAGIC_ERROR); if (m == NULL || magic_load(m, NULL) < 0) statusbar(_("magic_load() failed: %s"), strerror(errno)); else { @@ -171,7 +171,7 @@ void color_update(void) if (magicstring == NULL) { magicerr = magic_error(m); statusbar(_("magic_file(%s) failed: %s"), openfile->filename, magicerr); - } + } #ifdef DEBUG fprintf(stderr, "magic string returned: %s\n", magicstring); #endif @@ -395,8 +395,8 @@ void reset_multis(filestruct *fileptr, bool force) /* Figure out where the first begin and end are to determine if * things changed drastically for the precalculated multi values. */ - nobegin = regexec(tmpcolor->start, fileptr->data, 1, &startmatch, 0); - noend = regexec(tmpcolor->end, fileptr->data, 1, &endmatch, 0); + nobegin = regexec(tmpcolor->start, fileptr->data, 1, &startmatch, 0); + noend = regexec(tmpcolor->end, fileptr->data, 1, &endmatch, 0); if (fileptr->multidata[tmpcolor->id] == CWHOLELINE) { if (nobegin && noend) continue; diff --git a/src/cut.c b/src/cut.c index 9ea2321e..03c4843a 100644 --- a/src/cut.c +++ b/src/cut.c @@ -125,7 +125,7 @@ void do_cut_text( * it. */ size_t cb_save_len = 0; /* The length of the string at the current end of the cutbuffer, - * before we add text to it. */ + * before we add text to it. */ bool old_no_newlines = ISSET(NO_NEWLINES); #endif @@ -264,7 +264,7 @@ void do_uncut_text(void) return; #ifndef NANO_TINY - update_undo(UNCUT); + update_undo(UNCUT); #endif /* Add a copy of the text in the cutbuffer to the current filestruct diff --git a/src/files.c b/src/files.c index 6ce73034..e5444b6b 100644 --- a/src/files.c +++ b/src/files.c @@ -1476,11 +1476,11 @@ char *safe_tempfile(FILE **f) /* If $TMPDIR is unset, empty, or not a writable directory, and * full_tempdir is NULL, try P_tmpdir instead. */ - if (full_tempdir == NULL) + if (full_tempdir == NULL) full_tempdir = check_writable_directory(P_tmpdir); - /* if P_tmpdir is NULL, use /tmp. */ - if (full_tempdir == NULL) + /* if P_tmpdir is NULL, use /tmp. */ + if (full_tempdir == NULL) full_tempdir = mallocstrcpy(NULL, "/tmp/"); full_tempdir = charealloc(full_tempdir, strlen(full_tempdir) + 12); diff --git a/src/help.c b/src/help.c index 7d3c7c9e..e1b9c6fa 100644 --- a/src/help.c +++ b/src/help.c @@ -47,8 +47,8 @@ void do_help(void (*refresh_func)(void)) /* The line number in help_text of the last help line. This * variable is zero-based. */ #ifndef DISABLE_MOUSE - /* The current shortcut list. */ int oldmenu = currmenu; + /* The menu we were called from. */ #endif const char *ptr; /* The current line of the help text. */ @@ -129,11 +129,10 @@ void do_help(void (*refresh_func)(void)) kbinput = get_kbinput(edit, &meta_key, &func_key); #ifndef DISABLE_MOUSE - if (kbinput == KEY_MOUSE) { + if (kbinput == KEY_MOUSE) { int mouse_x, mouse_y; get_mouseinput(&mouse_x, &mouse_y, TRUE); - continue; - /* Redraw the screen. */ + continue; /* Redraw the screen. */ } #endif @@ -141,7 +140,7 @@ void do_help(void (*refresh_func)(void)) s = get_shortcut(MHELP, &kbinput, &meta_key); if (!s) continue; - f = sctofunc((sc *) s); + f = sctofunc((sc *) s); if (!f) continue; @@ -388,7 +387,7 @@ void help_init(void) * which fill 24 columns, plus translated text, plus one or two * \n's. */ for (f = allfuncs; f != NULL; f = f->next) - if (f->menus & currmenu) + if (f->menus & currmenu) allocsize += (24 * mb_cur_max()) + strlen(f->help) + 2; #ifndef NANO_TINY @@ -399,7 +398,7 @@ void help_init(void) size_t endis_len = strlen(_("enable/disable")); for (s = sclist; s != NULL; s = s->next) - if (s->scfunc == do_toggle_void) + if (s->scfunc == do_toggle_void) allocsize += strlen(_(flagtostr(s->toggle))) + endis_len + 9; } @@ -425,26 +424,26 @@ void help_init(void) /* Now add our shortcut info. */ for (f = allfuncs; f != NULL; f = f->next) { - if ((f->menus & currmenu) == 0) + if ((f->menus & currmenu) == 0) continue; - if (!f->desc || !strcmp(f->desc, "")) + if (!f->desc || !strcmp(f->desc, "")) continue; - /* Let's just try and use the first 3 shortcuts from the new - * struct... */ - for (s = sclist, scsfound = 0; s != NULL; s = s->next) { + /* Let's just try and use the first 3 shortcuts from the new + * struct... */ + for (s = sclist, scsfound = 0; s != NULL; s = s->next) { - if (scsfound == 3) + if (scsfound == 3) continue; - if (s->type == RAWINPUT) + if (s->type == RAWINPUT) continue; if ((s->menu & currmenu) == 0) continue; - if (s->scfunc == f->scfunc) { + if (s->scfunc == f->scfunc) { scsfound++; if (scsfound == 1) @@ -455,7 +454,7 @@ void help_init(void) } } /* Pad with tabs if we didn't find 3. */ - for (; scsfound < 3; scsfound++) { + for (; scsfound < 3; scsfound++) { *(ptr++) = '\t'; } @@ -469,8 +468,8 @@ void help_init(void) #ifndef NANO_TINY /* And the toggles... */ if (currmenu == MMAIN) - for (s = sclist; s != NULL; s = s->next) - if (s->scfunc == do_toggle_void) + for (s = sclist; s != NULL; s = s->next) + if (s->scfunc == do_toggle_void) ptr += sprintf(ptr, "(%s)\t\t\t%s %s\n", s->keystr, _(flagtostr(s->toggle)), _("enable/disable")); diff --git a/src/nano.h b/src/nano.h index 3b73db52..85e97dba 100644 --- a/src/nano.h +++ b/src/nano.h @@ -214,7 +214,7 @@ typedef struct colortype { /* The compiled end (if any) of the regex string. */ struct colortype *next; /* Next set of colors. */ - int id; + int id; /* Basic id for assigning to lines later. */ } colortype; diff --git a/src/prompt.c b/src/prompt.c index 67d914da..367c1a45 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -1278,7 +1278,7 @@ int do_yesno_prompt(bool all, const char *msg) blank_statusbar(); mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1)); - wattroff(bottomwin, reverse_attr); + wattroff(bottomwin, reverse_attr); /* Refresh the edit window and the statusbar before getting * input. */ diff --git a/src/rcfile.c b/src/rcfile.c index 977c13f7..9742574c 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -454,7 +454,7 @@ int check_bad_binding(sc *s) int i; for (i = 0; i < BADLISTLEN; i++) - if (s->type == badtypes[i] && s->seq == badseqs[i]) + if (s->type == badtypes[i] && s->seq == badseqs[i]) return 1; return 0; @@ -563,7 +563,7 @@ void parse_binding(char *ptr, bool dobind) /* Now find and delete any existing same shortcut in the menu(s). */ for (s = sclist; s != NULL; s = s->next) { - if (((s->menu & menu)) && !strcmp(s->keystr, keycopy)) { + if (((s->menu & menu)) && !strcmp(s->keystr, keycopy)) { #ifdef DEBUG fprintf(stderr, "deleting entry from menu %x\n", s->menu); #endif diff --git a/src/search.c b/src/search.c index 3f200e8e..9a5a37c7 100644 --- a/src/search.c +++ b/src/search.c @@ -307,10 +307,10 @@ bool findnextstr( /* Look for needle in the current line we're searching. */ enable_nodelay(); while (TRUE) { - if (time(NULL) - lastkbcheck > 1) { - lastkbcheck = time(NULL); + if (time(NULL) - lastkbcheck > 1) { + lastkbcheck = time(NULL); f = getfuncfromkey(edit); - if (f && f->scfunc == do_cancel) { + if (f && f->scfunc == do_cancel) { statusbar(_("Cancelled")); return FALSE; } @@ -361,7 +361,7 @@ bool findnextstr( /* We've finished processing the file, so get out. */ if (search_last_line) { not_found_msg(needle); - disable_nodelay(); + disable_nodelay(); return FALSE; } @@ -580,7 +580,7 @@ void do_research(void) #endif } } else - statusbar(_("No current search pattern")); + statusbar(_("No current search pattern")); openfile->placewewant = xplustabs(); edit_redraw(fileptr, pww_save); diff --git a/src/text.c b/src/text.c index 3a6e42be..b24530ec 100644 --- a/src/text.c +++ b/src/text.c @@ -550,12 +550,11 @@ void do_undo(void) u->strdata = f->data; f->data = data; break; - default: undidmsg = _("Internal error: unknown type. Please save your work."); break; - } + renumber(f); do_gotolinecolumn(u->lineno, u->begin, FALSE, FALSE, FALSE, TRUE); statusbar(_("Undid action (%s)"), undidmsg); @@ -669,14 +668,13 @@ void do_redo(void) default: undidmsg = _("Internal error: unknown type. Please save your work."); break; - } + do_gotolinecolumn(u->lineno, u->begin, FALSE, FALSE, FALSE, TRUE); statusbar(_("Redid action (%s)"), undidmsg); openfile->current_undo = u; openfile->last_action = OTHER; - } #endif /* !NANO_TINY */ @@ -1361,7 +1359,7 @@ ssize_t break_line(const char *line, ssize_t goal { ssize_t blank_loc = -1; /* Current tentative return value. Index of the last blank we - * found with short enough display width. */ + * found with short enough display width. */ ssize_t cur_loc = 0; /* Current index in line. */ size_t cur_pos = 0; diff --git a/src/utils.c b/src/utils.c index 75135001..5d59eb99 100644 --- a/src/utils.c +++ b/src/utils.c @@ -259,8 +259,8 @@ bool regexp_bol_or_eol(const regex_t *preg, const char *string) REG_NOMATCH); } -/* Fix the regex if we're on platforms which requires an adjustment - * from GNU-style to BSD-style word boundaries. */ +/* 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) { #ifndef GNU_WORDBOUNDS int i, j = 0; diff --git a/src/winio.c b/src/winio.c index 348b05df..a4f8d4ea 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2496,13 +2496,13 @@ 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 */ + /* 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; /* Assue this applies until we know otherwise */ + fileptr->multidata[i] = -1; /* Assume this applies until we know otherwise. */ } for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) { int x_start;