From dbcaa3b1fbbe73764550717f1b6b1e93436f540a Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Fri, 8 Jul 2005 20:59:24 +0000 Subject: [PATCH] fix some breakage caused by the restructuring git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2836 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ src/files.c | 8 ++++---- src/nano.c | 29 ++++++++--------------------- src/proto.h | 1 - src/search.c | 2 +- src/winio.c | 2 +- 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index b77818b0..f9be1ce9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ CVS code - backup_lines(). (DLR) - Reorder some functions for consistency. (DLR) - Rename variable open_files openfile, for consistency. (DLR) + - Remove renumber()'s dependency on the main filestruct. + Changes to renumber(); removal of renumber_all(). (DLR) - Restructure things so that every file has its own openfilestruct, and so that the values in it are used directly instead of being periodically synced up with the globals. diff --git a/src/files.c b/src/files.c index 61771239..2d07ea3d 100644 --- a/src/files.c +++ b/src/files.c @@ -165,13 +165,13 @@ void open_buffer(const char *filename) } #endif + /* Open the file. */ + rc = open_file(filename, new_buffer, &f); + /* If we're loading into a new buffer, add a new openfile entry. */ if (new_buffer) make_new_buffer(); - /* Open the file. */ - rc = open_file(filename, new_buffer, &f); - /* If we have a file and we're loading into a new buffer, update the * filename. */ if (rc != -1 && new_buffer) @@ -545,7 +545,7 @@ int open_file(const char *filename, bool newfie, FILE **f) statusbar(_("\"%s\" not found"), filename); return -1; } else if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) || - S_ISBLK(fileinfo.st_mode)) { + S_ISBLK(fileinfo.st_mode)) { /* Don't open character or block files. Sorry, /dev/sndstat! */ statusbar(S_ISDIR(fileinfo.st_mode) ? _("\"%s\" is a directory") : diff --git a/src/nano.c b/src/nano.c index 390aefaf..08cc340d 100644 --- a/src/nano.c +++ b/src/nano.c @@ -179,32 +179,19 @@ void free_filestruct(filestruct *src) delete_node(src); } -/* Renumber all entries in the main filestruct. */ -void renumber_all(void) +/* Renumbers all entries in a filestruct, starting with fileptr. */ +void renumber(filestruct *fileptr) { - filestruct *temp; - ssize_t line = 1; + ssize_t line; - assert(openfile->fileage == NULL || openfile->fileage != openfile->fileage->next); + assert(fileptr != NULL && fileptr->prev != NULL); - for (temp = openfile->fileage; temp != NULL; temp = temp->next) - temp->lineno = line++; -} + line = (fileptr->prev == NULL) ? 1 : fileptr->prev->lineno; -/* Renumbers all entries in the main filestruct, starting with - * fileptr. */ -void renumber(filestruct *fileptr) -{ - if (fileptr == NULL || fileptr->prev == NULL || fileptr == openfile->fileage) - renumber_all(); - else { - ssize_t line = fileptr->prev->lineno; - - assert(fileptr != fileptr->next); + assert(fileptr != fileptr->next); - for (; fileptr != NULL; fileptr = fileptr->next) - fileptr->lineno = ++line; - } + for (; fileptr != NULL; fileptr = fileptr->next) + fileptr->lineno = ++line; } /* Partition a filestruct so it begins at (top, top_x) and ends at (bot, diff --git a/src/proto.h b/src/proto.h index 1f953d41..938e3371 100644 --- a/src/proto.h +++ b/src/proto.h @@ -348,7 +348,6 @@ void unlink_node(const filestruct *fileptr); void delete_node(filestruct *fileptr); filestruct *copy_filestruct(const filestruct *src); void free_filestruct(filestruct *src); -void renumber_all(void); void renumber(filestruct *fileptr); partition *partition_filestruct(filestruct *top, size_t top_x, filestruct *bot, size_t bot_x); diff --git a/src/search.c b/src/search.c index 3a793374..2ae55457 100644 --- a/src/search.c +++ b/src/search.c @@ -953,7 +953,7 @@ void do_replace(void) openfile->current_x = beginx; openfile->placewewant = pww_save; - renumber_all(); + renumber(openfile->fileage); edit_refresh(); if (numreplaced >= 0) diff --git a/src/winio.c b/src/winio.c index fe5bc248..81b6bc78 100644 --- a/src/winio.c +++ b/src/winio.c @@ -3063,7 +3063,7 @@ void reset_cursor(void) { /* If we haven't opened any files yet, put the cursor in the top * left corner of the edit window and get out. */ - if (openfile->edittop == NULL || openfile->current == NULL) { + if (openfile == NULL) { wmove(edit, 0, 0); return; } -- 2.39.5