files: rewrap en reindent some lines

master
Benno Schulenberg 2016-04-17 20:58:33 +02:00
parent 5c5fefc8cf
commit 2815eaa5f8
1 changed files with 26 additions and 42 deletions

View File

@ -610,9 +610,7 @@ void switch_to_next_buffer_void(void)
/* Delete an entry from the openfile filebuffer, and switch to the one /* Delete an entry from the openfile filebuffer, and switch to the one
* after it. Return TRUE on success, or FALSE if there are no more open * after it. Return TRUE on success, or FALSE if there are no more open
* file buffers. * buffers. quiet means not to print messages when switching buffers. */
* quiet - should we print messages switching bufers
*/
bool close_buffer(bool quiet) bool close_buffer(bool quiet)
{ {
assert(openfile != NULL); assert(openfile != NULL);
@ -1677,7 +1675,7 @@ void init_backup_dir(void)
/* If get_full_path() failed or the backup directory is /* If get_full_path() failed or the backup directory is
* inaccessible, unset backup_dir. */ * inaccessible, unset backup_dir. */
if (full_backup_dir == NULL || if (full_backup_dir == NULL ||
full_backup_dir[strlen(full_backup_dir) - 1] != '/') { full_backup_dir[strlen(full_backup_dir) - 1] != '/') {
free(full_backup_dir); free(full_backup_dir);
free(backup_dir); free(backup_dir);
backup_dir = NULL; backup_dir = NULL;
@ -1854,14 +1852,13 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
} }
} }
backupname = charalloc(strlen(backup_dir) + backupname = charalloc(strlen(backup_dir) + strlen(backuptemp) + 1);
strlen(backuptemp) + 1);
sprintf(backupname, "%s%s", backup_dir, backuptemp); sprintf(backupname, "%s%s", backup_dir, backuptemp);
free(backuptemp); free(backuptemp);
backuptemp = get_next_filename(backupname, "~"); backuptemp = get_next_filename(backupname, "~");
if (*backuptemp == '\0') { if (*backuptemp == '\0') {
statusbar(_("Error writing backup file %s: %s"), backupname, statusbar(_("Error writing backup file %s: %s"), backupname,
_("Too many backup files?")); _("Too many backup files?"));
free(backuptemp); free(backuptemp);
free(backupname); free(backupname);
/* If we can't write to the backup, DON'T go on, since /* If we can't write to the backup, DON'T go on, since
@ -1917,7 +1914,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
if (prompt_failed_backupwrite(backupname)) if (prompt_failed_backupwrite(backupname))
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));
free(backupname); free(backupname);
fclose(backup_file); fclose(backup_file);
goto cleanup_and_exit; goto cleanup_and_exit;
@ -1928,7 +1925,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
if (prompt_failed_backupwrite(backupname)) if (prompt_failed_backupwrite(backupname))
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));
free(backupname); free(backupname);
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
@ -2001,8 +1998,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
tempname = safe_tempfile(&f); tempname = safe_tempfile(&f);
if (tempname == NULL) { if (tempname == NULL) {
statusbar(_("Error writing temp file: %s"), statusbar(_("Error writing temp file: %s"), strerror(errno));
strerror(errno));
goto cleanup_and_exit; goto cleanup_and_exit;
} }
@ -2013,7 +2009,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
f_source = fdopen(fd_source, "rb"); f_source = fdopen(fd_source, "rb");
if (f_source == NULL) { if (f_source == NULL) {
statusbar(_("Error reading %s: %s"), realname, statusbar(_("Error reading %s: %s"), realname,
strerror(errno)); strerror(errno));
beep(); beep();
close(fd_source); close(fd_source);
fclose(f); fclose(f);
@ -2024,8 +2020,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
} }
if (f_source == NULL || copy_file(f_source, f) != 0) { if (f_source == NULL || copy_file(f_source, f) != 0) {
statusbar(_("Error writing %s: %s"), tempname, statusbar(_("Error writing %s: %s"), tempname, strerror(errno));
strerror(errno));
unlink(tempname); unlink(tempname);
goto cleanup_and_exit; goto cleanup_and_exit;
} }
@ -2043,10 +2038,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
/* If we couldn't open the file, give up. */ /* If we couldn't open the file, give up. */
if (fd == -1) { if (fd == -1) {
statusbar(_("Error writing %s: %s"), realname, statusbar(_("Error writing %s: %s"), realname, strerror(errno));
strerror(errno));
/* tempname has been set only if we're prepending. */
if (tempname != NULL) if (tempname != NULL)
unlink(tempname); unlink(tempname);
goto cleanup_and_exit; goto cleanup_and_exit;
@ -2055,8 +2047,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
f = fdopen(fd, (append == APPEND) ? "ab" : "wb"); f = fdopen(fd, (append == APPEND) ? "ab" : "wb");
if (f == NULL) { if (f == NULL) {
statusbar(_("Error writing %s: %s"), realname, statusbar(_("Error writing %s: %s"), realname, strerror(errno));
strerror(errno));
close(fd); close(fd);
goto cleanup_and_exit; goto cleanup_and_exit;
} }
@ -2079,8 +2070,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
unsunder(fileptr->data, data_len); unsunder(fileptr->data, data_len);
if (size < data_len) { if (size < data_len) {
statusbar(_("Error writing %s: %s"), realname, statusbar(_("Error writing %s: %s"), realname, strerror(errno));
strerror(errno));
fclose(f); fclose(f);
goto cleanup_and_exit; goto cleanup_and_exit;
} }
@ -2097,7 +2087,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
if (openfile->fmt == DOS_FILE || openfile->fmt == MAC_FILE) { if (openfile->fmt == DOS_FILE || openfile->fmt == MAC_FILE) {
if (putc('\r', f) == EOF) { if (putc('\r', f) == EOF) {
statusbar(_("Error writing %s: %s"), realname, statusbar(_("Error writing %s: %s"), realname,
strerror(errno)); strerror(errno));
fclose(f); fclose(f);
goto cleanup_and_exit; goto cleanup_and_exit;
} }
@ -2107,7 +2097,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
#endif #endif
if (putc('\n', f) == EOF) { if (putc('\n', f) == EOF) {
statusbar(_("Error writing %s: %s"), realname, statusbar(_("Error writing %s: %s"), realname,
strerror(errno)); strerror(errno));
fclose(f); fclose(f);
goto cleanup_and_exit; goto cleanup_and_exit;
} }
@ -2131,24 +2121,21 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
} }
if (f_source == NULL) { if (f_source == NULL) {
statusbar(_("Error reading %s: %s"), tempname, statusbar(_("Error reading %s: %s"), tempname, strerror(errno));
strerror(errno));
beep(); beep();
fclose(f); fclose(f);
goto cleanup_and_exit; goto cleanup_and_exit;
} }
if (copy_file(f_source, f) == -1) { if (copy_file(f_source, f) == -1) {
statusbar(_("Error writing %s: %s"), realname, statusbar(_("Error writing %s: %s"), realname, strerror(errno));
strerror(errno));
goto cleanup_and_exit; goto cleanup_and_exit;
} }
unlink(tempname); unlink(tempname);
} else if (fclose(f) != 0) { } else if (fclose(f) != 0) {
statusbar(_("Error writing %s: %s"), realname, statusbar(_("Error writing %s: %s"), realname, strerror(errno));
strerror(errno)); goto cleanup_and_exit;
goto cleanup_and_exit;
} }
if (!tmp && append == OVERWRITE) { if (!tmp && append == OVERWRITE) {
@ -2210,7 +2197,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
/* Partition the filestruct so that it contains only the marked /* Partition the filestruct so that it contains only the marked
* text. */ * text. */
mark_order((const filestruct **)&top, &top_x, mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, NULL); (const filestruct **)&bot, &bot_x, NULL);
filepart = partition_filestruct(top, top_x, bot, bot_x); filepart = partition_filestruct(top, top_x, bot, bot_x);
/* Handle the magicline if the NO_NEWLINES flag isn't set. If the /* Handle the magicline if the NO_NEWLINES flag isn't set. If the
@ -2406,14 +2393,14 @@ int do_writeout(bool exiting)
full_answer = get_full_path(answer); full_answer = get_full_path(answer);
full_filename = get_full_path(openfile->filename); full_filename = get_full_path(openfile->filename);
name_exists = (stat((full_answer == NULL) ? answer : name_exists = (stat((full_answer == NULL) ?
full_answer, &st) != -1); answer : full_answer, &st) != -1);
if (openfile->filename[0] == '\0') if (openfile->filename[0] == '\0')
do_warning = name_exists; do_warning = name_exists;
else else
do_warning = (strcmp((full_answer == NULL) ? do_warning = (strcmp((full_answer == NULL) ?
answer : full_answer, (full_filename == NULL) ? answer : full_answer, (full_filename == NULL) ?
openfile->filename : full_filename) != 0); openfile->filename : full_filename) != 0);
/* Convert nulls to newlines. answer_len is the /* Convert nulls to newlines. answer_len is the
* string's real length. */ * string's real length. */
@ -2885,8 +2872,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
* only one space after the last column. */ * only one space after the last column. */
ncols = (COLS + 1) / (longest_name + 2); ncols = (COLS + 1) / (longest_name + 2);
/* Blank the edit window, and print the matches out /* Blank the edit window, and print the matches out there. */
* there. */
blank_edit(); blank_edit();
wmove(edit, 0, 0); wmove(edit, 0, 0);
@ -2896,11 +2882,9 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
for (match = 0; match < num_matches; match++) { for (match = 0; match < num_matches; match++) {
char *disp; char *disp;
wmove(edit, editline, (longest_name + 2) * wmove(edit, editline, (longest_name + 2) * (match % ncols));
(match % ncols));
if (match % ncols == 0 && if (match % ncols == 0 && editline == editwinrows - 1 &&
editline == editwinrows - 1 &&
num_matches - match > ncols) { num_matches - match > ncols) {
waddstr(edit, _("(more)")); waddstr(edit, _("(more)"));
break; break;