-
Notifications
You must be signed in to change notification settings - Fork 3
/
ex_file.c
55 lines (53 loc) · 1 KB
/
ex_file.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "ex.h"
#include "ex_glob.h"
/*
* Ex - a text editor
* Bill Joy UCB September 1977
*/
void
filename(int comm)
{
int c;
c = ex_getchar();
if (endcmd(c)) {
if (savedfile[0] == 0 && comm != 'f')
error("No file|No current filename");
strcpy(file, savedfile);
} else {
ungetchar(c);
getone();
c = comm;
if (savedfile[0] == 0 && c != 'E' && c != 'e') {
c = 'e';
value(EDITED) = 0;
}
switch (c) {
case 'f':
value(EDITED) = 0;
case 'e':
if (savedfile[0])
strcpy(altfile, savedfile);
strcpy(savedfile, file);
break;
default:
if (file[0])
strcpy(altfile, file);
break;
}
}
if ((value(HUSH) && comm != 'f') || comm == 'E')
return;
if (file[0] != 0) {
lprintf("\"%s\"", file);
if (comm == 'f') {
if (value(EDITED))
ex_printf(" [Edited]");
if (tchngflag)
ex_printf(" [Modified]");
}
flush();
} else
ex_printf("No file ");
if (comm == 'f')
ex_printf(mesg(" %d lin%s@in buffer"), dol - zero, dol == one ? "e" : "es");
}