Subversion Repositories planix.SVN

Rev

Rev 113 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 113 Rev 115
Line 11... Line 11...
11
#include "ex.h"
11
#include "ex.h"
12
#include "ex_argv.h"
12
#include "ex_argv.h"
13
#include "ex_temp.h"
13
#include "ex_temp.h"
14
#include "ex_tty.h"
14
#include "ex_tty.h"
15
#include "ex_vis.h"
15
#include "ex_vis.h"
16
void
-
 
17
checkmodeline(char * li_ne);
-
 
18
void
-
 
19
putfile(int isfilter);
-
 
20
 
16
 
21
/*
17
/*
22
 * File input/output, source, preserve and recover
18
 * File input/output, source, preserve and recover
23
 */
19
 */
24
 
20
 
Line 43... Line 39...
43
/*
39
/*
44
 * Parse file name for command encoded by comm.
40
 * Parse file name for command encoded by comm.
45
 * If comm is E then command is doomed and we are
41
 * If comm is E then command is doomed and we are
46
 * parsing just so user won't have to retype the name.
42
 * parsing just so user won't have to retype the name.
47
 */
43
 */
48
void
-
 
49
filename(comm)
44
filename(comm)
50
	int comm;
45
	int comm;
51
{
46
{
52
	register int c = comm, d;
47
	register int c = comm, d;
53
	register int i;
48
	register int i;
54
 
49
 
55
	d = getchar();
50
	d = getchar();
56
	if (endcmd(d)) {
51
	if (endcmd(d)) {
57
		if (savedfile[0] == 0 && comm != 'f')
52
		if (savedfile[0] == 0 && comm != 'f')
58
			error("No file|No current filename");
53
			error("No file|No current filename");
59
		strcpy(file, savedfile);
54
		CP(file, savedfile);
60
		wasalt = (isalt > 0) ? isalt-1 : 0;
55
		wasalt = (isalt > 0) ? isalt-1 : 0;
61
		isalt = 0;
56
		isalt = 0;
62
		oldadot = altdot;
57
		oldadot = altdot;
63
		if (c == 'e' || c == 'E')
58
		if (c == 'e' || c == 'E')
64
			altdot = lineDOT();
59
			altdot = lineDOT();
Line 81... Line 76...
81
			/* fall into ... */
76
			/* fall into ... */
82
 
77
 
83
		case 'e':
78
		case 'e':
84
			if (savedfile[0]) {
79
			if (savedfile[0]) {
85
				altdot = lineDOT();
80
				altdot = lineDOT();
86
				strcpy(altfile, savedfile);
81
				CP(altfile, savedfile);
87
			}
82
			}
88
			strcpy(savedfile, file);
83
			CP(savedfile, file);
89
			break;
84
			break;
90
 
85
 
91
		default:
86
		default:
92
			if (file[0]) {
87
			if (file[0]) {
93
				if (c != 'E')
88
				if (c != 'E')
94
					altdot = lineDOT();
89
					altdot = lineDOT();
95
				strcpy(altfile, file);
90
				CP(altfile, file);
96
			}
91
			}
97
			break;
92
			break;
98
		}
93
		}
99
	}
94
	}
100
	if (hush && comm != 'f' || comm == 'E')
95
	if (hush && comm != 'f' || comm == 'E')
Line 146... Line 141...
146
			}
141
			}
147
		}
142
		}
148
	}
143
	}
149
	if (skipend())
144
	if (skipend())
150
		return (0);
145
		return (0);
151
	strcpy(genbuf, "echo "); cp = &genbuf[5];
146
	CP(genbuf, "echo "); cp = &genbuf[5];
152
	for (;;) {
147
	for (;;) {
153
		c = getchar();
148
		c = getchar();
154
		if (endcmd(c)) {
149
		if (endcmd(c)) {
155
			ungetchar(c);
150
			ungetchar(c);
156
			break;
151
			break;
Line 194... Line 189...
194
 
189
 
195
/*
190
/*
196
 * Glob the argument words in genbuf, or if no globbing
191
 * Glob the argument words in genbuf, or if no globbing
197
 * is implied, just split them up directly.
192
 * is implied, just split them up directly.
198
 */
193
 */
199
void
-
 
200
glob(gp)
194
glob(gp)
201
	struct glob *gp;
195
	struct glob *gp;
202
{
196
{
203
	int pvec[2];
197
	int pvec[2];
204
	register char **argv = gp->argv;
198
	register char **argv = gp->argv;
Line 312... Line 306...
312
		error("Ambiguous|Too many file names");
306
		error("Ambiguous|Too many file names");
313
	str = G.argv[G.argc0 - 1];
307
	str = G.argv[G.argc0 - 1];
314
	if (strlen(str) > FNSIZE - 4)
308
	if (strlen(str) > FNSIZE - 4)
315
		error("Filename too long");
309
		error("Filename too long");
316
samef:
310
samef:
317
	strcpy(file, str);
311
	CP(file, str);
318
}
312
}
319
 
313
 
320
/*
314
/*
321
 * Read a file from the world.
315
 * Read a file from the world.
322
 * C is command, 'e' if this really an edit (or a recover).
316
 * C is command, 'e' if this really an edit (or a recover).
323
 */
317
 */
324
void
-
 
325
rop(c)
318
rop(c)
326
	int c;
319
	int c;
327
{
320
{
328
	register int i;
321
	register int i;
329
	struct stat stbuf;
322
	struct stat stbuf;
Line 551... Line 544...
551
			error("No file|No current filename");
544
			error("No file|No current filename");
552
		saddr1=addr1;
545
		saddr1=addr1;
553
		saddr2=addr2;
546
		saddr2=addr2;
554
		addr1=one;
547
		addr1=one;
555
		addr2=dol;
548
		addr2=dol;
556
		strcpy(file, savedfile);
549
		CP(file, savedfile);
557
		if (inopen) {
550
		if (inopen) {
558
			vclrech(0);
551
			vclrech(0);
559
			splitw++;
552
			splitw++;
560
		}
553
		}
561
		lprintf("\"%s\"", file);
554
		lprintf("\"%s\"", file);
Line 706... Line 699...
706
}
699
}
707
 
700
 
708
/*
701
/*
709
 * Write a range onto the io stream.
702
 * Write a range onto the io stream.
710
 */
703
 */
711
void
-
 
712
putfile(isfilter)
704
putfile(isfilter)
713
int isfilter;
705
int isfilter;
714
{
706
{
715
	line *a1;
707
	line *a1;
716
	register char *fp, *lp;
708
	register char *fp, *lp;
Line 780... Line 772...
780
 * Traps errors since it mungs unit 0 during the source.
772
 * Traps errors since it mungs unit 0 during the source.
781
 */
773
 */
782
short slevel;
774
short slevel;
783
short ttyindes;
775
short ttyindes;
784
 
776
 
785
void
-
 
786
source(fil, okfail)
777
source(fil, okfail)
787
	char *fil;
778
	char *fil;
788
	bool okfail;
779
	bool okfail;
789
{
780
{
790
	jmp_buf osetexit;
781
	jmp_buf osetexit;
Line 893... Line 884...
893
/* It's so wonderful how we all speak the same language... */
884
/* It's so wonderful how we all speak the same language... */
894
# define index strchr
885
# define index strchr
895
# define rindex strrchr
886
# define rindex strrchr
896
#endif
887
#endif
897
 
888
 
898
void
-
 
899
checkmodeline(li_ne)
889
checkmodeline(li_ne)
900
char *li_ne;
890
char *li_ne;
901
{
891
{
902
	char *beg, *end;
892
	char *beg, *end;
903
	char cmdbuf[1024];
893
	char cmdbuf[1024];