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.
}
#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)
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") :
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,
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);
openfile->current_x = beginx;
openfile->placewewant = pww_save;
- renumber_all();
+ renumber(openfile->fileage);
edit_refresh();
if (numreplaced >= 0)
{
/* 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;
}