fix some breakage caused by the restructuring

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2836 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-07-08 20:59:24 +00:00
parent 6ad59cd29b
commit dbcaa3b1fb
6 changed files with 17 additions and 29 deletions

View File

@ -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.

View File

@ -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") :

View File

@ -179,32 +179,19 @@ void free_filestruct(filestruct *src)
delete_node(src);
}
/* Renumber all entries in the main filestruct. */
void renumber_all(void)
{
filestruct *temp;
ssize_t line = 1;
assert(openfile->fileage == NULL || openfile->fileage != openfile->fileage->next);
for (temp = openfile->fileage; temp != NULL; temp = temp->next)
temp->lineno = line++;
}
/* Renumbers all entries in the main filestruct, starting with
* fileptr. */
/* Renumbers all entries in a 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;
ssize_t line;
assert(fileptr != fileptr->next);
assert(fileptr != NULL && fileptr->prev != NULL);
for (; fileptr != NULL; fileptr = fileptr->next)
fileptr->lineno = ++line;
}
line = (fileptr->prev == NULL) ? 1 : fileptr->prev->lineno;
assert(fileptr != fileptr->next);
for (; fileptr != NULL; fileptr = fileptr->next)
fileptr->lineno = ++line;
}
/* Partition a filestruct so it begins at (top, top_x) and ends at (bot,

View File

@ -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);

View File

@ -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)

View File

@ -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;
}