More editing of comment blocks and trimming of blank lines.

Patch by David Lawrence Ramsey, slightly tweaked.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4753 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2014-04-08 18:38:45 +00:00
parent 598c654294
commit d19be5aafa
10 changed files with 68 additions and 77 deletions

View File

@ -1,3 +1,6 @@
2014-04-08 David Lawrence Ramsey <pooka109@gmail.com>
* src/*.c: More editing of comment blocks and trimming of blank lines.
2014-04-08 Benno Schulenberg <bensberg@justemail.net> 2014-04-08 Benno Schulenberg <bensberg@justemail.net>
* src/rcfile.c: Correct two comments, and tweak two others. * src/rcfile.c: Correct two comments, and tweak two others.
* src/color.c (color_update): Correct one comment, tweak some others, * src/color.c (color_update): Correct one comment, tweak some others,

View File

@ -1810,10 +1810,11 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
_("Too many backup files?")); _("Too many backup files?"));
free(backuptemp); free(backuptemp);
free(backupname); free(backupname);
/* If we can't write to the backup, DONT go on, since /* If we can't write to the backup, DON'T go on, since
whatever caused the backup file to fail (e.g. disk * whatever caused the backup file to fail (e.g. disk
full may well cause the real file write to fail, which * full may well cause the real file write to fail,
means we could lose both the backup and the original! */ * which means we could lose both the backup and the
* original! */
goto cleanup_and_exit; goto cleanup_and_exit;
} else { } else {
free(backupname); free(backupname);
@ -1825,8 +1826,8 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
} }
/* First, unlink any existing backups. Next, open the backup /* First, unlink any existing backups. Next, open the backup
file with O_CREAT and O_EXCL. If it succeeds, we * file with O_CREAT and O_EXCL. If it succeeds, we have a file
have a file descriptor to a new backup file. */ * descriptor to a new backup file. */
if (unlink(backupname) < 0 && errno != ENOENT && !ISSET(INSECURE_BACKUP)) { if (unlink(backupname) < 0 && errno != ENOENT && !ISSET(INSECURE_BACKUP)) {
if (prompt_failed_backupwrite(backupname)) if (prompt_failed_backupwrite(backupname))
goto skip_backup; goto skip_backup;
@ -1844,7 +1845,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
backup_fd = open(backupname, backup_cflags, backup_fd = open(backupname, backup_cflags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
/* Now we've got a safe file stream. If the previous open() /* Now we've got a safe file stream. If the previous open()
call failed, this will return NULL. */ * call failed, this will return NULL. */
backup_file = fdopen(backup_fd, "wb"); backup_file = fdopen(backup_fd, "wb");
if (backup_fd < 0 || backup_file == NULL) { if (backup_fd < 0 || backup_file == NULL) {
@ -1903,10 +1904,10 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
goto skip_backup; goto skip_backup;
statusbar(_("Error writing backup file %s: %s"), backupname, statusbar(_("Error writing backup file %s: %s"), backupname,
strerror(errno)); strerror(errno));
/* If we can't write to the backup, DONT go on, since /* If we can't write to the backup, DON'T go on, since
whatever caused the backup file to fail (e.g. disk * whatever caused the backup file to fail (e.g. disk full
full may well cause the real file write to fail, which * may well cause the real file write to fail, which means
means we could lose both the backup and the original! */ * we could lose both the backup and the original! */
goto cleanup_and_exit; goto cleanup_and_exit;
} }
@ -2404,8 +2405,9 @@ bool do_writeout(bool exiting)
} }
} }
#ifndef NANO_TINY #ifndef NANO_TINY
/* Complain if the file exists, the name hasn't changed, and the /* Complain if the file exists, the name hasn't changed,
stat information we had before does not match what we have now */ * and the stat information we had before does not match
* what we have now. */
else if (name_exists && openfile->current_stat && (openfile->current_stat->st_mtime < st.st_mtime || else if (name_exists && openfile->current_stat && (openfile->current_stat->st_mtime < st.st_mtime ||
openfile->current_stat->st_dev != st.st_dev || openfile->current_stat->st_ino != st.st_ino)) { openfile->current_stat->st_dev != st.st_dev || openfile->current_stat->st_ino != st.st_ino)) {
i = do_yesno_prompt(FALSE, i = do_yesno_prompt(FALSE,
@ -2926,8 +2928,6 @@ char *poshistfilename(void)
return construct_filename("/.nano/filepos_history"); return construct_filename("/.nano/filepos_history");
} }
void history_error(const char *msg, ...) void history_error(const char *msg, ...)
{ {
va_list ap; va_list ap;
@ -2980,8 +2980,6 @@ void load_history(void)
legacyhist, nanohist); legacyhist, nanohist);
} }
/* Assume do_rcfile() has reported a missing home directory. */ /* Assume do_rcfile() has reported a missing home directory. */
if (nanohist != NULL) { if (nanohist != NULL) {
FILE *hist = fopen(nanohist, "rb"); FILE *hist = fopen(nanohist, "rb");
@ -3136,7 +3134,6 @@ 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;
@ -3175,7 +3172,6 @@ int check_poshistory(const char *file, ssize_t *line, ssize_t *column)
return 0; return 0;
} }
/* Load histories from ~/.nano_history. */ /* Load histories from ~/.nano_history. */
void load_poshistory(void) void load_poshistory(void)
{ {

View File

@ -1295,8 +1295,8 @@ const subnfunc *sctofunc(sc *s)
} }
#ifndef NANO_TINY #ifndef NANO_TINY
/* Now let's come up with a single (hopefully) /* Now let's come up with a single (hopefully) function to get a string
* function to get a string for each flag. */ * for each flag. */
const char *flagtostr(int flag) const char *flagtostr(int flag)
{ {
switch (flag) { switch (flag) {
@ -1340,8 +1340,8 @@ const char *flagtostr(int flag)
} }
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
/* Interpret the string given by the rc file and return a /* Interpret the string given by the rc file and return a shortcut
* shortcut struct, complete with proper value for execute. */ * struct, complete with proper value for execute. */
sc *strtosc(int menu, char *input) sc *strtosc(int menu, char *input)
{ {
sc *s; sc *s;

View File

@ -1130,7 +1130,7 @@ void do_exit(void)
display_main_list(); display_main_list();
} }
/* Another placeholder for function mapping */ /* Another placeholder for function mapping. */
void do_cancel(void) void do_cancel(void)
{ {
; ;
@ -1453,10 +1453,10 @@ void do_toggle(int flag)
statusbar("%s %s", desc, enabled ? _("enabled") : _("disabled")); statusbar("%s %s", desc, enabled ? _("enabled") : _("disabled"));
} }
/* Bleh */ /* Bleh. */
void do_toggle_void(void) void do_toggle_void(void)
{ {
; ;
} }
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
@ -1903,7 +1903,6 @@ void precalc_multicolorinfo(void)
/* Nice, we didn't find the end regex on this line. Let's start looking for it. */ /* Nice, we didn't find the end regex on this line. Let's start looking for it. */
for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) { for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "advancing to line %lu to find end...\n", (unsigned long) endptr->lineno); fprintf(stderr, "advancing to line %lu to find end...\n", (unsigned long) endptr->lineno);
#endif #endif
@ -2791,4 +2790,3 @@ int main(int argc, char **argv)
/* We should never get here. */ /* We should never get here. */
assert(FALSE); assert(FALSE);
} }

View File

@ -220,12 +220,11 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
'\0' || currmenu != MWRITEFILE) '\0' || currmenu != MWRITEFILE)
do_statusbar_backspace(); do_statusbar_backspace();
} else { } else {
/* Handle the normal statusbar prompt shortcuts, setting /* Handle the normal statusbar prompt shortcuts, setting
* ran_func to TRUE if we try to run their associated * ran_func to TRUE if we try to run their associated
* functions and setting finished to TRUE to indicate * functions and setting finished to TRUE to indicate
* that we're done after running or trying to run their * that we're done after running or trying to run their
* associated functions. */ * associated functions. */
f = sctofunc((sc *) s); f = sctofunc((sc *) s);
if (s->scfunc != 0 && s->execute == TRUE) { if (s->scfunc != 0 && s->execute == TRUE) {
*ran_func = TRUE; *ran_func = TRUE;

View File

@ -825,7 +825,7 @@ extern const char *regexp_msg;
void do_credits(void); void do_credits(void);
#endif #endif
/* May as just throw these here since they are just placeholders */ /* May as well throw these here, since they are just placeholders. */
void do_cancel(void); void do_cancel(void);
void do_page_up(void); void do_page_up(void);
void do_page_down(void); void do_page_down(void);
@ -844,5 +844,4 @@ void goto_dir_void(void);
void no_replace_void(void); void no_replace_void(void);
void ext_cmd_void(void); void ext_cmd_void(void);
#endif /* !PROTO_H */ #endif /* !PROTO_H */

View File

@ -518,7 +518,7 @@ void parse_binding(char *ptr, bool dobind)
ptr = parse_next_word(ptr); ptr = parse_next_word(ptr);
if (!strcmp(menuptr, "")) { if (!strcmp(menuptr, "")) {
/* TRANSLATORS: do not translate the word "all". */ /* TRANSLATORS: Do not translate the word "all". */
rcfile_error(N_("Must specify menu in which to bind/unbind key (or \"all\")")); rcfile_error(N_("Must specify menu in which to bind/unbind key (or \"all\")"));
return; return;
} }
@ -586,8 +586,9 @@ static void _parse_include(char *file)
struct stat rcinfo; struct stat rcinfo;
FILE *rcstream; FILE *rcstream;
/* Can't get the specified file's full path cause it may screw up /* Can't get the specified file's full path because it may screw up
our cwd depending on the parent dirs' permissions, (see Savannah bug 25297) */ * our cwd depending on the parent directories' permissions (see
* Savannah bug #25297). */
/* Don't open directories, character files, or block files. */ /* Don't open directories, character files, or block files. */
if (stat(file, &rcinfo) != -1) { if (stat(file, &rcinfo) != -1) {
@ -805,9 +806,10 @@ void parse_colors(char *ptr, bool icase)
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Adding new entry for fg %hd, bg %hd\n", fg, bg); fprintf(stderr, "Adding new entry for fg %hd, bg %hd\n", fg, bg);
#endif #endif
/* Need to recompute endcolor now so we can extend colors to syntaxes */ /* Need to recompute endcolor now so we can extend
* colors to syntaxes. */
for (endcolor = endsyntax->color; endcolor->next != NULL; endcolor = endcolor->next) for (endcolor = endsyntax->color; endcolor->next != NULL; endcolor = endcolor->next)
; ;
endcolor->next = newcolor; endcolor->next = newcolor;
} }
@ -837,8 +839,8 @@ void parse_colors(char *ptr, bool icase)
if (ptr == NULL) if (ptr == NULL)
break; break;
/* If the start regex was invalid, skip past the end regex to /* If the start regex was invalid, skip past the end regex
* stay in sync. */ * to stay in sync. */
if (cancelled) if (cancelled)
continue; continue;
@ -915,7 +917,6 @@ void parse_headers(char *ptr)
} }
} }
/* Parse the linter requested for this syntax. Simple? */ /* Parse the linter requested for this syntax. Simple? */
void parse_linter(char *ptr) void parse_linter(char *ptr)
{ {
@ -943,7 +944,6 @@ void parse_linter(char *ptr)
} }
#endif /* !DISABLE_COLOR */ #endif /* !DISABLE_COLOR */
/* Check whether the user has unmapped every shortcut for a /* Check whether the user has unmapped every shortcut for a
* sequence we consider 'vital', like the exit function. */ * sequence we consider 'vital', like the exit function. */
static void check_vitals_mapped(void) static void check_vitals_mapped(void)
@ -1010,7 +1010,6 @@ void parse_rcfile(FILE *rcstream
keyword = ptr; keyword = ptr;
ptr = parse_next_word(ptr); ptr = parse_next_word(ptr);
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
/* Handle extending first... */ /* Handle extending first... */
if (strcasecmp(keyword, "extendsyntax") == 0) { if (strcasecmp(keyword, "extendsyntax") == 0) {

View File

@ -1432,7 +1432,7 @@ char *get_history_newer(filestruct **h)
return (*h)->data; return (*h)->data;
} }
/* More placeholders */ /* More placeholders. */
void get_history_newer_void(void) void get_history_newer_void(void)
{ {
; ;

View File

@ -359,7 +359,6 @@ void do_unindent(void)
do_indent(-tabsize); do_indent(-tabsize);
} }
/* Undo a cut, or redo an uncut. */ /* Undo a cut, or redo an uncut. */
void undo_cut(undo *u) void undo_cut(undo *u)
{ {
@ -386,7 +385,8 @@ void undo_cut(undo *u)
} }
/* Redo a cut, or undo an uncut. */ /* Redo a cut, or undo an uncut. */
void redo_cut(undo *u) { void redo_cut(undo *u)
{
int i; int i;
filestruct *t, *c; filestruct *t, *c;
@ -400,7 +400,7 @@ void redo_cut(undo *u) {
free(cutbuffer); free(cutbuffer);
cutbuffer = NULL; cutbuffer = NULL;
/* Move ahead the same # lines we had if a marked cut. */ /* Move ahead the same number of lines we had if a marked cut. */
if (u->mark_set) { if (u->mark_set) {
for (i = 1, t = openfile->fileage; i != u->mark_begin_lineno; i++) for (i = 1, t = openfile->fileage; i != u->mark_begin_lineno; i++)
t = t->next; t = t->next;
@ -410,13 +410,12 @@ void redo_cut(undo *u) {
* We'll need to trick nano into thinking it's a marked cut, * We'll need to trick nano into thinking it's a marked cut,
* to cut more than one line again. */ * to cut more than one line again. */
for (c = u->cutbuffer, t = openfile->current; c->next != NULL && t->next != NULL; ) { for (c = u->cutbuffer, t = openfile->current; c->next != NULL && t->next != NULL; ) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Advancing, lineno = %lu, data = \"%s\"\n", (unsigned long) t->lineno, t->data); fprintf(stderr, "Advancing, lineno = %lu, data = \"%s\"\n", (unsigned long) t->lineno, t->data);
#endif #endif
c = c->next; c = c->next;
t = t->next; t = t->next;
} }
openfile->mark_begin = t; openfile->mark_begin = t;
openfile->mark_begin_x = 0; openfile->mark_begin_x = 0;
openfile->mark_set = TRUE; openfile->mark_set = TRUE;
@ -460,7 +459,7 @@ void do_undo(void)
#endif #endif
openfile->current_x = u->begin; openfile->current_x = u->begin;
switch(u->type) { switch (u->type) {
case ADD: case ADD:
undidmsg = _("text add"); undidmsg = _("text add");
len = strlen(f->data) - strlen(u->strdata) + 1; len = strlen(f->data) - strlen(u->strdata) + 1;
@ -598,7 +597,7 @@ void do_redo(void)
fprintf(stderr, "Redo running for type %d\n", u->type); fprintf(stderr, "Redo running for type %d\n", u->type);
#endif #endif
switch(u->type) { switch (u->type) {
case ADD: case ADD:
undidmsg = _("text add"); undidmsg = _("text add");
len = strlen(f->data) + strlen(u->strdata) + 1; len = strlen(f->data) + strlen(u->strdata) + 1;
@ -693,7 +692,6 @@ void do_enter(bool undoing)
if (!undoing) if (!undoing)
add_undo(ENTER); add_undo(ENTER);
/* Do auto-indenting, like the neolithic Turbo Pascal editor. */ /* Do auto-indenting, like the neolithic Turbo Pascal editor. */
if (ISSET(AUTOINDENT)) { if (ISSET(AUTOINDENT)) {
/* If we are breaking the line in the indentation, the new /* If we are breaking the line in the indentation, the new
@ -742,7 +740,8 @@ void do_enter(bool undoing)
} }
/* Need this again... */ /* Need this again... */
void do_enter_void(void) { void do_enter_void(void)
{
do_enter(FALSE); do_enter(FALSE);
} }
@ -845,8 +844,10 @@ void add_undo(undo_type current_action)
undo *u; undo *u;
char *data; char *data;
openfilestruct *fs = openfile; openfilestruct *fs = openfile;
static undo *last_cutu = NULL; /* Last thing we cut to set up the undo for uncut. */ static undo *last_cutu = NULL;
ssize_t wrap_loc; /* For calculating split beginning. */ /* Last thing we cut to set up the undo for uncut. */
ssize_t wrap_loc;
/* For calculating split beginning. */
if (!ISSET(UNDOABLE)) if (!ISSET(UNDOABLE))
return; return;
@ -1085,7 +1086,7 @@ void update_undo(undo_type action)
} }
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Done in udpate_undo (type was %d)\n", action); fprintf(stderr, "Done in update_undo (type was %d)\n", action);
#endif #endif
if (fs->last_action != action) { if (fs->last_action != action) {
#ifdef DEBUG #ifdef DEBUG
@ -3115,11 +3116,13 @@ void do_linter(void)
char *message = mallocstrcpy(NULL, read_buff_word); char *message = mallocstrcpy(NULL, read_buff_word);
/* At the moment we're assuming the following formats: /* At the moment we're assuming the following formats:
filenameorcategory:line:column:message (e.g. splint) *
filenameorcategory:line:message (e.g. pyflakes) * filenameorcategory:line:column:message (e.g. splint)
filenameorcategory:line,col:message (e.g. pylint) * filenameorcategory:line:message (e.g. pyflakes)
This could be turnes into some scanf() based parser but ugh. * filenameorcategory:line,col:message (e.g. pylint)
*/ *
* This could be turned into some scanf() based parser,
* but ugh. */
if ((filename = strtok(read_buff_word, ":")) != NULL) { if ((filename = strtok(read_buff_word, ":")) != NULL) {
if ((linestr = strtok(NULL, ":")) != NULL) { if ((linestr = strtok(NULL, ":")) != NULL) {
if ((maybecol = strtok(NULL, ":")) != NULL) { if ((maybecol = strtok(NULL, ":")) != NULL) {
@ -3135,8 +3138,8 @@ void do_linter(void)
tmpcolno = strtol(maybecol, &convendptr, 10); tmpcolno = strtol(maybecol, &convendptr, 10);
if (*convendptr != '\0') { if (*convendptr != '\0') {
/* Previous field might still be
/* Prev field might still be line,col format */ * line,col format. */
strtok(linestr, ","); strtok(linestr, ",");
if ((tmplinecol = strtok(NULL, ",")) != NULL) if ((tmplinecol = strtok(NULL, ",")) != NULL)
tmpcolno = strtol(tmplinecol, NULL, 10); tmpcolno = strtol(tmplinecol, NULL, 10);
@ -3145,7 +3148,7 @@ void do_linter(void)
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "text.c:do_lint:Successful parse! %d:%d:%s\n", tmplineno, tmpcolno, message); fprintf(stderr, "text.c:do_lint:Successful parse! %d:%d:%s\n", tmplineno, tmpcolno, message);
#endif #endif
/* Nice we have a lint message we can use */ /* Nice. We have a lint message we can use. */
parsesuccess++; parsesuccess++;
tmplint = curlint; tmplint = curlint;
curlint = nmalloc(sizeof(lintstruct)); curlint = nmalloc(sizeof(lintstruct));
@ -3382,4 +3385,3 @@ void do_verbatim_input(void)
free(output); free(output);
} }

View File

@ -1714,7 +1714,6 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
f = f->next; f = f->next;
} }
/* And put back the equivalent key. */ /* And put back the equivalent key. */
if (f != NULL) { if (f != NULL) {
const sc *s = first_sc_for(currmenu, f->scfunc); const sc *s = first_sc_for(currmenu, f->scfunc);
@ -1798,10 +1797,9 @@ const sc *get_shortcut(int menu, int *kbinput, bool
return NULL; return NULL;
} }
/* Try to get a function back from a window. Just a wrapper
/* Try to get a function back from a window. Just a wrapper so * functions need to create a function_key meta_key blah blah
functions to need to create function_key meta_key blah blah * menu - what menu name to look through for valid funcs. */
mmenu - what menu name to look through for valid funcs */
const subnfunc *getfuncfromkey(WINDOW *win) const subnfunc *getfuncfromkey(WINDOW *win)
{ {
int kbinput; int kbinput;
@ -1822,8 +1820,6 @@ const subnfunc *getfuncfromkey(WINDOW *win)
} }
/* Move to (x, y) in win, and display a line of n spaces with the /* Move to (x, y) in win, and display a line of n spaces with the
* current attributes. */ * current attributes. */
void blank_line(WINDOW *win, int y, int x, int n) void blank_line(WINDOW *win, int y, int x, int n)
@ -3372,7 +3368,6 @@ void disable_nodelay(void)
nodelay(edit, FALSE); nodelay(edit, FALSE);
} }
/* Highlight the current word being replaced or spell checked. We /* Highlight the current word being replaced or spell checked. We
* expect word to have tabs and control characters expanded. */ * expect word to have tabs and control characters expanded. */
void do_replace_highlight(bool highlight, const char *word) void do_replace_highlight(bool highlight, const char *word)