1
1

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
Этот коммит содержится в:
Benno Schulenberg 2014-04-08 18:38:45 +00:00
родитель 598c654294
Коммит d19be5aafa
10 изменённых файлов: 68 добавлений и 77 удалений

Просмотреть файл

@ -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>
* src/rcfile.c: Correct two comments, and tweak two others.
* src/color.c (color_update): Correct one comment, tweak some others,

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -1130,7 +1130,7 @@ void do_exit(void)
display_main_list();
}
/* Another placeholder for function mapping */
/* Another placeholder for function mapping. */
void do_cancel(void)
{
;
@ -1453,10 +1453,10 @@ void do_toggle(int flag)
statusbar("%s %s", desc, enabled ? _("enabled") : _("disabled"));
}
/* Bleh */
/* Bleh. */
void do_toggle_void(void)
{
;
;
}
#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. */
for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) {
#ifdef DEBUG
fprintf(stderr, "advancing to line %lu to find end...\n", (unsigned long) endptr->lineno);
#endif
@ -2791,4 +2790,3 @@ int main(int argc, char **argv)
/* We should never get here. */
assert(FALSE);
}

Просмотреть файл

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

Просмотреть файл

@ -825,7 +825,7 @@ extern const char *regexp_msg;
void do_credits(void);
#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_page_up(void);
void do_page_down(void);
@ -844,5 +844,4 @@ void goto_dir_void(void);
void no_replace_void(void);
void ext_cmd_void(void);
#endif /* !PROTO_H */

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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