Rewrapping some lines and tweaking two comments.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5368 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2015-08-29 20:14:57 +00:00
parent 213294e69c
commit 459d9f8ba8
2 changed files with 35 additions and 47 deletions

View File

@ -1,5 +1,6 @@
2015-08-29 Benno Schulenberg <bensberg@justemail.net> 2015-08-29 Benno Schulenberg <bensberg@justemail.net>
* doc/syntax/autoconf.nanor: New file; syntax colouring for Autoconf. * doc/syntax/autoconf.nanor: New file; syntax colouring for Autoconf.
* src/files.c: Rewrap some lines and tweak two comments.
2015-08-16 Benno Schulenberg <bensberg@justemail.net> 2015-08-16 Benno Schulenberg <bensberg@justemail.net>
* src/help.c (help_init, help_line_len): Avoid wide paragraphs of text * src/help.c (help_init, help_line_len): Avoid wide paragraphs of text

View File

@ -808,11 +808,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
/* Tack the text at fileptr onto the beginning of the text /* Tack the text at fileptr onto the beginning of the text
* at current. */ * at current. */
openfile->current->data = openfile->current->data = charealloc(openfile->current->data,
charealloc(openfile->current->data, len + len + current_len + 1);
charmove(openfile->current->data + len, openfile->current->data,
current_len + 1); current_len + 1);
charmove(openfile->current->data + len,
openfile->current->data, current_len + 1);
strncpy(openfile->current->data, fileptr->data, len); strncpy(openfile->current->data, fileptr->data, len);
/* Don't destroy fileage, edittop, or filebot! */ /* Don't destroy fileage, edittop, or filebot! */
@ -840,8 +839,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
renumber(openfile->current); renumber(openfile->current);
} }
openfile->totsize += get_totsize(openfile->fileage, openfile->totsize += get_totsize(openfile->fileage, openfile->filebot);
openfile->filebot);
/* If the NO_NEWLINES flag isn't set, and text has been added to /* If the NO_NEWLINES flag isn't set, and text has been added to
* the magicline (i.e. a file that doesn't end in a newline has been * the magicline (i.e. a file that doesn't end in a newline has been
@ -928,11 +926,10 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
/* Okay, if we can't stat the path due to a component's /* Okay, if we can't stat the path due to a component's
* permissions, just try the relative one. */ * permissions, just try the relative one. */
if (full_filename == NULL if (full_filename == NULL || (stat(full_filename, &fileinfo) == -1 &&
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1)) stat(filename, &fileinfo2) != -1))
full_filename = mallocstrcpy(NULL, filename); full_filename = mallocstrcpy(NULL, filename);
if (stat(full_filename, &fileinfo) == -1) { if (stat(full_filename, &fileinfo) == -1) {
/* Well, maybe we can open the file even if the OS says it's /* Well, maybe we can open the file even if the OS says it's
* not there. */ * not there. */
@ -961,8 +958,7 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
beep(); beep();
return -1; return -1;
} else if ((fd = open(full_filename, O_RDONLY)) == -1) { } else if ((fd = open(full_filename, O_RDONLY)) == -1) {
statusbar(_("Error reading %s: %s"), filename, statusbar(_("Error reading %s: %s"), filename, strerror(errno));
strerror(errno));
beep(); beep();
return -1; return -1;
} else { } else {
@ -970,8 +966,7 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
*f = fdopen(fd, "rb"); *f = fdopen(fd, "rb");
if (*f == NULL) { if (*f == NULL) {
statusbar(_("Error reading %s: %s"), filename, statusbar(_("Error reading %s: %s"), filename, strerror(errno));
strerror(errno));
beep(); beep();
close(fd); close(fd);
} else } else
@ -1132,8 +1127,7 @@ void do_insertfile(
} }
#endif #endif
/* If we don't have a file yet, go back to the statusbar /* If we don't have a file yet, go back to the statusbar prompt. */
* prompt. */
if (i != 0 if (i != 0
#ifndef DISABLE_MULTIBUFFER #ifndef DISABLE_MULTIBUFFER
&& (i != -2 || !ISSET(MULTIBUFFER)) && (i != -2 || !ISSET(MULTIBUFFER))
@ -1166,8 +1160,7 @@ void do_insertfile(
filepart = partition_filestruct(openfile->current, filepart = partition_filestruct(openfile->current,
openfile->current_x, openfile->current, openfile->current_x, openfile->current,
openfile->current_x); openfile->current_x);
edittop_inside = edittop_inside = (openfile->edittop == openfile->fileage);
(openfile->edittop == openfile->fileage);
#ifndef DISABLE_MULTIBUFFER #ifndef DISABLE_MULTIBUFFER
} }
#endif #endif
@ -1242,8 +1235,7 @@ void do_insertfile(
if (openfile->mark_set) { if (openfile->mark_set) {
openfile->mark_begin = openfile->current; openfile->mark_begin = openfile->current;
if (!right_side_up) if (!right_side_up)
openfile->mark_begin_x += openfile->mark_begin_x += openfile->current_x;
openfile->current_x;
} }
#endif #endif
openfile->current_x += current_x_save; openfile->current_x += current_x_save;
@ -1255,8 +1247,7 @@ void do_insertfile(
openfile->mark_begin = openfile->current; openfile->mark_begin = openfile->current;
openfile->mark_begin_x -= current_x_save; openfile->mark_begin_x -= current_x_save;
} else } else
openfile->mark_begin_x -= openfile->mark_begin_x -= openfile->current_x;
openfile->current_x;
} }
} }
#endif #endif
@ -1366,8 +1357,7 @@ char *get_full_path(const char *origpath)
/* If stat()ing d_there fails, assume that d_there refers to a new /* If stat()ing d_there fails, assume that d_there refers to a new
* file that hasn't been saved to disk yet. Set path_only to TRUE * file that hasn't been saved to disk yet. Set path_only to TRUE
* if d_there refers to a directory, and FALSE otherwise. */ * if d_there refers to a directory, and FALSE otherwise. */
path_only = (stat(d_there, &fileinfo) != -1 && path_only = (stat(d_there, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
S_ISDIR(fileinfo.st_mode));
/* If path_only is TRUE, make sure d_there ends in a slash. */ /* If path_only is TRUE, make sure d_there ends in a slash. */
if (path_only) { if (path_only) {
@ -1453,7 +1443,7 @@ char *get_full_path(const char *origpath)
} }
/* Return the full version of path, as returned by get_full_path(). On /* Return the full version of path, as returned by get_full_path(). On
* error, if path doesn't reference a directory, or if the directory * error, or if path doesn't reference a directory, or if the directory
* isn't writable, return NULL. */ * isn't writable, return NULL. */
char *check_writable_directory(const char *path) char *check_writable_directory(const char *path)
{ {
@ -1463,8 +1453,7 @@ char *check_writable_directory(const char *path)
if (full_path == NULL) if (full_path == NULL)
return NULL; return NULL;
/* If we can't write to path or path isn't a directory, return /* If we can't write to path or path isn't a directory, return NULL. */
* NULL. */
if (access(full_path, W_OK) != 0 || if (access(full_path, W_OK) != 0 ||
full_path[strlen(full_path) - 1] != '/') { full_path[strlen(full_path) - 1] != '/') {
free(full_path); free(full_path);
@ -1768,8 +1757,8 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
* aren't appending, prepending, or writing a selection, we backup * aren't appending, prepending, or writing a selection, we backup
* only if the file has not been modified by someone else since nano * only if the file has not been modified by someone else since nano
* opened it. */ * opened it. */
if (ISSET(BACKUP_FILE) && !tmp && realexists && ((append != if (ISSET(BACKUP_FILE) && !tmp && realexists && ((append != OVERWRITE ||
OVERWRITE || openfile->mark_set) || (openfile->current_stat && openfile->mark_set) || (openfile->current_stat &&
openfile->current_stat->st_mtime == st.st_mtime))) { openfile->current_stat->st_mtime == st.st_mtime))) {
int backup_fd; int backup_fd;
FILE *backup_file; FILE *backup_file;
@ -1901,7 +1890,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
fclose(backup_file); fclose(backup_file);
/* If we can't write to the backup, DONT go on, since /* If we can't write to the backup, DONT 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, which
* means we could lose both the backup and the original! */ * means we could lose both the backup and the original! */
goto cleanup_and_exit; goto cleanup_and_exit;
} }
@ -2141,8 +2130,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
/* If color syntaxes are available and turned on, we need to /* If color syntaxes are available and turned on, we need to
* call edit_refresh(). */ * call edit_refresh(). */
if (openfile->colorstrings != NULL && if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
!ISSET(NO_COLOR_SYNTAX))
edit_refresh(); edit_refresh();
#endif #endif
} }
@ -2569,8 +2557,7 @@ bool is_dir(const char *buf)
dirptr = real_dir_from_tilde(buf); dirptr = real_dir_from_tilde(buf);
retval = (stat(dirptr, &fileinfo) != -1 && retval = (stat(dirptr, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
S_ISDIR(fileinfo.st_mode));
free(dirptr); free(dirptr);
@ -2686,8 +2673,8 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t
#endif #endif
/* See if this matches. */ /* See if this matches. */
if (strncmp(nextdir->d_name, filename, filenamelen) == 0 && if (strncmp(nextdir->d_name, filename, filenamelen) == 0 &&
(*filename == '.' || (strcmp(nextdir->d_name, ".") != (*filename == '.' || (strcmp(nextdir->d_name, ".") != 0 &&
0 && strcmp(nextdir->d_name, "..") != 0))) { strcmp(nextdir->d_name, "..") != 0))) {
/* Cool, found a match. Add it to the list. This makes a /* Cool, found a match. Add it to the list. This makes a
* lot more sense to me (Chris) this way... */ * lot more sense to me (Chris) this way... */
@ -2735,7 +2722,8 @@ char *input_tab(char *buf, bool allow_files, size_t *place, bool
size_t num_matches = 0, buf_len; size_t num_matches = 0, buf_len;
char **matches = NULL; char **matches = NULL;
assert(buf != NULL && place != NULL && *place <= strlen(buf) && lastwastab != NULL && refresh_func != NULL && list != NULL); assert(buf != NULL && place != NULL && *place <= strlen(buf) &&
lastwastab != NULL && refresh_func != NULL && list != NULL);
*list = FALSE; *list = FALSE;
@ -3095,8 +3083,7 @@ void save_history(void)
* history file. */ * history file. */
chmod(nanohist, S_IRUSR | S_IWUSR); chmod(nanohist, S_IRUSR | S_IWUSR);
if (!writehist(hist, searchage) || !writehist(hist, if (!writehist(hist, searchage) || !writehist(hist, replaceage))
replaceage))
history_error(N_("Error writing %s: %s"), nanohist, history_error(N_("Error writing %s: %s"), nanohist,
strerror(errno)); strerror(errno));