mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-21 20:31:20 +03:00
Unwrapping some lines and rewrapping some others in a more congenial manner;
tweaking some comments and whitespace and braces. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5290 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
ea4b775a3e
commit
08d9f572a4
@ -3,6 +3,8 @@
|
|||||||
* src/files.c (do_lockfile): Rename a variable; it does not contain
|
* src/files.c (do_lockfile): Rename a variable; it does not contain
|
||||||
the size of the file but the size of the name.
|
the size of the file but the size of the name.
|
||||||
* src/nano.c (do_toggle): Elide an unneeded variable.
|
* src/nano.c (do_toggle): Elide an unneeded variable.
|
||||||
|
* src/files.c: Unwrap some lines and rewrap some others in a more
|
||||||
|
congenial manner; tweak some comments and whitespace and braces.
|
||||||
|
|
||||||
2015-07-06 Benno Schulenberg <bensberg@justemail.net>
|
2015-07-06 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/global.c (add_to_sclist), src/help.c (help_init), src/nano.h,
|
* src/global.c (add_to_sclist), src/help.c (help_init), src/nano.h,
|
||||||
|
3
README
3
README
@ -71,6 +71,3 @@ Current Status
|
|||||||
GNU nano has reached its fifth stable milestone, 2.4.x.
|
GNU nano has reached its fifth stable milestone, 2.4.x.
|
||||||
Development of new features will continue in the 2.5.x branch,
|
Development of new features will continue in the 2.5.x branch,
|
||||||
while 2.4.x versions are dedicated to bug-fixing and polishing.
|
while 2.4.x versions are dedicated to bug-fixing and polishing.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
69
src/files.c
69
src/files.c
@ -71,15 +71,15 @@ void initialize_buffer(void)
|
|||||||
openfile->modified = FALSE;
|
openfile->modified = FALSE;
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
openfile->mark_set = FALSE;
|
openfile->mark_set = FALSE;
|
||||||
|
|
||||||
openfile->mark_begin = NULL;
|
openfile->mark_begin = NULL;
|
||||||
openfile->mark_begin_x = 0;
|
openfile->mark_begin_x = 0;
|
||||||
|
|
||||||
openfile->fmt = NIX_FILE;
|
openfile->fmt = NIX_FILE;
|
||||||
|
|
||||||
openfile->current_stat = NULL;
|
|
||||||
openfile->undotop = NULL;
|
openfile->undotop = NULL;
|
||||||
openfile->current_undo = NULL;
|
openfile->current_undo = NULL;
|
||||||
|
|
||||||
|
openfile->current_stat = NULL;
|
||||||
openfile->lock_filename = NULL;
|
openfile->lock_filename = NULL;
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_COLOR
|
#ifndef DISABLE_COLOR
|
||||||
@ -339,8 +339,8 @@ void open_buffer(const char *filename, bool undoable)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If we're loading into a new buffer, add a new entry to
|
/* If we're going to load into a new buffer, first create the new
|
||||||
* openfile. */
|
* buffer and lock the corresponding file. */
|
||||||
if (new_buffer) {
|
if (new_buffer) {
|
||||||
make_new_buffer();
|
make_new_buffer();
|
||||||
|
|
||||||
@ -541,8 +541,8 @@ int is_file_writable(const char *filename)
|
|||||||
/* Get the specified file's full path. */
|
/* Get the specified file's full path. */
|
||||||
full_filename = get_full_path(filename);
|
full_filename = get_full_path(filename);
|
||||||
|
|
||||||
/* Okay, if we can't stat the path due to a component's
|
/* Okay, if we can't stat the absolute path due to some 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(filename, &fileinfo2) != -1))
|
(stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
|
||||||
full_filename = mallocstrcpy(NULL, filename);
|
full_filename = mallocstrcpy(NULL, filename);
|
||||||
@ -568,8 +568,7 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
|
|||||||
{
|
{
|
||||||
filestruct *fileptr = (filestruct *)nmalloc(sizeof(filestruct));
|
filestruct *fileptr = (filestruct *)nmalloc(sizeof(filestruct));
|
||||||
|
|
||||||
/* Convert nulls to newlines. buf_len is the string's real
|
/* Convert nulls to newlines. buf_len is the string's real length. */
|
||||||
* length. */
|
|
||||||
unsunder(buf, buf_len);
|
unsunder(buf, buf_len);
|
||||||
|
|
||||||
assert(openfile->fileage != NULL && strlen(buf) == buf_len);
|
assert(openfile->fileage != NULL && strlen(buf) == buf_len);
|
||||||
@ -584,7 +583,7 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_COLOR
|
#ifndef DISABLE_COLOR
|
||||||
fileptr->multidata = NULL;
|
fileptr->multidata = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (*first_line_ins) {
|
if (*first_line_ins) {
|
||||||
@ -684,8 +683,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
|
|||||||
/* Read in the line properly. */
|
/* Read in the line properly. */
|
||||||
fileptr = read_line(buf, fileptr, &first_line_ins, len);
|
fileptr = read_line(buf, fileptr, &first_line_ins, len);
|
||||||
|
|
||||||
/* Reset the line length in preparation for the next
|
/* Reset the line length in preparation for the next line. */
|
||||||
* line. */
|
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
num_lines++;
|
num_lines++;
|
||||||
@ -826,8 +824,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
|
|||||||
openfile->current->prev = fileptr;
|
openfile->current->prev = fileptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Renumber starting with the last line of the file we
|
/* Renumber, starting with the last line of the file we inserted. */
|
||||||
* inserted. */
|
|
||||||
renumber(openfile->current);
|
renumber(openfile->current);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1148,8 +1145,7 @@ void do_insertfile(
|
|||||||
/* If we're not inserting into a new buffer, partition
|
/* If we're not inserting into a new buffer, partition
|
||||||
* the filestruct so that it contains no text and hence
|
* the filestruct so that it contains no text and hence
|
||||||
* looks like a new buffer, and keep track of whether
|
* looks like a new buffer, and keep track of whether
|
||||||
* the top of the edit window is inside the
|
* the top of the edit window is inside the partition. */
|
||||||
* partition. */
|
|
||||||
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);
|
||||||
@ -1184,24 +1180,20 @@ void do_insertfile(
|
|||||||
openfile->placewewant = 0;
|
openfile->placewewant = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else
|
||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
|
{
|
||||||
/* Make sure the path to the file specified in answer is
|
/* Make sure the path to the file specified in answer is
|
||||||
* tilde-expanded. */
|
* tilde-expanded. */
|
||||||
answer = mallocstrassn(answer,
|
answer = mallocstrassn(answer, real_dir_from_tilde(answer));
|
||||||
real_dir_from_tilde(answer));
|
|
||||||
|
|
||||||
/* Save the file specified in answer in the current
|
/* Save the file specified in answer in the current buffer. */
|
||||||
* buffer. */
|
|
||||||
open_buffer(answer, TRUE);
|
open_buffer(answer, TRUE);
|
||||||
#ifndef NANO_TINY
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(DISABLE_MULTIBUFFER) && !defined(DISABLE_HISTORIES)
|
#if !defined(DISABLE_MULTIBUFFER) && !defined(DISABLE_HISTORIES)
|
||||||
if (ISSET(MULTIBUFFER)) {
|
if (ISSET(MULTIBUFFER)) {
|
||||||
/* Update the screen to account for the current
|
/* Update the screen to account for the current buffer. */
|
||||||
* buffer. */
|
|
||||||
display_buffer();
|
display_buffer();
|
||||||
|
|
||||||
ssize_t savedposline, savedposcol;
|
ssize_t savedposline, savedposcol;
|
||||||
@ -1212,7 +1204,7 @@ void do_insertfile(
|
|||||||
check_poshistory(answer, &savedposline, &savedposcol))
|
check_poshistory(answer, &savedposline, &savedposcol))
|
||||||
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE, FALSE, FALSE);
|
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE, FALSE, FALSE);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif /* !DISABLE_MULTIBUFFER && !DISABLE_HISTORIES */
|
||||||
{
|
{
|
||||||
filestruct *top_save = openfile->fileage;
|
filestruct *top_save = openfile->fileage;
|
||||||
|
|
||||||
@ -2062,8 +2054,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
|||||||
lineswritten--;
|
lineswritten--;
|
||||||
} else {
|
} else {
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (openfile->fmt == DOS_FILE || openfile->fmt ==
|
if (openfile->fmt == DOS_FILE || openfile->fmt == MAC_FILE) {
|
||||||
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));
|
||||||
@ -2072,7 +2063,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openfile->fmt != MAC_FILE) {
|
if (openfile->fmt != MAC_FILE)
|
||||||
#endif
|
#endif
|
||||||
if (putc('\n', f) == EOF) {
|
if (putc('\n', f) == EOF) {
|
||||||
statusbar(_("Error writing %s: %s"), realname,
|
statusbar(_("Error writing %s: %s"), realname,
|
||||||
@ -2080,9 +2071,6 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
goto cleanup_and_exit;
|
goto cleanup_and_exit;
|
||||||
}
|
}
|
||||||
#ifndef NANO_TINY
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileptr = fileptr->next;
|
fileptr = fileptr->next;
|
||||||
@ -2250,9 +2238,8 @@ bool do_writeout(bool exiting)
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
const char *formatstr, *backupstr;
|
const char *formatstr, *backupstr;
|
||||||
|
|
||||||
formatstr = (openfile->fmt == DOS_FILE) ?
|
formatstr = (openfile->fmt == DOS_FILE) ? _(" [DOS Format]") :
|
||||||
_(" [DOS Format]") : (openfile->fmt == MAC_FILE) ?
|
(openfile->fmt == MAC_FILE) ? _(" [Mac Format]") : "";
|
||||||
_(" [Mac Format]") : "";
|
|
||||||
|
|
||||||
backupstr = ISSET(BACKUP_FILE) ? _(" [Backup]") : "";
|
backupstr = ISSET(BACKUP_FILE) ? _(" [Backup]") : "";
|
||||||
|
|
||||||
@ -2261,15 +2248,14 @@ bool do_writeout(bool exiting)
|
|||||||
* it allows reading from or writing to files not specified on
|
* it allows reading from or writing to files not specified on
|
||||||
* the command line. */
|
* the command line. */
|
||||||
if (!ISSET(RESTRICTED) && !exiting && openfile->mark_set)
|
if (!ISSET(RESTRICTED) && !exiting && openfile->mark_set)
|
||||||
msg = (append == PREPEND) ?
|
msg = (append == PREPEND) ? _("Prepend Selection to File") :
|
||||||
_("Prepend Selection to File") : (append == APPEND) ?
|
(append == APPEND) ? _("Append Selection to File") :
|
||||||
_("Append Selection to File") :
|
_("Write Selection to File");
|
||||||
_("Write Selection to File");
|
|
||||||
else
|
else
|
||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
msg = (append == PREPEND) ? _("File Name to Prepend to") :
|
msg = (append == PREPEND) ? _("File Name to Prepend to") :
|
||||||
(append == APPEND) ? _("File Name to Append to") :
|
(append == APPEND) ? _("File Name to Append to") :
|
||||||
_("File Name to Write");
|
_("File Name to Write");
|
||||||
|
|
||||||
/* If we're using restricted mode, the filename isn't blank,
|
/* If we're using restricted mode, the filename isn't blank,
|
||||||
* and we're at the "Write File" prompt, disable tab
|
* and we're at the "Write File" prompt, disable tab
|
||||||
@ -2429,8 +2415,7 @@ bool do_writeout(bool exiting)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert newlines to nulls, just before we save the
|
/* Convert newlines to nulls, just before we save the file. */
|
||||||
* file. */
|
|
||||||
sunder(answer);
|
sunder(answer);
|
||||||
align(&answer);
|
align(&answer);
|
||||||
|
|
||||||
|
@ -1045,7 +1045,7 @@ fprintf(stderr, " >> Updating... action = %d, fs->last_action = %d, openfile->c
|
|||||||
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 is \"%s\"\n", u->strdata);
|
fprintf(stderr, " >> current undo data is \"%s\"\n", u->strdata);
|
||||||
#endif
|
#endif
|
||||||
u->mark_begin_lineno = fs->current->lineno;
|
u->mark_begin_lineno = fs->current->lineno;
|
||||||
u->mark_begin_x = fs->current_x;
|
u->mark_begin_x = fs->current_x;
|
||||||
|
@ -3333,11 +3333,9 @@ void do_cursorpos(bool constant)
|
|||||||
|
|
||||||
/* Display the current cursor position on the statusbar, and set
|
/* Display the current cursor position on the statusbar, and set
|
||||||
* disable_cursorpos to FALSE. */
|
* disable_cursorpos to FALSE. */
|
||||||
linepct = 100 * openfile->current->lineno /
|
linepct = 100 * openfile->current->lineno / openfile->filebot->lineno;
|
||||||
openfile->filebot->lineno;
|
|
||||||
colpct = 100 * cur_xpt / cur_lenpt;
|
colpct = 100 * cur_xpt / cur_lenpt;
|
||||||
charpct = (openfile->totsize == 0) ? 0 : 100 * i /
|
charpct = (openfile->totsize == 0) ? 0 : 100 * i / openfile->totsize;
|
||||||
openfile->totsize;
|
|
||||||
|
|
||||||
statusbar(
|
statusbar(
|
||||||
_("line %ld/%ld (%d%%), col %lu/%lu (%d%%), char %lu/%lu (%d%%)"),
|
_("line %ld/%ld (%d%%), col %lu/%lu (%d%%), char %lu/%lu (%d%%)"),
|
||||||
|
Loading…
Reference in New Issue
Block a user