version 1.18, 2015/11/09 16:42:35 |
version 1.19, 2015/11/09 16:46:42 |
|
|
{ |
{ |
struct scrpos scrpos; |
struct scrpos scrpos; |
|
|
if (curr_ifile == NULL_IFILE) |
if (curr_ifile == NULL) |
return; |
return; |
|
|
/* |
/* |
|
|
free(curr_altfilename); |
free(curr_altfilename); |
curr_altfilename = NULL; |
curr_altfilename = NULL; |
} |
} |
curr_ifile = NULL_IFILE; |
curr_ifile = NULL; |
curr_ino = curr_dev = 0; |
curr_ino = curr_dev = 0; |
} |
} |
|
|
|
|
edit(char *filename) |
edit(char *filename) |
{ |
{ |
if (filename == NULL) |
if (filename == NULL) |
return (edit_ifile(NULL_IFILE)); |
return (edit_ifile(NULL)); |
return (edit_ifile(get_ifile(filename, curr_ifile))); |
return (edit_ifile(get_ifile(filename, curr_ifile))); |
} |
} |
|
|
|
|
*/ |
*/ |
end_logfile(); |
end_logfile(); |
was_curr_ifile = save_curr_ifile(); |
was_curr_ifile = save_curr_ifile(); |
if (curr_ifile != NULL_IFILE) { |
if (curr_ifile != NULL) { |
chflags = ch_getflags(); |
chflags = ch_getflags(); |
close_file(); |
close_file(); |
if ((chflags & CH_HELPFILE) && |
if ((chflags & CH_HELPFILE) && |
|
|
} |
} |
} |
} |
|
|
if (ifile == NULL_IFILE) { |
if (ifile == NULL) { |
/* |
/* |
* No new file to open. |
* No new file to open. |
* (Don't set old_ifile, because if you call edit_ifile(NULL), |
* (Don't set old_ifile, because if you call edit_ifile(NULL), |
|
|
* Get the new ifile. |
* Get the new ifile. |
* Get the saved position for the file. |
* Get the saved position for the file. |
*/ |
*/ |
if (was_curr_ifile != NULL_IFILE) { |
if (was_curr_ifile != NULL) { |
old_ifile = was_curr_ifile; |
old_ifile = was_curr_ifile; |
unsave_ifile(was_curr_ifile); |
unsave_ifile(was_curr_ifile); |
} |
} |
|
|
int |
int |
edit_first(void) |
edit_first(void) |
{ |
{ |
curr_ifile = NULL_IFILE; |
curr_ifile = NULL; |
return (edit_next(1)); |
return (edit_next(1)); |
} |
} |
|
|
|
|
int |
int |
edit_last(void) |
edit_last(void) |
{ |
{ |
curr_ifile = NULL_IFILE; |
curr_ifile = NULL; |
return (edit_prev(1)); |
return (edit_prev(1)); |
} |
} |
|
|
|
|
if (edit_ifile(h) == 0) |
if (edit_ifile(h) == 0) |
break; |
break; |
} |
} |
if (next == NULL_IFILE) { |
if (next == NULL) { |
/* |
/* |
* Reached end of the ifile list. |
* Reached end of the ifile list. |
*/ |
*/ |
|
|
{ |
{ |
IFILE h; |
IFILE h; |
|
|
h = NULL_IFILE; |
h = NULL; |
do { |
do { |
if ((h = next_ifile(h)) == NULL_IFILE) { |
if ((h = next_ifile(h)) == NULL) { |
/* |
/* |
* Reached end of the list without finding it. |
* Reached end of the list without finding it. |
*/ |
*/ |
|
|
IFILE |
IFILE |
save_curr_ifile(void) |
save_curr_ifile(void) |
{ |
{ |
if (curr_ifile != NULL_IFILE) |
if (curr_ifile != NULL) |
hold_ifile(curr_ifile, 1); |
hold_ifile(curr_ifile, 1); |
return (curr_ifile); |
return (curr_ifile); |
} |
} |
|
|
void |
void |
unsave_ifile(IFILE save_ifile) |
unsave_ifile(IFILE save_ifile) |
{ |
{ |
if (save_ifile != NULL_IFILE) |
if (save_ifile != NULL) |
hold_ifile(save_ifile, -1); |
hold_ifile(save_ifile, -1); |
} |
} |
|
|
|
|
/* |
/* |
* If can't reopen it, open the next input file in the list. |
* If can't reopen it, open the next input file in the list. |
*/ |
*/ |
if (next != NULL_IFILE && edit_inext(next, 0) == 0) |
if (next != NULL && edit_inext(next, 0) == 0) |
return; |
return; |
/* |
/* |
* If can't open THAT one, open the previous input file in the list. |
* If can't open THAT one, open the previous input file in the list. |
*/ |
*/ |
if (prev != NULL_IFILE && edit_iprev(prev, 0) == 0) |
if (prev != NULL && edit_iprev(prev, 0) == 0) |
return; |
return; |
/* |
/* |
* If can't even open that, we're stuck. Just quit. |
* If can't even open that, we're stuck. Just quit. |