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
This commit is contained in:
Benno Schulenberg 2014-06-04 16:02:51 +00:00
parent ac1508c49e
commit 1de337de9c
9 changed files with 42 additions and 34 deletions

View File

@ -1,3 +1,7 @@
2014-06-04 David Lawrence Ramsey <pooka109@gmail.com>
* src/*.c: Adjustments of whitespace and comments.
* doc/nanorc.sample.in: Interpunction tweaks.
2014-06-02 Chris Allegretta <chrisa@asty.org> 2014-06-02 Chris Allegretta <chrisa@asty.org>
* doc/syntax/default.nanorc: Can't do trailing spaces in the * doc/syntax/default.nanorc: Can't do trailing spaces in the
default syntax or it will hilight the spaces as you type default syntax or it will hilight the spaces as you type

View File

@ -61,7 +61,7 @@
## Enable vim-style lock-files. This is just to let a vim user know you ## 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 ## 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 # set locking
## The opening and closing brackets that can be found by bracket ## The opening and closing brackets that can be found by bracket
@ -162,7 +162,7 @@
## Convert typed tabs to spaces. ## Convert typed tabs to spaces.
# set tabstospaces # set tabstospaces
## Save automatically on exit, don't prompt. ## Save automatically on exit; don't prompt.
# set tempfile # set tempfile
## Enable the new (EXPERIMENTAL) generic undo code, not just for line ## Enable the new (EXPERIMENTAL) generic undo code, not just for line
@ -186,7 +186,7 @@
## Paint the interface elements of nano. ## 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 titlecolor brightwhite,blue
# set statuscolor brightwhite,green # set statuscolor brightwhite,green
# set keycolor green # set keycolor green

View File

@ -127,8 +127,7 @@ char *do_browser(char *path, DIR *dir)
kbinput = get_kbinput(edit, &meta_key, &func_key); kbinput = get_kbinput(edit, &meta_key, &func_key);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
if (kbinput == KEY_MOUSE) { if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y; int mouse_x, mouse_y;
/* We can click on the edit window to select a /* We can click on the edit window to select a

View File

@ -3133,7 +3133,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
} }
/* Didn't find it, make a new node yo! */ /* 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->filename = mallocstrcpy(NULL, fullpath);
posptr->lineno = lineno; posptr->lineno = lineno;
posptr->xno = xpos; posptr->xno = xpos;
@ -3207,7 +3207,7 @@ void load_poshistory(void)
lineno = atoi(lineptr); lineno = atoi(lineptr);
xno = atoi(xptr); xno = atoi(xptr);
if (poshistory == NULL) { if (poshistory == NULL) {
poshistory = (poshiststruct *) nmalloc(sizeof(poshiststruct)); poshistory = (poshiststruct *)nmalloc(sizeof(poshiststruct));
poshistory->filename = mallocstrcpy(NULL, line); poshistory->filename = mallocstrcpy(NULL, line);
poshistory->lineno = lineno; poshistory->lineno = lineno;
poshistory->xno = xno; poshistory->xno = xno;
@ -3215,7 +3215,7 @@ void load_poshistory(void)
} else { } else {
for (posptr = poshistory; posptr->next != NULL; posptr = posptr->next) 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->filename = mallocstrcpy(NULL, line);
posptr->next->lineno = lineno; posptr->next->lineno = lineno;
posptr->next->xno = xno; posptr->next->xno = xno;

View File

@ -344,7 +344,7 @@ void add_to_sclist(int menu, const char *scstring, void (*func)(void), int toggl
sc *s; sc *s;
if (sclist == NULL) { if (sclist == NULL) {
sclist = (sc *) nmalloc(sizeof(sc)); sclist = (sc *)nmalloc(sizeof(sc));
s = sclist; s = sclist;
s->next = NULL; s->next = NULL;
} else { } else {

View File

@ -616,7 +616,7 @@ void finish(void)
if (!no_rcfiles && ISSET(HISTORYLOG)) if (!no_rcfiles && ISSET(HISTORYLOG))
save_history(); save_history();
if (!no_rcfiles && ISSET(POS_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(); save_poshistory();
} }
#endif #endif
@ -1825,7 +1825,7 @@ int do_mouse(void)
void alloc_multidata_if_needed(filestruct *fileptr) void alloc_multidata_if_needed(filestruct *fileptr)
{ {
if (!fileptr->multidata) 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 /* Precalculate the multi-line start and end regex info so we can

View File

@ -1011,7 +1011,7 @@ void update_undo(undo_type action)
#endif #endif
char *char_buf = charalloc(mb_cur_max()); char *char_buf = charalloc(mb_cur_max());
size_t char_buf_len = parse_mbchar(&fs->current->data[u->mark_begin_x], char_buf, NULL); 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 #ifdef DEBUG
fprintf(stderr, "current undo data now \"%s\"\n", u->strdata); fprintf(stderr, "current undo data now \"%s\"\n", u->strdata);
#endif #endif
@ -1022,11 +1022,11 @@ void update_undo(undo_type action)
case DEL: { case DEL: {
char *char_buf = charalloc(mb_cur_max()); char *char_buf = charalloc(mb_cur_max());
size_t char_buf_len = parse_mbchar(&fs->current->data[fs->current_x], char_buf, NULL); 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. */ /* They're deleting. */
u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_buf_len); u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_buf_len);
u->mark_begin_x = fs->current_x; 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. */ /* They're backspacing. */
u->strdata = addstrings(char_buf, char_buf_len, u->strdata, strlen(u->strdata)); u->strdata = addstrings(char_buf, char_buf_len, u->strdata, strlen(u->strdata));
u->begin = fs->current_x; u->begin = fs->current_x;

View File

@ -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 /* Fix the regex if we're on platforms which require an adjustment
* from GNU-style to BSD-style word boundaries. */ * from GNU-style to BSD-style word boundaries. */
const char *fixbounds(const char *r) { const char *fixbounds(const char *r)
{
#ifndef GNU_WORDBOUNDS #ifndef GNU_WORDBOUNDS
int i, j = 0; int i, j = 0;
char *r2 = charalloc(strlen(r) * 5); char *r2 = charalloc(strlen(r) * 5);
@ -272,15 +273,15 @@ const char *fixbounds(const char *r) {
#endif #endif
for (i = 0; i < strlen(r); i++) { for (i = 0; i < strlen(r); i++) {
if (r[i] != '\0' && r[i] == '\\' && (r[i+1] == '>' || r[i+1] == '<')) { if (r[i] != '\0' && r[i] == '\\' && (r[i + 1] == '>' || r[i + 1] == '<')) {
strcpy(&r2[j], "[[:"); strcpy(&r2[j], "[[:");
r2[j+3] = r[i+1]; r2[j + 3] = r[i + 1];
strcpy(&r2[j+4], ":]]"); strcpy(&r2[j + 4], ":]]");
i++; i++;
j += 6; j += 6;
} else } else
r2[j] = r[i]; r2[j] = r[i];
j++; j++;
} }
r2[j] = '\0'; r2[j] = '\0';
r3 = mallocstrcpy(NULL, r2); r3 = mallocstrcpy(NULL, r2);

View File

@ -1053,7 +1053,7 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
break; break;
case '6': /* Esc [ 6 ~ == PageDown on VT220/VT320/ case '6': /* Esc [ 6 ~ == PageDown on VT220/VT320/
* Linux console/xterm/Terminal; * Linux console/xterm/Terminal;
* Esc [ 6 ^ == PageDown on Eterm. */ * Esc [ 6 ^ == PageDown on Eterm. */
retval = sc_seq_or(do_page_down, 0); retval = sc_seq_or(do_page_down, 0);
break; break;
case '7': /* Esc [ 7 ~ == Home on rxvt. */ 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 /* First simply paint the line -- then we'll add colors or the
* marking highlight on just the pieces that need it. */ * marking highlight on just the pieces that need it. */
mvwaddstr(edit, line, 0, converted); 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 #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); wredrawln(edit, line, 1);
#endif #endif
@ -2508,13 +2509,15 @@ void edit_draw(filestruct *fileptr, const char *converted, int
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) { if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) {
const colortype *tmpcolor = openfile->colorstrings; 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
if (fileptr->multidata == NULL && openfile->syntax * calculated. */
if (fileptr->multidata == NULL && openfile->syntax
&& openfile->syntax->nmultis > 0) { && openfile->syntax->nmultis > 0) {
int i; int i;
fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short)); fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
for (i = 0; i < openfile->syntax->nmultis; i++) for (i = 0; i < openfile->syntax->nmultis; i++)
fileptr->multidata[i] = -1; /* Assume this applies until we know otherwise. */ /* Assume this applies until we know otherwise. */
fileptr->multidata[i] = -1;
} }
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) { for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
int x_start; int x_start;
@ -2601,7 +2604,8 @@ void edit_draw(filestruct *fileptr, const char *converted, int
short md = fileptr->multidata[tmpcolor->id]; short md = fileptr->multidata[tmpcolor->id];
if (md == -1) 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) else if (md == CNONE)
goto end_of_loop; goto end_of_loop;
else if (md == CWHOLELINE) { else if (md == CWHOLELINE) {