Commit dbcaa3b1 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

fix some breakage caused by the restructuring

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2836 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 16 additions and 28 deletions
+16 -28
......@@ -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.
......
......@@ -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") :
......
......@@ -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,
......
......@@ -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);
......
......@@ -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)
......
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment