modelines are in the first or last five lines of a file, and look like:
[ \t]ex:command: or [ \t]vi:command:
and mark has mumbled something about their not working all the time.
SCCS-vsn: usr.bin/ex/ex_io.c 7.7
/* Copyright (c) 1981 Regents of the University of California */
/* Copyright (c) 1981 Regents of the University of California */
-static char *sccsid = "@(#)ex_io.c 7.6 %G%";
+static char *sccsid = "@(#)ex_io.c 7.7 %G%";
#include "ex.h"
#include "ex_argv.h"
#include "ex_temp.h"
#include "ex.h"
#include "ex_argv.h"
#include "ex_temp.h"
first = addr2 + 1;
ignore(append(getfile, addr2));
last = dot;
first = addr2 + 1;
ignore(append(getfile, addr2));
last = dot;
- for (a=first; a<=last; a++) {
- if (a==first+5 && last-first > 10)
- a = last - 4;
- getline(*a);
- checkmodeline(linebuf);
+ /*
+ * if the modeline variable is set,
+ * check the first and last five lines of the file
+ * for a mode line.
+ */
+ if (value(MODELINE)) {
+ for (a=first; a<=last; a++) {
+ if (a==first+5 && last-first > 10)
+ a = last - 4;
+ getline(*a);
+ checkmodeline(linebuf);
+ }
beg = index(line, ':');
if (beg == NULL)
return;
beg = index(line, ':');
if (beg == NULL)
return;
- if (beg[-2] != 'e' && beg[-2] != 'v') return;
- if (beg[-1] != 'x' && beg[-1] != 'i') return;
-
+ if (&beg[-3] < line)
+ return;
+ if (!( ( (beg[-3] == ' ' || beg[-3] == '\t')
+ && beg[-2] == 'e'
+ && beg[-1] == 'x')
+ || ( (beg[-3] == ' ' || beg[-3] == '\t')
+ && beg[-2] == 'v'
+ && beg[-1] == 'i'))) return;
strncpy(cmdbuf, beg+1, sizeof cmdbuf);
end = rindex(cmdbuf, ':');
if (end == NULL)
strncpy(cmdbuf, beg+1, sizeof cmdbuf);
end = rindex(cmdbuf, ':');
if (end == NULL)