From c3f352d4ad515968c54d216a0e53252eff8ab3ef Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 30 Dec 1995 19:02:48 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r13122, which included commits to RCS files with non-trunk default branches. --- usr.bin/apropos/Makefile | 7 - usr.bin/apropos/apropos.1 | 120 - usr.bin/apropos/apropos.c | 223 - usr.bin/ar/ar.5.5 | 145 - usr.bin/bdes/Makefile | 5 - usr.bin/bdes/bdes.1 | 304 - usr.bin/bdes/bdes.c | 1046 -- usr.bin/bdes/bdes.ps | 2945 ---- usr.bin/chat/fix-cua | 16 - usr.bin/compile_et/error_message.c | 77 - usr.bin/compile_et/error_table.h | 17 - usr.bin/compile_et/et_name.c | 44 - usr.bin/compile_et/init_et.c | 67 - usr.bin/compile_et/perror.c | 76 - usr.bin/compile_et/test/test.c | 43 - usr.bin/compile_et/test/test1.et | 69 - usr.bin/compile_et/test/test2.et | 9 - usr.bin/compress/zcat.sh | 37 - usr.bin/diff/diff/diff.1 | 387 - usr.bin/diff/diff3/diff3.1 | 172 - usr.bin/ee/ee.msg | 170 - usr.bin/f2c/dependencies | 60 - usr.bin/f2c/f2c.1t | 336 - usr.bin/f2c/gram.c | 1829 -- usr.bin/f2c/makefile | 90 - usr.bin/f2c/xsum0.out | 56 - usr.bin/grep/egrep/egrep.c | 924 - usr.bin/grep/egrep/grep.1 | 250 - usr.bin/grep/egrep/pathnames.h | 40 - usr.bin/ld/Makefile | 7 - usr.bin/ld/cplus-dem.c | 970 -- usr.bin/ld/ld.c | 4718 ----- usr.bin/ld/symseg.h | 358 - usr.bin/lex/flex.1 | 1001 -- usr.bin/lex/flexdoc.1 | 3045 ---- usr.bin/m4/serv.c | 475 - usr.bin/man/Makefile | 8 - usr.bin/man/config.c | 174 - usr.bin/man/config.h | 57 - usr.bin/man/man.1 | 188 - usr.bin/man/man.c | 712 - usr.bin/man/man.conf | 46 - usr.bin/man/man.conf.5 | 195 - usr.bin/man/pathnames.h | 39 - usr.bin/mklocale/Japanese | 158 - usr.bin/ncftp/Makefile.ORIG | 287 - usr.bin/ncftp/v2_Note | 35 - usr.bin/passwd/kpasswd_proto.h | 54 - usr.bin/passwd/krb_passwd.c | 319 - usr.bin/patch/EXTERN.h | 15 - usr.bin/patch/INTERN.h | 15 - usr.bin/patch/Makefile | 6 - usr.bin/patch/README | 79 - usr.bin/patch/common.h | 138 - usr.bin/patch/config.h | 16 - usr.bin/patch/inp.c | 313 - usr.bin/patch/inp.h | 18 - usr.bin/patch/patch.1 | 446 - usr.bin/patch/patch.c | 800 - usr.bin/patch/patchlevel.h | 1 - usr.bin/patch/pch.c | 1108 -- usr.bin/patch/pch.h | 36 - usr.bin/patch/util.c | 339 - usr.bin/patch/util.h | 74 - usr.bin/patch/version.c | 28 - usr.bin/patch/version.h | 9 - usr.bin/ranlib/ranlib.5.5 | 70 - usr.bin/rlogin/des_rw.c | 203 - usr.bin/sccs/Makefile | 5 - usr.bin/sccs/PSD.doc/Makefile | 10 - usr.bin/sccs/PSD.doc/sccs.me | 1608 -- usr.bin/sccs/PSD.doc/spell.ok | 77 - usr.bin/sccs/pathnames.h | 51 - usr.bin/sccs/sccs.1 | 398 - usr.bin/sccs/sccs.c | 1621 -- usr.bin/sort/sort.1 | 310 - usr.bin/timedef/Makefile | 13 - usr.bin/tip/acu.c | 196 - usr.bin/tip/aculib/biz22.c | 187 - usr.bin/tip/aculib/biz31.c | 248 - usr.bin/tip/aculib/courier.c | 380 - usr.bin/tip/aculib/df.c | 132 - usr.bin/tip/aculib/dn11.c | 142 - usr.bin/tip/aculib/hayes.c | 305 - usr.bin/tip/aculib/t3000.c | 408 - usr.bin/tip/aculib/v3451.c | 214 - usr.bin/tip/aculib/v831.c | 259 - usr.bin/tip/aculib/ventel.c | 251 - usr.bin/tip/acutab.c | 97 - usr.bin/tip/cmds.c | 888 - usr.bin/tip/cmdtab.c | 64 - usr.bin/tip/cu.c | 132 - usr.bin/tip/hunt.c | 93 - usr.bin/tip/log.c | 86 - usr.bin/tip/partab.c | 58 - usr.bin/tip/remcap.c | 426 - usr.bin/tip/remote.c | 226 - usr.bin/tip/tip.1 | 451 - usr.bin/tip/value.c | 353 - usr.bin/tip/vars.c | 112 - usr.bin/uucp/acucntrl/acucntrl.c | 814 - usr.bin/uucp/uupoll/uupoll.8 | 111 - usr.bin/uucp/uupoll/uupoll.c | 129 - usr.bin/uucp/uuq/Makefile | 9 - usr.bin/uucp/uuq/uuq.1 | 126 - usr.bin/uucp/uuq/uuq.c | 435 - usr.bin/uucp/uusend/Makefile | 6 - usr.bin/uucp/uusend/uusend.1 | 96 - usr.bin/uucp/uusend/uusend.c | 403 - usr.bin/uucp/uusnap/uusnap.8 | 80 - usr.bin/uucp/uusnap/uusnap.c | 348 - usr.bin/vi/USD.doc/vi.ref/paper.ps | 30924 --------------------------------- usr.bin/vi/USD.doc/vi.ref/vi.ref.txt | 5544 ------ usr.bin/whatis/Makefile | 7 - usr.bin/whatis/whatis.1 | 105 - usr.bin/whatis/whatis.c | 218 - usr.bin/which/which.sh | 62 - 117 files changed, 75342 deletions(-) delete mode 100644 usr.bin/apropos/Makefile delete mode 100644 usr.bin/apropos/apropos.1 delete mode 100644 usr.bin/apropos/apropos.c delete mode 100644 usr.bin/ar/ar.5.5 delete mode 100644 usr.bin/bdes/Makefile delete mode 100644 usr.bin/bdes/bdes.1 delete mode 100644 usr.bin/bdes/bdes.c delete mode 100644 usr.bin/bdes/bdes.ps delete mode 100644 usr.bin/chat/fix-cua delete mode 100644 usr.bin/compile_et/error_message.c delete mode 100644 usr.bin/compile_et/error_table.h delete mode 100644 usr.bin/compile_et/et_name.c delete mode 100644 usr.bin/compile_et/init_et.c delete mode 100644 usr.bin/compile_et/perror.c delete mode 100644 usr.bin/compile_et/test/test.c delete mode 100644 usr.bin/compile_et/test/test1.et delete mode 100644 usr.bin/compile_et/test/test2.et delete mode 100644 usr.bin/compress/zcat.sh delete mode 100644 usr.bin/diff/diff/diff.1 delete mode 100644 usr.bin/diff/diff3/diff3.1 delete mode 100644 usr.bin/ee/ee.msg delete mode 100644 usr.bin/f2c/dependencies delete mode 100644 usr.bin/f2c/f2c.1t delete mode 100644 usr.bin/f2c/gram.c delete mode 100644 usr.bin/f2c/makefile delete mode 100644 usr.bin/f2c/xsum0.out delete mode 100644 usr.bin/grep/egrep/egrep.c delete mode 100644 usr.bin/grep/egrep/grep.1 delete mode 100644 usr.bin/grep/egrep/pathnames.h delete mode 100644 usr.bin/ld/Makefile delete mode 100644 usr.bin/ld/cplus-dem.c delete mode 100644 usr.bin/ld/ld.c delete mode 100644 usr.bin/ld/symseg.h delete mode 100644 usr.bin/lex/flex.1 delete mode 100644 usr.bin/lex/flexdoc.1 delete mode 100644 usr.bin/m4/serv.c delete mode 100644 usr.bin/man/Makefile delete mode 100644 usr.bin/man/config.c delete mode 100644 usr.bin/man/config.h delete mode 100644 usr.bin/man/man.1 delete mode 100644 usr.bin/man/man.c delete mode 100644 usr.bin/man/man.conf delete mode 100644 usr.bin/man/man.conf.5 delete mode 100644 usr.bin/man/pathnames.h delete mode 100644 usr.bin/mklocale/Japanese delete mode 100644 usr.bin/ncftp/Makefile.ORIG delete mode 100644 usr.bin/ncftp/v2_Note delete mode 100644 usr.bin/passwd/kpasswd_proto.h delete mode 100644 usr.bin/passwd/krb_passwd.c delete mode 100644 usr.bin/patch/EXTERN.h delete mode 100644 usr.bin/patch/INTERN.h delete mode 100644 usr.bin/patch/Makefile delete mode 100644 usr.bin/patch/README delete mode 100644 usr.bin/patch/common.h delete mode 100644 usr.bin/patch/config.h delete mode 100644 usr.bin/patch/inp.c delete mode 100644 usr.bin/patch/inp.h delete mode 100644 usr.bin/patch/patch.1 delete mode 100644 usr.bin/patch/patch.c delete mode 100644 usr.bin/patch/patchlevel.h delete mode 100644 usr.bin/patch/pch.c delete mode 100644 usr.bin/patch/pch.h delete mode 100644 usr.bin/patch/util.c delete mode 100644 usr.bin/patch/util.h delete mode 100644 usr.bin/patch/version.c delete mode 100644 usr.bin/patch/version.h delete mode 100644 usr.bin/ranlib/ranlib.5.5 delete mode 100644 usr.bin/rlogin/des_rw.c delete mode 100644 usr.bin/sccs/Makefile delete mode 100644 usr.bin/sccs/PSD.doc/Makefile delete mode 100644 usr.bin/sccs/PSD.doc/sccs.me delete mode 100644 usr.bin/sccs/PSD.doc/spell.ok delete mode 100644 usr.bin/sccs/pathnames.h delete mode 100644 usr.bin/sccs/sccs.1 delete mode 100644 usr.bin/sccs/sccs.c delete mode 100644 usr.bin/sort/sort.1 delete mode 100644 usr.bin/timedef/Makefile delete mode 100644 usr.bin/tip/acu.c delete mode 100644 usr.bin/tip/aculib/biz22.c delete mode 100644 usr.bin/tip/aculib/biz31.c delete mode 100644 usr.bin/tip/aculib/courier.c delete mode 100644 usr.bin/tip/aculib/df.c delete mode 100644 usr.bin/tip/aculib/dn11.c delete mode 100644 usr.bin/tip/aculib/hayes.c delete mode 100644 usr.bin/tip/aculib/t3000.c delete mode 100644 usr.bin/tip/aculib/v3451.c delete mode 100644 usr.bin/tip/aculib/v831.c delete mode 100644 usr.bin/tip/aculib/ventel.c delete mode 100644 usr.bin/tip/acutab.c delete mode 100644 usr.bin/tip/cmds.c delete mode 100644 usr.bin/tip/cmdtab.c delete mode 100644 usr.bin/tip/cu.c delete mode 100644 usr.bin/tip/hunt.c delete mode 100644 usr.bin/tip/log.c delete mode 100644 usr.bin/tip/partab.c delete mode 100644 usr.bin/tip/remcap.c delete mode 100644 usr.bin/tip/remote.c delete mode 100644 usr.bin/tip/tip.1 delete mode 100644 usr.bin/tip/value.c delete mode 100644 usr.bin/tip/vars.c delete mode 100644 usr.bin/uucp/acucntrl/acucntrl.c delete mode 100644 usr.bin/uucp/uupoll/uupoll.8 delete mode 100644 usr.bin/uucp/uupoll/uupoll.c delete mode 100644 usr.bin/uucp/uuq/Makefile delete mode 100644 usr.bin/uucp/uuq/uuq.1 delete mode 100644 usr.bin/uucp/uuq/uuq.c delete mode 100644 usr.bin/uucp/uusend/Makefile delete mode 100644 usr.bin/uucp/uusend/uusend.1 delete mode 100644 usr.bin/uucp/uusend/uusend.c delete mode 100644 usr.bin/uucp/uusnap/uusnap.8 delete mode 100644 usr.bin/uucp/uusnap/uusnap.c delete mode 100644 usr.bin/vi/USD.doc/vi.ref/paper.ps delete mode 100644 usr.bin/vi/USD.doc/vi.ref/vi.ref.txt delete mode 100644 usr.bin/whatis/Makefile delete mode 100644 usr.bin/whatis/whatis.1 delete mode 100644 usr.bin/whatis/whatis.c delete mode 100755 usr.bin/which/which.sh (limited to 'usr.bin') diff --git a/usr.bin/apropos/Makefile b/usr.bin/apropos/Makefile deleted file mode 100644 index 028a42c..0000000 --- a/usr.bin/apropos/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= apropos -SRCS= apropos.c config.c -.PATH: ${.CURDIR}/../man - -.include diff --git a/usr.bin/apropos/apropos.1 b/usr.bin/apropos/apropos.1 deleted file mode 100644 index eb68f37..0000000 --- a/usr.bin/apropos/apropos.1 +++ /dev/null @@ -1,120 +0,0 @@ -.\" Copyright (c) 1989, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)apropos.1 8.1 (Berkeley) 6/29/93 -.\" -.Dd June 29, 1993 -.Dt APROPOS 1 -.Os -.Sh NAME -.Nm apropos -.Nd locate commands by keyword lookup -.Sh SYNOPSIS -.Nm apropos -.Op Fl M Ar path -.Op Fl m Ar path -.Ar keyword ... -.Sh DESCRIPTION -.Nm Apropos -shows which manual pages contain instances of any of the given -.Ar keyword(s) -in their title line. -Each word is considered separately and case of letters is ignored. -Words which are part of other words are considered; when looking for -.Dq compile , -.Nm apropos -will also list all instances of -.Dq compiler . -.Pp -If the line output by -.Nm apropos -starts -.Dq Li name(section) ... -you can enter -.Dq Li man section name -to get -its documentation. -.Pp -The options are as follows: -.Bl -tag -width flag -.It Fl M -Override the list of standard directories -.Nm apropos -searches for a database named -.Pa whatis.db . -The supplied -.Ar path -must be a colon -.Dq \&: -separated list of directories. -This search path may also be set using the environment variable -.Ev MANPATH . -.It Fl m -Augment the list of standard directories -.Nm apropos -searches for its database. -The supplied -.Ar path -must be a colon -.Dq \&: -separated list of directories. -These directories will be searched before the standard directories, -or the directories supplied with the -.Fl M -option or the -.Ev MANPATH -environment variable. -.Sh ENVIRONMENT -.Bl -tag -width MANPATH -.It Ev MANPATH -The standard search path used by -.Xr man 1 -may be overridden by specifying a path in the -.Ev MANPATH -environment variable. -The format of the path is a colon -.Dq \&: -separated list of directories. -.El -.Sh FILES -.Bl -tag -width whatis.db -compact -.It Pa whatis.db -name of the apropos database -.El -.Sh SEE ALSO -.Xr man 1 , -.Xr whatis 1 , -.Xr whereis 1 -.Sh HISTORY -The -.Nm apropos -command appeared in -.Bx 3.0 . diff --git a/usr.bin/apropos/apropos.c b/usr.bin/apropos/apropos.c deleted file mode 100644 index a0e0525..0000000 --- a/usr.bin/apropos/apropos.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) 1987, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1987, 1993, 1994\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)apropos.c 8.7 (Berkeley) 4/2/94"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "../man/config.h" -#include "../man/pathnames.h" - -static int *found, foundman; - -void apropos __P((char **, char *, int)); -void lowstr __P((char *, char *)); -int match __P((char *, char *)); -void usage __P((void)); - -int -main(argc, argv) - int argc; - char *argv[]; -{ - ENTRY *ep; - TAG *tp; - int ch, rv; - char *conffile, **p, *p_augment, *p_path; - - conffile = NULL; - p_augment = p_path = NULL; - while ((ch = getopt(argc, argv, "C:M:m:P:")) != EOF) - switch (ch) { - case 'C': - conffile = optarg; - break; - case 'M': - case 'P': /* backward compatible */ - p_path = optarg; - break; - case 'm': - p_augment = optarg; - break; - case '?': - default: - usage(); - } - argv += optind; - argc -= optind; - - if (argc < 1) - usage(); - - if ((found = malloc((u_int)argc * sizeof(int))) == NULL) - err(1, NULL); - memset(found, 0, argc * sizeof(int)); - - for (p = argv; *p; ++p) /* convert to lower-case */ - lowstr(*p, *p); - - if (p_augment) - apropos(argv, p_augment, 1); - if (p_path || (p_path = getenv("MANPATH"))) - apropos(argv, p_path, 1); - else { - config(conffile); - ep = (tp = getlist("_whatdb")) == NULL ? - NULL : tp->list.tqh_first; - for (; ep != NULL; ep = ep->q.tqe_next) - apropos(argv, ep->s, 0); - } - - if (!foundman) - errx(1, "no %s file found", _PATH_WHATIS); - - rv = 1; - for (p = argv; *p; ++p) - if (found[p - argv]) - rv = 0; - else - (void)printf("%s: nothing appropriate\n", *p); - exit(rv); -} - -void -apropos(argv, path, buildpath) - char **argv, *path; - int buildpath; -{ - char *end, *name, **p; - char buf[LINE_MAX + 1], wbuf[LINE_MAX + 1]; - - for (name = path; name; name = end) { /* through name list */ - if (end = strchr(name, ':')) - *end++ = '\0'; - - if (buildpath) { - char hold[MAXPATHLEN + 1]; - - (void)sprintf(hold, "%s/%s", name, _PATH_WHATIS); - name = hold; - } - - if (!freopen(name, "r", stdin)) - continue; - - foundman = 1; - - /* for each file found */ - while (fgets(buf, sizeof(buf), stdin)) { - if (!strchr(buf, '\n')) { - warnx("%s: line too long", name); - continue; - } - lowstr(buf, wbuf); - for (p = argv; *p; ++p) - if (match(wbuf, *p)) { - (void)printf("%s", buf); - found[p - argv] = 1; - - /* only print line once */ - while (*++p) - if (match(wbuf, *p)) - found[p - argv] = 1; - break; - } - } - } -} - -/* - * match -- - * match anywhere the string appears - */ -int -match(bp, str) - char *bp, *str; -{ - int len; - char test; - - if (!*bp) - return (0); - /* backward compatible: everything matches empty string */ - if (!*str) - return (1); - for (test = *str++, len = strlen(str); *bp;) - if (test == *bp++ && !strncmp(bp, str, len)) - return (1); - return (0); -} - -/* - * lowstr -- - * convert a string to lower case - */ -void -lowstr(from, to) - char *from, *to; -{ - char ch; - - while ((ch = *from++) && ch != '\n') - *to++ = isupper(ch) ? tolower(ch) : ch; - *to = '\0'; -} - -/* - * usage -- - * print usage message and die - */ -void -usage() -{ - - (void)fprintf(stderr, - "usage: apropos [-C file] [-M path] [-m path] keyword ...\n"); - exit(1); -} diff --git a/usr.bin/ar/ar.5.5 b/usr.bin/ar/ar.5.5 deleted file mode 100644 index 29c8f8c..0000000 --- a/usr.bin/ar/ar.5.5 +++ /dev/null @@ -1,145 +0,0 @@ -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ar.5.5 8.1 (Berkeley) 6/9/93 -.\" -.Dd June 9, 1993 -.Dt AR 5 -.Os -.Sh NAME -.Nm ar -.Nd archive (library) file format -.Sh SYNOPSIS -.Fd #include -.Sh DESCRIPTION -The archive command -.Nm ar -combines several files into one. -Archives are mainly used as libraries of object files intended to be -loaded using the link-editor -.Xr ld 1 . -.Pp -A file created with -.Nm ar -begins with the ``magic'' string "!\en". -The rest of the archive is made up of objects, each of which is composed -of a header for a file, a possible file name, and the file contents. -The header is portable between machine architectures, and, if the file -contents are printable, the archive is itself printable. -.Pp -The header is made up of six variable length -.Tn ASCII -fields, followed by a -two character trailer. -The fields are the object name (16 characters), the file last modification -time (12 characters), the user and group id's (each 6 characters), the file -mode (8 characters) and the file size (10 characters). -All numeric fields are in decimal, except for the file mode which is in -octal. -.Pp -The modification time is the file -.Fa st_mtime -field, i.e., -.Dv CUT -seconds since -the epoch. -The user and group id's are the file -.Fa st_uid -and -.Fa st_gid -fields. -The file mode is the file -.Fa st_mode -field. -The file size is the file -.Fa st_size -field. -The two-byte trailer is the string "\`\en". -.Pp -Only the name field has any provision for overflow. -If any file name is more than 16 characters in length or contains an -embedded space, the string "#1/" followed by the -.Tn ASCII -length of the -name is written in the name field. -The file size (stored in the archive header) is incremented by the length -of the name. -The name is then written immediately following the archive header. -.Pp -Any unused characters in any of these fields are written as space -characters. -If any fields are their particular maximum number of characters in -length, there will be no separation between the fields. -.Pp -Objects in the archive are always an even number of bytes long; files -which are an odd number of bytes long are padded with a newline (``\en'') -character, although the size in the header does not reflect this. -.Sh SEE ALSO -.Xr ar 1 , -.Xr stat 2 -.Sh HISTORY -There have been at least four -.Nm ar -formats. -The first was denoted by the leading ``magic'' number 0177555 (stored as -type int). -These archives were almost certainly created on a 16-bit machine, and -contain headers made up of five fields. -The fields are the object name (8 characters), the file last modification -time (type long), the user id (type char), the file mode (type char) and -the file size (type unsigned int). -Files were padded to an even number of bytes. -.Pp -The second was denoted by the leading ``magic'' number 0177545 (stored as -type int). -These archives may have been created on either 16 or 32-bit machines, and -contain headers made up of six fields. -The fields are the object name (14 characters), the file last modification -time (type long), the user and group id's (each type char), the file mode -(type int) and the file size (type long). -Files were padded to an even number of bytes. -For more information on converting from this format see -.Xr arcv 8 . -.Pp -The current archive format (without support for long character names and -names with embedded spaces) was introduced in -.Bx 4.0 . -The headers were the same as the current format, with the exception that -names longer than 16 characters were truncated, and names with embedded -spaces (and often trailing spaces) were not supported. -It has been extended for these reasons, -as described above. -This format first appeared in 4.4BSD. -.Sh COMPATIBILITY -No archive format is currently specified by any standard. -.At V -has historically distributed archives in a different format from -all of the above. diff --git a/usr.bin/bdes/Makefile b/usr.bin/bdes/Makefile deleted file mode 100644 index 9166f72..0000000 --- a/usr.bin/bdes/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= bdes - -.include diff --git a/usr.bin/bdes/bdes.1 b/usr.bin/bdes/bdes.1 deleted file mode 100644 index eecd81b..0000000 --- a/usr.bin/bdes/bdes.1 +++ /dev/null @@ -1,304 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Matt Bishop of Dartmouth College. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)bdes.1 8.1 (Berkeley) 6/29/93 -.\" -.TH BDES 1 "June 29, 1993" -.UC 6 -.SH NAME -bdes \- encrypt/decrypt using the Data Encryption Standard -.SH SYNOPSIS -.nf -.ft B -bdes [ \-abdp ] [ \-F N ] [ \-f N ] [ \-k key ] -.ti +5 -[ \-m N ] [ \-o N ] [ \-v vector ] -.ft R -.fi -.SH DESCRIPTION -.I Bdes -implements all DES modes of operation described in FIPS PUB 81, -including alternative cipher feedback mode and both authentication -modes. -.I Bdes -reads from the standard input and writes to the standard output. -By default, the input is encrypted using cipher block chaining mode. -Using the same key for encryption and decryption preserves plain text. -.PP -All modes but the electronic code book mode require an initialization -vector; if none is supplied, the zero vector is used. -If no -.I key -is specified on the command line, the user is prompted for one (see -.IR getpass (3) -for more details). -.PP -The options are as follows: -.TP -\-a -The key and initialization vector strings are to be taken as ASCII, -suppressing the special interpretation given to leading ``0X'', ``0x'', -``0B'', and ``0b'' characters. -This flag applies to -.I both -the key and initialization vector. -.TP -\-b -Use electronic code book mode. -.TP -\-d -Decrypt the input. -.TP -\-F -Use -.IR N -bit -alternative cipher feedback mode. -Currently -.I N -must be a multiple of 7 between 7 and 56 inclusive (this does not conform -to the alternative CFB mode specification). -.TP -\-f -Use -.IR N -bit -cipher feedback mode. -Currently -.I N -must be a multiple of 8 between 8 and 64 inclusive (this does not conform -to the standard CFB mode specification). -.TP -\-k -Use -.I key -as the cryptographic key. -.TP -\-m -Compute a message authentication code (MAC) of -.I N -bits on the input. -The value of -.I N -must be between 1 and 64 inclusive; if -.I N -is not a multiple of 8, enough 0 bits will be added to pad the MAC length -to the nearest multiple of 8. -Only the MAC is output. -MACs are only available in cipher block chaining mode or in cipher feedback -mode. -.TP -\-o -Use -.IR N -bit -output feedback mode. -Currently -.I N -must be a multiple of 8 between 8 and 64 inclusive (this does not conform -to the OFB mode specification). -.TP -\-p -Disable the resetting of the parity bit. -This flag forces the parity bit of the key to be used as typed, rather than -making each character be of odd parity. -It is used only if the key is given in ASCII. -.TP -\-v -Set the initialization vector to -.IR vector ; -the vector is interpreted in the same way as the key. -The vector is ignored in electronic codebook mode. -.PP -The key and initialization vector are taken as sequences of ASCII -characters which are then mapped into their bit representations. -If either begins with ``0X'' or ``0x'', -that one is taken as a sequence of hexadecimal digits indicating the -bit pattern; -if either begins with ``0B'' or ``0b'', -that one is taken as a sequence of binary digits indicating the bit pattern. -In either case, -only the leading 64 bits of the key or initialization vector -are used, -and if fewer than 64 bits are provided, enough 0 bits are appended -to pad the key to 64 bits. -.PP -According to the DES standard, the low-order bit of each character in the -key string is deleted. -Since most ASCII representations set the high-order bit to 0, simply -deleting the low-order bit effectively reduces the size of the key space -from 2\u\s-356\s0\d to 2\u\s-348\s0\d keys. -To prevent this, the high-order bit must be a function depending in part -upon the low-order bit; so, the high-order bit is set to whatever value -gives odd parity. -This preserves the key space size. -Note this resetting of the parity bit is -.I not -done if the key is given in binary or hex, and can be disabled for ASCII -keys as well. -.PP -The DES is considered a very strong cryptosystem, and other than table lookup -attacks, key search attacks, and Hellman's time-memory tradeoff (all of which -are very expensive and time-consuming), no cryptanalytic methods for breaking -the DES are known in the open literature. -No doubt the choice of keys and key security are the most vulnerable aspect -of -.IR bdes . -.SH IMPLEMENTATION NOTES -For implementors wishing to write software compatible with this program, -the following notes are provided. -This software is believed to be compatible with the implementation of the -data encryption standard distributed by Sun Microsystems, Inc. -.PP -In the ECB and CBC modes, plaintext is encrypted in units of 64 bits (8 bytes, -also called a block). -To ensure that the plaintext file is encrypted correctly, -.I bdes -will (internally) append from 1 to 8 bytes, the last byte containing an -integer stating how many bytes of that final block are from the plaintext -file, and encrypt the resulting block. -Hence, when decrypting, the last block may contain from 0 to 7 characters -present in the plaintext file, and the last byte tells how many. -Note that if during decryption the last byte of the file does not contain an -integer between 0 and 7, either the file has been corrupted or an incorrect -key has been given. -A similar mechanism is used for the OFB and CFB modes, except that those -simply require the length of the input to be a multiple of the mode size, -and the final byte contains an integer between 0 and one less than the number -of bytes being used as the mode. -(This was another reason that the mode size must be a multiple of 8 for those -modes.) -.PP -Unlike Sun's implementation, unused bytes of that last block are not filled -with random data, but instead contain what was in those byte positions in -the preceding block. -This is quicker and more portable, and does not weaken the encryption -significantly. -.PP -If the key is entered in ASCII, the parity bits of the key characters are set -so that each key character is of odd parity. -Unlike Sun's implementation, it is possible to enter binary or hexadecimal -keys on the command line, and if this is done, the parity bits are -.I not -reset. -This allows testing using arbitrary bit patterns as keys. -.PP -The Sun implementation always uses an initialization vector of 0 -(that is, all zeroes). -By default, -.I bdes -does too, but this may be changed from the command line. -.SH SEE ALSO -crypt(1), crypt(3), getpass(3) -.sp -.IR "Data Encryption Standard" , -Federal Information Processing Standard #46, -National Bureau of Standards, -U.S. Department of Commerce, -Washington DC -(Jan. 1977) -.sp -.IR "DES Modes of Operation" , -Federal Information Processing Standard #81, -National Bureau of Standards, -U.S. Department of Commerce -Washington DC -(Dec. 1980) -.sp -Dorothy Denning, -.IR "Cryptography and Data Security" , -Addison-Wesley Publishing Co., -Reading, MA -\(co1982. -.sp -Matt Bishop, -.IR "Implementation Notes on bdes(1)" , -Technical Report PCS-TR-91-158, -Department of Mathematics and Computer Science, -Dartmouth College, -Hanover, NH 03755 -(Apr. 1991). -.SH DISCLAIMER -.nf -THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. -.fi -.SH BUGS -There is a controversy raging over whether the DES will still be secure -in a few years. -The advent of special-purpose hardware could reduce the cost of any of the -methods of attack named above so that they are no longer computationally -infeasible. -.PP -As the key or key schedule is stored in memory, the encryption can be -compromised if memory is readable. -Additionally, programs which display programs' arguments may compromise the -key and initialization vector, if they are specified on the command line. -To avoid this -.I bdes -overwrites its arguments, however, the obvious race cannot currently be -avoided. -.PP -Certain specific keys should be avoided because they introduce potential -weaknesses; these keys, called the -.I weak -and -.I semiweak -keys, are (in hex notation, where p is either 0 or 1, and P is either -e or f): -.sp -.nf -.in +10n -.ta \w'0x0p0p0p0p0p0p0p0p\0\0\0'u+5n -0x0p0p0p0p0p0p0p0p 0x0p1P0p1P0p0P0p0P -0x0pep0pep0pfp0pfp 0x0pfP0pfP0pfP0pfP -0x1P0p1P0p0P0p0P0p 0x1P1P1P1P0P0P0P0P -0x1Pep1Pep0Pfp0Pfp 0x1PfP1PfP0PfP0PfP -0xep0pep0pfp0pfp0p 0xep1Pep1pfp0Pfp0P -0xepepepepepepepep 0xepfPepfPfpfPfpfP -0xfP0pfP0pfP0pfP0p 0xfP1PfP1PfP0PfP0P -0xfPepfPepfPepfPep 0xfPfPfPfPfPfPfPfP -.fi -.in -10n -.sp -This is inherent in the DES algorithm (see Moore and Simmons, -\*(LqCycle structure of the DES with weak and semi-weak keys,\*(Rq -.I "Advances in Cryptology \- Crypto '86 Proceedings" , -Springer-Verlag New York, \(co1987, pp. 9-32.) diff --git a/usr.bin/bdes/bdes.c b/usr.bin/bdes/bdes.c deleted file mode 100644 index f702e01..0000000 --- a/usr.bin/bdes/bdes.c +++ /dev/null @@ -1,1046 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Matt Bishop of Dartmouth College. - * - * The United States Government has rights in this work pursuant - * to contract no. NAG 2-680 between the National Aeronautics and - * Space Administration and Dartmouth College. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)bdes.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * BDES -- DES encryption package for Berkeley Software Distribution 4.4 - * options: - * -a key is in ASCII - * -b use ECB (electronic code book) mode - * -d invert (decrypt) input - * -f b use b-bit CFB (cipher feedback) mode - * -F b use b-bit CFB (cipher feedback) alternative mode - * -k key use key as the cryptographic key - * -m b generate a MAC of length b - * -o b use b-bit OFB (output feedback) mode - * -p don't reset the parity bit - * -v v use v as the initialization vector (ignored for ECB) - * note: the last character of the last block is the integer indicating - * how many characters of that block are to be output - * - * Author: Matt Bishop - * Department of Mathematics and Computer Science - * Dartmouth College - * Hanover, NH 03755 - * Email: Matt.Bishop@dartmouth.edu - * ...!decvax!dartvax!Matt.Bishop - * - * See Technical Report PCS-TR91-158, Department of Mathematics and Computer - * Science, Dartmouth College, for a detailed description of the implemen- - * tation and differences between it and Sun's. The DES is described in - * FIPS PUB 46, and the modes in FIPS PUB 81 (see either the manual page - * or the technical report for a complete reference). - */ - -#include -#include -#include -#include -#include -#include - -/* - * BSD and System V systems offer special library calls that do - * block moves and fills, so if possible we take advantage of them - */ -#define MEMCPY(dest,src,len) bcopy((src),(dest),(len)) -#define MEMZERO(dest,len) bzero((dest),(len)) - -/* Hide the calls to the primitive encryption routines. */ -#define FASTWAY -#ifdef FASTWAY -#define DES_KEY(buf) \ - if (des_setkey(buf)) \ - err("des_setkey", 0); -#define DES_XFORM(buf) \ - if (des_cipher(buf, buf, 0L, (inverse ? -1 : 1))) \ - err("des_cipher", 0); -#else -#define DES_KEY(buf) { \ - char bits1[64]; /* bits of key */ \ - expand(buf, bits1); \ - if (setkey(bits1)) \ - err("setkey", 0); \ - } -#define DES_XFORM(buf) { \ - char bits1[64]; /* bits of message */ \ - expand(buf, bits1); \ - if (encrypt(bits1, inverse)) \ - err("encrypt", 0); \ - compress(bits1, buf); \ - } -#endif - -/* - * this does an error-checking write - */ -#define READ(buf, n) fread(buf, sizeof(char), n, stdin) -#define WRITE(buf,n) \ - if (fwrite(buf, sizeof(char), n, stdout) != n) \ - err(bn, NULL); - -/* - * some things to make references easier - */ -typedef char Desbuf[8]; -#define CHAR(x,i) (x[i]) -#define UCHAR(x,i) (x[i]) -#define BUFFER(x) (x) -#define UBUFFER(x) (x) - -/* - * global variables and related macros - */ -#define KEY_DEFAULT 0 /* interpret radix of key from key */ -#define KEY_ASCII 1 /* key is in ASCII characters */ -int keybase = KEY_DEFAULT; /* how to interpret the key */ - -enum { /* encrypt, decrypt, authenticate */ - MODE_ENCRYPT, MODE_DECRYPT, MODE_AUTHENTICATE -} mode = MODE_ENCRYPT; -enum { /* ecb, cbc, cfb, cfba, ofb? */ - ALG_ECB, ALG_CBC, ALG_CFB, ALG_OFB, ALG_CFBA -} alg = ALG_CBC; - -Desbuf ivec; /* initialization vector */ -char bits[] = { /* used to extract bits from a char */ - '\200', '\100', '\040', '\020', '\010', '\004', '\002', '\001' -}; -int inverse; /* 0 to encrypt, 1 to decrypt */ -int macbits = -1; /* number of bits in authentication */ -int fbbits = -1; /* number of feedback bits */ -int pflag; /* 1 to preserve parity bits */ - -main(ac, av) - int ac; /* arg count */ - char **av; /* arg vector */ -{ - extern int optind; /* option (argument) number */ - extern char *optarg; /* argument to option if any */ - register int i; /* counter in a for loop */ - register char *p; /* used to obtain the key */ - Desbuf msgbuf; /* I/O buffer */ - int kflag; /* command-line encryptiooon key */ - int argc; /* the real arg count */ - char **argv; /* the real argument vector */ - - /* - * Hide the arguments from ps(1) by making private copies of them - * and clobbering the global (visible to ps(1)) ones. - */ - argc = ac; - ac = 1; - argv = malloc((argc + 1) * sizeof(char *)); - for (i = 0; i < argc; ++i) { - argv[i] = strdup(av[i]); - MEMZERO(av[i], strlen(av[i])); - } - argv[argc] = NULL; - - /* initialize the initialization vctor */ - MEMZERO(ivec, 8); - - /* process the argument list */ - kflag = 0; - while ((i = getopt(argc, argv, "abdF:f:k:m:o:pv:")) != EOF) - switch(i) { - case 'a': /* key is ASCII */ - keybase = KEY_ASCII; - break; - case 'b': /* use ECB mode */ - alg = ALG_ECB; - break; - case 'd': /* decrypt */ - mode = MODE_DECRYPT; - break; - case 'F': /* use alternative CFB mode */ - alg = ALG_CFBA; - if ((fbbits = setbits(optarg, 7)) > 56 || fbbits == 0) - err(-1, "-F: number must be 1-56 inclusive"); - else if (fbbits == -1) - err(-1, "-F: number must be a multiple of 7"); - break; - case 'f': /* use CFB mode */ - alg = ALG_CFB; - if ((fbbits = setbits(optarg, 8)) > 64 || fbbits == 0) - err(-1, "-f: number must be 1-64 inclusive"); - else if (fbbits == -1) - err(-1, "-f: number must be a multiple of 8"); - break; - case 'k': /* encryption key */ - kflag = 1; - cvtkey(BUFFER(msgbuf), optarg); - break; - case 'm': /* number of bits for MACing */ - mode = MODE_AUTHENTICATE; - if ((macbits = setbits(optarg, 1)) > 64) - err(-1, "-m: number must be 0-64 inclusive"); - break; - case 'o': /* use OFB mode */ - alg = ALG_OFB; - if ((fbbits = setbits(optarg, 8)) > 64 || fbbits == 0) - err(-1, "-o: number must be 1-64 inclusive"); - else if (fbbits == -1) - err(-1, "-o: number must be a multiple of 8"); - break; - case 'p': /* preserve parity bits */ - pflag = 1; - break; - case 'v': /* set initialization vector */ - cvtkey(BUFFER(ivec), optarg); - break; - default: /* error */ - usage(); - } - - if (!kflag) { - /* - * if the key's not ASCII, assume it is - */ - keybase = KEY_ASCII; - /* - * get the key - */ - p = getpass("Enter key: "); - /* - * copy it, nul-padded, into the key area - */ - cvtkey(BUFFER(msgbuf), p); - } - - makekey(msgbuf); - inverse = (alg == ALG_CBC || alg == ALG_ECB) && mode == MODE_DECRYPT; - - switch(alg) { - case ALG_CBC: - switch(mode) { - case MODE_AUTHENTICATE: /* authenticate using CBC mode */ - cbcauth(); - break; - case MODE_DECRYPT: /* decrypt using CBC mode */ - cbcdec(); - break; - case MODE_ENCRYPT: /* encrypt using CBC mode */ - cbcenc(); - break; - } - break; - case ALG_CFB: - switch(mode) { - case MODE_AUTHENTICATE: /* authenticate using CFB mode */ - cfbauth(); - break; - case MODE_DECRYPT: /* decrypt using CFB mode */ - cfbdec(); - break; - case MODE_ENCRYPT: /* encrypt using CFB mode */ - cfbenc(); - break; - } - break; - case ALG_CFBA: - switch(mode) { - case MODE_AUTHENTICATE: /* authenticate using CFBA mode */ - err(-1, "can't authenticate with CFBA mode"); - break; - case MODE_DECRYPT: /* decrypt using CFBA mode */ - cfbadec(); - break; - case MODE_ENCRYPT: /* encrypt using CFBA mode */ - cfbaenc(); - break; - } - break; - case ALG_ECB: - switch(mode) { - case MODE_AUTHENTICATE: /* authenticate using ECB mode */ - err(-1, "can't authenticate with ECB mode"); - break; - case MODE_DECRYPT: /* decrypt using ECB mode */ - ecbdec(); - break; - case MODE_ENCRYPT: /* encrypt using ECB mode */ - ecbenc(); - break; - } - break; - case ALG_OFB: - switch(mode) { - case MODE_AUTHENTICATE: /* authenticate using OFB mode */ - err(-1, "can't authenticate with OFB mode"); - break; - case MODE_DECRYPT: /* decrypt using OFB mode */ - ofbdec(); - break; - case MODE_ENCRYPT: /* encrypt using OFB mode */ - ofbenc(); - break; - } - break; - } - exit(0); -} - -/* - * print a warning message and, possibly, terminate - */ -err(n, s) - int n; /* offending block number */ - char *s; /* the message */ -{ - if (n > 0) - (void)fprintf(stderr, "bdes (block %d): ", n); - else - (void)fprintf(stderr, "bdes: "); - (void)fprintf(stderr, "%s\n", s ? s : strerror(errno)); - exit(1); -} - -/* - * map a hex character to an integer - */ -tobinhex(c, radix) - char c; /* char to be converted */ - int radix; /* base (2 to 16) */ -{ - switch(c) { - case '0': return(0x0); - case '1': return(0x1); - case '2': return(radix > 2 ? 0x2 : -1); - case '3': return(radix > 3 ? 0x3 : -1); - case '4': return(radix > 4 ? 0x4 : -1); - case '5': return(radix > 5 ? 0x5 : -1); - case '6': return(radix > 6 ? 0x6 : -1); - case '7': return(radix > 7 ? 0x7 : -1); - case '8': return(radix > 8 ? 0x8 : -1); - case '9': return(radix > 9 ? 0x9 : -1); - case 'A': case 'a': return(radix > 10 ? 0xa : -1); - case 'B': case 'b': return(radix > 11 ? 0xb : -1); - case 'C': case 'c': return(radix > 12 ? 0xc : -1); - case 'D': case 'd': return(radix > 13 ? 0xd : -1); - case 'E': case 'e': return(radix > 14 ? 0xe : -1); - case 'F': case 'f': return(radix > 15 ? 0xf : -1); - } - /* - * invalid character - */ - return(-1); -} - -/* - * convert the key to a bit pattern - */ -cvtkey(obuf, ibuf) - char *obuf; /* bit pattern */ - char *ibuf; /* the key itself */ -{ - register int i, j; /* counter in a for loop */ - int nbuf[64]; /* used for hex/key translation */ - - /* - * just switch on the key base - */ - switch(keybase) { - case KEY_ASCII: /* ascii to integer */ - (void)strncpy(obuf, ibuf, 8); - return; - case KEY_DEFAULT: /* tell from context */ - /* - * leading '0x' or '0X' == hex key - */ - if (ibuf[0] == '0' && (ibuf[1] == 'x' || ibuf[1] == 'X')) { - ibuf = &ibuf[2]; - /* - * now translate it, bombing on any illegal hex digit - */ - for (i = 0; ibuf[i] && i < 16; i++) - if ((nbuf[i] = tobinhex(ibuf[i], 16)) == -1) - err(-1, "bad hex digit in key"); - while (i < 16) - nbuf[i++] = 0; - for (i = 0; i < 8; i++) - obuf[i] = - ((nbuf[2*i]&0xf)<<4) | (nbuf[2*i+1]&0xf); - /* preserve parity bits */ - pflag = 1; - return; - } - /* - * leading '0b' or '0B' == binary key - */ - if (ibuf[0] == '0' && (ibuf[1] == 'b' || ibuf[1] == 'B')) { - ibuf = &ibuf[2]; - /* - * now translate it, bombing on any illegal binary digit - */ - for (i = 0; ibuf[i] && i < 16; i++) - if ((nbuf[i] = tobinhex(ibuf[i], 2)) == -1) - err(-1, "bad binary digit in key"); - while (i < 64) - nbuf[i++] = 0; - for (i = 0; i < 8; i++) - for (j = 0; j < 8; j++) - obuf[i] = (obuf[i]<<1)|nbuf[8*i+j]; - /* preserve parity bits */ - pflag = 1; - return; - } - /* - * no special leader -- ASCII - */ - (void)strncpy(obuf, ibuf, 8); - } -} - -/* - * convert an ASCII string into a decimal number: - * 1. must be between 0 and 64 inclusive - * 2. must be a valid decimal number - * 3. must be a multiple of mult - */ -setbits(s, mult) - char *s; /* the ASCII string */ - int mult; /* what it must be a multiple of */ -{ - register char *p; /* pointer in a for loop */ - register int n = 0; /* the integer collected */ - - /* - * skip white space - */ - while (isspace(*s)) - s++; - /* - * get the integer - */ - for (p = s; *p; p++) { - if (isdigit(*p)) - n = n * 10 + *p - '0'; - else { - err(-1, "bad decimal digit in MAC length"); - } - } - /* - * be sure it's a multiple of mult - */ - return((n % mult != 0) ? -1 : n); -} - -/***************** - * DES FUNCTIONS * - *****************/ -/* - * This sets the DES key and (if you're using the deszip version) - * the direction of the transformation. This uses the Sun - * to map the 64-bit key onto the 56 bits that the key schedule - * generation routines use: the old way, which just uses the user- - * supplied 64 bits as is, and the new way, which resets the parity - * bit to be the same as the low-order bit in each character. The - * new way generates a greater variety of key schedules, since many - * systems set the parity (high) bit of each character to 0, and the - * DES ignores the low order bit of each character. - */ -makekey(buf) - Desbuf buf; /* key block */ -{ - register int i, j; /* counter in a for loop */ - register int par; /* parity counter */ - - /* - * if the parity is not preserved, flip it - */ - if (!pflag) { - for (i = 0; i < 8; i++) { - par = 0; - for (j = 1; j < 8; j++) - if ((bits[j]&UCHAR(buf, i)) != 0) - par++; - if ((par&01) == 01) - UCHAR(buf, i) = UCHAR(buf, i)&0177; - else - UCHAR(buf, i) = (UCHAR(buf, i)&0177)|0200; - } - } - - DES_KEY(UBUFFER(buf)); -} - -/* - * This encrypts using the Electronic Code Book mode of DES - */ -ecbenc() -{ - register int n; /* number of bytes actually read */ - register int bn; /* block number */ - Desbuf msgbuf; /* I/O buffer */ - - for (bn = 0; (n = READ(BUFFER(msgbuf), 8)) == 8; bn++) { - /* - * do the transformation - */ - DES_XFORM(UBUFFER(msgbuf)); - WRITE(BUFFER(msgbuf), 8); - } - /* - * at EOF or last block -- in either ase, the last byte contains - * the character representation of the number of bytes in it - */ - bn++; - MEMZERO(&CHAR(msgbuf, n), 8 - n); - CHAR(msgbuf, 7) = n; - DES_XFORM(UBUFFER(msgbuf)); - WRITE(BUFFER(msgbuf), 8); - -} - -/* - * This decrypts using the Electronic Code Book mode of DES - */ -ecbdec() -{ - register int n; /* number of bytes actually read */ - register int c; /* used to test for EOF */ - register int bn; /* block number */ - Desbuf msgbuf; /* I/O buffer */ - - for (bn = 1; (n = READ(BUFFER(msgbuf), 8)) == 8; bn++) { - /* - * do the transformation - */ - DES_XFORM(UBUFFER(msgbuf)); - /* - * if the last one, handle it specially - */ - if ((c = getchar()) == EOF) { - n = CHAR(msgbuf, 7); - if (n < 0 || n > 7) - err(bn, "decryption failed (block corrupted)"); - } - else - (void)ungetc(c, stdin); - WRITE(BUFFER(msgbuf), n); - } - if (n > 0) - err(bn, "decryption failed (incomplete block)"); -} - -/* - * This encrypts using the Cipher Block Chaining mode of DES - */ -cbcenc() -{ - register int n; /* number of bytes actually read */ - register int bn; /* block number */ - Desbuf msgbuf; /* I/O buffer */ - - /* - * do the transformation - */ - for (bn = 1; (n = READ(BUFFER(msgbuf), 8)) == 8; bn++) { - for (n = 0; n < 8; n++) - CHAR(msgbuf, n) ^= CHAR(ivec, n); - DES_XFORM(UBUFFER(msgbuf)); - MEMCPY(BUFFER(ivec), BUFFER(msgbuf), 8); - WRITE(BUFFER(msgbuf), 8); - } - /* - * at EOF or last block -- in either case, the last byte contains - * the character representation of the number of bytes in it - */ - bn++; - MEMZERO(&CHAR(msgbuf, n), 8 - n); - CHAR(msgbuf, 7) = n; - for (n = 0; n < 8; n++) - CHAR(msgbuf, n) ^= CHAR(ivec, n); - DES_XFORM(UBUFFER(msgbuf)); - WRITE(BUFFER(msgbuf), 8); - -} - -/* - * This decrypts using the Cipher Block Chaining mode of DES - */ -cbcdec() -{ - register int n; /* number of bytes actually read */ - Desbuf msgbuf; /* I/O buffer */ - Desbuf ibuf; /* temp buffer for initialization vector */ - register int c; /* used to test for EOF */ - register int bn; /* block number */ - - for (bn = 0; (n = READ(BUFFER(msgbuf), 8)) == 8; bn++) { - /* - * do the transformation - */ - MEMCPY(BUFFER(ibuf), BUFFER(msgbuf), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (c = 0; c < 8; c++) - UCHAR(msgbuf, c) ^= UCHAR(ivec, c); - MEMCPY(BUFFER(ivec), BUFFER(ibuf), 8); - /* - * if the last one, handle it specially - */ - if ((c = getchar()) == EOF) { - n = CHAR(msgbuf, 7); - if (n < 0 || n > 7) - err(bn, "decryption failed (block corrupted)"); - } - else - (void)ungetc(c, stdin); - WRITE(BUFFER(msgbuf), n); - } - if (n > 0) - err(bn, "decryption failed (incomplete block)"); -} - -/* - * This authenticates using the Cipher Block Chaining mode of DES - */ -cbcauth() -{ - register int n, j; /* number of bytes actually read */ - Desbuf msgbuf; /* I/O buffer */ - Desbuf encbuf; /* encryption buffer */ - - /* - * do the transformation - * note we DISCARD the encrypted block; - * we only care about the last one - */ - while ((n = READ(BUFFER(msgbuf), 8)) == 8) { - for (n = 0; n < 8; n++) - CHAR(encbuf, n) = CHAR(msgbuf, n) ^ CHAR(ivec, n); - DES_XFORM(UBUFFER(encbuf)); - MEMCPY(BUFFER(ivec), BUFFER(encbuf), 8); - } - /* - * now compute the last one, right padding with '\0' if need be - */ - if (n > 0) { - MEMZERO(&CHAR(msgbuf, n), 8 - n); - for (n = 0; n < 8; n++) - CHAR(encbuf, n) = CHAR(msgbuf, n) ^ CHAR(ivec, n); - DES_XFORM(UBUFFER(encbuf)); - } - /* - * drop the bits - * we write chars until fewer than 7 bits, - * and then pad the last one with 0 bits - */ - for (n = 0; macbits > 7; n++, macbits -= 8) - (void)putchar(CHAR(encbuf, n)); - if (macbits > 0) { - CHAR(msgbuf, 0) = 0x00; - for (j = 0; j < macbits; j++) - CHAR(msgbuf, 0) |= (CHAR(encbuf, n)&bits[j]); - (void)putchar(CHAR(msgbuf, 0)); - } -} - -/* - * This encrypts using the Cipher FeedBack mode of DES - */ -cfbenc() -{ - register int n; /* number of bytes actually read */ - register int nbytes; /* number of bytes to read */ - register int bn; /* block number */ - char ibuf[8]; /* input buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 8; - /* - * do the transformation - */ - for (bn = 1; (n = READ(ibuf, nbytes)) == nbytes; bn++) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < 8 - nbytes; n++) - UCHAR(ivec, n) = UCHAR(ivec, n+nbytes); - for (n = 0; n < nbytes; n++) - UCHAR(ivec, 8-nbytes+n) = ibuf[n] ^ UCHAR(msgbuf, n); - WRITE(&CHAR(ivec, 8-nbytes), nbytes); - } - /* - * at EOF or last block -- in either case, the last byte contains - * the character representation of the number of bytes in it - */ - bn++; - MEMZERO(&ibuf[n], nbytes - n); - ibuf[nbytes - 1] = n; - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < nbytes; n++) - ibuf[n] ^= UCHAR(msgbuf, n); - WRITE(ibuf, nbytes); -} - -/* - * This decrypts using the Cipher Block Chaining mode of DES - */ -cfbdec() -{ - register int n; /* number of bytes actually read */ - register int c; /* used to test for EOF */ - register int nbytes; /* number of bytes to read */ - register int bn; /* block number */ - char ibuf[8]; /* input buffer */ - char obuf[8]; /* output buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 8; - /* - * do the transformation - */ - for (bn = 1; (n = READ(ibuf, nbytes)) == nbytes; bn++) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (c = 0; c < 8 - nbytes; c++) - CHAR(ivec, c) = CHAR(ivec, c+nbytes); - for (c = 0; c < nbytes; c++) { - CHAR(ivec, 8-nbytes+c) = ibuf[c]; - obuf[c] = ibuf[c] ^ UCHAR(msgbuf, c); - } - /* - * if the last one, handle it specially - */ - if ((c = getchar()) == EOF) { - n = obuf[nbytes-1]; - if (n < 0 || n > nbytes-1) - err(bn, "decryption failed (block corrupted)"); - } - else - (void)ungetc(c, stdin); - WRITE(obuf, n); - } - if (n > 0) - err(bn, "decryption failed (incomplete block)"); -} - -/* - * This encrypts using the alternative Cipher FeedBack mode of DES - */ -cfbaenc() -{ - register int n; /* number of bytes actually read */ - register int nbytes; /* number of bytes to read */ - register int bn; /* block number */ - char ibuf[8]; /* input buffer */ - char obuf[8]; /* output buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 7; - /* - * do the transformation - */ - for (bn = 1; (n = READ(ibuf, nbytes)) == nbytes; bn++) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < 8 - nbytes; n++) - UCHAR(ivec, n) = UCHAR(ivec, n+nbytes); - for (n = 0; n < nbytes; n++) - UCHAR(ivec, 8-nbytes+n) = (ibuf[n] ^ UCHAR(msgbuf, n)) - |0200; - for (n = 0; n < nbytes; n++) - obuf[n] = CHAR(ivec, 8-nbytes+n)&0177; - WRITE(obuf, nbytes); - } - /* - * at EOF or last block -- in either case, the last byte contains - * the character representation of the number of bytes in it - */ - bn++; - MEMZERO(&ibuf[n], nbytes - n); - ibuf[nbytes - 1] = ('0' + n)|0200; - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < nbytes; n++) - ibuf[n] ^= UCHAR(msgbuf, n); - WRITE(ibuf, nbytes); -} - -/* - * This decrypts using the alternative Cipher Block Chaining mode of DES - */ -cfbadec() -{ - register int n; /* number of bytes actually read */ - register int c; /* used to test for EOF */ - register int nbytes; /* number of bytes to read */ - register int bn; /* block number */ - char ibuf[8]; /* input buffer */ - char obuf[8]; /* output buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 7; - /* - * do the transformation - */ - for (bn = 1; (n = READ(ibuf, nbytes)) == nbytes; bn++) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (c = 0; c < 8 - nbytes; c++) - CHAR(ivec, c) = CHAR(ivec, c+nbytes); - for (c = 0; c < nbytes; c++) { - CHAR(ivec, 8-nbytes+c) = ibuf[c]|0200; - obuf[c] = (ibuf[c] ^ UCHAR(msgbuf, c))&0177; - } - /* - * if the last one, handle it specially - */ - if ((c = getchar()) == EOF) { - if ((n = (obuf[nbytes-1] - '0')) < 0 - || n > nbytes-1) - err(bn, "decryption failed (block corrupted)"); - } - else - (void)ungetc(c, stdin); - WRITE(obuf, n); - } - if (n > 0) - err(bn, "decryption failed (incomplete block)"); -} - - -/* - * This encrypts using the Output FeedBack mode of DES - */ -ofbenc() -{ - register int n; /* number of bytes actually read */ - register int c; /* used to test for EOF */ - register int nbytes; /* number of bytes to read */ - register int bn; /* block number */ - char ibuf[8]; /* input buffer */ - char obuf[8]; /* output buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 8; - /* - * do the transformation - */ - for (bn = 1; (n = READ(ibuf, nbytes)) == nbytes; bn++) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < 8 - nbytes; n++) - UCHAR(ivec, n) = UCHAR(ivec, n+nbytes); - for (n = 0; n < nbytes; n++) { - UCHAR(ivec, 8-nbytes+n) = UCHAR(msgbuf, n); - obuf[n] = ibuf[n] ^ UCHAR(msgbuf, n); - } - WRITE(obuf, nbytes); - } - /* - * at EOF or last block -- in either case, the last byte contains - * the character representation of the number of bytes in it - */ - bn++; - MEMZERO(&ibuf[n], nbytes - n); - ibuf[nbytes - 1] = n; - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (c = 0; c < nbytes; c++) - ibuf[c] ^= UCHAR(msgbuf, c); - WRITE(ibuf, nbytes); -} - -/* - * This decrypts using the Output Block Chaining mode of DES - */ -ofbdec() -{ - register int n; /* number of bytes actually read */ - register int c; /* used to test for EOF */ - register int nbytes; /* number of bytes to read */ - register int bn; /* block number */ - char ibuf[8]; /* input buffer */ - char obuf[8]; /* output buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 8; - /* - * do the transformation - */ - for (bn = 1; (n = READ(ibuf, nbytes)) == nbytes; bn++) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (c = 0; c < 8 - nbytes; c++) - CHAR(ivec, c) = CHAR(ivec, c+nbytes); - for (c = 0; c < nbytes; c++) { - CHAR(ivec, 8-nbytes+c) = UCHAR(msgbuf, c); - obuf[c] = ibuf[c] ^ UCHAR(msgbuf, c); - } - /* - * if the last one, handle it specially - */ - if ((c = getchar()) == EOF) { - n = obuf[nbytes-1]; - if (n < 0 || n > nbytes-1) - err(bn, "decryption failed (block corrupted)"); - } - else - (void)ungetc(c, stdin); - /* - * dump it - */ - WRITE(obuf, n); - } - if (n > 0) - err(bn, "decryption failed (incomplete block)"); -} - -/* - * This authenticates using the Cipher FeedBack mode of DES - */ -cfbauth() -{ - register int n, j; /* number of bytes actually read */ - register int nbytes; /* number of bytes to read */ - char ibuf[8]; /* input buffer */ - Desbuf msgbuf; /* encryption buffer */ - - /* - * do things in bytes, not bits - */ - nbytes = fbbits / 8; - /* - * do the transformation - */ - while ((n = READ(ibuf, nbytes)) == nbytes) { - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < 8 - nbytes; n++) - UCHAR(ivec, n) = UCHAR(ivec, n+nbytes); - for (n = 0; n < nbytes; n++) - UCHAR(ivec, 8-nbytes+n) = ibuf[n] ^ UCHAR(msgbuf, n); - } - /* - * at EOF or last block -- in either case, the last byte contains - * the character representation of the number of bytes in it - */ - MEMZERO(&ibuf[n], nbytes - n); - ibuf[nbytes - 1] = '0' + n; - MEMCPY(BUFFER(msgbuf), BUFFER(ivec), 8); - DES_XFORM(UBUFFER(msgbuf)); - for (n = 0; n < nbytes; n++) - ibuf[n] ^= UCHAR(msgbuf, n); - /* - * drop the bits - * we write chars until fewer than 7 bits, - * and then pad the last one with 0 bits - */ - for (n = 0; macbits > 7; n++, macbits -= 8) - (void)putchar(CHAR(msgbuf, n)); - if (macbits > 0) { - CHAR(msgbuf, 0) = 0x00; - for (j = 0; j < macbits; j++) - CHAR(msgbuf, 0) |= (CHAR(msgbuf, n)&bits[j]); - (void)putchar(CHAR(msgbuf, 0)); - } -} - -#ifndef FASTWAY -/* - * change from 8 bits/Uchar to 1 bit/Uchar - */ -expand(from, to) - Desbuf from; /* 8bit/unsigned char string */ - char *to; /* 1bit/char string */ -{ - register int i, j; /* counters in for loop */ - - for (i = 0; i < 8; i++) - for (j = 0; j < 8; j++) - *to++ = (CHAR(from, i)>>(7-j))&01; -} - -/* - * change from 1 bit/char to 8 bits/Uchar - */ -compress(from, to) - char *from; /* 1bit/char string */ - Desbuf to; /* 8bit/unsigned char string */ -{ - register int i, j; /* counters in for loop */ - - for (i = 0; i < 8; i++) { - CHAR(to, i) = 0; - for (j = 0; j < 8; j++) - CHAR(to, i) = ((*from++)<<(7-j))|CHAR(to, i); - } -} -#endif - -/* - * message about usage - */ -usage() -{ - (void)fprintf(stderr, "%s\n", -"usage: bdes [-abdp] [-F bit] [-f bit] [-k key] [-m bit] [-o bit] [-v vector]"); - exit(1); -} diff --git a/usr.bin/bdes/bdes.ps b/usr.bin/bdes/bdes.ps deleted file mode 100644 index 471c267..0000000 --- a/usr.bin/bdes/bdes.ps +++ /dev/null @@ -1,2945 +0,0 @@ -%! -%%BoundingBox: (atend) -%%Pages: (atend) -%%DocumentFonts: (atend) -%%EndComments -% -% FrameMaker PostScript Prolog 2.0, for use with FrameMaker 2.0 -% Copyright (c) 1986,87,89 by Frame Technology, Inc. All rights reserved. -% -% Known Problems: -% Due to bugs in Transcript, the 'PS-Adobe-' is omitted from line 1 -/FMversion (2.0) def -% Set up Color vs. Black-and-White - /FMPrintInColor systemdict /colorimage known def -% Uncomment this line to force b&w on color printer -% /FMPrintInColor false def -/FrameDict 190 dict def -systemdict /errordict known not {/errordict 10 dict def - errordict /rangecheck {stop} put} if -% The readline in 23.0 doesn't recognize cr's as nl's on AppleTalk -FrameDict /tmprangecheck errordict /rangecheck get put -errordict /rangecheck {FrameDict /bug true put} put -FrameDict /bug false put -mark -% Some PS machines read past the CR, so keep the following 3 lines together! -currentfile 5 string readline -00 -0000000000 -cleartomark -errordict /rangecheck FrameDict /tmprangecheck get put -FrameDict /bug get { - /readline { - /gstring exch def - /gfile exch def - /gindex 0 def - { - gfile read pop - dup 10 eq {exit} if - dup 13 eq {exit} if - gstring exch gindex exch put - /gindex gindex 1 add def - } loop - pop - gstring 0 gindex getinterval true - } def - } if -/FMVERSION { - FMversion ne { - /Times-Roman findfont 18 scalefont setfont - 100 100 moveto - (FrameMaker version does not match postscript_prolog!) - dup = - show showpage - } if - } def -/FMLOCAL { - FrameDict begin - 0 def - end - } def - /gstring FMLOCAL - /gfile FMLOCAL - /gindex FMLOCAL - /orgxfer FMLOCAL - /orgproc FMLOCAL - /organgle FMLOCAL - /orgfreq FMLOCAL - /yscale FMLOCAL - /xscale FMLOCAL - /manualfeed FMLOCAL - /paperheight FMLOCAL - /paperwidth FMLOCAL -/FMDOCUMENT { - array /FMfonts exch def - /#copies exch def - FrameDict begin - 0 ne dup {setmanualfeed} if - /manualfeed exch def - /paperheight exch def - /paperwidth exch def - setpapername - manualfeed {true} {papersize} ifelse - {manualpapersize} {false} ifelse - {desperatepapersize} if - /yscale exch def - /xscale exch def - currenttransfer cvlit /orgxfer exch def - currentscreen cvlit /orgproc exch def - /organgle exch def /orgfreq exch def - end - } def - /pagesave FMLOCAL - /orgmatrix FMLOCAL - /landscape FMLOCAL -/FMBEGINPAGE { - FrameDict begin - /pagesave save def - 3.86 setmiterlimit - /landscape exch 0 ne def - landscape { - 90 rotate 0 exch neg translate pop - } - {pop pop} - ifelse - xscale yscale scale - /orgmatrix matrix def - gsave - } def -/FMENDPAGE { - grestore - pagesave restore - end - showpage - } def -/FMDEFINEFONT { - FrameDict begin - findfont - ReEncode - 2 index exch - definefont exch - scalefont - FMfonts 3 1 roll - put - end - } bind def -/FMNORMALIZEGRAPHICS { - newpath - 0.0 0.0 moveto - 1 setlinewidth - 0 setlinecap - 0 0 0 sethsbcolor - 0 setgray - } bind def - /fx FMLOCAL - /fy FMLOCAL - /fh FMLOCAL - /fw FMLOCAL - /llx FMLOCAL - /lly FMLOCAL - /urx FMLOCAL - /ury FMLOCAL -/FMBEGINEPSF { - end - /FMEPSF save def - /showpage {} def - FMNORMALIZEGRAPHICS - [/fy /fx /fh /fw /ury /urx /lly /llx] {exch def} forall - fx fy translate - rotate - fw urx llx sub div fh ury lly sub div scale - llx neg lly neg translate - } bind def -/FMENDEPSF { - FMEPSF restore - FrameDict begin - } bind def -FrameDict begin -/setmanualfeed { -%%BeginFeature *ManualFeed True - statusdict /manualfeed true put -%%EndFeature - } def -/max {2 copy lt {exch} if pop} bind def -/min {2 copy gt {exch} if pop} bind def -/inch {72 mul} def -/pagedimen { - paperheight sub abs 16 lt exch - paperwidth sub abs 16 lt and - {/papername exch def} {pop} ifelse - } def - /papersizedict FMLOCAL -/setpapername { - /papersizedict 14 dict def - papersizedict begin - /papername /unknown def - /Letter 8.5 inch 11.0 inch pagedimen - /LetterSmall 7.68 inch 10.16 inch pagedimen - /Tabloid 11.0 inch 17.0 inch pagedimen - /Ledger 17.0 inch 11.0 inch pagedimen - /Legal 8.5 inch 14.0 inch pagedimen - /Statement 5.5 inch 8.5 inch pagedimen - /Executive 7.5 inch 10.0 inch pagedimen - /A3 11.69 inch 16.5 inch pagedimen - /A4 8.26 inch 11.69 inch pagedimen - /A4Small 7.47 inch 10.85 inch pagedimen - /B4 10.125 inch 14.33 inch pagedimen - /B5 7.16 inch 10.125 inch pagedimen - end - } def -/papersize { - papersizedict begin - /Letter {lettertray} def - /LetterSmall {lettertray lettersmall} def - /Tabloid {11x17tray} def - /Ledger {ledgertray} def - /Legal {legaltray} def - /Statement {statementtray} def - /Executive {executivetray} def - /A3 {a3tray} def - /A4 {a4tray} def - /A4Small {a4tray a4small} def - /B4 {b4tray} def - /B5 {b5tray} def - /unknown {unknown} def - papersizedict dup papername known {papername} {/unknown} ifelse get - end - /FMdicttop countdictstack 1 add def - statusdict begin stopped end - countdictstack -1 FMdicttop {pop end} for - } def -/manualpapersize { - papersizedict begin - /Letter {letter} def - /LetterSmall {lettersmall} def - /Tabloid {11x17} def - /Ledger {ledger} def - /Legal {legal} def - /Statement {statement} def - /Executive {executive} def - /A3 {a3} def - /A4 {a4} def - /A4Small {a4small} def - /B4 {b4} def - /B5 {b5} def - /unknown {unknown} def - papersizedict dup papername known {papername} {/unknown} ifelse get - end - stopped - } def -/desperatepapersize { - statusdict /setpageparams known - { - paperwidth paperheight 0 1 - statusdict begin - {setpageparams} stopped pop - end - } if - } def -/savematrix { - orgmatrix currentmatrix pop - } bind def -/restorematrix { - orgmatrix setmatrix - } bind def -/dmatrix matrix def -/dpi 72 0 dmatrix defaultmatrix dtransform - dup mul exch dup mul add sqrt def -/freq dpi 18.75 div 8 div round dup 0 eq {pop 1} if 8 mul dpi exch div def -/sangle 1 0 dmatrix defaultmatrix dtransform exch atan def -/DiacriticEncoding [ -/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef -/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef -/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef -/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef -/.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl -/numbersign /dollar /percent /ampersand /quotesingle /parenleft -/parenright /asterisk /plus /comma /hyphen /period /slash /zero /one -/two /three /four /five /six /seven /eight /nine /colon /semicolon -/less /equal /greater /question /at /A /B /C /D /E /F /G /H /I /J /K -/L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash -/bracketright /asciicircum /underscore /grave /a /b /c /d /e /f /g /h -/i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar -/braceright /asciitilde /.notdef /Adieresis /Aring /Ccedilla /Eacute -/Ntilde /Odieresis /Udieresis /aacute /agrave /acircumflex /adieresis -/atilde /aring /ccedilla /eacute /egrave /ecircumflex /edieresis -/iacute /igrave /icircumflex /idieresis /ntilde /oacute /ograve -/ocircumflex /odieresis /otilde /uacute /ugrave /ucircumflex -/udieresis /dagger /.notdef /cent /sterling /section /bullet -/paragraph /germandbls /registered /copyright /trademark /acute -/dieresis /.notdef /AE /Oslash /.notdef /.notdef /.notdef /.notdef -/yen /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef -/ordfeminine /ordmasculine /.notdef /ae /oslash /questiondown -/exclamdown /logicalnot /.notdef /florin /.notdef /.notdef -/guillemotleft /guillemotright /ellipsis /.notdef /Agrave /Atilde -/Otilde /OE /oe /endash /emdash /quotedblleft /quotedblright -/quoteleft /quoteright /.notdef /.notdef /ydieresis /Ydieresis -/fraction /currency /guilsinglleft /guilsinglright /fi /fl /daggerdbl -/periodcentered /quotesinglbase /quotedblbase /perthousand -/Acircumflex /Ecircumflex /Aacute /Edieresis /Egrave /Iacute -/Icircumflex /Idieresis /Igrave /Oacute /Ocircumflex /.notdef /Ograve -/Uacute /Ucircumflex /Ugrave /dotlessi /circumflex /tilde /macron -/breve /dotaccent /ring /cedilla /hungarumlaut /ogonek /caron -] def -/ReEncode { - dup - length - dict begin - { - 1 index /FID ne - {def} - {pop pop} ifelse - } forall - Encoding StandardEncoding eq - { - /Encoding DiacriticEncoding def - }if - currentdict - end - } bind def -/graymode true def - /bwidth FMLOCAL - /bpside FMLOCAL - /bstring FMLOCAL - /onbits FMLOCAL - /offbits FMLOCAL - /xindex FMLOCAL - /yindex FMLOCAL - /x FMLOCAL - /y FMLOCAL -/setpattern { - /bwidth exch def - /bpside exch def - /bstring exch def - /onbits 0 def /offbits 0 def - freq sangle landscape {90 add} if - {/y exch def - /x exch def - /xindex x 1 add 2 div bpside mul cvi def - /yindex y 1 add 2 div bpside mul cvi def - bstring yindex bwidth mul xindex 8 idiv add get - 1 7 xindex 8 mod sub bitshift and 0 ne - {/onbits onbits 1 add def 1} - {/offbits offbits 1 add def 0} - ifelse - } - setscreen - {} settransfer - offbits offbits onbits add div FMsetgray - /graymode false def - } bind def -/grayness { - FMsetgray - graymode not { - /graymode true def - orgxfer cvx settransfer - orgfreq organgle orgproc cvx setscreen - } if - } bind def - /HUE FMLOCAL - /SAT FMLOCAL - /BRIGHT FMLOCAL - /Colors FMLOCAL -FMPrintInColor - - { - /HUE 0 def - /SAT 0 def - /BRIGHT 0 def - % array of arrays Hue and Sat values for the separations [HUE BRIGHT] - /Colors - [[0 0 ] % black - [0 0 ] % white - [0.00 1.0] % red - [0.37 1.0] % green - [0.60 1.0] % blue - [0.50 1.0] % cyan - [0.83 1.0] % magenta - [0.16 1.0] % comment / yellow - ] def - - /BEGINBITMAPCOLOR { - BITMAPCOLOR} def - /BEGINBITMAPCOLORc { - BITMAPCOLORc} def - /K { - Colors exch get dup - 0 get /HUE exch store - 1 get /BRIGHT exch store - HUE 0 eq BRIGHT 0 eq and - {1.0 SAT sub setgray} - {HUE SAT BRIGHT sethsbcolor} - ifelse - } def - /FMsetgray { - /SAT exch 1.0 exch sub store - HUE 0 eq BRIGHT 0 eq and - {1.0 SAT sub setgray} - {HUE SAT BRIGHT sethsbcolor} - ifelse - } bind def - } - - { - /BEGINBITMAPCOLOR { - BITMAPGRAY} def - /BEGINBITMAPCOLORc { - BITMAPGRAYc} def - /FMsetgray {setgray} bind def - /K { - pop - } def - } -ifelse -/normalize { - transform round exch round exch itransform - } bind def -/dnormalize { - dtransform round exch round exch idtransform - } bind def -/lnormalize { - 0 dtransform exch cvi 2 idiv 2 mul 1 add exch idtransform pop - } bind def -/H { - lnormalize setlinewidth - } bind def -/Z { - setlinecap - } bind def -/X { - fillprocs exch get exec - } bind def -/V { - gsave eofill grestore - } bind def -/N { - stroke - } bind def -/M {newpath moveto} bind def -/E {lineto} bind def -/D {curveto} bind def -/O {closepath} bind def - /n FMLOCAL -/L { - /n exch def - newpath - normalize - moveto - 2 1 n {pop normalize lineto} for - } bind def -/Y { - L - closepath - } bind def - /x1 FMLOCAL - /x2 FMLOCAL - /y1 FMLOCAL - /y2 FMLOCAL - /rad FMLOCAL -/R { - /y2 exch def - /x2 exch def - /y1 exch def - /x1 exch def - x1 y1 - x2 y1 - x2 y2 - x1 y2 - 4 Y - } bind def -/RR { - /rad exch def - normalize - /y2 exch def - /x2 exch def - normalize - /y1 exch def - /x1 exch def - newpath - x1 y1 rad add moveto - x1 y2 x2 y2 rad arcto - x2 y2 x2 y1 rad arcto - x2 y1 x1 y1 rad arcto - x1 y1 x1 y2 rad arcto - closepath - 16 {pop} repeat - } bind def -/C { - grestore - gsave - R - clip - } bind def -/U { - grestore - gsave - } bind def -/F { - FMfonts exch get - setfont - } bind def -/T { - moveto show - } bind def -/RF { - rotate - 0 ne {-1 1 scale} if - } bind def -/TF { - gsave - moveto - RF - show - grestore - } bind def -/P { - moveto - 0 32 3 2 roll widthshow - } bind def -/PF { - gsave - moveto - RF - 0 32 3 2 roll widthshow - grestore - } bind def -/S { - moveto - 0 exch ashow - } bind def -/SF { - gsave - moveto - RF - 0 exch ashow - grestore - } bind def -/B { - moveto - 0 32 4 2 roll 0 exch awidthshow - } bind def -/BF { - gsave - moveto - RF - 0 32 4 2 roll 0 exch awidthshow - grestore - } bind def - /x FMLOCAL - /y FMLOCAL - /dx FMLOCAL - /dy FMLOCAL - /dl FMLOCAL - /t FMLOCAL - /t2 FMLOCAL - /Cos FMLOCAL - /Sin FMLOCAL - /r FMLOCAL -/W { - dnormalize - /dy exch def - /dx exch def - normalize - /y exch def - /x exch def - /dl dx dx mul dy dy mul add sqrt def - dl 0.0 gt { - /t currentlinewidth def - savematrix - /Cos dx dl div def - /Sin dy dl div def - /r [Cos Sin Sin neg Cos 0.0 0.0] def - /t2 t 2.5 mul 3.5 max def - newpath - x y translate - r concat - 0.0 0.0 moveto - dl t 2.7 mul sub 0.0 rlineto - stroke - restorematrix - x dx add y dy add translate - r concat - t 0.67 mul setlinewidth - t 1.61 mul neg 0.0 translate - 0.0 0.0 moveto - t2 1.7 mul neg t2 2.0 div moveto - 0.0 0.0 lineto - t2 1.7 mul neg t2 2.0 div neg lineto - stroke - t setlinewidth - restorematrix - } if - } bind def -/G { - gsave - newpath - normalize translate 0.0 0.0 moveto - dnormalize scale - 0.0 0.0 1.0 5 3 roll arc - closepath fill - grestore - } bind def -/A { - gsave - savematrix - newpath - 2 index 2 div add exch 3 index 2 div sub exch - normalize 2 index 2 div sub exch 3 index 2 div add exch - translate - scale - 0.0 0.0 1.0 5 3 roll arc - restorematrix - stroke - grestore - } bind def - /x FMLOCAL - /y FMLOCAL - /w FMLOCAL - /h FMLOCAL - /xx FMLOCAL - /yy FMLOCAL - /ww FMLOCAL - /hh FMLOCAL - /FMsaveobject FMLOCAL - /FMoptop FMLOCAL - /FMdicttop FMLOCAL -/BEGINPRINTCODE { - /FMdicttop countdictstack 1 add def - /FMoptop count 4 sub def - /FMsaveobject save def - userdict begin - /showpage {} def - FMNORMALIZEGRAPHICS - 3 index neg 3 index neg translate - } bind def -/ENDPRINTCODE { - count -1 FMoptop {pop pop} for - countdictstack -1 FMdicttop {pop end} for - FMsaveobject restore - } bind def -/gn { - 0 - { 46 mul - cf read pop - 32 sub - dup 46 lt {exit} if - 46 sub add - } loop - add - } bind def - /str FMLOCAL -/cfs { - /str sl string def - 0 1 sl 1 sub {str exch val put} for - str def - } bind def -/ic [ - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0223 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0223 - 0 - {0 hx} {1 hx} {2 hx} {3 hx} {4 hx} {5 hx} {6 hx} {7 hx} {8 hx} {9 hx} - {10 hx} {11 hx} {12 hx} {13 hx} {14 hx} {15 hx} {16 hx} {17 hx} {18 hx} - {19 hx} {gn hx} {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12} - {13} {14} {15} {16} {17} {18} {19} {gn} {0 wh} {1 wh} {2 wh} {3 wh} - {4 wh} {5 wh} {6 wh} {7 wh} {8 wh} {9 wh} {10 wh} {11 wh} {12 wh} - {13 wh} {14 wh} {gn wh} {0 bl} {1 bl} {2 bl} {3 bl} {4 bl} {5 bl} {6 bl} - {7 bl} {8 bl} {9 bl} {10 bl} {11 bl} {12 bl} {13 bl} {14 bl} {gn bl} - {0 fl} {1 fl} {2 fl} {3 fl} {4 fl} {5 fl} {6 fl} {7 fl} {8 fl} {9 fl} - {10 fl} {11 fl} {12 fl} {13 fl} {14 fl} {gn fl} - ] def - /sl FMLOCAL - /val FMLOCAL - /ws FMLOCAL - /im FMLOCAL - /bs FMLOCAL - /cs FMLOCAL - /len FMLOCAL - /pos FMLOCAL -/ms { - /sl exch def - /val 255 def - /ws cfs - /im cfs - /val 0 def - /bs cfs - /cs cfs - } bind def -400 ms -/ip { - is - 0 - cf cs readline pop - { ic exch get exec - add - } forall - pop - - } bind def -/wh { - /len exch def - /pos exch def - ws 0 len getinterval im pos len getinterval copy pop - pos len - } bind def -/bl { - /len exch def - /pos exch def - bs 0 len getinterval im pos len getinterval copy pop - pos len - } bind def -/s1 1 string def -/fl { - /len exch def - /pos exch def - /val cf s1 readhexstring pop 0 get def - pos 1 pos len add 1 sub {im exch val put} for - pos len - } bind def -/hx { - 3 copy getinterval - cf exch readhexstring pop pop - } bind def - /h FMLOCAL - /w FMLOCAL - /d FMLOCAL - /lb FMLOCAL - /bitmapsave FMLOCAL - /is FMLOCAL - /cf FMLOCAL -/wbytes { - dup - 8 eq {pop} {1 eq {7 add 8 idiv} {3 add 4 idiv} ifelse} ifelse - } bind def -/BEGINBITMAPBWc { - 1 {} COMMONBITMAPc - } bind def -/BEGINBITMAPGRAYc { - 8 {} COMMONBITMAPc - } bind def -/BEGINBITMAP2BITc { - 2 {} COMMONBITMAPc - } bind def -/COMMONBITMAPc { - /r exch def - /d exch def - gsave - translate rotate scale /h exch def /w exch def - /lb w d wbytes def - sl lb lt {lb ms} if - /bitmapsave save def - r - /is im 0 lb getinterval def - ws 0 lb getinterval is copy pop - /cf currentfile def - w h d [w 0 0 h neg 0 h] - {ip} image - bitmapsave restore - grestore - } bind def -/BEGINBITMAPBW { - 1 {} COMMONBITMAP - } bind def -/BEGINBITMAPGRAY { - 8 {} COMMONBITMAP - } bind def -/BEGINBITMAP2BIT { - 2 {} COMMONBITMAP - } bind def -/COMMONBITMAP { - /r exch def - /d exch def - gsave - translate rotate scale /h exch def /w exch def - /bitmapsave save def - r - /is w d wbytes string def - /cf currentfile def - w h d [w 0 0 h neg 0 h] - {cf is readhexstring pop} image - bitmapsave restore - grestore - } bind def - /proc1 FMLOCAL - /proc2 FMLOCAL - /newproc FMLOCAL -/Fmcc { - /proc2 exch cvlit def - /proc1 exch cvlit def - /newproc proc1 length proc2 length add array def - newproc 0 proc1 putinterval - newproc proc1 length proc2 putinterval - newproc cvx -} bind def -/ngrayt 256 array def -/nredt 256 array def -/nbluet 256 array def -/ngreent 256 array def - /gryt FMLOCAL - /blut FMLOCAL - /grnt FMLOCAL - /redt FMLOCAL - /indx FMLOCAL - /cynu FMLOCAL - /magu FMLOCAL - /yelu FMLOCAL - /k FMLOCAL - /u FMLOCAL -/colorsetup { - currentcolortransfer - /gryt exch def - /blut exch def - /grnt exch def - /redt exch def - 0 1 255 { - /indx exch def - /cynu 1 red indx get 255 div sub def - /magu 1 green indx get 255 div sub def - /yelu 1 blue indx get 255 div sub def - /k cynu magu min yelu min def - /u k currentundercolorremoval exec def - nredt indx 1 0 cynu u sub max sub redt exec put - ngreent indx 1 0 magu u sub max sub grnt exec put - nbluet indx 1 0 yelu u sub max sub blut exec put - ngrayt indx 1 k currentblackgeneration exec sub gryt exec put - } for - {255 mul cvi nredt exch get} - {255 mul cvi ngreent exch get} - {255 mul cvi nbluet exch get} - {255 mul cvi ngrayt exch get} - setcolortransfer - {pop 0} setundercolorremoval - {} setblackgeneration - } bind def - /tran FMLOCAL -/fakecolorsetup { - /tran 256 string def - 0 1 255 {/indx exch def - tran indx - red indx get 77 mul - green indx get 151 mul - blue indx get 28 mul - add add 256 idiv put} for - currenttransfer - {255 mul cvi tran exch get 255.0 div} - exch Fmcc settransfer -} bind def -/BITMAPCOLOR { - /d 8 def - gsave - translate rotate scale /h exch def /w exch def - /bitmapsave save def - colorsetup - /is w d wbytes string def - /cf currentfile def - w h d [w 0 0 h neg 0 h] - {cf is readhexstring pop} {is} {is} true 3 colorimage - bitmapsave restore - grestore - } bind def -/BITMAPCOLORc { - /d 8 def - gsave - translate rotate scale /h exch def /w exch def - /lb w d wbytes def - sl lb lt {lb ms} if - /bitmapsave save def - colorsetup - /is im 0 lb getinterval def - ws 0 lb getinterval is copy pop - /cf currentfile def - w h d [w 0 0 h neg 0 h] - {ip} {is} {is} true 3 colorimage - bitmapsave restore - grestore - } bind def -/BITMAPGRAY { - 8 {fakecolorsetup} COMMONBITMAP - } bind def -/BITMAPGRAYc { - 8 {fakecolorsetup} COMMONBITMAPc - } bind def -/ENDBITMAP { - } bind def -end -%%EndProlog -%%BeginSetup -(2.0) FMVERSION -1 1 612 792 0 1 16 FMDOCUMENT -/fillprocs 32 array def -fillprocs 0 { 0.000000 grayness } put -fillprocs 1 { 0.100000 grayness } put -fillprocs 2 { 0.300000 grayness } put -fillprocs 3 { 0.500000 grayness } put -fillprocs 4 { 0.700000 grayness } put -fillprocs 5 { 0.900000 grayness } put -fillprocs 6 { 0.970000 grayness } put -fillprocs 7 { 1.000000 grayness } put -fillprocs 8 {<0f87c3e1f0783c1e> 8 1 setpattern } put -fillprocs 9 {<0f1e3c78f0e1c387> 8 1 setpattern } put -fillprocs 10 { 8 1 setpattern } put -fillprocs 11 { 8 1 setpattern } put -fillprocs 12 {<8142241818244281> 8 1 setpattern } put -fillprocs 13 {<8040201008040201> 8 1 setpattern } put -fillprocs 14 {<03060c183060c081> 8 1 setpattern } put -fillprocs 15 {} put -fillprocs 16 { 1.000000 grayness } put -fillprocs 17 { 0.900000 grayness } put -fillprocs 18 { 0.700000 grayness } put -fillprocs 19 { 0.500000 grayness } put -fillprocs 20 { 0.300000 grayness } put -fillprocs 21 { 0.100000 grayness } put -fillprocs 22 { 0.030000 grayness } put -fillprocs 23 { 0.000000 grayness } put -fillprocs 24 { 8 1 setpattern } put -fillprocs 25 { 8 1 setpattern } put -fillprocs 26 {<3333333333333333> 8 1 setpattern } put -fillprocs 27 {<0000ffff0000ffff> 8 1 setpattern } put -fillprocs 28 {<7ebddbe7e7dbbd7e> 8 1 setpattern } put -fillprocs 29 {<7fbfdfeff7fbfdfe> 8 1 setpattern } put -fillprocs 30 { 8 1 setpattern } put -fillprocs 31 {} put -%%EndSetup -0 12 /Helvetica-Bold FMDEFINEFONT -1 12 /Helvetica-BoldOblique FMDEFINEFONT -%%Page: "-1" 1 -%%BeginPaperSize: Letter -%%EndPaperSize -612 792 0 FMBEGINPAGE -144 144 468 396 R -7 X -0 K -V -0 F -0 X -1.2 (IMPLEMENT) 178.34 388 S -1.2 (A) 258.88 388 S -1.2 (TION NOTES ON ) 267.85 388 S -1 F -1.2 (bdes) 382.61 388 S -0 F -1.2 (\0501\051) 415.4 388 S -1.2 (Matt Bishop) 265.09 338 S -1.2 (T) 197.74 288 S -1.2 (echnical Report PCS-TR91-158) 205.38 288 S -FMENDPAGE -%%EndPage: "-1" 2 -%%Page: "0" 2 -612 792 0 FMBEGINPAGE -72 72 540 720 R -7 X -0 K -V -FMENDPAGE -%%EndPage: "0" 3 -0 12 /Times-Roman FMDEFINEFONT -1 18 /Times-Bold FMDEFINEFONT -2 18 /Times-BoldItalic FMDEFINEFONT -3 12 /Times-Italic FMDEFINEFONT -4 12 /Times-Bold FMDEFINEFONT -5 10 /Times-Roman FMDEFINEFONT -6 12 /Courier FMDEFINEFONT -7 12 /Courier-Oblique FMDEFINEFONT -8 12 /ZapfDingbats FMDEFINEFONT -9 12 /Symbol FMDEFINEFONT -10 12 /Courier-Bold FMDEFINEFONT -%%Page: "1" 3 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 1 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -1 F -0 X -(Implementation Notes on ) 179.84 708 T -2 F -(bdes) 378.21 708 T -1 F -(\0501\051) 411.19 708 T -0 F -( ) 432.17 708 T -3 F -(Matt Bishop) 276.51 676 T -0 F -(Department of Mathematics and Computer Science) 182.92 656 T -(Dartmouth College) 259.86 642 T -(Hanover) 257.45 628 T -(, NH 03755) 298.26 628 T -3 F -(ABSTRACT) 277.68 602 T -0 F -0.27 (This note describes the implementation of ) 108 582 P -3 F -0.27 (bdes) 314.13 582 P -0 F -0.27 (, the \336le encryption program being) 336.12 582 P -0.36 (distributed in the 4.4 release of the Berkeley Software Distribution. It implements) 108 568 P -(all modes of the Data Encryption Standard program.) 108 554 T -4 F -(1. Intr) 72 528 T -(oduction) 104.43 528 T -0 F --0.09 (The Data Encryption Standard is a standard endorsed by the federal government. It is con-) 108 504 P --0.56 (siderably stronger than the algorithm used by the ) 72 484 P -5 F --0.47 (UNIX) 305.36 484 P -0 F --0.56 (\252 ) 330.34 484 P -3 F --0.56 (crypt) 344.53 484 P -0 F --0.56 (\0501\051 program, and therefore is a more) 369.18 484 P -0.11 (suitable candidate for protecting information, especially information contained in ) 72 464 P -5 F -0.09 (ASCII) 466.05 464 P -0 F -0.11 ( \336les. The) 492.14 464 P --0.65 (program ) 72 444 P -3 F --0.65 (bdes) 114.99 444 P -0 F --0.65 (\0501\051 implements the DES and all of its modes, including the two authentication modes.) 136.97 444 P --0.59 (Because others may wish to write software compatible with this program, this note presents) 108 420 P --0.04 (the layout of the encrypted \336les produced by ) 72 400 P -3 F --0.04 (bdes) 288.86 400 P -0 F --0.04 ( as well as internal details relevant to the imple-) 310.85 400 P --0.15 (mentation. Whereever possible and appropriate, the description of the ) 72 380 P -3 F --0.15 (des) 408.04 380 P -0 F --0.15 (\0501\051 program given in [4]) 424.03 380 P --0.2 (has been followed; thus, ) 72 360 P -3 F --0.2 (bdes) 190.77 360 P -0 F --0.2 ( is completely compatible with that program. However) 212.75 360 P --0.2 (, ) 473.33 360 P -3 F --0.2 (bdes) 479.12 360 P -0 F --0.2 ( also of-) 501.11 360 P -(fers several extensions to ) 72 340 T -3 F -(des) 195.9 340 T -0 F -( that are not compatible, and these will be explicitly pointed out.) 211.89 340 T --0.14 (In this note, strings typed as shown will be in ) 108 316 P -6 F --0.34 (Courier Roman font) 326.78 316 P -0 F --0.14 (, and strings to be) 455.62 316 P --0.42 (chosen by the user will be in ) 72 296 P -7 F --1 (Courier Oblique font) 209.32 296 P -0 F --0.42 (. The space character \050) 351.24 296 P -5 F --0.35 (ASCII) 457.79 296 P -0 F --0.42 ( <) 483.88 296 P -5 F --0.35 (SP) 493.23 296 P -0 F --0.42 (>, octal) 504.34 296 P --0.43 (40, decimal 32, hex 20\051 will be represented as \322) 72 276 P -8 F --0.47 (z) 296.98 276 P -0 F --0.43 (\323 and the newline character \050) 301.96 276 P -5 F --0.35 (ASCII) 438.03 276 P -0 F --0.43 ( <) 464.13 276 P -5 F --0.35 (NL) 473.46 276 P -0 F --0.43 (>, octal 12,) 486.79 276 P --0.05 (decimal 10, hex a\051 as \322) 72 256 P -9 F --0.05 (\277) 181.65 256 P -0 F --0.05 (\323. Because it is often more convenient to represent arbitrary characters as) 189.54 256 P -1.13 (a sequence of hexadecimal digits, that representation will often be used; these digits will be in) 72 236 P -10 F -(Courier Bold font) 72 216 T -0 F -( with spaces often inserted for readability) 194.33 216 T -(.) 392.07 216 T -4 F -(2. Overview and Use) 72 184 T -3 F --0.39 (Bdes) 108 160 P -0 F --0.39 ( implements the Data Encryption Standard algorithm in software, and enables the user) 131.32 160 P --0.61 (to encrypt data using any of the four modes of operation of the DES \050Electronic Code Book, Cipher) 72 140 P -72 72 540 720 C -72 72 540 117 C -72 72 549 108 R -7 X -0 K -V -5 F -0 X -(This work is based on work funded by grant NAG2-680 from the National -Aeronautics and Space Administration to ) 72 101.33 T -(Dartmouth College.) 72 89.33 T -(UNIX is a Registered T) 72 77.33 T -(rademark of A) 166.58 77.33 T -(T&T Bell Laboratories.) 223.75 77.33 T -72 72 540 720 C -0 0 612 792 C -72 126 225 126 2 L -7 X -0 K -V -0.5 H -2 Z -0 X -N -FMENDPAGE -%%EndPage: "1" 4 -%%Page: "2" 4 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 2 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -0 X -0.31 (Block Chaining, ) 72 712 P -3 F -0.31 (k) 154.25 712 P -0 F -0.31 (-bit Cipher Feed Back, and ) 159.58 712 P -3 F -0.31 (k) 293.71 712 P -0 F -0.31 (-bit Output Feed Back\051 as well as the Alternate ) 299.04 712 P -3 F -0.31 (k) 530.68 712 P -0 F -0.31 (-) 536.01 712 P --0.04 (bit Cipher Feed Back mode. Further) 72 692 P --0.04 (, ) 244.52 692 P -3 F --0.04 (bdes) 250.48 692 P -0 F --0.04 ( supports message authentication code generation based) 272.46 692 P -(on both the Cipher Block Chaining mode and the ) 72 672 T -3 F -(k) 310.86 672 T -0 F -(-bit Cipher Feed Back mode.) 316.19 672 T -0.07 (By default, ) 108 648 P -3 F -0.07 (bdes) 164.43 648 P -0 F -0.07 ( encrypts an input \336le using Cipher Block Chaining mode, and is invoked) 186.41 648 P --0.4 (as a \336lter) 72 628 P --0.4 (. The key may be speci\336ed either on the command line or may be typed to the prompt. So,) 114.51 628 P -(if the input \336le ) 72 608 T -7 F -(inputf) 145.96 608 T -(ile) 189.14 608 T -0 F -( contains the message) 210.73 608 T -6 F -(a) 253.9 584 T -8 F -(z) 261.1 584 T -6 F -(test) 266.07 584 T -8 F -(z) 294.86 584 T -6 F -(message) 299.83 584 T -9 F -(\277) 350.21 584 T -0 F -(then the following command encrypts it using the key ) 72 560 T -6 F -(abcdefgh) 333.5 560 T -0 F -(:) 391.07 560 T -6 F -(bdes -k abcdefgh < ) 158.48 536 T -7 F -(inputf) 295.21 536 T -(ile) 338.38 536 T -6 F -( > ) 359.97 536 T -7 F -(outputf) 381.56 536 T -(ile) 431.93 536 T -0 F -(The option ) 72 512 T -4 F -(-k) 127.3 512 T -0 F -( indicates the next ar) 137.96 512 T -(gument is the key) 237.01 512 T -(. Now ) 321.17 512 T -7 F -(outputf) 353.48 512 T -(ile) 403.86 512 T -0 F -( contains) 425.45 512 T -10 F -(16 0e eb af 68 a0 d0 19 f1 a2 9b 31 0d 8a 01 c3) 136.89 488 T -0 F -0.06 (Other modes are speci\336ed using command-line options, as is control of the way the key is) 108 464 P -(interpreted. The next sections contain several examples, and the Appendix has the manual page.) 72 444 T -4 F -(3. Keys and Parity) 72 412 T -0 F -0.58 (The key consists of 64 bits, and may be presented in any of hex, binary) 108 388 P -0.58 (, or as a string of) 456.48 388 P -5 F -0.12 (ASCII) 72 368 P -0 F -0.14 ( characters. If the key is given in hex or binary) 98.1 368 P -0.14 (, it is used as is with no changes. However) 322.21 368 P -0.14 (, if) 526.53 368 P --0.27 (the key is given in ) 72 348 P -5 F --0.23 (ASCII) 161.59 348 P -0 F --0.27 (, a delicate problem arises: by convention, the parity bit is usually set to 0.) 187.69 348 P --0.47 (This high-order bit is generally ignored by applications; but the DES -does not do so. Instead, it dis-) 72 328 P --0.14 (cards the low-order bit, ef) 72 308 P --0.14 (fectively reducing the size of the space of possible keys from 2) 195.44 308 P -5 F --0.12 (56) 495.97 312.8 P -0 F --0.14 ( to 2) 505.97 308 P -5 F --0.12 (48) 527.01 312.8 P -0 F --0.14 (.) 537 308 P --0.46 ( T) 108 284 P --0.46 (o preserve the size of the key space, the value of the parity bit must be related to the value) 117.03 284 P --0.09 (in the low-order bit, so the program sets the high-order bit to make each character in the key be of) 72 264 P --0.7 (odd parity) 72 244 P --0.7 (. \050Note that the initial value of the parity bit is ) 119.49 244 P -3 F --0.7 (not) 334.99 244 P -0 F --0.7 ( used in this computation.\051 For example,) 350.31 244 P -(if the key is ) 72 224 T -6 F -(abcdefgh) 131.29 224 T -0 F -(, the actual key bits used are determined as follows:) 188.86 224 T -5 F -(ASCII) 99 200 T -0 F -( key) 125.1 200 T -6 F -(a) 243 200 T -(b) 279 200 T -(c) 315 200 T -(d) 351 200 T -(e) 387 200 T -(f) 423 200 T -(g) 459 200 T -(h) 495 200 T -5 F -(ASCII) 99 180 T -0 F -( key bits \050hex\051) 125.1 180 T -10 F -(61) 243 180 T -(62) 279 180 T -(63) 315 180 T -(64) 351 180 T -(65) 387 180 T -(66) 423 180 T -(67) 459 180 T -(68) 495 180 T -0 F -(parity) 99 160 T -(odd) 243 160 T -(odd) 279 160 T -(even) 315 160 T -(odd) 351 160 T -(even) 387 160 T -(even) 423 160 T -(odd) 459 160 T -(odd) 495 160 T -(key bits used \050hex\051) 99 140 T -10 F -(61) 243 140 T -(62) 279 140 T -(e3) 315 140 T -(64) 351 140 T -(e5) 387 140 T -(e6) 423 140 T -(67) 459 140 T -(68) 495 140 T -0 F -0.18 (This convention \050as opposed to requiring even parity) 108 120 P -0.18 (, or simply copying the low-order bit) 362 120 P --0.41 (to the high-order bit\051 was chosen to provide compatibility with the encryption program ) 72 100 P -3 F --0.41 (des) 486.77 100 P -0 F --0.41 ( distrib-) 502.76 100 P --0.52 (uted by Sun Microsystems, Inc. [4]. Whether the key is entered on the command line or on the key-) 72 80 P -FMENDPAGE -%%EndPage: "2" 5 -%%Page: "3" 5 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 3 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -0 X -1.89 (board, by default it is processed into the same key schedule generated by Sun\325) 72 712 P -1.89 (s ) 471.02 712 P -3 F -1.89 (des) 480.58 712 P -0 F -1.89 (, so \336les) 496.56 712 P -(encrypted on a Sun can be decrypted using ) 72 692 T -3 F -(bdes) 280.51 692 T -0 F -( \050and vice versa\051.) 302.49 692 T --0.3 (If the user does not wish to use the Sun convention, the option \320) 108 668 P -4 F --0.3 (p) 411.9 668 P -0 F --0.3 ( will disable the parity bit) 418.57 668 P --0.62 (changing; with it, the parity bit is that of the character typed. This -is useful when the key is a known) 72 648 P -5 F -(ASCII) 72 628 T -0 F -( string and the \336le was encrypted on a system which does not alter parity bits.) 98.1 628 T --0.24 (A key may be represented as a bit vector) 108 604 P --0.24 (, rather than an ) 300.74 604 P -5 F --0.2 (ASCII) 374.7 604 P -0 F --0.24 ( string, in one of two ways. It) 400.8 604 P -0.19 (may be represented as a string of up to 16 hexadecimal digits; if fewer than 16 are given, the key) 72 584 P -0.16 (is right \336lled with 0 bits. Or) 72 564 P -0.16 (, it may be represented as a string of up to 64 binary digits, and again) 206.11 564 P -0.15 (if fewer than 64 are given, the key is right-\336lled with 0 bits. Bit -vector keys must be given on the) 72 544 P -0.51 (command line, and must begin with the characters ) 72 524 P -6 F -1.24 (0x) 320.28 524 P -0 F -0.51 ( or ) 334.67 524 P -6 F -1.24 (0X) 351.69 524 P -0 F -0.51 ( \050for hexadecimal\051 or ) 366.08 524 P -6 F -1.24 (0b) 472.71 524 P -0 F -0.51 ( or ) 487.1 524 P -6 F -1.24 (0B) 504.12 524 P -0 F -0.51 ( \050for) 518.51 524 P -(binary\051. For example, all of the following strings generate the same key schedule:) 72 504 T -5 F -(ASCII) 72 480 T -0 F -( key) 98.1 480 T -6 F -(abcdefgh) 180 480 T -0 F -(hexadecimal key) 72 460 T -6 F -(0x6162e364e5e66768) 180 460 T -0 F -(binary key) 72 440 T -6 F -(0b0110000101100010111000110110100011100101111000-) 180 440 T -(1100110011101101000) 180 420 T -0 F --0.14 ( Note that giving the key on the command line as ) 108 396 P -6 F --0.34 (0x6162636465666768) 345.27 396 P -0 F --0.14 ( will ) 474.8 396 P -3 F --0.14 (not) 499.17 396 P -0 F --0.14 ( reset) 514.5 396 P -0.25 (the parity bits, because it is interpreted as a sequence of hex digits, not ) 72 376 P -5 F -0.21 (ASCII) 416.58 376 P -0 F -0.25 ( characters. The dif-) 442.68 376 P -0.69 (ference in interpretation is that here the user can specify all bits of the key exactly) 72 356 P -0.69 (, whereas \050on) 474.34 356 P -0.25 (most terminals\051 it is not possible to control how the parity bit of ) 72 336 P -5 F -0.21 (ASCII) 384.76 336 P -0 F -0.25 ( characters is set. On some) 410.85 336 P -0.36 (systems, it is possible to use a \322Meta\323 key to set the parity bit for an ) 72 316 P -5 F -0.3 (ASCII) 407.23 316 P -0 F -0.36 ( character; should this) 433.33 316 P --0.3 (be the case and the user desire ) 72 296 P -3 F --0.3 (bdes) 218.09 296 P -0 F --0.3 ( not to reset the parity bit, the option ) 240.07 296 P -4 F --0.3 (\320p) 415.25 296 P -0 F --0.3 ( will force the parity bit) 427.92 296 P -(to be used as typed.) 72 276 T -4 F -(4. Encryption Output Repr) 72 244 T -(esentation) 211.05 244 T -0 F -0.01 (All modes of the DES output ciphertext in blocks; the size of the block is 64 bits \0508 bytes\051) 108 220 P --0.25 (for ECB and CBC modes, and ) 72 200 P -3 F --0.25 (k) 218.74 200 P -0 F --0.25 ( bits for the ) 224.07 200 P -3 F --0.25 (k) 281.02 200 P -0 F --0.25 (-bit CFB and OFB modes, and there are as many out-) 286.35 200 P --0.5 (put blocks as input blocks. However) 72 180 P --0.5 (, as the length of the input is usually not a multiple of the block) 243.55 180 P --0.35 (size, some padding is necessary; but as padding must be done by appending characters, these char-) 72 160 P -0.29 (acters must be distinguished from the input characters somehow) 72 140 P -0.29 (. The mechanism used is that the) 381.35 140 P -0.31 (last character of the \050decrypted\051 last block is the -\050integer\051 number of characters from the input in) 72 120 P -(the last block.) 72 100 T -FMENDPAGE -%%EndPage: "3" 6 -%%Page: "4" 6 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 4 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -0 X --0.59 (For example, suppose ) 108 712 P -7 F --1.41 (inputf) 214.16 712 P --1.41 (ile) 257.34 712 P -0 F --0.59 ( contains \322) 278.93 712 P -6 F --1.41 (This) 329.04 712 P -8 F --0.65 (z) 357.83 712 P -6 F --1.41 (is) 362.8 712 P -8 F --0.65 (z) 377.2 712 P -6 F --1.41 (a) 382.17 712 P -8 F --0.65 (z) 389.37 712 P -6 F --1.41 (test) 394.35 712 P -9 F --0.59 (\277) 423.13 712 P -0 F --0.59 (\323, and it is encrypted in) 431.02 712 P -(CBC mode using the key \322) 72 692 T -6 F -(abcdef#@) 200.93 692 T -0 F -(\323 and the initialization vector ) 258.5 692 T -6 F -(0x0) 401.4 692 T -0 F -(; the command is) 422.99 692 T -6 F -(bdes -k abcdef#@ < ) 158.48 668 T -7 F -(inputf) 295.21 668 T -(ile) 338.38 668 T -6 F -( > ) 359.97 668 T -7 F -(outputf) 381.56 668 T -(ile) 431.93 668 T -0 F -(as CBC is the default encryption mode and ) 72 644 T -6 F -(0x0) 281.2 644 T -0 F -( the default initialization vector:) 302.79 644 T -(text) 72 620 T -6 F -(T) 117 620 T -(h) 144 620 T -(i) 171 620 T -(s) 198 620 T -8 F -(z) 225 620 T -6 F -(i) 252 620 T -(s) 279 620 T -8 F -(z) 306 620 T -6 F -(a) 333 620 T -8 F -(z) 360 620 T -6 F -(t) 387 620 T -(e) 414 620 T -(s) 441 620 T -(t) 468 620 T -9 F -(\277) 495 620 T -0 F -(hex) 72 600 T -10 F -(54) 117 600 T -(68) 144 600 T -(69) 171 600 T -(73) 198 600 T -(20) 225 600 T -(69) 252 600 T -(73) 279 600 T -(20) 306 600 T -(61) 333 600 T -(20) 360 600 T -(74) 387 600 T -(65) 414 600 T -(73) 441 600 T -(74) 468 600 T -(0a) 495 600 T -0 F -(input) 72 580 T -10 F -(54) 117 580 T -(68) 144 580 T -(69) 171 580 T -(73) 198 580 T -(20) 225 580 T -(69) 252 580 T -(73) 279 580 T -(20) 306 580 T -(61) 333 580 T -(20) 360 580 T -(74) 387 580 T -(65) 414 580 T -(73) 441 580 T -(74) 468 580 T -(0a) 495 580 T -(07) 522 580 T -0 F -(output) 72 560 T -10 F -(a5) 117 560 T -(5f) 144 560 T -(81) 171 560 T -(53) 198 560 T -(51) 225 560 T -(98) 252 560 T -(47) 279 560 T -(02) 306 560 T -(db) 333 560 T -(5a) 360 560 T -(c5) 387 560 T -(fe) 414 560 T -(50) 441 560 T -(3d) 468 560 T -(40) 495 560 T -(ce) 522 560 T -0 F -0.04 (Notice that the text is 15 characters long, so there are 7 bytes following the last full block.) 108 540 P -3 F -0.22 (Bdes) 72 520 P -0 F -0.22 ( pads this to a full block by appending one byte containing the ) 95.32 520 P -5 F -0.19 (ASCII) 399.67 520 P -0 F -0.22 ( character with numeric) 425.77 520 P -(value 7 \050the ) 72 500 T -5 F -(ASCII) 131.62 500 T -0 F -( character <) 157.71 500 T -5 F -(BEL) 214.42 500 T -0 F -(>\051. The result is then encrypted.) 233.3 500 T -0.44 (As another example, suppose ) 108 476 P -7 F -1.07 (inputf) 253.34 476 P -1.07 (ile) 296.52 476 P -0 F -0.44 ( contains \322) 318.11 476 P -6 F -1.07 (test) 370.29 476 P -0 F -0.44 (\323, and it is encrypted in ECB) 399.08 476 P -(mode using the key \322) 72 456 T -6 F -(abcdef#@) 173.93 456 T -0 F -(\323; the command is) 231.5 456 T -6 F -(bdes -b \320k abcdef#@ < ) 147.69 432 T -7 F -(inputf) 306 432 T -(ile) 349.18 432 T -6 F -( > ) 370.76 432 T -7 F -(outputf) 392.35 432 T -(ile) 442.73 432 T -0 F -(because the option ) 72 408 T -4 F -(\320b) 164.26 408 T -0 F -( signi\336es ECB mode:) 176.93 408 T -(text) 72 384 T -6 F -(t) 144 384 T -(e) 171 384 T -(s) 198 384 T -(t) 225 384 T -0 F -(hex) 72 364 T -10 F -(74) 144 364 T -(65) 171 364 T -(73) 198 364 T -(74) 225 364 T -0 F -(input) 72 344 T -10 F -(74) 144 344 T -(65) 171 344 T -(73) 198 344 T -(74) 225 344 T -(00) 252 344 T -(00) 279 344 T -(00) 306 344 T -(04) 333 344 T -0 F -(output) 72 324 T -10 F -(0d) 144 324 T -(8a) 171 324 T -(6e) 198 324 T -(57) 225 324 T -(9c) 252 324 T -(8f) 279 324 T -(27) 306 324 T -(5d) 333 324 T -0 F --0.31 (Finally) 108 304 P --0.31 (, if the length of the message is indeed a multiple of the block size, an extra block of) 141.21 304 P -0.83 (all 0 bits is added. Suppose ) 72 284 P -7 F -1.99 (inputf) 210.57 284 P -1.99 (ile) 253.74 284 P -0 F -0.83 ( contains \322) 275.33 284 P -6 F -1.99 (test) 328.28 284 P -9 F -0.83 (\277) 357.07 284 P -0 F -0.83 (\323, and it is encrypted in 40-bit CFB) 364.96 284 P -1.51 (mode using the key \322) 72 264 P -6 F -3.62 (abcdef#@) 179.96 264 P -0 F -1.51 (\323 and the initialization vector ) 237.53 264 P -6 F -3.62 (0x0123456789abcdef) 387.97 264 P -0 F -1.51 (; the) 517.5 264 P -(command is) 72 244 T -6 F --0.99 (bdes -f40 -v0x0123456789abcdef -kabcdef#@ < ) 72 220 P -7 F --0.99 (inputf) 383.67 220 P --0.99 (ile) 426.85 220 P -6 F --0.99 ( > ) 448.43 220 P -7 F --0.99 (outputf) 468.04 220 P --0.99 (ile) 518.41 220 P -0 F -0.16 (because the option ) 72 196 P -4 F -0.16 (\320f40 ) 164.75 196 P -0 F -0.16 (signi\336es 40-bit CFB mode, and ) 189.89 196 P -4 F -0.16 (-v0x01234566789abcdef) 343.96 196 P -0 F -0.16 ( sets the initial-) 465.89 196 P -(ization vector \050note that spaces between the option and its ar) 72 176 T -(gument are optional\051:) 361.57 176 T -(text) 72 152 T -6 F -(t) 144 152 T -(e) 171 152 T -(s) 198 152 T -(t) 225 152 T -9 F -(\277) 252 152 T -0 F -(hex) 72 132 T -10 F -(74) 144 132 T -(65) 171 132 T -(73) 198 132 T -(74) 225 132 T -(0a) 252 132 T -0 F -(input) 72 112 T -10 F -(74) 144 112 T -(65) 171 112 T -(73) 198 112 T -(74) 225 112 T -(0a) 252 112 T -(00) 279 112 T -(00) 306 112 T -(00) 333 112 T -(00) 360 112 T -(00) 387 112 T -0 F -(output) 72 92 T -10 F -(e2) 144 92 T -(c2) 171 92 T -(69) 198 92 T -(a4) 225 92 T -(5b) 252 92 T -(3c) 279 92 T -(3d) 306 92 T -(b3) 333 92 T -(f5) 360 92 T -(3c) 387 92 T -FMENDPAGE -%%EndPage: "4" 7 -1 12 /Times-BoldItalic FMDEFINEFONT -2 14 /Symbol FMDEFINEFONT -%%Page: "5" 7 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 5 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -0 X -(Note here the block size is 40 bits \0505 bytes\051, not 64 bits \0508 bytes\051.) 108 712 T --0.4 (This technique allows complete compatibility with Sun\325) 108 688 P --0.4 (s ) 374.11 688 P -3 F --0.4 (des) 381.37 688 P -0 F --0.4 ( program. In Sun\325) 397.36 688 P --0.4 (s implemen-) 480.77 688 P -0.02 (tation, padding is done with random bytes rather than bytes containing all zero bits. Cryptograph-) 72 668 P -0.85 (ically) 72 648 P -0.85 (, this makes no dif) 97.87 648 P -0.85 (ference, as the DES is a suf) 189.32 648 P -0.85 (\336ciently good random cipher to obscure the) 325.74 648 P -(input \050see for example [2], Chapter 6\051, and known plaintext attacks are very dif) 72 628 T -(\336cult [1].) 451.82 628 T -4 F -(5. Differ) 72 596 T -(ences Between the Standard CFB and OFB Modes and ) 114.41 596 T -1 F -(bdes) 397.26 596 T -0 F --0.11 (The UNIX operating system treats all \336les as streams of 8-bit bytes. In order to implement) 108 572 P --0.08 (the CFB and OFB modes properly) 72 552 P --0.08 (, it would be necessary to read ) 235.74 552 P -3 F --0.08 (k) 383.74 552 P -0 F --0.08 ( bits from the \336le, where ) 389.07 552 P -3 F --0.08 (k) 509.51 552 P -0 F --0.08 ( is an) 514.84 552 P -0.98 (integer between 1 and 64 inclusive. However) 72 532 P -0.98 (, this would require considerable buf) 294.22 532 P -0.98 (fering and be) 474.77 532 P -0.23 (quite inef) 72 512 P -0.23 (\336cient and prohibitively slow) 117.65 512 P -0.23 (. For these reasons, the current implementation of ) 258.48 512 P -3 F -0.23 (bdes) 501.48 512 P -0 F -0.23 ( re-) 523.46 512 P -0.47 (quires that ) 72 492 P -3 F -0.47 (k) 126.23 492 P -0 F -0.47 ( be a multiple of 8, so that an integral number of bytes will always be read from the) 131.56 492 P -(\336le. Other than this change, this mode is implemented as described in [3].) 72 472 T --0.58 (A similar observation holds for the alternate CFB mode described in [3]. Here, only the low) 108 448 P -0.23 (7 bits of each byte are signi\336cant, and hence the parameter ) 72 428 P -3 F -0.23 (k) 358.95 428 P -0 F -0.23 ( is an integer from 1 to 56 inclusive;) 364.28 428 P -(bdes requires k to be a multiple of 7. The high-order bit is retained for encryption and decryption,) 72 408 T -(but output \050whether from encryption or decryption\051 always has the high-order bit set to zero.) 72 388 T -4 F -(6. Message Authentication Code Modes) 72 356 T -0 F -0.57 (The Data Encryption Standard provides two modes of authentication, each providing be-) 108 332 P -1.27 (tween 1 and 64 bits of authentication data. In both cases an ) 72 312 P -3 F -1.27 (n) 373.32 312 P -0 F -1.27 (-bit message authentication code) 379.32 312 P -0.62 (\050MAC\051 is generated, where 1) 72 292 P -2 F -0.73 ( ) 214.71 292 P -9 F -0.62 (\243) 218.94 292 P -0 F -0.62 ( ) 225.52 292 P -3 F -0.62 (n) 229.15 292 P -0 F -0.62 ( ) 235.14 292 P -9 F -0.62 (\243) 238.76 292 P -0 F -0.62 ( 64. The \336rst is based on the CBC encryption mode, and the) 245.35 292 P -(second on CFB mode. Both work the same.) 72 272 T -0.13 (First, the \336le is padded to a multiple of the block size by appending enough zero bits. It is) 108 248 P --0.16 (then encrypted using the standard CBC \050or CFB\051 algorithm, but -all encrypted text is discarded ex-) 72 228 P --0.44 (cept for the last block. The ) 72 208 P -3 F --0.44 (n) 200.9 208 P -0 F --0.44 ( leading bits of the last block are used as the MAC. Note that the block) 206.9 208 P -(size constrains the number of bits available as the MAC.) 72 188 T -0.71 (The implementation allows the user to specify that the MAC is to be computed in either) 108 164 P --0.01 (CBC or CFB mode, and the user can specify any number of bits from 1 to 64 inclusive. However) 72 144 P --0.01 (,) 537 144 P --0.11 (because the UNIX operating system can only output bits in multiples of 8, if the number of bits of) 72 124 P --0.08 (MAC is not a multiple of 8, the MAC will be right-padded with the minimum number of zero bits) 72 104 P --0.31 (necessary to make the MAC length be a multiple of 8. However) 72 84 P --0.31 (, note that as the standard \050[3], Ap-) 374.6 84 P -FMENDPAGE -%%EndPage: "5" 8 -%%Page: "6" 8 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 6 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -0 X --0.14 (pendix F\051 requires an incomplete \336nal block be right-padded with -zeroes, the technique of forcing) 72 712 P -(the last octet to contain the number of bytes in the message is ) 72 692 T -3 F -(not) 369.47 692 T -0 F -( used here.) 384.8 692 T --0.39 (For example, suppose ) 108 668 P -7 F --0.94 (inputf) 214.76 668 P --0.94 (ile) 257.93 668 P -0 F --0.39 ( contains \322) 279.52 668 P -6 F --0.94 (This) 330.04 668 P -8 F --0.43 (z) 358.82 668 P -6 F --0.94 (is) 363.8 668 P -8 F --0.43 (z) 378.19 668 P -6 F --0.94 (a) 383.17 668 P -8 F --0.43 (z) 390.36 668 P -6 F --0.94 (test) 395.34 668 P -9 F --0.39 (\277) 424.13 668 P -0 F --0.39 (\323, and a 64-bit MAC is) 432.02 668 P --0.73 (to be generated using CBC mode, the key \322) 72 648 P -6 F --1.74 (abcdef#@) 274.39 648 P -0 F --0.73 (\323 and the initialization vector ) 331.96 648 P -6 F --1.74 (0x0) 471.23 648 P -0 F --0.73 (; the com-) 492.82 648 P -(mand is) 72 628 T -6 F -(bdes -m 64 -k abcdef#@ < ) 136.89 604 T -7 F -(inputf) 316.79 604 T -(ile) 359.97 604 T -6 F -( > ) 381.56 604 T -7 F -(outputf) 403.15 604 T -(ile) 453.52 604 T -0 F -(as CBC is the default encryption mode and ) 72 580 T -6 F -(0x0) 281.2 580 T -0 F -( the default initialization vector:) 302.79 580 T -(text) 72 556 T -6 F -(T) 117 556 T -(h) 144 556 T -(i) 171 556 T -(s) 198 556 T -8 F -(z) 225 556 T -6 F -(i) 252 556 T -(s) 279 556 T -8 F -(z) 306 556 T -6 F -(a) 333 556 T -8 F -(z) 360 556 T -6 F -(t) 387 556 T -(e) 414 556 T -(s) 441 556 T -(t) 468 556 T -9 F -(\277) 495 556 T -0 F -(hex) 72 536 T -10 F -(54) 117 536 T -(68) 144 536 T -(69) 171 536 T -(73) 198 536 T -(20) 225 536 T -(69) 252 536 T -(73) 279 536 T -(20) 306 536 T -(61) 333 536 T -(20) 360 536 T -(74) 387 536 T -(65) 414 536 T -(73) 441 536 T -(74) 468 536 T -(0a) 495 536 T -0 F -(input) 72 516 T -10 F -(54) 117 516 T -(68) 144 516 T -(69) 171 516 T -(73) 198 516 T -(20) 225 516 T -(69) 252 516 T -(73) 279 516 T -(20) 306 516 T -(61) 333 516 T -(20) 360 516 T -(74) 387 516 T -(65) 414 516 T -(73) 441 516 T -(74) 468 516 T -(0a) 495 516 T -(00) 522 516 T -0 F -(output) 72 496 T -10 F -(43) 117 496 T -(18) 144 496 T -(de) 171 496 T -(74) 198 496 T -(24) 225 496 T -(a9) 252 496 T -(65) 279 496 T -(d1) 306 496 T -0 F -0.04 (Notice that the text is 15 characters long, so there are 7 bytes following the last full block.) 108 476 P -3 F -(Bdes) 72 456 T -0 F -( pads this to a full block by appending a zero-\336lled byte. The result is then encrypted and the) 95.32 456 T -(last block of output is used as the MAC.) 72 436 T -0.06 (As another example, suppose we used the same text, and wanted a 36-bit MAC to be gen-) 108 412 P -6.91 (erated using 40-bit CFB mode, the key \322) 72 392 P -6 F -16.58 (abcdef#@) 314.9 392 P -0 F -6.91 (\323 and the initialization vector) 372.47 392 P -6 F -(0x0123456789abcdef) 72 372 T -0 F -(; the command is) 201.53 372 T -6 F -(bdes -m 36 -f 40 -v 0x0123456789abcdef < ) 79.32 348 T -7 F -(inputf) 374.36 348 T -(ile) 417.54 348 T -6 F -( > ) 439.13 348 T -7 F -(outputf) 460.71 348 T -(ile) 511.09 348 T -0 F --0.19 (where ) 72 324 P -4 F --0.19 (\320m 36) 104.11 324 P -0 F --0.19 ( is the option to generate a 36-bit MAC, ) 134.91 324 P -4 F --0.19 (\320f 40) 327.79 324 P -0 F --0.19 ( indicates 40-bit CFB is to be used, and) 352.58 324 P -4 F --0.31 (\320v 0x123456789abcdef) 72 304 P -0 F --0.31 ( sets the initialization vector) 186.62 304 P --0.31 (. Note that, as the key is not given on the com-) 319.95 304 P -(mand line, the user will be prompted for it. It gives:) 72 284 T -(text) 72 260 T -6 F -(T) 117 260 T -(h) 144 260 T -(i) 171 260 T -(s) 198 260 T -8 F -(z) 225 260 T -6 F -(i) 252 260 T -(s) 279 260 T -8 F -(z) 306 260 T -6 F -(a) 333 260 T -8 F -(z) 360 260 T -6 F -(t) 387 260 T -(e) 414 260 T -(s) 441 260 T -(t) 468 260 T -9 F -(\277) 495 260 T -0 F -(hex) 72 240 T -10 F -(54) 117 240 T -(68) 144 240 T -(69) 171 240 T -(73) 198 240 T -(20) 225 240 T -(69) 252 240 T -(73) 279 240 T -(20) 306 240 T -(61) 333 240 T -(20) 360 240 T -(74) 387 240 T -(65) 414 240 T -(73) 441 240 T -(74) 468 240 T -(0a) 495 240 T -0 F -(input) 72 220 T -10 F -(54) 117 220 T -(68) 144 220 T -(69) 171 220 T -(73) 198 220 T -(20) 225 220 T -(69) 252 220 T -(73) 279 220 T -(20) 306 220 T -(61) 333 220 T -(20) 360 220 T -(74) 387 220 T -(65) 414 220 T -(73) 441 220 T -(74) 468 220 T -(0a) 495 220 T -0 F -(output) 72 200 T -10 F -(2b) 117 200 T -(18) 144 200 T -(68) 171 200 T -(2d) 198 200 T -(60) 225 200 T -0 F -0.19 (Note that the MAC is padded on the right by four zero bits to produce \336ve characters that) 108 180 P -(can be output.) 72 160 T -4 F -(7. Differ) 72 128 T -(ences Between ) 114.41 128 T -1 F -(bdes) 191.01 128 T -4 F -( and Sun\325) 212.99 128 T -(s DES Implementation) 261.88 128 T -0 F -0.02 (The program ) 108 104 P -3 F -0.02 (bdes) 173.33 104 P -0 F -0.02 ( is designed to be completely compatible with Sun Microsystems, Inc.\325) 195.31 104 P -0.02 (s) 535.33 104 P -0.57 (implementation of the Data Encryption Standard, called ) 72 84 P -3 F -0.57 (des) 347.14 84 P -0 F -0.57 ( and described in [4]. Thus, \336les en-) 363.13 84 P -FMENDPAGE -%%EndPage: "6" 9 -%%Page: "7" 9 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 7 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -0 X -0.44 (crypted using ) 72 712 P -3 F -0.44 (des) 140.84 712 P -0 F -0.44 ( can be decrypted using ) 156.83 712 P -3 F -0.44 (bdes) 275.29 712 P -0 F -0.44 (, and vice versa, provided modes common to both) 297.27 712 P --0.34 (are used. However) 72 692 P --0.34 (, ) 160.41 692 P -3 F --0.34 (bdes) 166.06 692 P -0 F --0.34 ( does not allow \336les to be named on the command line, nor does it support) 188.05 692 P --0.68 (hardware devices \050and so the ) 72 672 P -4 F --0.68 (-s) 210.83 672 P -0 F --0.68 ( and ) 219.49 672 P -4 F --0.68 (-f) 241.45 672 P -0 F --0.68 ( options of Sun\325) 249.44 672 P --0.68 (s ) 323.71 672 P -3 F --0.68 (des) 330.7 672 P -0 F --0.68 ( are not available\051. Further) 346.69 672 P --0.68 (, as encryption) 471.07 672 P --0.05 (is the default, the Sun ) 72 652 P -3 F --0.05 (des) 179.01 652 P -0 F --0.05 ( ) 195 652 P -4 F --0.05 (-e) 197.95 652 P -0 F --0.05 ( option is not recognized. As the manual page to ) 207.27 652 P -3 F --0.05 (bdes) 441.6 652 P -0 F --0.05 ( is in the appen-) 463.59 652 P -(dix, these dif) 72 632 T -(ferences will not be elaborated upon further) 134.08 632 T -(.) 343.24 632 T -0.44 (Sun\325) 108 608 P -0.44 (s ) 130 608 P -3 F -0.44 (des) 138.1 608 P -0 F -0.44 ( supports the use of special-purpose hardware to encrypt and decrypt. Although) 154.09 608 P -3 F -1.33 (bdes) 72 588 P -0 F -1.33 ( does not directly support the use of such hardware, it uses the library routine ) 93.98 588 P -3 F -1.33 (encrypt) 487.05 588 P -0 F -1.33 (\0503\051,) 523.02 588 P --0.09 (which may) 72 568 P --0.09 (. Hardware support was not included directly to support as lar) 124.1 568 P --0.09 (ge a number of platforms) 419.11 568 P -(as possible with installers needing to know as little about the hardware as possible.) 72 548 T --0.08 (Sun\325) 108 524 P --0.08 (s ) 130 524 P -3 F --0.08 (des) 137.58 524 P -0 F --0.08 ( supports only the CBC and ECB encryption modes; ) 153.57 524 P -3 F --0.08 (bdes) 407.07 524 P -0 F --0.08 ( supports all modes de-) 429.05 524 P -0.26 (scribed in [3] \050although CFB and OFB are not completely supported\051 as well as both CBC-based) 72 504 P -(and CFB-based MACs.) 72 484 T -0.15 (Although input with length not a multiple of the block size is handled in the same way by) 108 460 P --0.47 (both ) 72 440 P -3 F --0.47 (des) 95.85 440 P -0 F --0.47 ( and ) 111.84 440 P -3 F --0.47 (bdes) 134.21 440 P -0 F --0.47 (, dif) 156.19 440 P --0.47 (ferent values of the padding bytes are used in all but the last byte of the input.) 174.82 440 P -(Where ) 72 420 T -3 F -(bdes) 106.96 420 T -0 F -( puts zero bytes, ) 128.94 420 T -3 F -(des) 209.89 420 T -0 F -( puts bytes containing random values. The reason for Sun\325) 225.87 420 T -(s doing) 505.02 420 T -0.47 (so is to prevent a known plaintext attack on the \336le should an -attacker determine that the input\325) 72 400 P -0.47 (s) 535.33 400 P --0.29 (length were a multiple of the block size. W) 72 380 P --0.29 (ith ) 276.05 380 P -3 F --0.29 (bdes) 291.43 380 P -0 F --0.29 (, the plaintext contents of the last block of input) 313.41 380 P -0.31 (for such a \336le is known \050a block with all bits zero\051. W) 72 360 P -0.31 (ith ) 333.99 360 P -3 F -0.31 (des) 349.96 360 P -0 F -0.31 (, the plaintext contents of that block) 365.95 360 P -0.73 (are not known. Cryptanalytically) 72 340 P -0.73 (, given the information about the strength of the DES currently) 231.29 340 P -0.2 (known, it is widely believed that known plaintext attacks are infeasible -\050see for example [1]\051 and) 72 320 P -1.86 (so initializing and invoking the pseudorandom number generator seems unnecessary) 72 300 P -1.86 (. But this) 492.63 300 P -(means that ciphertexts produced from a plaintext by ) 72 280 T -3 F -(bdes) 324.48 280 T -0 F -( and ) 346.47 280 T -3 F -(des) 369.78 280 T -0 F -( will dif) 385.77 280 T -(fer in the last block.) 423.54 280 T -4 F -(Refer) 72 248 T -(ences) 100.41 248 T -0 F -([1]) 72 224 T -0.37 (D. Denning, \322The Data Encryption Standard: Fifteen Y) 108 224 P -0.37 (ears of Public Scrutiny) 374.87 224 P -0.37 (,\323 ) 484.8 224 P -3 F -0.37 (Pr) 496.49 224 P -0.37 (oceed-) 508.04 224 P --0.47 (ings of the Sixth Annual Computer Security Applications Confer) 108 204 P --0.47 (ence) 411.65 204 P -0 F --0.47 ( pp. x\320xv \050Dec. 1990\051.) 433.62 204 P -([2]) 72 180 T -(A. Konheim, ) 108 180 T -3 F -(Cryptography: A Primer) 173.29 180 T -0 F -(, John W) 291.4 180 T -(iley and Sons, Inc., New Y) 333.9 180 T -(ork, NY \0501981\051.) 461.94 180 T -([3]) 72 156 T -3 F -0.63 (DES Modes of Operation) 108 156 P -0 F -0.63 (, Federal Information Processing Standards Publication 81, Na-) 231.47 156 P --0.07 (tional Bureau of Standards, U.S. Department of Commerce, W) 108 136 P --0.07 (ashington, DC \050Dec. 1980\051.) 407.62 136 P -([4]) 72 112 T -3 F -(UNIX User) 108 112 T -(\325) 162.74 112 T -(s Manual) 165.18 112 T -0 F -(, Sun Microsystems Inc., Mountain V) 210.16 112 T -(iew) 390 112 T -(, CA \050Mar) 406.54 112 T -(. 1988\051.) 455.51 112 T -4 F -(Appendix. The UNIX System Manual Page for ) 72 80 T -1 F -(bdes) 313.2 80 T -FMENDPAGE -%%EndPage: "7" 10 -1 11 /Times-Bold FMDEFINEFONT -%%Page: "8" 10 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 8 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -1 F -0 X -(NAME) 72 712.67 T -0 F -(bdes - encrypt/decrypt using the Data Encryption Standard) 108 689 T -1 F -(SYNOPSIS) 72 663.67 T -4 F -(bdes) 108 640 T -0 F -( [) 131.33 640 T -3 F -( ) 138.32 640 T -4 F -(-abdp) 141.32 640 T -0 F -( ] [ ) 171.31 640 T -4 F -(-F) 188.3 640 T -0 F -( ) 199.62 640 T -3 F -(b) 202.62 640 T -0 F -( ] [ ) 208.61 640 T -4 F -(-f) 225.6 640 T -0 F -( ) 233.58 640 T -3 F -(b) 236.58 640 T -0 F -( ] [ ) 242.58 640 T -4 F -(-k) 259.56 640 T -0 F -( ) 270.22 640 T -3 F -(key) 273.22 640 T -0 F -( ] [ ) 289.2 640 T -4 F -(-m) 306.18 640 T -0 F -( ) 320.16 640 T -3 F -(b) 323.16 640 T -0 F -( ] [ ) 329.16 640 T -4 F -(-o) 346.14 640 T -0 F -( ) 356.13 640 T -3 F -(b) 359.13 640 T -0 F -( ] [ ) 365.13 640 T -4 F -(-v) 382.11 640 T -0 F -( ) 392.1 640 T -3 F -(vector) 395.1 640 T -0 F -( ]) 425.07 640 T -1 F -(DESCRIPTION) 72 614.67 T -3 F --0.69 (Bdes) 108 591 P -0 F --0.69 ( reads from the standard input and writes on the standard output. It implements all DES) 131.32 591 P --0.09 (modes of operation described in FIPS PUB 81 including alternative cipher feedback mode) 108 577 P -0.74 (and both authentication modes. All modes but the electronic code book mode require an) 108 563 P --0.14 (initialization vector; if none is supplied, the zero vector is used. T) 108 549 P --0.14 (o protect the key and ini-) 420.44 549 P -0.29 (tialization vector from being read by) 108 535 P -3 F -0.29 ( ps) 284.98 535 P -0 F -0.29 (\0501\051, ) 298.94 535 P -3 F -0.29 (bdes ) 319.21 535 P -0 F -0.29 (hides its ar) 344.48 535 P -0.29 (guments on entry) 396.81 535 P -0.29 (. If no ) 479.89 535 P -3 F -0.29 (key ) 512.74 535 P -0 F -0.29 (is) 532 535 P --0.61 (given, one is requested from the controlling terminal if that can be opened, or from the stan-) 108 521 P -(dard input if not.) 108 507 T --0.17 (The key and initialization vector are taken as sequences of ) 108 489 P -5 F --0.14 (ASCII) 389.38 489 P -0 F --0.17 ( characters which are then) 415.48 489 P --0.35 (mapped into their bit representations. If either begins with -\3240x\325 or \3240X\325, that one is taken as) 108 475 P -1.02 (a sequence of hexadecimal digits indicating the bit pattern; if either begins with \3240b\325 or) 108 461 P --0.73 (\3240B\325, that one is taken as a sequence of binary digits -indicating the bit pattern. In either case,) 108 447 P --0.37 (only the leading 64 bits of the key or initialization vector are used, and if fewer than 64 bits) 108 433 P -0.35 (are provided, enough 0 bits are appended to pad the key to 64 bits. Note that if the key is) 108 419 P -0.03 (not entered on the command line, it is interpreted in the same way) 108 405 P -0.03 (, because with 4.4 BSD,) 424.31 405 P --0.36 (the password reading function ) 108 391 P -3 F --0.36 (getpass) 254.45 391 P -0 F --0.36 (\0503\051 allows enough characters for either hex or binary) 290.43 391 P -(keys to be entered.) 108 377 T -0.04 (According to the DES standard, the low-order bit of each character in the key string is de-) 108 359 P --0.18 (leted. Since most ) 108 345 P -5 F --0.15 (ASCII) 192.75 345 P -0 F --0.18 ( representations set the high-order bit to 0, simply deleting the low-) 218.84 345 P --0.29 (order bit ef) 108 331 P --0.29 (fectively reduces the size of the key space from 2) 160.49 331 P -5 F --0.24 (56) 394.67 335.8 P -0 F --0.29 ( to 2) 404.67 331 P -5 F --0.24 (48) 425.41 335.8 P -0 F --0.29 ( keys. T) 435.4 331 P --0.29 (o prevent this,) 472.29 331 P --0.46 (the high-order bit must be a function depending in part upon the low-order bit; so, the high-) 108 317 P -0.11 (order bit is set to whatever value gives odd parity) 108 303 P -0.11 (. This preserves the key space size. Note) 345.05 303 P -(this resetting of the parity bit is ) 108 289 T -3 F -(not) 260.92 289 T -0 F -( done if the key is given in binary or hex.) 276.24 289 T --0.38 (By default, the standard input is encrypted using cipher block chaining mode and is written) 108 271 P -0.18 (to the standard output. Using the same key for encryption and decryption preserves plain-) 108 257 P -(text, so) 108 243 T -( bdes ) 225.81 225 T -3 F -(key) 253.79 225 T -0 F -( < plaintext | bdes \320i ) 269.77 225 T -3 F -(key) 370.21 225 T -0 F -( ) 386.19 225 T -(is a very expensive equivalent of ) 108 201 T -3 F -(cat) 268.54 201 T -0 F -(\0501\051.) 283.2 201 T -(Options are:) 108 183 T -( ) 108 165 T -4 F -(\320a) 111 165 T -0 F --0.75 (The key and initialization vector strings are to be taken as ) 144 165 P -5 F --0.62 (ASCII) 415.89 165 P -0 F --0.75 ( suppressing the spe-) 441.98 165 P -0.3 (cial interpretation given to leading \3240x\325, \3240X\325, \3240b\325, -and \3240B\325 characters. Note this) 144 151 P -(\337ag applies to ) 144 137 T -3 F -(both) 214.29 137 T -0 F -( the key and initialization vector) 235.62 137 T -(.) 389.85 137 T -4 F -(\320b) 108 119 T -0 F -(Use electronic code book mode.) 144 119 T -4 F -(\320d) 108 101 T -0 F -(Decrypt the input.) 144 101 T -FMENDPAGE -%%EndPage: "8" 11 -%%Page: "9" 11 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 9 of 11) 479.71 34.7 T -72 72 540 720 R -7 X -V -4 F -0 X -(\320f) 108 712 T -0 F -( ) 117.99 712 T -3 F -(b) 120.99 712 T -0 F --0.29 (Use ) 144 712 P -3 F --0.29 (b) 165.36 712 P -0 F --0.29 (-bit cipher feedback mode. Currently ) 171.35 712 P -3 F --0.29 (b) 350.42 712 P -0 F --0.29 ( must be a multiple of 8 between 8 and) 356.42 712 P -(64 inclusive \050this does not conform to the standard CFB mode speci\336cation\051.) 144 698 T -4 F -(\320F) 108 680 T -0 F -( ) 121.32 680 T -3 F -(b) 124.32 680 T -0 F --0.29 (Use ) 144 680 P -3 F --0.29 (b) 165.36 680 P -0 F --0.29 (-bit alternative cipher feedback mode. Currently ) 171.36 680 P -3 F --0.29 (b) 403.77 680 P -0 F --0.29 ( must be a multiple of 7 be-) 409.77 680 P --0.12 (tween 7 and 56 inclusive \050this does not conform to the alternative CFB mode spec-) 144 666 P -(i\336cation\051.) 144 652 T -4 F -(\320k) 108 634 T -0 F -( ) 120.67 634 T -3 F -(key) 123.66 634 T -0 F -0.37 (Use the string ) 144 616 P -3 F -0.37 (key) 214.74 616 P -0 F -0.37 ( as the cryptographic key) 230.72 616 P -0.37 (. If this ar) 352.01 616 P -0.37 (gument is not given, the user) 399.54 616 P -(will be prompted for the key) 144 602 T -(.) 280.12 602 T -4 F -(\320m) 108 584 T -0 F -( ) 123.99 584 T -3 F -(b) 126.99 584 T -0 F -0.71 (Compute a message authentication code \050MAC\051 of ) 144 584 P -3 F -0.71 (b) 395.78 584 P -0 F -0.71 ( bits on the input. ) 401.77 584 P -3 F -0.71 (b) 491.94 584 P -0 F -0.71 ( must be) 497.94 584 P -0.11 (between 1 and 64 inclusive; if ) 144 570 P -3 F -0.11 (b) 291.87 570 P -0 F -0.11 ( is not a multiple of 8, enough 0 bits will be added) 297.86 570 P --0.44 (to pad the MAC length to the nearest multiple of 8. Only the MAC is output. MACs) 144 556 P -(are only available in cipher block chaining mode or in cipher feedback mode.) 144 542 T -4 F -(\320o) 108 524 T -0 F -( ) 119.99 524 T -3 F -(b) 122.99 524 T -0 F --0.34 (Use ) 144 524 P -3 F --0.34 (b) 165.31 524 P -0 F --0.34 (-bit output feedback mode. Currently ) 171.31 524 P -3 F --0.34 (b) 350.83 524 P -0 F --0.34 ( must be a multiple of 8 between 8 and) 356.83 524 P -(64 inclusive \050this does not conform to the OFB mode speci\336cation\051.) 144 510 T -4 F -(\320p) 108 492 T -0 F --0.14 (Disable the resetting of the parity bit. This \337ag forces the parity bit of the key to be) 144 492 P -0.03 (used as typed, rather than making each character be of odd parity) 144 478 P -0.03 (. It is used only if) 455.91 478 P -(the key is given in ) 144 464 T -5 F -(ASCII) 234.95 464 T -0 F -(.) 261.04 464 T -4 F -(\320v) 108 446 T -0 F -( ) 119.99 446 T -3 F -(vector) 122.99 446 T -0 F --0.5 (Set the initialization vector to ) 144 428 P -3 F --0.5 (v) 286.44 428 P -0 F --0.5 (; the vector is interpreted in the same way as the key) 291.76 428 P --0.5 (.) 537 428 P -(The vector is ignored in electronic codebook mode.) 144 414 T --0.55 (The DES is considered a very strong cryptosystem, and other than table lookup attacks, key) 108 396 P -0.24 (search attacks, and Hellman\325) 108 382 P -0.24 (s time-memory tradeof) 246.61 382 P -0.24 (f \050all of which are very expensive and) 356.8 382 P -0.66 (time-consuming\051, no cryptanalytic methods for breaking the DES are known in the open) 108 368 P -0.33 (literature. No doubt the choice of keys and key security are the most vulnerable aspect of) 108 354 P -3 F -(bdes) 108 340 T -0 F -(.) 129.98 340 T -4 F -(IMPLEMENT) 72 314 T -(A) 146.41 314 T -(TION NOTES) 154.18 314 T -0 F -0.57 (For implementors wishing to write software compatible with this program, the following) 108 290 P --0.23 (notes are provided. This software is completely compatible with the implementation of the) 108 276 P -(data encryption standard distributed by Sun Microsystems, Inc.) 108 262 T -0.11 (In the ECB and CBC modes, plaintext is encrypted in units of 64 bits \0508 bytes, also called) 108 244 P -0.52 (a block\051. T) 108 230 P -0.52 (o ensure that the plaintext \336le is encrypted correctly) 160.49 230 P -0.52 (, ) 413.01 230 P -3 F -0.52 (bdes ) 419.53 230 P -0 F -0.52 (will \050internally\051 ap-) 445.03 230 P -0.29 (pend from 1 to 8 bytes, the last byte containing an integer stating how many bytes of that) 108 216 P --0.71 (\336nal block are from the plaintext \336le, and encrypt the resulting block. Hence, when decrypt-) 108 202 P -0.27 (ing, the last block may contain from 0 to 7 characters present in the plaintext \336le, and the) 108 188 P --0.59 (last byte tells how many) 108 174 P --0.59 (. Note that if during decryption the last byte of the \336le does not con-) 221.46 174 P -0.41 (tain an integer between 0 and 7, either the \336le has been corrupted or an incorrect key has) 108 160 P -0.48 (been given. A similar mechanism is used for the OFB and CFB modes, except that those) 108 146 P -0.26 (simply require the length of the input to be a multiple of the mode size, and the \336nal byte) 108 132 P --0.73 (contains an integer between 0 and one less than the number of bytes being used as the mode.) 108 118 P -(\050This was another reason that the mode size must be a multiple of 8 for those modes.\051) 108 104 T -FMENDPAGE -%%EndPage: "9" 12 -%%Page: "10" 12 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 10 of 11) 473.71 34.7 T -72 72 540 720 R -7 X -V -0 X -0.94 (Unlike Sun\325) 108 712 P -0.94 (s implementation, unused bytes of that last block are not \336lled with random) 166.58 712 P -0.57 (data, but instead contain what was in those byte positions in the preceding block. This is) 108 698 P -(quicker and more portable, and does not weaken the encryption signi\336cantly) 108 684 T -(.) 473.95 684 T -0.36 (If the key is entered in ) 108 666 P -5 F -0.3 (ASCII) 220.76 666 P -0 F -0.36 (, the parity bits of the key characters are set so that each key) 246.85 666 P -1.03 (character is of odd parity) 108 652 P -1.03 (. Unlike Sun\325) 231.23 652 P -1.03 (s implementation, it is possible to enter binary or) 296.92 652 P --0.57 (hexadecimal keys on the command line, and if this is done, the parity bits are ) 108 638 P -3 F --0.57 (not ) 472.85 638 P -0 F --0.57 (reset. This) 490.61 638 P -(allows testing using arbitrary bit patterns as keys.) 108 624 T -0.64 (The Sun implementation always uses an initialization vector of 0 \050that is, all zeroes\051. By) 108 606 P -(default, ) 108 592 T -3 F -(bdes ) 147.3 592 T -0 F -(does too, but this may be changed from the command line.) 172.29 592 T -4 F -(FILES) 72 566 T -0 F -(/dev/tty) 108 542 T -(controlling terminal for typed key) 180 542 T -4 F -(SEE ALSO) 72 516 T -3 F -(crypt) 108 492 T -0 F -(\0501\051, ) 132.65 492 T -3 F -(crypt) 152.63 492 T -0 F -(\0503\051) 177.27 492 T -3 F --0.4 (Data Encryption Standar) 108 474 P --0.4 (d) 228.02 474 P -0 F --0.4 (, Federal Information Processing Standard #46, National Bureau) 234.02 474 P -(of Standards, U.S. Department of Commerce, W) 108 460 T -(ashington DC \050Jan. 1977\051.) 340.2 460 T -3 F -0.16 (DES) 108 442 P -0 F -0.16 ( ) 129.98 442 P -3 F -0.16 (Modes of Operation, ) 133.15 442 P -0 F -0.16 (Federal Information Processing Standard #81, National Bureau) 236.24 442 P -(of Standards, U.S. Department of Commerce, W) 108 428 T -(ashington DC \050Dec. 1980\051.) 340.2 428 T -2.75 (Dorothy Denning, ) 108 410 P -3 F -2.75 (Cryptography and Data Security) 203.77 410 P -0 F -2.75 (, Addison-W) 368.8 410 P -2.75 (esley Publishing Co.,) 432.55 410 P -(Reading, MA \2511982.) 108 396 T --0.19 ( Matt Bishop, \322Implementation Notes on ) 108 378 P -3 F --0.19 (bdes) 305.76 378 P -0 F --0.19 (\0501\051\323, T) 327.75 378 P --0.19 (echnical Report PCS-TR-91-158, De-) 359.35 378 P -0.34 (partment of Mathematics and Computer Science, Dartmouth College, Hanover) 108 364 P -0.34 (, NH \050Apr) 488.01 364 P -0.34 (.) 537 364 P -(1991\051.) 108 350 T -4 F -(CAUTION) 72 324 T -0 F --0.55 (Certain speci\336c keys should be avoided because they introduce potential weaknesses; these) 108 300 P --0.44 (keys, called the ) 108 286 P -3 F --0.44 (weak) 183.95 286 P -0 F --0.44 ( and ) 208.6 286 P -3 F --0.44 (semiweak) 231.03 286 P -0 F --0.44 ( keys, are \050in hex notation, where ) 277.66 286 P -6 F --1.06 (p) 437.45 286 P -0 F --0.44 ( is either ) 444.64 286 P -6 F --1.06 (0) 487.63 286 P -0 F --0.44 ( or ) 494.82 286 P -6 F --1.06 (1) 509.93 286 P -0 F --0.44 (, and) 517.12 286 P -6 F -(P) 108 272 T -0 F -( is either ) 115.2 272 T -6 F -(e) 159.5 272 T -0 F -( or ) 166.7 272 T -6 F -(f) 182.68 272 T -0 F -(\051:) 189.88 272 T -6 F -(0x0p0p0p0p0p0p0p0p) 144 254 T -(0x0p1P0p1P0p0P0p0P) 360 254 T -(0x0pep0pep0pfp0pfp) 144 236 T -(0x0pfP0pfP0pfP0pfP) 360 236 T -(0x1P0p1P0p0P0p0P0p) 144 218 T -(0x1P1P1P1P0P0P0P0P) 360 218 T -(0x1Pep1Pep0Pfp0Pfp) 144 200 T -(0x1PfP1PfP0PfP0PfP) 360 200 T -(0xep0pep0pfp0pfp0p) 144 182 T -(0xep1Pep1pfp0Pfp0P) 360 182 T -(0xepepepepepepepep) 144 164 T -(0xepfPepfPfpfPfpfP) 360 164 T -(0xfP0pfP0pfP0pfP0p) 144 146 T -(0xfP1PfP1PfP0PfP0P) 360 146 T -(0xfPepfPepfPepfPep) 144 128 T -(0xfPfPfPfPfPfPfPfP) 360 128 T -0 F -0.13 (The weakness of these keys is inherent in the DES algorithm \050see for example Moore and) 108 110 P --0.57 (Simmons, \322Cycle structure of the DES with weak and semi-weak keys,\323) 108 96 P -3 F --0.57 ( Advances in Cryp-) 449.43 96 P -(tology \320 Crypto \32486 Pr) 108 82 T -(oceedings) 216.83 82 T -0 F -(, Springer) 264.79 82 T -(-V) 311.85 82 T -(erlag New Y) 323.17 82 T -(ork, \2511987, pp. 9-32\051.) 383.25 82 T -FMENDPAGE -%%EndPage: "10" 13 -%%Page: "11" 13 -612 792 0 FMBEGINPAGE -72 745.99 540 756 R -7 X -0 K -V -72 32.69 540 42.7 R -V -0 F -0 X -(Page 11 of 11) 473.71 34.7 T -72 72 540 720 R -7 X -V -4 F -0 X -(BUGS) 72 712 T -0 F --0.18 (There is a controversy raging over whether the DES will still be secure in a few years. The) 108 688 P -0.31 (advent of special-purpose hardware could reduce the cost of any of the methods of attack) 108 674 P -(named above so that they are no longer computationally infeasible.) 108 660 T -0.32 (Programs which display programs\325 ar) 108 642 P -0.32 (guments may compromise the key and initialization) 289.59 642 P -0.76 (vector if they are speci\336ed on the command line. T) 108 628 P -0.76 (o avoid this ) 358.46 628 P -3 F -0.76 (bdes) 419.7 628 P -0 F -0.76 ( overwrites its ar) 441.68 628 P -0.76 (gu-) 524.01 628 P -(ments. However) 108 614 T -(, the obvious race cannot currently be avoided.) 186.12 614 T -0.25 (As the key or key schedule is kept in memory throughout the run of this program, the en-) 108 596 P -(cryption can be compromised if memory is readable.) 108 582 T --0.4 (There is no warranty of merchantability nor any warranty of \336tness for a particular purpose) 108 564 P -0.05 (nor any other warranty) 108 550 P -0.05 (, either express or implied, as to the accuracy of the enclosed mate-) 216.95 550 P -(rials or as to their suitability for any particular purpose.) 108 536 T --0.06 (Accordingly) 108 518 P --0.06 (, the user assumes full responsibility for their use. Further) 167.18 518 P --0.06 (, the author assumes) 442.93 518 P --0.25 (no obligation to furnish any assistance of any kind whatsoever) 108 504 P --0.25 (, or to furnish any additional) 404.69 504 P -(information or documentation.) 108 490 T -4 F -(AUTHOR) 72 464 T -0 F --0.54 (Matt Bishop, Department of Mathematics and Computer Science, Bradley Hall, Dartmouth) 108 440 P -(College, Hanover) 108 426 T -(, NH 03755) 192.12 426 T -(Electronic mail addresses:) 108 408 T -(Internet: Matt.Bishop@dartmouth.edu) 108 390 T -(UUCP: decvax!dartvax!Matt.Bishop) 108 372 T -FMENDPAGE -%%EndPage: "11" 14 -%%Trailer -%%BoundingBox: 0 0 612 792 -%%Pages: 13 1 -%%DocumentFonts: Helvetica-Bold -%%+ Helvetica-BoldOblique -%%+ Times-Roman -%%+ Times-Bold -%%+ Times-BoldItalic -%%+ Times-Italic -%%+ Courier -%%+ Courier-Oblique -%%+ ZapfDingbats -%%+ Symbol -%%+ Courier-Bold diff --git a/usr.bin/chat/fix-cua b/usr.bin/chat/fix-cua deleted file mode 100644 index 74f000a..0000000 --- a/usr.bin/chat/fix-cua +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -LOCKDIR=/var/spool/lock - -case "$1" in - "") echo "Usage: fix-cua device"; exit 1 ;; -esac - -if [ -f $LOCKDIR/LCK..$1 ] -then - echo "/dev/$1 is locked" 2>&1 - exit 1 -fi - -chown root /dev/$1 -chmod 666 /dev/$1 diff --git a/usr.bin/compile_et/error_message.c b/usr.bin/compile_et/error_message.c deleted file mode 100644 index 92cec57..0000000 --- a/usr.bin/compile_et/error_message.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 1987 by the Student Information Processing Board - * of the Massachusetts Institute of Technology - * For copyright info, see "Copyright.SIPB". - * - * from: error_message.c,v 1.1 86/11/10 21:34:34 spook Exp $ - * $Id: error_message.c,v 1.3 1994/09/09 21:43:22 g89r4222 Exp $ - */ - -#include -#include "error_table.h" -extern int sys_nerr; - -static char buffer[25]; - -char * -error_message(code) - int code; -{ - register int offset; - register error_table **et; - register int table_num; - register int div; - register char *cp; - - offset = code & ((1<base == table_num) { - /* This is the right table */ - if ((*et)->n_msgs <= offset) - goto oops; - return((*et)->msgs[offset]); - } - } - oops: - cp = buffer; - { - register char *cp1; - for (cp1 = "Unknown code "; *cp1; cp1++, cp++) - *cp = *cp1; - if (table_num) { - for (cp1 = error_table_name(table_num); *cp1; cp1++, cp++) - *cp = *cp1; - *cp++ = ' '; - *cp = '\0'; - } - } - div = 1000000000; - if (offset == 0) { - *cp++ = '0'; - *cp = '\0'; - return(buffer); - } - while (div > offset) - div /= 10; - do { - register int n = offset / div; - *cp++ = '0' + n; - offset -= n * div; - div /= 10; - } while (offset && div); - while (div) { - *cp++ = '0'; - div /= 10; - } - *cp = '\0'; - return(buffer); -} diff --git a/usr.bin/compile_et/error_table.h b/usr.bin/compile_et/error_table.h deleted file mode 100644 index e32ec30..0000000 --- a/usr.bin/compile_et/error_table.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _ET -extern int errno; -typedef struct { - char **msgs; - int base; - int n_msgs; -} error_table; -extern error_table **_et_list; - -#define ERROR_CODE "int" /* type used for error codes */ - -#define ERRCODE_RANGE 8 /* # of bits to shift table number */ -#define BITS_PER_CHAR 6 /* # bits to shift per character in name */ - -extern char *error_table_name(); -#define _ET -#endif diff --git a/usr.bin/compile_et/et_name.c b/usr.bin/compile_et/et_name.c deleted file mode 100644 index 98ccb08..0000000 --- a/usr.bin/compile_et/et_name.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 1987 by MIT Student Information Processing Board - * For copyright info, see Copyright.SIPB. - * - * $Id: et_name.c,v 1.2 1994/07/19 19:21:27 g89r4222 Exp $ - */ - -#include "error_table.h" - -static char copyright[] = "Copyright 1987 by MIT Student Information Processing Board"; - -char *malloc(); - -char * -error_table_name(num) - int num; -{ - register int ch; - register int i; - register char *buf, *p; - - /* num = aa aaa abb bbb bcc ccc cdd ddd d?? ??? ??? */ - buf = malloc(5); - p = buf; - num >>= ERRCODE_RANGE; - /* num = ?? ??? ??? aaa aaa bbb bbb ccc ccc ddd ddd */ - num &= 077777777; - /* num = 00 000 000 aaa aaa bbb bbb ccc ccc ddd ddd */ - for (i = 0; i < 5; i++) { - ch = (num >> 24-6*i) & 077; - if (ch == 0) - continue; - else if (ch < 27) - *p++ = ch - 1 + 'A'; - else if (ch < 53) - *p++ = ch - 27 + 'a'; - else if (ch < 63) - *p++ = ch - 53 + '0'; - else /* ch == 63 */ - *p++ = '_'; - } - return(buf); -} - diff --git a/usr.bin/compile_et/init_et.c b/usr.bin/compile_et/init_et.c deleted file mode 100644 index c23facb..0000000 --- a/usr.bin/compile_et/init_et.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 1986 by MIT Information Systems and - * MIT Student Information Processing Board - * For copyright info, see Copyright.SIPB. - * - * form: init_et.c,v 1.1 86/11/10 21:42:26 spook Exp $ - * $Id: init_et.c,v 1.2 1994/07/19 19:21:28 g89r4222 Exp $ - */ - -#include -#include "error_table.h" - -static char copyright[] = "Copyright 1987 by MIT Student Information Processing Board"; - -extern char *malloc(), *realloc(); - -/* useful */ -typedef error_table *etp; -typedef etp *etpp; - -etpp _et_list = (etpp)NULL; -static int n_allocated = 0, n_used = 0; - -int -init_error_table(msgs, base, count) - char **msgs; - register int base; - int count; -{ - register int i; - register etp new_et; - register etpp list; - - if (!base || !count || !msgs) - return; - - new_et = (etp)malloc(sizeof(error_table)); - new_et->msgs = msgs; - new_et->base = base; - new_et->n_msgs= count; - - list = _et_list; - if (list == (etpp)NULL) { - _et_list = (etpp) malloc(10*sizeof(etp)); - list = _et_list; - if (list == (etpp)NULL) - return; /* oops */ - list[0] = new_et; - list[1] = (etp)NULL; - n_allocated = 10; - n_used = 1; - return; - } - for (i = 0; i < n_used; i++) - if (list[i]->base == base) - return; /* avoid duplicates */ - if (n_used+2 > n_allocated) { - n_allocated += 10; /* don't re-allocate too often */ - list = (etpp) realloc((char *)list, - (unsigned)n_allocated * sizeof(etp)); - _et_list = list; - if (list == (etpp)NULL) - return; /* oops */ - } - list[n_used++] = new_et; - list[n_used] = (etp)NULL; -} diff --git a/usr.bin/compile_et/perror.c b/usr.bin/compile_et/perror.c deleted file mode 100644 index ef50e07..0000000 --- a/usr.bin/compile_et/perror.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 1987 by MIT Student Information Processing Board - * For copyright info, see Copyright.SIPB - * - * $Id: perror.c,v 1.2 1994/07/19 19:21:30 g89r4222 Exp $ - */ - -#include -#include -#include -#include "error_table.h" - -typedef int (*int_func)(); - -#if defined(mips) && defined(ultrix) -int errno; /* this is needed to keep the loader from complaining */ -#endif - -int_func com_err_hook = (int_func) NULL; -char *error_message(); - -void -com_err(whoami, code, message) - char *whoami; - int code; - char *message; -{ - struct iovec strings[6]; - - if (com_err_hook) { - (*com_err_hook)(whoami, code, message); - return; - } - - strings[0].iov_base = whoami; - strings[0].iov_len = strlen(whoami); - if (whoami) { - strings[1].iov_base = ": "; - strings[1].iov_len = 2; - } else - strings[1].iov_len = 0; - if (code) { - register char *errmsg = error_message(code); - strings[2].iov_base = errmsg; - strings[2].iov_len = strlen(errmsg); - } else - strings[2].iov_len = 0; - strings[3].iov_base = " "; - strings[3].iov_len = 1; - strings[4].iov_base = message; - strings[4].iov_len = strlen(message); - strings[5].iov_base = "\n"; - strings[5].iov_len = 1; - (void) writev(2, strings, 6); -} - -int_func -set_com_err_hook(new_proc) - int_func new_proc; -{ - register int_func x = com_err_hook; - com_err_hook = new_proc; - return (x); -} - -reset_com_err_hook() -{ - com_err_hook = (int_func) NULL; -} - -void -perror(msg) - register const char *msg; -{ - com_err(msg, errno, (char *)NULL); -} diff --git a/usr.bin/compile_et/test/test.c b/usr.bin/compile_et/test/test.c deleted file mode 100644 index df430da..0000000 --- a/usr.bin/compile_et/test/test.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include "test1.h" -#include "test2.h" -char *error_message(); -extern int sys_nerr, errno; - -main() -{ - printf("\nBefore initiating error table:\n\n"); - printf("Table name '%s'\n", error_table_name(KRB_MK_AP_TGTEXP)); - printf("UNIX name '%s'\n", error_table_name(EPERM)); - printf("Msg TGT-expired is '%s'\n", error_message(KRB_MK_AP_TGTEXP)); - printf("Msg EPERM is '%s'\n", error_message(EPERM)); - printf("Msg FOO_ERR is '%s'\n", error_message(FOO_ERR)); - printf("Msg {sys_nerr-1} is '%s'\n", error_message(sys_nerr-1)); - printf("Msg {sys_nerr} is '%s'\n", error_message(sys_nerr)); - - init_error_table(0, 0, 0); - printf("With 0: tgt-expired -> %s\n", error_message(KRB_MK_AP_TGTEXP)); - - init_krb_err_tbl(); - printf("KRB error table initialized: base %d (%s), name %s\n", - krb_err_base, error_message(krb_err_base), - error_table_name(krb_err_base)); - printf("With krb: tgt-expired -> %s\n", - error_message(KRB_MK_AP_TGTEXP)); - - init_quux_err_tbl(); - printf("QUUX error table initialized: base %d (%s), name %s\n", - quux_err_base, error_message(quux_err_base), - error_table_name(quux_err_base)); - - printf("Msg for TGT-expired is '%s'\n", - error_message(KRB_MK_AP_TGTEXP)); - printf("Msg {sys_nerr-1} is '%s'\n", error_message(sys_nerr-1)); - printf("Msg FOO_ERR is '%s'\n", error_message(FOO_ERR)); - printf("Msg KRB_SKDC_CANT is '%s'\n", - error_message(KRB_SKDC_CANT)); - printf("Msg 1e6 is '%s'\n", error_message(1000000)); - errno = FOO_ERR; - perror("FOO_ERR"); -} diff --git a/usr.bin/compile_et/test/test1.et b/usr.bin/compile_et/test/test1.et deleted file mode 100644 index 4c7b77f..0000000 --- a/usr.bin/compile_et/test/test1.et +++ /dev/null @@ -1,69 +0,0 @@ - error_table krb - - error_code KRB_MK_AP_TKFIL, - "Can't read ticket file" - - ec KRB_MK_AP_NOTKT, - "Can't find ticket or TGT" - - ec KRB_MK_AP_TGTEXP, - "TGT expired" - - ec KRB_RD_AP_UNDEC, - "Can't decode authenticator" - - ec KRB_RD_AP_EXP, - "Ticket expired" - - ec KRB_RD_AP_REPEAT, - "Repeated request" - - ec KRB_RD_AP_NOT_US, - "The ticket isn't for us" - - ec KRB_RD_AP_INCON, - "Request is inconsistent" - - ec KRB_RD_AP_TIME, - "Delta-T too big" - - ec KRB_RD_AP_BADD, - "Incorrect net address" - - ec KRB_RD_AP_VERSION, - "Protocol version mismatch" - - ec KRB_RD_AP_MSG_TYPE, - "Invalid message type" - - ec KRB_RD_AP_MODIFIED, - "Message stream modified" - - ec KRB_RD_AP_ORDER, - "Message out of order" - - ec KRB_RD_AP_UNAUTHOR, - "Unauthorized request" - - ec KRB_GT_PW_NULL, - "Current password is null" - - ec KRB_GT_PW_BADPW, - "Incorrect current password" - - ec KRB_GT_PW_PROT, - "Protocol error" - - ec KRB_GT_PW_KDCERR, - "Error returned by KDC" - - ec KRB_GT_PW_NULLTKT, - "Null ticket returned by KDC" - - ec KRB_SKDC_RETRY, - "Retry count exceeded" - - ec KRB_SKDC_CANT, - "Can't send request" - - end diff --git a/usr.bin/compile_et/test/test2.et b/usr.bin/compile_et/test/test2.et deleted file mode 100644 index 55ad74e..0000000 --- a/usr.bin/compile_et/test/test2.et +++ /dev/null @@ -1,9 +0,0 @@ - error_table quux - - ec FOO_ERR, "foo" - - ec BAR_ERR, "bar" - - ec BAZ_ERR, "meow" - - end diff --git a/usr.bin/compress/zcat.sh b/usr.bin/compress/zcat.sh deleted file mode 100644 index c4931e4..0000000 --- a/usr.bin/compress/zcat.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 1992, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# @(#)zcat.sh 8.1 (Berkeley) 6/6/93 -# - -uncompress -c $* diff --git a/usr.bin/diff/diff/diff.1 b/usr.bin/diff/diff/diff.1 deleted file mode 100644 index 1b5c078..0000000 --- a/usr.bin/diff/diff/diff.1 +++ /dev/null @@ -1,387 +0,0 @@ -.\" Copyright (c) 1980, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)diff.1 8.1 (Berkeley) 6/30/93 -.\" -.Dd June 30, 1993 -.Dt DIFF 1 -.Os BSD 4 -.Sh NAME -.Nm diff -.Nd differential file and directory comparator -.Sh SYNOPSIS -.Nm diff -.Op Fl cefhn -.Op Fl biwt -.Ar file1 file2 -.Nm diff -.Op Fl D Ns Ar string -.Op Fl biw -.Ar file1 file2 -.Nm diff -.Op Fl l -.Op Fl r -.Op Fl s -.Op Fl cefhn -.Op Fl biwt -.Op Fl S Ns Ar name -.Ar dir1 dir2 -.Sh DESCRIPTION -The -.Nm diff -utility compares the contents of -.Ar file1 -and -.Ar file2 -and writes to the standard output the list of changes necessary to -convert one file into the other. -No output is produced if the files are identical. -.Pp -Output options (mutually exclusive): -.Bl -tag -width Ds -.It Fl c -produces a diff with lines of context. -The default is to present 3 lines of context and may be changed, e.g., to 10, by -.Fl c10 . -With -.Fl c -the output format is modified slightly: -the output beginning with identification of the files involved and -their creation dates and then each change is separated -by a line with a dozen *'s. -The lines removed from -.Ar file1 -are marked with `\(mi '; those added to -.Ar file2 -are marked `+ '. Lines which are changed from one -file to the other are marked in both files with `! '. -Changes which lie within lines of each other are grouped -together on output. (This is a change from the previous ``diff -c'' -but the resulting output is usually much easier to interpret.) -.It Fl e -produces output in a form suitable as input for the editor utility, -.Xr ed 1 , -which can then be used to convert file1 into file2. -.Pp -Extra commands are added to the output when comparing directories with -.Fl e , -so that the result is a -.Xr sh 1 -script for converting text files which are common to the two directories -from their state in -.Ar dir1 -to their state in -.Ar dir2 . -.It Fl f -identical output to that of the -.Fl e -flag, but in reverse order. It cannot -be digested by -.Xr ed 1 . -.It Fl h -Invokes an alternate algorithm which can handle files of very long lengths. -There is a trade off. The algorithm can only deal with changes which are -clearly delimited and brief. Long sections of changes and overlaps will -confuse it. -.It Fl n -produces a script similar to that of -.Fl e , -but in the opposite order and with a count of changed lines on each -insert or delete command. This is the form used by -.Xr rcsdiff 1 . -.It Fl D Ns Ar string -creates a merged version of -.Ar file1 -and -.Ar file2 -on the standard output, with C preprocessor controls included so that -a compilation of the result without defining -.Ar string -is equivalent -to compiling -.Ar file1 , -while defining -.Ar string -will yield -.Ar file2 . -.El -.Pp -Comparison options: -.Bl -tag -width Ds -.It Fl b -causes trailing blanks (spaces and tabs) to be ignored, and other -strings of blanks to compare equal. -.It Fl i -ignores the case of letters. E.g., ``A'' will compare equal to ``a''. -.It Fl t -will expand tabs in output lines. Normal or -.Fl c -output adds character(s) to the front of each line which may screw up -the indentation of the original source lines and make the output listing -difficult to interpret. This option will preserve the original source's -indentation. -.It Fl w -is similar to -.Fl b -but causes whitespace (blanks and tabs) to be totally ignored. E.g., -``if\ (\ a\ ==\ b\ )'' will compare equal to ``if(a==b)''. -.El -.Pp -Directory comparison options: -.Bl -tag -width Ds -.It Fl l -long output format; each text file -.Nm diff Ns \'d -is piped through -.Xr pr 1 -to paginate it, -other differences are remembered and summarized -after all text file differences are reported. -.It Fl r -causes application of -.Nm diff -recursively to common subdirectories encountered. -.It Fl s -causes -.Nm diff -to report files which are the same, which are otherwise not mentioned. -.It Fl S Ns Ar name -re-starts a directory -.Nm diff -in the middle beginning with file -.Ar name . -.El -.Pp -If both arguments are directories, -.Nm diff -sorts the contents of the directories by name, and then runs the -regular file -.Nm diff -algorithm, producing a change list, -on text files which are different. -Binary files which differ, -common subdirectories, and files which appear in only one directory -are described as such. -.Pp -If only one of -.Ar file1 -and -.Ar file2 -is a directory, -.Nm diff -is applied to the non-directory file and the file contained in -the directory file with a filename that is the same as the -last component of the non-directory file. -.Pp -If either -.Ar file1 -or -.Ar file2 -is -.Sq Fl , -the standard input is -used in its place. -.Ss Output Style -The default (without -.Fl e , -.Fl c , -or -.Fl n -.\" -C -options) -output contains lines of these forms, where -.Va XX , YY , ZZ , QQ -are line numbers respective of file order. -.Pp -.Bl -tag -width "XX,YYcZZ,QQ" -compact -.It Li XX Ns Ic a Ns Li YY -At (the end of) line -.Va XX -of -.Ar file1 , -append the contents -of line -.Va YY -of -.Ar file2 -to make them equal. -.It Li XX Ns Ic a Ns Li YY,ZZ -Same as above, but append the range of lines, -.Va YY -through -.Va ZZ -of -.Ar file2 -to line -.Va XX -of file1. -.It Li XX Ns Ic d Ns Li YY -At line -.Va XX -delete -the line. The value -.Va YY -tells to which line the change -would bring -.Ar file1 -in line with -.Ar file1 . -.It Li XX,YY Ns Ic d Ns Li ZZ -Delete the range of lines -.Va XX -through -.Va YY -in -.Ar file1 . -.It Li XX Ns Ic c Ns Li YY -Change the line -.Va XX -in -.Ar file1 -to the line -.Va YY -in -.Ar file2. -.It Li XX,YY Ns Ic c Ns Li ZZ -Replace the range of specified lines with the line -.Va ZZ . -.It Li XX,YY Ns Ic c Ns Li ZZ,QQ -Replace the range -.Va XX , Ns YY -from -.Ar file1 -with the range -.Va ZZ , Ns QQ -from -.Ar file2 . -.El -.Pp -These lines resemble -.Xr ed 1 -subcommands to convert -.Ar file1 -into -.Ar file2 . -The line numbers before the action letters pertain to -.Ar file1 ; -those after pertain to -.Ar file2 . -Thus, by exchanging -.Ic a -for -.Ic d -and reading the line in reverse order, one can also -determine how to convert -.Ar file2 -into -.Ar file1 . -As in -.Xr ed 1 , -identical -pairs (where num1 = num2) are abbreviated as a single -number. -.Sh ENVIRONMENT -.Bl -tag -width TMPDIR -.It Ev TMPDIR -If the environment variable -.Ev TMPDIR -exists, -.Nm diff -will use the directory specified by -.Ev TMPDIR -as the temporary directory. -.El -.Sh FILES -.Bl -tag -width /usr/bin/diffh -compact -.It Pa /tmp/d????? -.It Pa /usr/bin/diffh -Alternate algorithm version (used by option -.Fl h ) . -.It Pa /usr/bin/diff -for directory diffs -.It Pa /usr/bin/pr -used by the -.Fl l -option. -.El -.Sh SEE ALSO -.Xr cmp 1 , -.Xr cc 1 , -.Xr comm 1 , -.Xr ed 1 , -.Xr diff3 1 -.br -.ne 1i -.Sh DIAGNOSTICS -The -.Nm diff -utility exits with one of the following values: -.Pp -.Bl -tag -width Ds -compact -offset indent -.It \&0 -No differences were found. -.It \&1 -Differences were found. -.It "\&>\&1" -An error occurred. -.El -.Sh BUGS -The -.Fl f -and -.Fl e -options -do not provide special handling for lines on which the -first and only character is -.Dq Li \&. . -This can cause problems for -.Xr ed 1 . -.Pp -When comparing directories with the -.Fl b , -.Fl w -or -.Fl i -options specified, -.Nm diff -first compares the files ala -.Ar cmp , -and then decides to run the -.Nm diff -algorithm if they are not equal. -This may cause a small amount of spurious output if the files -then turn out to be identical because the only differences are -insignificant white space or case differences. -.Sh HISTORY -A -.Nm -command appeared in -.At v6 . diff --git a/usr.bin/diff/diff3/diff3.1 b/usr.bin/diff/diff3/diff3.1 deleted file mode 100644 index 09b1d72..0000000 --- a/usr.bin/diff/diff3/diff3.1 +++ /dev/null @@ -1,172 +0,0 @@ -.\" Copyright (c) 1990, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)diff3.1 8.2 (Berkeley) 4/18/94 -.\" -.Dd April 18, 1994 -.Dt DIFF3 1 -.Os BSD 4.3R -.Sh NAME -.Nm diff3 -.Nd 3-way differential file comparison -.Sh SYNOPSIS -.Nm diff3 -.Op Fl exEX3 -.Ar file1 file2 file3 -.Sh DESCRIPTION -The -.Nm diff3 -utility compares the contents of three different versions of a file, -.Ar file1 , -.Ar file2 -and -.Ar file3 , -writing the result to the standard output. -The options describe different methods of merging and -purging -the separate versions into a new file. -.Nm Diff3 -is used by -.Xr RCS 1 -to merge specific versions or create -new versions. -.Pp -Options are: -.Bl -tag -width "--E, --X" -.It Fl e -Produces output in a form suitable as an input script for the -.Xr ed 1 -utility. The script may then be used to merge differences common -between all three files and differences specific to file1 and file3. -In other words, the -.Fl e -option ignores differences specific to file1 and file2, and those -specific to file2 and file3. It is useful for backing out changes -specific to file2 only. -.It Fl x -Produces an output script suitable for -.Xr ed 1 -with changes -specific only to all three versions. -.It Fl 3 -Produces an output script suitable for -.Xr ed 1 -with changes -specific only to file3. -.It Fl E , X -Similar to -.Fl e -and -.Fl x , -respectively, but treat overlapping changes (i.e., changes that would -be noted with ==== in the normal listing) differently. The overlapping -lines from both files will be inserted by the edit script, bracketed -by "<<<<<<" and ">>>>>>" lines. -.El -.Pp -The -.Fl E -option is used by -.Tn RCS -.Xr merge 1 -to insure that overlapping changes in the merged files are preserved -and brought to someone's attention. -.Pp -For example, suppose lines 7-8 are changed in both file1 and file2. -Applying the edit script generated by the command -.Pp -.Dl diff3 -E file1 file2 file3 -.Pp -to file1 results in the file: -.Pp -.Bd -literal -offset indent -compact -lines 1-6 -of file1 -<<<<<<< file1 -lines 7-8 -of file1 -======= -lines 7-8 -of file3 ->>>>>>> file3 -rest of file1 -.Ed -.Pp -The default output of -.Nm diff3 -makes notation of the differences between all files, and those differences -specific to each pair of files. The -changes are described by -the commands necessary for -.Xr ed 1 -to create the desired target from the different versions. -See -.Xr diff 1 -for a description of the commands. -.Bl -tag -width "=====" -.It Li \&==== -The lines beneath this notation are ranges of lines which are different -between all files. -.It \&==== Ns Va n -The lines beneath this notation are ranges of lines which are exclusively -different in file -.Va n . -.El -.Sh FILES -.Bl -tag -width /usr/bin/diff3 -compact -.It Pa /tmp/d3????? -temporary files. -.It Pa /usr/bin/diff3 -the executable. -.El -.Sh SEE ALSO -.Xr diff 1 -.Xr ed 1 -.Xr rcs 1 -.Sh BUGS -The -.Fl e -option -cannot catch and change -lines which have -.Ql \&. -as the first and only character on the line. -The resulting script will fail on that line -as -.Ql \&. -is an -.Xr ed 1 -editing command. -.Sh HISTORY -A -.Nm -command appeared in -.At v7 . diff --git a/usr.bin/ee/ee.msg b/usr.bin/ee/ee.msg deleted file mode 100644 index 2117d06..0000000 --- a/usr.bin/ee/ee.msg +++ /dev/null @@ -1,170 +0,0 @@ -$ This file contains the messages for ee ("easy editor"). See the file -$ ee.i18n.guide for more information -$ -$ For ee patchlevel 3 -$ -$ $Header: /users/hugh/tmp/old_ae/ee.msg,v 1.3 1993/06/22 04:13:35 hugh Exp $ -$ -$set 1 -$quote " -1 "modes menu" -2 "tabs to spaces " -3 "case sensitive search" -4 "margins observed " -5 "auto-paragraph format" -6 "eightbit characters " -7 "info window " -8 "right margin " -9 "leave menu" -10 "save changes" -11 "no save" -12 "file menu" -13 "read a file" -14 "write a file" -15 "save file" -16 "print editor contents" -17 "search menu" -18 "search for ..." -19 "search" -20 "spell menu" -21 "use 'spell'" -22 "use 'ispell'" -23 "miscellaneous menu" -24 "format paragraph" -25 "shell command" -26 "check spelling" -27 "main menu" -28 "leave editor" -29 "help" -30 "file operations" -31 "redraw screen" -32 "settings" -33 "search" -34 "miscellaneous" -35 "Control keys: " -36 "^a ascii code ^i tab ^r right " -37 "^b bottom of text ^j newline ^t top of text " -38 "^c command ^k delete char ^u up " -39 "^d down ^l left ^v undelete word " -40 "^e search prompt ^m newline ^w delete word " -41 "^f undelete char ^n next page ^x search " -42 "^g begin of line ^o end of line ^y delete line " -43 "^h backspace ^p prev page ^z undelete line " -44 "^[ (escape) menu " -45 " " -46 "Commands: " -47 "help : get this info file : print file name " -48 "read : read a file char : ascii code of char " -49 "write : write a file case : case sensitive search " -50 "exit : leave and save nocase : case insensitive search " -51 "quit : leave, no save !cmd : execute \"cmd\" in shell " -52 "line : display line # 0-9 : go to line \"#\" " -53 "expand : expand tabs noexpand: do not expand tabs " -54 " " -55 " ee [-i] [-e] [-h] [file(s)] " -56 " -i : no information window -e : do not expand tabs -h : no highlight " -57 "^[ (escape) menu ^e search prompt ^y delete line ^u up ^p prev page " -58 "^a ascii code ^x search ^z undelete line ^d down ^n next page " -59 "^b bottom of text ^g begin of line ^w delete word ^l left " -60 "^t top of text ^o end of line ^v undelete word ^r right " -61 "^c command ^k delete char ^f undelete char " -62 "help : get help info |file : print file name |line : print line # " -63 "read : read a file |char : ascii code of char |0-9 : go to line \"#\"" -64 "write: write a file |case : case sensitive search |exit : leave and save " -65 "!cmd : shell \"cmd\" |nocase: ignore case in search |quit : leave, no save" -66 "expand: expand tabs |noexpand: do not expand tabs " -67 " press Escape (^[) for menu" -68 "no file" -69 "ascii code: " -70 "sending contents of buffer to \"%s\" " -71 "command: " -72 "name of file to write: " -73 "name of file to read: " -74 "character = %d" -75 "unknown command \"%s\"" -76 "entered command is not unique" -77 "line %d " -78 "length = %d" -79 "current file is \"%s\" " -80 "usage: %s [-i] [-e] [-h] [+line_number] [file(s)]\n" -81 " -i turn off info window\n" -82 " -e do not convert tabs to spaces\n" -83 " -h do not use highlighting\n" -84 "file \"%s\" is a directory" -85 "new file \"%s\"" -86 "can't open \"%s\"" -87 "file \"%s\", %d lines" -88 "finished reading file \"%s\"" -89 "reading file \"%s\"" -90 ", read only" -91 "file \"%s\", %d lines" -92 "enter name of file: " -93 "no filename entered: file not saved" -94 "changes have been made, are you sure? (y/n [n]) " -95 "y" -96 "file already exists, overwrite? (y/n) [n] " -97 "unable to create file \"%s\"" -98 "writing file \"%s\"" -99 "\"%s\" %d lines, %d characters" -100 " ...searching" -101 "string \"%s\" not found" -102 "search for: " -103 "could not exec %s\n" -104 "press return to continue " -105 "press Esc to cancel" -106 "menu too large for window" -107 "press any key to continue " -108 "shell command: " -109 "...formatting paragraph..." -110 "datap) - curdtp = (chainp)d0->datap; - datastack = d0->nextp; - d0->nextp = 0; - frchain(&d0); - } - - -/* # line 178 "gram.in" */ -typedef union { - int ival; - ftnint lval; - char *charpval; - chainp chval; - tagptr tagval; - expptr expval; - struct Labelblock *labval; - struct Nameblock *namval; - struct Eqvchain *eqvval; - Extsym *extval; - } YYSTYPE; -#define yyclearin yychar = -1 -#define yyerrok yyerrflag = 0 -extern int yychar; -typedef int yytabelem; -extern yytabelem yyerrflag; -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 150 -#endif -YYSTYPE yylval, yyval; -# define YYERRCODE 256 -yytabelem yyexca[] ={ --1, 1, - 0, -1, - -2, 0, --1, 20, - 1, 38, - -2, 228, --1, 24, - 1, 42, - -2, 228, --1, 122, - 6, 240, - -2, 228, --1, 150, - 1, 244, - -2, 188, --1, 174, - 1, 265, - 78, 265, - -2, 188, --1, 223, - 77, 173, - -2, 139, --1, 245, - 74, 228, - -2, 225, --1, 271, - 1, 286, - -2, 143, --1, 275, - 1, 295, - 78, 295, - -2, 145, --1, 328, - 77, 174, - -2, 141, --1, 358, - 1, 267, - 14, 267, - 74, 267, - 78, 267, - -2, 189, --1, 436, - 91, 0, - 92, 0, - 93, 0, - 94, 0, - 95, 0, - 96, 0, - -2, 153, --1, 453, - 1, 289, - 78, 289, - -2, 143, --1, 455, - 1, 291, - 78, 291, - -2, 143, --1, 457, - 1, 293, - 78, 293, - -2, 143, --1, 459, - 1, 296, - 78, 296, - -2, 144, --1, 504, - 78, 289, - -2, 143, - }; -# define YYNPROD 301 -# define YYLAST 1346 -yytabelem yyact[]={ - - 237, 274, 471, 317, 316, 412, 420, 297, 470, 399, - 413, 397, 386, 357, 398, 266, 128, 356, 273, 252, - 292, 5, 116, 295, 326, 303, 222, 99, 184, 121, - 195, 229, 17, 203, 270, 304, 313, 199, 201, 118, - 94, 202, 396, 104, 210, 183, 236, 101, 106, 234, - 264, 103, 111, 336, 260, 95, 96, 97, 165, 166, - 334, 335, 336, 395, 105, 311, 309, 190, 130, 131, - 132, 133, 120, 135, 119, 114, 157, 129, 157, 475, - 103, 272, 334, 335, 336, 396, 521, 103, 278, 483, - 535, 165, 166, 334, 335, 336, 342, 341, 340, 339, - 338, 137, 343, 345, 344, 347, 346, 348, 450, 258, - 259, 260, 539, 165, 166, 258, 259, 260, 261, 525, - 102, 522, 155, 409, 155, 186, 187, 103, 408, 117, - 165, 166, 258, 259, 260, 318, 100, 527, 484, 188, - 446, 185, 480, 230, 240, 240, 194, 193, 290, 120, - 211, 119, 462, 481, 157, 294, 482, 257, 157, 243, - 468, 214, 463, 469, 461, 464, 460, 239, 241, 220, - 215, 218, 157, 219, 213, 165, 166, 334, 335, 336, - 342, 341, 340, 157, 371, 452, 343, 345, 344, 347, - 346, 348, 443, 428, 377, 294, 102, 102, 102, 102, - 155, 189, 447, 149, 155, 446, 192, 103, 98, 196, - 197, 198, 277, 376, 320, 321, 206, 288, 155, 289, - 300, 375, 299, 324, 315, 328, 275, 275, 330, 155, - 310, 333, 196, 216, 217, 350, 269, 207, 308, 352, - 353, 333, 100, 177, 354, 349, 323, 112, 245, 257, - 247, 110, 157, 417, 286, 287, 418, 362, 157, 157, - 157, 157, 157, 257, 257, 109, 108, 268, 279, 280, - 281, 265, 107, 355, 4, 333, 427, 465, 378, 370, - 170, 172, 176, 257, 165, 166, 258, 259, 260, 261, - 102, 406, 232, 293, 407, 381, 422, 390, 155, 400, - 391, 223, 419, 422, 155, 155, 155, 155, 155, 117, - 221, 314, 392, 319, 387, 359, 372, 196, 360, 373, - 374, 333, 333, 536, 350, 333, 275, 250, 424, 333, - 405, 333, 410, 532, 230, 432, 433, 434, 435, 436, - 437, 438, 439, 440, 441, 403, 331, 156, 401, 332, - 531, 333, 530, 333, 333, 333, 388, 526, 380, 529, - 524, 157, 257, 333, 431, 492, 257, 257, 257, 257, - 257, 382, 383, 235, 426, 384, 358, 494, 296, 333, - 448, 165, 166, 258, 259, 260, 261, 451, 165, 166, - 258, 259, 260, 261, 103, 445, 472, 400, 421, 191, - 402, 196, 103, 150, 307, 174, 285, 155, 474, 246, - 476, 416, 467, 466, 242, 226, 223, 200, 212, 136, - 209, 486, 171, 488, 490, 275, 275, 275, 141, 240, - 496, 429, 329, 333, 333, 333, 333, 333, 333, 333, - 333, 333, 333, 403, 497, 479, 401, 403, 487, 154, - 257, 154, 495, 493, 306, 485, 502, 454, 456, 458, - 500, 491, 268, 499, 505, 506, 507, 103, 451, 271, - 271, 472, 30, 333, 414, 501, 400, 508, 511, 509, - 387, 244, 208, 510, 516, 514, 515, 333, 517, 333, - 513, 333, 520, 293, 518, 225, 240, 333, 402, 523, - 92, 248, 402, 528, 6, 262, 123, 249, 81, 80, - 275, 275, 275, 79, 534, 533, 479, 78, 173, 263, - 314, 77, 403, 76, 537, 401, 351, 154, 75, 333, - 282, 154, 60, 49, 48, 333, 45, 33, 333, 538, - 113, 205, 454, 456, 458, 154, 267, 165, 166, 334, - 335, 336, 342, 540, 503, 411, 154, 204, 394, 393, - 298, 478, 503, 503, 503, 134, 389, 312, 115, 379, - 26, 25, 24, 23, 302, 22, 305, 402, 21, 385, - 284, 9, 503, 8, 7, 2, 519, 301, 20, 319, - 164, 51, 489, 291, 228, 327, 325, 415, 91, 361, - 255, 53, 337, 19, 55, 365, 366, 367, 368, 369, - 37, 224, 3, 1, 0, 351, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 154, 0, 0, 0, 0, - 0, 154, 154, 154, 154, 154, 0, 0, 0, 267, - 0, 512, 267, 267, 165, 166, 334, 335, 336, 342, - 341, 340, 339, 338, 0, 343, 345, 344, 347, 346, - 348, 165, 166, 334, 335, 336, 342, 341, 453, 455, - 457, 0, 343, 345, 344, 347, 346, 348, 0, 0, - 305, 0, 459, 0, 0, 0, 0, 165, 166, 334, - 335, 336, 342, 341, 340, 339, 338, 351, 343, 345, - 344, 347, 346, 348, 444, 0, 0, 0, 449, 165, - 166, 334, 335, 336, 342, 341, 340, 339, 338, 0, - 343, 345, 344, 347, 346, 348, 165, 166, 334, 335, - 336, 342, 0, 0, 154, 0, 498, 343, 345, 344, - 347, 346, 348, 0, 0, 267, 0, 0, 0, 0, - 0, 442, 0, 504, 455, 457, 165, 166, 334, 335, - 336, 342, 341, 340, 339, 338, 0, 343, 345, 344, - 347, 346, 348, 0, 0, 0, 0, 0, 0, 430, - 0, 477, 0, 305, 165, 166, 334, 335, 336, 342, - 341, 340, 339, 338, 0, 343, 345, 344, 347, 346, - 348, 423, 0, 0, 0, 0, 165, 166, 334, 335, - 336, 342, 341, 340, 339, 338, 0, 343, 345, 344, - 347, 346, 348, 0, 0, 0, 267, 0, 0, 0, - 0, 165, 166, 334, 335, 336, 342, 341, 340, 339, - 338, 12, 343, 345, 344, 347, 346, 348, 0, 0, - 0, 0, 0, 0, 305, 10, 56, 46, 73, 85, - 14, 61, 70, 90, 38, 66, 47, 42, 68, 72, - 31, 67, 35, 34, 11, 87, 36, 18, 41, 39, - 28, 16, 57, 58, 59, 50, 54, 43, 88, 64, - 40, 69, 44, 89, 29, 62, 84, 13, 0, 82, - 65, 52, 86, 27, 74, 63, 15, 0, 0, 71, - 83, 160, 161, 162, 163, 169, 168, 167, 158, 159, - 103, 0, 160, 161, 162, 163, 169, 168, 167, 158, - 159, 103, 0, 0, 32, 160, 161, 162, 163, 169, - 168, 167, 158, 159, 103, 0, 160, 161, 162, 163, - 169, 168, 167, 158, 159, 103, 0, 160, 161, 162, - 163, 169, 168, 167, 158, 159, 103, 0, 160, 161, - 162, 163, 169, 168, 167, 158, 159, 103, 0, 0, - 233, 0, 0, 0, 0, 0, 165, 166, 363, 0, - 364, 233, 227, 0, 0, 0, 238, 165, 166, 231, - 0, 0, 0, 0, 233, 0, 0, 238, 0, 0, - 165, 166, 473, 0, 0, 233, 0, 0, 0, 0, - 238, 165, 166, 231, 0, 0, 233, 0, 0, 0, - 0, 238, 165, 166, 425, 0, 0, 233, 0, 0, - 0, 0, 238, 165, 166, 0, 0, 0, 0, 0, - 0, 0, 0, 238, 160, 161, 162, 163, 169, 168, - 167, 158, 159, 103, 0, 160, 161, 162, 163, 169, - 168, 167, 158, 159, 103, 160, 161, 162, 163, 169, - 168, 167, 158, 159, 103, 0, 0, 0, 160, 161, - 162, 163, 169, 168, 167, 158, 159, 103, 256, 0, - 93, 160, 161, 162, 163, 169, 168, 167, 158, 159, - 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 276, 0, 0, 0, 0, 0, 165, - 166, 0, 122, 0, 322, 125, 126, 127, 0, 238, - 165, 166, 0, 0, 0, 0, 0, 138, 139, 0, - 238, 140, 0, 142, 143, 144, 0, 251, 145, 146, - 147, 0, 148, 165, 166, 253, 0, 254, 0, 0, - 153, 0, 0, 0, 0, 0, 165, 166, 151, 0, - 152, 178, 179, 180, 181, 182, 160, 161, 162, 163, - 169, 168, 167, 158, 159, 103, 160, 161, 162, 163, - 169, 168, 167, 158, 159, 103, 160, 161, 162, 163, - 169, 168, 167, 158, 159, 103, 160, 161, 162, 163, - 169, 168, 167, 158, 159, 103, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 251, 0, 0, 0, 0, - 0, 165, 166, 283, 0, 153, 0, 0, 0, 0, - 0, 165, 166, 175, 0, 404, 0, 0, 0, 0, - 0, 165, 166, 56, 46, 251, 85, 0, 61, 0, - 90, 165, 166, 47, 73, 0, 0, 0, 70, 0, - 0, 66, 87, 0, 68, 72, 0, 67, 0, 57, - 58, 59, 50, 0, 0, 88, 0, 0, 0, 0, - 89, 0, 62, 84, 0, 64, 82, 69, 52, 86, - 0, 0, 63, 0, 124, 0, 65, 83, 0, 0, - 74, 0, 0, 0, 0, 71 }; -yytabelem yypact[]={ - --1000, 18, 503, 837,-1000,-1000,-1000,-1000,-1000,-1000, - 495,-1000,-1000,-1000,-1000,-1000,-1000, 164, 453, -35, - 194, 188, 187, 173, 58, 169, -8, 66,-1000,-1000, --1000,-1000,-1000,1264,-1000,-1000,-1000, -5,-1000,-1000, --1000,-1000,-1000,-1000,-1000, 453,-1000,-1000,-1000,-1000, --1000, 354,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000, --1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000, --1000,-1000,-1000,-1000,-1000,1096, 348,1191, 348, 165, --1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000, --1000,-1000,-1000,-1000, 453, 453, 453, 453,-1000, 453, --1000, 325,-1000,-1000, 453,-1000, -11, 453, 453, 453, - 343,-1000,-1000,-1000, 453, 159,-1000,-1000,-1000,-1000, - 468, 346, 58,-1000,-1000, 344,-1000,-1000,-1000,-1000, - 66, 453, 453, 343,-1000,-1000, 234, 342, 489,-1000, - 341, 917, 963, 963, 340, 475, 453, 335, 453,-1000, --1000,-1000,-1000,1083,-1000,-1000, 308,1211,-1000,-1000, --1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000, --1000,1083, 193, 158,-1000,-1000,1049,1049,-1000,-1000, --1000,-1000,1181, 332,-1000,-1000, 325, 325, 453,-1000, --1000, 73, 304,-1000, 58,-1000, 304,-1000,-1000,-1000, - 453,-1000, 380,-1000, 330,1273, -17, 66, -18, 453, - 475, 37, 963,1060,-1000, 453,-1000,-1000,-1000,-1000, --1000, 963,-1000, 963, 361,-1000, 963,-1000, 271,-1000, - 751, 475,-1000, 963,-1000,-1000,-1000, 963, 963,-1000, - 751,-1000, 963,-1000,-1000, 58, 475,-1000, 301, 240, --1000,1211,-1000,-1000,-1000, 906,-1000,1211,1211,1211, -1211,1211, -30, 204, 106, 388,-1000,-1000, 388, 388, --1000, 143, 135, 116, 751,-1000,1049,-1000,-1000,-1000, --1000,-1000, 308,-1000,-1000, 300,-1000,-1000, 325,-1000, --1000, 222,-1000,-1000,-1000, -5,-1000, -36,1201, 453, --1000, 216,-1000, 45,-1000,-1000, 380, 460,-1000, 453, --1000,-1000, 178,-1000, 226,-1000,-1000,-1000, 324, 220, - 726, 751, 952,-1000, 751, 299, 199, 115, 751, 453, - 704,-1000, 941, 963, 963, 963, 963, 963, 963, 963, - 963, 963, 963,-1000,-1000,-1000,-1000,-1000,-1000,-1000, - 676, 114, -31, 646, 629, 321, 127,-1000,-1000,-1000, -1083, 33, 751,-1000,-1000, 27, -30, -30, -30, 50, --1000, 388, 106, 107, 106,1049,1049,1049, 607, 88, - 86, 74,-1000,-1000,-1000, 87,-1000, 201,-1000, 304, --1000, 113,-1000, 85, 930,-1000,1201,-1000,-1000, -3, -1070,-1000,-1000,-1000, 963,-1000,-1000, 453,-1000, 380, - 64, 78,-1000, 8,-1000, 60,-1000,-1000, 453, 963, - 58, 963, 963, 391,-1000, 290, 303, 963, 963,-1000, - 475,-1000, 0, -31, -31, -31, 467, 95, 95, 581, - 646, -22,-1000, 963,-1000, 475, 475, 58,-1000, 308, --1000,-1000, 388,-1000,-1000,-1000,-1000,-1000,-1000,-1000, -1049,1049,1049,-1000, 466, 465, -5,-1000,-1000, 930, --1000,-1000, 564,-1000,-1000,1201,-1000,-1000,-1000,-1000, - 380,-1000, 460, 460, 453,-1000, 751, 37, 11, 43, - 751,-1000,-1000,-1000, 963, 285, 751, 41, 282, 62, --1000, 963, 284, 227, 282, 277, 275, 258,-1000,-1000, --1000,-1000, 930,-1000,-1000, 7, 248,-1000,-1000,-1000, --1000,-1000, 963,-1000,-1000, 475,-1000,-1000, 751,-1000, --1000,-1000,-1000,-1000, 751,-1000,-1000, 751, 34, 475, --1000 }; -yytabelem yypgo[]={ - - 0, 613, 612, 13, 611, 81, 15, 32, 610, 604, - 603, 10, 0, 602, 601, 600, 16, 598, 35, 25, - 597, 596, 595, 3, 4, 594, 67, 593, 592, 50, - 34, 18, 26, 101, 20, 591, 30, 373, 1, 292, - 24, 347, 327, 2, 9, 14, 31, 49, 46, 590, - 588, 39, 28, 45, 587, 585, 584, 583, 581,1100, - 40, 580, 579, 12, 578, 575, 573, 572, 571, 570, - 568, 29, 567, 27, 566, 23, 41, 7, 44, 6, - 37, 565, 38, 561, 560, 11, 22, 36, 559, 558, - 8, 17, 33, 557, 555, 541, 5, 540, 472, 537, - 536, 534, 533, 532, 528, 203, 523, 521, 518, 517, - 513, 509, 88, 508, 507, 19 }; -yytabelem yyr1[]={ - - 0, 1, 1, 55, 55, 55, 55, 55, 55, 55, - 2, 56, 56, 56, 56, 56, 56, 56, 60, 52, - 33, 53, 53, 61, 61, 62, 62, 63, 63, 26, - 26, 26, 27, 27, 34, 34, 17, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 10, - 10, 10, 74, 7, 8, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 16, 16, 16, 50, - 50, 50, 50, 51, 51, 64, 64, 65, 65, 66, - 66, 80, 54, 54, 67, 67, 81, 82, 76, 83, - 84, 77, 77, 85, 85, 45, 45, 45, 70, 70, - 86, 86, 72, 72, 87, 36, 18, 18, 19, 19, - 75, 75, 89, 88, 88, 90, 90, 43, 43, 91, - 91, 3, 68, 68, 92, 92, 95, 93, 94, 94, - 96, 96, 11, 69, 69, 97, 20, 20, 71, 21, - 21, 22, 22, 38, 38, 38, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 12, 12, 13, 13, 13, 13, 13, 13, 37, 37, - 37, 37, 32, 40, 40, 44, 44, 48, 48, 48, - 48, 48, 48, 48, 47, 49, 49, 49, 41, 41, - 42, 42, 42, 42, 42, 42, 42, 42, 58, 58, - 58, 58, 58, 58, 58, 58, 58, 99, 23, 24, - 24, 98, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 4, 100, 101, 101, 101, 101, 73, 73, - 35, 25, 25, 46, 46, 14, 14, 28, 28, 59, - 78, 79, 102, 103, 103, 103, 103, 103, 103, 103, - 103, 103, 103, 103, 103, 103, 103, 104, 111, 111, - 111, 106, 113, 113, 113, 108, 108, 105, 105, 114, - 114, 115, 115, 115, 115, 115, 115, 15, 107, 109, - 110, 110, 29, 29, 6, 6, 30, 30, 30, 31, - 31, 31, 31, 31, 31, 5, 5, 5, 5, 5, - 112 }; -yytabelem yyr2[]={ - - 0, 0, 3, 2, 2, 2, 3, 3, 2, 1, - 1, 3, 4, 3, 4, 4, 5, 3, 0, 1, - 1, 0, 1, 2, 3, 1, 3, 1, 3, 0, - 2, 3, 1, 3, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 1, 5, 7, - 5, 5, 0, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 4, 6, 3, - 4, 5, 3, 1, 3, 3, 3, 3, 3, 3, - 3, 3, 1, 3, 3, 3, 0, 6, 0, 0, - 0, 2, 3, 1, 3, 1, 2, 1, 1, 3, - 1, 1, 1, 3, 3, 2, 1, 5, 1, 3, - 0, 3, 0, 2, 3, 1, 3, 1, 1, 1, - 3, 1, 3, 3, 4, 1, 0, 2, 1, 3, - 1, 3, 1, 1, 2, 4, 1, 3, 0, 0, - 1, 1, 3, 1, 3, 1, 1, 1, 3, 3, - 3, 3, 2, 3, 3, 3, 3, 3, 2, 3, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 4, 5, 5, 0, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 5, 1, 1, 1, 1, 3, - 1, 1, 3, 3, 3, 3, 2, 3, 1, 7, - 4, 1, 2, 2, 6, 2, 2, 5, 3, 1, - 4, 4, 5, 2, 1, 1, 10, 1, 3, 4, - 3, 3, 1, 1, 3, 3, 7, 7, 0, 1, - 3, 1, 3, 1, 2, 1, 1, 1, 3, 0, - 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, - 3, 4, 4, 2, 3, 1, 3, 3, 1, 1, - 1, 3, 1, 1, 1, 1, 1, 3, 3, 1, - 3, 1, 1, 1, 2, 2, 2, 1, 3, 3, - 4, 4, 1, 3, 1, 5, 1, 1, 1, 3, - 3, 3, 3, 3, 3, 1, 3, 5, 5, 5, - 0 }; -yytabelem yychk[]={ - --1000, -1, -55, -2, 256, 3, 1, -56, -57, -58, - 18, 37, 4, 60, 23, 69, 44, -7, 40, -10, - -50, -64, -65, -66, -67, -68, -69, 66, 43, 57, - -98, 33, 97, -99, 36, 35, 39, -8, 27, 42, - 53, 41, 30, 50, 55,-100, 20, 29,-101,-102, - 48, -35, 64, -14, 49, -9, 19, 45, 46, 47, --103, 24, 58, 68, 52, 63, 28, 34, 31, 54, - 25, 72, 32, 21, 67,-104,-106,-107,-109,-110, --111,-113, 62, 73, 59, 22, 65, 38, 51, 56, - 26, -17, 5, -59, -60, -60, -60, -60, 44, -73, - 78, -52, -33, 14, 78, 99, -73, 78, 78, 78, - 78, -73, 78, -97, 83, -70, -86, -33, -51, 85, - 83, -71, -59, -98, 70, -59, -59, -59, -16, 82, - -71, -71, -71, -71, -81, -71, -37, -33, -59, -59, - -59, 74, -59, -59, -59, -59, -59, -59, -59,-105, - -42, 82, 84, 74, -37, -48, -41, -12, 12, 13, - 5, 6, 7, 8, -49, 80, 81, 11, 10, 9, --105, 74,-105,-108, -42, 82,-105, 78, -59, -59, - -59, -59, -59, -53, -52, -53, -52, -52, -60, -33, - -26, 74, -33, -76, -51, -36, -33, -33, -33, -80, - 74, -82, -76, -92, -93, -95, -33, 78, 14, 74, - -78, -73, 74, -78, -36, -51, -33, -33, -80, -82, - -92, 76, -32, 74, -4, 6, 74, 75, -25, -46, - -38, 82, -39, 74, -47, -37, -48, -12, 90, -40, - -38, -40, 74, -3, 6, -33, 74, -33, -41,-114, - -42, 74,-115, 82, 84, -15, 15, -12, 82, 83, - 84, 85, -41, -41, -29, 78, -6, -37, 74, 78, - -30, -39, -5, -31, -38, -47, 74, -30,-112,-112, --112,-112, -41, 82, -61, 74, -26, -26, -52, -71, - 75, -27, -34, -33, 82, -75, 74, -77, -84, -73, - -75, -54, -37, -19, -18, -37, 74, 74, -7, 83, - -86, 83, -72, -87, -33, -3, -24, -23, 98, -33, - -38, -38, 74, -36, -38, -21, -40, -22, -38, 71, - -38, 75, 78, -12, 82, 83, 84, -13, 89, 88, - 87, 86, 85, 91, 93, 92, 95, 94, 96, -3, - -38, -39, -38, -38, -38, -73, -91, -3, 75, 75, - 78, -41, -38, 82, 84, -41, -41, -41, -41, -41, - 75, 78, -29, -29, -29, 78, 78, 78, -38, -39, - -5, -31,-112,-112, 75, -62, -63, 14, -26, -74, - 75, 78, -16, -88, -89, 99, 78, -85, -45, -44, - -12, -47, -33, -48, 74, -36, 75, 78, 83, 78, - -19, -94, -96, -11, 14, -20, -33, 75, 78, 76, - -79, 74, 76, 75, -79, 82, 75, 77, 78, -33, - 75, -46, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, 75, 78, 75, 74, 78, 75,-115, -41, - 75, -6, 78, -39, -5, -39, -5, -39, -5, 75, - 78, 78, 78, 75, 78, 76, -75, -34, 75, 78, - -90, -43, -38, 82, -85, 82, -44, -37, -83, -18, - 78, 75, 78, 81, 78, -87, -38, -73, -38, -28, - -38, 70, 75, -32, 74, -40, -38, -3, -39, -91, - -3, -73, -23, -33, -39, -23, -23, -23, -63, 14, - -16, -90, 77, -45, -44, -77, -23, -96, -11, -33, - -24, 75, 78, -79, 75, 78, 75, 75, -38, 75, - 75, 75, 75, -43, -38, 83, 75, -38, -3, 78, - -3 }; -yytabelem yydef[]={ - - 1, -2, 0, 0, 9, 10, 2, 3, 4, 5, - 0, 239, 8, 18, 18, 18, 18, 228, 0, 37, - -2, 39, 40, 41, -2, 43, 44, 45, 47, 138, - 198, 239, 201, 0, 239, 239, 239, 66, 138, 138, - 138, 138, 86, 138, 133, 0, 239, 239, 214, 215, - 239, 217, 239, 239, 239, 54, 223, 239, 239, 239, - 242, 239, 235, 236, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 0, 0, 0, 0, 255, - 239, 239, 239, 239, 239, 258, 259, 260, 262, 263, - 264, 6, 36, 7, 21, 21, 0, 0, 18, 0, - 229, 29, 19, 20, 0, 88, 0, 229, 0, 0, - 0, 88, 126, 134, 0, 46, 98, 100, 101, 73, - 0, 0, -2, 202, 203, 0, 205, 206, 53, 240, - 0, 0, 0, 0, 88, 126, 0, 168, 0, 213, - 0, 0, 173, 173, 0, 0, 0, 0, 0, 243, - -2, 245, 246, 0, 190, 191, 0, 0, 177, 178, - 179, 180, 181, 182, 183, 160, 161, 185, 186, 187, - 247, 0, 248, 249, -2, 266, 253, 0, 300, 300, - 300, 300, 0, 11, 22, 13, 29, 29, 0, 138, - 17, 0, 110, 90, 228, 72, 110, 76, 78, 80, - 0, 85, 0, 123, 125, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 69, 0, 75, 77, 79, 84, - 122, 0, 169, -2, 0, 222, 0, 218, 0, 231, - 233, 0, 143, 0, 145, 146, 147, 0, 0, 220, - 174, 221, 0, 224, 121, -2, 0, 230, 271, 0, - 188, 0, 269, 272, 273, 0, 277, 0, 0, 0, - 0, 0, 196, 271, 250, 0, 282, 284, 0, 0, - 254, -2, 287, 288, 0, -2, 0, 256, 257, 261, - 278, 279, 300, 300, 12, 0, 14, 15, 29, 52, - 30, 0, 32, 34, 35, 66, 112, 0, 0, 0, - 105, 0, 82, 0, 108, 106, 0, 0, 127, 0, - 99, 74, 0, 102, 0, 241, 200, 209, 0, 0, - 0, 241, 0, 70, 211, 0, 0, 140, -2, 0, - 0, 219, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 162, 163, 164, 165, 166, 167, 234, - 0, 143, 152, 158, 0, 0, 0, 119, -2, 268, - 0, 0, 274, 275, 276, 192, 193, 194, 195, 197, - 267, 0, 252, 0, 251, 0, 0, 0, 0, 143, - 0, 0, 280, 281, 23, 0, 25, 27, 16, 110, - 31, 0, 50, 0, 0, 51, 0, 91, 93, 95, - 0, 97, 175, 176, 0, 71, 81, 0, 89, 0, - 0, 0, 128, 130, 132, 135, 136, 48, 0, 0, - 228, 0, 0, 0, 67, 0, 170, 173, 0, 212, - 0, 232, 148, 149, 150, 151, -2, 154, 155, 156, - 157, 159, 144, 0, 207, 0, 0, 228, 270, 271, - 189, 283, 0, -2, 290, -2, 292, -2, 294, -2, - 0, 0, 0, 24, 0, 0, 66, 33, 111, 0, - 113, 115, 118, 117, 92, 0, 96, 83, 90, 109, - 0, 124, 0, 0, 0, 103, 104, 0, 0, 208, - 237, 204, 241, 171, 173, 0, 142, 0, 143, 0, - 120, 0, 0, 168, -2, 0, 0, 0, 26, 28, - 49, 114, 0, 94, 95, 0, 0, 129, 131, 137, - 199, 210, 0, 68, 172, 0, 184, 226, 227, 285, - 297, 298, 299, 116, 118, 87, 107, 238, 0, 0, - 216 }; -# ifdef YYDEBUG -# include "y.debug" -# endif - -# define YYFLAG -1000 -# define YYERROR goto yyerrlab -# define YYACCEPT return(0) -# define YYABORT return(1) - -/* parser for yacc output */ - -#ifdef YYDEBUG -int yydebug = 0; /* 1 for debugging */ -#endif -YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */ -int yychar = -1; /* current input token number */ -int yynerrs = 0; /* number of errors */ -yytabelem yyerrflag = 0; /* error recovery flag */ - -yyparse() -{ yytabelem yys[YYMAXDEPTH]; - int yyj, yym; - register YYSTYPE *yypvt; - register int yystate, yyn; - register yytabelem *yyps; - register YYSTYPE *yypv; - register yytabelem *yyxi; - - yystate = 0; - yychar = -1; - yynerrs = 0; - yyerrflag = 0; - yyps= &yys[-1]; - yypv= &yyv[-1]; - -yystack: /* put a state and value onto the stack */ -#ifdef YYDEBUG - if(yydebug >= 3) - if(yychar < 0 || yytoknames[yychar] == 0) - printf("char %d in %s", yychar, yystates[yystate]); - else - printf("%s in %s", yytoknames[yychar], yystates[yystate]); -#endif - if( ++yyps >= &yys[YYMAXDEPTH] ) { - yyerror( "yacc stack overflow" ); - return(1); - } - *yyps = yystate; - ++yypv; - *yypv = yyval; -yynewstate: - yyn = yypact[yystate]; - if(yyn <= YYFLAG) goto yydefault; /* simple state */ - if(yychar<0) { - yychar = yylex(); -#ifdef YYDEBUG - if(yydebug >= 2) { - if(yychar <= 0) - printf("lex EOF\n"); - else if(yytoknames[yychar]) - printf("lex %s\n", yytoknames[yychar]); - else - printf("lex (%c)\n", yychar); - } -#endif - if(yychar < 0) - yychar = 0; - } - if((yyn += yychar) < 0 || yyn >= YYLAST) - goto yydefault; - if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */ - yychar = -1; - yyval = yylval; - yystate = yyn; - if( yyerrflag > 0 ) --yyerrflag; - goto yystack; - } -yydefault: - /* default state action */ - if( (yyn=yydef[yystate]) == -2 ) { - if(yychar < 0) { - yychar = yylex(); -#ifdef YYDEBUG - if(yydebug >= 2) - if(yychar < 0) - printf("lex EOF\n"); - else - printf("lex %s\n", yytoknames[yychar]); -#endif - if(yychar < 0) - yychar = 0; - } - /* look through exception table */ - for(yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate); - yyxi += 2 ) ; /* VOID */ - while( *(yyxi+=2) >= 0 ){ - if( *yyxi == yychar ) break; - } - if( (yyn = yyxi[1]) < 0 ) return(0); /* accept */ - } - if( yyn == 0 ){ /* error */ - /* error ... attempt to resume parsing */ - switch( yyerrflag ){ - case 0: /* brand new error */ -#ifdef YYDEBUG - yyerror("syntax error\n%s", yystates[yystate]); - if(yytoknames[yychar]) - yyerror("saw %s\n", yytoknames[yychar]); - else if(yychar >= ' ' && yychar < '\177') - yyerror("saw `%c'\n", yychar); - else if(yychar == 0) - yyerror("saw EOF\n"); - else - yyerror("saw char 0%o\n", yychar); -#else - yyerror( "syntax error" ); -#endif -yyerrlab: - ++yynerrs; - case 1: - case 2: /* incompletely recovered error ... try again */ - yyerrflag = 3; - /* find a state where "error" is a legal shift action */ - while ( yyps >= yys ) { - yyn = yypact[*yyps] + YYERRCODE; - if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){ - yystate = yyact[yyn]; /* simulate a shift of "error" */ - goto yystack; - } - yyn = yypact[*yyps]; - /* the current yyps has no shift onn "error", pop stack */ -#ifdef YYDEBUG - if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] ); -#endif - --yyps; - --yypv; - } - /* there is no state on the stack with an error shift ... abort */ -yyabort: - return(1); - case 3: /* no shift yet; clobber input char */ -#ifdef YYDEBUG - if( yydebug ) { - printf("error recovery discards "); - if(yytoknames[yychar]) - printf("%s\n", yytoknames[yychar]); - else if(yychar >= ' ' && yychar < '\177') - printf("`%c'\n", yychar); - else if(yychar == 0) - printf("EOF\n"); - else - printf("char 0%o\n", yychar); - } -#endif - if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */ - yychar = -1; - goto yynewstate; /* try again in the same state */ - } - } - /* reduction by production yyn */ -#ifdef YYDEBUG - if(yydebug) { char *s; - printf("reduce %d in:\n\t", yyn); - for(s = yystates[yystate]; *s; s++) { - putchar(*s); - if(*s == '\n' && *(s+1)) - putchar('\t'); - } - } -#endif - yyps -= yyr2[yyn]; - yypvt = yypv; - yypv -= yyr2[yyn]; - yyval = yypv[1]; - yym=yyn; - /* consult goto table to find next state */ - yyn = yyr1[yyn]; - yyj = yypgo[yyn] + *yyps + 1; - if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]]; - switch(yym){ - -case 3: -/* # line 226 "gram.in" */ -{ -/* stat: is the nonterminal for Fortran statements */ - - lastwasbranch = NO; } break; -case 5: -/* # line 232 "gram.in" */ -{ /* forbid further statement function definitions... */ - if (parstate == INDATA && laststfcn != thisstno) - parstate = INEXEC; - thisstno++; - if(yypvt[-1].labval && (yypvt[-1].labval->labelno==dorange)) - enddo(yypvt[-1].labval->labelno); - if(lastwasbranch && thislabel==NULL) - warn("statement cannot be reached"); - lastwasbranch = thiswasbranch; - thiswasbranch = NO; - if(yypvt[-1].labval) - { - if(yypvt[-1].labval->labtype == LABFORMAT) - err("label already that of a format"); - else - yypvt[-1].labval->labtype = LABEXEC; - } - freetemps(); - } break; -case 6: -/* # line 252 "gram.in" */ -{ if (can_include) - doinclude( yypvt[-0].charpval ); - else { - fprintf(diagfile, "Cannot open file %s\n", yypvt[-0].charpval); - done(1); - } - } break; -case 7: -/* # line 260 "gram.in" */ -{ if (yypvt[-2].labval) - lastwasbranch = NO; - endproc(); /* lastwasbranch = NO; -- set in endproc() */ - } break; -case 8: -/* # line 265 "gram.in" */ -{ extern void unclassifiable(); - unclassifiable(); - -/* flline flushes the current line, ignoring the rest of the text there */ - - flline(); } break; -case 9: -/* # line 272 "gram.in" */ -{ flline(); needkwd = NO; inioctl = NO; - yyerrok; yyclearin; } break; -case 10: -/* # line 277 "gram.in" */ -{ - if(yystno != 0) - { - yyval.labval = thislabel = mklabel(yystno); - if( ! headerdone ) { - if (procclass == CLUNKNOWN) - procclass = CLMAIN; - puthead(CNULL, procclass); - } - if(thislabel->labdefined) - execerr("label %s already defined", - convic(thislabel->stateno) ); - else { - if(thislabel->blklevel!=0 && thislabel->blklevellabtype!=LABFORMAT) - warn1("there is a branch to label %s from outside block", - convic( (ftnint) (thislabel->stateno) ) ); - thislabel->blklevel = blklevel; - thislabel->labdefined = YES; - if(thislabel->labtype != LABFORMAT) - p1_label((long)(thislabel - labeltab)); - } - } - else yyval.labval = thislabel = NULL; - } break; -case 11: -/* # line 305 "gram.in" */ -{startproc(yypvt[-0].extval, CLMAIN); } break; -case 12: -/* # line 307 "gram.in" */ -{ warn("ignoring arguments to main program"); - /* hashclear(); */ - startproc(yypvt[-1].extval, CLMAIN); } break; -case 13: -/* # line 311 "gram.in" */ -{ if(yypvt[-0].extval) NO66("named BLOCKDATA"); - startproc(yypvt[-0].extval, CLBLOCK); } break; -case 14: -/* # line 314 "gram.in" */ -{ entrypt(CLPROC, TYSUBR, (ftnint) 0, yypvt[-1].extval, yypvt[-0].chval); } break; -case 15: -/* # line 316 "gram.in" */ -{ entrypt(CLPROC, TYUNKNOWN, (ftnint) 0, yypvt[-1].extval, yypvt[-0].chval); } break; -case 16: -/* # line 318 "gram.in" */ -{ entrypt(CLPROC, yypvt[-4].ival, varleng, yypvt[-1].extval, yypvt[-0].chval); } break; -case 17: -/* # line 320 "gram.in" */ -{ if(parstate==OUTSIDE || procclass==CLMAIN - || procclass==CLBLOCK) - execerr("misplaced entry statement", CNULL); - entrypt(CLENTRY, 0, (ftnint) 0, yypvt[-1].extval, yypvt[-0].chval); - } break; -case 18: -/* # line 328 "gram.in" */ -{ newproc(); } break; -case 19: -/* # line 332 "gram.in" */ -{ yyval.extval = newentry(yypvt[-0].namval, 1); } break; -case 20: -/* # line 336 "gram.in" */ -{ yyval.namval = mkname(token); } break; -case 21: -/* # line 339 "gram.in" */ -{ yyval.extval = NULL; } break; -case 29: -/* # line 357 "gram.in" */ -{ yyval.chval = 0; } break; -case 30: -/* # line 359 "gram.in" */ -{ NO66(" () argument list"); - yyval.chval = 0; } break; -case 31: -/* # line 362 "gram.in" */ -{yyval.chval = yypvt[-1].chval; } break; -case 32: -/* # line 366 "gram.in" */ -{ yyval.chval = (yypvt[-0].namval ? mkchain((char *)yypvt[-0].namval,CHNULL) : CHNULL ); } break; -case 33: -/* # line 368 "gram.in" */ -{ if(yypvt[-0].namval) yypvt[-2].chval = yyval.chval = mkchain((char *)yypvt[-0].namval, yypvt[-2].chval); } break; -case 34: -/* # line 372 "gram.in" */ -{ if(yypvt[-0].namval->vstg!=STGUNKNOWN && yypvt[-0].namval->vstg!=STGARG) - dclerr("name declared as argument after use", yypvt[-0].namval); - yypvt[-0].namval->vstg = STGARG; - } break; -case 35: -/* # line 377 "gram.in" */ -{ NO66("altenate return argument"); - -/* substars means that '*'ed formal parameters should be replaced. - This is used to specify alternate return labels; in theory, only - parameter slots which have '*' should accept the statement labels. - This compiler chooses to ignore the '*'s in the formal declaration, and - always return the proper value anyway. - - This variable is only referred to in proc.c */ - - yyval.namval = 0; substars = YES; } break; -case 36: -/* # line 393 "gram.in" */ -{ - char *s; - s = copyn(toklen+1, token); - s[toklen] = '\0'; - yyval.charpval = s; - } break; -case 45: -/* # line 409 "gram.in" */ -{ NO66("SAVE statement"); - saveall = YES; } break; -case 46: -/* # line 412 "gram.in" */ -{ NO66("SAVE statement"); } break; -case 47: -/* # line 414 "gram.in" */ -{ fmtstmt(thislabel); setfmt(thislabel); } break; -case 48: -/* # line 416 "gram.in" */ -{ NO66("PARAMETER statement"); } break; -case 49: -/* # line 420 "gram.in" */ -{ settype(yypvt[-4].namval, yypvt[-6].ival, yypvt[-0].lval); - if(ndim>0) setbound(yypvt[-4].namval,ndim,dims); - } break; -case 50: -/* # line 424 "gram.in" */ -{ settype(yypvt[-2].namval, yypvt[-4].ival, yypvt[-0].lval); - if(ndim>0) setbound(yypvt[-2].namval,ndim,dims); - } break; -case 51: -/* # line 428 "gram.in" */ -{ if (new_dcl == 2) { - err("attempt to give DATA in type-declaration"); - new_dcl = 1; - } - } break; -case 52: -/* # line 435 "gram.in" */ -{ new_dcl = 2; } break; -case 53: -/* # line 438 "gram.in" */ -{ varleng = yypvt[-0].lval; } break; -case 54: -/* # line 442 "gram.in" */ -{ varleng = (yypvt[-0].ival<0 || ONEOF(yypvt[-0].ival,M(TYLOGICAL)|M(TYLONG)) - ? 0 : typesize[yypvt[-0].ival]); - vartype = yypvt[-0].ival; } break; -case 55: -/* # line 447 "gram.in" */ -{ yyval.ival = TYLONG; } break; -case 56: -/* # line 448 "gram.in" */ -{ yyval.ival = tyreal; } break; -case 57: -/* # line 449 "gram.in" */ -{ ++complex_seen; yyval.ival = tycomplex; } break; -case 58: -/* # line 450 "gram.in" */ -{ yyval.ival = TYDREAL; } break; -case 59: -/* # line 451 "gram.in" */ -{ ++dcomplex_seen; NOEXT("DOUBLE COMPLEX statement"); yyval.ival = TYDCOMPLEX; } break; -case 60: -/* # line 452 "gram.in" */ -{ yyval.ival = TYLOGICAL; } break; -case 61: -/* # line 453 "gram.in" */ -{ NO66("CHARACTER statement"); yyval.ival = TYCHAR; } break; -case 62: -/* # line 454 "gram.in" */ -{ yyval.ival = TYUNKNOWN; } break; -case 63: -/* # line 455 "gram.in" */ -{ yyval.ival = TYUNKNOWN; } break; -case 64: -/* # line 456 "gram.in" */ -{ NOEXT("AUTOMATIC statement"); yyval.ival = - STGAUTO; } break; -case 65: -/* # line 457 "gram.in" */ -{ NOEXT("STATIC statement"); yyval.ival = - STGBSS; } break; -case 66: -/* # line 461 "gram.in" */ -{ yyval.lval = varleng; } break; -case 67: -/* # line 463 "gram.in" */ -{ - expptr p; - p = yypvt[-1].expval; - NO66("length specification *n"); - if( ! ISICON(p) || p->constblock.Const.ci <= 0 ) - { - yyval.lval = 0; - dclerr("length must be a positive integer constant", - NPNULL); - } - else { - if (vartype == TYCHAR) - yyval.lval = p->constblock.Const.ci; - else switch((int)p->constblock.Const.ci) { - case 1: yyval.lval = 1; break; - case 2: yyval.lval = typesize[TYSHORT]; break; - case 4: yyval.lval = typesize[TYLONG]; break; - case 8: yyval.lval = typesize[TYDREAL]; break; - case 16: yyval.lval = typesize[TYDCOMPLEX]; break; - default: - dclerr("invalid length",NPNULL); - yyval.lval = varleng; - } - } - } break; -case 68: -/* # line 489 "gram.in" */ -{ NO66("length specification *(*)"); yyval.lval = -1; } break; -case 69: -/* # line 493 "gram.in" */ -{ incomm( yyval.extval = comblock("") , yypvt[-0].namval ); } break; -case 70: -/* # line 495 "gram.in" */ -{ yyval.extval = yypvt[-1].extval; incomm(yypvt[-1].extval, yypvt[-0].namval); } break; -case 71: -/* # line 497 "gram.in" */ -{ yyval.extval = yypvt[-2].extval; incomm(yypvt[-2].extval, yypvt[-0].namval); } break; -case 72: -/* # line 499 "gram.in" */ -{ incomm(yypvt[-2].extval, yypvt[-0].namval); } break; -case 73: -/* # line 503 "gram.in" */ -{ yyval.extval = comblock(""); } break; -case 74: -/* # line 505 "gram.in" */ -{ yyval.extval = comblock(token); } break; -case 75: -/* # line 509 "gram.in" */ -{ setext(yypvt[-0].namval); } break; -case 76: -/* # line 511 "gram.in" */ -{ setext(yypvt[-0].namval); } break; -case 77: -/* # line 515 "gram.in" */ -{ NO66("INTRINSIC statement"); setintr(yypvt[-0].namval); } break; -case 78: -/* # line 517 "gram.in" */ -{ setintr(yypvt[-0].namval); } break; -case 81: -/* # line 525 "gram.in" */ -{ - struct Equivblock *p; - if(nequiv >= maxequiv) - many("equivalences", 'q', maxequiv); - p = & eqvclass[nequiv++]; - p->eqvinit = NO; - p->eqvbottom = 0; - p->eqvtop = 0; - p->equivs = yypvt[-1].eqvval; - } break; -case 82: -/* # line 538 "gram.in" */ -{ yyval.eqvval=ALLOC(Eqvchain); - yyval.eqvval->eqvitem.eqvlhs = (struct Primblock *)yypvt[-0].expval; - } break; -case 83: -/* # line 542 "gram.in" */ -{ yyval.eqvval=ALLOC(Eqvchain); - yyval.eqvval->eqvitem.eqvlhs = (struct Primblock *) yypvt[-0].expval; - yyval.eqvval->eqvnextp = yypvt[-2].eqvval; - } break; -case 86: -/* # line 553 "gram.in" */ -{ if(parstate == OUTSIDE) - { - newproc(); - startproc(ESNULL, CLMAIN); - } - if(parstate < INDATA) - { - enddcl(); - parstate = INDATA; - datagripe = 1; - } - } break; -case 87: -/* # line 568 "gram.in" */ -{ ftnint junk; - if(nextdata(&junk) != NULL) - err("too few initializers"); - frdata(yypvt[-4].chval); - frrpl(); - } break; -case 88: -/* # line 576 "gram.in" */ -{ frchain(&datastack); curdtp = 0; } break; -case 89: -/* # line 578 "gram.in" */ -{ pop_datastack(); } break; -case 90: -/* # line 580 "gram.in" */ -{ toomanyinit = NO; } break; -case 93: -/* # line 585 "gram.in" */ -{ dataval(ENULL, yypvt[-0].expval); } break; -case 94: -/* # line 587 "gram.in" */ -{ dataval(yypvt[-2].expval, yypvt[-0].expval); } break; -case 96: -/* # line 592 "gram.in" */ -{ if( yypvt[-1].ival==OPMINUS && ISCONST(yypvt[-0].expval) ) - consnegop((Constp)yypvt[-0].expval); - yyval.expval = yypvt[-0].expval; - } break; -case 100: -/* # line 604 "gram.in" */ -{ int k; - yypvt[-0].namval->vsave = YES; - k = yypvt[-0].namval->vstg; - if( ! ONEOF(k, M(STGUNKNOWN)|M(STGBSS)|M(STGINIT)) ) - dclerr("can only save static variables", yypvt[-0].namval); - } break; -case 104: -/* # line 618 "gram.in" */ -{ if(yypvt[-2].namval->vclass == CLUNKNOWN) - make_param((struct Paramblock *)yypvt[-2].namval, yypvt[-0].expval); - else dclerr("cannot make into parameter", yypvt[-2].namval); - } break; -case 105: -/* # line 625 "gram.in" */ -{ if(ndim>0) setbound(yypvt[-1].namval, ndim, dims); } break; -case 106: -/* # line 629 "gram.in" */ -{ Namep np; - np = ( (struct Primblock *) yypvt[-0].expval) -> namep; - vardcl(np); - if(np->vstg == STGCOMMON) - extsymtab[np->vardesc.varno].extinit = YES; - else if(np->vstg==STGEQUIV) - eqvclass[np->vardesc.varno].eqvinit = YES; - else if(np->vstg!=STGINIT && np->vstg!=STGBSS) - dclerr("inconsistent storage classes", np); - yyval.chval = mkchain((char *)yypvt[-0].expval, CHNULL); - } break; -case 107: -/* # line 641 "gram.in" */ -{ chainp p; struct Impldoblock *q; - pop_datastack(); - q = ALLOC(Impldoblock); - q->tag = TIMPLDO; - (q->varnp = (Namep) (yypvt[-1].chval->datap))->vimpldovar = 1; - p = yypvt[-1].chval->nextp; - if(p) { q->implb = (expptr)(p->datap); p = p->nextp; } - if(p) { q->impub = (expptr)(p->datap); p = p->nextp; } - if(p) { q->impstep = (expptr)(p->datap); } - frchain( & (yypvt[-1].chval) ); - yyval.chval = mkchain((char *)q, CHNULL); - q->datalist = hookup(yypvt[-3].chval, yyval.chval); - } break; -case 108: -/* # line 657 "gram.in" */ -{ if (!datastack) - curdtp = 0; - datastack = mkchain((char *)curdtp, datastack); - curdtp = yypvt[-0].chval; curdtelt = 0; - } break; -case 109: -/* # line 663 "gram.in" */ -{ yyval.chval = hookup(yypvt[-2].chval, yypvt[-0].chval); } break; -case 110: -/* # line 667 "gram.in" */ -{ ndim = 0; } break; -case 112: -/* # line 671 "gram.in" */ -{ ndim = 0; } break; -case 115: -/* # line 676 "gram.in" */ -{ - if(ndim == maxdim) - err("too many dimensions"); - else if(ndim < maxdim) - { dims[ndim].lb = 0; - dims[ndim].ub = yypvt[-0].expval; - } - ++ndim; - } break; -case 116: -/* # line 686 "gram.in" */ -{ - if(ndim == maxdim) - err("too many dimensions"); - else if(ndim < maxdim) - { dims[ndim].lb = yypvt[-2].expval; - dims[ndim].ub = yypvt[-0].expval; - } - ++ndim; - } break; -case 117: -/* # line 698 "gram.in" */ -{ yyval.expval = 0; } break; -case 119: -/* # line 703 "gram.in" */ -{ nstars = 1; labarray[0] = yypvt[-0].labval; } break; -case 120: -/* # line 705 "gram.in" */ -{ if(nstars < maxlablist) labarray[nstars++] = yypvt[-0].labval; } break; -case 121: -/* # line 709 "gram.in" */ -{ yyval.labval = execlab( convci(toklen, token) ); } break; -case 122: -/* # line 713 "gram.in" */ -{ NO66("IMPLICIT statement"); } break; -case 125: -/* # line 719 "gram.in" */ -{ if (vartype != TYUNKNOWN) - dclerr("-- expected letter range",NPNULL); - setimpl(vartype, varleng, 'a', 'z'); } break; -case 126: -/* # line 724 "gram.in" */ -{ needkwd = 1; } break; -case 130: -/* # line 733 "gram.in" */ -{ setimpl(vartype, varleng, yypvt[-0].ival, yypvt[-0].ival); } break; -case 131: -/* # line 735 "gram.in" */ -{ setimpl(vartype, varleng, yypvt[-2].ival, yypvt[-0].ival); } break; -case 132: -/* # line 739 "gram.in" */ -{ if(toklen!=1 || token[0]<'a' || token[0]>'z') - { - dclerr("implicit item must be single letter", NPNULL); - yyval.ival = 0; - } - else yyval.ival = token[0]; - } break; -case 135: -/* # line 753 "gram.in" */ -{ - if(yypvt[-2].namval->vclass == CLUNKNOWN) - { - yypvt[-2].namval->vclass = CLNAMELIST; - yypvt[-2].namval->vtype = TYINT; - yypvt[-2].namval->vstg = STGBSS; - yypvt[-2].namval->varxptr.namelist = yypvt[-0].chval; - yypvt[-2].namval->vardesc.varno = ++lastvarno; - } - else dclerr("cannot be a namelist name", yypvt[-2].namval); - } break; -case 136: -/* # line 767 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].namval, CHNULL); } break; -case 137: -/* # line 769 "gram.in" */ -{ yyval.chval = hookup(yypvt[-2].chval, mkchain((char *)yypvt[-0].namval, CHNULL)); } break; -case 138: -/* # line 773 "gram.in" */ -{ switch(parstate) - { - case OUTSIDE: newproc(); - startproc(ESNULL, CLMAIN); - case INSIDE: parstate = INDCL; - case INDCL: break; - - case INDATA: - if (datagripe) { - errstr( - "Statement order error: declaration after DATA", - CNULL); - datagripe = 0; - } - break; - - default: - dclerr("declaration among executables", NPNULL); - } - } break; -case 139: -/* # line 795 "gram.in" */ -{ yyval.chval = 0; } break; -case 140: -/* # line 797 "gram.in" */ -{ yyval.chval = revchain(yypvt[-0].chval); } break; -case 141: -/* # line 801 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].expval, CHNULL); } break; -case 142: -/* # line 803 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].expval, yypvt[-2].chval); } break; -case 144: -/* # line 808 "gram.in" */ -{ yyval.expval = yypvt[-1].expval; if (yyval.expval->tag == TPRIM) - yyval.expval->primblock.parenused = 1; } break; -case 148: -/* # line 816 "gram.in" */ -{ yyval.expval = mkexpr(yypvt[-1].ival, yypvt[-2].expval, yypvt[-0].expval); } break; -case 149: -/* # line 818 "gram.in" */ -{ yyval.expval = mkexpr(OPSTAR, yypvt[-2].expval, yypvt[-0].expval); } break; -case 150: -/* # line 820 "gram.in" */ -{ yyval.expval = mkexpr(OPSLASH, yypvt[-2].expval, yypvt[-0].expval); } break; -case 151: -/* # line 822 "gram.in" */ -{ yyval.expval = mkexpr(OPPOWER, yypvt[-2].expval, yypvt[-0].expval); } break; -case 152: -/* # line 824 "gram.in" */ -{ if(yypvt[-1].ival == OPMINUS) - yyval.expval = mkexpr(OPNEG, yypvt[-0].expval, ENULL); - else yyval.expval = yypvt[-0].expval; - } break; -case 153: -/* # line 829 "gram.in" */ -{ yyval.expval = mkexpr(yypvt[-1].ival, yypvt[-2].expval, yypvt[-0].expval); } break; -case 154: -/* # line 831 "gram.in" */ -{ NO66(".EQV. operator"); - yyval.expval = mkexpr(OPEQV, yypvt[-2].expval,yypvt[-0].expval); } break; -case 155: -/* # line 834 "gram.in" */ -{ NO66(".NEQV. operator"); - yyval.expval = mkexpr(OPNEQV, yypvt[-2].expval, yypvt[-0].expval); } break; -case 156: -/* # line 837 "gram.in" */ -{ yyval.expval = mkexpr(OPOR, yypvt[-2].expval, yypvt[-0].expval); } break; -case 157: -/* # line 839 "gram.in" */ -{ yyval.expval = mkexpr(OPAND, yypvt[-2].expval, yypvt[-0].expval); } break; -case 158: -/* # line 841 "gram.in" */ -{ yyval.expval = mkexpr(OPNOT, yypvt[-0].expval, ENULL); } break; -case 159: -/* # line 843 "gram.in" */ -{ NO66("concatenation operator //"); - yyval.expval = mkexpr(OPCONCAT, yypvt[-2].expval, yypvt[-0].expval); } break; -case 160: -/* # line 847 "gram.in" */ -{ yyval.ival = OPPLUS; } break; -case 161: -/* # line 848 "gram.in" */ -{ yyval.ival = OPMINUS; } break; -case 162: -/* # line 851 "gram.in" */ -{ yyval.ival = OPEQ; } break; -case 163: -/* # line 852 "gram.in" */ -{ yyval.ival = OPGT; } break; -case 164: -/* # line 853 "gram.in" */ -{ yyval.ival = OPLT; } break; -case 165: -/* # line 854 "gram.in" */ -{ yyval.ival = OPGE; } break; -case 166: -/* # line 855 "gram.in" */ -{ yyval.ival = OPLE; } break; -case 167: -/* # line 856 "gram.in" */ -{ yyval.ival = OPNE; } break; -case 168: -/* # line 860 "gram.in" */ -{ yyval.expval = mkprim(yypvt[-0].namval, LBNULL, CHNULL); } break; -case 169: -/* # line 862 "gram.in" */ -{ NO66("substring operator :"); - yyval.expval = mkprim(yypvt[-1].namval, LBNULL, yypvt[-0].chval); } break; -case 170: -/* # line 865 "gram.in" */ -{ yyval.expval = mkprim(yypvt[-3].namval, mklist(yypvt[-1].chval), CHNULL); } break; -case 171: -/* # line 867 "gram.in" */ -{ NO66("substring operator :"); - yyval.expval = mkprim(yypvt[-4].namval, mklist(yypvt[-2].chval), yypvt[-0].chval); } break; -case 172: -/* # line 872 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-3].expval, mkchain((char *)yypvt[-1].expval,CHNULL)); } break; -case 173: -/* # line 876 "gram.in" */ -{ yyval.expval = 0; } break; -case 175: -/* # line 881 "gram.in" */ -{ if(yypvt[-0].namval->vclass == CLPARAM) - yyval.expval = (expptr) cpexpr( - ( (struct Paramblock *) (yypvt[-0].namval) ) -> paramval); - } break; -case 177: -/* # line 888 "gram.in" */ -{ yyval.expval = mklogcon(1); } break; -case 178: -/* # line 889 "gram.in" */ -{ yyval.expval = mklogcon(0); } break; -case 179: -/* # line 890 "gram.in" */ -{ yyval.expval = mkstrcon(toklen, token); } break; -case 180: -/* # line 891 "gram.in" */ - { yyval.expval = mkintcon( convci(toklen, token) ); } break; -case 181: -/* # line 892 "gram.in" */ - { yyval.expval = mkrealcon(tyreal, token); } break; -case 182: -/* # line 893 "gram.in" */ - { yyval.expval = mkrealcon(TYDREAL, token); } break; -case 184: -/* # line 898 "gram.in" */ -{ yyval.expval = mkcxcon(yypvt[-3].expval,yypvt[-1].expval); } break; -case 185: -/* # line 902 "gram.in" */ -{ NOEXT("hex constant"); - yyval.expval = mkbitcon(4, toklen, token); } break; -case 186: -/* # line 905 "gram.in" */ -{ NOEXT("octal constant"); - yyval.expval = mkbitcon(3, toklen, token); } break; -case 187: -/* # line 908 "gram.in" */ -{ NOEXT("binary constant"); - yyval.expval = mkbitcon(1, toklen, token); } break; -case 189: -/* # line 914 "gram.in" */ -{ yyval.expval = yypvt[-1].expval; } break; -case 192: -/* # line 920 "gram.in" */ -{ yyval.expval = mkexpr(yypvt[-1].ival, yypvt[-2].expval, yypvt[-0].expval); } break; -case 193: -/* # line 922 "gram.in" */ -{ yyval.expval = mkexpr(OPSTAR, yypvt[-2].expval, yypvt[-0].expval); } break; -case 194: -/* # line 924 "gram.in" */ -{ yyval.expval = mkexpr(OPSLASH, yypvt[-2].expval, yypvt[-0].expval); } break; -case 195: -/* # line 926 "gram.in" */ -{ yyval.expval = mkexpr(OPPOWER, yypvt[-2].expval, yypvt[-0].expval); } break; -case 196: -/* # line 928 "gram.in" */ -{ if(yypvt[-1].ival == OPMINUS) - yyval.expval = mkexpr(OPNEG, yypvt[-0].expval, ENULL); - else yyval.expval = yypvt[-0].expval; - } break; -case 197: -/* # line 933 "gram.in" */ -{ NO66("concatenation operator //"); - yyval.expval = mkexpr(OPCONCAT, yypvt[-2].expval, yypvt[-0].expval); } break; -case 199: -/* # line 938 "gram.in" */ -{ - if(yypvt[-3].labval->labdefined) - execerr("no backward DO loops", CNULL); - yypvt[-3].labval->blklevel = blklevel+1; - exdo(yypvt[-3].labval->labelno, NPNULL, yypvt[-0].chval); - } break; -case 200: -/* # line 945 "gram.in" */ -{ - exdo((int)(ctls - ctlstack - 2), NPNULL, yypvt[-0].chval); - NOEXT("DO without label"); - } break; -case 201: -/* # line 950 "gram.in" */ -{ exenddo(NPNULL); } break; -case 202: -/* # line 952 "gram.in" */ -{ exendif(); thiswasbranch = NO; } break; -case 204: -/* # line 955 "gram.in" */ -{ exelif(yypvt[-2].expval); lastwasbranch = NO; } break; -case 205: -/* # line 957 "gram.in" */ -{ exelse(); lastwasbranch = NO; } break; -case 206: -/* # line 959 "gram.in" */ -{ exendif(); lastwasbranch = NO; } break; -case 207: -/* # line 963 "gram.in" */ -{ exif(yypvt[-1].expval); } break; -case 208: -/* # line 967 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-2].namval, yypvt[-0].chval); } break; -case 210: -/* # line 972 "gram.in" */ -{ yyval.chval = mkchain(CNULL, (chainp)yypvt[-1].expval); } break; -case 211: -/* # line 976 "gram.in" */ -{ exequals((struct Primblock *)yypvt[-2].expval, yypvt[-0].expval); } break; -case 212: -/* # line 978 "gram.in" */ -{ exassign(yypvt[-0].namval, yypvt[-2].labval); } break; -case 215: -/* # line 982 "gram.in" */ -{ inioctl = NO; } break; -case 216: -/* # line 984 "gram.in" */ -{ exarif(yypvt[-6].expval, yypvt[-4].labval, yypvt[-2].labval, yypvt[-0].labval); thiswasbranch = YES; } break; -case 217: -/* # line 986 "gram.in" */ -{ excall(yypvt[-0].namval, LBNULL, 0, labarray); } break; -case 218: -/* # line 988 "gram.in" */ -{ excall(yypvt[-2].namval, LBNULL, 0, labarray); } break; -case 219: -/* # line 990 "gram.in" */ -{ if(nstars < maxlablist) - excall(yypvt[-3].namval, mklist(revchain(yypvt[-1].chval)), nstars, labarray); - else - many("alternate returns", 'l', maxlablist); - } break; -case 220: -/* # line 996 "gram.in" */ -{ exreturn(yypvt[-0].expval); thiswasbranch = YES; } break; -case 221: -/* # line 998 "gram.in" */ -{ exstop(yypvt[-2].ival, yypvt[-0].expval); thiswasbranch = yypvt[-2].ival; } break; -case 222: -/* # line 1002 "gram.in" */ -{ yyval.labval = mklabel( convci(toklen, token) ); } break; -case 223: -/* # line 1006 "gram.in" */ -{ if(parstate == OUTSIDE) - { - newproc(); - startproc(ESNULL, CLMAIN); - } - } break; -case 224: -/* # line 1015 "gram.in" */ -{ exgoto(yypvt[-0].labval); thiswasbranch = YES; } break; -case 225: -/* # line 1017 "gram.in" */ -{ exasgoto(yypvt[-0].namval); thiswasbranch = YES; } break; -case 226: -/* # line 1019 "gram.in" */ -{ exasgoto(yypvt[-4].namval); thiswasbranch = YES; } break; -case 227: -/* # line 1021 "gram.in" */ -{ if(nstars < maxlablist) - putcmgo(putx(fixtype(yypvt[-0].expval)), nstars, labarray); - else - many("labels in computed GOTO list", 'l', maxlablist); - } break; -case 230: -/* # line 1033 "gram.in" */ -{ nstars = 0; yyval.namval = yypvt[-0].namval; } break; -case 231: -/* # line 1037 "gram.in" */ -{ yyval.chval = yypvt[-0].expval ? mkchain((char *)yypvt[-0].expval,CHNULL) : CHNULL; } break; -case 232: -/* # line 1039 "gram.in" */ -{ yyval.chval = yypvt[-0].expval ? mkchain((char *)yypvt[-0].expval, yypvt[-2].chval) : yypvt[-2].chval; } break; -case 234: -/* # line 1044 "gram.in" */ -{ if(nstars < maxlablist) labarray[nstars++] = yypvt[-0].labval; yyval.expval = 0; } break; -case 235: -/* # line 1048 "gram.in" */ -{ yyval.ival = 0; } break; -case 236: -/* # line 1050 "gram.in" */ -{ yyval.ival = 2; } break; -case 237: -/* # line 1054 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].expval, CHNULL); } break; -case 238: -/* # line 1056 "gram.in" */ -{ yyval.chval = hookup(yypvt[-2].chval, mkchain((char *)yypvt[-0].expval,CHNULL) ); } break; -case 239: -/* # line 1060 "gram.in" */ -{ if(parstate == OUTSIDE) - { - newproc(); - startproc(ESNULL, CLMAIN); - } - -/* This next statement depends on the ordering of the state table encoding */ - - if(parstate < INDATA) enddcl(); - } break; -case 240: -/* # line 1073 "gram.in" */ -{ intonly = YES; } break; -case 241: -/* # line 1077 "gram.in" */ -{ intonly = NO; } break; -case 242: -/* # line 1082 "gram.in" */ -{ endio(); } break; -case 244: -/* # line 1087 "gram.in" */ -{ ioclause(IOSUNIT, yypvt[-0].expval); endioctl(); } break; -case 245: -/* # line 1089 "gram.in" */ -{ ioclause(IOSUNIT, ENULL); endioctl(); } break; -case 246: -/* # line 1091 "gram.in" */ -{ ioclause(IOSUNIT, IOSTDERR); endioctl(); } break; -case 248: -/* # line 1094 "gram.in" */ -{ doio(CHNULL); } break; -case 249: -/* # line 1096 "gram.in" */ -{ doio(CHNULL); } break; -case 250: -/* # line 1098 "gram.in" */ -{ doio(revchain(yypvt[-0].chval)); } break; -case 251: -/* # line 1100 "gram.in" */ -{ doio(revchain(yypvt[-0].chval)); } break; -case 252: -/* # line 1102 "gram.in" */ -{ doio(revchain(yypvt[-0].chval)); } break; -case 253: -/* # line 1104 "gram.in" */ -{ doio(CHNULL); } break; -case 254: -/* # line 1106 "gram.in" */ -{ doio(revchain(yypvt[-0].chval)); } break; -case 255: -/* # line 1108 "gram.in" */ -{ doio(CHNULL); } break; -case 256: -/* # line 1110 "gram.in" */ -{ doio(revchain(yypvt[-0].chval)); } break; -case 258: -/* # line 1117 "gram.in" */ -{ iostmt = IOBACKSPACE; } break; -case 259: -/* # line 1119 "gram.in" */ -{ iostmt = IOREWIND; } break; -case 260: -/* # line 1121 "gram.in" */ -{ iostmt = IOENDFILE; } break; -case 262: -/* # line 1128 "gram.in" */ -{ iostmt = IOINQUIRE; } break; -case 263: -/* # line 1130 "gram.in" */ -{ iostmt = IOOPEN; } break; -case 264: -/* # line 1132 "gram.in" */ -{ iostmt = IOCLOSE; } break; -case 265: -/* # line 1136 "gram.in" */ -{ - ioclause(IOSUNIT, ENULL); - ioclause(IOSFMT, yypvt[-0].expval); - endioctl(); - } break; -case 266: -/* # line 1142 "gram.in" */ -{ - ioclause(IOSUNIT, ENULL); - ioclause(IOSFMT, ENULL); - endioctl(); - } break; -case 267: -/* # line 1150 "gram.in" */ -{ - ioclause(IOSUNIT, yypvt[-1].expval); - endioctl(); - } break; -case 268: -/* # line 1155 "gram.in" */ -{ endioctl(); } break; -case 271: -/* # line 1163 "gram.in" */ -{ ioclause(IOSPOSITIONAL, yypvt[-0].expval); } break; -case 272: -/* # line 1165 "gram.in" */ -{ ioclause(IOSPOSITIONAL, ENULL); } break; -case 273: -/* # line 1167 "gram.in" */ -{ ioclause(IOSPOSITIONAL, IOSTDERR); } break; -case 274: -/* # line 1169 "gram.in" */ -{ ioclause(yypvt[-1].ival, yypvt[-0].expval); } break; -case 275: -/* # line 1171 "gram.in" */ -{ ioclause(yypvt[-1].ival, ENULL); } break; -case 276: -/* # line 1173 "gram.in" */ -{ ioclause(yypvt[-1].ival, IOSTDERR); } break; -case 277: -/* # line 1177 "gram.in" */ -{ yyval.ival = iocname(); } break; -case 278: -/* # line 1181 "gram.in" */ -{ iostmt = IOREAD; } break; -case 279: -/* # line 1185 "gram.in" */ -{ iostmt = IOWRITE; } break; -case 280: -/* # line 1189 "gram.in" */ -{ - iostmt = IOWRITE; - ioclause(IOSUNIT, ENULL); - ioclause(IOSFMT, yypvt[-1].expval); - endioctl(); - } break; -case 281: -/* # line 1196 "gram.in" */ -{ - iostmt = IOWRITE; - ioclause(IOSUNIT, ENULL); - ioclause(IOSFMT, ENULL); - endioctl(); - } break; -case 282: -/* # line 1205 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].tagval, CHNULL); } break; -case 283: -/* # line 1207 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].tagval, yypvt[-2].chval); } break; -case 284: -/* # line 1211 "gram.in" */ -{ yyval.tagval = (tagptr) yypvt[-0].expval; } break; -case 285: -/* # line 1213 "gram.in" */ -{ yyval.tagval = (tagptr) mkiodo(yypvt[-1].chval,revchain(yypvt[-3].chval)); } break; -case 286: -/* # line 1217 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].expval, CHNULL); } break; -case 287: -/* # line 1219 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].tagval, CHNULL); } break; -case 289: -/* # line 1224 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].expval, mkchain((char *)yypvt[-2].expval, CHNULL) ); } break; -case 290: -/* # line 1226 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].tagval, mkchain((char *)yypvt[-2].expval, CHNULL) ); } break; -case 291: -/* # line 1228 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].expval, mkchain((char *)yypvt[-2].tagval, CHNULL) ); } break; -case 292: -/* # line 1230 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].tagval, mkchain((char *)yypvt[-2].tagval, CHNULL) ); } break; -case 293: -/* # line 1232 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].expval, yypvt[-2].chval); } break; -case 294: -/* # line 1234 "gram.in" */ -{ yyval.chval = mkchain((char *)yypvt[-0].tagval, yypvt[-2].chval); } break; -case 295: -/* # line 1238 "gram.in" */ -{ yyval.tagval = (tagptr) yypvt[-0].expval; } break; -case 296: -/* # line 1240 "gram.in" */ -{ yyval.tagval = (tagptr) yypvt[-1].expval; } break; -case 297: -/* # line 1242 "gram.in" */ -{ yyval.tagval = (tagptr) mkiodo(yypvt[-1].chval, mkchain((char *)yypvt[-3].expval, CHNULL) ); } break; -case 298: -/* # line 1244 "gram.in" */ -{ yyval.tagval = (tagptr) mkiodo(yypvt[-1].chval, mkchain((char *)yypvt[-3].tagval, CHNULL) ); } break; -case 299: -/* # line 1246 "gram.in" */ -{ yyval.tagval = (tagptr) mkiodo(yypvt[-1].chval, revchain(yypvt[-3].chval)); } break; -case 300: -/* # line 1250 "gram.in" */ -{ startioctl(); } break; - } - goto yystack; /* stack new state and value */ -} diff --git a/usr.bin/f2c/makefile b/usr.bin/f2c/makefile deleted file mode 100644 index d15fe2a..0000000 --- a/usr.bin/f2c/makefile +++ /dev/null @@ -1,90 +0,0 @@ -# Makefile for f2c, a Fortran 77 to C converter - -g = -g -CFLAGS = $g -SHELL = /bin/sh - -OBJECTSd = main.o init.o gram.o lex.o proc.o equiv.o data.o format.o \ - expr.o exec.o intr.o io.o misc.o error.o mem.o names.o \ - output.o p1output.o pread.o put.o putpcc.o vax.o formatdata.o \ - parse_args.o niceprintf.o cds.o sysdep.o version.o -OBJECTS = $(OBJECTSd) malloc.o - -all: xsum.out f2c - -f2c: $(OBJECTS) - $(CC) $(LDFLAGS) $(OBJECTS) -o f2c - -gram.c: gram.head gram.dcl gram.expr gram.exec gram.io defs.h tokdefs.h - ( sed gram.in - $(YACC) $(YFLAGS) gram.in - echo "(expect 4 shift/reduce)" - sed 's/^# line.*/\/* & *\//' y.tab.c >gram.c - rm -f gram.in y.tab.c - -$(OBJECTSd): defs.h ftypes.h defines.h machdefs.h sysdep.h - -tokdefs.h: tokens - grep -n . tokdefs.h - -cds.o: sysdep.h -exec.o: p1defs.h names.h -expr.o: output.h niceprintf.h names.h -format.o: p1defs.h format.h output.h niceprintf.h names.h iob.h -formatdata.o: format.h output.h niceprintf.h names.h -gram.o: p1defs.h -init.o: output.h niceprintf.h iob.h -intr.o: names.h -io.o: names.h iob.h -lex.o : tokdefs.h p1defs.h -main.o: parse.h usignal.h -mem.o: iob.h -names.o: iob.h names.h output.h niceprintf.h -niceprintf.o: defs.h names.h output.h niceprintf.h -output.o: output.h niceprintf.h names.h -p1output.o: p1defs.h output.h niceprintf.h names.h -parse_args.o: parse.h -proc.o: tokdefs.h names.h niceprintf.h output.h p1defs.h -put.o: names.h pccdefs.h p1defs.h -putpcc.o: names.h -vax.o: defs.h output.h pccdefs.h -output.h: niceprintf.h - -put.o putpcc.o: pccdefs.h - -f2c.t: f2c.1t - troff -man f2c.1t >f2c.t - -f2c.1: f2c.1t - nroff -man f2c.1t | col -b | uniq >f2c.1 - -clean: - rm -f gram.c *.o f2c tokdefs.h f2c.t - -b = Notice README cds.c data.c defines.h defs.h equiv.c error.c \ - exec.c expr.c f2c.1 f2c.1t f2c.h format.c format.h formatdata.c \ - ftypes.h gram.dcl gram.exec gram.expr gram.head gram.io \ - init.c intr.c io.c iob.h lex.c machdefs.h main.c makefile \ - malloc.c mem.c memset.c misc.c names.c names.h niceprintf.c \ - niceprintf.h output.c output.h p1defs.h p1output.c \ - parse.h parse_args.c pccdefs.h pread.c proc.c put.c putpcc.c \ - sysdep.c sysdep.h tokens usignal.h vax.c version.c xsum.c - -bundle: - bundle $b xsum0.out >/tmp/f2c.bundle - -xsum: xsum.c - $(CC) -o xsum xsum.c - -#Check validity of transmitted source... -xsum.out: xsum - ./xsum $b >xsum1.out - cmp xsum0.out xsum1.out && mv xsum1.out xsum.out - -#On non-Unix systems that end lines with carriage-return/newline pairs, -#use "make xsumr.out" rather than "make xsum.out". The -r flag ignores -#carriage-return characters. -xsumr.out: xsum - ./xsum -r $b >xsum1.out - cmp xsum0.out xsum1.out && mv xsum1.out xsumr.out diff --git a/usr.bin/f2c/xsum0.out b/usr.bin/f2c/xsum0.out deleted file mode 100644 index 0eecb1c..0000000 --- a/usr.bin/f2c/xsum0.out +++ /dev/null @@ -1,56 +0,0 @@ -Notice 1211689a 1195 -README 110fc3e8 4398 -cds.c 38ec751 4076 -data.c fa8cecd6 9370 -defines.h e500bb1a 8464 -defs.h 72515cc 24172 -equiv.c f6b65bcc 8831 -error.c 7e4ede 3648 -exec.c e279d99 17980 -expr.c 1d64bc48 60705 -f2c.1 fa354030 6042 -f2c.1t e571e717 5988 -f2c.h 1be46b90 4271 -format.c ed4c1a9 52848 -format.h e861ad39 300 -formatdata.c eb45f76a 24861 -ftypes.h 18b86a27 1377 -gram.dcl 11121871 7977 -gram.exec e190cb8e 3026 -gram.expr e3da3320 3137 -gram.head ecf8a5e0 7554 -gram.io 1b7c281c 3294 -init.c ffd3616 11452 -intr.c e9519537 19813 -io.c feb30d5a 29027 -iob.h fe479ed3 459 -lex.c ffae6a9f 31482 -machdefs.h 4950e5b 659 -main.c 54cb955 17040 -makefile f3877062 2766 -malloc.c 5c2be2a 3422 -mem.c 133c066 4839 -memset.c 17404d52 1964 -misc.c fe327633 18006 -names.c 3123927 19947 -names.h f25436a3 689 -niceprintf.c f976e7dd 9781 -niceprintf.h c31f08c 412 -output.c f0627d49 38529 -output.h edfe9e59 2113 -p1defs.h e4e11c4e 5776 -p1output.c 157a2c7e 12175 -parse.h e457df2e 855 -parse_args.c e01b1fe9 13035 -pccdefs.h 1b4fbbee 1195 -pread.c 5ac0d2 16490 -proc.c 116a13d2 34930 -put.c fe8a1281 9480 -putpcc.c 1cebcba8 40081 -sysdep.c 174741bc 10939 -sysdep.h 1021aa5e 2834 -tokens 194fccfe 727 -usignal.h 1c4ce909 124 -vax.c cf2e339 11030 -version.c 3351b7b 107 -xsum.c e2d50e0b 6437 diff --git a/usr.bin/grep/egrep/egrep.c b/usr.bin/grep/egrep/egrep.c deleted file mode 100644 index 885965c..0000000 --- a/usr.bin/grep/egrep/egrep.c +++ /dev/null @@ -1,924 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)egrep.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - Hybrid Boyer/Moore/Gosper-assisted 'grep/egrep/fgrep' search, with delta0 - table as in original paper (CACM, October, 1977). No delta1 or delta2. - According to experiment (Horspool, Soft. Prac. Exp., 1982), delta2 is of - minimal practical value. However, to improve for worst case input, - integrating the improved Galil strategies (Apostolico/Giancarlo, SIAM. J. - Comput., Feb. 1986) deserves consideration. - - Method: extract longest metacharacter-free string from expression. - this is done using a side-effect from henry spencer's regcomp(). - use boyer-moore to match such, then pass submatching lines - to either regexp() or standard 'egrep', depending on certain - criteria within execstrategy() below. [this tradeoff is due - to the general slowness of the regexp() nondeterministic - machine on complex expressions, as well as the startup time - of standard 'egrep' on short files.] alternatively, one may - change the vendor-supplied 'egrep' automaton to include - boyer-moore directly. see accompanying writeup for discussion - of kanji expression treatment. - - late addition: apply trickbag for fast match of simple - alternations (sublinear, in common low-cardinality cases). - trap fgrep into this lair. - - gnu additions: -f, newline as |, \< and \> [in regexec()], more - comments. inspire better dfa exec() strategy. - serious testing and help with special cases. - - Algorithm amalgam summary: - - dfa e?grep (aho/thompson) - ndfa regexp() (spencer/aho) - bmg (boyer/moore/gosper) - "superimposed" bmg (jaw) - fgrep (aho/corrasick) - - sorry, but the knuth/morris/pratt machine, horspool's - "frequentist" code, and the rabin/karp matcher, however cute, - just don't cut it for this production. - - James A. Woods Copyright (c) 1986 - NASA Ames Research Center -*/ -#include -#include -#include -#include /* must be henry spencer's version */ -#include -#include -#include "pathnames.h" - -#define MIN(A, B) ((A) > (B) ? (B) : (A)) - -#ifdef SLOWSYS -#define read xread -#endif - -#define BUFSIZE 8192 /* make higher for cray */ -#define PATSIZE 6000 -#define LARGE BUFSIZE + PATSIZE - -#define NALT 7 /* tied to scanf() size in alternate() */ -#define NMUSH 6 /* loosely relates to expected alt length */ - -#define FIRSTFEW 33 /* Always do FIRSTFEW matches with regexec() */ -#define PUNTPERCENT 10 /* After FIRSTFEW, if PUNTPERCENT of the input - * was processed by regexp(), exec std egrep. */ -#define NL '\n' -#define EOS '\0' -#define NONASCII 0200 /* Bit mask for Kanji non-ascii chars */ -#define META "\n^$.[]()?+*|\\" /* egrep meta-characters */ -#define SS2 '\216' /* EUC Katakana (or Chinese2) prefix */ -#define SS3 '\217' /* EUC Kanji2 (or Chinese3) prefix */ - -extern char *optarg; -extern int optind; -char *progname; - -int cflag, iflag, eflag, fflag, lflag, nflag; /* SVID flags */ -int sflag, hflag; /* v7, v8, bsd */ - -int firstflag; /* Stop at first match */ -int grepflag; /* Called as "grep" */ -int fgrepflag; /* Called as "fgrep" */ -int altflag; /* Simple alternation in pattern */ -int boyonly; /* No regexp needed -- all simple */ -int flushflag; -int grepold, egrepold, fgrepold; - -int nalt; /* Number of alternatives */ -int nsuccess; /* 1 for match, 2 for error */ -int altmin; /* Minimum length of all the alternate - * strings */ -int firstfile; /* argv index of first file argument */ -int patind; /* argv index of pattern */ -long nmatch; /* Number of matches in this file */ -long incount, counted; /* Amount of input consumed */ -long rxcount; /* Bytes of input processed by regexec() */ -int boyfound; /* accumulated partial matches (tripped by - * FIRSTFEW) */ -int prevmatch; /* next three lines aid fast -n */ -long nline, prevnline; -char *prevloc; - -regexp *rspencer; -char *pattern; -char *patboy; /* Pattern for simple Boyer-Moore */ -char *patfile; /* Filename containing pattern(s) */ - -int delta0[256]; /* Boyer-Moore algorithm core */ -char cmap[256]; /* Usually 0-255, but if -i, maps upper to - * lower case */ -char str[BUFSIZE + 2]; -int nleftover; -char linetemp[BUFSIZE]; -char *altpat[NALT]; /* alternation component storage */ -int altlen[NALT]; -short altset[NMUSH + 1][256]; -char preamble[200]; /* match prefix (filename, line no.) */ - -int fd; -char * -strchr(), *strrchr(), *strcpy(), *strncpy(), *strpbrk(), *malloc(); -char * -grepxlat(), *fold(), *pfile(), *alternate(), *isolate(); -char *gotamatch(), *kanji(), *linesave(), *submatch(); -char **args; - -main(argc, argv) - int argc; - char *argv[]; -{ - int c, oflag; - int errflag = 0; - - args = argv; - - if ((progname = strrchr(argv[0], '/')) != 0) - progname++; - else - progname = argv[0]; - if (strcmp(progname, "grep") == 0) - grepflag++; - else if (strcmp(progname, "fgrep") == 0) - fgrepflag++; - - oflag = 0; - while ((c = getopt(argc, argv, "bchie:f:lnosvwxy1")) != EOF) { - switch (c) { - - case 'f': - fflag++; - patfile = optarg; - continue; - case 'b': - case 'v': - egrepold++; /* boyer-moore of little help here */ - continue; - case 'c': - cflag++; - continue; - case 'e': - eflag++; - pattern = optarg; - continue; - case 'h': - hflag++; - continue; - case 'o': - oflag++; - continue; - case '1': /* Stop at very first match */ - firstflag++; /* spead freaks only */ - continue; - case 'i': - iflag++; - continue; - case 'l': - lflag++; - continue; - case 'n': - nflag++; - continue; - case 's': - sflag++; - continue; - case 'w': - case 'y': - if (!grepflag) - errflag++; - grepold++; - continue; - case 'x': /* needs more work, like -b above */ - if (!fgrepflag) - errflag++; - fgrepold++; - continue; - case '?': - errflag++; - } - } - if (errflag || ((argc <= optind) && !fflag && !eflag)) { - if (grepflag) -oops("usage: grep [-bchilnosvwy] [-e] pattern [file ...]"); - else if (fgrepflag) -oops("usage: fgrep [-bchilnosvx] {-f patfile | [-e] strings} [file ...]"); - else /* encourage SVID options, though we provide - * others */ -oops("usage: egrep [-bchilnosv] {-f patfile | [-e] pattern} [file ...]"); - } - if (fflag) - pattern = pfile(patfile); - else if (!eflag) { - patind = optind; - pattern = argv[optind++]; - } - - if (!oflag && (argc - optind) <= 1) /* Filename invisible given < 2 files */ - hflag++; - if (pattern[0] == EOS) - kernighan(argv); /* same as it ever was */ - /* - * 'grep/egrep' merger -- "old" grep is called to handle: tagged - * exprs \( \), word matches \< and \>, -w and -y options, char - * classes with '-' at end (egrep bug?), and patterns beginning with - * an asterisk (don't ask why). otherwise, characters meaningful to - * 'egrep' but not to 'grep' are escaped; the entire expr is then - * passed to 'egrep'. - */ - if (grepflag && !grepold) { - if (strindex(pattern, "\\(") >= 0 || - strindex(pattern, "\\<") >= 0 || - strindex(pattern, "\\>") >= 0 || - strindex(pattern, "-]") >= 0 || - pattern[0] == '*') /* grep bug */ - grepold++; - else - pattern = grepxlat(pattern); - } - if (grepold || egrepold || fgrepold) - kernighan(argv); - - if (iflag) - strcpy(pattern, fold(pattern)); - /* - * If the pattern is a plain string, just run boyer-moore. If it - * consists of meta-free alternatives, run "superimposed" bmg. - * Otherwise, find best string, and compile pattern for regexec(). - */ - if (strpbrk(pattern, META) == NULL) { /* do boyer-moore only */ - boyonly++; - patboy = pattern; - } else { - if ((patboy = alternate(pattern)) != NULL) - boyonly++; - else { - if ((patboy = isolate(pattern)) == NULL) - kernighan(argv); /* expr too involved */ -#ifndef NOKANJI - for (c = 0; pattern[c] != EOS; c++) - if (pattern[c] & NONASCII) /* kanji + meta */ - kernighan(argv); -#endif - if ((rspencer = regcomp(pattern)) == NULL) - oops("regcomp failure"); - } - } - gosper(patboy); /* "pre-conditioning is wonderful" - * -- v. strassen */ - - if ((firstfile = optind) >= argc) { - /* Grep standard input */ - if (lflag) /* We don't know its name! */ - exit(1); - egsecute((char *) NULL); - } else { - while (optind < argc) { - egsecute(argv[optind]); - optind++; - if (firstflag && (nsuccess == 1)) - break; - } - } - exit((nsuccess == 2) ? 2 : (nsuccess == 0)); -} - -char * -pfile(pfname) /* absorb expression from file */ - char *pfname; -{ - int fd; - struct stat patstat; - static char *pat; - - if ((fd = open(pfname, O_RDONLY, 0)) < 0) - oops("can't read pattern file"); - if (fstat(fd, &patstat) != 0) - oops("can't stat pattern file"); - if (patstat.st_size > PATSIZE) { - if (fgrepflag) { /* defer to unix version */ - fgrepold++; - return "dummy"; - } else - oops("pattern file too big"); - } - if ((pat = malloc((unsigned) patstat.st_size + 1)) == NULL) - oops("out of memory to read pattern file"); - if (patstat.st_size != read(fd, pat, (int)patstat.st_size)) - oops("error reading pattern file"); - (void) close(fd); - - pat[patstat.st_size] = EOS; - if (pat[patstat.st_size - 1] == NL) /* NOP for egrep; helps grep */ - pat[patstat.st_size - 1] = EOS; - - if (nlcount(pat, &pat[patstat.st_size]) > NALT) { - if (fgrepflag) - fgrepold++; /* "what's it all about, alfie?" */ - else - egrepold++; - } - return (pat); -} - -egsecute(file) - char *file; -{ - extern int errno; - - if (file == NULL) - fd = 0; - else if ((fd = open(file, O_RDONLY, 0)) <= 0) { - fprintf(stderr, - "%s: %s: %s\n", progname, file, strerror(errno)); - nsuccess = 2; - return; - } - chimaera(file, patboy); - - if (!boyonly && !flushflag && file != NULL) - flushmatches(); - if (file != NULL) - close(fd); -} - -chimaera(file, pat) /* "reach out and boyer-moore search someone" */ - char *file, *pat; /* -- soon-to-be-popular bumper sticker */ -{ - register char *k, *strend, *s; - register int j, count; - register int *deltazero = delta0; - int patlen = altmin; - char *t; - - nleftover = boyfound = flushflag = 0; - nline = 1L; - prevmatch = 0; - nmatch = counted = rxcount = 0L; - - while ((count = read(fd, str + nleftover, BUFSIZE - nleftover)) > 0) { - - counted += count; - strend = linesave(str, count); - - for (k = str + patlen - 1; k < strend;) { - /* - * for a large class of patterns, upwards of 80% of - * match time is spent on the next line. we beat - * existing microcode (vax 'matchc') this way. - */ - while ((k += deltazero[*(unsigned char *) k]) < strend); - if (k < (str + LARGE)) - break; - k -= LARGE; - - if (altflag) { - /* - * Parallel Boyer-Moore. Check whether each - * of the previous chars COULD be - * from one of the alternative strings. - */ - s = k - 1; - j = altmin; - while (altset[--j][(unsigned char) - cmap[*(unsigned char *) s--]]); - /* - * quick test fails. in this life, compare - * 'em all. but, a "reverse trie" would - * attenuate worst case (linear w/delta2?). - */ - if (--j < 0) { - count = nalt - 1; - do { - s = k; - j = altlen[count]; - t = altpat[count]; - - while - (cmap[*(unsigned char *) s--] - == t[--j]); - if (j < 0) - break; - } - while (count--); - } - } else { - /* One string -- check it */ - j = patlen - 1; - s = k - 1; - while (cmap[*(unsigned char *) s--] == pat[--j]); - } - /* - * delta-less shortcut for literati. short shrift for - * genetic engineers? - */ - if (j >= 0) { - k++; /* no match; restart next char */ - continue; - } - k = submatch(file, pat, str, strend, k, count); - if (k == NULL) - return; - } - if (nflag) { - if (prevmatch) - nline = prevnline + nlcount(prevloc, k); - else - nline = nline + nlcount(str, k); - prevmatch = 0; - } - strncpy(str, linetemp, nleftover); - } - if (cflag) { - /* Bug from old grep: -c overrides -h. We fix the bug. */ - if (!hflag) - printf("%s:", file); - printf("%ld\n", nmatch); - } -} - -char * -linesave(str, count) /* accumulate partial line at end of buffer */ - char str[]; - register int count; -{ - register int j; - - count += nleftover; - if (count != BUFSIZE && fd != 0) - str[count++] = NL; /* insurance for broken last line */ - str[count] = EOS; - for (j = count - 1; str[j] != NL && j >= 0;) - j--; - /* - * break up these lines: long line (> BUFSIZE), last line of file, or - * short return from read(), as from tee(1) input - */ - if (j < 0 && (count == (BUFSIZE - nleftover))) { - str[count++] = NL; - str[count] = EOS; - linetemp[0] = EOS; - nleftover = 0; - return (str + count); - } else { - nleftover = count - j - 1; - strncpy(linetemp, str + j + 1, nleftover); - return (str + j); - } -} - -/* - * Process partial match. First check for mis-aligned Kanji, then match line - * against full compiled r.e. if statistics do not warrant handing off to - * standard egrep. - */ -char * -submatch(file, pat, str, strend, k, altindex) - char file[], pat[], str[]; - register char *strend, *k; - int altindex; -{ - register char *s; - char *t, c; - - t = k; - s = ((altflag) ? k - altlen[altindex] + 1 : k - altmin + 1); -#ifndef NOKANJI - c = ((altflag) ? altpat[altindex][0] : pat[0]); - if (c & NONASCII) - if ((s = kanji(str, s, k)) == NULL) - return (++k); /* reject false kanji */ -#endif - do; - while (*s != NL && --s >= str); - k = s + 1; /* now at line start */ - - if (boyonly) - return (gotamatch(file, k)); - - incount = counted - (strend - k); - if (boyfound++ == FIRSTFEW) - execstrategy(file); - - s = t; - do - rxcount++; - while (*s++ != NL); - *--s = EOS; - /* - * "quick henry -- the flit" (after theodor geisel) - */ - if (regexec(rspencer, ((iflag) ? fold(k) : k)) == 1) { - *s = NL; - if (gotamatch(file, k) == NULL) - return (NULL); - } - *s = NL; - return (s + 1); -} - -#ifndef NOKANJI -/* - * EUC code disambiguation -- scan backwards to first 7-bit code, while - * counting intervening 8-bit codes. If odd, reject unaligned Kanji pattern. - * SS2/3 checks are for intermixed Japanase Katakana or Kanji2. - */ -char * -kanji(str, s, k) - register char *str, *s, *k; -{ - register int j = 0; - - for (s--; s >= str; s--) { - if (*s == SS2 || *s == SS3 || (*s & NONASCII) == 0) - break; - j++; - } -#ifndef CHINESE - if (*s == SS2) - j -= 1; -#endif CHINESE - return ((j & 01) ? NULL : k); -} -#endif - -/* - * Compute "Boyer-Moore" delta table -- put skip distance in delta0[c] - */ -gosper(pattern) - char *pattern; /* ... HAKMEM lives ... */ -{ - register int i, j; - unsigned char c; - - /* Make one-string case look like simple alternatives case */ - if (!altflag) { - nalt = 1; - altmin = altlen[0] = strlen(pattern); - altpat[0] = pattern; - } - /* For chars that aren't in any string, skip by string length. */ - for (j = 0; j < 256; j++) { - delta0[j] = altmin; - cmap[j] = j; /* Sneak in initialization of cmap */ - } - - /* For chars in a string, skip distance from char to end of string. */ - /* (If char appears more than once, skip minimum distance.) */ - for (i = 0; i < nalt; i++) - for (j = 0; j < altlen[i] - 1; j++) { - c = altpat[i][j]; - delta0[c] = MIN(delta0[c], altlen[i] - j - 1); - if (iflag && islower((int) c)) - delta0[toupper((int) c)] = delta0[c]; - } - - /* For last char of each string, fall out of search loop. */ - for (i = 0; i < nalt; i++) { - c = altpat[i][altlen[i] - 1]; - delta0[c] = LARGE; - if (iflag && islower((int) c)) - delta0[toupper((int) c)] = LARGE; - } - if (iflag) - for (j = 'A'; j <= 'Z'; j++) - cmap[j] = tolower((int) j); -} - -/* - * Print, count, or stop on full match. Result is either the location for - * continued search, or NULL to stop. - */ -char * -gotamatch(file, s) - register char *file, *s; -{ - char *savematch(); - int squirrel = 0; /* nonzero to squirrel away FIRSTFEW matches */ - - nmatch++; - nsuccess = 1; - if (!boyonly && boyfound <= FIRSTFEW && file != NULL) - squirrel = 1; - - if (sflag) - return (NULL); /* -s usurps all flags (unlike some versions) */ - if (cflag) { /* -c overrides -l, we guess */ - do; - while (*s++ != NL); - } else if (lflag) { - puts(file); - return (NULL); - } else { - if (!hflag) - if (!squirrel) - printf("%s:", file); - else - (void)sprintf(preamble, "%s:", file); - if (nflag) { - if (prevmatch) - prevnline = prevnline + nlcount(prevloc, s); - else - prevnline = nline + nlcount(str, s); - prevmatch = 1; - - if (!squirrel) - printf("%ld:", prevnline); - else - (void)sprintf(preamble + strlen(preamble), - "%ld:", prevnline); - } - if (!squirrel) { - do - putchar(*s); - while (*s++ != NL); - } else - s = savematch(s); - - if (nflag) - prevloc = s - 1; - } - return ((firstflag && !cflag) ? NULL : s); -} - -char * -fold(line) - char *line; -{ - static char fline[BUFSIZE]; - register char *s, *t = fline; - - for (s = line; *s != EOS; s++) - *t++ = (isupper((int) *s) ? (char) tolower((int) *s) : *s); - *t = EOS; - return (fline); -} - -strindex(s, t) /* the easy way, as in K&P, p. 192 */ - char *s, *t; -{ - int i, n; - - n = strlen(t); - for (i = 0; s[i] != '\0'; i++) - if (strncmp(s + i, t, n) == 0) - return (i); - return (-1); -} - -char * -grepxlat(pattern) /* grep pattern meta conversion */ - char *pattern; -{ - register char *p, *s; - static char newpat[BUFSIZE]; - - for (s = newpat, p = pattern; *p != EOS;) { - if (*p == '\\') { /* skip escapes ... */ - *s++ = *p++; - if (*p) - *s++ = *p++; - } else if (*p == '[') { /* ... and char classes */ - while (*p != EOS && *p != ']') - *s++ = *p++; - } else if (strchr("+?|()", *p) != NULL) { - *s++ = '\\'; /* insert protection */ - *s++ = *p++; - } else - *s++ = *p++; - } - *s = EOS; - grepflag = ((patind) ? 0 : 1); - return (newpat); -} - -/* - * Test for simple alternation. Result is NULL if it's not so simple, or is - * a pointer to the first string if it is. Warning: sscanf size is a - * fixpoint, beyond which the speedup linearity starts to break down. In the - * wake of the elegant aho/corrasick "trie"-based fgrep, generalizing - * altpat[] to arbitrary size is not useful. - */ -char * -alternate(regexpr) - char *regexpr; -{ - register int i, j; - register char *start, *stop; - unsigned char c; - - if (fgrepflag && strchr(regexpr, '|')) - return (NULL); - - /* - * break pattern up into altpat array; delimit on newline, bar, - * or EOS. We know we won't overflow, we've already checked the - * number of patterns we're going to find against NALT. - * Also, set length of pattern and find minimum pattern length. - */ - nalt = 0; - altmin = NMUSH; - for (start = stop = regexpr;; ++stop) - if (!*stop || *stop == '|' || *stop == NL) { - altlen[nalt] = j = stop - start; - if (j < altmin) - altmin = j; - if (!(altpat[nalt] = malloc((u_int)(j + 1)))) - oops("out of memory"); - bcopy(start, altpat[nalt], j); - altpat[nalt][j] = EOS; - ++nalt; - if (!*stop) - break; - if (nalt == NALT) - return(NULL); - if (*stop == NL) - *stop = '|'; - start = stop + 1; - } - if (!fgrepflag) { - if (strchr(regexpr, '|') == NULL || regexpr[0] == '|') - return (NULL); - if (strpbrk(regexpr, "^$.[]()?+*\\") != NULL - || strindex(regexpr, "||") >= 0) - return (NULL); - } - - if (nalt > 1) { /* build superimposed "pre-match" sets per - * char */ - altflag++; - for (j = 0; j < nalt; j++) - for (i = 0; i < altmin; i++) { - c = altpat[j][altlen[j] - altmin + i]; - altset[i + 1][c] = 1; /* offset for sentinel */ - } - } - return (altpat[0]); -} - -/* - * Grapple with the dfa (std egrep) vs. ndfa (regexp) tradeoff. Criteria to - * determine whether to use dfa-based egrep: We do FIRSTFEW matches with - * regexec(). If Boyer-Moore up to now matched more than PUNTPERCENT - * of the input, the r.e. is likely to be underspecified, so do old *grep, - * which is faster on complex patterns than regexp(). At FIRSTFEW, - * dump the saved matches collected by savematch(). They are saved - * so that a "PUNT" can "rewind" to ignore them. Stdin is problematic, - * since it's hard to rewind. - */ - -execstrategy(file) - char *file; -{ - int pctmatch; - - pctmatch = (100 * rxcount) / incount; - if (pctmatch > PUNTPERCENT && file != NULL) - kernighan(args); - if (file != NULL) - flushmatches(); -} - -nlcount(bstart, bstop) /* flail interval to totalize newlines. */ - char *bstart, *bstop; -{ - register char *s = bstart; - register char *t = bstop; - register int count = 0; - - do { /* loop unroll for older architectures */ - if (*t == NL) /* ... ask ames!jaw for sample code */ - count++; - } while (t-- > s); - - return (count); -} - -char * -isolate(regexpr) /* isolate longest metacharacter-free string */ - char *regexpr; -{ - char *dummyexpr; - - /* - * We add (.)* because Henry's regcomp only figures regmust if it - * sees a leading * pattern. Foo! - */ - dummyexpr = malloc((unsigned) strlen(regexpr) + 5); - (void)sprintf(dummyexpr, "(.)*%s", regexpr); - if ((rspencer = regcomp(dummyexpr)) == NULL) - kernighan(args); - return (rspencer->regmust); -} - -char *matches[FIRSTFEW]; -static int mcount = 0; - -char * -savematch(s) /* horde matches during statistics gathering */ - register char *s; -{ - char *p; - char *start = s; - int msize = 0; - int psize = strlen(preamble); - - while (*s++ != NL) - msize++; - *--s = EOS; - - p = malloc((unsigned) msize + 1 + psize); - strcpy(p, preamble); - strcpy(p + psize, start); - matches[mcount++] = p; - - preamble[0] = 0; - *s = NL; - return (s); -} - -flushmatches() -{ - int n; - - flushflag = 1; - for (n = 0; n < mcount; n++) - printf("%s\n", matches[n]); - mcount = 0; -} - -oops(message) - char *message; -{ - fprintf(stderr, "%s: %s\n", progname, message); - exit(2); -} - -kernighan(args) /* "let others do the hard part ..." */ - char *args[]; -{ - /* - * We may have already run grep on some of the files; remove them - * from the arg list we pass on. Note that we can't delete them - * totally because the number of file names affects the output - * (automatic -h). - */ - /* better would be fork/exec per punted file -- jaw */ - - while (firstfile && optind > firstfile) - args[firstfile++] = _PATH_DEVNULL; - if (patind) - args[patind] = pattern; - (void) fflush(stdout); - - if (grepflag) - execvp(_PATH_GREPSTD, args), oops("can't exec old 'grep'"); - else if (fgrepflag) - execvp(_PATH_FGREPSTD, args), oops("can't exec old 'fgrep'"); - else - execvp(_PATH_EGREPSTD, args), oops("can't exec old 'egrep'"); -} diff --git a/usr.bin/grep/egrep/grep.1 b/usr.bin/grep/egrep/grep.1 deleted file mode 100644 index 771cc8c..0000000 --- a/usr.bin/grep/egrep/grep.1 +++ /dev/null @@ -1,250 +0,0 @@ -.\" Copyright (c) 1980, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)grep.1 8.3 (Berkeley) 4/18/94 -.\" -.Dd April 18, 1994 -.Dt GREP 1 -.Os -.Sh NAME -.Nm grep -.Nd file pattern searcher -.Sh SYNOPSIS -.Nm grep -.Op Fl bchilnosvw -.Op Fl e Ar pattern -.Op Ar -.Nm egrep -.Op Fl bchilnosv -.Op Fl e Ar pattern -.Op Fl f Ar pattern_file -.Op Ar -.Nm fgrep -.Op Fl bchilnosvx -.Op Fl e Ar pattern -.Op Fl f Ar pattern_file -.Op Ar -.Sh DESCRIPTION -The -.Nm grep -utilities search the given input files selecting lines -which match one or more patterns; the type of patterns is controlled -by the options specified. -By default, a pattern -matches an input line if any regular expression (RE) in the -pattern matches the input line without its trailing . -A null RE matches every line. -Each input line that matches at -least one of the patterns is written to the standard output. -.Pp -For simple patterns or -.Xr ex 1 -or -.Xr ed 1 -style regular expressions, the -.Nm grep -utility is used. -The -.Nm egrep -utility -can handle extended regular expressions and -embedded s in patterns. -The -.Nm fgrep -utility is quick but can handle only fixed strings. -A fixed string -is a string of characters, -each character -is matched only by itself. -The pattern -value can consist of multiple lines with -embedded s. -In this case, the s -act as alternation characters, allowing any of the -pattern lines to match a portion of the input. -.Pp -The following options are available: -.Pp -.Bl -tag -width indent -.It Fl b -The block number on the disk in which a matched pattern is located -is displayed in front of the respective matched line. -.It Fl c -Only a count of selected lines is written to standard -output. -.It Fl e Ar expression -Specify a pattern used during the search of the -input. -Multiple -.Fl e -options can be used to specify -multiple patterns; an input line is selected if it -matches any of the specified patterns. -.It Fl f Ar pattern_file -The pattern is read from the file named by the -pathname pattern_file. -Trailing newlines -in the pattern_file are ignored. -.Pf ( Nm Egrep -and -.Nm fgrep -only). -.It Fl h -Never print filename headers with output lines. -.It Fl i -The case of letters is ignored in making comparisons \- that is, upper and -lower case are considered identical. -.It Fl l -Only the names of files containing selected lines -are written to standard output. -Pathnames are -listed once per file searched. -If the standard -input is searched, the pathname -.Sq Fl -is written. -.It Fl n -Each output line is preceded by its relative line -number in the file; each file starting at line 1. -The line number counter is reset for each file processed. -This option is ignored if -.Fl c , -.Fl l , -or -.Fl s -is -specified. -.It Fl o -Always print filename headers with output lines. -.It Fl s -Silent mode. Nothing is printed (except error messages). -This is useful for checking the error status. -.It Fl v -Selected lines are those -.Em not -matching the specified -patterns. -.It Fl x -Only input lines selected against an entire fixed -string or regular expression are considered to be -matching lines. -.Pf ( Nm Fgrep -only). -.It Fl w -The expression is searched for as a word -(as if surrounded by `\e<' and `\e>', see -.Xr ex 1 . ) -.Pf ( Nm Grep -only) -.Pp -.El -If no file arguments are specified, the -standard input is used. -.Pp -The -.Nm grep -utility exits with one of the following values: -.Pp -.Bl -tag -width flag -compact -.It Li 0 -One or more lines were selected. -.It Li 1 -No lines were selected. -.It Li >1 -An error occurred. -.El -.Sh EXTENDED REGULAR EXPRESSIONS -The following characters are interpreted by -.Nm egrep : -.Pp -.Bl -tag -width flag -compact -.It Cm \&$ -Align the match from the end of the line. -.It Cm \&^ -Align the match from the beginning of the line. -.It Cm \&| -Add another pattern (see example below). -.It Cm \&? -Match 1 or less sequential repetitions of the pattern. -.It Cm \&+ -Match 1 or more sequential repetitions of the pattern. -.It Cm \&* -Match 0 or more sequential repetitions of the pattern. -.It Cm \&[] -Match any single character or range of characters -enclosed in the brackets. -.It Cm \&\e -Escape special characters which have meaning to -.Nm egrep , -the set of {$,.,^,[,],|,?,+,*,(,)}. -.El -.Sh EXAMPLES -To find all occurrences of the word patricia in a file: -.Pp -.Dl grep patricia myfile -.Pp -To find all occurrences of the pattern -.Ql \&.Pp -at the beginning of a line: -.Pp -.Dl grep '^\e.Pp' -.Pp -The apostrophes assure the entire expression is evaluated by -.Nm grep -instead of by the -users shell. -The carat or hat -.Ql Li \&^ -means -.Em from the beginning of a line , -and the -.Ql Li \&\e -escapes the -.Ql Li \&. -which would otherwise match any character. -.Pp -A simple example of an extended regular expression: -.Pp -.Dl egrep '19|20|25' calendar -.Pp -Peruses the file calendar looking for either 19, 20 -or 25. -.Sh SEE ALSO -.Xr ed 1 , -.Xr ex 1 , -.Xr sed 1 -.Sh HISTORY -The -.Nm grep -command appeared in -.At v6 . -.Sh BUGS -Lines are limited to 256 characters; longer lines are truncated. diff --git a/usr.bin/grep/egrep/pathnames.h b/usr.bin/grep/egrep/pathnames.h deleted file mode 100644 index a25b3dc..0000000 --- a/usr.bin/grep/egrep/pathnames.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - */ - -#include - -#define _PATH_EGREPSTD "/usr/libexec/old.egrep" -#define _PATH_GREPSTD "/usr/libexec/old.bin.grep" -#define _PATH_FGREPSTD "/usr/libexec/old.fgrep" diff --git a/usr.bin/ld/Makefile b/usr.bin/ld/Makefile deleted file mode 100644 index 834a5c9..0000000 --- a/usr.bin/ld/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= ld -SRCS= ld.c cplus-dem.c -NOMAN= noman - -.include diff --git a/usr.bin/ld/cplus-dem.c b/usr.bin/ld/cplus-dem.c deleted file mode 100644 index b2e3050..0000000 --- a/usr.bin/ld/cplus-dem.c +++ /dev/null @@ -1,970 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - */ - -#ifndef lint -static char sccsid[] = "@(#)cplus-dem.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* Demangler for GNU C++ - Copyright (C) 1989 Free Software Foundation, Inc. - written by James Clark (jjc@jclark.uucp) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 1, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This is for g++ 1.36.1 (November 6 version). It will probably - require changes for any other version. - - Modified for g++ 1.36.2 (November 18 version). */ - -/* This file exports one function - - char *cplus_demangle (const char *name) - - If `name' is a mangled function name produced by g++, then - a pointer to a malloced string giving a C++ representation - of the name will be returned; otherwise NULL will be returned. - It is the caller's responsibility to free the string which - is returned. - - For example, - - cplus_demangle ("_foo__1Ai") - - returns - - "A::foo(int)" - - This file imports xmalloc and xrealloc, which are like malloc and - realloc except that they generate a fatal error if there is no - available memory. */ - -/* #define nounderscore 1 /* define this is names don't start with _ */ - -#include -#include - -#ifdef USG -#include -#include -#else -#include -#define memcpy(s1, s2, n) bcopy ((s2), (s1), (n)) -#define memcmp(s1, s2, n) bcmp ((s2), (s1), (n)) -#define strchr index -#define strrchr rindex -#endif - -#ifdef __STDC__ -extern char *cplus_demangle (const char *type); -#else -extern char *cplus_demangle (); -#endif - -#ifdef __STDC__ -extern char *xmalloc (int); -extern char *xrealloc (char *, int); -#else -extern char *xmalloc (); -extern char *xrealloc (); -#endif - -static char **typevec = 0; -static int ntypes = 0; -static int typevec_size = 0; - -static struct { - const char *in; - const char *out; -} optable[] = { - "new", " new", - "delete", " delete", - "ne", "!=", - "eq", "==", - "ge", ">=", - "gt", ">", - "le", "<=", - "lt", "<", - "plus", "+", - "minus", "-", - "mult", "*", - "convert", "+", /* unary + */ - "negate", "-", /* unary - */ - "trunc_mod", "%", - "trunc_div", "/", - "truth_andif", "&&", - "truth_orif", "||", - "truth_not", "!", - "postincrement", "++", - "postdecrement", "--", - "bit_ior", "|", - "bit_xor", "^", - "bit_and", "&", - "bit_not", "~", - "call", "()", - "cond", "?:", - "alshift", "<<", - "arshift", ">>", - "component", "->", - "indirect", "*", - "method_call", "->()", - "addr", "&", /* unary & */ - "array", "[]", - "nop", "", /* for operator= */ -}; - -/* Beware: these aren't '\0' terminated. */ - -typedef struct { - char *b; /* pointer to start of string */ - char *p; /* pointer after last character */ - char *e; /* pointer after end of allocated space */ -} string; - -#ifdef __STDC__ -static void string_need (string *s, int n); -static void string_delete (string *s); -static void string_init (string *s); -static void string_clear (string *s); -static int string_empty (string *s); -static void string_append (string *p, const char *s); -static void string_appends (string *p, string *s); -static void string_appendn (string *p, const char *s, int n); -static void string_prepend (string *p, const char *s); -#if 0 -static void string_prepends (string *p, string *s); -#endif -static void string_prependn (string *p, const char *s, int n); -static int get_count (const char **type, int *count); -static int do_args (const char **type, string *decl); -static int do_type (const char **type, string *result); -static int do_arg (const char **type, string *result); -static int do_args (const char **type, string *decl); -static void munge_function_name (string *name); -static void remember_type (const char *type, int len); -#else -static void string_need (); -static void string_delete (); -static void string_init (); -static void string_clear (); -static int string_empty (); -static void string_append (); -static void string_appends (); -static void string_appendn (); -static void string_prepend (); -static void string_prepends (); -static void string_prependn (); -static int get_count (); -static int do_args (); -static int do_type (); -static int do_arg (); -static int do_args (); -static void munge_function_name (); -static void remember_type (); -#endif - -char * -cplus_demangle (type) - const char *type; -{ - string decl; - int n; - int success = 0; - int constructor = 0; - int const_flag = 0; - int i; - const char *p; -#ifndef LONGERNAMES - const char *premangle; -#endif - - if (type == NULL || *type == '\0') - return NULL; -#ifndef nounderscore - if (*type++ != '_') - return NULL; -#endif - p = type; - while (*p != '\0' && !(*p == '_' && p[1] == '_')) - p++; - if (*p == '\0') - { - /* destructor */ - if (type[0] == '_' && type[1] == '$' && type[2] == '_') - { - int n = (strlen (type) - 3)*2 + 3 + 2 + 1; - char *tem = (char *) xmalloc (n); - strcpy (tem, type + 3); - strcat (tem, "::~"); - strcat (tem, type + 3); - strcat (tem, "()"); - return tem; - } - /* static data member */ - if (*type != '_' && (p = strchr (type, '$')) != NULL) - { - int n = strlen (type) + 2; - char *tem = (char *) xmalloc (n); - memcpy (tem, type, p - type); - strcpy (tem + (p - type), "::"); - strcpy (tem + (p - type) + 2, p + 1); - return tem; - } - /* virtual table */ - if (type[0] == '_' && type[1] == 'v' && type[2] == 't' && type[3] == '$') - { - int n = strlen (type + 4) + 14 + 1; - char *tem = (char *) xmalloc (n); - strcpy (tem, type + 4); - strcat (tem, " virtual table"); - return tem; - } - return NULL; - } - - string_init (&decl); - - if (p == type) - { - if (!isdigit (p[2])) - { - string_delete (&decl); - return NULL; - } - constructor = 1; - } - else - { - string_appendn (&decl, type, p - type); - munge_function_name (&decl); - } - p += 2; - -#ifndef LONGERNAMES - premangle = p; -#endif - switch (*p) - { - case 'C': - /* a const member function */ - if (!isdigit (p[1])) - { - string_delete (&decl); - return NULL; - } - p += 1; - const_flag = 1; - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (strlen (p) < n) - { - string_delete (&decl); - return NULL; - } - if (constructor) - { - string_appendn (&decl, p, n); - string_append (&decl, "::"); - string_appendn (&decl, p, n); - } - else - { - string_prepend (&decl, "::"); - string_prependn (&decl, p, n); - } - p += n; -#ifndef LONGERNAMES - remember_type (premangle, p - premangle); -#endif - success = do_args (&p, &decl); - if (const_flag) - string_append (&decl, " const"); - break; - case 'F': - p += 1; - success = do_args (&p, &decl); - break; - } - - for (i = 0; i < ntypes; i++) - if (typevec[i] != NULL) - free (typevec[i]); - ntypes = 0; - if (typevec != NULL) - { - free ((char *)typevec); - typevec = NULL; - typevec_size = 0; - } - - if (success) - { - string_appendn (&decl, "", 1); - return decl.b; - } - else - { - string_delete (&decl); - return NULL; - } -} - -static int -get_count (type, count) - const char **type; - int *count; -{ - if (!isdigit (**type)) - return 0; - *count = **type - '0'; - *type += 1; - /* see flush_repeats in cplus-method.c */ - if (isdigit (**type)) - { - const char *p = *type; - int n = *count; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (*p == '_') - { - *type = p + 1; - *count = n; - } - } - return 1; -} - -/* result will be initialised here; it will be freed on failure */ - -static int -do_type (type, result) - const char **type; - string *result; -{ - int n; - int done; - int non_empty = 0; - int success; - string decl; - const char *remembered_type; - - string_init (&decl); - string_init (result); - - done = 0; - success = 1; - while (success && !done) - { - int member; - switch (**type) - { - case 'P': - *type += 1; - string_prepend (&decl, "*"); - break; - - case 'R': - *type += 1; - string_prepend (&decl, "&"); - break; - - case 'T': - *type += 1; - if (!get_count (type, &n) || n >= ntypes) - success = 0; - else - { - remembered_type = typevec[n]; - type = &remembered_type; - } - break; - - case 'F': - *type += 1; - if (!string_empty (&decl) && decl.b[0] == '*') - { - string_prepend (&decl, "("); - string_append (&decl, ")"); - } - if (!do_args (type, &decl) || **type != '_') - success = 0; - else - *type += 1; - break; - - case 'M': - case 'O': - { - int constp = 0; - int volatilep = 0; - - member = **type == 'M'; - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - string_append (&decl, ")"); - string_prepend (&decl, "::"); - string_prependn (&decl, *type, n); - string_prepend (&decl, "("); - *type += n; - if (member) - { - if (**type == 'C') - { - *type += 1; - constp = 1; - } - if (**type == 'V') - { - *type += 1; - volatilep = 1; - } - if (*(*type)++ != 'F') - { - success = 0; - break; - } - } - if ((member && !do_args (type, &decl)) || **type != '_') - { - success = 0; - break; - } - *type += 1; - if (constp) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "const"); - } - if (volatilep) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "volatilep"); - } - break; - } - - case 'C': - if ((*type)[1] == 'P') - { - *type += 1; - if (!string_empty (&decl)) - string_prepend (&decl, " "); - string_prepend (&decl, "const"); - break; - } - - /* fall through */ - default: - done = 1; - break; - } - } - - done = 0; - non_empty = 0; - while (success && !done) - { - switch (**type) - { - case 'C': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "const"); - break; - case 'U': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "unsigned"); - break; - case 'V': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "volatile"); - break; - default: - done = 1; - break; - } - } - - if (success) - switch (**type) - { - case '\0': - case '_': - break; - case 'v': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "void"); - break; - case 'x': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long long"); - break; - case 'l': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long"); - break; - case 'i': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "int"); - break; - case 's': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "short"); - break; - case 'c': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "char"); - break; - case 'r': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long double"); - break; - case 'd': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "double"); - break; - case 'f': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "float"); - break; - case 'G': - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - if (non_empty) - string_append (result, " "); - string_appendn (result, *type, n); - *type += n; - break; - default: - success = 0; - break; - } - - if (success) - { - if (!string_empty (&decl)) - { - string_append (result, " "); - string_appends (result, &decl); - } - string_delete (&decl); - return 1; - } - else - { - string_delete (&decl); - string_delete (result); - return 0; - } -} - -/* `result' will be initialised in do_type; it will be freed on failure */ - -static int -do_arg (type, result) - const char **type; - string *result; -{ - const char *start = *type; - - if (!do_type (type, result)) - return 0; - remember_type (start, *type - start); - return 1; -} - -static void -remember_type (start, len) - const char *start; - int len; -{ - char *tem; - - if (ntypes >= typevec_size) - { - if (typevec_size == 0) - { - typevec_size = 3; - typevec = (char **) xmalloc (sizeof (char*)*typevec_size); - } - else - { - typevec_size *= 2; - typevec = (char **) xrealloc ((char *)typevec, sizeof (char*)*typevec_size); - } - } - tem = (char *) xmalloc (len + 1); - memcpy (tem, start, len); - tem[len] = '\0'; - typevec[ntypes++] = tem; -} - -/* `decl' must be already initialised, usually non-empty; - it won't be freed on failure */ - -static int -do_args (type, decl) - const char **type; - string *decl; -{ - string arg; - int need_comma = 0; - - string_append (decl, "("); - - while (**type != '_' && **type != '\0' && **type != 'e' && **type != 'v') - { - if (**type == 'N') - { - int r; - int t; - *type += 1; - if (!get_count (type, &r) || !get_count (type, &t) || t >= ntypes) - return 0; - while (--r >= 0) - { - const char *tem = typevec[t]; - if (need_comma) - string_append (decl, ", "); - if (!do_arg (&tem, &arg)) - return 0; - string_appends (decl, &arg); - string_delete (&arg); - need_comma = 1; - } - } - else - { - if (need_comma) - string_append (decl, ", "); - if (!do_arg (type, &arg)) - return 0; - string_appends (decl, &arg); - string_delete (&arg); - need_comma = 1; - } - } - - if (**type == 'v') - *type += 1; - else if (**type == 'e') - { - *type += 1; - if (need_comma) - string_append (decl, ","); - string_append (decl, "..."); - } - - string_append (decl, ")"); - return 1; -} - -static void -munge_function_name (name) - string *name; -{ - if (!string_empty (name) && name->p - name->b >= 3 - && name->b[0] == 'o' && name->b[1] == 'p' && name->b[2] == '$') - { - int i; - /* see if it's an assignment expression */ - if (name->p - name->b >= 10 /* op$assign_ */ - && memcmp (name->b + 3, "assign_", 7) == 0) - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 10; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 10, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - string_append (name, "="); - return; - } - } - } - else - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 3; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 3, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - return; - } - } - } - return; - } - else if (!string_empty (name) && name->p - name->b >= 5 - && memcmp (name->b, "type$", 5) == 0) - { - /* type conversion operator */ - string type; - const char *tem = name->b + 5; - if (do_type (&tem, &type)) - { - string_clear (name); - string_append (name, "operator "); - string_appends (name, &type); - string_delete (&type); - return; - } - } -} - -/* a mini string-handling package */ - -static void -string_need (s, n) - string *s; - int n; -{ - if (s->b == NULL) - { - if (n < 32) - n = 32; - s->p = s->b = (char *) xmalloc (n); - s->e = s->b + n; - } - else if (s->e - s->p < n) - { - int tem = s->p - s->b; - n += tem; - n *= 2; - s->b = (char *) xrealloc (s->b, n); - s->p = s->b + tem; - s->e = s->b + n; - } -} - -static void -string_delete (s) - string *s; -{ - if (s->b != NULL) - { - free (s->b); - s->b = s->e = s->p = NULL; - } -} - -static void -string_init (s) - string *s; -{ - s->b = s->p = s->e = NULL; -} - -static void -string_clear (s) - string *s; -{ - s->p = s->b; -} - -static int -string_empty (s) - string *s; -{ - return s->b == s->p; -} - -static void -string_append (p, s) - string *p; - const char *s; -{ - int n; - if (s == NULL || *s == '\0') - return; - n = strlen (s); - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_appends (p, s) - string *p, *s; -{ - int n; - if (s->b == s->p) - return; - n = s->p - s->b; - string_need (p, n); - memcpy (p->p, s->b, n); - p->p += n; -} - -static void -string_appendn (p, s, n) - string *p; - const char *s; - int n; -{ - if (n == 0) - return; - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_prepend (p, s) - string *p; - const char *s; -{ - if (s == NULL || *s == '\0') - return; - string_prependn (p, s, strlen (s)); -} - -#if 0 -static void -string_prepends (p, s) - string *p, *s; -{ - if (s->b == s->p) - return; - string_prependn (p, s->b, s->p - s->b); -} -#endif - -static void -string_prependn (p, s, n) - string *p; - const char *s; - int n; -{ - char *q; - - if (n == 0) - return; - string_need (p, n); - for (q = p->p - 1; q >= p->b; q--) - q[n] = q[0]; - memcpy (p->b, s, n); - p->p += n; -} diff --git a/usr.bin/ld/ld.c b/usr.bin/ld/ld.c deleted file mode 100644 index f0b35f2..0000000 --- a/usr.bin/ld/ld.c +++ /dev/null @@ -1,4718 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - */ - -#ifndef lint -static char sccsid[] = "@(#)ld.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* Linker `ld' for GNU - Copyright (C) 1988 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 1, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Written by Richard Stallman with some help from Eric Albert. - Set, indirect, and warning symbol features added by Randy Smith. */ - -/* Define how to initialize system-dependent header fields. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* symseg.h defines the obsolete GNU debugging format; we should nuke it. */ -#define CORE_ADDR unsigned long /* For symseg.h */ -#include "symseg.h" - -#define N_SET_MAGIC(exec, val) ((exec).a_magic = val) - -/* If compiled with GNU C, use the built-in alloca */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#endif - -#define min(a,b) ((a) < (b) ? (a) : (b)) - -/* Macro to control the number of undefined references printed */ -#define MAX_UREFS_PRINTED 10 - -/* Size of a page; obtained from the operating system. */ - -int page_size; - -/* Name this program was invoked by. */ - -char *progname; - -/* System dependencies */ - -/* Define this to specify the default executable format. */ - -#ifndef DEFAULT_MAGIC -#define DEFAULT_MAGIC ZMAGIC -#endif - -#if defined(hp300) || defined(luna68k) -#define INITIALIZE_HEADER outheader.a_mid = MID_HP300 -#endif - -#ifdef sparc -#ifndef sun -#define sun 1 -#endif -#define INITIALIZE_HEADER \ - (outheader.a_mid = MID_SUN_SPARC, outheader.a_toolversion = 1) -#endif - -/* - * Ok. Following are the relocation information macros. If your - * system should not be able to use the default set (below), you must - * define the following: - - * relocation_info: This must be typedef'd (or #define'd) to the type - * of structure that is stored in the relocation info section of your - * a.out files. Often this is defined in the a.out.h for your system. - * - * RELOC_ADDRESS (rval): Offset into the current section of the - * to be relocated. *Must be an lvalue*. - * - * RELOC_EXTERN_P (rval): Is this relocation entry based on an - * external symbol (1), or was it fully resolved upon entering the - * loader (0) in which case some combination of the value in memory - * (if RELOC_MEMORY_ADD_P) and the extra (if RELOC_ADD_EXTRA) contains - * what the value of the relocation actually was. *Must be an lvalue*. - * - * RELOC_TYPE (rval): If this entry was fully resolved upon - * entering the loader, what type should it be relocated as? - * - * RELOC_SYMBOL (rval): If this entry was not fully resolved upon - * entering the loader, what is the index of it's symbol in the symbol - * table? *Must be a lvalue*. - * - * RELOC_MEMORY_ADD_P (rval): This should return true if the final - * relocation value output here should be added to memory, or if the - * section of memory described should simply be set to the relocation - * value. - * - * RELOC_ADD_EXTRA (rval): (Optional) This macro, if defined, gives - * an extra value to be added to the relocation value based on the - * individual relocation entry. *Must be an lvalue if defined*. - * - * RELOC_PCREL_P (rval): True if the relocation value described is - * pc relative. - * - * RELOC_VALUE_RIGHTSHIFT (rval): Number of bits right to shift the - * final relocation value before putting it where it belongs. - * - * RELOC_TARGET_SIZE (rval): log to the base 2 of the number of - * bytes of size this relocation entry describes; 1 byte == 0; 2 bytes - * == 1; 4 bytes == 2, and etc. This is somewhat redundant (we could - * do everything in terms of the bit operators below), but having this - * macro could end up producing better code on machines without fancy - * bit twiddling. Also, it's easier to understand/code big/little - * endian distinctions with this macro. - * - * RELOC_TARGET_BITPOS (rval): The starting bit position within the - * object described in RELOC_TARGET_SIZE in which the relocation value - * will go. - * - * RELOC_TARGET_BITSIZE (rval): How many bits are to be replaced - * with the bits of the relocation value. It may be assumed by the - * code that the relocation value will fit into this many bits. This - * may be larger than RELOC_TARGET_SIZE if such be useful. - * - * - * Things I haven't implemented - * ---------------------------- - * - * Values for RELOC_TARGET_SIZE other than 0, 1, or 2. - * - * Pc relative relocation for External references. - * - * - */ - -/* The following #if has been modifed for cross compilation */ -/* It originally read: #if defined(sun) && defined(sparc) */ -/* Marc Ullman, Stanford University Nov. 1 1989 */ -#if defined(sun) && (TARGET == SUN4) -/* Sparc (Sun 4) macros */ -#undef relocation_info -#define relocation_info reloc_info_sparc -#define RELOC_ADDRESS(r) ((r)->r_address) -#define RELOC_EXTERN_P(r) ((r)->r_extern) -#define RELOC_TYPE(r) ((r)->r_index) -#define RELOC_SYMBOL(r) ((r)->r_index) -#define RELOC_MEMORY_SUB_P(r) 0 -#define RELOC_MEMORY_ADD_P(r) 0 -#define RELOC_ADD_EXTRA(r) ((r)->r_addend) -#define RELOC_PCREL_P(r) \ - ((r)->r_type >= RELOC_DISP8 && (r)->r_type <= RELOC_WDISP22) -#define RELOC_VALUE_RIGHTSHIFT(r) (reloc_target_rightshift[(r)->r_type]) -#define RELOC_TARGET_SIZE(r) (reloc_target_size[(r)->r_type]) -#define RELOC_TARGET_BITPOS(r) 0 -#define RELOC_TARGET_BITSIZE(r) (reloc_target_bitsize[(r)->r_type]) - -/* Note that these are very dependent on the order of the enums in - enum reloc_type (in a.out.h); if they change the following must be - changed */ -/* Also note that the last few may be incorrect; I have no information */ -static int reloc_target_rightshift[] = { - 0, 0, 0, 0, 0, 0, 2, 2, 10, 0, 0, 0, 0, 0, 0, -}; -static int reloc_target_size[] = { - 0, 1, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -}; -static int reloc_target_bitsize[] = { - 8, 16, 32, 8, 16, 32, 30, 22, 22, 22, 13, 10, 32, 32, 16, -}; - -#define MAX_ALIGNMENT (sizeof (double)) -#endif - -/* Default macros */ -#ifndef RELOC_ADDRESS -#define RELOC_ADDRESS(r) ((r)->r_address) -#define RELOC_EXTERN_P(r) ((r)->r_extern) -#define RELOC_TYPE(r) ((r)->r_symbolnum) -#define RELOC_SYMBOL(r) ((r)->r_symbolnum) -#define RELOC_MEMORY_SUB_P(r) 0 -#define RELOC_MEMORY_ADD_P(r) 1 -#undef RELOC_ADD_EXTRA -#define RELOC_PCREL_P(r) ((r)->r_pcrel) -#define RELOC_VALUE_RIGHTSHIFT(r) 0 -#define RELOC_TARGET_SIZE(r) ((r)->r_length) -#define RELOC_TARGET_BITPOS(r) 0 -#define RELOC_TARGET_BITSIZE(r) 32 -#endif - -#ifndef MAX_ALIGNMENT -#define MAX_ALIGNMENT (sizeof (int)) -#endif - -#ifdef nounderscore -#define LPREFIX '.' -#else -#define LPREFIX 'L' -#endif - -#ifndef TEXT_START -#define TEXT_START(x) N_TXTADDR(x) -#endif - -/* Special global symbol types understood by GNU LD. */ - -/* The following type indicates the definition of a symbol as being - an indirect reference to another symbol. The other symbol - appears as an undefined reference, immediately following this symbol. - - Indirection is asymmetrical. The other symbol's value will be used - to satisfy requests for the indirect symbol, but not vice versa. - If the other symbol does not have a definition, libraries will - be searched to find a definition. - - So, for example, the following two lines placed in an assembler - input file would result in an object file which would direct gnu ld - to resolve all references to symbol "foo" as references to symbol - "bar". - - .stabs "_foo",11,0,0,0 - .stabs "_bar",1,0,0,0 - - Note that (11 == (N_INDR | N_EXT)) and (1 == (N_UNDF | N_EXT)). */ - -#ifndef N_INDR -#define N_INDR 0xa -#endif - -/* The following symbols refer to set elements. These are expected - only in input to the loader; they should not appear in loader - output (unless relocatable output is requested). To be recognized - by the loader, the input symbols must have their N_EXT bit set. - All the N_SET[ATDB] symbols with the same name form one set. The - loader collects all of these elements at load time and outputs a - vector for each name. - Space (an array of 32 bit words) is allocated for the set in the - data section, and the n_value field of each set element value is - stored into one word of the array. - The first word of the array is the length of the set (number of - elements). The last word of the vector is set to zero for possible - use by incremental loaders. The array is ordered by the linkage - order; the first symbols which the linker encounters will be first - in the array. - - In C syntax this looks like: - - struct set_vector { - unsigned int length; - unsigned int vector[length]; - unsigned int always_zero; - }; - - Before being placed into the array, each element is relocated - according to its type. This allows the loader to create an array - of pointers to objects automatically. N_SETA type symbols will not - be relocated. - - The address of the set is made into an N_SETV symbol - whose name is the same as the name of the set. - This symbol acts like a N_DATA global symbol - in that it can satisfy undefined external references. - - For the purposes of determining whether or not to load in a library - file, set element definitions are not considered "real - definitions"; they will not cause the loading of a library - member. - - If relocatable output is requested, none of this processing is - done. The symbols are simply relocated and passed through to the - output file. - - So, for example, the following three lines of assembler code - (whether in one file or scattered between several different ones) - will produce a three element vector (total length is five words; - see above), referenced by the symbol "_xyzzy", which will have the - addresses of the routines _init1, _init2, and _init3. - - *NOTE*: If symbolic addresses are used in the n_value field of the - defining .stabs, those symbols must be defined in the same file as - that containing the .stabs. - - .stabs "_xyzzy",23,0,0,_init1 - .stabs "_xyzzy",23,0,0,_init2 - .stabs "_xyzzy",23,0,0,_init3 - - Note that (23 == (N_SETT | N_EXT)). */ - -#ifndef N_SETA -#define N_SETA 0x14 /* Absolute set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETT -#define N_SETT 0x16 /* Text set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETD -#define N_SETD 0x18 /* Data set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETB -#define N_SETB 0x1A /* Bss set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -/* Macros dealing with the set element symbols defined in a.out.h */ -#define SET_ELEMENT_P(x) ((x)>=N_SETA&&(x)<=(N_SETB|N_EXT)) -#define TYPE_OF_SET_ELEMENT(x) ((x)-N_SETA+N_ABS) - -#ifndef N_SETV -#define N_SETV 0x1C /* Pointer to set vector in data area. */ -#endif /* This is output from LD. */ - -/* If a this type of symbol is encountered, its name is a warning - message to print each time the symbol referenced by the next symbol - table entry is referenced. - - This feature may be used to allow backwards compatibility with - certain functions (eg. gets) but to discourage programmers from - their use. - - So if, for example, you wanted to have ld print a warning whenever - the function "gets" was used in their C program, you would add the - following to the assembler file in which gets is defined: - - .stabs "Obsolete function \"gets\" referenced",30,0,0,0 - .stabs "_gets",1,0,0,0 - - These .stabs do not necessarily have to be in the same file as the - gets function, they simply must exist somewhere in the compilation. */ - -#ifndef N_WARNING -#define N_WARNING 0x1E /* Warning message to print if symbol - included */ -#endif /* This is input to ld */ - -#ifndef __GNU_STAB__ - -/* Line number for the data section. This is to be used to describe - the source location of a variable declaration. */ -#ifndef N_DSLINE -#define N_DSLINE (N_SLINE+N_DATA-N_TEXT) -#endif - -/* Line number for the bss section. This is to be used to describe - the source location of a variable declaration. */ -#ifndef N_BSLINE -#define N_BSLINE (N_SLINE+N_BSS-N_TEXT) -#endif - -#endif /* not __GNU_STAB__ */ - -/* Symbol table */ - -/* Global symbol data is recorded in these structures, - one for each global symbol. - They are found via hashing in 'symtab', which points to a vector of buckets. - Each bucket is a chain of these structures through the link field. */ - -typedef - struct glosym - { - /* Pointer to next symbol in this symbol's hash bucket. */ - struct glosym *link; - /* Name of this symbol. */ - char *name; - /* Value of this symbol as a global symbol. */ - long value; - /* Chain of external 'nlist's in files for this symbol, both defs - and refs. */ - struct nlist *refs; - /* Any warning message that might be associated with this symbol - from an N_WARNING symbol encountered. */ - char *warning; - /* Nonzero means definitions of this symbol as common have been seen, - and the value here is the largest size specified by any of them. */ - int max_common_size; - /* For relocatable_output, records the index of this global sym in the - symbol table to be written, with the first global sym given index 0.*/ - int def_count; - /* Nonzero means a definition of this global symbol is known to exist. - Library members should not be loaded on its account. */ - char defined; - /* Nonzero means a reference to this global symbol has been seen - in a file that is surely being loaded. - A value higher than 1 is the n_type code for the symbol's - definition. */ - char referenced; - /* A count of the number of undefined references printed for a - specific symbol. If a symbol is unresolved at the end of - digest_symbols (and the loading run is supposed to produce - relocatable output) do_file_warnings keeps track of how many - unresolved reference error messages have been printed for - each symbol here. When the number hits MAX_UREFS_PRINTED, - messages stop. */ - unsigned char undef_refs; - /* 1 means that this symbol has multiple definitions. 2 means - that it has multiple definitions, and some of them are set - elements, one of which has been printed out already. */ - unsigned char multiply_defined; - /* Nonzero means print a message at all refs or defs of this symbol */ - char trace; - } - symbol; - -/* Demangler for C++. */ -extern char *cplus_demangle (); - -/* Demangler function to use. */ -char *(*demangler)() = NULL; - -/* Number of buckets in symbol hash table */ -#define TABSIZE 1009 - -/* The symbol hash table: a vector of TABSIZE pointers to struct glosym. */ -symbol *symtab[TABSIZE]; - -/* Number of symbols in symbol hash table. */ -int num_hash_tab_syms = 0; - -/* Count the number of nlist entries that are for local symbols. - This count and the three following counts - are incremented as as symbols are entered in the symbol table. */ -int local_sym_count; - -/* Count number of nlist entries that are for local symbols - whose names don't start with L. */ -int non_L_local_sym_count; - -/* Count the number of nlist entries for debugger info. */ -int debugger_sym_count; - -/* Count the number of global symbols referenced and not defined. */ -int undefined_global_sym_count; - -/* Count the number of global symbols multiply defined. */ -int multiple_def_count; - -/* Count the number of defined global symbols. - Each symbol is counted only once - regardless of how many different nlist entries refer to it, - since the output file will need only one nlist entry for it. - This count is computed by `digest_symbols'; - it is undefined while symbols are being loaded. */ -int defined_global_sym_count; - -/* Count the number of symbols defined through common declarations. - This count is kept in symdef_library, linear_library, and - enter_global_ref. It is incremented when the defined flag is set - in a symbol because of a common definition, and decremented when - the symbol is defined "for real" (ie. by something besides a common - definition). */ -int common_defined_global_count; - -/* Count the number of set element type symbols and the number of - separate vectors which these symbols will fit into. See the - GNU a.out.h for more info. - This count is computed by 'enter_file_symbols' */ -int set_symbol_count; -int set_vector_count; - -/* Define a linked list of strings which define symbols which should - be treated as set elements even though they aren't. Any symbol - with a prefix matching one of these should be treated as a set - element. - - This is to make up for deficiencies in many assemblers which aren't - willing to pass any stabs through to the loader which they don't - understand. */ -struct string_list_element { - char *str; - struct string_list_element *next; -}; - -struct string_list_element *set_element_prefixes; - -/* Count the number of definitions done indirectly (ie. done relative - to the value of some other symbol. */ -int global_indirect_count; - -/* Count the number of warning symbols encountered. */ -int warning_count; - -/* Total number of symbols to be written in the output file. - Computed by digest_symbols from the variables above. */ -int nsyms; - - -/* Nonzero means ptr to symbol entry for symbol to use as start addr. - -e sets this. */ -symbol *entry_symbol; - -symbol *edata_symbol; /* the symbol _edata */ -symbol *etext_symbol; /* the symbol _etext */ -symbol *end_symbol; /* the symbol _end */ - -/* Each input file, and each library member ("subfile") being loaded, - has a `file_entry' structure for it. - - For files specified by command args, these are contained in the vector - which `file_table' points to. - - For library members, they are dynamically allocated, - and chained through the `chain' field. - The chain is found in the `subfiles' field of the `file_entry'. - The `file_entry' objects for the members have `superfile' fields pointing - to the one for the library. */ - -struct file_entry { - /* Name of this file. */ - char *filename; - /* Name to use for the symbol giving address of text start */ - /* Usually the same as filename, but for a file spec'd with -l - this is the -l switch itself rather than the filename. */ - char *local_sym_name; - - /* Describe the layout of the contents of the file */ - - /* The file's a.out header. */ - struct exec header; - /* Offset in file of GDB symbol segment, or 0 if there is none. */ - int symseg_offset; - - /* Describe data from the file loaded into core */ - - /* Symbol table of the file. */ - struct nlist *symbols; - /* Size in bytes of string table. */ - int string_size; - /* Pointer to the string table. - The string table is not kept in core all the time, - but when it is in core, its address is here. */ - char *strings; - - /* Next two used only if `relocatable_output' or if needed for */ - /* output of undefined reference line numbers. */ - - /* Text reloc info saved by `write_text' for `coptxtrel'. */ - struct relocation_info *textrel; - /* Data reloc info saved by `write_data' for `copdatrel'. */ - struct relocation_info *datarel; - - /* Relation of this file's segments to the output file */ - - /* Start of this file's text seg in the output file core image. */ - int text_start_address; - /* Start of this file's data seg in the output file core image. */ - int data_start_address; - /* Start of this file's bss seg in the output file core image. */ - int bss_start_address; - /* Offset in bytes in the output file symbol table - of the first local symbol for this file. Set by `write_file_symbols'. */ - int local_syms_offset; - - /* For library members only */ - - /* For a library, points to chain of entries for the library members. */ - struct file_entry *subfiles; - /* For a library member, offset of the member within the archive. - Zero for files that are not library members. */ - int starting_offset; - /* Size of contents of this file, if library member. */ - int total_size; - /* For library member, points to the library's own entry. */ - struct file_entry *superfile; - /* For library member, points to next entry for next member. */ - struct file_entry *chain; - - /* 1 if file is a library. */ - char library_flag; - - /* 1 if file's header has been read into this structure. */ - char header_read_flag; - - /* 1 means search a set of directories for this file. */ - char search_dirs_flag; - - /* 1 means this is base file of incremental load. - Do not load this file's text or data. - Also default text_start to after this file's bss. */ - char just_syms_flag; -}; - -/* Vector of entries for input files specified by arguments. - These are all the input files except for members of specified libraries. */ -struct file_entry *file_table; - -/* Length of that vector. */ -int number_of_files; - -/* When loading the text and data, we can avoid doing a close - and another open between members of the same library. - - These two variables remember the file that is currently open. - Both are zero if no file is open. - - See `each_file' and `file_close'. */ - -struct file_entry *input_file; -int input_desc; - -/* The name of the file to write; "a.out" by default. */ - -char *output_filename; - -/* Descriptor for writing that file with `mywrite'. */ - -int outdesc; - -/* Header for that file (filled in by `write_header'). */ - -struct exec outheader; - -#ifdef COFF_ENCAPSULATE -struct coffheader coffheader; -int need_coff_header; -#endif - -/* The following are computed by `digest_symbols'. */ - -int text_size; /* total size of text of all input files. */ -int data_size; /* total size of data of all input files. */ -int bss_size; /* total size of bss of all input files. */ -int text_reloc_size; /* total size of text relocation of all input files. */ -int data_reloc_size; /* total size of data relocation of all input */ - /* files. */ - -/* Specifications of start and length of the area reserved at the end - of the text segment for the set vectors. Computed in 'digest_symbols' */ -int set_sect_start; -int set_sect_size; - -/* Pointer for in core storage for the above vectors, before they are - written. */ -unsigned long *set_vectors; - -/* Amount of cleared space to leave between the text and data segments. */ - -int text_pad; - -/* Amount of bss segment to include as part of the data segment. */ - -int data_pad; - -/* Format of __.SYMDEF: - First, a longword containing the size of the 'symdef' data that follows. - Second, zero or more 'symdef' structures. - Third, a longword containing the length of symbol name strings. - Fourth, zero or more symbol name strings (each followed by a null). */ - -struct symdef { - int symbol_name_string_index; - int library_member_offset; -}; - -/* Record most of the command options. */ - -/* Address we assume the text section will be loaded at. - We relocate symbols and text and data for this, but we do not - write any padding in the output file for it. */ -int text_start; - -/* Offset of default entry-pc within the text section. */ -int entry_offset; - -/* Address we decide the data section will be loaded at. */ -int data_start; - -/* `text-start' address is normally this much plus a page boundary. - This is not a user option; it is fixed for each system. */ -int text_start_alignment; - -/* Nonzero if -T was specified in the command line. - This prevents text_start from being set later to default values. */ -int T_flag_specified; - -/* Nonzero if -Tdata was specified in the command line. - This prevents data_start from being set later to default values. */ -int Tdata_flag_specified; - -/* Size to pad data section up to. - We simply increase the size of the data section, padding with zeros, - and reduce the size of the bss section to match. */ -int specified_data_size; - -/* Magic number to use for the output file, set by switch. */ -int magic; - -/* Nonzero means print names of input files as processed. */ -int trace_files; - -/* Which symbols should be stripped (omitted from the output): - none, all, or debugger symbols. */ -enum { STRIP_NONE, STRIP_ALL, STRIP_DEBUGGER } strip_symbols; - -/* Which local symbols should be omitted: - none, all, or those starting with L. - This is irrelevant if STRIP_NONE. */ -enum { DISCARD_NONE, DISCARD_ALL, DISCARD_L } discard_locals; - -/* Do we want to pad the text to a page boundary? */ -int padtext; - -/* 1 => write load map. */ -int write_map; - -/* 1 => write relocation into output file so can re-input it later. */ -int relocatable_output; - -/* 1 => assign space to common symbols even if `relocatable_output'. */ -int force_common_definition; - -/* Standard directories to search for files specified by -l. */ -char *standard_search_dirs[] = -#ifdef STANDARD_SEARCH_DIRS - {STANDARD_SEARCH_DIRS}; -#else -#ifdef NON_NATIVE - {"/usr/local/lib/gnu"}; -#else - {"/lib", "/usr/lib", "/usr/local/lib"}; -#endif -#endif - -/* Actual vector of directories to search; - this contains those specified with -L plus the standard ones. */ -char **search_dirs; - -/* Length of the vector `search_dirs'. */ -int n_search_dirs; - -/* Non zero means to create the output executable. */ -/* Cleared by nonfatal errors. */ -int make_executable; - -/* Force the executable to be output, even if there are non-fatal - errors */ -int force_executable; - -/* Keep a list of any symbols referenced from the command line (so - that error messages for these guys can be generated). This list is - zero terminated. */ -struct glosym **cmdline_references; -int cl_refs_allocated; - -void bcopy (), bzero (); -int malloc (), realloc (); -#ifndef alloca -int alloca (); -#endif -int free (); - -int xmalloc (); -int xrealloc (); -void fatal (); -void fatal_with_file (); -void perror_name (); -void perror_file (); -void error (); - -void digest_symbols (); -void print_symbols (); -void load_symbols (); -void decode_command (); -void list_undefined_symbols (); -void list_unresolved_references (); -void write_output (); -void write_header (); -void write_text (); -void read_file_relocation (); -void write_data (); -void write_rel (); -void write_syms (); -void write_symsegs (); -void mywrite (); -void symtab_init (); -void padfile (); -char *concat (); -char *get_file_name (); -symbol *getsym (), *getsym_soft (); - -int -main (argc, argv) - char **argv; - int argc; -{ -/* Added this to stop ld core-dumping on very large .o files. */ -#ifdef RLIMIT_STACK - /* Get rid of any avoidable limit on stack size. */ - { - struct rlimit rlim; - - /* Set the stack limit huge so that alloca does not fail. */ - getrlimit (RLIMIT_STACK, &rlim); - rlim.rlim_cur = rlim.rlim_max; - setrlimit (RLIMIT_STACK, &rlim); - } -#endif /* RLIMIT_STACK */ - - page_size = getpagesize (); - progname = argv[0]; - - /* Clear the cumulative info on the output file. */ - - text_size = 0; - data_size = 0; - bss_size = 0; - text_reloc_size = 0; - data_reloc_size = 0; - - data_pad = 0; - text_pad = 0; - - /* Initialize the data about options. */ - - specified_data_size = 0; - strip_symbols = STRIP_NONE; - trace_files = 0; - discard_locals = DISCARD_NONE; - padtext = 0; - entry_symbol = 0; - write_map = 0; - relocatable_output = 0; - force_common_definition = 0; - T_flag_specified = 0; - Tdata_flag_specified = 0; - magic = DEFAULT_MAGIC; - make_executable = 1; - force_executable = 0; - set_element_prefixes = 0; - - /* Initialize the cumulative counts of symbols. */ - - local_sym_count = 0; - non_L_local_sym_count = 0; - debugger_sym_count = 0; - undefined_global_sym_count = 0; - set_symbol_count = 0; - set_vector_count = 0; - global_indirect_count = 0; - warning_count = 0; - multiple_def_count = 0; - common_defined_global_count = 0; - - /* Keep a list of symbols referenced from the command line */ - cl_refs_allocated = 10; - cmdline_references - = (struct glosym **) xmalloc (cl_refs_allocated - * sizeof(struct glosym *)); - *cmdline_references = 0; - - /* Completely decode ARGV. */ - - decode_command (argc, argv); - - /* Create the symbols `etext', `edata' and `end'. */ - - if (!relocatable_output) - symtab_init (); - - /* Determine whether to count the header as part of - the text size, and initialize the text size accordingly. - This depends on the kind of system and on the output format selected. */ - - N_SET_MAGIC (outheader, magic); -#ifdef INITIALIZE_HEADER - INITIALIZE_HEADER; -#endif - - text_size = sizeof (struct exec); -#ifdef COFF_ENCAPSULATE - if (relocatable_output == 0 && file_table[0].just_syms_flag == 0) - { - need_coff_header = 1; - /* set this flag now, since it will change the values of N_TXTOFF, etc */ - N_SET_FLAGS (outheader, N_FLAGS_COFF_ENCAPSULATE); - text_size += sizeof (struct coffheader); - } -#endif - - text_size -= N_TXTOFF (outheader); - - if (text_size < 0) - text_size = 0; - entry_offset = text_size; - - if (!T_flag_specified && !relocatable_output) - text_start = TEXT_START (outheader); - - /* The text-start address is normally this far past a page boundary. */ - text_start_alignment = text_start % page_size; - - /* Load symbols of all input files. - Also search all libraries and decide which library members to load. */ - - load_symbols (); - - /* Compute where each file's sections go, and relocate symbols. */ - - digest_symbols (); - - /* Print error messages for any missing symbols, for any warning - symbols, and possibly multiple definitions */ - - do_warnings (stderr); - - /* Print a map, if requested. */ - - if (write_map) print_symbols (stdout); - - /* Write the output file. */ - - if (make_executable || force_executable) - write_output (); - - exit (!make_executable); -} - -void decode_option (); - -/* Analyze a command line argument. - Return 0 if the argument is a filename. - Return 1 if the argument is a option complete in itself. - Return 2 if the argument is a option which uses an argument. - - Thus, the value is the number of consecutive arguments - that are part of options. */ - -int -classify_arg (arg) - register char *arg; -{ - if (*arg != '-') return 0; - switch (arg[1]) - { - case 'A': - case 'D': - case 'e': - case 'L': - case 'l': - case 'o': - case 'u': - case 'V': - case 'y': - if (arg[2]) - return 1; - return 2; - - case 'B': - if (! strcmp (&arg[2], "static")) - return 1; - - case 'T': - if (arg[2] == 0) - return 2; - if (! strcmp (&arg[2], "text")) - return 2; - if (! strcmp (&arg[2], "data")) - return 2; - return 1; - } - - return 1; -} - -/* Process the command arguments, - setting up file_table with an entry for each input file, - and setting variables according to the options. */ - -void -decode_command (argc, argv) - char **argv; - int argc; -{ - register int i; - register struct file_entry *p; - char *cp; - - number_of_files = 0; - output_filename = "a.out"; - - n_search_dirs = 0; - search_dirs = (char **) xmalloc (sizeof (char *)); - - /* First compute number_of_files so we know how long to make file_table. */ - /* Also process most options completely. */ - - for (i = 1; i < argc; i++) - { - register int code = classify_arg (argv[i]); - if (code) - { - if (i + code > argc) - fatal ("no argument following %s\n", argv[i]); - - decode_option (argv[i], argv[i+1]); - - if (argv[i][1] == 'l' || argv[i][1] == 'A') - number_of_files++; - - i += code - 1; - } - else - number_of_files++; - } - - if (!number_of_files) - fatal ("no input files", 0); - - p = file_table - = (struct file_entry *) xmalloc (number_of_files * sizeof (struct file_entry)); - bzero (p, number_of_files * sizeof (struct file_entry)); - - /* Now scan again and fill in file_table. */ - /* All options except -A and -l are ignored here. */ - - for (i = 1; i < argc; i++) - { - register int code = classify_arg (argv[i]); - - if (code) - { - char *string; - if (code == 2) - string = argv[i+1]; - else - string = &argv[i][2]; - - if (argv[i][1] == 'A') - { - if (p != file_table) - fatal ("-A specified before an input file other than the first"); - - p->filename = string; - p->local_sym_name = string; - p->just_syms_flag = 1; - p++; - } - if (argv[i][1] == 'l') - { - if (cp = rindex(string, '/')) - { - *cp++ = '\0'; - cp = concat (string, "/lib", cp); - p->filename = concat (cp, ".a", ""); - } - else - p->filename = concat ("lib", string, ".a"); - - p->local_sym_name = concat ("-l", string, ""); - p->search_dirs_flag = 1; - p++; - } - i += code - 1; - } - else - { - p->filename = argv[i]; - p->local_sym_name = argv[i]; - p++; - } - } - - /* Now check some option settings for consistency. */ - -#ifdef NMAGIC - if ((magic == ZMAGIC || magic == NMAGIC) -#else - if ((magic == ZMAGIC) -#endif - && (text_start - text_start_alignment) & (page_size - 1)) - fatal ("-T argument not multiple of page size, with sharable output", 0); - - /* Append the standard search directories to the user-specified ones. */ - { - int n = sizeof standard_search_dirs / sizeof standard_search_dirs[0]; - n_search_dirs += n; - search_dirs - = (char **) xrealloc (search_dirs, n_search_dirs * sizeof (char *)); - bcopy (standard_search_dirs, &search_dirs[n_search_dirs - n], - n * sizeof (char *)); - } -} - - -void -add_cmdline_ref (sp) - struct glosym *sp; -{ - struct glosym **ptr; - - for (ptr = cmdline_references; - ptr < cmdline_references + cl_refs_allocated && *ptr; - ptr++) - ; - - if (ptr >= cmdline_references + cl_refs_allocated - 1) - { - int diff = ptr - cmdline_references; - - cl_refs_allocated *= 2; - cmdline_references = (struct glosym **) - xrealloc (cmdline_references, - cl_refs_allocated * sizeof (struct glosym *)); - ptr = cmdline_references + diff; - } - - *ptr++ = sp; - *ptr = (struct glosym *) 0; -} - -int -set_element_prefixed_p (name) - char *name; -{ - struct string_list_element *p; - int i; - - for (p = set_element_prefixes; p; p = p->next) - { - for (i = 0; p->str[i] != '\0' && (p->str[i] == name[i]); i++) - ; - - if (p->str[i] == '\0') - return 1; - } - return 0; -} - -int parse (); - -/* Record an option and arrange to act on it later. - ARG should be the following command argument, - which may or may not be used by this option. - - The `l' and `A' options are ignored here since they actually - specify input files. */ - -void -decode_option (swt, arg) - register char *swt, *arg; -{ - /* We get Bstatic from gcc on suns. */ - if (! strcmp (swt + 1, "Bstatic")) - return; - if (! strcmp (swt + 1, "Ttext")) - { - text_start = parse (arg, "%x", "invalid argument to -Ttext"); - T_flag_specified = 1; - return; - } - if (! strcmp (swt + 1, "Tdata")) - { - data_start = parse (arg, "%x", "invalid argument to -Tdata"); - Tdata_flag_specified = 1; - return; - } - if (! strcmp (swt + 1, "noinhibit-exec")) - { - force_executable = 1; - return; - } - - if (swt[2] != 0) - arg = &swt[2]; - - switch (swt[1]) - { - case 'A': - return; - - case 'D': - specified_data_size = parse (arg, "%x", "invalid argument to -D"); - return; - - case 'd': - force_common_definition = 1; - return; - - case 'e': - entry_symbol = getsym (arg); - if (!entry_symbol->defined && !entry_symbol->referenced) - undefined_global_sym_count++; - entry_symbol->referenced = 1; - add_cmdline_ref (entry_symbol); - return; - - case 'l': - /* If linking with libg++, use the C++ demangler. */ - if (arg != NULL && strcmp (arg, "g++") == 0) - demangler = cplus_demangle; - return; - - case 'L': - n_search_dirs++; - search_dirs - = (char **) xrealloc (search_dirs, n_search_dirs * sizeof (char *)); - search_dirs[n_search_dirs - 1] = arg; - return; - - case 'M': - write_map = 1; - return; - - case 'N': - magic = OMAGIC; - return; - -#ifdef NMAGIC - case 'n': - magic = NMAGIC; - return; -#endif - - case 'o': - output_filename = arg; - return; - - case 'p': - padtext = 1; - return; - - case 'r': - relocatable_output = 1; - magic = OMAGIC; - text_start = 0; - return; - - case 'S': - strip_symbols = STRIP_DEBUGGER; - return; - - case 's': - strip_symbols = STRIP_ALL; - return; - - case 'T': - text_start = parse (arg, "%x", "invalid argument to -T"); - T_flag_specified = 1; - return; - - case 't': - trace_files = 1; - return; - - case 'u': - { - register symbol *sp = getsym (arg); - if (!sp->defined && !sp->referenced) - undefined_global_sym_count++; - sp->referenced = 1; - add_cmdline_ref (sp); - } - return; - - case 'V': - { - struct string_list_element *new - = (struct string_list_element *) - xmalloc (sizeof (struct string_list_element)); - - new->str = arg; - new->next = set_element_prefixes; - set_element_prefixes = new; - return; - } - - case 'X': - discard_locals = DISCARD_L; - return; - - case 'x': - discard_locals = DISCARD_ALL; - return; - - case 'y': - { - register symbol *sp = getsym (&swt[2]); - sp->trace = 1; - } - return; - - case 'z': - magic = ZMAGIC; - return; - - default: - fatal ("invalid command option `%s'", swt); - } -} - -/** Convenient functions for operating on one or all files being */ - /** loaded. */ -void print_file_name (); - -/* Call FUNCTION on each input file entry. - Do not call for entries for libraries; - instead, call once for each library member that is being loaded. - - FUNCTION receives two arguments: the entry, and ARG. */ - -void -each_file (function, arg) - register void (*function)(); - register int arg; -{ - register int i; - - for (i = 0; i < number_of_files; i++) - { - register struct file_entry *entry = &file_table[i]; - if (entry->library_flag) - { - register struct file_entry *subentry = entry->subfiles; - for (; subentry; subentry = subentry->chain) - (*function) (subentry, arg); - } - else - (*function) (entry, arg); - } -} - -/* Call FUNCTION on each input file entry until it returns a non-zero - value. Return this value. - Do not call for entries for libraries; - instead, call once for each library member that is being loaded. - - FUNCTION receives two arguments: the entry, and ARG. It must be a - function returning unsigned long (though this can probably be fudged). */ - -unsigned long -check_each_file (function, arg) - register unsigned long (*function)(); - register int arg; -{ - register int i; - register unsigned long return_val; - - for (i = 0; i < number_of_files; i++) - { - register struct file_entry *entry = &file_table[i]; - if (entry->library_flag) - { - register struct file_entry *subentry = entry->subfiles; - for (; subentry; subentry = subentry->chain) - if (return_val = (*function) (subentry, arg)) - return return_val; - } - else - if (return_val = (*function) (entry, arg)) - return return_val; - } - return 0; -} - -/* Like `each_file' but ignore files that were just for symbol definitions. */ - -void -each_full_file (function, arg) - register void (*function)(); - register int arg; -{ - register int i; - - for (i = 0; i < number_of_files; i++) - { - register struct file_entry *entry = &file_table[i]; - if (entry->just_syms_flag) - continue; - if (entry->library_flag) - { - register struct file_entry *subentry = entry->subfiles; - for (; subentry; subentry = subentry->chain) - (*function) (subentry, arg); - } - else - (*function) (entry, arg); - } -} - -/* Close the input file that is now open. */ - -void -file_close () -{ - close (input_desc); - input_desc = 0; - input_file = 0; -} - -/* Open the input file specified by 'entry', and return a descriptor. - The open file is remembered; if the same file is opened twice in a row, - a new open is not actually done. */ - -int -file_open (entry) - register struct file_entry *entry; -{ - register int desc; - - if (entry->superfile) - return file_open (entry->superfile); - - if (entry == input_file) - return input_desc; - - if (input_file) file_close (); - - if (entry->search_dirs_flag) - { - int i; - - for (i = 0; i < n_search_dirs; i++) - { - register char *string - = concat (search_dirs[i], "/", entry->filename); - desc = open (string, O_RDONLY, 0); - if (desc > 0) - { - entry->filename = string; - entry->search_dirs_flag = 0; - break; - } - free (string); - } - } - else - desc = open (entry->filename, O_RDONLY, 0); - - if (desc > 0) - { - input_file = entry; - input_desc = desc; - return desc; - } - - perror_file (entry); - /* NOTREACHED */ -} - -/* Print the filename of ENTRY on OUTFILE (a stdio stream), - and then a newline. */ - -void -prline_file_name (entry, outfile) - struct file_entry *entry; - FILE *outfile; -{ - print_file_name (entry, outfile); - fprintf (outfile, "\n"); -} - -/* Print the filename of ENTRY on OUTFILE (a stdio stream). */ - -void -print_file_name (entry, outfile) - struct file_entry *entry; - FILE *outfile; -{ - if (entry->superfile) - { - print_file_name (entry->superfile, outfile); - fprintf (outfile, "(%s)", entry->filename); - } - else - fprintf (outfile, "%s", entry->filename); -} - -/* Return the filename of entry as a string (malloc'd for the purpose) */ - -char * -get_file_name (entry) - struct file_entry *entry; -{ - char *result, *supfile; - if (entry->superfile) - { - supfile = get_file_name (entry->superfile); - result = (char *) xmalloc (strlen (supfile) - + strlen (entry->filename) + 3); - sprintf (result, "%s(%s)", supfile, entry->filename); - free (supfile); - } - else - { - result = (char *) xmalloc (strlen (entry->filename) + 1); - strcpy (result, entry->filename); - } - return result; -} - -/* Medium-level input routines for rel files. */ - -/* Read a file's header into the proper place in the file_entry. - DESC is the descriptor on which the file is open. - ENTRY is the file's entry. */ - -void -read_header (desc, entry) - int desc; - register struct file_entry *entry; -{ - register int len; - struct exec *loc = (struct exec *) &entry->header; - - lseek (desc, entry->starting_offset, 0); -#ifdef COFF_ENCAPSULATE - if (entry->just_syms_flag) - lseek (desc, sizeof(coffheader), 1); -#endif - len = read (desc, loc, sizeof (struct exec)); - if (len != sizeof (struct exec)) - fatal_with_file ("failure reading header of ", entry); - if (N_BADMAG (*loc)) - fatal_with_file ("bad magic number in ", entry); - - entry->header_read_flag = 1; -} - -/* Read the symbols of file ENTRY into core. - Assume it is already open, on descriptor DESC. - Also read the length of the string table, which follows the symbol table, - but don't read the contents of the string table. */ - -void -read_entry_symbols (desc, entry) - struct file_entry *entry; - int desc; -{ - int str_size; - - if (!entry->header_read_flag) - read_header (desc, entry); - - entry->symbols = (struct nlist *) xmalloc (entry->header.a_syms); - - lseek (desc, N_SYMOFF (entry->header) + entry->starting_offset, 0); - if (entry->header.a_syms != read (desc, entry->symbols, entry->header.a_syms)) - fatal_with_file ("premature end of file in symbols of ", entry); - - lseek (desc, N_STROFF (entry->header) + entry->starting_offset, 0); - if (sizeof str_size != read (desc, &str_size, sizeof str_size)) - fatal_with_file ("bad string table size in ", entry); - - entry->string_size = str_size; -} - -/* Read the string table of file ENTRY into core. - Assume it is already open, on descriptor DESC. - Also record whether a GDB symbol segment follows the string table. */ - -void -read_entry_strings (desc, entry) - struct file_entry *entry; - int desc; -{ - int buffer; - - if (!entry->header_read_flag) - read_header (desc, entry); - - lseek (desc, N_STROFF (entry->header) + entry->starting_offset, 0); - if (entry->string_size != read (desc, entry->strings, entry->string_size)) - fatal_with_file ("premature end of file in strings of ", entry); - - /* While we are here, see if the file has a symbol segment at the end. - For a separate file, just try reading some more. - For a library member, compare current pos against total size. */ - if (entry->superfile) - { - if (entry->total_size == N_STROFF (entry->header) + entry->string_size) - return; - } - else - { - buffer = read (desc, &buffer, sizeof buffer); - if (buffer == 0) - return; - if (buffer != sizeof buffer) - fatal_with_file ("premature end of file in GDB symbol segment of ", entry); - } - /* Don't try to do anything with symsegs. */ - return; -#if 0 - /* eliminate warning of `statement not reached'. */ - entry->symseg_offset = N_STROFF (entry->header) + entry->string_size; -#endif -} - -/* Read in the symbols of all input files. */ - -void read_file_symbols (), read_entry_symbols (), read_entry_strings (); -void enter_file_symbols (), enter_global_ref (), search_library (); - -void -load_symbols () -{ - register int i; - - if (trace_files) fprintf (stderr, "Loading symbols:\n\n"); - - for (i = 0; i < number_of_files; i++) - { - register struct file_entry *entry = &file_table[i]; - read_file_symbols (entry); - } - - if (trace_files) fprintf (stderr, "\n"); -} - -/* If ENTRY is a rel file, read its symbol and string sections into core. - If it is a library, search it and load the appropriate members - (which means calling this function recursively on those members). */ - -void -read_file_symbols (entry) - register struct file_entry *entry; -{ - register int desc; - register int len; - struct exec hdr; - - desc = file_open (entry); - -#ifdef COFF_ENCAPSULATE - if (entry->just_syms_flag) - lseek (desc, sizeof(coffheader),0); -#endif - - len = read (desc, &hdr, sizeof hdr); - if (len != sizeof hdr) - fatal_with_file ("failure reading header of ", entry); - - if (!N_BADMAG (hdr)) - { - read_entry_symbols (desc, entry); - entry->strings = (char *) alloca (entry->string_size); - read_entry_strings (desc, entry); - enter_file_symbols (entry); - entry->strings = 0; - } - else - { - char armag[SARMAG]; - - lseek (desc, 0, 0); - if (SARMAG != read (desc, armag, SARMAG) || strncmp (armag, ARMAG, SARMAG)) - fatal_with_file ("malformed input file (not rel or archive) ", entry); - entry->library_flag = 1; - search_library (desc, entry); - } - - file_close (); -} - -/* Enter the external symbol defs and refs of ENTRY in the hash table. */ - -void -enter_file_symbols (entry) - struct file_entry *entry; -{ - register struct nlist - *p, - *end = entry->symbols + entry->header.a_syms / sizeof (struct nlist); - - if (trace_files) prline_file_name (entry, stderr); - - for (p = entry->symbols; p < end; p++) - { - if (p->n_type == (N_SETV | N_EXT)) continue; - if (set_element_prefixes - && set_element_prefixed_p (p->n_un.n_strx + entry->strings)) - p->n_type += (N_SETA - N_ABS); - - if (SET_ELEMENT_P (p->n_type)) - { - set_symbol_count++; - if (!relocatable_output) - enter_global_ref (p, p->n_un.n_strx + entry->strings, entry); - } - else if (p->n_type == N_WARNING) - { - char *name = p->n_un.n_strx + entry->strings; - - /* Grab the next entry. */ - p++; - if (p->n_type != (N_UNDF | N_EXT)) - { - fprintf (stderr, "%s: Warning symbol found in %s without external reference following.\n", - progname, entry->filename); - make_executable = 0; - p--; /* Process normally. */ - } - else - { - symbol *sp; - char *sname = p->n_un.n_strx + entry->strings; - /* Deal with the warning symbol. */ - enter_global_ref (p, p->n_un.n_strx + entry->strings, entry); - sp = getsym (sname); - sp->warning = (char *) xmalloc (strlen(name) + 1); - strcpy (sp->warning, name); - warning_count++; - } - } - else if (p->n_type & N_EXT) - enter_global_ref (p, p->n_un.n_strx + entry->strings, entry); - else if (p->n_un.n_strx && !(p->n_type & (N_STAB | N_EXT))) - { - if ((p->n_un.n_strx + entry->strings)[0] != LPREFIX) - non_L_local_sym_count++; - local_sym_count++; - } - else debugger_sym_count++; - } - - /* Count one for the local symbol that we generate, - whose name is the file's name (usually) and whose address - is the start of the file's text. */ - - local_sym_count++; - non_L_local_sym_count++; -} - -/* Enter one global symbol in the hash table. - NLIST_P points to the `struct nlist' read from the file - that describes the global symbol. NAME is the symbol's name. - ENTRY is the file entry for the file the symbol comes from. - - The `struct nlist' is modified by placing it on a chain of - all such structs that refer to the same global symbol. - This chain starts in the `refs' field of the symbol table entry - and is chained through the `n_name'. */ - -void -enter_global_ref (nlist_p, name, entry) - register struct nlist *nlist_p; - char *name; - struct file_entry *entry; -{ - register symbol *sp = getsym (name); - register int type = nlist_p->n_type; - int oldref = sp->referenced; - int olddef = sp->defined; - int com = sp->defined && sp->max_common_size; - - nlist_p->n_un.n_name = (char *) sp->refs; - sp->refs = nlist_p; - - sp->referenced = 1; - if (type != (N_UNDF | N_EXT) || nlist_p->n_value) - { - if (!sp->defined || sp->defined == (N_UNDF | N_EXT)) - sp->defined = type; - - if (oldref && !olddef) - /* It used to be undefined and we're defining it. */ - undefined_global_sym_count--; - - if (!olddef && type == (N_UNDF | N_EXT) && nlist_p->n_value) - { - /* First definition and it's common. */ - common_defined_global_count++; - sp->max_common_size = nlist_p->n_value; - } - else if (com && type != (N_UNDF | N_EXT)) - { - /* It used to be common and we're defining it as - something else. */ - common_defined_global_count--; - sp->max_common_size = 0; - } - else if (com && type == (N_UNDF | N_EXT) - && sp->max_common_size < nlist_p->n_value) - /* It used to be common and this is a new common entry to - which we need to pay attention. */ - sp->max_common_size = nlist_p->n_value; - - /* Are we defining it as a set element? */ - if (SET_ELEMENT_P (type) && (!olddef || com)) - set_vector_count++; - /* As an indirection? */ - else if (type == (N_INDR | N_EXT)) - { - /* Indirect symbols value should be modified to point - a symbol being equivalenced to. */ - nlist_p->n_value - = (unsigned int) getsym ((nlist_p + 1)->n_un.n_strx - + entry->strings); - if ((symbol *) nlist_p->n_value == sp) - { - /* Somebody redefined a symbol to be itself. */ - fprintf (stderr, "%s: Symbol %s indirected to itself.\n", - entry->filename, name); - /* Rewrite this symbol as being a global text symbol - with value 0. */ - nlist_p->n_type = sp->defined = N_TEXT | N_EXT; - nlist_p->n_value = 0; - /* Don't make the output executable. */ - make_executable = 0; - } - else - global_indirect_count++; - } - } - else - if (!oldref) -#ifndef DOLLAR_KLUDGE - undefined_global_sym_count++; -#else - { - if (entry->superfile && type == (N_UNDF | N_EXT) && name[1] == '$') - { - /* This is an (ISI?) $-conditional; skip it */ - sp->referenced = 0; - if (sp->trace) - { - fprintf (stderr, "symbol %s is a $-conditional ignored in ", sp->name); - print_file_name (entry, stderr); - fprintf (stderr, "\n"); - } - return; - } - else - undefined_global_sym_count++; - } -#endif - - if (sp == end_symbol && entry->just_syms_flag && !T_flag_specified) - text_start = nlist_p->n_value; - - if (sp->trace) - { - register char *reftype; - switch (type & N_TYPE) - { - case N_UNDF: - if (nlist_p->n_value) - reftype = "defined as common"; - else reftype = "referenced"; - break; - - case N_ABS: - reftype = "defined as absolute"; - break; - - case N_TEXT: - reftype = "defined in text section"; - break; - - case N_DATA: - reftype = "defined in data section"; - break; - - case N_BSS: - reftype = "defined in BSS section"; - break; - - case N_SETT: - reftype = "is a text set element"; - break; - - case N_SETD: - reftype = "is a data set element"; - break; - - case N_SETB: - reftype = "is a BSS set element"; - break; - - case N_SETA: - reftype = "is an absolute set element"; - break; - - case N_SETV: - reftype = "defined in data section as vector"; - break; - - case N_INDR: - reftype = (char *) alloca (23 - + strlen ((nlist_p + 1)->n_un.n_strx - + entry->strings)); - sprintf (reftype, "defined equivalent to %s", - (nlist_p + 1)->n_un.n_strx + entry->strings); - break; - -#ifdef sequent - case N_SHUNDF: - reftype = "shared undf"; - break; - -/* These conflict with cases above. - case N_SHDATA: - reftype = "shared data"; - break; - - case N_SHBSS: - reftype = "shared BSS"; - break; -*/ - default: - reftype = "I don't know this type"; - break; -#endif - } - - fprintf (stderr, "symbol %s %s in ", sp->name, reftype); - print_file_name (entry, stderr); - fprintf (stderr, "\n"); - } -} - -/* This return 0 if the given file entry's symbol table does *not* - contain the nlist point entry, and it returns the files entry - pointer (cast to unsigned long) if it does. */ - -unsigned long -contains_symbol (entry, n_ptr) - struct file_entry *entry; - register struct nlist *n_ptr; -{ - if (n_ptr >= entry->symbols && - n_ptr < (entry->symbols - + (entry->header.a_syms / sizeof (struct nlist)))) - return (unsigned long) entry; - return 0; -} - - -/* Searching libraries */ - -struct file_entry *decode_library_subfile (); -void linear_library (), symdef_library (); - -/* Search the library ENTRY, already open on descriptor DESC. - This means deciding which library members to load, - making a chain of `struct file_entry' for those members, - and entering their global symbols in the hash table. */ - -void -search_library (desc, entry) - int desc; - struct file_entry *entry; -{ - int member_length; - register char *name; - register struct file_entry *subentry; - - if (!undefined_global_sym_count) return; - - /* Examine its first member, which starts SARMAG bytes in. */ - subentry = decode_library_subfile (desc, entry, SARMAG, &member_length); - if (!subentry) return; - - name = subentry->filename; - free (subentry); - - /* Search via __.SYMDEF if that exists, else linearly. */ - - if (!strcmp (name, "__.SYMDEF")) - symdef_library (desc, entry, member_length); - else - linear_library (desc, entry); -} - -/* Construct and return a file_entry for a library member. - The library's file_entry is library_entry, and the library is open on DESC. - SUBFILE_OFFSET is the byte index in the library of this member's header. - We store the length of the member into *LENGTH_LOC. */ - -struct file_entry * -decode_library_subfile (desc, library_entry, subfile_offset, length_loc) - int desc; - struct file_entry *library_entry; - int subfile_offset; - int *length_loc; -{ - int bytes_read; - register int namelen; - int member_length; - register char *name; - struct ar_hdr hdr1; - register struct file_entry *subentry; - - lseek (desc, subfile_offset, 0); - - bytes_read = read (desc, &hdr1, sizeof hdr1); - if (!bytes_read) - return 0; /* end of archive */ - - if (sizeof hdr1 != bytes_read) - fatal_with_file ("malformed library archive ", library_entry); - - if (sscanf (hdr1.ar_size, "%d", &member_length) != 1) - fatal_with_file ("malformatted header of archive member in ", library_entry); - - subentry = (struct file_entry *) xmalloc (sizeof (struct file_entry)); - bzero (subentry, sizeof (struct file_entry)); - - for (namelen = 0; - namelen < sizeof hdr1.ar_name - && hdr1.ar_name[namelen] != 0 && hdr1.ar_name[namelen] != ' ' - && hdr1.ar_name[namelen] != '/'; - namelen++); - - name = (char *) xmalloc (namelen+1); - strncpy (name, hdr1.ar_name, namelen); - name[namelen] = 0; - - subentry->filename = name; - subentry->local_sym_name = name; - subentry->symbols = 0; - subentry->strings = 0; - subentry->subfiles = 0; - subentry->starting_offset = subfile_offset + sizeof hdr1; - subentry->superfile = library_entry; - subentry->library_flag = 0; - subentry->header_read_flag = 0; - subentry->just_syms_flag = 0; - subentry->chain = 0; - subentry->total_size = member_length; - - (*length_loc) = member_length; - - return subentry; -} - -int subfile_wanted_p (); - -/* Search a library that has a __.SYMDEF member. - DESC is a descriptor on which the library is open. - The file pointer is assumed to point at the __.SYMDEF data. - ENTRY is the library's file_entry. - MEMBER_LENGTH is the length of the __.SYMDEF data. */ - -void -symdef_library (desc, entry, member_length) - int desc; - struct file_entry *entry; - int member_length; -{ - int *symdef_data = (int *) xmalloc (member_length); - register struct symdef *symdef_base; - char *sym_name_base; - int number_of_symdefs; - int length_of_strings; - int not_finished; - int bytes_read; - register int i; - struct file_entry *prev = 0; - int prev_offset = 0; - - bytes_read = read (desc, symdef_data, member_length); - if (bytes_read != member_length) - fatal_with_file ("malformatted __.SYMDEF in ", entry); - - number_of_symdefs = *symdef_data / sizeof (struct symdef); - if (number_of_symdefs < 0 || - number_of_symdefs * sizeof (struct symdef) + 2 * sizeof (int) > member_length) - fatal_with_file ("malformatted __.SYMDEF in ", entry); - - symdef_base = (struct symdef *) (symdef_data + 1); - length_of_strings = *(int *) (symdef_base + number_of_symdefs); - - if (length_of_strings < 0 - || number_of_symdefs * sizeof (struct symdef) + length_of_strings - + 2 * sizeof (int) > member_length) - fatal_with_file ("malformatted __.SYMDEF in ", entry); - - sym_name_base = sizeof (int) + (char *) (symdef_base + number_of_symdefs); - - /* Check all the string indexes for validity. */ - - for (i = 0; i < number_of_symdefs; i++) - { - register int index = symdef_base[i].symbol_name_string_index; - if (index < 0 || index >= length_of_strings - || (index && *(sym_name_base + index - 1))) - fatal_with_file ("malformatted __.SYMDEF in ", entry); - } - - /* Search the symdef data for members to load. - Do this until one whole pass finds nothing to load. */ - - not_finished = 1; - while (not_finished) - { - not_finished = 0; - - /* Scan all the symbols mentioned in the symdef for ones that we need. - Load the library members that contain such symbols. */ - - for (i = 0; - (i < number_of_symdefs - && (undefined_global_sym_count || common_defined_global_count)); - i++) - if (symdef_base[i].symbol_name_string_index >= 0) - { - register symbol *sp; - - sp = getsym_soft (sym_name_base - + symdef_base[i].symbol_name_string_index); - - /* If we find a symbol that appears to be needed, think carefully - about the archive member that the symbol is in. */ - - /* - * Per Mike Karels' recommendation, we no longer load library - * files if the only reference(s) that would be satisfied are - * 'common' references. This prevents some problems with name - * pollution (e.g. a global common 'utime' linked to a function). - */ - if (sp && sp->referenced && !sp->defined) - { - int junk; - register int j; - register int offset = symdef_base[i].library_member_offset; - struct file_entry *subentry; - - /* Don't think carefully about any archive member - more than once in a given pass. */ - - if (prev_offset == offset) - continue; - prev_offset = offset; - - /* Read the symbol table of the archive member. */ - - subentry = decode_library_subfile (desc, entry, offset, &junk); - if (subentry == 0) - fatal ("invalid offset for %s in symbol table of %s", - sym_name_base - + symdef_base[i].symbol_name_string_index, - entry->filename); - read_entry_symbols (desc, subentry); - subentry->strings = (char *) malloc (subentry->string_size); - read_entry_strings (desc, subentry); - - /* Now scan the symbol table and decide whether to load. */ - - if (!subfile_wanted_p (subentry)) - { - free (subentry->symbols); - free (subentry); - } - else - { - /* This member is needed; load it. - Since we are loading something on this pass, - we must make another pass through the symdef data. */ - - not_finished = 1; - - enter_file_symbols (subentry); - - if (prev) - prev->chain = subentry; - else entry->subfiles = subentry; - prev = subentry; - - /* Clear out this member's symbols from the symdef data - so that following passes won't waste time on them. */ - - for (j = 0; j < number_of_symdefs; j++) - { - if (symdef_base[j].library_member_offset == offset) - symdef_base[j].symbol_name_string_index = -1; - } - } - - /* We'll read the strings again if we need them again. */ - free (subentry->strings); - subentry->strings = 0; - } - } - } - - free (symdef_data); -} - -/* Search a library that has no __.SYMDEF. - ENTRY is the library's file_entry. - DESC is the descriptor it is open on. */ - -void -linear_library (desc, entry) - int desc; - struct file_entry *entry; -{ - register struct file_entry *prev = 0; - register int this_subfile_offset = SARMAG; - - while (undefined_global_sym_count || common_defined_global_count) - { - int member_length; - register struct file_entry *subentry; - - subentry = decode_library_subfile (desc, entry, this_subfile_offset, - &member_length); - - if (!subentry) return; - - read_entry_symbols (desc, subentry); - subentry->strings = (char *) alloca (subentry->string_size); - read_entry_strings (desc, subentry); - - if (!subfile_wanted_p (subentry)) - { - free (subentry->symbols); - free (subentry); - } - else - { - enter_file_symbols (subentry); - - if (prev) - prev->chain = subentry; - else entry->subfiles = subentry; - prev = subentry; - subentry->strings = 0; /* Since space will dissapear on return */ - } - - this_subfile_offset += member_length + sizeof (struct ar_hdr); - if (this_subfile_offset & 1) this_subfile_offset++; - } -} - -/* ENTRY is an entry for a library member. - Its symbols have been read into core, but not entered. - Return nonzero if we ought to load this member. */ - -int -subfile_wanted_p (entry) - struct file_entry *entry; -{ - register struct nlist *p; - register struct nlist *end - = entry->symbols + entry->header.a_syms / sizeof (struct nlist); -#ifdef DOLLAR_KLUDGE - register int dollar_cond = 0; -#endif - - for (p = entry->symbols; p < end; p++) - { - register int type = p->n_type; - register char *name = p->n_un.n_strx + entry->strings; - - /* If the symbol has an interesting definition, we could - potentially want it. */ - if (type & N_EXT - && (type != (N_UNDF | N_EXT) || p->n_value - -#ifdef DOLLAR_KLUDGE - || name[1] == '$' -#endif - ) - && !SET_ELEMENT_P (type) - && !set_element_prefixed_p (name)) - { - register symbol *sp = getsym_soft (name); - -#ifdef DOLLAR_KLUDGE - if (name[1] == '$') - { - sp = getsym_soft (&name[2]); - dollar_cond = 1; - if (!sp) continue; - if (sp->referenced) - { - if (write_map) - { - print_file_name (entry, stdout); - fprintf (stdout, " needed due to $-conditional %s\n", name); - } - return 1; - } - continue; - } -#endif - - /* If this symbol has not been hashed, we can't be looking for it. */ - - if (!sp) continue; - - /* - * We don't load a file if it merely satisfies a common reference - * (see explanation above in symdef_library()). - */ - if (sp->referenced && !sp->defined) - { - /* This is a symbol we are looking for. It is either - not yet defined or defined as a common. */ -#ifdef DOLLAR_KLUDGE - if (dollar_cond) continue; -#endif - if (type == (N_UNDF | N_EXT)) - { - /* Symbol being defined as common. - Remember this, but don't load subfile just for this. */ - - /* If it didn't used to be common, up the count of - common symbols. */ - if (!sp->max_common_size) - common_defined_global_count++; - - if (sp->max_common_size < p->n_value) - sp->max_common_size = p->n_value; - if (!sp->defined) - undefined_global_sym_count--; - sp->defined = 1; - continue; - } - - if (write_map) - { - print_file_name (entry, stdout); - fprintf (stdout, " needed due to %s\n", sp->name); - } - return 1; - } - } - } - - return 0; -} - -void consider_file_section_lengths (), relocate_file_addresses (); - -/* Having entered all the global symbols and found the sizes of sections - of all files to be linked, make all appropriate deductions from this data. - - We propagate global symbol values from definitions to references. - We compute the layout of the output file and where each input file's - contents fit into it. */ - -void -digest_symbols () -{ - register int i; - int setv_fill_count; - - if (trace_files) - fprintf (stderr, "Digesting symbol information:\n\n"); - - /* Compute total size of sections */ - - each_file (consider_file_section_lengths, 0); - - /* If necessary, pad text section to full page in the file. - Include the padding in the text segment size. */ - - if (magic == ZMAGIC) - { - int text_end = text_size + N_TXTOFF (outheader); - text_pad = ((text_end + page_size - 1) & (- page_size)) - text_end; - text_size += text_pad; - } - if (padtext) - { - int text_end = text_size; - text_pad = ((text_end + page_size - 1) & (- page_size)) - text_end; - text_size += text_pad; - } - -#ifdef _N_BASEADDR - /* SunOS 4.1 N_TXTADDR depends on the value of outheader.a_entry. */ - outheader.a_entry = N_PAGSIZ (outheader); -#endif - - outheader.a_text = text_size; -#ifdef sequent - outheader.a_text += N_ADDRADJ (outheader); -#endif - - /* Make the data segment address start in memory on a suitable boundary. */ - - if (! Tdata_flag_specified) - data_start = N_DATADDR (outheader) + text_start - TEXT_START (outheader); - - /* Set up the set element vector */ - - if (!relocatable_output) - { - /* The set sector size is the number of set elements + a word - for each symbol for the length word at the beginning of the - vector, plus a word for each symbol for a zero at the end of - the vector (for incremental linking). */ - set_sect_size - = (2 * set_symbol_count + set_vector_count) * sizeof (unsigned long); - set_sect_start = data_start + data_size; - data_size += set_sect_size; - set_vectors = (unsigned long *) xmalloc (set_sect_size); - setv_fill_count = 0; - } - - /* Compute start addresses of each file's sections and symbols. */ - - each_full_file (relocate_file_addresses, 0); - - /* Now, for each symbol, verify that it is defined globally at most once. - Put the global value into the symbol entry. - Common symbols are allocated here, in the BSS section. - Each defined symbol is given a '->defined' field - which is the correct N_ code for its definition, - except in the case of common symbols with -r. - Then make all the references point at the symbol entry - instead of being chained together. */ - - defined_global_sym_count = 0; - - for (i = 0; i < TABSIZE; i++) - { - register symbol *sp; - for (sp = symtab[i]; sp; sp = sp->link) - { - /* For each symbol */ - register struct nlist *p, *next; - int defs = 0, com = sp->max_common_size; - struct nlist *first_definition; - for (p = sp->refs; p; p = next) - { - register int type = p->n_type; - - if (SET_ELEMENT_P (type)) - { - if (relocatable_output) - fatal ("internal: global ref to set element with -r"); - if (!defs++) - { - sp->value = set_sect_start - + setv_fill_count++ * sizeof (unsigned long); - sp->defined = N_SETV | N_EXT; - first_definition = p; - } - else if ((sp->defined & ~N_EXT) != N_SETV) - { - sp->multiply_defined = 1; - multiple_def_count++; - } - set_vectors[setv_fill_count++] = p->n_value; - } - else if ((type & N_EXT) && type != (N_UNDF | N_EXT)) - { - /* non-common definition */ - if (defs++ && sp->value != p->n_value) - { - sp->multiply_defined = 1; - multiple_def_count++; - } - sp->value = p->n_value; - sp->defined = type; - first_definition = p; - } - next = (struct nlist *) p->n_un.n_name; - p->n_un.n_name = (char *) sp; - } - /* Allocate as common if defined as common and not defined for real */ - if (com && !defs) - { - if (!relocatable_output || force_common_definition) - { - int align = sizeof (int); - - /* Round up to nearest sizeof (int). I don't know - whether this is necessary or not (given that - alignment is taken care of later), but it's - traditional, so I'll leave it in. Note that if - this size alignment is ever removed, ALIGN above - will have to be initialized to 1 instead of - sizeof (int). */ - - com = (com + sizeof (int) - 1) & (- sizeof (int)); - - while (!(com & align)) - align <<= 1; - - align = align > MAX_ALIGNMENT ? MAX_ALIGNMENT : align; - - bss_size = ((((bss_size + data_size + data_start) - + (align - 1)) & (- align)) - - data_size - data_start); - - sp->value = data_start + data_size + bss_size; - sp->defined = N_BSS | N_EXT; - bss_size += com; - if (write_map) - printf ("Allocating common %s: %x at %x\n", - sp->name, com, sp->value); - } - else - { - sp->defined = 0; - undefined_global_sym_count++; - } - } - /* Set length word at front of vector and zero byte at end. - Reverse the vector itself to put it in file order. */ - if ((sp->defined & ~N_EXT) == N_SETV) - { - unsigned long length_word_index - = (sp->value - set_sect_start) / sizeof (unsigned long); - unsigned long i, tmp; - - set_vectors[length_word_index] - = setv_fill_count - 1 - length_word_index; - - /* Reverse the vector. */ - for (i = 1; - i < (setv_fill_count - length_word_index - 1) / 2 + 1; - i++) - { - tmp = set_vectors[length_word_index + i]; - set_vectors[length_word_index + i] - = set_vectors[setv_fill_count - i]; - set_vectors[setv_fill_count - i] = tmp; - } - - set_vectors[setv_fill_count++] = 0; - } - if (sp->defined) - defined_global_sym_count++; - } - } - - if (end_symbol) /* These are null if -r. */ - { - etext_symbol->value = text_size + text_start; - edata_symbol->value = data_start + data_size; - end_symbol->value = data_start + data_size + bss_size; - } - - /* Figure the data_pad now, so that it overlaps with the bss addresses. */ - - if (specified_data_size && specified_data_size > data_size) - data_pad = specified_data_size - data_size; - - if (magic == ZMAGIC) - data_pad = ((data_pad + data_size + page_size - 1) & (- page_size)) - - data_size; - - bss_size -= data_pad; - if (bss_size < 0) bss_size = 0; - - data_size += data_pad; -} - -/* Accumulate the section sizes of input file ENTRY - into the section sizes of the output file. */ - -void -consider_file_section_lengths (entry) - register struct file_entry *entry; -{ - if (entry->just_syms_flag) - return; - - entry->text_start_address = text_size; - /* If there were any vectors, we need to chop them off */ - text_size += entry->header.a_text; - entry->data_start_address = data_size; - data_size += entry->header.a_data; - entry->bss_start_address = bss_size; - bss_size += entry->header.a_bss; - - text_reloc_size += entry->header.a_trsize; - data_reloc_size += entry->header.a_drsize; -} - -/* Determine where the sections of ENTRY go into the output file, - whose total section sizes are already known. - Also relocate the addresses of the file's local and debugger symbols. */ - -void -relocate_file_addresses (entry) - register struct file_entry *entry; -{ - entry->text_start_address += text_start; - /* Note that `data_start' and `data_size' have not yet been - adjusted for `data_pad'. If they had been, we would get the wrong - results here. */ - entry->data_start_address += data_start; - entry->bss_start_address += data_start + data_size; - - { - register struct nlist *p; - register struct nlist *end - = entry->symbols + entry->header.a_syms / sizeof (struct nlist); - - for (p = entry->symbols; p < end; p++) - { - /* If this belongs to a section, update it by the section's start address */ - register int type = p->n_type & N_TYPE; - - switch (type) - { - case N_TEXT: - case N_SETT: - p->n_value += entry->text_start_address; - break; - case N_DATA: - case N_SETV: - case N_SETD: - /* A symbol whose value is in the data section - is present in the input file as if the data section - started at an address equal to the length of the file's text. */ - p->n_value += entry->data_start_address - entry->header.a_text; - break; - case N_BSS: - case N_SETB: - /* likewise for symbols with value in BSS. */ - p->n_value += entry->bss_start_address - - entry->header.a_text - entry->header.a_data; - break; - } - } - } -} - -void describe_file_sections (), list_file_locals (); - -/* Print a complete or partial map of the output file. */ - -void -print_symbols (outfile) - FILE *outfile; -{ - register int i; - - fprintf (outfile, "\nFiles:\n\n"); - - each_file (describe_file_sections, outfile); - - fprintf (outfile, "\nGlobal symbols:\n\n"); - - for (i = 0; i < TABSIZE; i++) - { - register symbol *sp; - for (sp = symtab[i]; sp; sp = sp->link) - { - if (sp->defined == 1) - fprintf (outfile, " %s: common, length 0x%x\n", sp->name, sp->max_common_size); - if (sp->defined) - fprintf (outfile, " %s: 0x%x\n", sp->name, sp->value); - else if (sp->referenced) - fprintf (outfile, " %s: undefined\n", sp->name); - } - } - - each_file (list_file_locals, outfile); -} - -void -describe_file_sections (entry, outfile) - struct file_entry *entry; - FILE *outfile; -{ - fprintf (outfile, " "); - print_file_name (entry, outfile); - if (entry->just_syms_flag) - fprintf (outfile, " symbols only\n", 0); - else - fprintf (outfile, " text %x(%x), data %x(%x), bss %x(%x) hex\n", - entry->text_start_address, entry->header.a_text, - entry->data_start_address, entry->header.a_data, - entry->bss_start_address, entry->header.a_bss); -} - -void -list_file_locals (entry, outfile) - struct file_entry *entry; - FILE *outfile; -{ - register struct nlist - *p, - *end = entry->symbols + entry->header.a_syms / sizeof (struct nlist); - - entry->strings = (char *) alloca (entry->string_size); - read_entry_strings (file_open (entry), entry); - - fprintf (outfile, "\nLocal symbols of "); - print_file_name (entry, outfile); - fprintf (outfile, ":\n\n"); - - for (p = entry->symbols; p < end; p++) - /* If this is a definition, - update it if necessary by this file's start address. */ - if (!(p->n_type & (N_STAB | N_EXT))) - fprintf (outfile, " %s: 0x%x\n", - entry->strings + p->n_un.n_strx, p->n_value); - - entry->strings = 0; /* All done with them. */ -} - - -/* Static vars for do_warnings and subroutines of it */ -int list_unresolved_refs; /* List unresolved refs */ -int list_warning_symbols; /* List warning syms */ -int list_multiple_defs; /* List multiple definitions */ - -/* - * Structure for communication between do_file_warnings and it's - * helper routines. Will in practice be an array of three of these: - * 0) Current line, 1) Next line, 2) Source file info. - */ -struct line_debug_entry -{ - int line; - char *filename; - struct nlist *sym; -}; - -void qsort (); -/* - * Helper routines for do_file_warnings. - */ - -/* Return an integer less than, equal to, or greater than 0 as per the - relation between the two relocation entries. Used by qsort. */ - -int -relocation_entries_relation (rel1, rel2) - struct relocation_info *rel1, *rel2; -{ - return RELOC_ADDRESS(rel1) - RELOC_ADDRESS(rel2); -} - -/* Moves to the next debugging symbol in the file. USE_DATA_SYMBOLS - determines the type of the debugging symbol to look for (DSLINE or - SLINE). STATE_POINTER keeps track of the old and new locatiosn in - the file. It assumes that state_pointer[1] is valid; ie - that it.sym points into some entry in the symbol table. If - state_pointer[1].sym == 0, this routine should not be called. */ - -int -next_debug_entry (use_data_symbols, state_pointer) - register int use_data_symbols; - /* Next must be passed by reference! */ - struct line_debug_entry state_pointer[3]; -{ - register struct line_debug_entry - *current = state_pointer, - *next = state_pointer + 1, - /* Used to store source file */ - *source = state_pointer + 2; - struct file_entry *entry = (struct file_entry *) source->sym; - - current->sym = next->sym; - current->line = next->line; - current->filename = next->filename; - - while (++(next->sym) < (entry->symbols - + entry->header.a_syms/sizeof (struct nlist))) - { - /* n_type is a char, and N_SOL, N_EINCL and N_BINCL are > 0x80, so - * may look negative...therefore, must mask to low bits - */ - switch (next->sym->n_type & 0xff) - { - case N_SLINE: - if (use_data_symbols) continue; - next->line = next->sym->n_desc; - return 1; - case N_DSLINE: - if (!use_data_symbols) continue; - next->line = next->sym->n_desc; - return 1; -#ifdef HAVE_SUN_STABS - case N_EINCL: - next->filename = source->filename; - continue; -#endif - case N_SO: - source->filename = next->sym->n_un.n_strx + entry->strings; - source->line++; -#ifdef HAVE_SUN_STABS - case N_BINCL: -#endif - case N_SOL: - next->filename - = next->sym->n_un.n_strx + entry->strings; - default: - continue; - } - } - next->sym = (struct nlist *) 0; - return 0; -} - -/* Create a structure to save the state of a scan through the debug - symbols. USE_DATA_SYMBOLS is set if we should be scanning for - DSLINE's instead of SLINE's. entry is the file entry which points - at the symbols to use. */ - -struct line_debug_entry * -init_debug_scan (use_data_symbols, entry) - int use_data_symbols; - struct file_entry *entry; -{ - struct line_debug_entry - *state_pointer - = (struct line_debug_entry *) - xmalloc (3 * sizeof (struct line_debug_entry)); - register struct line_debug_entry - *current = state_pointer, - *next = state_pointer + 1, - *source = state_pointer + 2; /* Used to store source file */ - - struct nlist *tmp; - - for (tmp = entry->symbols; - tmp < (entry->symbols - + entry->header.a_syms/sizeof (struct nlist)); - tmp++) - if (tmp->n_type == (int) N_SO) - break; - - if (tmp >= (entry->symbols - + entry->header.a_syms/sizeof (struct nlist))) - { - /* I believe this translates to "We lose" */ - current->filename = next->filename = entry->filename; - current->line = next->line = -1; - current->sym = next->sym = (struct nlist *) 0; - return state_pointer; - } - - next->line = source->line = 0; - next->filename = source->filename - = (tmp->n_un.n_strx + entry->strings); - source->sym = (struct nlist *) entry; - next->sym = tmp; - - next_debug_entry (use_data_symbols, state_pointer); /* To setup next */ - - if (!next->sym) /* No line numbers for this section; */ - /* setup output results as appropriate */ - { - if (source->line) - { - current->filename = source->filename = entry->filename; - current->line = -1; /* Don't print lineno */ - } - else - { - current->filename = source->filename; - current->line = 0; - } - return state_pointer; - } - - - next_debug_entry (use_data_symbols, state_pointer); /* To setup current */ - - return state_pointer; -} - -/* Takes an ADDRESS (in either text or data space) and a STATE_POINTER - which describes the current location in the implied scan through - the debug symbols within the file which ADDRESS is within, and - returns the source line number which corresponds to ADDRESS. */ - -int -address_to_line (address, state_pointer) - unsigned long address; - /* Next must be passed by reference! */ - struct line_debug_entry state_pointer[3]; -{ - struct line_debug_entry - *current = state_pointer, - *next = state_pointer + 1; - struct line_debug_entry *tmp_pointer; - - int use_data_symbols; - - if (next->sym) - use_data_symbols = (next->sym->n_type & N_TYPE) == N_DATA; - else - return current->line; - - /* Go back to the beginning if we've already passed it. */ - if (current->sym->n_value > address) - { - tmp_pointer = init_debug_scan (use_data_symbols, - (struct file_entry *) - ((state_pointer + 2)->sym)); - state_pointer[0] = tmp_pointer[0]; - state_pointer[1] = tmp_pointer[1]; - state_pointer[2] = tmp_pointer[2]; - free (tmp_pointer); - } - - /* If we're still in a bad way, return -1, meaning invalid line. */ - if (current->sym->n_value > address) - return -1; - - while (next->sym - && next->sym->n_value <= address - && next_debug_entry (use_data_symbols, state_pointer)) - ; - return current->line; -} - - -/* Macros for manipulating bitvectors. */ -#define BIT_SET_P(bv, index) ((bv)[(index) >> 3] & 1 << ((index) & 0x7)) -#define SET_BIT(bv, index) ((bv)[(index) >> 3] |= 1 << ((index) & 0x7)) - -/* This routine will scan through the relocation data of file ENTRY, - printing out references to undefined symbols and references to - symbols defined in files with N_WARNING symbols. If DATA_SEGMENT - is non-zero, it will scan the data relocation segment (and use - N_DSLINE symbols to track line number); otherwise it will scan the - text relocation segment. Warnings will be printed on the output - stream OUTFILE. Eventually, every nlist symbol mapped through will - be marked in the NLIST_BITVECTOR, so we don't repeat ourselves when - we scan the nlists themselves. */ - -do_relocation_warnings (entry, data_segment, outfile, nlist_bitvector) - struct file_entry *entry; - int data_segment; - FILE *outfile; - unsigned char *nlist_bitvector; -{ - struct relocation_info - *reloc_start = data_segment ? entry->datarel : entry->textrel, - *reloc; - int reloc_size - = ((data_segment ? entry->header.a_drsize : entry->header.a_trsize) - / sizeof (struct relocation_info)); - int start_of_segment - = (data_segment ? entry->data_start_address : entry->text_start_address); - struct nlist *start_of_syms = entry->symbols; - struct line_debug_entry *state_pointer - = init_debug_scan (data_segment != 0, entry); - register struct line_debug_entry - *current = state_pointer; - /* Assigned to generally static values; should not be written into. */ - char *errfmt; - /* Assigned to alloca'd values cand copied into; should be freed - when done. */ - char *errmsg; - int invalidate_line_number; - - /* We need to sort the relocation info here. Sheesh, so much effort - for one lousy error optimization. */ - - qsort (reloc_start, reloc_size, sizeof (struct relocation_info), - relocation_entries_relation); - - for (reloc = reloc_start; - reloc < (reloc_start + reloc_size); - reloc++) - { - register struct nlist *s; - register symbol *g; - - /* If the relocation isn't resolved through a symbol, continue */ - if (!RELOC_EXTERN_P(reloc)) - continue; - - s = &(entry->symbols[RELOC_SYMBOL(reloc)]); - - /* Local symbols shouldn't ever be used by relocation info, so - the next should be safe. - This is, of course, wrong. References to local BSS symbols can be - the targets of relocation info, and they can (must) be - resolved through symbols. However, these must be defined properly, - (the assembler would have caught it otherwise), so we can - ignore these cases. */ - if (!(s->n_type & N_EXT)) - continue; - - g = (symbol *) s->n_un.n_name; - errmsg = 0; - - if (!g->defined && list_unresolved_refs) /* Reference */ - { - /* Mark as being noted by relocation warning pass. */ - SET_BIT (nlist_bitvector, s - start_of_syms); - - if (g->undef_refs >= MAX_UREFS_PRINTED) /* Listed too many */ - continue; - - /* Undefined symbol which we should mention */ - - if (++(g->undef_refs) == MAX_UREFS_PRINTED) - { - errfmt = "More undefined symbol %s refs follow"; - invalidate_line_number = 1; - } - else - { - errfmt = "Undefined symbol %s referenced from %s segment"; - invalidate_line_number = 0; - } - } - else /* Defined */ - { - /* Potential symbol warning here */ - if (!g->warning) continue; - - /* Mark as being noted by relocation warning pass. */ - SET_BIT (nlist_bitvector, s - start_of_syms); - - errfmt = 0; - errmsg = g->warning; - invalidate_line_number = 0; - } - - - /* If errfmt == 0, errmsg has already been defined. */ - if (errfmt != 0) - { - char *nm; - - if (demangler == NULL || (nm = (*demangler)(g->name)) == NULL) - nm = g->name; - errmsg = (char *) xmalloc (strlen (errfmt) + strlen (nm) + 1); - sprintf (errmsg, errfmt, nm, data_segment ? "data" : "text"); - if (nm != g->name) - free (nm); - } - - address_to_line (RELOC_ADDRESS (reloc) + start_of_segment, - state_pointer); - - if (current->line >=0) - fprintf (outfile, "%s:%d: %s\n", current->filename, - invalidate_line_number ? 0 : current->line, errmsg); - else - fprintf (outfile, "%s: %s\n", current->filename, errmsg); - - if (errfmt != 0) - free (errmsg); - } - - free (state_pointer); -} - -/* Print on OUTFILE a list of all warnings generated by references - and/or definitions in the file ENTRY. List source file and line - number if possible, just the .o file if not. */ - -void -do_file_warnings (entry, outfile) - struct file_entry *entry; - FILE *outfile; -{ - int number_of_syms = entry->header.a_syms / sizeof (struct nlist); - unsigned char *nlist_bitvector - = (unsigned char *) alloca ((number_of_syms >> 3) + 1); - struct line_debug_entry *text_scan, *data_scan; - int i; - char *errfmt, *file_name; - int line_number; - int dont_allow_symbol_name; - - bzero (nlist_bitvector, (number_of_syms >> 3) + 1); - - /* Read in the files strings if they aren't available */ - if (!entry->strings) - { - int desc; - - entry->strings = (char *) alloca (entry->string_size); - desc = file_open (entry); - read_entry_strings (desc, entry); - } - - read_file_relocation (entry); - - /* Do text warnings based on a scan through the relocation info. */ - do_relocation_warnings (entry, 0, outfile, nlist_bitvector); - - /* Do data warnings based on a scan through the relocation info. */ - do_relocation_warnings (entry, 1, outfile, nlist_bitvector); - - /* Scan through all of the nlist entries in this file and pick up - anything that the scan through the relocation stuff didn't. */ - - text_scan = init_debug_scan (0, entry); - data_scan = init_debug_scan (1, entry); - - for (i = 0; i < number_of_syms; i++) - { - struct nlist *s; - struct glosym *g; - - s = entry->symbols + i; - - if (!(s->n_type & N_EXT)) - continue; - - g = (symbol *) s->n_un.n_name; - dont_allow_symbol_name = 0; - - if (list_multiple_defs && g->multiply_defined) - { - errfmt = "Definition of symbol %s (multiply defined)"; - switch (s->n_type) - { - case N_TEXT | N_EXT: - line_number = address_to_line (s->n_value, text_scan); - file_name = text_scan[0].filename; - break; - case N_DATA | N_EXT: - line_number = address_to_line (s->n_value, data_scan); - file_name = data_scan[0].filename; - break; - case N_SETA | N_EXT: - case N_SETT | N_EXT: - case N_SETD | N_EXT: - case N_SETB | N_EXT: - if (g->multiply_defined == 2) - continue; - errfmt = "First set element definition of symbol %s (multiply defined)"; - break; - default: - continue; /* Don't print out multiple defs - at references. */ - } - } - else if (BIT_SET_P (nlist_bitvector, i)) - continue; - else if (list_unresolved_refs && !g->defined) - { - if (g->undef_refs >= MAX_UREFS_PRINTED) - continue; - - if (++(g->undef_refs) == MAX_UREFS_PRINTED) - errfmt = "More undefined \"%s\" refs follow"; - else - errfmt = "Undefined symbol \"%s\" referenced"; - line_number = -1; - } - else if (g->warning) - { - /* There are two cases in which we don't want to - do this. The first is if this is a definition instead of - a reference. The second is if it's the reference used by - the warning stabs itself. */ - if (s->n_type != (N_EXT | N_UNDF) - || (i && (s-1)->n_type == N_WARNING)) - continue; - - errfmt = g->warning; - line_number = -1; - dont_allow_symbol_name = 1; - } - else - continue; - - if (line_number == -1) - fprintf (outfile, "%s: ", entry->filename); - else - fprintf (outfile, "%s:%d: ", file_name, line_number); - - if (dont_allow_symbol_name) - fprintf (outfile, "%s", errfmt); - else - { - char *nm; - if (demangler != NULL && (nm = (*demangler)(g->name)) != NULL) - { - fprintf (outfile, errfmt, nm); - free (nm); - } - else - fprintf (outfile, errfmt, g->name); - } - - fputc ('\n', outfile); - } - free (text_scan); - free (data_scan); - entry->strings = 0; /* Since it will dissapear anyway. */ -} - -do_warnings (outfile) - FILE *outfile; -{ - list_unresolved_refs = !relocatable_output && undefined_global_sym_count; - list_warning_symbols = warning_count; - list_multiple_defs = multiple_def_count != 0; - - if (!(list_unresolved_refs || - list_warning_symbols || - list_multiple_defs )) - /* No need to run this routine */ - return; - - each_file (do_file_warnings, outfile); - - if (list_unresolved_refs || list_multiple_defs) - make_executable = 0; -} - -/* Write the output file */ - -void -write_output () -{ - struct stat statbuf; - int filemode; - - (void) unlink (output_filename); - outdesc = open (output_filename, O_WRONLY | O_CREAT | O_TRUNC, 0666); - if (outdesc < 0) perror_name (output_filename); - - if (fstat (outdesc, &statbuf) < 0) - perror_name (output_filename); - - (void) fchflags(outdesc, statbuf.st_flags | UF_NODUMP); - - filemode = statbuf.st_mode; - (void) fchmod (outdesc, filemode & ~0111); - - /* Output the a.out header. */ - write_header (); - - /* Output the text and data segments, relocating as we go. */ - write_text (); - write_data (); - - /* Output the merged relocation info, if requested with `-r'. */ - if (relocatable_output) - write_rel (); - - /* Output the symbol table (both globals and locals). */ - write_syms (); - - /* Copy any GDB symbol segments from input files. */ - write_symsegs (); - - if (fchmod (outdesc, filemode | 0111) == -1) - perror_name (output_filename); - - close (outdesc); -} - -void modify_location (), perform_relocation (), copy_text (), copy_data (); - -void -write_header () -{ - N_SET_MAGIC (outheader, magic); - outheader.a_text = text_size; -#ifdef sequent - outheader.a_text += N_ADDRADJ (outheader); - if (entry_symbol == 0) - entry_symbol = getsym("start"); -#endif - outheader.a_data = data_size; - outheader.a_bss = bss_size; - outheader.a_entry = (entry_symbol ? entry_symbol->value - : text_start + entry_offset); -#ifdef COFF_ENCAPSULATE - if (need_coff_header) - { - /* We are encapsulating BSD format within COFF format. */ - struct coffscn *tp, *dp, *bp; - - tp = &coffheader.scns[0]; - dp = &coffheader.scns[1]; - bp = &coffheader.scns[2]; - - strcpy (tp->s_name, ".text"); - tp->s_paddr = text_start; - tp->s_vaddr = text_start; - tp->s_size = text_size; - tp->s_scnptr = sizeof (struct coffheader) + sizeof (struct exec); - tp->s_relptr = 0; - tp->s_lnnoptr = 0; - tp->s_nreloc = 0; - tp->s_nlnno = 0; - tp->s_flags = 0x20; - strcpy (dp->s_name, ".data"); - dp->s_paddr = data_start; - dp->s_vaddr = data_start; - dp->s_size = data_size; - dp->s_scnptr = tp->s_scnptr + tp->s_size; - dp->s_relptr = 0; - dp->s_lnnoptr = 0; - dp->s_nreloc = 0; - dp->s_nlnno = 0; - dp->s_flags = 0x40; - strcpy (bp->s_name, ".bss"); - bp->s_paddr = dp->s_vaddr + dp->s_size; - bp->s_vaddr = bp->s_paddr; - bp->s_size = bss_size; - bp->s_scnptr = 0; - bp->s_relptr = 0; - bp->s_lnnoptr = 0; - bp->s_nreloc = 0; - bp->s_nlnno = 0; - bp->s_flags = 0x80; - - coffheader.f_magic = COFF_MAGIC; - coffheader.f_nscns = 3; - /* store an unlikely time so programs can - * tell that there is a bsd header - */ - coffheader.f_timdat = 1; - coffheader.f_symptr = 0; - coffheader.f_nsyms = 0; - coffheader.f_opthdr = 28; - coffheader.f_flags = 0x103; - /* aouthdr */ - coffheader.magic = ZMAGIC; - coffheader.vstamp = 0; - coffheader.tsize = tp->s_size; - coffheader.dsize = dp->s_size; - coffheader.bsize = bp->s_size; - coffheader.entry = outheader.a_entry; - coffheader.text_start = tp->s_vaddr; - coffheader.data_start = dp->s_vaddr; - } -#endif - -#ifdef INITIALIZE_HEADER - INITIALIZE_HEADER; -#endif - - if (strip_symbols == STRIP_ALL) - nsyms = 0; - else - { - nsyms = (defined_global_sym_count - + undefined_global_sym_count); - if (discard_locals == DISCARD_L) - nsyms += non_L_local_sym_count; - else if (discard_locals == DISCARD_NONE) - nsyms += local_sym_count; - /* One extra for following reference on indirects */ - if (relocatable_output) - nsyms += set_symbol_count + global_indirect_count; - } - - if (strip_symbols == STRIP_NONE) - nsyms += debugger_sym_count; - - outheader.a_syms = nsyms * sizeof (struct nlist); - - if (relocatable_output) - { - outheader.a_trsize = text_reloc_size; - outheader.a_drsize = data_reloc_size; - } - else - { - outheader.a_trsize = 0; - outheader.a_drsize = 0; - } - -#ifdef COFF_ENCAPSULATE - if (need_coff_header) - mywrite (&coffheader, sizeof coffheader, 1, outdesc); -#endif - mywrite (&outheader, sizeof (struct exec), 1, outdesc); - - /* Output whatever padding is required in the executable file - between the header and the start of the text. */ - -#ifndef COFF_ENCAPSULATE - padfile (N_TXTOFF (outheader) - sizeof outheader, outdesc); -#endif -} - -/* Relocate the text segment of each input file - and write to the output file. */ - -void -write_text () -{ - if (trace_files) - fprintf (stderr, "Copying and relocating text:\n\n"); - - each_full_file (copy_text, 0); - file_close (); - - if (trace_files) - fprintf (stderr, "\n"); - - padfile (text_pad, outdesc); -} - -int -text_offset (entry) - struct file_entry *entry; -{ - return entry->starting_offset + N_TXTOFF (entry->header); -} - -/* Read in all of the relocation information */ - -void -read_relocation () -{ - each_full_file (read_file_relocation, 0); -} - -/* Read in the relocation sections of ENTRY if necessary */ - -void -read_file_relocation (entry) - struct file_entry *entry; -{ - register struct relocation_info *reloc; - int desc; - int read_return; - - desc = -1; - if (!entry->textrel) - { - reloc = (struct relocation_info *) xmalloc (entry->header.a_trsize); - desc = file_open (entry); - lseek (desc, - text_offset (entry) + entry->header.a_text + entry->header.a_data, - L_SET); - if (entry->header.a_trsize != (read_return = read (desc, reloc, entry->header.a_trsize))) - { - fprintf (stderr, "Return from read: %d\n", read_return); - fatal_with_file ("premature eof in text relocation of ", entry); - } - entry->textrel = reloc; - } - - if (!entry->datarel) - { - reloc = (struct relocation_info *) xmalloc (entry->header.a_drsize); - if (desc == -1) desc = file_open (entry); - lseek (desc, - text_offset (entry) + entry->header.a_text - + entry->header.a_data + entry->header.a_trsize, - L_SET); - if (entry->header.a_drsize != read (desc, reloc, entry->header.a_drsize)) - fatal_with_file ("premature eof in data relocation of ", entry); - entry->datarel = reloc; - } -} - -/* Read the text segment contents of ENTRY, relocate them, - and write the result to the output file. - If `-r', save the text relocation for later reuse. */ - -void -copy_text (entry) - struct file_entry *entry; -{ - register char *bytes; - register int desc; - register struct relocation_info *reloc; - - if (trace_files) - prline_file_name (entry, stderr); - - desc = file_open (entry); - - /* Allocate space for the file's text section */ - - bytes = (char *) alloca (entry->header.a_text); - - /* Deal with relocation information however is appropriate */ - - if (entry->textrel) reloc = entry->textrel; - else if (relocatable_output) - { - read_file_relocation (entry); - reloc = entry->textrel; - } - else - { - reloc = (struct relocation_info *) alloca (entry->header.a_trsize); - lseek (desc, text_offset (entry) + entry->header.a_text + entry->header.a_data, 0); - if (entry->header.a_trsize != read (desc, reloc, entry->header.a_trsize)) - fatal_with_file ("premature eof in text relocation of ", entry); - } - - /* Read the text section into core. */ - - lseek (desc, text_offset (entry), 0); - if (entry->header.a_text != read (desc, bytes, entry->header.a_text)) - fatal_with_file ("premature eof in text section of ", entry); - - - /* Relocate the text according to the text relocation. */ - - perform_relocation (bytes, entry->text_start_address, entry->header.a_text, - reloc, entry->header.a_trsize, entry); - - /* Write the relocated text to the output file. */ - - mywrite (bytes, 1, entry->header.a_text, outdesc); -} - -/* Relocate the data segment of each input file - and write to the output file. */ - -void -write_data () -{ - if (trace_files) - fprintf (stderr, "Copying and relocating data:\n\n"); - - each_full_file (copy_data, 0); - file_close (); - - /* Write out the set element vectors. See digest symbols for - description of length of the set vector section. */ - - if (set_vector_count) - mywrite (set_vectors, 2 * set_symbol_count + set_vector_count, - sizeof (unsigned long), outdesc); - - if (trace_files) - fprintf (stderr, "\n"); - - padfile (data_pad, outdesc); -} - -/* Read the data segment contents of ENTRY, relocate them, - and write the result to the output file. - If `-r', save the data relocation for later reuse. - See comments in `copy_text'. */ - -void -copy_data (entry) - struct file_entry *entry; -{ - register struct relocation_info *reloc; - register char *bytes; - register int desc; - - if (trace_files) - prline_file_name (entry, stderr); - - desc = file_open (entry); - - bytes = (char *) alloca (entry->header.a_data); - - if (entry->datarel) reloc = entry->datarel; - else if (relocatable_output) /* Will need this again */ - { - read_file_relocation (entry); - reloc = entry->datarel; - } - else - { - reloc = (struct relocation_info *) alloca (entry->header.a_drsize); - lseek (desc, text_offset (entry) + entry->header.a_text - + entry->header.a_data + entry->header.a_trsize, - 0); - if (entry->header.a_drsize != read (desc, reloc, entry->header.a_drsize)) - fatal_with_file ("premature eof in data relocation of ", entry); - } - - lseek (desc, text_offset (entry) + entry->header.a_text, 0); - if (entry->header.a_data != read (desc, bytes, entry->header.a_data)) - fatal_with_file ("premature eof in data section of ", entry); - - perform_relocation (bytes, entry->data_start_address - entry->header.a_text, - entry->header.a_data, reloc, entry->header.a_drsize, entry); - - mywrite (bytes, 1, entry->header.a_data, outdesc); -} - -/* Relocate ENTRY's text or data section contents. - DATA is the address of the contents, in core. - DATA_SIZE is the length of the contents. - PC_RELOCATION is the difference between the address of the contents - in the output file and its address in the input file. - RELOC_INFO is the address of the relocation info, in core. - RELOC_SIZE is its length in bytes. */ -/* This version is about to be severly hacked by Randy. Hope it - works afterwards. */ -void -perform_relocation (data, pc_relocation, data_size, reloc_info, reloc_size, entry) - char *data; - struct relocation_info *reloc_info; - struct file_entry *entry; - int pc_relocation; - int data_size; - int reloc_size; -{ - register struct relocation_info *p = reloc_info; - struct relocation_info *end - = reloc_info + reloc_size / sizeof (struct relocation_info); - int text_relocation = entry->text_start_address; - int data_relocation = entry->data_start_address - entry->header.a_text; - int bss_relocation - = entry->bss_start_address - entry->header.a_text - entry->header.a_data; - - for (; p < end; p++) - { - register int relocation = 0; - register int addr = RELOC_ADDRESS(p); - register unsigned int mask = 0; - - if (addr >= data_size) - fatal_with_file ("relocation address out of range in ", entry); - - if (RELOC_EXTERN_P(p)) - { - int symindex = RELOC_SYMBOL (p) * sizeof (struct nlist); - symbol *sp = ((symbol *) - (((struct nlist *) - (((char *)entry->symbols) + symindex)) - ->n_un.n_name)); - -#ifdef N_INDR - /* Resolve indirection */ - if ((sp->defined & ~N_EXT) == N_INDR) - sp = (symbol *) sp->value; -#endif - - if (symindex >= entry->header.a_syms) - fatal_with_file ("relocation symbolnum out of range in ", entry); - - /* If the symbol is undefined, leave it at zero. */ - if (! sp->defined) - relocation = 0; - else - relocation = sp->value; - } - else switch (RELOC_TYPE(p)) - { - case N_TEXT: - case N_TEXT | N_EXT: - relocation = text_relocation; - break; - - case N_DATA: - case N_DATA | N_EXT: - /* A word that points to beginning of the the data section - initially contains not 0 but rather the "address" of that section - in the input file, which is the length of the file's text. */ - relocation = data_relocation; - break; - - case N_BSS: - case N_BSS | N_EXT: - /* Similarly, an input word pointing to the beginning of the bss - initially contains the length of text plus data of the file. */ - relocation = bss_relocation; - break; - - case N_ABS: - case N_ABS | N_EXT: - /* Don't know why this code would occur, but apparently it does. */ - break; - - default: - fatal_with_file ("nonexternal relocation code invalid in ", entry); - } - -#ifdef RELOC_ADD_EXTRA - relocation += RELOC_ADD_EXTRA(p); - if (relocatable_output) - { - /* Non-PC relative relocations which are absolute - or which have become non-external now have fixed - relocations. Set the ADD_EXTRA of this relocation - to be the relocation we have now determined. */ - if (! RELOC_PCREL_P (p)) - { - if ((int)p->r_type <= RELOC_32 - || RELOC_EXTERN_P (p) == 0) - RELOC_ADD_EXTRA (p) = relocation; - } - /* External PC-relative relocations continue to move around; - update their relocations by the amount they have moved - so far. */ - else if (RELOC_EXTERN_P (p)) - RELOC_ADD_EXTRA (p) -= pc_relocation; - continue; - } -#endif - - if (RELOC_PCREL_P(p)) - relocation -= pc_relocation; - - relocation >>= RELOC_VALUE_RIGHTSHIFT(p); - - /* Unshifted mask for relocation */ - mask = 1 << RELOC_TARGET_BITSIZE(p) - 1; - mask |= mask - 1; - relocation &= mask; - - /* Shift everything up to where it's going to be used */ - relocation <<= RELOC_TARGET_BITPOS(p); - mask <<= RELOC_TARGET_BITPOS(p); - - switch (RELOC_TARGET_SIZE(p)) - { - case 0: - if (RELOC_MEMORY_SUB_P(p)) - relocation -= mask & *(char *) (data + addr); - else if (RELOC_MEMORY_ADD_P(p)) - relocation += mask & *(char *) (data + addr); - *(char *) (data + addr) &= ~mask; - *(char *) (data + addr) |= relocation; - break; - - case 1: -#ifdef tahoe - if (((int) data + addr & 1) == 0) - { -#endif - if (RELOC_MEMORY_SUB_P(p)) - relocation -= mask & *(short *) (data + addr); - else if (RELOC_MEMORY_ADD_P(p)) - relocation += mask & *(short *) (data + addr); - *(short *) (data + addr) &= ~mask; - *(short *) (data + addr) |= relocation; -#ifdef tahoe - } - /* - * The CCI Power 6 (aka Tahoe) architecture has byte-aligned - * instruction operands but requires data accesses to be aligned. - * Brain-damage... - */ - else - { - unsigned char *da = (unsigned char *) (data + addr); - unsigned short s = da[0] << 8 | da[1]; - - if (RELOC_MEMORY_SUB_P(p)) - relocation -= mask & s; - else if (RELOC_MEMORY_ADD_P(p)) - relocation += mask & s; - s &= ~mask; - s |= relocation; - da[0] = s >> 8; - da[1] = s; - } -#endif - break; - - case 2: -#ifndef _CROSS_TARGET_ARCH -#ifdef tahoe - if (((int) data + addr & 3) == 0) - { -#endif - if (RELOC_MEMORY_SUB_P(p)) - relocation -= mask & *(long *) (data + addr); - else if (RELOC_MEMORY_ADD_P(p)) - relocation += mask & *(long *) (data + addr); - *(long *) (data + addr) &= ~mask; - *(long *) (data + addr) |= relocation; -#ifdef tahoe - } - else - { - unsigned char *da = (unsigned char *) (data + addr); - unsigned long l = da[0] << 24 | da[1] << 16 | da[2] << 8 | da[3]; - - if (RELOC_MEMORY_SUB_P(p)) - relocation -= mask & l; - else if (RELOC_MEMORY_ADD_P(p)) - relocation += mask & l; - l &= ~mask; - l |= relocation; - da[0] = l >> 24; - da[1] = l >> 16; - da[2] = l >> 8; - da[3] = l; - } -#endif -#else - /* Handle long word alignment requirements of SPARC architecture */ - /* WARNING: This fix makes an assumption on byte ordering */ - /* Marc Ullman, Stanford University Nov. 1 1989 */ - if (RELOC_MEMORY_SUB_P(p)) { - relocation -= mask & - ((*(unsigned short *) (data + addr) << 16) | - *(unsigned short *) (data + addr + 2)); - } else if (RELOC_MEMORY_ADD_P(p)) { - relocation += mask & - ((*(unsigned short *) (data + addr) << 16) | - *(unsigned short *) (data + addr + 2)); - } - *(unsigned short *) (data + addr) &= (~mask >> 16); - *(unsigned short *) (data + addr + 2) &= (~mask & 0xffff); - *(unsigned short *) (data + addr) |= (relocation >> 16); - *(unsigned short *) (data + addr + 2) |= (relocation & 0xffff); -#endif - break; - - default: - fatal_with_file ("Unimplemented relocation field length in ", entry); - } - } -} - -/* For relocatable_output only: write out the relocation, - relocating the addresses-to-be-relocated. */ - -void coptxtrel (), copdatrel (); - -void -write_rel () -{ - register int i; - register int count = 0; - - if (trace_files) - fprintf (stderr, "Writing text relocation:\n\n"); - - /* Assign each global symbol a sequence number, giving the order - in which `write_syms' will write it. - This is so we can store the proper symbolnum fields - in relocation entries we write. */ - - for (i = 0; i < TABSIZE; i++) - { - symbol *sp; - for (sp = symtab[i]; sp; sp = sp->link) - if (sp->referenced || sp->defined) - { - sp->def_count = count++; - /* Leave room for the reference required by N_INDR, if - necessary. */ - if ((sp->defined & ~N_EXT) == N_INDR) - count++; - } - } - /* Correct, because if (relocatable_output), we will also be writing - whatever indirect blocks we have. */ - if (count != defined_global_sym_count - + undefined_global_sym_count + global_indirect_count) - fatal ("internal error"); - - /* Write out the relocations of all files, remembered from copy_text. */ - - each_full_file (coptxtrel, 0); - - if (trace_files) - fprintf (stderr, "\nWriting data relocation:\n\n"); - - each_full_file (copdatrel, 0); - - if (trace_files) - fprintf (stderr, "\n"); -} - -void -coptxtrel (entry) - struct file_entry *entry; -{ - register struct relocation_info *p, *end; - register int reloc = entry->text_start_address; - - p = entry->textrel; - end = (struct relocation_info *) (entry->header.a_trsize + (char *) p); - while (p < end) - { - RELOC_ADDRESS(p) += reloc; - if (RELOC_EXTERN_P(p)) - { - register int symindex = RELOC_SYMBOL(p) * sizeof (struct nlist); - symbol *symptr = ((symbol *) - (((struct nlist *) - (((char *)entry->symbols) + symindex)) - ->n_un.n_name)); - - if (symindex >= entry->header.a_syms) - fatal_with_file ("relocation symbolnum out of range in ", entry); - -#ifdef N_INDR - /* Resolve indirection. */ - if ((symptr->defined & ~N_EXT) == N_INDR) - symptr = (symbol *) symptr->value; -#endif - - /* If the symbol is now defined, change the external relocation - to an internal one. */ - - if (symptr->defined) - { - RELOC_EXTERN_P(p) = 0; - RELOC_SYMBOL(p) = (symptr->defined & N_TYPE); -#ifdef RELOC_ADD_EXTRA - /* If we aren't going to be adding in the value in - memory on the next pass of the loader, then we need - to add it in from the relocation entry. Otherwise - the work we did in this pass is lost. */ - if (!RELOC_MEMORY_ADD_P(p)) - RELOC_ADD_EXTRA (p) += symptr->value; -#endif - } - else - /* Debugger symbols come first, so have to start this - after them. */ - RELOC_SYMBOL(p) = (symptr->def_count + nsyms - - defined_global_sym_count - - undefined_global_sym_count - - global_indirect_count); - } - p++; - } - mywrite (entry->textrel, 1, entry->header.a_trsize, outdesc); -} - -void -copdatrel (entry) - struct file_entry *entry; -{ - register struct relocation_info *p, *end; - /* Relocate the address of the relocation. - Old address is relative to start of the input file's data section. - New address is relative to start of the output file's data section. */ - register int reloc = entry->data_start_address - text_size; - - p = entry->datarel; - end = (struct relocation_info *) (entry->header.a_drsize + (char *) p); - while (p < end) - { - RELOC_ADDRESS(p) += reloc; - if (RELOC_EXTERN_P(p)) - { - register int symindex = RELOC_SYMBOL(p) * sizeof (struct nlist); - symbol *symptr = ((symbol *) - (((struct nlist *) - (((char *)entry->symbols) + symindex)) - ->n_un.n_name)); - int symtype; - - if (symindex >= entry->header.a_syms) - fatal_with_file ("relocation symbolnum out of range in ", entry); - -#ifdef N_INDR - /* Resolve indirection. */ - if ((symptr->defined & ~N_EXT) == N_INDR) - symptr = (symbol *) symptr->value; -#endif - - symtype = symptr->defined & N_TYPE; - - if (force_common_definition - || symtype == N_DATA || symtype == N_TEXT || symtype == N_ABS) - { - RELOC_EXTERN_P(p) = 0; - RELOC_SYMBOL(p) = symtype; - } - else - /* Debugger symbols come first, so have to start this - after them. */ - RELOC_SYMBOL(p) - = (((symbol *) - (((struct nlist *) - (((char *)entry->symbols) + symindex)) - ->n_un.n_name)) - ->def_count - + nsyms - defined_global_sym_count - - undefined_global_sym_count - - global_indirect_count); - } - p++; - } - mywrite (entry->datarel, 1, entry->header.a_drsize, outdesc); -} - -void write_file_syms (); -void write_string_table (); - -/* Offsets and current lengths of symbol and string tables in output file. */ - -int symbol_table_offset; -int symbol_table_len; - -/* Address in output file where string table starts. */ -int string_table_offset; - -/* Offset within string table - where the strings in `strtab_vector' should be written. */ -int string_table_len; - -/* Total size of string table strings allocated so far, - including strings in `strtab_vector'. */ -int strtab_size; - -/* Vector whose elements are strings to be added to the string table. */ -char **strtab_vector; - -/* Vector whose elements are the lengths of those strings. */ -int *strtab_lens; - -/* Index in `strtab_vector' at which the next string will be stored. */ -int strtab_index; - -/* Add the string NAME to the output file string table. - Record it in `strtab_vector' to be output later. - Return the index within the string table that this string will have. */ - -int -assign_string_table_index (name) - char *name; -{ - register int index = strtab_size; - register int len = strlen (name) + 1; - - strtab_size += len; - strtab_vector[strtab_index] = name; - strtab_lens[strtab_index++] = len; - - return index; -} - -FILE *outstream = (FILE *) 0; - -/* Write the contents of `strtab_vector' into the string table. - This is done once for each file's local&debugger symbols - and once for the global symbols. */ - -void -write_string_table () -{ - register int i; - - lseek (outdesc, string_table_offset + string_table_len, 0); - - if (!outstream) - outstream = fdopen (outdesc, "w"); - - for (i = 0; i < strtab_index; i++) - { - fwrite (strtab_vector[i], 1, strtab_lens[i], outstream); - string_table_len += strtab_lens[i]; - } - - fflush (outstream); - - /* Report I/O error such as disk full. */ - if (ferror (outstream)) - perror_name (output_filename); -} - -/* Write the symbol table and string table of the output file. */ - -void -write_syms () -{ - /* Number of symbols written so far. */ - int syms_written = 0; - register int i; - register symbol *sp; - - /* Buffer big enough for all the global symbols. One - extra struct for each indirect symbol to hold the extra reference - following. */ - struct nlist *buf - = (struct nlist *) alloca ((defined_global_sym_count - + undefined_global_sym_count - + global_indirect_count) - * sizeof (struct nlist)); - /* Pointer for storing into BUF. */ - register struct nlist *bufp = buf; - - /* Size of string table includes the bytes that store the size. */ - strtab_size = sizeof strtab_size; - - symbol_table_offset = N_SYMOFF (outheader); - symbol_table_len = 0; - string_table_offset = N_STROFF (outheader); - string_table_len = strtab_size; - - if (strip_symbols == STRIP_ALL) - return; - - /* Write the local symbols defined by the various files. */ - - each_file (write_file_syms, &syms_written); - file_close (); - - /* Now write out the global symbols. */ - - /* Allocate two vectors that record the data to generate the string - table from the global symbols written so far. This must include - extra space for the references following indirect outputs. */ - - strtab_vector = (char **) alloca ((num_hash_tab_syms - + global_indirect_count) * sizeof (char *)); - strtab_lens = (int *) alloca ((num_hash_tab_syms - + global_indirect_count) * sizeof (int)); - strtab_index = 0; - - /* Scan the symbol hash table, bucket by bucket. */ - - for (i = 0; i < TABSIZE; i++) - for (sp = symtab[i]; sp; sp = sp->link) - { - struct nlist nl; - - nl.n_other = 0; - nl.n_desc = 0; - - /* Compute a `struct nlist' for the symbol. */ - - if (sp->defined || sp->referenced) - { - /* common condition needs to be before undefined condition */ - /* because unallocated commons are set undefined in */ - /* digest_symbols */ - if (sp->defined > 1) /* defined with known type */ - { - /* If the target of an indirect symbol has been - defined and we are outputting an executable, - resolve the indirection; it's no longer needed */ - if (!relocatable_output - && ((sp->defined & N_TYPE) == N_INDR) - && (((symbol *) sp->value)->defined > 1)) - { - symbol *newsp = (symbol *) sp->value; - nl.n_type = newsp->defined; - nl.n_value = newsp->value; - } - else - { - nl.n_type = sp->defined; - if (sp->defined != (N_INDR | N_EXT)) - nl.n_value = sp->value; - else - nl.n_value = 0; - } - } - else if (sp->max_common_size) /* defined as common but not allocated. */ - { - /* happens only with -r and not -d */ - /* write out a common definition */ - nl.n_type = N_UNDF | N_EXT; - nl.n_value = sp->max_common_size; - } - else if (!sp->defined) /* undefined -- legit only if -r */ - { - nl.n_type = N_UNDF | N_EXT; - nl.n_value = 0; - } - else - fatal ("internal error: %s defined in mysterious way", sp->name); - - /* Allocate string table space for the symbol name. */ - - nl.n_un.n_strx = assign_string_table_index (sp->name); - - /* Output to the buffer and count it. */ - - *bufp++ = nl; - syms_written++; - if (nl.n_type == (N_INDR | N_EXT)) - { - struct nlist xtra_ref; - xtra_ref.n_type = N_EXT | N_UNDF; - xtra_ref.n_un.n_strx - = assign_string_table_index (((symbol *) sp->value)->name); - xtra_ref.n_other = 0; - xtra_ref.n_desc = 0; - xtra_ref.n_value = 0; - *bufp++ = xtra_ref; - syms_written++; - } - } - } - - /* Output the buffer full of `struct nlist's. */ - - lseek (outdesc, symbol_table_offset + symbol_table_len, 0); - mywrite (buf, sizeof (struct nlist), bufp - buf, outdesc); - symbol_table_len += sizeof (struct nlist) * (bufp - buf); - - if (syms_written != nsyms) - fatal ("internal error: wrong number of symbols written into output file", 0); - - if (symbol_table_offset + symbol_table_len != string_table_offset) - fatal ("internal error: inconsistent symbol table length", 0); - - /* Now the total string table size is known, so write it. - We are already positioned at the right place in the file. */ - - mywrite (&strtab_size, sizeof (int), 1, outdesc); /* we're at right place */ - - /* Write the strings for the global symbols. */ - - write_string_table (); -} - -/* Write the local and debugger symbols of file ENTRY. - Increment *SYMS_WRITTEN_ADDR for each symbol that is written. */ - -/* Note that we do not combine identical names of local symbols. - dbx or gdb would be confused if we did that. */ - -void -write_file_syms (entry, syms_written_addr) - struct file_entry *entry; - int *syms_written_addr; -{ - register struct nlist *p = entry->symbols; - register struct nlist *end = p + entry->header.a_syms / sizeof (struct nlist); - - /* Buffer to accumulate all the syms before writing them. - It has one extra slot for the local symbol we generate here. */ - struct nlist *buf - = (struct nlist *) alloca (entry->header.a_syms + sizeof (struct nlist)); - register struct nlist *bufp = buf; - - /* Upper bound on number of syms to be written here. */ - int max_syms = (entry->header.a_syms / sizeof (struct nlist)) + 1; - - /* Make tables that record, for each symbol, its name and its name's length. - The elements are filled in by `assign_string_table_index'. */ - - strtab_vector = (char **) alloca (max_syms * sizeof (char *)); - strtab_lens = (int *) alloca (max_syms * sizeof (int)); - strtab_index = 0; - - /* Generate a local symbol for the start of this file's text. */ - - if (discard_locals != DISCARD_ALL) - { - struct nlist nl; - - nl.n_type = N_FN | N_EXT; - nl.n_un.n_strx = assign_string_table_index (entry->local_sym_name); - nl.n_value = entry->text_start_address; - nl.n_desc = 0; - nl.n_other = 0; - *bufp++ = nl; - (*syms_written_addr)++; - entry->local_syms_offset = *syms_written_addr * sizeof (struct nlist); - } - - /* Read the file's string table. */ - - entry->strings = (char *) alloca (entry->string_size); - read_entry_strings (file_open (entry), entry); - - for (; p < end; p++) - { - register int type = p->n_type; - register int write = 0; - - /* WRITE gets 1 for a non-global symbol that should be written. */ - - - if (SET_ELEMENT_P (type)) /* This occurs even if global. These */ - /* types of symbols are never written */ - /* globally, though they are stored */ - /* globally. */ - write = relocatable_output; - else if (!(type & (N_STAB | N_EXT))) - /* ordinary local symbol */ - write = ((discard_locals != DISCARD_ALL) - && !(discard_locals == DISCARD_L && - (p->n_un.n_strx + entry->strings)[0] == LPREFIX) - && type != N_WARNING); - else if (!(type & N_EXT)) - /* debugger symbol */ - write = (strip_symbols == STRIP_NONE); - - if (write) - { - /* If this symbol has a name, - allocate space for it in the output string table. */ - - if (p->n_un.n_strx) - p->n_un.n_strx = assign_string_table_index (p->n_un.n_strx - + entry->strings); - - /* Output this symbol to the buffer and count it. */ - - *bufp++ = *p; - (*syms_written_addr)++; - } - } - - /* All the symbols are now in BUF; write them. */ - - lseek (outdesc, symbol_table_offset + symbol_table_len, 0); - mywrite (buf, sizeof (struct nlist), bufp - buf, outdesc); - symbol_table_len += sizeof (struct nlist) * (bufp - buf); - - /* Write the string-table data for the symbols just written, - using the data in vectors `strtab_vector' and `strtab_lens'. */ - - write_string_table (); - entry->strings = 0; /* Since it will dissapear anyway. */ -} - -/* Copy any GDB symbol segments from the input files to the output file. - The contents of the symbol segment is copied without change - except that we store some information into the beginning of it. */ - -void write_file_symseg (); - -void -write_symsegs () -{ - each_file (write_file_symseg, 0); -} - -void -write_file_symseg (entry) - struct file_entry *entry; -{ - char buffer[4096]; - struct symbol_root root; - int indesc; - int len; - - if (entry->symseg_offset == 0) - return; - - /* This entry has a symbol segment. Read the root of the segment. */ - - indesc = file_open (entry); - lseek (indesc, entry->symseg_offset + entry->starting_offset, 0); - if (sizeof root != read (indesc, &root, sizeof root)) - fatal_with_file ("premature end of file in symbol segment of ", entry); - - /* Store some relocation info into the root. */ - - root.ldsymoff = entry->local_syms_offset; - root.textrel = entry->text_start_address; - root.datarel = entry->data_start_address - entry->header.a_text; - root.bssrel = entry->bss_start_address - - entry->header.a_text - entry->header.a_data; - root.databeg = entry->data_start_address - root.datarel; - root.bssbeg = entry->bss_start_address - root.bssrel; - - /* Write the modified root into the output file. */ - - mywrite (&root, sizeof root, 1, outdesc); - - /* Copy the rest of the symbol segment unchanged. */ - - if (entry->superfile) - { - /* Library member: number of bytes to copy is determined - from the member's total size. */ - - int total = entry->total_size - entry->symseg_offset - sizeof root; - - while (total > 0) - { - len = read (indesc, buffer, min (sizeof buffer, total)); - - if (len != min (sizeof buffer, total)) - fatal_with_file ("premature end of file in symbol segment of ", entry); - total -= len; - mywrite (buffer, len, 1, outdesc); - } - } - else - { - /* A separate file: copy until end of file. */ - - while (len = read (indesc, buffer, sizeof buffer)) - { - mywrite (buffer, len, 1, outdesc); - if (len < sizeof buffer) - break; - } - } - - file_close (); -} - -/* Create the symbol table entries for `etext', `edata' and `end'. */ - -void -symtab_init () -{ -#ifndef nounderscore - edata_symbol = getsym ("_edata"); - etext_symbol = getsym ("_etext"); - end_symbol = getsym ("_end"); -#else - edata_symbol = getsym ("edata"); - etext_symbol = getsym ("etext"); - end_symbol = getsym ("end"); -#endif - -#ifdef sun - { - symbol *dynamic_symbol = getsym ("__DYNAMIC"); - dynamic_symbol->defined = N_ABS | N_EXT; - dynamic_symbol->referenced = 1; - dynamic_symbol->value = 0; - } -#endif - -#ifdef sequent - { - symbol *_387_flt_symbol = getsym ("_387_flt"); - _387_flt_symbol->defined = N_ABS | N_EXT; - _387_flt_symbol->referenced = 1; - _387_flt_symbol->value = 0; - } -#endif - - edata_symbol->defined = N_DATA | N_EXT; - etext_symbol->defined = N_TEXT | N_EXT; - end_symbol->defined = N_BSS | N_EXT; - - edata_symbol->referenced = 1; - etext_symbol->referenced = 1; - end_symbol->referenced = 1; -} - -/* Compute the hash code for symbol name KEY. */ - -int -hash_string (key) - char *key; -{ - register char *cp; - register int k; - - cp = key; - k = 0; - while (*cp) - k = (((k << 1) + (k >> 14)) ^ (*cp++)) & 0x3fff; - - return k; -} - -/* Get the symbol table entry for the global symbol named KEY. - Create one if there is none. */ - -symbol * -getsym (key) - char *key; -{ - register int hashval; - register symbol *bp; - - /* Determine the proper bucket. */ - - hashval = hash_string (key) % TABSIZE; - - /* Search the bucket. */ - - for (bp = symtab[hashval]; bp; bp = bp->link) - if (! strcmp (key, bp->name)) - return bp; - - /* Nothing was found; create a new symbol table entry. */ - - bp = (symbol *) xmalloc (sizeof (symbol)); - bp->refs = 0; - bp->name = (char *) xmalloc (strlen (key) + 1); - strcpy (bp->name, key); - bp->defined = 0; - bp->referenced = 0; - bp->trace = 0; - bp->value = 0; - bp->max_common_size = 0; - bp->warning = 0; - bp->undef_refs = 0; - bp->multiply_defined = 0; - - /* Add the entry to the bucket. */ - - bp->link = symtab[hashval]; - symtab[hashval] = bp; - - ++num_hash_tab_syms; - - return bp; -} - -/* Like `getsym' but return 0 if the symbol is not already known. */ - -symbol * -getsym_soft (key) - char *key; -{ - register int hashval; - register symbol *bp; - - /* Determine which bucket. */ - - hashval = hash_string (key) % TABSIZE; - - /* Search the bucket. */ - - for (bp = symtab[hashval]; bp; bp = bp->link) - if (! strcmp (key, bp->name)) - return bp; - - return 0; -} - -/* Report a fatal error. - STRING is a printf format string and ARG is one arg for it. */ - -void -fatal (string, arg) - char *string, *arg; -{ - fprintf (stderr, "ld: "); - fprintf (stderr, string, arg); - fprintf (stderr, "\n"); - exit (1); -} - -/* Report a fatal error. The error message is STRING - followed by the filename of ENTRY. */ - -void -fatal_with_file (string, entry) - char *string; - struct file_entry *entry; -{ - fprintf (stderr, "ld: "); - fprintf (stderr, string); - print_file_name (entry, stderr); - fprintf (stderr, "\n"); - exit (1); -} - -/* Report a fatal error using the message for the last failed system call, - followed by the string NAME. */ - -void -perror_name (name) - char *name; -{ - extern int errno; - char *s; - - if (errno < sys_nerr) - s = concat ("", sys_errlist[errno], " for %s"); - else - s = "cannot open %s"; - fatal (s, name); -} - -/* Report a fatal error using the message for the last failed system call, - followed by the name of file ENTRY. */ - -void -perror_file (entry) - struct file_entry *entry; -{ - extern int errno; - char *s; - - if (errno < sys_nerr) - s = concat ("", sys_errlist[errno], " for "); - else - s = "cannot open "; - fatal_with_file (s, entry); -} - -/* Report a nonfatal error. - STRING is a format for printf, and ARG1 ... ARG3 are args for it. */ - -void -error (string, arg1, arg2, arg3) - char *string, *arg1, *arg2, *arg3; -{ - fprintf (stderr, "%s: ", progname); - fprintf (stderr, string, arg1, arg2, arg3); - fprintf (stderr, "\n"); -} - - -/* Output COUNT*ELTSIZE bytes of data at BUF - to the descriptor DESC. */ - -void -mywrite (buf, count, eltsize, desc) - char *buf; - int count; - int eltsize; - int desc; -{ - register int val; - register int bytes = count * eltsize; - - while (bytes > 0) - { - val = write (desc, buf, bytes); - if (val <= 0) - perror_name (output_filename); - buf += val; - bytes -= val; - } -} - -/* Output PADDING zero-bytes to descriptor OUTDESC. - PADDING may be negative; in that case, do nothing. */ - -void -padfile (padding, outdesc) - int padding; - int outdesc; -{ - register char *buf; - if (padding <= 0) - return; - - buf = (char *) alloca (padding); - bzero (buf, padding); - mywrite (buf, padding, 1, outdesc); -} - -/* Return a newly-allocated string - whose contents concatenate the strings S1, S2, S3. */ - -char * -concat (s1, s2, s3) - char *s1, *s2, *s3; -{ - register int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); - register char *result = (char *) xmalloc (len1 + len2 + len3 + 1); - - strcpy (result, s1); - strcpy (result + len1, s2); - strcpy (result + len1 + len2, s3); - result[len1 + len2 + len3] = 0; - - return result; -} - -/* Parse the string ARG using scanf format FORMAT, and return the result. - If it does not parse, report fatal error - generating the error message using format string ERROR and ARG as arg. */ - -int -parse (arg, format, error) - char *arg, *format; -{ - int x; - if (1 != sscanf (arg, format, &x)) - fatal (error, arg); - return x; -} - -/* Like malloc but get fatal error if memory is exhausted. */ - -int -xmalloc (size) - int size; -{ - register int result = malloc (size); - if (!result) - fatal ("virtual memory exhausted", 0); - return result; -} - -/* Like realloc but get fatal error if memory is exhausted. */ - -int -xrealloc (ptr, size) - char *ptr; - int size; -{ - register int result = realloc (ptr, size); - if (!result) - fatal ("virtual memory exhausted", 0); - return result; -} - -#ifdef USG - -void -bzero (p, n) - char *p; -{ - memset (p, 0, n); -} - -void -bcopy (from, to, n) - char *from, *to; -{ - memcpy (to, from, n); -} - -getpagesize () -{ - return (4096); -} - -#endif - -#if defined(sun) && (TARGET == SUN4) - -/* Don't use local pagesize to build for Sparc. */ - -getpagesize () -{ - return (8192); -} -#endif diff --git a/usr.bin/ld/symseg.h b/usr.bin/ld/symseg.h deleted file mode 100644 index 978d8be..0000000 --- a/usr.bin/ld/symseg.h +++ /dev/null @@ -1,358 +0,0 @@ -/*- - * - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * @(#)symseg.h 8.1 (Berkeley) 6/6/93 - */ - -/* GDB symbol table format definitions. - Copyright (C) 1987, 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 1, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Format of GDB symbol table data. - There is one symbol segment for each source file or - independant compilation. These segments are simply concatenated - to form the GDB symbol table. A zero word where the beginning - of a segment is expected indicates there are no more segments. - -Format of a symbol segment: - - The symbol segment begins with a word containing 1 - if it is in the format described here. Other formats may - be designed, with other code numbers. - - The segment contains many objects which point at each other. - The pointers are offsets in bytes from the beginning of the segment. - Thus, each segment can be loaded into core and its pointers relocated - to make valid in-core pointers. - - All the data objects in the segment can be found indirectly from - one of them, the root object, of type `struct symbol_root'. - It appears at the beginning of the segment. - - The total size of the segment, in bytes, appears as the `length' - field of this object. This size includes the size of the - root object. - - All the object data types are defined here to contain pointer types - appropriate for in-core use on a relocated symbol segment. - Casts to and from type int are required for working with - unrelocated symbol segments such as are found in the file. - - The ldsymaddr word is filled in by the loader to contain - the offset (in bytes) within the ld symbol table - of the first nonglobal symbol from this compilation. - This makes it possible to match those symbols - (which contain line number information) reliably with - the segment they go with. - - Core addresses within the program that appear in the symbol segment - are not relocated by the loader. They are inserted by the assembler - and apply to addresses as output by the assembler, so GDB must - relocate them when it loads the symbol segment. It gets the information - on how to relocate from the textrel, datarel, bssrel, databeg and bssbeg - words of the root object. - - The words textrel, datarel and bssrel - are filled in by ld with the amounts to relocate within-the-file - text, data and bss addresses by; databeg and bssbeg can be - used to tell which kind of relocation an address needs. */ - -enum language {language_c}; - -struct symbol_root -{ - int format; /* Data format version */ - int length; /* # bytes in this symbol segment */ - int ldsymoff; /* Offset in ld symtab of this file's syms */ - int textrel; /* Relocation for text addresses */ - int datarel; /* Relocation for data addresses */ - int bssrel; /* Relocation for bss addresses */ - char *filename; /* Name of main source file compiled */ - char *filedir; /* Name of directory it was reached from */ - struct blockvector *blockvector; /* Vector of all symbol-naming blocks */ - struct typevector *typevector; /* Vector of all data types */ - enum language language; /* Code identifying the language used */ - char *version; /* Version info. Not fully specified */ - char *compilation; /* Compilation info. Not fully specified */ - int databeg; /* Address within the file of data start */ - int bssbeg; /* Address within the file of bss start */ - struct sourcevector *sourcevector; /* Vector of line-number info */ -}; - -/* All data types of symbols in the compiled program - are represented by `struct type' objects. - All of these objects are pointed to by the typevector. - The type vector may have empty slots that contain zero. */ - -struct typevector -{ - int length; /* Number of types described */ - struct type *type[1]; -}; - -/* Different kinds of data types are distinguished by the `code' field. */ - -enum type_code -{ - TYPE_CODE_UNDEF, /* Not used; catches errors */ - TYPE_CODE_PTR, /* Pointer type */ - TYPE_CODE_ARRAY, /* Array type, lower bound zero */ - TYPE_CODE_STRUCT, /* C struct or Pascal record */ - TYPE_CODE_UNION, /* C union or Pascal variant part */ - TYPE_CODE_ENUM, /* Enumeration type */ - TYPE_CODE_FUNC, /* Function type */ - TYPE_CODE_INT, /* Integer type */ - TYPE_CODE_FLT, /* Floating type */ - TYPE_CODE_VOID, /* Void type (values zero length) */ - TYPE_CODE_SET, /* Pascal sets */ - TYPE_CODE_RANGE, /* Range (integers within spec'd bounds) */ - TYPE_CODE_PASCAL_ARRAY, /* Array with explicit type of index */ -}; - -/* This appears in a type's flags word for an unsigned integer type. */ -#define TYPE_FLAG_UNSIGNED 1 - -/* Other flag bits are used with GDB. */ - -struct type -{ - /* Code for kind of type */ - enum type_code code; - /* Name of this type, or zero if none. - This is used for printing only. - Type names specified as input are defined by symbols. */ - char *name; - /* Length in bytes of storage for a value of this type */ - int length; - /* For a pointer type, describes the type of object pointed to. - For an array type, describes the type of the elements. - For a function type, describes the type of the value. - Unused otherwise. */ - struct type *target_type; - /* Type that is a pointer to this type. - Zero if no such pointer-to type is known yet. - The debugger may add the address of such a type - if it has to construct one later. */ - struct type *pointer_type; - /* Type that is a function returning this type. - Zero if no such function type is known here. - The debugger may add the address of such a type - if it has to construct one later. */ - struct type *function_type; - /* Flags about this type. */ - short flags; - /* Number of fields described for this type */ - short nfields; - /* For structure and union types, a description of each field. - For set and pascal array types, there is one "field", - whose type is the domain type of the set or array. - For range types, there are two "fields", - the minimum and maximum values (both inclusive). - For enum types, each possible value is described by one "field". - For range types, there are two "fields", that record constant values - (inclusive) for the minimum and maximum. - - Using a pointer to a separate array of fields - allows all types to have the same size, which is useful - because we can allocate the space for a type before - we know what to put in it. */ - struct field - { - /* Position of this field, counting in bits from start of - containing structure. For a function type, this is the - position in the argument list of this argument. - For a range bound or enum value, this is the value itself. */ - int bitpos; - /* Size of this field, in bits, or zero if not packed. - For an unpacked field, the field's type's length - says how many bytes the field occupies. */ - int bitsize; - /* In a struct or enum type, type of this field. - In a function type, type of this argument. - In an array type, the domain-type of the array. */ - struct type *type; - /* Name of field, value or argument. - Zero for range bounds and array domains. */ - char *name; - } *fields; -}; - -/* All of the name-scope contours of the program - are represented by `struct block' objects. - All of these objects are pointed to by the blockvector. - - Each block represents one name scope. - Each lexical context has its own block. - - The first two blocks in the blockvector are special. - The first one contains all the symbols defined in this compilation - whose scope is the entire program linked together. - The second one contains all the symbols whose scope is the - entire compilation excluding other separate compilations. - In C, these correspond to global symbols and static symbols. - - Each block records a range of core addresses for the code that - is in the scope of the block. The first two special blocks - give, for the range of code, the entire range of code produced - by the compilation that the symbol segment belongs to. - - The blocks appear in the blockvector - in order of increasing starting-address, - and, within that, in order of decreasing ending-address. - - This implies that within the body of one function - the blocks appear in the order of a depth-first tree walk. */ - -struct blockvector -{ - /* Number of blocks in the list. */ - int nblocks; - /* The blocks themselves. */ - struct block *block[1]; -}; - -struct block -{ - /* Addresses in the executable code that are in this block. - Note: in an unrelocated symbol segment in a file, - these are always zero. They can be filled in from the - N_LBRAC and N_RBRAC symbols in the loader symbol table. */ - int startaddr, endaddr; - /* The symbol that names this block, - if the block is the body of a function; - otherwise, zero. - Note: In an unrelocated symbol segment in an object file, - this field may be zero even when the block has a name. - That is because the block is output before the name - (since the name resides in a higher block). - Since the symbol does point to the block (as its value), - it is possible to find the block and set its name properly. */ - struct symbol *function; - /* The `struct block' for the containing block, or 0 if none. */ - /* Note that in an unrelocated symbol segment in an object file - this pointer may be zero when the correct value should be - the second special block (for symbols whose scope is one compilation). - This is because the compiler ouptuts the special blocks at the - very end, after the other blocks. */ - struct block *superblock; - /* Number of local symbols. */ - int nsyms; - /* The symbols. */ - struct symbol *sym[1]; -}; - -/* Represent one symbol name; a variable, constant, function or typedef. */ - -/* Different name spaces for symbols. Looking up a symbol specifies - a namespace and ignores symbol definitions in other name spaces. - - VAR_NAMESPACE is the usual namespace. - In C, this contains variables, function names, typedef names - and enum type values. - - STRUCT_NAMESPACE is used in C to hold struct, union and enum type names. - Thus, if `struct foo' is used in a C program, - it produces a symbol named `foo' in the STRUCT_NAMESPACE. - - LABEL_NAMESPACE may be used for names of labels (for gotos); - currently it is not used and labels are not recorded at all. */ - -/* For a non-global symbol allocated statically, - the correct core address cannot be determined by the compiler. - The compiler puts an index number into the symbol's value field. - This index number can be matched with the "desc" field of - an entry in the loader symbol table. */ - -enum namespace -{ - UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE, LABEL_NAMESPACE, -}; - -/* An address-class says where to find the value of the symbol in core. */ - -enum address_class -{ - LOC_UNDEF, /* Not used; catches errors */ - LOC_CONST, /* Value is constant int */ - LOC_STATIC, /* Value is at fixed address */ - LOC_REGISTER, /* Value is in register */ - LOC_ARG, /* Value is at spec'd position in arglist */ - LOC_LOCAL, /* Value is at spec'd pos in stack frame */ - LOC_TYPEDEF, /* Value not used; definition in SYMBOL_TYPE - Symbols in the namespace STRUCT_NAMESPACE - all have this class. */ - LOC_LABEL, /* Value is address in the code */ - LOC_BLOCK, /* Value is address of a `struct block'. - Function names have this class. */ - LOC_EXTERNAL, /* Value is at address not in this compilation. - This is used for .comm symbols - and for extern symbols within functions. - Inside GDB, this is changed to LOC_STATIC once the - real address is obtained from a loader symbol. */ - LOC_CONST_BYTES /* Value is a constant byte-sequence. */ -}; - -struct symbol -{ - /* Symbol name */ - char *name; - /* Name space code. */ - enum namespace namespace; - /* Address class */ - enum address_class class; - /* Data type of value */ - struct type *type; - /* constant value, or address if static, or register number, - or offset in arguments, or offset in stack frame. */ - union - { - long value; - struct block *block; /* for LOC_BLOCK */ - char *bytes; /* for LOC_CONST_BYTES */ - } - value; -}; - -/* Source-file information. - This describes the relation between source files and line numbers - and addresses in the program text. */ - -struct sourcevector -{ - int length; /* Number of source files described */ - struct source *source[1]; /* Descriptions of the files */ -}; - -/* Line number and address of one line. */ - -struct line -{ - int linenum; - int address; -}; - -/* All the information on one source file. */ - -struct source -{ - char *name; /* Name of file */ - int nlines; /* Number of lines that follow */ - struct line lines[1]; /* Information on each line */ -}; diff --git a/usr.bin/lex/flex.1 b/usr.bin/lex/flex.1 deleted file mode 100644 index 6aba4d6..0000000 --- a/usr.bin/lex/flex.1 +++ /dev/null @@ -1,1001 +0,0 @@ -.TH FLEX 1 "November 1993" "Version 2.4" -.SH NAME -flex \- fast lexical analyzer generator -.SH SYNOPSIS -.B flex -.B [\-bcdfhilnpstvwBFILTV78+ \-C[aefFmr] \-Pprefix \-Sskeleton] -.I [filename ...] -.SH DESCRIPTION -.I flex -is a tool for generating -.I scanners: -programs which recognized lexical patterns in text. -.I flex -reads -the given input files, or its standard input if no file names are given, -for a description of a scanner to generate. The description is in -the form of pairs -of regular expressions and C code, called -.I rules. flex -generates as output a C source file, -.B lex.yy.c, -which defines a routine -.B yylex(). -This file is compiled and linked with the -.B \-lfl -library to produce an executable. When the executable is run, -it analyzes its input for occurrences -of the regular expressions. Whenever it finds one, it executes -the corresponding C code. -.PP -For full documentation, see -.B flexdoc(1). -This manual entry is intended for use as a quick reference. -.SH OPTIONS -.I flex -has the following options: -.TP -.B \-b -generate backing-up information to -.I lex.backup. -This is a list of scanner states which require backing up and the input -characters on which they do so. By adding rules one can remove -backing-up states. If all backing-up states are eliminated and -.B \-Cf -or -.B \-CF -is used, the generated scanner will run faster. -.TP -.B \-c -is a do-nothing, deprecated option included for POSIX compliance. -.IP -.B NOTE: -in previous releases of -.I flex -.B \-c -specified table-compression options. This functionality is -now given by the -.B \-C -flag. To ease the the impact of this change, when -.I flex -encounters -.B \-c, -it currently issues a warning message and assumes that -.B \-C -was desired instead. In the future this "promotion" of -.B \-c -to -.B \-C -will go away in the name of full POSIX compliance (unless -the POSIX meaning is removed first). -.TP -.B \-d -makes the generated scanner run in -.I debug -mode. Whenever a pattern is recognized and the global -.B yy_flex_debug -is non-zero (which is the default), the scanner will -write to -.I stderr -a line of the form: -.nf - - --accepting rule at line 53 ("the matched text") - -.fi -The line number refers to the location of the rule in the file -defining the scanner (i.e., the file that was fed to flex). Messages -are also generated when the scanner backs up, accepts the -default rule, reaches the end of its input buffer (or encounters -a NUL; the two look the same as far as the scanner's concerned), -or reaches an end-of-file. -.TP -.B \-f -specifies -.I fast scanner. -No table compression is done and stdio is bypassed. -The result is large but fast. This option is equivalent to -.B \-Cfr -(see below). -.TP -.B \-h -generates a "help" summary of -.I flex's -options to -.I stderr -and then exits. -.TP -.B \-i -instructs -.I flex -to generate a -.I case-insensitive -scanner. The case of letters given in the -.I flex -input patterns will -be ignored, and tokens in the input will be matched regardless of case. The -matched text given in -.I yytext -will have the preserved case (i.e., it will not be folded). -.TP -.B \-l -turns on maximum compatibility with the original AT&T lex implementation, -at a considerable performance cost. This option is incompatible with -.B \-+, \-f, \-F, \-Cf, -or -.B \-CF. -See -.I flexdoc(1) -for details. -.TP -.B \-n -is another do-nothing, deprecated option included only for -POSIX compliance. -.TP -.B \-p -generates a performance report to stderr. The report -consists of comments regarding features of the -.I flex -input file which will cause a loss of performance in the resulting scanner. -If you give the flag twice, you will also get comments regarding -features that lead to minor performance losses. -.TP -.B \-s -causes the -.I default rule -(that unmatched scanner input is echoed to -.I stdout) -to be suppressed. If the scanner encounters input that does not -match any of its rules, it aborts with an error. -.TP -.B \-t -instructs -.I flex -to write the scanner it generates to standard output instead -of -.B lex.yy.c. -.TP -.B \-v -specifies that -.I flex -should write to -.I stderr -a summary of statistics regarding the scanner it generates. -.TP -.B \-w -suppresses warning messages. -.TP -.B \-B -instructs -.I flex -to generate a -.I batch -scanner instead of an -.I interactive -scanner (see -.B \-I -below). See -.I flexdoc(1) -for details. Scanners using -.B \-Cf -or -.B \-CF -compression options automatically specify this option, too. -.TP -.B \-F -specifies that the -.ul -fast -scanner table representation should be used (and stdio bypassed). -This representation is about as fast as the full table representation -.B (-f), -and for some sets of patterns will be considerably smaller (and for -others, larger). It cannot be used with the -.B \-+ -option. See -.B flexdoc(1) -for more details. -.IP -This option is equivalent to -.B \-CFr -(see below). -.TP -.B \-I -instructs -.I flex -to generate an -.I interactive -scanner, that is, a scanner which stops immediately rather than -looking ahead if it knows -that the currently scanned text cannot be part of a longer rule's match. -This is the opposite of -.I batch -scanners (see -.B \-B -above). See -.B flexdoc(1) -for details. -.IP -Note, -.B \-I -cannot be used in conjunction with -.I full -or -.I fast tables, -i.e., the -.B \-f, \-F, \-Cf, -or -.B \-CF -flags. For other table compression options, -.B \-I -is the default. -.TP -.B \-L -instructs -.I flex -not to generate -.B #line -directives in -.B lex.yy.c. -The default is to generate such directives so error -messages in the actions will be correctly -located with respect to the original -.I flex -input file, and not to -the fairly meaningless line numbers of -.B lex.yy.c. -.TP -.B \-T -makes -.I flex -run in -.I trace -mode. It will generate a lot of messages to -.I stderr -concerning -the form of the input and the resultant non-deterministic and deterministic -finite automata. This option is mostly for use in maintaining -.I flex. -.TP -.B \-V -prints the version number to -.I stderr -and exits. -.TP -.B \-7 -instructs -.I flex -to generate a 7-bit scanner, which can save considerable table space, -especially when using -.B \-Cf -or -.B \-CF -(and, at most sites, -.B \-7 -is on by default for these options. To see if this is the case, use the -.B -v -verbose flag and check the flag summary it reports). -.TP -.B \-8 -instructs -.I flex -to generate an 8-bit scanner. This is the default except for the -.B \-Cf -and -.B \-CF -compression options, for which the default is site-dependent, and -can be checked by inspecting the flag summary generated by the -.B \-v -option. -.TP -.B \-+ -specifies that you want flex to generate a C++ -scanner class. See the section on Generating C++ Scanners in -.I flexdoc(1) -for details. -.TP -.B \-C[aefFmr] -controls the degree of table compression and scanner optimization. -.IP -.B \-Ca -trade off larger tables in the generated scanner for faster performance -because the elements of the tables are better aligned for memory access -and computation. This option can double the size of the tables used by -your scanner. -.IP -.B \-Ce -directs -.I flex -to construct -.I equivalence classes, -i.e., sets of characters -which have identical lexical properties. -Equivalence classes usually give -dramatic reductions in the final table/object file sizes (typically -a factor of 2-5) and are pretty cheap performance-wise (one array -look-up per character scanned). -.IP -.B \-Cf -specifies that the -.I full -scanner tables should be generated - -.I flex -should not compress the -tables by taking advantages of similar transition functions for -different states. -.IP -.B \-CF -specifies that the alternate fast scanner representation (described in -.B flexdoc(1)) -should be used. This option cannot be used with -.B \-+. -.IP -.B \-Cm -directs -.I flex -to construct -.I meta-equivalence classes, -which are sets of equivalence classes (or characters, if equivalence -classes are not being used) that are commonly used together. Meta-equivalence -classes are often a big win when using compressed tables, but they -have a moderate performance impact (one or two "if" tests and one -array look-up per character scanned). -.IP -.B \-Cr -causes the generated scanner to -.I bypass -using stdio for input. In general this option results in a minor -performance gain only worthwhile if used in conjunction with -.B \-Cf -or -.B \-CF. -It can cause surprising behavior if you use stdio yourself to -read from -.I yyin -prior to calling the scanner. -.IP -A lone -.B \-C -specifies that the scanner tables should be compressed but neither -equivalence classes nor meta-equivalence classes should be used. -.IP -The options -.B \-Cf -or -.B \-CF -and -.B \-Cm -do not make sense together - there is no opportunity for meta-equivalence -classes if the table is not being compressed. Otherwise the options -may be freely mixed. -.IP -The default setting is -.B \-Cem, -which specifies that -.I flex -should generate equivalence classes -and meta-equivalence classes. This setting provides the highest -degree of table compression. You can trade off -faster-executing scanners at the cost of larger tables with -the following generally being true: -.nf - - slowest & smallest - -Cem - -Cm - -Ce - -C - -C{f,F}e - -C{f,F} - -C{f,F}a - fastest & largest - -.fi -.IP -.B \-C -options are cumulative. -.TP -.B \-Pprefix -changes the default -.I "yy" -prefix used by -.I flex -to be -.I prefix -instead. See -.I flexdoc(1) -for a description of all the global variables and file names that -this affects. -.TP -.B \-Sskeleton_file -overrides the default skeleton file from which -.I flex -constructs its scanners. You'll never need this option unless you are doing -.I flex -maintenance or development. -.SH SUMMARY OF FLEX REGULAR EXPRESSIONS -The patterns in the input are written using an extended set of regular -expressions. These are: -.nf - - x match the character 'x' - . any character except newline - [xyz] a "character class"; in this case, the pattern - matches either an 'x', a 'y', or a 'z' - [abj-oZ] a "character class" with a range in it; matches - an 'a', a 'b', any letter from 'j' through 'o', - or a 'Z' - [^A-Z] a "negated character class", i.e., any character - but those in the class. In this case, any - character EXCEPT an uppercase letter. - [^A-Z\\n] any character EXCEPT an uppercase letter or - a newline - r* zero or more r's, where r is any regular expression - r+ one or more r's - r? zero or one r's (that is, "an optional r") - r{2,5} anywhere from two to five r's - r{2,} two or more r's - r{4} exactly 4 r's - {name} the expansion of the "name" definition - (see above) - "[xyz]\\"foo" - the literal string: [xyz]"foo - \\X if X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v', - then the ANSI-C interpretation of \\x. - Otherwise, a literal 'X' (used to escape - operators such as '*') - \\123 the character with octal value 123 - \\x2a the character with hexadecimal value 2a - (r) match an r; parentheses are used to override - precedence (see below) - - - rs the regular expression r followed by the - regular expression s; called "concatenation" - - - r|s either an r or an s - - - r/s an r but only if it is followed by an s. The - s is not part of the matched text. This type - of pattern is called as "trailing context". - ^r an r, but only at the beginning of a line - r$ an r, but only at the end of a line. Equivalent - to "r/\\n". - - - r an r, but only in start condition s (see - below for discussion of start conditions) - r - same, but in any of start conditions s1, - s2, or s3 - <*>r an r in any start condition, even an exclusive one. - - - <> an end-of-file - <> - an end-of-file when in start condition s1 or s2 - -.fi -The regular expressions listed above are grouped according to -precedence, from highest precedence at the top to lowest at the bottom. -Those grouped together have equal precedence. -.PP -Some notes on patterns: -.IP - -Negated character classes -.I match newlines -unless "\\n" (or an equivalent escape sequence) is one of the -characters explicitly present in the negated character class -(e.g., "[^A-Z\\n]"). -.IP - -A rule can have at most one instance of trailing context (the '/' operator -or the '$' operator). The start condition, '^', and "<>" patterns -can only occur at the beginning of a pattern, and, as well as with '/' and '$', -cannot be grouped inside parentheses. The following are all illegal: -.nf - - foo/bar$ - foo|(bar$) - foo|^bar - foobar - -.fi -.SH SUMMARY OF SPECIAL ACTIONS -In addition to arbitrary C code, the following can appear in actions: -.IP - -.B ECHO -copies yytext to the scanner's output. -.IP - -.B BEGIN -followed by the name of a start condition places the scanner in the -corresponding start condition. -.IP - -.B REJECT -directs the scanner to proceed on to the "second best" rule which matched the -input (or a prefix of the input). -.B yytext -and -.B yyleng -are set up appropriately. Note that -.B REJECT -is a particularly expensive feature in terms scanner performance; -if it is used in -.I any -of the scanner's actions it will slow down -.I all -of the scanner's matching. Furthermore, -.B REJECT -cannot be used with the -.B \-f -or -.B \-F -options. -.IP -Note also that unlike the other special actions, -.B REJECT -is a -.I branch; -code immediately following it in the action will -.I not -be executed. -.IP - -.B yymore() -tells the scanner that the next time it matches a rule, the corresponding -token should be -.I appended -onto the current value of -.B yytext -rather than replacing it. -.IP - -.B yyless(n) -returns all but the first -.I n -characters of the current token back to the input stream, where they -will be rescanned when the scanner looks for the next match. -.B yytext -and -.B yyleng -are adjusted appropriately (e.g., -.B yyleng -will now be equal to -.I n -). -.IP - -.B unput(c) -puts the character -.I c -back onto the input stream. It will be the next character scanned. -.IP - -.B input() -reads the next character from the input stream (this routine is called -.B yyinput() -if the scanner is compiled using -.B C++). -.IP - -.B yyterminate() -can be used in lieu of a return statement in an action. It terminates -the scanner and returns a 0 to the scanner's caller, indicating "all done". -.IP -By default, -.B yyterminate() -is also called when an end-of-file is encountered. It is a macro and -may be redefined. -.IP - -.B YY_NEW_FILE -is an action available only in <> rules. It means "Okay, I've -set up a new input file, continue scanning". It is no longer required; -you can just assign -.I yyin -to point to a new file in the <> action. -.IP - -.B yy_create_buffer( file, size ) -takes a -.I FILE -pointer and an integer -.I size. -It returns a YY_BUFFER_STATE -handle to a new input buffer large enough to accomodate -.I size -characters and associated with the given file. When in doubt, use -.B YY_BUF_SIZE -for the size. -.IP - -.B yy_switch_to_buffer( new_buffer ) -switches the scanner's processing to scan for tokens from -the given buffer, which must be a YY_BUFFER_STATE. -.IP - -.B yy_delete_buffer( buffer ) -deletes the given buffer. -.SH VALUES AVAILABLE TO THE USER -.IP - -.B char *yytext -holds the text of the current token. It may be modified but not lengthened -(you cannot append characters to the end). Modifying the last character -may affect the activity of rules anchored using '^' during the next scan; -see -.B flexdoc(1) -for details. -.IP -If the special directive -.B %array -appears in the first section of the scanner description, then -.B yytext -is instead declared -.B char yytext[YYLMAX], -where -.B YYLMAX -is a macro definition that you can redefine in the first section -if you don't like the default value (generally 8KB). Using -.B %array -results in somewhat slower scanners, but the value of -.B yytext -becomes immune to calls to -.I input() -and -.I unput(), -which potentially destroy its value when -.B yytext -is a character pointer. The opposite of -.B %array -is -.B %pointer, -which is the default. -.IP -You cannot use -.B %array -when generating C++ scanner classes -(the -.B \-+ -flag). -.IP - -.B int yyleng -holds the length of the current token. -.IP - -.B FILE *yyin -is the file which by default -.I flex -reads from. It may be redefined but doing so only makes sense before -scanning begins or after an EOF has been encountered. Changing it in -the midst of scanning will have unexpected results since -.I flex -buffers its input; use -.B yyrestart() -instead. -Once scanning terminates because an end-of-file -has been seen, -.B -you can assign -.I yyin -at the new input file and then call the scanner again to continue scanning. -.IP - -.B void yyrestart( FILE *new_file ) -may be called to point -.I yyin -at the new input file. The switch-over to the new file is immediate -(any previously buffered-up input is lost). Note that calling -.B yyrestart() -with -.I yyin -as an argument thus throws away the current input buffer and continues -scanning the same input file. -.IP - -.B FILE *yyout -is the file to which -.B ECHO -actions are done. It can be reassigned by the user. -.IP - -.B YY_CURRENT_BUFFER -returns a -.B YY_BUFFER_STATE -handle to the current buffer. -.IP - -.B YY_START -returns an integer value corresponding to the current start -condition. You can subsequently use this value with -.B BEGIN -to return to that start condition. -.SH MACROS AND FUNCTIONS YOU CAN REDEFINE -.IP - -.B YY_DECL -controls how the scanning routine is declared. -By default, it is "int yylex()", or, if prototypes are being -used, "int yylex(void)". This definition may be changed by redefining -the "YY_DECL" macro. Note that -if you give arguments to the scanning routine using a -K&R-style/non-prototyped function declaration, you must terminate -the definition with a semi-colon (;). -.IP - -The nature of how the scanner -gets its input can be controlled by redefining the -.B YY_INPUT -macro. -YY_INPUT's calling sequence is "YY_INPUT(buf,result,max_size)". Its -action is to place up to -.I max_size -characters in the character array -.I buf -and return in the integer variable -.I result -either the -number of characters read or the constant YY_NULL (0 on Unix systems) -to indicate EOF. The default YY_INPUT reads from the -global file-pointer "yyin". -A sample redefinition of YY_INPUT (in the definitions -section of the input file): -.nf - - %{ - #undef YY_INPUT - #define YY_INPUT(buf,result,max_size) \\ - { \\ - int c = getchar(); \\ - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \\ - } - %} - -.fi -.IP - -When the scanner receives an end-of-file indication from YY_INPUT, -it then checks the function -.B yywrap() -function. If -.B yywrap() -returns false (zero), then it is assumed that the -function has gone ahead and set up -.I yyin -to point to another input file, and scanning continues. If it returns -true (non-zero), then the scanner terminates, returning 0 to its -caller. -.IP -The default -.B yywrap() -always returns 1. -.IP - -YY_USER_ACTION -can be redefined to provide an action -which is always executed prior to the matched rule's action. -.IP - -The macro -.B YY_USER_INIT -may be redefined to provide an action which is always executed before -the first scan. -.IP - -In the generated scanner, the actions are all gathered in one large -switch statement and separated using -.B YY_BREAK, -which may be redefined. By default, it is simply a "break", to separate -each rule's action from the following rule's. -.SH FILES -.TP -.B \-lfl -library with which to link scanners to obtain the default versions -of -.I yywrap() -and/or -.I main(). -.TP -.I lex.yy.c -generated scanner (called -.I lexyy.c -on some systems). -.TP -.I lex.yy.cc -generated C++ scanner class, when using -.B -+. -.TP -.I -header file defining the C++ scanner base class, -.B FlexLexer, -and its derived class, -.B yyFlexLexer. -.TP -.I flex.skl -skeleton scanner. This file is only used when building flex, not when -flex executes. -.TP -.I lex.backup -backing-up information for -.B \-b -flag (called -.I lex.bck -on some systems). -.SH "SEE ALSO" -.PP -flexdoc(1), lex(1), yacc(1), sed(1), awk(1). -.PP -M. E. Lesk and E. Schmidt, -.I LEX \- Lexical Analyzer Generator -.SH DIAGNOSTICS -.PP -.I reject_used_but_not_detected undefined -or -.PP -.I yymore_used_but_not_detected undefined - -These errors can occur at compile time. They indicate that the -scanner uses -.B REJECT -or -.B yymore() -but that -.I flex -failed to notice the fact, meaning that -.I flex -scanned the first two sections looking for occurrences of these actions -and failed to find any, but somehow you snuck some in (via a #include -file, for example). Make an explicit reference to the action in your -.I flex -input file. (Note that previously -.I flex -supported a -.B %used/%unused -mechanism for dealing with this problem; this feature is still supported -but now deprecated, and will go away soon unless the author hears from -people who can argue compellingly that they need it.) -.PP -.I flex scanner jammed - -a scanner compiled with -.B \-s -has encountered an input string which wasn't matched by -any of its rules. -.PP -.I warning, rule cannot be matched -indicates that the given rule -cannot be matched because it follows other rules that will -always match the same text as it. See -.I flexdoc(1) -for an example. -.PP -.I warning, -.B \-s -.I -option given but default rule can be matched -means that it is possible (perhaps only in a particular start condition) -that the default rule (match any single character) is the only one -that will match a particular input. Since -.PP -.I scanner input buffer overflowed - -a scanner rule matched more text than the available dynamic memory. -.PP -.I token too large, exceeds YYLMAX - -your scanner uses -.B %array -and one of its rules matched a string longer than the -.B YYLMAX -constant (8K bytes by default). You can increase the value by -#define'ing -.B YYLMAX -in the definitions section of your -.I flex -input. -.PP -.I scanner requires \-8 flag to -.I use the character 'x' - -Your scanner specification includes recognizing the 8-bit character -.I 'x' -and you did not specify the \-8 flag, and your scanner defaulted to 7-bit -because you used the -.B \-Cf -or -.B \-CF -table compression options. -.PP -.I flex scanner push-back overflow - -you used -.B unput() -to push back so much text that the scanner's buffer could not hold -both the pushed-back text and the current token in -.B yytext. -Ideally the scanner should dynamically resize the buffer in this case, but at -present it does not. -.PP -.I -input buffer overflow, can't enlarge buffer because scanner uses REJECT - -the scanner was working on matching an extremely large token and needed -to expand the input buffer. This doesn't work with scanners that use -.B -REJECT. -.PP -.I -fatal flex scanner internal error--end of buffer missed - -This can occur in an scanner which is reentered after a long-jump -has jumped out (or over) the scanner's activation frame. Before -reentering the scanner, use: -.nf - - yyrestart( yyin ); - -.fi -or use C++ scanner classes (the -.B \-+ -option), which are fully reentrant. -.SH AUTHOR -Vern Paxson, with the help of many ideas and much inspiration from -Van Jacobson. Original version by Jef Poskanzer. -.PP -See flexdoc(1) for additional credits and the address to send comments to. -.SH DEFICIENCIES / BUGS -.PP -Some trailing context -patterns cannot be properly matched and generate -warning messages ("dangerous trailing context"). These are -patterns where the ending of the -first part of the rule matches the beginning of the second -part, such as "zx*/xy*", where the 'x*' matches the 'x' at -the beginning of the trailing context. (Note that the POSIX draft -states that the text matched by such patterns is undefined.) -.PP -For some trailing context rules, parts which are actually fixed-length are -not recognized as such, leading to the abovementioned performance loss. -In particular, parts using '|' or {n} (such as "foo{3}") are always -considered variable-length. -.PP -Combining trailing context with the special '|' action can result in -.I fixed -trailing context being turned into the more expensive -.I variable -trailing context. For example, in the following: -.nf - - %% - abc | - xyz/def - -.fi -.PP -Use of -.B unput() -or -.B input() -invalidates yytext and yyleng, unless the -.B %array -directive -or the -.B \-l -option has been used. -.PP -Use of unput() to push back more text than was matched can -result in the pushed-back text matching a beginning-of-line ('^') -rule even though it didn't come at the beginning of the line -(though this is rare!). -.PP -Pattern-matching of NUL's is substantially slower than matching other -characters. -.PP -Dynamic resizing of the input buffer is slow, as it entails rescanning -all the text matched so far by the current (generally huge) token. -.PP -.I flex -does not generate correct #line directives for code internal -to the scanner; thus, bugs in -.I flex.skl -yield bogus line numbers. -.PP -Due to both buffering of input and read-ahead, you cannot intermix -calls to routines, such as, for example, -.B getchar(), -with -.I flex -rules and expect it to work. Call -.B input() -instead. -.PP -The total table entries listed by the -.B \-v -flag excludes the number of table entries needed to determine -what rule has been matched. The number of entries is equal -to the number of DFA states if the scanner does not use -.B REJECT, -and somewhat greater than the number of states if it does. -.PP -.B REJECT -cannot be used with the -.B \-f -or -.B \-F -options. -.PP -The -.I flex -internal algorithms need documentation. diff --git a/usr.bin/lex/flexdoc.1 b/usr.bin/lex/flexdoc.1 deleted file mode 100644 index b80d569..0000000 --- a/usr.bin/lex/flexdoc.1 +++ /dev/null @@ -1,3045 +0,0 @@ -.TH FLEXDOC 1 "November 1993" "Version 2.4" -.SH NAME -flexdoc \- documentation for flex, fast lexical analyzer generator -.SH SYNOPSIS -.B flex -.B [\-bcdfhilnpstvwBFILTV78+ \-C[aefFmr] \-Pprefix \-Sskeleton] -.I [filename ...] -.SH DESCRIPTION -.I flex -is a tool for generating -.I scanners: -programs which recognized lexical patterns in text. -.I flex -reads -the given input files, or its standard input if no file names are given, -for a description of a scanner to generate. The description is in -the form of pairs -of regular expressions and C code, called -.I rules. flex -generates as output a C source file, -.B lex.yy.c, -which defines a routine -.B yylex(). -This file is compiled and linked with the -.B \-lfl -library to produce an executable. When the executable is run, -it analyzes its input for occurrences -of the regular expressions. Whenever it finds one, it executes -the corresponding C code. -.SH SOME SIMPLE EXAMPLES -.PP -First some simple examples to get the flavor of how one uses -.I flex. -The following -.I flex -input specifies a scanner which whenever it encounters the string -"username" will replace it with the user's login name: -.nf - - %% - username printf( "%s", getlogin() ); - -.fi -By default, any text not matched by a -.I flex -scanner -is copied to the output, so the net effect of this scanner is -to copy its input file to its output with each occurrence -of "username" expanded. -In this input, there is just one rule. "username" is the -.I pattern -and the "printf" is the -.I action. -The "%%" marks the beginning of the rules. -.PP -Here's another simple example: -.nf - - int num_lines = 0, num_chars = 0; - - %% - \\n ++num_lines; ++num_chars; - . ++num_chars; - - %% - main() - { - yylex(); - printf( "# of lines = %d, # of chars = %d\\n", - num_lines, num_chars ); - } - -.fi -This scanner counts the number of characters and the number -of lines in its input (it produces no output other than the -final report on the counts). The first line -declares two globals, "num_lines" and "num_chars", which are accessible -both inside -.B yylex() -and in the -.B main() -routine declared after the second "%%". There are two rules, one -which matches a newline ("\\n") and increments both the line count and -the character count, and one which matches any character other than -a newline (indicated by the "." regular expression). -.PP -A somewhat more complicated example: -.nf - - /* scanner for a toy Pascal-like language */ - - %{ - /* need this for the call to atof() below */ - #include - %} - - DIGIT [0-9] - ID [a-z][a-z0-9]* - - %% - - {DIGIT}+ { - printf( "An integer: %s (%d)\\n", yytext, - atoi( yytext ) ); - } - - {DIGIT}+"."{DIGIT}* { - printf( "A float: %s (%g)\\n", yytext, - atof( yytext ) ); - } - - if|then|begin|end|procedure|function { - printf( "A keyword: %s\\n", yytext ); - } - - {ID} printf( "An identifier: %s\\n", yytext ); - - "+"|"-"|"*"|"/" printf( "An operator: %s\\n", yytext ); - - "{"[^}\\n]*"}" /* eat up one-line comments */ - - [ \\t\\n]+ /* eat up whitespace */ - - . printf( "Unrecognized character: %s\\n", yytext ); - - %% - - main( argc, argv ) - int argc; - char **argv; - { - ++argv, --argc; /* skip over program name */ - if ( argc > 0 ) - yyin = fopen( argv[0], "r" ); - else - yyin = stdin; - - yylex(); - } - -.fi -This is the beginnings of a simple scanner for a language like -Pascal. It identifies different types of -.I tokens -and reports on what it has seen. -.PP -The details of this example will be explained in the following -sections. -.SH FORMAT OF THE INPUT FILE -The -.I flex -input file consists of three sections, separated by a line with just -.B %% -in it: -.nf - - definitions - %% - rules - %% - user code - -.fi -The -.I definitions -section contains declarations of simple -.I name -definitions to simplify the scanner specification, and declarations of -.I start conditions, -which are explained in a later section. -.PP -Name definitions have the form: -.nf - - name definition - -.fi -The "name" is a word beginning with a letter or an underscore ('_') -followed by zero or more letters, digits, '_', or '-' (dash). -The definition is taken to begin at the first non-white-space character -following the name and continuing to the end of the line. -The definition can subsequently be referred to using "{name}", which -will expand to "(definition)". For example, -.nf - - DIGIT [0-9] - ID [a-z][a-z0-9]* - -.fi -defines "DIGIT" to be a regular expression which matches a -single digit, and -"ID" to be a regular expression which matches a letter -followed by zero-or-more letters-or-digits. -A subsequent reference to -.nf - - {DIGIT}+"."{DIGIT}* - -.fi -is identical to -.nf - - ([0-9])+"."([0-9])* - -.fi -and matches one-or-more digits followed by a '.' followed -by zero-or-more digits. -.PP -The -.I rules -section of the -.I flex -input contains a series of rules of the form: -.nf - - pattern action - -.fi -where the pattern must be unindented and the action must begin -on the same line. -.PP -See below for a further description of patterns and actions. -.PP -Finally, the user code section is simply copied to -.B lex.yy.c -verbatim. -It is used for companion routines which call or are called -by the scanner. The presence of this section is optional; -if it is missing, the second -.B %% -in the input file may be skipped, too. -.PP -In the definitions and rules sections, any -.I indented -text or text enclosed in -.B %{ -and -.B %} -is copied verbatim to the output (with the %{}'s removed). -The %{}'s must appear unindented on lines by themselves. -.PP -In the rules section, -any indented or %{} text appearing before the -first rule may be used to declare variables -which are local to the scanning routine and (after the declarations) -code which is to be executed whenever the scanning routine is entered. -Other indented or %{} text in the rule section is still copied to the output, -but its meaning is not well-defined and it may well cause compile-time -errors (this feature is present for -.I POSIX -compliance; see below for other such features). -.PP -In the definitions section (but not in the rules section), -an unindented comment (i.e., a line -beginning with "/*") is also copied verbatim to the output up -to the next "*/". -.SH PATTERNS -The patterns in the input are written using an extended set of regular -expressions. These are: -.nf - - x match the character 'x' - . any character except newline - [xyz] a "character class"; in this case, the pattern - matches either an 'x', a 'y', or a 'z' - [abj-oZ] a "character class" with a range in it; matches - an 'a', a 'b', any letter from 'j' through 'o', - or a 'Z' - [^A-Z] a "negated character class", i.e., any character - but those in the class. In this case, any - character EXCEPT an uppercase letter. - [^A-Z\\n] any character EXCEPT an uppercase letter or - a newline - r* zero or more r's, where r is any regular expression - r+ one or more r's - r? zero or one r's (that is, "an optional r") - r{2,5} anywhere from two to five r's - r{2,} two or more r's - r{4} exactly 4 r's - {name} the expansion of the "name" definition - (see above) - "[xyz]\\"foo" - the literal string: [xyz]"foo - \\X if X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v', - then the ANSI-C interpretation of \\x. - Otherwise, a literal 'X' (used to escape - operators such as '*') - \\123 the character with octal value 123 - \\x2a the character with hexadecimal value 2a - (r) match an r; parentheses are used to override - precedence (see below) - - - rs the regular expression r followed by the - regular expression s; called "concatenation" - - - r|s either an r or an s - - - r/s an r but only if it is followed by an s. The - s is not part of the matched text. This type - of pattern is called as "trailing context". - ^r an r, but only at the beginning of a line - r$ an r, but only at the end of a line. Equivalent - to "r/\\n". - - - r an r, but only in start condition s (see - below for discussion of start conditions) - r - same, but in any of start conditions s1, - s2, or s3 - <*>r an r in any start condition, even an exclusive one. - - - <> an end-of-file - <> - an end-of-file when in start condition s1 or s2 - -.fi -Note that inside of a character class, all regular expression operators -lose their special meaning except escape ('\\') and the character class -operators, '-', ']', and, at the beginning of the class, '^'. -.PP -The regular expressions listed above are grouped according to -precedence, from highest precedence at the top to lowest at the bottom. -Those grouped together have equal precedence. For example, -.nf - - foo|bar* - -.fi -is the same as -.nf - - (foo)|(ba(r*)) - -.fi -since the '*' operator has higher precedence than concatenation, -and concatenation higher than alternation ('|'). This pattern -therefore matches -.I either -the string "foo" -.I or -the string "ba" followed by zero-or-more r's. -To match "foo" or zero-or-more "bar"'s, use: -.nf - - foo|(bar)* - -.fi -and to match zero-or-more "foo"'s-or-"bar"'s: -.nf - - (foo|bar)* - -.fi -.PP -Some notes on patterns: -.IP - -A negated character class such as the example "[^A-Z]" -above -.I will match a newline -unless "\\n" (or an equivalent escape sequence) is one of the -characters explicitly present in the negated character class -(e.g., "[^A-Z\\n]"). This is unlike how many other regular -expression tools treat negated character classes, but unfortunately -the inconsistency is historically entrenched. -Matching newlines means that a pattern like [^"]* can match the entire -input unless there's another quote in the input. -.IP - -A rule can have at most one instance of trailing context (the '/' operator -or the '$' operator). The start condition, '^', and "<>" patterns -can only occur at the beginning of a pattern, and, as well as with '/' and '$', -cannot be grouped inside parentheses. A '^' which does not occur at -the beginning of a rule or a '$' which does not occur at the end of -a rule loses its special properties and is treated as a normal character. -.IP -The following are illegal: -.nf - - foo/bar$ - foobar - -.fi -Note that the first of these, can be written "foo/bar\\n". -.IP -The following will result in '$' or '^' being treated as a normal character: -.nf - - foo|(bar$) - foo|^bar - -.fi -If what's wanted is a "foo" or a bar-followed-by-a-newline, the following -could be used (the special '|' action is explained below): -.nf - - foo | - bar$ /* action goes here */ - -.fi -A similar trick will work for matching a foo or a -bar-at-the-beginning-of-a-line. -.SH HOW THE INPUT IS MATCHED -When the generated scanner is run, it analyzes its input looking -for strings which match any of its patterns. If it finds more than -one match, it takes the one matching the most text (for trailing -context rules, this includes the length of the trailing part, even -though it will then be returned to the input). If it finds two -or more matches of the same length, the -rule listed first in the -.I flex -input file is chosen. -.PP -Once the match is determined, the text corresponding to the match -(called the -.I token) -is made available in the global character pointer -.B yytext, -and its length in the global integer -.B yyleng. -The -.I action -corresponding to the matched pattern is then executed (a more -detailed description of actions follows), and then the remaining -input is scanned for another match. -.PP -If no match is found, then the -.I default rule -is executed: the next character in the input is considered matched and -copied to the standard output. Thus, the simplest legal -.I flex -input is: -.nf - - %% - -.fi -which generates a scanner that simply copies its input (one character -at a time) to its output. -.PP -Note that -.B yytext -can be defined in two different ways: either as a character -.I pointer -or as a character -.I array. -You can control which definition -.I flex -uses by including one of the special directives -.B %pointer -or -.B %array -in the first (definitions) section of your flex input. The default is -.B %pointer, -unless you use the -.B -l -lex compatibility option, in which case -.B yytext -will be an array. -The advantage of using -.B %pointer -is substantially faster scanning and no buffer overflow when matching -very large tokens (unless you run out of dynamic memory). The disadvantage -is that you are restricted in how your actions can modify -.B yytext -(see the next section), and calls to the -.B input() -and -.B unput() -functions destroy the present contents of -.B yytext, -which can be a considerable porting headache when moving between different -.I lex -versions. -.PP -The advantage of -.B %array -is that you can then modify -.B yytext -to your heart's content, and calls to -.B input() -and -.B unput() -do not destroy -.B yytext -(see below). Furthermore, existing -.I lex -programs sometimes access -.B yytext -externally using declarations of the form: -.nf - extern char yytext[]; -.fi -This definition is erroneous when used with -.B %pointer, -but correct for -.B %array. -.PP -.B %array -defines -.B yytext -to be an array of -.B YYLMAX -characters, which defaults to a fairly large value. You can change -the size by simply #define'ing -.B YYLMAX -to a different value in the first section of your -.I flex -input. As mentioned above, with -.B %pointer -yytext grows dynamically to accomodate large tokens. While this means your -.B %pointer -scanner can accomodate very large tokens (such as matching entire blocks -of comments), bear in mind that each time the scanner must resize -.B yytext -it also must rescan the entire token from the beginning, so matching such -tokens can prove slow. -.B yytext -presently does -.I not -dynamically grow if a call to -.B unput() -results in too much text being pushed back; instead, a run-time error results. -.PP -Also note that you cannot use -.B %array -with C++ scanner classes -(the -.B \-+ -option; see below). -.SH ACTIONS -Each pattern in a rule has a corresponding action, which can be any -arbitrary C statement. The pattern ends at the first non-escaped -whitespace character; the remainder of the line is its action. If the -action is empty, then when the pattern is matched the input token -is simply discarded. For example, here is the specification for a program -which deletes all occurrences of "zap me" from its input: -.nf - - %% - "zap me" - -.fi -(It will copy all other characters in the input to the output since -they will be matched by the default rule.) -.PP -Here is a program which compresses multiple blanks and tabs down to -a single blank, and throws away whitespace found at the end of a line: -.nf - - %% - [ \\t]+ putchar( ' ' ); - [ \\t]+$ /* ignore this token */ - -.fi -.PP -If the action contains a '{', then the action spans till the balancing '}' -is found, and the action may cross multiple lines. -.I flex -knows about C strings and comments and won't be fooled by braces found -within them, but also allows actions to begin with -.B %{ -and will consider the action to be all the text up to the next -.B %} -(regardless of ordinary braces inside the action). -.PP -An action consisting solely of a vertical bar ('|') means "same as -the action for the next rule." See below for an illustration. -.PP -Actions can include arbitrary C code, including -.B return -statements to return a value to whatever routine called -.B yylex(). -Each time -.B yylex() -is called it continues processing tokens from where it last left -off until it either reaches -the end of the file or executes a return. -.PP -Actions are free to modify -.B yytext -except for lengthening it (adding -characters to its end--these will overwrite later characters in the -input stream). Modifying the final character of yytext may alter -whether when scanning resumes rules anchored with '^' are active. -Specifically, changing the final character of yytext to a newline will -activate such rules on the next scan, and changing it to anything else -will deactivate the rules. Users should not rely on this behavior being -present in future releases. Finally, note that none of this paragraph -applies when using -.B %array -(see above). -.PP -Actions are free to modify -.B yyleng -except they should not do so if the action also includes use of -.B yymore() -(see below). -.PP -There are a number of special directives which can be included within -an action: -.IP - -.B ECHO -copies yytext to the scanner's output. -.IP - -.B BEGIN -followed by the name of a start condition places the scanner in the -corresponding start condition (see below). -.IP - -.B REJECT -directs the scanner to proceed on to the "second best" rule which matched the -input (or a prefix of the input). The rule is chosen as described -above in "How the Input is Matched", and -.B yytext -and -.B yyleng -set up appropriately. -It may either be one which matched as much text -as the originally chosen rule but came later in the -.I flex -input file, or one which matched less text. -For example, the following will both count the -words in the input and call the routine special() whenever "frob" is seen: -.nf - - int word_count = 0; - %% - - frob special(); REJECT; - [^ \\t\\n]+ ++word_count; - -.fi -Without the -.B REJECT, -any "frob"'s in the input would not be counted as words, since the -scanner normally executes only one action per token. -Multiple -.B REJECT's -are allowed, each one finding the next best choice to the currently -active rule. For example, when the following scanner scans the token -"abcd", it will write "abcdabcaba" to the output: -.nf - - %% - a | - ab | - abc | - abcd ECHO; REJECT; - .|\\n /* eat up any unmatched character */ - -.fi -(The first three rules share the fourth's action since they use -the special '|' action.) -.B REJECT -is a particularly expensive feature in terms scanner performance; -if it is used in -.I any -of the scanner's actions it will slow down -.I all -of the scanner's matching. Furthermore, -.B REJECT -cannot be used with the -.I -Cf -or -.I -CF -options (see below). -.IP -Note also that unlike the other special actions, -.B REJECT -is a -.I branch; -code immediately following it in the action will -.I not -be executed. -.IP - -.B yymore() -tells the scanner that the next time it matches a rule, the corresponding -token should be -.I appended -onto the current value of -.B yytext -rather than replacing it. For example, given the input "mega-kludge" -the following will write "mega-mega-kludge" to the output: -.nf - - %% - mega- ECHO; yymore(); - kludge ECHO; - -.fi -First "mega-" is matched and echoed to the output. Then "kludge" -is matched, but the previous "mega-" is still hanging around at the -beginning of -.B yytext -so the -.B ECHO -for the "kludge" rule will actually write "mega-kludge". -The presence of -.B yymore() -in the scanner's action entails a minor performance penalty in the -scanner's matching speed. -.IP - -.B yyless(n) -returns all but the first -.I n -characters of the current token back to the input stream, where they -will be rescanned when the scanner looks for the next match. -.B yytext -and -.B yyleng -are adjusted appropriately (e.g., -.B yyleng -will now be equal to -.I n -). For example, on the input "foobar" the following will write out -"foobarbar": -.nf - - %% - foobar ECHO; yyless(3); - [a-z]+ ECHO; - -.fi -An argument of 0 to -.B yyless -will cause the entire current input string to be scanned again. Unless you've -changed how the scanner will subsequently process its input (using -.B BEGIN, -for example), this will result in an endless loop. -.PP -Note that -.B yyless -is a macro and can only be used in the flex input file, not from -other source files. -.IP - -.B unput(c) -puts the character -.I c -back onto the input stream. It will be the next character scanned. -The following action will take the current token and cause it -to be rescanned enclosed in parentheses. -.nf - - { - int i; - unput( ')' ); - for ( i = yyleng - 1; i >= 0; --i ) - unput( yytext[i] ); - unput( '(' ); - } - -.fi -Note that since each -.B unput() -puts the given character back at the -.I beginning -of the input stream, pushing back strings must be done back-to-front. -Also note that you cannot put back -.B EOF -to attempt to mark the input stream with an end-of-file. -.IP - -.B input() -reads the next character from the input stream. For example, -the following is one way to eat up C comments: -.nf - - %% - "/*" { - register int c; - - for ( ; ; ) - { - while ( (c = input()) != '*' && - c != EOF ) - ; /* eat up text of comment */ - - if ( c == '*' ) - { - while ( (c = input()) == '*' ) - ; - if ( c == '/' ) - break; /* found the end */ - } - - if ( c == EOF ) - { - error( "EOF in comment" ); - break; - } - } - } - -.fi -(Note that if the scanner is compiled using -.B C++, -then -.B input() -is instead referred to as -.B yyinput(), -in order to avoid a name clash with the -.B C++ -stream by the name of -.I input.) -.IP - -.B yyterminate() -can be used in lieu of a return statement in an action. It terminates -the scanner and returns a 0 to the scanner's caller, indicating "all done". -By default, -.B yyterminate() -is also called when an end-of-file is encountered. It is a macro and -may be redefined. -.SH THE GENERATED SCANNER -The output of -.I flex -is the file -.B lex.yy.c, -which contains the scanning routine -.B yylex(), -a number of tables used by it for matching tokens, and a number -of auxiliary routines and macros. By default, -.B yylex() -is declared as follows: -.nf - - int yylex() - { - ... various definitions and the actions in here ... - } - -.fi -(If your environment supports function prototypes, then it will -be "int yylex( void )".) This definition may be changed by defining -the "YY_DECL" macro. For example, you could use: -.nf - - #define YY_DECL float lexscan( a, b ) float a, b; - -.fi -to give the scanning routine the name -.I lexscan, -returning a float, and taking two floats as arguments. Note that -if you give arguments to the scanning routine using a -K&R-style/non-prototyped function declaration, you must terminate -the definition with a semi-colon (;). -.PP -Whenever -.B yylex() -is called, it scans tokens from the global input file -.I yyin -(which defaults to stdin). It continues until it either reaches -an end-of-file (at which point it returns the value 0) or -one of its actions executes a -.I return -statement. -.PP -If the scanner reaches an end-of-file, subsequent calls are undefined -unless either -.I yyin -is pointed at a new input file (in which case scanning continues from -that file), or -.B yyrestart() -is called. -.B yyrestart() -takes one argument, a -.B FILE * -pointer, and initializes -.I yyin -for scanning from that file. Essentially there is no difference between -just assigning -.I yyin -to a new input file or using -.B yyrestart() -to do so; the latter is available for compatibility with previous versions -of -.I flex, -and because it can be used to switch input files in the middle of scanning. -It can also be used to throw away the current input buffer, by calling -it with an argument of -.I yyin. -.PP -If -.B yylex() -stops scanning due to executing a -.I return -statement in one of the actions, the scanner may then be called again and it -will resume scanning where it left off. -.PP -By default (and for purposes of efficiency), the scanner uses -block-reads rather than simple -.I getc() -calls to read characters from -.I yyin. -The nature of how it gets its input can be controlled by defining the -.B YY_INPUT -macro. -YY_INPUT's calling sequence is "YY_INPUT(buf,result,max_size)". Its -action is to place up to -.I max_size -characters in the character array -.I buf -and return in the integer variable -.I result -either the -number of characters read or the constant YY_NULL (0 on Unix systems) -to indicate EOF. The default YY_INPUT reads from the -global file-pointer "yyin". -.PP -A sample definition of YY_INPUT (in the definitions -section of the input file): -.nf - - %{ - #define YY_INPUT(buf,result,max_size) \\ - { \\ - int c = getchar(); \\ - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \\ - } - %} - -.fi -This definition will change the input processing to occur -one character at a time. -.PP -You also can add in things like keeping track of the -input line number this way; but don't expect your scanner to -go very fast. -.PP -When the scanner receives an end-of-file indication from YY_INPUT, -it then checks the -.B yywrap() -function. If -.B yywrap() -returns false (zero), then it is assumed that the -function has gone ahead and set up -.I yyin -to point to another input file, and scanning continues. If it returns -true (non-zero), then the scanner terminates, returning 0 to its -caller. -.PP -The default -.B yywrap() -always returns 1. -.PP -The scanner writes its -.B ECHO -output to the -.I yyout -global (default, stdout), which may be redefined by the user simply -by assigning it to some other -.B FILE -pointer. -.SH START CONDITIONS -.I flex -provides a mechanism for conditionally activating rules. Any rule -whose pattern is prefixed with "" will only be active when -the scanner is in the start condition named "sc". For example, -.nf - - [^"]* { /* eat up the string body ... */ - ... - } - -.fi -will be active only when the scanner is in the "STRING" start -condition, and -.nf - - \\. { /* handle an escape ... */ - ... - } - -.fi -will be active only when the current start condition is -either "INITIAL", "STRING", or "QUOTE". -.PP -Start conditions -are declared in the definitions (first) section of the input -using unindented lines beginning with either -.B %s -or -.B %x -followed by a list of names. -The former declares -.I inclusive -start conditions, the latter -.I exclusive -start conditions. A start condition is activated using the -.B BEGIN -action. Until the next -.B BEGIN -action is executed, rules with the given start -condition will be active and -rules with other start conditions will be inactive. -If the start condition is -.I inclusive, -then rules with no start conditions at all will also be active. -If it is -.I exclusive, -then -.I only -rules qualified with the start condition will be active. -A set of rules contingent on the same exclusive start condition -describe a scanner which is independent of any of the other rules in the -.I flex -input. Because of this, -exclusive start conditions make it easy to specify "mini-scanners" -which scan portions of the input that are syntactically different -from the rest (e.g., comments). -.PP -If the distinction between inclusive and exclusive start conditions -is still a little vague, here's a simple example illustrating the -connection between the two. The set of rules: -.nf - - %s example - %% - foo /* do something */ - -.fi -is equivalent to -.nf - - %x example - %% - foo /* do something */ - -.fi -.PP -Also note that the special start-condition specifier -.B <*> -matches every start condition. Thus, the above example could also -have been written; -.nf - - %x example - %% - <*>foo /* do something */ - -.fi -.PP -The default rule (to -.B ECHO -any unmatched character) remains active in start conditions. -.PP -.B BEGIN(0) -returns to the original state where only the rules with -no start conditions are active. This state can also be -referred to as the start-condition "INITIAL", so -.B BEGIN(INITIAL) -is equivalent to -.B BEGIN(0). -(The parentheses around the start condition name are not required but -are considered good style.) -.PP -.B BEGIN -actions can also be given as indented code at the beginning -of the rules section. For example, the following will cause -the scanner to enter the "SPECIAL" start condition whenever -.I yylex() -is called and the global variable -.I enter_special -is true: -.nf - - int enter_special; - - %x SPECIAL - %% - if ( enter_special ) - BEGIN(SPECIAL); - - blahblahblah - ...more rules follow... - -.fi -.PP -To illustrate the uses of start conditions, -here is a scanner which provides two different interpretations -of a string like "123.456". By default it will treat it as -as three tokens, the integer "123", a dot ('.'), and the integer "456". -But if the string is preceded earlier in the line by the string -"expect-floats" -it will treat it as a single token, the floating-point number -123.456: -.nf - - %{ - #include - %} - %s expect - - %% - expect-floats BEGIN(expect); - - [0-9]+"."[0-9]+ { - printf( "found a float, = %f\\n", - atof( yytext ) ); - } - \\n { - /* that's the end of the line, so - * we need another "expect-number" - * before we'll recognize any more - * numbers - */ - BEGIN(INITIAL); - } - - [0-9]+ { - printf( "found an integer, = %d\\n", - atoi( yytext ) ); - } - - "." printf( "found a dot\\n" ); - -.fi -Here is a scanner which recognizes (and discards) C comments while -maintaining a count of the current input line. -.nf - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\\n]* /* eat anything that's not a '*' */ - "*"+[^*/\\n]* /* eat up '*'s not followed by '/'s */ - \\n ++line_num; - "*"+"/" BEGIN(INITIAL); - -.fi -This scanner goes to a bit of trouble to match as much -text as possible with each rule. In general, when attempting to write -a high-speed scanner try to match as much possible in each rule, as -it's a big win. -.PP -Note that start-conditions names are really integer values and -can be stored as such. Thus, the above could be extended in the -following fashion: -.nf - - %x comment foo - %% - int line_num = 1; - int comment_caller; - - "/*" { - comment_caller = INITIAL; - BEGIN(comment); - } - - ... - - "/*" { - comment_caller = foo; - BEGIN(comment); - } - - [^*\\n]* /* eat anything that's not a '*' */ - "*"+[^*/\\n]* /* eat up '*'s not followed by '/'s */ - \\n ++line_num; - "*"+"/" BEGIN(comment_caller); - -.fi -Furthermore, you can access the current start condition using -the integer-valued -.B YY_START -macro. For example, the above assignments to -.I comment_caller -could instead be written -.nf - - comment_caller = YY_START; -.fi -.PP -Note that start conditions do not have their own name-space; %s's and %x's -declare names in the same fashion as #define's. -.PP -Finally, here's an example of how to match C-style quoted strings using -exclusive start conditions, including expanded escape sequences (but -not including checking for a string that's too long): -.nf - - %x str - - %% - char string_buf[MAX_STR_CONST]; - char *string_buf_ptr; - - - \\" string_buf_ptr = string_buf; BEGIN(str); - - \\" { /* saw closing quote - all done */ - BEGIN(INITIAL); - *string_buf_ptr = '\\0'; - /* return string constant token type and - * value to parser - */ - } - - \\n { - /* error - unterminated string constant */ - /* generate error message */ - } - - \\\\[0-7]{1,3} { - /* octal escape sequence */ - int result; - - (void) sscanf( yytext + 1, "%o", &result ); - - if ( result > 0xff ) - /* error, constant is out-of-bounds */ - - *string_buf_ptr++ = result; - } - - \\\\[0-9]+ { - /* generate error - bad escape sequence; something - * like '\\48' or '\\0777777' - */ - } - - \\\\n *string_buf_ptr++ = '\\n'; - \\\\t *string_buf_ptr++ = '\\t'; - \\\\r *string_buf_ptr++ = '\\r'; - \\\\b *string_buf_ptr++ = '\\b'; - \\\\f *string_buf_ptr++ = '\\f'; - - \\\\(.|\\n) *string_buf_ptr++ = yytext[1]; - - [^\\\\\\n\\"]+ { - char *yytext_ptr = yytext; - - while ( *yytext_ptr ) - *string_buf_ptr++ = *yytext_ptr++; - } - -.fi -.SH MULTIPLE INPUT BUFFERS -Some scanners (such as those which support "include" files) -require reading from several input streams. As -.I flex -scanners do a large amount of buffering, one cannot control -where the next input will be read from by simply writing a -.B YY_INPUT -which is sensitive to the scanning context. -.B YY_INPUT -is only called when the scanner reaches the end of its buffer, which -may be a long time after scanning a statement such as an "include" -which requires switching the input source. -.PP -To negotiate these sorts of problems, -.I flex -provides a mechanism for creating and switching between multiple -input buffers. An input buffer is created by using: -.nf - - YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) - -.fi -which takes a -.I FILE -pointer and a size and creates a buffer associated with the given -file and large enough to hold -.I size -characters (when in doubt, use -.B YY_BUF_SIZE -for the size). It returns a -.B YY_BUFFER_STATE -handle, which may then be passed to other routines: -.nf - - void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) - -.fi -switches the scanner's input buffer so subsequent tokens will -come from -.I new_buffer. -Note that -.B yy_switch_to_buffer() -may be used by yywrap() to set things up for continued scanning, instead -of opening a new file and pointing -.I yyin -at it. -.nf - - void yy_delete_buffer( YY_BUFFER_STATE buffer ) - -.fi -is used to reclaim the storage associated with a buffer. -.PP -.B yy_new_buffer() -is an alias for -.B yy_create_buffer(), -provided for compatibility with the C++ use of -.I new -and -.I delete -for creating and destroying dynamic objects. -.PP -Finally, the -.B YY_CURRENT_BUFFER -macro returns a -.B YY_BUFFER_STATE -handle to the current buffer. -.PP -Here is an example of using these features for writing a scanner -which expands include files (the -.B <> -feature is discussed below): -.nf - - /* the "incl" state is used for picking up the name - * of an include file - */ - %x incl - - %{ - #define MAX_INCLUDE_DEPTH 10 - YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; - int include_stack_ptr = 0; - %} - - %% - include BEGIN(incl); - - [a-z]+ ECHO; - [^a-z\\n]*\\n? ECHO; - - [ \\t]* /* eat the whitespace */ - [^ \\t\\n]+ { /* got the include file name */ - if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) - { - fprintf( stderr, "Includes nested too deeply" ); - exit( 1 ); - } - - include_stack[include_stack_ptr++] = - YY_CURRENT_BUFFER; - - yyin = fopen( yytext, "r" ); - - if ( ! yyin ) - error( ... ); - - yy_switch_to_buffer( - yy_create_buffer( yyin, YY_BUF_SIZE ) ); - - BEGIN(INITIAL); - } - - <> { - if ( --include_stack_ptr < 0 ) - { - yyterminate(); - } - - else - { - yy_delete_buffer( YY_CURRENT_BUFFER ); - yy_switch_to_buffer( - include_stack[include_stack_ptr] ); - } - } - -.fi -.SH END-OF-FILE RULES -The special rule "<>" indicates -actions which are to be taken when an end-of-file is -encountered and yywrap() returns non-zero (i.e., indicates -no further files to process). The action must finish -by doing one of four things: -.IP - -assigning -.I yyin -to a new input file (in previous versions of flex, after doing the -assignment you had to call the special action -.B YY_NEW_FILE; -this is no longer necessary); -.IP - -executing a -.I return -statement; -.IP - -executing the special -.B yyterminate() -action; -.IP - -or, switching to a new buffer using -.B yy_switch_to_buffer() -as shown in the example above. -.PP -<> rules may not be used with other -patterns; they may only be qualified with a list of start -conditions. If an unqualified <> rule is given, it -applies to -.I all -start conditions which do not already have <> actions. To -specify an <> rule for only the initial start condition, use -.nf - - <> - -.fi -.PP -These rules are useful for catching things like unclosed comments. -An example: -.nf - - %x quote - %% - - ...other rules for dealing with quotes... - - <> { - error( "unterminated quote" ); - yyterminate(); - } - <> { - if ( *++filelist ) - yyin = fopen( *filelist, "r" ); - else - yyterminate(); - } - -.fi -.SH MISCELLANEOUS MACROS -The macro -.bd -YY_USER_ACTION -can be defined to provide an action -which is always executed prior to the matched rule's action. For example, -it could be #define'd to call a routine to convert yytext to lower-case. -.PP -The macro -.B YY_USER_INIT -may be defined to provide an action which is always executed before -the first scan (and before the scanner's internal initializations are done). -For example, it could be used to call a routine to read -in a data table or open a logging file. -.PP -In the generated scanner, the actions are all gathered in one large -switch statement and separated using -.B YY_BREAK, -which may be redefined. By default, it is simply a "break", to separate -each rule's action from the following rule's. -Redefining -.B YY_BREAK -allows, for example, C++ users to -#define YY_BREAK to do nothing (while being very careful that every -rule ends with a "break" or a "return"!) to avoid suffering from -unreachable statement warnings where because a rule's action ends with -"return", the -.B YY_BREAK -is inaccessible. -.SH INTERFACING WITH YACC -One of the main uses of -.I flex -is as a companion to the -.I yacc -parser-generator. -.I yacc -parsers expect to call a routine named -.B yylex() -to find the next input token. The routine is supposed to -return the type of the next token as well as putting any associated -value in the global -.B yylval. -To use -.I flex -with -.I yacc, -one specifies the -.B \-d -option to -.I yacc -to instruct it to generate the file -.B y.tab.h -containing definitions of all the -.B %tokens -appearing in the -.I yacc -input. This file is then included in the -.I flex -scanner. For example, if one of the tokens is "TOK_NUMBER", -part of the scanner might look like: -.nf - - %{ - #include "y.tab.h" - %} - - %% - - [0-9]+ yylval = atoi( yytext ); return TOK_NUMBER; - -.fi -.SH OPTIONS -.I flex -has the following options: -.TP -.B \-b -Generate backing-up information to -.I lex.backup. -This is a list of scanner states which require backing up -and the input characters on which they do so. By adding rules one -can remove backing-up states. If all backing-up states -are eliminated and -.B \-Cf -or -.B \-CF -is used, the generated scanner will run faster (see the -.B \-p -flag). Only users who wish to squeeze every last cycle out of their -scanners need worry about this option. (See the section on Performance -Considerations below.) -.TP -.B \-c -is a do-nothing, deprecated option included for POSIX compliance. -.IP -.B NOTE: -in previous releases of -.I flex -.B \-c -specified table-compression options. This functionality is -now given by the -.B \-C -flag. To ease the the impact of this change, when -.I flex -encounters -.B \-c, -it currently issues a warning message and assumes that -.B \-C -was desired instead. In the future this "promotion" of -.B \-c -to -.B \-C -will go away in the name of full POSIX compliance (unless -the POSIX meaning is removed first). -.TP -.B \-d -makes the generated scanner run in -.I debug -mode. Whenever a pattern is recognized and the global -.B yy_flex_debug -is non-zero (which is the default), -the scanner will write to -.I stderr -a line of the form: -.nf - - --accepting rule at line 53 ("the matched text") - -.fi -The line number refers to the location of the rule in the file -defining the scanner (i.e., the file that was fed to flex). Messages -are also generated when the scanner backs up, accepts the -default rule, reaches the end of its input buffer (or encounters -a NUL; at this point, the two look the same as far as the scanner's concerned), -or reaches an end-of-file. -.TP -.B \-f -specifies -.I fast scanner. -No table compression is done and stdio is bypassed. -The result is large but fast. This option is equivalent to -.B \-Cfr -(see below). -.TP -.B \-h -generates a "help" summary of -.I flex's -options to -.I stderr -and then exits. -.TP -.B \-i -instructs -.I flex -to generate a -.I case-insensitive -scanner. The case of letters given in the -.I flex -input patterns will -be ignored, and tokens in the input will be matched regardless of case. The -matched text given in -.I yytext -will have the preserved case (i.e., it will not be folded). -.TP -.B \-l -turns on maximum compatibility with the original AT&T -.I lex -implementation. Note that this does not mean -.I full -compatibility. Use of this option costs a considerable amount of -performance, and it cannot be used with the -.B \-+, -f, -F, -Cf, -or -.B -CF -options. For details on the compatibilities it provides, see the section -"Incompatibilities With Lex And POSIX" below. -.TP -.B \-n -is another do-nothing, deprecated option included only for -POSIX compliance. -.TP -.B \-p -generates a performance report to stderr. The report -consists of comments regarding features of the -.I flex -input file which will cause a serious loss of performance in the resulting -scanner. If you give the flag twice, you will also get comments regarding -features that lead to minor performance losses. -.IP -Note that the use of -.B REJECT -and variable trailing context (see the Bugs section in flex(1)) -entails a substantial performance penalty; use of -.I yymore(), -the -.B ^ -operator, -and the -.B \-I -flag entail minor performance penalties. -.TP -.B \-s -causes the -.I default rule -(that unmatched scanner input is echoed to -.I stdout) -to be suppressed. If the scanner encounters input that does not -match any of its rules, it aborts with an error. This option is -useful for finding holes in a scanner's rule set. -.TP -.B \-t -instructs -.I flex -to write the scanner it generates to standard output instead -of -.B lex.yy.c. -.TP -.B \-v -specifies that -.I flex -should write to -.I stderr -a summary of statistics regarding the scanner it generates. -Most of the statistics are meaningless to the casual -.I flex -user, but the first line identifies the version of -.I flex -(same as reported by -.B \-V), -and the next line the flags used when generating the scanner, including -those that are on by default. -.TP -.B \-w -suppresses warning messages. -.TP -.B \-B -instructs -.I flex -to generate a -.I batch -scanner, the opposite of -.I interactive -scanners generated by -.B \-I -(see below). In general, you use -.B \-B -when you are -.I certain -that your scanner will never be used interactively, and you want to -squeeze a -.I little -more performance out of it. If your goal is instead to squeeze out a -.I lot -more performance, you should be using the -.B \-Cf -or -.B \-CF -options (discussed below), which turn on -.B \-B -automatically anyway. -.TP -.B \-F -specifies that the -.ul -fast -scanner table representation should be used (and stdio -bypassed). This representation is -about as fast as the full table representation -.B (-f), -and for some sets of patterns will be considerably smaller (and for -others, larger). In general, if the pattern set contains both "keywords" -and a catch-all, "identifier" rule, such as in the set: -.nf - - "case" return TOK_CASE; - "switch" return TOK_SWITCH; - ... - "default" return TOK_DEFAULT; - [a-z]+ return TOK_ID; - -.fi -then you're better off using the full table representation. If only -the "identifier" rule is present and you then use a hash table or some such -to detect the keywords, you're better off using -.B -F. -.IP -This option is equivalent to -.B \-CFr -(see below). It cannot be used with -.B \-+. -.TP -.B \-I -instructs -.I flex -to generate an -.I interactive -scanner. An interactive scanner is one that only looks ahead to decide -what token has been matched if it absolutely must. It turns out that -always looking one extra character ahead, even if the scanner has already -seen enough text to disambiguate the current token, is a bit faster than -only looking ahead when necessary. But scanners that always look ahead -give dreadful interactive performance; for example, when a user types -a newline, it is not recognized as a newline token until they enter -.I another -token, which often means typing in another whole line. -.IP -.I Flex -scanners default to -.I interactive -unless you use the -.B \-Cf -or -.B \-CF -table-compression options (see below). That's because if you're looking -for high-performance you should be using one of these options, so if you -didn't, -.I flex -assumes you'd rather trade off a bit of run-time performance for intuitive -interactive behavior. Note also that you -.I cannot -use -.B \-I -in conjunction with -.B \-Cf -or -.B \-CF. -Thus, this option is not really needed; it is on by default for all those -cases in which it is allowed. -.IP -You can force a scanner to -.I not -be interactive by using -.B \-B -(see above). -.TP -.B \-L -instructs -.I flex -not to generate -.B #line -directives. Without this option, -.I flex -peppers the generated scanner -with #line directives so error messages in the actions will be correctly -located with respect to the original -.I flex -input file, and not to -the fairly meaningless line numbers of -.B lex.yy.c. -(Unfortunately -.I flex -does not presently generate the necessary directives -to "retarget" the line numbers for those parts of -.B lex.yy.c -which it generated. So if there is an error in the generated code, -a meaningless line number is reported.) -.TP -.B \-T -makes -.I flex -run in -.I trace -mode. It will generate a lot of messages to -.I stderr -concerning -the form of the input and the resultant non-deterministic and deterministic -finite automata. This option is mostly for use in maintaining -.I flex. -.TP -.B \-V -prints the version number to -.I stderr -and exits. -.TP -.B \-7 -instructs -.I flex -to generate a 7-bit scanner, i.e., one which can only recognized 7-bit -characters in its input. The advantage of using -.B \-7 -is that the scanner's tables can be up to half the size of those generated -using the -.B \-8 -option (see below). The disadvantage is that such scanners often hang -or crash if their input contains an 8-bit character. -.IP -Note, however, that unless you generate your scanner using the -.B \-Cf -or -.B \-CF -table compression options, use of -.B \-7 -will save only a small amount of table space, and make your scanner -considerably less portable. -.I Flex's -default behavior is to generate an 8-bit scanner unless you use the -.B \-Cf -or -.B \-CF, -in which case -.I flex -defaults to generating 7-bit scanners unless your site was always -configured to generate 8-bit scanners (as will often be the case -with non-USA sites). You can tell whether flex generated a 7-bit -or an 8-bit scanner by inspecting the flag summary in the -.B \-v -output as described above. -.IP -Note that if you use -.B \-Cfe -or -.B \-CFe -(those table compression options, but also using equivalence classes as -discussed see below), flex still defaults to generating an 8-bit -scanner, since usually with these compression options full 8-bit tables -are not much more expensive than 7-bit tables. -.TP -.B \-8 -instructs -.I flex -to generate an 8-bit scanner, i.e., one which can recognize 8-bit -characters. This flag is only needed for scanners generated using -.B \-Cf -or -.B \-CF, -as otherwise flex defaults to generating an 8-bit scanner anyway. -.IP -See the discussion of -.B \-7 -above for flex's default behavior and the tradeoffs between 7-bit -and 8-bit scanners. -.TP -.B \-+ -specifies that you want flex to generate a C++ -scanner class. See the section on Generating C++ Scanners below for -details. -.TP -.B \-C[aefFmr] -controls the degree of table compression and, more generally, trade-offs -between small scanners and fast scanners. -.IP -.B \-Ca -("align") instructs flex to trade off larger tables in the -generated scanner for faster performance because the elements of -the tables are better aligned for memory access and computation. On some -RISC architectures, fetching and manipulating longwords is more efficient -than with smaller-sized datums such as shortwords. This option can -double the size of the tables used by your scanner. -.IP -.B \-Ce -directs -.I flex -to construct -.I equivalence classes, -i.e., sets of characters -which have identical lexical properties (for example, if the only -appearance of digits in the -.I flex -input is in the character class -"[0-9]" then the digits '0', '1', ..., '9' will all be put -in the same equivalence class). Equivalence classes usually give -dramatic reductions in the final table/object file sizes (typically -a factor of 2-5) and are pretty cheap performance-wise (one array -look-up per character scanned). -.IP -.B \-Cf -specifies that the -.I full -scanner tables should be generated - -.I flex -should not compress the -tables by taking advantages of similar transition functions for -different states. -.IP -.B \-CF -specifies that the alternate fast scanner representation (described -above under the -.B \-F -flag) -should be used. This option cannot be used with -.B \-+. -.IP -.B \-Cm -directs -.I flex -to construct -.I meta-equivalence classes, -which are sets of equivalence classes (or characters, if equivalence -classes are not being used) that are commonly used together. Meta-equivalence -classes are often a big win when using compressed tables, but they -have a moderate performance impact (one or two "if" tests and one -array look-up per character scanned). -.IP -.B \-Cr -causes the generated scanner to -.I bypass -use of the standard I/O library (stdio) for input. Instead of calling -.B fread() -or -.B getc(), -the scanner will use the -.B read() -system call, resulting in a performance gain which varies from system -to system, but in general is probably negligible unless you are also using -.B \-Cf -or -.B \-CF. -Using -.B \-Cr -can cause strange behavior if, for example, you read from -.I yyin -using stdio prior to calling the scanner (because the scanner will miss -whatever text your previous reads left in the stdio input buffer). -.IP -.B \-Cr -has no effect if you define -.B YY_INPUT -(see The Generated Scanner above). -.IP -A lone -.B \-C -specifies that the scanner tables should be compressed but neither -equivalence classes nor meta-equivalence classes should be used. -.IP -The options -.B \-Cf -or -.B \-CF -and -.B \-Cm -do not make sense together - there is no opportunity for meta-equivalence -classes if the table is not being compressed. Otherwise the options -may be freely mixed, and are cumulative. -.IP -The default setting is -.B \-Cem, -which specifies that -.I flex -should generate equivalence classes -and meta-equivalence classes. This setting provides the highest -degree of table compression. You can trade off -faster-executing scanners at the cost of larger tables with -the following generally being true: -.nf - - slowest & smallest - -Cem - -Cm - -Ce - -C - -C{f,F}e - -C{f,F} - -C{f,F}a - fastest & largest - -.fi -Note that scanners with the smallest tables are usually generated and -compiled the quickest, so -during development you will usually want to use the default, maximal -compression. -.IP -.B \-Cfe -is often a good compromise between speed and size for production -scanners. -.TP -.B \-Pprefix -changes the default -.I "yy" -prefix used by -.I flex -for all globally-visible variable and function names to instead be -.I prefix. -For example, -.B \-Pfoo -changes the name of -.B yytext -to -.B footext. -It also changes the name of the default output file from -.B lex.yy.c -to -.B lex.foo.c. -Here are all of the names affected: -.nf - - yyFlexLexer - yy_create_buffer - yy_delete_buffer - yy_flex_debug - yy_init_buffer - yy_load_buffer_state - yy_switch_to_buffer - yyin - yyleng - yylex - yyout - yyrestart - yytext - yywrap - -.fi -Within your scanner itself, you can still refer to the global variables -and functions using either version of their name; but eternally, they -have the modified name. -.IP -This option lets you easily link together multiple -.I flex -programs into the same executable. Note, though, that using this -option also renames -.B yywrap(), -so you now -.I must -provide your own (appropriately-named) version of the routine for your -scanner, as linking with -.B \-lfl -no longer provides one for you by default. -.TP -.B \-Sskeleton_file -overrides the default skeleton file from which -.I flex -constructs its scanners. You'll never need this option unless you are doing -.I flex -maintenance or development. -.SH PERFORMANCE CONSIDERATIONS -The main design goal of -.I flex -is that it generate high-performance scanners. It has been optimized -for dealing well with large sets of rules. Aside from the effects on -scanner speed of the table compression -.B \-C -options outlined above, -there are a number of options/actions which degrade performance. These -are, from most expensive to least: -.nf - - REJECT - - pattern sets that require backing up - arbitrary trailing context - - yymore() - '^' beginning-of-line operator - -.fi -with the first three all being quite expensive and the last two -being quite cheap. Note also that -.B unput() -is implemented as a routine call that potentially does quite a bit of -work, while -.B yyless() -is a quite-cheap macro; so if just putting back some excess text you -scanned, use -.B yyless(). -.PP -.B REJECT -should be avoided at all costs when performance is important. -It is a particularly expensive option. -.PP -Getting rid of backing up is messy and often may be an enormous -amount of work for a complicated scanner. In principal, one begins -by using the -.B \-b -flag to generate a -.I lex.backup -file. For example, on the input -.nf - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - -.fi -the file looks like: -.nf - - State #6 is non-accepting - - associated rule line numbers: - 2 3 - out-transitions: [ o ] - jam-transitions: EOF [ \\001-n p-\\177 ] - - State #8 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ a ] - jam-transitions: EOF [ \\001-` b-\\177 ] - - State #9 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ r ] - jam-transitions: EOF [ \\001-q s-\\177 ] - - Compressed tables always back up. - -.fi -The first few lines tell us that there's a scanner state in -which it can make a transition on an 'o' but not on any other -character, and that in that state the currently scanned text does not match -any rule. The state occurs when trying to match the rules found -at lines 2 and 3 in the input file. -If the scanner is in that state and then reads -something other than an 'o', it will have to back up to find -a rule which is matched. With -a bit of headscratching one can see that this must be the -state it's in when it has seen "fo". When this has happened, -if anything other than another 'o' is seen, the scanner will -have to back up to simply match the 'f' (by the default rule). -.PP -The comment regarding State #8 indicates there's a problem -when "foob" has been scanned. Indeed, on any character other -than an 'a', the scanner will have to back up to accept "foo". -Similarly, the comment for State #9 concerns when "fooba" has -been scanned and an 'r' does not follow. -.PP -The final comment reminds us that there's no point going to -all the trouble of removing backing up from the rules unless -we're using -.B \-Cf -or -.B \-CF, -since there's no performance gain doing so with compressed scanners. -.PP -The way to remove the backing up is to add "error" rules: -.nf - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - fooba | - foob | - fo { - /* false alarm, not really a keyword */ - return TOK_ID; - } - -.fi -.PP -Eliminating backing up among a list of keywords can also be -done using a "catch-all" rule: -.nf - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - [a-z]+ return TOK_ID; - -.fi -This is usually the best solution when appropriate. -.PP -Backing up messages tend to cascade. -With a complicated set of rules it's not uncommon to get hundreds -of messages. If one can decipher them, though, it often -only takes a dozen or so rules to eliminate the backing up (though -it's easy to make a mistake and have an error rule accidentally match -a valid token. A possible future -.I flex -feature will be to automatically add rules to eliminate backing up). -.PP -.I Variable -trailing context (where both the leading and trailing parts do not have -a fixed length) entails almost the same performance loss as -.B REJECT -(i.e., substantial). So when possible a rule like: -.nf - - %% - mouse|rat/(cat|dog) run(); - -.fi -is better written: -.nf - - %% - mouse/cat|dog run(); - rat/cat|dog run(); - -.fi -or as -.nf - - %% - mouse|rat/cat run(); - mouse|rat/dog run(); - -.fi -Note that here the special '|' action does -.I not -provide any savings, and can even make things worse (see -.PP -A final note regarding performance: as mentioned above in the section -How the Input is Matched, dynamically resizing -.B yytext -to accomodate huge tokens is a slow process because it presently requires that -the (huge) token be rescanned from the beginning. Thus if performance is -vital, you should attempt to match "large" quantities of text but not -"huge" quantities, where the cutoff between the two is at about 8K -characters/token. -.PP -Another area where the user can increase a scanner's performance -(and one that's easier to implement) arises from the fact that -the longer the tokens matched, the faster the scanner will run. -This is because with long tokens the processing of most input -characters takes place in the (short) inner scanning loop, and -does not often have to go through the additional work of setting up -the scanning environment (e.g., -.B yytext) -for the action. Recall the scanner for C comments: -.nf - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\\n]* - "*"+[^*/\\n]* - \\n ++line_num; - "*"+"/" BEGIN(INITIAL); - -.fi -This could be sped up by writing it as: -.nf - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\\n]* - [^*\\n]*\\n ++line_num; - "*"+[^*/\\n]* - "*"+[^*/\\n]*\\n ++line_num; - "*"+"/" BEGIN(INITIAL); - -.fi -Now instead of each newline requiring the processing of another -action, recognizing the newlines is "distributed" over the other rules -to keep the matched text as long as possible. Note that -.I adding -rules does -.I not -slow down the scanner! The speed of the scanner is independent -of the number of rules or (modulo the considerations given at the -beginning of this section) how complicated the rules are with -regard to operators such as '*' and '|'. -.PP -A final example in speeding up a scanner: suppose you want to scan -through a file containing identifiers and keywords, one per line -and with no other extraneous characters, and recognize all the -keywords. A natural first approach is: -.nf - - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ - - .|\\n /* it's not a keyword */ - -.fi -To eliminate the back-tracking, introduce a catch-all rule: -.nf - - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ - - [a-z]+ | - .|\\n /* it's not a keyword */ - -.fi -Now, if it's guaranteed that there's exactly one word per line, -then we can reduce the total number of matches by a half by -merging in the recognition of newlines with that of the other -tokens: -.nf - - %% - asm\\n | - auto\\n | - break\\n | - ... etc ... - volatile\\n | - while\\n /* it's a keyword */ - - [a-z]+\\n | - .|\\n /* it's not a keyword */ - -.fi -One has to be careful here, as we have now reintroduced backing up -into the scanner. In particular, while -.I we -know that there will never be any characters in the input stream -other than letters or newlines, -.I flex -can't figure this out, and it will plan for possibly needing to back up -when it has scanned a token like "auto" and then the next character -is something other than a newline or a letter. Previously it would -then just match the "auto" rule and be done, but now it has no "auto" -rule, only a "auto\\n" rule. To eliminate the possibility of backing up, -we could either duplicate all rules but without final newlines, or, -since we never expect to encounter such an input and therefore don't -how it's classified, we can introduce one more catch-all rule, this -one which doesn't include a newline: -.nf - - %% - asm\\n | - auto\\n | - break\\n | - ... etc ... - volatile\\n | - while\\n /* it's a keyword */ - - [a-z]+\\n | - [a-z]+ | - .|\\n /* it's not a keyword */ - -.fi -Compiled with -.B \-Cf, -this is about as fast as one can get a -.I flex -scanner to go for this particular problem. -.PP -A final note: -.I flex -is slow when matching NUL's, particularly when a token contains -multiple NUL's. -It's best to write rules which match -.I short -amounts of text if it's anticipated that the text will often include NUL's. -.SH GENERATING C++ SCANNERS -.I flex -provides two different ways to generate scanners for use with C++. The -first way is to simply compile a scanner generated by -.I flex -using a C++ compiler instead of a C compiler. You should not encounter -any compilations errors (please report any you find to the email address -given in the Author section below). You can then use C++ code in your -rule actions instead of C code. Note that the default input source for -your scanner remains -.I yyin, -and default echoing is still done to -.I yyout. -Both of these remain -.I FILE * -variables and not C++ -.I streams. -.PP -You can also use -.I flex -to generate a C++ scanner class, using the -.B \-+ -option, which is automatically specified if the name of the flex -executable ends in a '+', such as -.I flex++. -When using this option, flex defaults to generating the scanner to the file -.B lex.yy.cc -instead of -.B lex.yy.c. -The generated scanner includes the header file -.I FlexLexer.h, -which defines the interface to two C++ classes. -.PP -The first class, -.B FlexLexer, -provides an abstract base class defining the general scanner class -interface. It provides the following member functions: -.TP -.B const char* YYText() -returns the text of the most recently matched token, the equivalent of -.B yytext. -.TP -.B int YYLeng() -returns the length of the most recently matched token, the equivalent of -.B yyleng. -.PP -Also provided are member functions equivalent to -.B yy_switch_to_buffer(), -.B yy_create_buffer() -(though the first argument is an -.B istream* -object pointer and not a -.B FILE*), -.B yy_delete_buffer(), -and -.B yyrestart() -(again, the first argument is a -.B istream* -object pointer). -.PP -The second class defined in -.I FlexLexer.h -is -.B yyFlexLexer, -which is derived from -.B FlexLexer. -It defines the following additional member functions: -.TP -.B -yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 ) -constructs a -.B yyFlexLexer -object using the given streams for input and output. If not specified, -the streams default to -.B cin -and -.B cout, -respectively. -.TP -.B virtual int yylex() -performs the same role is -.B yylex() -does for ordinary flex scanners: it scans the input stream, consuming -tokens, until a rule's action returns a value. -.PP -In addition, -.B yyFlexLexer -defines the following protected virtual functions which you can redefine -in derived classes to tailor the scanner: -.TP -.B -virtual int LexerInput( char* buf, int max_size ) -reads up to -.B max_size -characters into -.B buf -and returns the number of characters read. To indicate end-of-input, -return 0 characters. Note that "interactive" scanners (see the -.B \-B -and -.B \-I -flags) define the macro -.B YY_INTERACTIVE. -If you redefine -.B LexerInput() -and need to take different actions depending on whether or not -the scanner might be scanning an interactive input source, you can -test for the presence of this name via -.B #ifdef. -.TP -.B -virtual void LexerOutput( const char* buf, int size ) -writes out -.B size -characters from the buffer -.B buf, -which, while NUL-terminated, may also contain "internal" NUL's if -the scanner's rules can match text with NUL's in them. -.TP -.B -virtual void LexerError( const char* msg ) -reports a fatal error message. The default version of this function -writes the message to the stream -.B cerr -and exits. -.PP -Note that a -.B yyFlexLexer -object contains its -.I entire -scanning state. Thus you can use such objects to create reentrant -scanners. You can instantiate multiple instances of the same -.B yyFlexLexer -class, and you can also combine multiple C++ scanner classes together -in the same program using the -.B \-P -option discussed above. -.PP -Finally, note that the -.B %array -feature is not available to C++ scanner classes; you must use -.B %pointer -(the default). -.PP -Here is an example of a simple C++ scanner: -.nf - - // An example of using the flex C++ scanner class. - - %{ - int mylineno = 0; - %} - - string \\"[^\\n"]+\\" - - ws [ \\t]+ - - alpha [A-Za-z] - dig [0-9] - name ({alpha}|{dig}|\\$)({alpha}|{dig}|[_.\\-/$])* - num1 [-+]?{dig}+\\.?([eE][-+]?{dig}+)? - num2 [-+]?{dig}*\\.{dig}+([eE][-+]?{dig}+)? - number {num1}|{num2} - - %% - - {ws} /* skip blanks and tabs */ - - "/*" { - int c; - - while((c = yyinput()) != 0) - { - if(c == '\\n') - ++mylineno; - - else if(c == '*') - { - if((c = yyinput()) == '/') - break; - else - unput(c); - } - } - } - - {number} cout << "number " << YYText() << '\\n'; - - \\n mylineno++; - - {name} cout << "name " << YYText() << '\\n'; - - {string} cout << "string " << YYText() << '\\n'; - - %% - - int main( int /* argc */, char** /* argv */ ) - { - FlexLexer* lexer = new yyFlexLexer; - while(lexer->yylex() != 0) - ; - return 0; - } -.fi -IMPORTANT: the present form of the scanning class is -.I experimental -and may change considerably between major releases. -.SH INCOMPATIBILITIES WITH LEX AND POSIX -.I flex -is a rewrite of the AT&T Unix -.I lex -tool (the two implementations do not share any code, though), -with some extensions and incompatibilities, both of which -are of concern to those who wish to write scanners acceptable -to either implementation. The POSIX -.I lex -specification is closer to -.I flex's -behavior than that of the original -.I lex -implementation, but there also remain some incompatibilities between -.I flex -and POSIX. The intent is that ultimately -.I flex -will be fully POSIX-conformant. In this section we discuss all of -the known areas of incompatibility. -.PP -.I flex's -.B \-l -option turns on maximum compatibility with the original AT&T -.I lex -implementation, at the cost of a major loss in the generated scanner's -performance. We note below which incompatibilities can be overcome -using the -.B \-l -option. -.PP -.I flex -is fully compatible with -.I lex -with the following exceptions: -.IP - -The undocumented -.I lex -scanner internal variable -.B yylineno -is not supported unless -.B \-l -is used. -.IP -yylineno is not part of the POSIX specification. -.IP - -The -.B input() -routine is not redefinable, though it may be called to read characters -following whatever has been matched by a rule. If -.B input() -encounters an end-of-file the normal -.B yywrap() -processing is done. A ``real'' end-of-file is returned by -.B input() -as -.I EOF. -.IP -Input is instead controlled by defining the -.B YY_INPUT -macro. -.IP -The -.I flex -restriction that -.B input() -cannot be redefined is in accordance with the POSIX specification, -which simply does not specify any way of controlling the -scanner's input other than by making an initial assignment to -.I yyin. -.IP - -.I flex -scanners are not as reentrant as -.I lex -scanners. In particular, if you have an interactive scanner and -an interrupt handler which long-jumps out of the scanner, and -the scanner is subsequently called again, you may get the following -message: -.nf - - fatal flex scanner internal error--end of buffer missed - -.fi -To reenter the scanner, first use -.nf - - yyrestart( yyin ); - -.fi -Note that this call will throw away any buffered input; usually this -isn't a problem with an interactive scanner. -.IP -Also note that flex C++ scanner classes -.I are -reentrant, so if using C++ is an option for you, you should use -them instead. See "Generating C++ Scanners" above for details. -.IP - -.B output() -is not supported. -Output from the -.B ECHO -macro is done to the file-pointer -.I yyout -(default -.I stdout). -.IP -.B output() -is not part of the POSIX specification. -.IP - -.I lex -does not support exclusive start conditions (%x), though they -are in the POSIX specification. -.IP - -When definitions are expanded, -.I flex -encloses them in parentheses. -With lex, the following: -.nf - - NAME [A-Z][A-Z0-9]* - %% - foo{NAME}? printf( "Found it\\n" ); - %% - -.fi -will not match the string "foo" because when the macro -is expanded the rule is equivalent to "foo[A-Z][A-Z0-9]*?" -and the precedence is such that the '?' is associated with -"[A-Z0-9]*". With -.I flex, -the rule will be expanded to -"foo([A-Z][A-Z0-9]*)?" and so the string "foo" will match. -.IP -Note that if the definition begins with -.B ^ -or ends with -.B $ -then it is -.I not -expanded with parentheses, to allow these operators to appear in -definitions without losing their special meanings. But the -.B , /, -and -.B <> -operators cannot be used in a -.I flex -definition. -.IP -Using -.B \-l -results in the -.I lex -behavior of no parentheses around the definition. -.IP -The POSIX specification is that the definition be enclosed in parentheses. -.IP - -The -.I lex -.B %r -(generate a Ratfor scanner) option is not supported. It is not part -of the POSIX specification. -.IP - -After a call to -.B unput(), -.I yytext -and -.I yyleng -are undefined until the next token is matched, unless the scanner -was built using -.B %array. -This is not the case with -.I lex -or the POSIX specification. The -.B \-l -option does away with this incompatibility. -.IP - -The precedence of the -.B {} -(numeric range) operator is different. -.I lex -interprets "abc{1,3}" as "match one, two, or -three occurrences of 'abc'", whereas -.I flex -interprets it as "match 'ab' -followed by one, two, or three occurrences of 'c'". The latter is -in agreement with the POSIX specification. -.IP - -The precedence of the -.B ^ -operator is different. -.I lex -interprets "^foo|bar" as "match either 'foo' at the beginning of a line, -or 'bar' anywhere", whereas -.I flex -interprets it as "match either 'foo' or 'bar' if they come at the beginning -of a line". The latter is in agreement with the POSIX specification. -.IP - -.I yyin -is -.I initialized -by -.I lex -to be -.I stdin; -.I flex, -on the other hand, -initializes -.I yyin -to NULL -and then -.I assigns -it to -.I stdin -the first time the scanner is called, providing -.I yyin -has not already been assigned to a non-NULL value. The difference is -subtle, but the net effect is that with -.I flex -scanners, -.I yyin -does not have a valid value until the scanner has been called. -.IP -The -.B \-l -option does away with this incompatibility. -.IP - -The special table-size declarations such as -.B %a -supported by -.I lex -are not required by -.I flex -scanners; -.I flex -ignores them. -.IP - -The name -.bd -FLEX_SCANNER -is #define'd so scanners may be written for use with either -.I flex -or -.I lex. -.PP -The following -.I flex -features are not included in -.I lex -or the POSIX specification: -.nf - - yyterminate() - <> - <*> - YY_DECL - YY_START - YY_USER_ACTION - #line directives - %{}'s around actions - multiple actions on a line - -.fi -plus almost all of the flex flags. -The last feature in the list refers to the fact that with -.I flex -you can put multiple actions on the same line, separated with -semi-colons, while with -.I lex, -the following -.nf - - foo handle_foo(); ++num_foos_seen; - -.fi -is (rather surprisingly) truncated to -.nf - - foo handle_foo(); - -.fi -.I flex -does not truncate the action. Actions that are not enclosed in -braces are simply terminated at the end of the line. -.SH DIAGNOSTICS -.PP -.I warning, rule cannot be matched -indicates that the given rule -cannot be matched because it follows other rules that will -always match the same text as it. For -example, in the following "foo" cannot be matched because it comes after -an identifier "catch-all" rule: -.nf - - [a-z]+ got_identifier(); - foo got_foo(); - -.fi -Using -.B REJECT -in a scanner suppresses this warning. -.PP -.I warning, -.B \-s -.I -option given but default rule can be matched -means that it is possible (perhaps only in a particular start condition) -that the default rule (match any single character) is the only one -that will match a particular input. Since -.B \-s -was given, presumably this is not intended. -.PP -.I reject_used_but_not_detected undefined -or -.I yymore_used_but_not_detected undefined - -These errors can occur at compile time. They indicate that the -scanner uses -.B REJECT -or -.B yymore() -but that -.I flex -failed to notice the fact, meaning that -.I flex -scanned the first two sections looking for occurrences of these actions -and failed to find any, but somehow you snuck some in (via a #include -file, for example). Make an explicit reference to the action in your -.I flex -input file. (Note that previously -.I flex -supported a -.B %used/%unused -mechanism for dealing with this problem; this feature is still supported -but now deprecated, and will go away soon unless the author hears from -people who can argue compellingly that they need it.) -.PP -.I flex scanner jammed - -a scanner compiled with -.B \-s -has encountered an input string which wasn't matched by -any of its rules. This error can also occur due to internal problems. -.PP -.I token too large, exceeds YYLMAX - -your scanner uses -.B %array -and one of its rules matched a string longer than the -.B YYLMAX -constant (8K bytes by default). You can increase the value by -#define'ing -.B YYLMAX -in the definitions section of your -.I flex -input. -.PP -.I scanner requires \-8 flag to -.I use the character 'x' - -Your scanner specification includes recognizing the 8-bit character -.I 'x' -and you did not specify the \-8 flag, and your scanner defaulted to 7-bit -because you used the -.B \-Cf -or -.B \-CF -table compression options. See the discussion of the -.B \-7 -flag for details. -.PP -.I flex scanner push-back overflow - -you used -.B unput() -to push back so much text that the scanner's buffer could not hold -both the pushed-back text and the current token in -.B yytext. -Ideally the scanner should dynamically resize the buffer in this case, but at -present it does not. -.PP -.I -input buffer overflow, can't enlarge buffer because scanner uses REJECT - -the scanner was working on matching an extremely large token and needed -to expand the input buffer. This doesn't work with scanners that use -.B -REJECT. -.PP -.I -fatal flex scanner internal error--end of buffer missed - -This can occur in an scanner which is reentered after a long-jump -has jumped out (or over) the scanner's activation frame. Before -reentering the scanner, use: -.nf - - yyrestart( yyin ); - -.fi -or, as noted above, switch to using the C++ scanner class. -.PP -.I too many start conditions in <> construct! - -you listed more start conditions in a <> construct than exist (so -you must have listed at least one of them twice). -.SH FILES -See flex(1). -.SH DEFICIENCIES / BUGS -Again, see flex(1). -.SH "SEE ALSO" -.PP -flex(1), lex(1), yacc(1), sed(1), awk(1). -.PP -M. E. Lesk and E. Schmidt, -.I LEX \- Lexical Analyzer Generator -.SH AUTHOR -Vern Paxson, with the help of many ideas and much inspiration from -Van Jacobson. Original version by Jef Poskanzer. The fast table -representation is a partial implementation of a design done by Van -Jacobson. The implementation was done by Kevin Gong and Vern Paxson. -.PP -Thanks to the many -.I flex -beta-testers, feedbackers, and contributors, especially Francois Pinard, -Casey Leedom, -Nelson H.F. Beebe, benson@odi.com, Peter A. Bigot, Keith Bostic, Frederic -Brehm, Nick Christopher, Jason Coughlin, Bill Cox, Dave Curtis, Scott David -Daniels, Chris G. Demetriou, Mike Donahue, Chuck Doucette, Tom Epperly, Leo -Eskin, Chris Faylor, Jon Forrest, Kaveh R. Ghazi, -Eric Goldman, Ulrich Grepel, Jan Hajic, -Jarkko Hietaniemi, Eric Hughes, John Interrante, -Ceriel Jacobs, Jeffrey R. Jones, Henry -Juengst, Amir Katz, ken@ken.hilco.com, Kevin B. Kenny, Marq Kole, Ronald -Lamprecht, Greg Lee, Craig Leres, John Levine, Steve Liddle, -Mohamed el Lozy, Brian Madsen, Chris -Metcalf, Luke Mewburn, Jim Meyering, G.T. Nicol, Landon Noll, Marc Nozell, -Richard Ohnemus, Sven Panne, Roland Pesch, Walter Pelissero, Gaumond -Pierre, Esmond Pitt, Jef Poskanzer, Joe Rahmeh, Frederic Raimbault, -Rick Richardson, -Kevin Rodgers, Jim Roskind, -Doug Schmidt, Philippe Schnoebelen, Andreas Schwab, -Alex Siegel, Mike Stump, Paul Stuart, Dave Tallman, Chris Thewalt, -Paul Tuinenga, Gary Weik, Frank Whaley, Gerhard Wilhelms, Kent Williams, Ken -Yap, Nathan Zelle, David Zuhn, and those whose names have slipped my marginal -mail-archiving skills but whose contributions are appreciated all the -same. -.PP -Thanks to Keith Bostic, Jon Forrest, Noah Friedman, -John Gilmore, Craig Leres, John Levine, Bob Mulcahy, G.T. -Nicol, Francois Pinard, Rich Salz, and Richard Stallman for help with various -distribution headaches. -.PP -Thanks to Esmond Pitt and Earle Horton for 8-bit character support; to -Benson Margulies and Fred Burke for C++ support; to Kent Williams and Tom -Epperly for C++ class support; to Ove Ewerlid for support of NUL's; and to -Eric Hughes for support of multiple buffers. -.PP -This work was primarily done when I was with the Real Time Systems Group -at the Lawrence Berkeley Laboratory in Berkeley, CA. Many thanks to all there -for the support I received. -.PP -Send comments to: -.nf - - Vern Paxson - Systems Engineering - Bldg. 46A, Room 1123 - Lawrence Berkeley Laboratory - University of California - Berkeley, CA 94720 - - vern@ee.lbl.gov - -.fi diff --git a/usr.bin/m4/serv.c b/usr.bin/m4/serv.c deleted file mode 100644 index 54a2e59..0000000 --- a/usr.bin/m4/serv.c +++ /dev/null @@ -1,475 +0,0 @@ -/* - * Copyright (c) 1989 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * This code is derived from software contributed to Berkeley by - * Ozan Yigit. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)serv.c 5.4 (Berkeley) 1/21/94"; -#endif /* not lint */ - -/* - * serv.c - * Facility: m4 macro processor - * by: oz - */ - -#include -#include -#include -#include "mdef.h" -#include "extr.h" -#include "pathnames.h" - -extern ndptr lookup(); -extern ndptr addent(); - -char *dumpfmt = "`%s'\t`%s'\n"; /* format string for dumpdef */ - -/* - * expand - user-defined macro expansion - * - */ -expand(argv, argc) -register char *argv[]; -register int argc; -{ - register char *t; - register char *p; - register int n; - register int argno; - - t = argv[0]; /* defn string as a whole */ - p = t; - while (*p) - p++; - p--; /* last character of defn */ - while (p > t) { - if (*(p-1) != ARGFLAG) - putback(*p); - else { - switch (*p) { - - case '#': - pbnum(argc-2); - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if ((argno = *p - '0') < argc-1) - pbstr(argv[argno+1]); - break; - case '*': - for (n = argc - 1; n > 2; n--) { - pbstr(argv[n]); - putback(','); - } - pbstr(argv[2]); - break; - default : - putback(*p); - break; - } - p--; - } - p--; - } - if (p == t) /* do last character */ - putback(*p); -} - -/* - * dodefine - install definition in the table - * - */ -dodefine(name, defn) -register char *name; -register char *defn; -{ - register ndptr p; - - if (!*name) - error("m4: null definition."); - if (strcmp(name, defn) == 0) - error("m4: recursive definition."); - if ((p = lookup(name)) == nil) - p = addent(name); - else if (p->defn != null) - free(p->defn); - if (!*defn) - p->defn = null; - else - p->defn = strdup(defn); - p->type = MACRTYPE; -} - -/* - * dodefn - push back a quoted definition of - * the given name. - */ - -dodefn(name) -char *name; -{ - register ndptr p; - - if ((p = lookup(name)) != nil && p->defn != null) { - putback(rquote); - pbstr(p->defn); - putback(lquote); - } -} - -/* - * dopushdef - install a definition in the hash table - * without removing a previous definition. Since - * each new entry is entered in *front* of the - * hash bucket, it hides a previous definition from - * lookup. - */ -dopushdef(name, defn) -register char *name; -register char *defn; -{ - register ndptr p; - - if (!*name) - error("m4: null definition"); - if (strcmp(name, defn) == 0) - error("m4: recursive definition."); - p = addent(name); - if (!*defn) - p->defn = null; - else - p->defn = strdup(defn); - p->type = MACRTYPE; -} - -/* - * dodumpdef - dump the specified definitions in the hash - * table to stderr. If nothing is specified, the entire - * hash table is dumped. - * - */ -dodump(argv, argc) -register char *argv[]; -register int argc; -{ - register int n; - ndptr p; - - if (argc > 2) { - for (n = 2; n < argc; n++) - if ((p = lookup(argv[n])) != nil) - fprintf(stderr, dumpfmt, p->name, - p->defn); - } - else { - for (n = 0; n < HASHSIZE; n++) - for (p = hashtab[n]; p != nil; p = p->nxtptr) - fprintf(stderr, dumpfmt, p->name, - p->defn); - } -} - -/* - * doifelse - select one of two alternatives - loop. - * - */ -doifelse(argv,argc) -register char *argv[]; -register int argc; -{ - cycle { - if (strcmp(argv[2], argv[3]) == 0) - pbstr(argv[4]); - else if (argc == 6) - pbstr(argv[5]); - else if (argc > 6) { - argv += 3; - argc -= 3; - continue; - } - break; - } -} - -/* - * doinclude - include a given file. - * - */ -doincl(ifile) -char *ifile; -{ - if (ilevel+1 == MAXINP) - error("m4: too many include files."); - if ((infile[ilevel+1] = fopen(ifile, "r")) != NULL) { - ilevel++; - return (1); - } - else - return (0); -} - -#ifdef EXTENDED -/* - * dopaste - include a given file without any - * macro processing. - */ -dopaste(pfile) -char *pfile; -{ - FILE *pf; - register int c; - - if ((pf = fopen(pfile, "r")) != NULL) { - while((c = getc(pf)) != EOF) - putc(c, active); - (void) fclose(pf); - return(1); - } - else - return(0); -} -#endif - -/* - * dochq - change quote characters - * - */ -dochq(argv, argc) -register char *argv[]; -register int argc; -{ - if (argc > 2) { - if (*argv[2]) - lquote = *argv[2]; - if (argc > 3) { - if (*argv[3]) - rquote = *argv[3]; - } - else - rquote = lquote; - } - else { - lquote = LQUOTE; - rquote = RQUOTE; - } -} - -/* - * dochc - change comment characters - * - */ -dochc(argv, argc) -register char *argv[]; -register int argc; -{ - if (argc > 2) { - if (*argv[2]) - scommt = *argv[2]; - if (argc > 3) { - if (*argv[3]) - ecommt = *argv[3]; - } - else - ecommt = ECOMMT; - } - else { - scommt = SCOMMT; - ecommt = ECOMMT; - } -} - -/* - * dodivert - divert the output to a temporary file - * - */ -dodiv(n) -register int n; -{ - if (n < 0 || n >= MAXOUT) - n = 0; /* bitbucket */ - if (outfile[n] == NULL) { - m4temp[UNIQUE] = n + '0'; - if ((outfile[n] = fopen(m4temp, "w")) == NULL) - error("m4: cannot divert."); - } - oindex = n; - active = outfile[n]; -} - -/* - * doundivert - undivert a specified output, or all - * other outputs, in numerical order. - */ -doundiv(argv, argc) -register char *argv[]; -register int argc; -{ - register int ind; - register int n; - - if (argc > 2) { - for (ind = 2; ind < argc; ind++) { - n = atoi(argv[ind]); - if (n > 0 && n < MAXOUT && outfile[n] != NULL) - getdiv(n); - - } - } - else - for (n = 1; n < MAXOUT; n++) - if (outfile[n] != NULL) - getdiv(n); -} - -/* - * dosub - select substring - * - */ -dosub (argv, argc) -register char *argv[]; -register int argc; -{ - register char *ap, *fc, *k; - register int nc; - - if (argc < 5) - nc = MAXTOK; - else -#ifdef EXPR - nc = expr(argv[4]); -#else - nc = atoi(argv[4]); -#endif - ap = argv[2]; /* target string */ -#ifdef EXPR - fc = ap + expr(argv[3]); /* first char */ -#else - fc = ap + atoi(argv[3]); /* first char */ -#endif - if (fc >= ap && fc < ap+strlen(ap)) - for (k = fc+min(nc,strlen(fc))-1; k >= fc; k--) - putback(*k); -} - -/* - * map: - * map every character of s1 that is specified in from - * into s3 and replace in s. (source s1 remains untouched) - * - * This is a standard implementation of map(s,from,to) function of ICON - * language. Within mapvec, we replace every character of "from" with - * the corresponding character in "to". If "to" is shorter than "from", - * than the corresponding entries are null, which means that those - * characters dissapear altogether. Furthermore, imagine - * map(dest, "sourcestring", "srtin", "rn..*") type call. In this case, - * `s' maps to `r', `r' maps to `n' and `n' maps to `*'. Thus, `s' - * ultimately maps to `*'. In order to achieve this effect in an efficient - * manner (i.e. without multiple passes over the destination string), we - * loop over mapvec, starting with the initial source character. if the - * character value (dch) in this location is different than the source - * character (sch), sch becomes dch, once again to index into mapvec, until - * the character value stabilizes (i.e. sch = dch, in other words - * mapvec[n] == n). Even if the entry in the mapvec is null for an ordinary - * character, it will stabilize, since mapvec[0] == 0 at all times. At the - * end, we restore mapvec* back to normal where mapvec[n] == n for - * 0 <= n <= 127. This strategy, along with the restoration of mapvec, is - * about 5 times faster than any algorithm that makes multiple passes over - * destination string. - * - */ - -map(dest,src,from,to) -register char *dest; -register char *src; -register char *from; -register char *to; -{ - register char *tmp; - register char sch, dch; - static char mapvec[128] = { - 0, 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, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127 - }; - - if (*src) { - tmp = from; - /* - * create a mapping between "from" and "to" - */ - while (*from) - mapvec[*from++] = (*to) ? *to++ : (char) 0; - - while (*src) { - sch = *src++; - dch = mapvec[sch]; - while (dch != sch) { - sch = dch; - dch = mapvec[sch]; - } - if (*dest = dch) - dest++; - } - /* - * restore all the changed characters - */ - while (*tmp) { - mapvec[*tmp] = *tmp; - tmp++; - } - } - *dest = (char) 0; -} diff --git a/usr.bin/man/Makefile b/usr.bin/man/Makefile deleted file mode 100644 index 728d038..0000000 --- a/usr.bin/man/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= man -SRCS= config.c man.c -MAN1= man.0 -MAN5= man.conf.0 - -.include diff --git a/usr.bin/man/config.c b/usr.bin/man/config.c deleted file mode 100644 index 1d875b5..0000000 --- a/usr.bin/man/config.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)config.c 8.7 (Berkeley) 1/3/94"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "config.h" -#include "pathnames.h" - -struct _head head; - -/* - * config -- - * - * Read the configuration file and build a doubly linked - * list that looks like: - * - * tag1 <-> record <-> record <-> record - * | - * tag2 <-> record <-> record <-> record - */ -void -config(fname) - char *fname; -{ - TAG *tp; - ENTRY *ep; - FILE *cfp; - size_t len; - int lcnt; - char *p, *t; - - if (fname == NULL) - fname = _PATH_MANCONF; - if ((cfp = fopen(fname, "r")) == NULL) - err(1, "%s", fname); - TAILQ_INIT(&head); - for (lcnt = 1; (p = fgetln(cfp, &len)) != NULL; ++lcnt) { - if (len == 1) /* Skip empty lines. */ - continue; - if (p[len - 1] != '\n') { /* Skip corrupted lines. */ - warnx("%s: line %d corrupted", fname, lcnt); - continue; - } - p[len - 1] = '\0'; /* Terminate the line. */ - - /* Skip leading space. */ - for (; *p != '\0' && isspace(*p); ++p); - /* Skip empty/comment lines. */ - if (*p == '\0' || *p == '#') - continue; - /* Find first token. */ - for (t = p; *t && !isspace(*t); ++t); - if (*t == '\0') /* Need more than one token.*/ - continue; - *t = '\0'; - - for (tp = head.tqh_first; /* Find any matching tag. */ - tp != NULL && strcmp(p, tp->s); tp = tp->q.tqe_next); - - if (tp == NULL) /* Create a new tag. */ - tp = addlist(p); - - /* - * Attach new records. The keyword _build takes the rest of - * the line as a single entity, everything else is white - * space separated. The reason we're not just using strtok(3) - * for all of the parsing is so we don't get caught if a line - * has only a single token on it. - */ - if (!strcmp(p, "_build")) { - while (*++t && isspace(*t)); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(t)) == NULL) - err(1, NULL); - TAILQ_INSERT_TAIL(&tp->list, ep, q); - } else for (++t; (p = strtok(t, " \t\n")) != NULL; t = NULL) { - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(p)) == NULL) - err(1, NULL); - TAILQ_INSERT_TAIL(&tp->list, ep, q); - } - } -} - -/* - * addlist -- - * Add a tag to the list. - */ -TAG * -addlist(name) - char *name; -{ - TAG *tp; - - if ((tp = calloc(1, sizeof(TAG))) == NULL || - (tp->s = strdup(name)) == NULL) - err(1, NULL); - TAILQ_INIT(&tp->list); - TAILQ_INSERT_TAIL(&head, tp, q); - return (tp); -} - -/* - * getlist -- - * Return the linked list of entries for a tag if it exists. - */ -TAG * -getlist(name) - char *name; -{ - TAG *tp; - - for (tp = head.tqh_first; tp != NULL; tp = tp->q.tqe_next) - if (!strcmp(name, tp->s)) - return (tp); - return (NULL); -} - -void -debug(l) - char *l; -{ - TAG *tp; - ENTRY *ep; - - (void)printf("%s ===============\n", l); - for (tp = head.tqh_first; tp != NULL; tp = tp->q.tqe_next) { - printf("%s\n", tp->s); - for (ep = tp->list.tqh_first; ep != NULL; ep = ep->q.tqe_next) - printf("\t%s\n", ep->s); - } -} diff --git a/usr.bin/man/config.h b/usr.bin/man/config.h deleted file mode 100644 index 52ea969..0000000 --- a/usr.bin/man/config.h +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)config.h 8.4 (Berkeley) 12/18/93 - */ - -typedef struct _tag { - TAILQ_ENTRY(_tag) q; /* Queue of tags. */ - - TAILQ_HEAD(tqh, _entry) list; /* Queue of entries. */ - char *s; /* Associated string. */ - size_t len; /* Length of 's'. */ -} TAG; -typedef struct _entry { - TAILQ_ENTRY(_entry) q; /* Queue of entries. */ - - char *s; /* Associated string. */ - size_t len; /* Length of 's'. */ -} ENTRY; - -TAILQ_HEAD(_head, _tag); -extern struct _head head; - -TAG *addlist __P((char *)); -void config __P((char *)); -void debug __P((char *)); -TAG *getlist __P((char *)); diff --git a/usr.bin/man/man.1 b/usr.bin/man/man.1 deleted file mode 100644 index 081e204..0000000 --- a/usr.bin/man/man.1 +++ /dev/null @@ -1,188 +0,0 @@ -.\" Copyright (c) 1989, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)man.1 8.2 (Berkeley) 1/2/94 -.\" -.Dd January 2, 1994 -.Dt MAN 1 -.Os BSD 4 -.Sh NAME -.Nm man -.Nd display the on-line manual pages -.Sh SYNOPSIS -.Nm man -.Op Fl achw -.Op Fl C Ar file -.Op Fl M Ar path -.Op Fl m Ar path -.Op Ar section -.Ar name Ar ... -.Sh DESCRIPTION -The -.Nm man -utility -displays the -.Bx -manual pages entitled -.Ar name . -.Pp -The options are as follows: -.Bl -tag -width indent -.It Fl a -Display all of the manual pages for a specified -.Ar section -and -.Ar name -combination. -(Normally, only the first manual page found is displayed.) -.It Fl C -Use the specified -.Ar file -instead of the default configuration file. -This permits users to configure their own manual environment. -See -.Xr man.conf 5 -for a description of the contents of this file. -.It Fl c -Copy the manual page to the standard output instead of using -.Xr more 1 -to paginate it. -This is done by default if the standard output is not a terminal device. -.It Fl h -Display only the -.Dq Tn SYNOPSIS -lines of the requested manual pages. -.It Fl M -Override the list of standard directories which -.Nm man -searches for manual pages. -The supplied -.Ar path -must be a colon (``:'') separated list of directories. -This search path may also be set using the environment variable -.Ev MANPATH . -The subdirectories to be searched, and their search order, -is specified by the ``_subdir'' line in the -.Nm man -configuration file. -.It Fl m -Augment the list of standard directories which -.Nm man -searches for manual pages. -The supplied -.Ar path -must be a colon (``:'') separated list of directories. -These directories will be searched before the standard directories or -the directories specified using the -.Fl M -option or the -.Ev MANPATH -environment variable. -The subdirectories to be searched, and their search order, -is specified by the ``_subdir'' line in the -.Nm man -configuration file. -.It Fl w -List the pathnames of the manual pages which -.Nm man -would display for the specified -.Ar section -and -.Ar name -combination. -.El -.Pp -The optional -.Ar section -argument restricts the directories that -.Nm man -will search. -The -.Nm man -configuration file (see -.Xr man.conf 5 ) -specifies the possible -.Ar section -values that are currently available. -If only a single argument is specified or if the first argument is -not a valid section, -.Nm man -assumes that the argument is the name of a manual page to be displayed. -.Sh ENVIRONMENT -.Bl -tag -width MANPATHX -.It Ev MACHINE -As some manual pages are intended only for specific architectures, -.Nm man -searches any subdirectories, -with the same name as the current architecture, -in every directory which it searches. -Machine specific areas are checked before general areas. -The current machine type may be overridden by setting the environment -variable -.Ev MACHINE -to the name of a specific architecture. -.It Ev MANPATH -The standard search path used by -.Nm man -may be overridden by specifying a path in the -.Ev MANPATH -environment -variable. -The format of the path is a colon (``:'') separated list of directories. -The subdirectories to be searched as well as their search order -is specified by the ``_subdir'' line in the -.Nm man -configuration file. -.It Ev PAGER -Any value of the environment variable -.Ev PAGER -will be used instead of the standard pagination program, -.Xr more 1 . -.El -.Sh FILES -.Bl -tag -width /etc/man.conf -compact -.It Pa /etc/man.conf -default man configuration file. -.El -.Sh SEE ALSO -.Xr apropos 1 , -.Xr whatis 1 , -.Xr whereis 1 , -.Xr man.conf 5 -.Sh BUGS -The on-line manual pages are, by necessity, forgiving toward stupid -display devices, causing a few manual pages to not as nicely formatted -as their typeset counterparts. -.Sh HISTORY -A -.Nm -command appeared in -.At v6 . diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c deleted file mode 100644 index a320e31..0000000 --- a/usr.bin/man/man.c +++ /dev/null @@ -1,712 +0,0 @@ -/* - * Copyright (c) 1987, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1987, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)man.c 8.16 (Berkeley) 4/16/94"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "config.h" -#include "pathnames.h" - -int f_all, f_where; - -static void build_page __P((char *, char **)); -static void cat __P((char *)); -static char *check_pager __P((char *)); -static int cleanup __P((void)); -static void how __P((char *)); -static void jump __P((char **, char *, char *)); -static int manual __P((char *, TAG *, glob_t *)); -static void onsig __P((int)); -static void usage __P((void)); - -int -main(argc, argv) - int argc; - char *argv[]; -{ - extern char *optarg; - extern int optind; - TAG *defp, *defnewp, *section, *sectnewp, *subp; - ENTRY *e_defp, *e_sectp, *e_subp, *ep; - glob_t pg; - size_t len; - int ch, f_cat, f_how, found; - char **ap, *cmd, *machine, *p, *p_add, *p_path, *pager, *slashp; - char *conffile, buf[MAXPATHLEN * 2]; - - f_cat = f_how = 0; - conffile = p_add = p_path = NULL; - while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:w")) != EOF) - switch (ch) { - case 'a': - f_all = 1; - break; - case 'C': - conffile = optarg; - break; - case 'c': - case '-': /* Deprecated. */ - f_cat = 1; - break; - case 'h': - f_how = 1; - break; - case 'm': - p_add = optarg; - break; - case 'M': - case 'P': /* Backward compatibility. */ - p_path = optarg; - break; - /* - * The -f and -k options are backward compatible, - * undocumented ways of calling whatis(1) and apropos(1). - */ - case 'f': - jump(argv, "-f", "whatis"); - /* NOTREACHED */ - case 'k': - jump(argv, "-k", "apropos"); - /* NOTREACHED */ - case 'w': - f_all = f_where = 1; - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - if (!*argv) - usage(); - - if (!f_cat && !f_how && !f_where) - if (!isatty(1)) - f_cat = 1; - else if ((pager = getenv("PAGER")) != NULL) - pager = check_pager(pager); - else - pager = _PATH_PAGER; - - /* Read the configuration file. */ - config(conffile); - - /* Get the machine type. */ - if ((machine = getenv("MACHINE")) == NULL) - machine = MACHINE; - - /* If there's no _default list, create an empty one. */ - if ((defp = getlist("_default")) == NULL) - defp = addlist("_default"); - - /* - * 1: If the user specified a MANPATH variable, or set the -M - * option, we replace the _default list with the user's list, - * appending the entries in the _subdir list and the machine. - */ - if (p_path == NULL) - p_path = getenv("MANPATH"); - if (p_path != NULL) { - while ((e_defp = defp->list.tqh_first) != NULL) { - free(e_defp->s); - TAILQ_REMOVE(&defp->list, e_defp, q); - } - for (p = strtok(p_path, ":"); - p != NULL; p = strtok(NULL, ":")) { - slashp = p[strlen(p) - 1] == '/' ? "" : "/"; - e_subp = (subp = getlist("_subdir")) == NULL ? - NULL : subp->list.tqh_first; - for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) { - (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}", - p, slashp, e_subp->s, machine); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(buf)) == NULL) - err(1, NULL); - TAILQ_INSERT_TAIL(&defp->list, ep, q); - } - } - } - - /* - * 2: If the user did not specify MANPATH, -M or a section, rewrite - * the _default list to include the _subdir list and the machine. - */ - if (argv[1] == NULL) - section = NULL; - else if ((section = getlist(*argv)) != NULL) - ++argv; - if (p_path == NULL && section == NULL) { - defnewp = addlist("_default_new"); - e_defp = - defp->list.tqh_first == NULL ? NULL : defp->list.tqh_first; - for (; e_defp != NULL; e_defp = e_defp->q.tqe_next) { - slashp = - e_defp->s[strlen(e_defp->s) - 1] == '/' ? "" : "/"; - e_subp = (subp = getlist("_subdir")) == NULL ? - NULL : subp->list.tqh_first; - for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) { - (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}", - e_defp->s, slashp, e_subp->s, machine); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(buf)) == NULL) - err(1, NULL); - TAILQ_INSERT_TAIL(&defnewp->list, ep, q); - } - } - defp = getlist("_default"); - while ((e_defp = defp->list.tqh_first) != NULL) { - free(e_defp->s); - TAILQ_REMOVE(&defp->list, e_defp, q); - } - free(defp->s); - TAILQ_REMOVE(&head, defp, q); - defnewp = getlist("_default_new"); - free(defnewp->s); - defnewp->s = "_default"; - defp = defnewp; - } - - /* - * 3: If the user set the -m option, insert the user's list before - * whatever list we have, again appending the _subdir list and - * the machine. - */ - if (p_add != NULL) - for (p = strtok(p_add, ":"); p != NULL; p = strtok(NULL, ":")) { - slashp = p[strlen(p) - 1] == '/' ? "" : "/"; - e_subp = (subp = getlist("_subdir")) == NULL ? - NULL : subp->list.tqh_first; - for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) { - (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}", - p, slashp, e_subp->s, machine); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(buf)) == NULL) - err(1, NULL); - TAILQ_INSERT_HEAD(&defp->list, ep, q); - } - } - - /* - * 4: If none of MANPATH, -M, or -m were specified, and a section was, - * rewrite the section's paths (if they have a trailing slash) to - * append the _subdir list and the machine. This then becomes the - * _default list. - */ - if (p_path == NULL && p_add == NULL && section != NULL) { - sectnewp = addlist("_section_new"); - for (e_sectp = section->list.tqh_first; - e_sectp != NULL; e_sectp = e_sectp->q.tqe_next) { - if (e_sectp->s[strlen(e_sectp->s) - 1] != '/') { - (void)snprintf(buf, sizeof(buf), - "%s{/%s,}", e_sectp->s, machine); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(buf)) == NULL) - err(1, NULL); - TAILQ_INSERT_TAIL(§newp->list, ep, q); - continue; - } - e_subp = (subp = getlist("_subdir")) == NULL ? - NULL : subp->list.tqh_first; - for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) { - (void)snprintf(buf, sizeof(buf), "%s%s{/%s,}", - e_sectp->s, e_subp->s, machine); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(buf)) == NULL) - err(1, NULL); - TAILQ_INSERT_TAIL(§newp->list, ep, q); - } - } - sectnewp->s = section->s; - defp = sectnewp; - TAILQ_REMOVE(&head, section, q); - } - - /* - * 5: Search for the files. Set up an interrupt handler, so the - * temporary files go away. - */ - (void)signal(SIGINT, onsig); - (void)signal(SIGHUP, onsig); - - memset(&pg, 0, sizeof(pg)); - for (found = 0; *argv; ++argv) - if (manual(*argv, defp, &pg)) - found = 1; - - /* 6: If nothing found, we're done. */ - if (!found) { - (void)cleanup(); - exit (1); - } - - /* 7: If it's simple, display it fast. */ - if (f_cat) { - for (ap = pg.gl_pathv; *ap != NULL; ++ap) { - if (**ap == '\0') - continue; - cat(*ap); - } - exit (cleanup()); - } - if (f_how) { - for (ap = pg.gl_pathv; *ap != NULL; ++ap) { - if (**ap == '\0') - continue; - how(*ap); - } - exit(cleanup()); - } - if (f_where) { - for (ap = pg.gl_pathv; *ap != NULL; ++ap) { - if (**ap == '\0') - continue; - (void)printf("%s\n", *ap); - } - exit(cleanup()); - } - - /* - * 8: We display things in a single command; build a list of things - * to display. - */ - for (ap = pg.gl_pathv, len = strlen(pager) + 1; *ap != NULL; ++ap) { - if (**ap == '\0') - continue; - len += strlen(*ap) + 1; - } - if ((cmd = malloc(len)) == NULL) { - warn(NULL); - (void)cleanup(); - exit(1); - } - p = cmd; - len = strlen(pager); - memmove(p, pager, len); - p += len; - *p++ = ' '; - for (ap = pg.gl_pathv; *ap != NULL; ++ap) { - if (**ap == '\0') - continue; - len = strlen(*ap); - memmove(p, *ap, len); - p += len; - *p++ = ' '; - } - *p = '\0'; - - /* Use system(3) in case someone's pager is "pager arg1 arg2". */ - (void)system(cmd); - - exit(cleanup()); -} - -/* - * manual -- - * Search the manuals for the pages. - */ -static int -manual(page, tag, pg) - char *page; - TAG *tag; - glob_t *pg; -{ - ENTRY *ep, *e_sufp, *e_tag; - TAG *missp, *sufp; - int anyfound, cnt, found; - char *p, buf[128]; - - anyfound = 0; - buf[0] = '*'; - - /* For each element in the list... */ - e_tag = tag == NULL ? NULL : tag->list.tqh_first; - for (; e_tag != NULL; e_tag = e_tag->q.tqe_next) { - (void)snprintf(buf, sizeof(buf), "%s/%s.*", e_tag->s, page); - if (glob(buf, - GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT | GLOB_QUOTE, - NULL, pg)) { - warn("globbing"); - (void)cleanup(); - exit(1); - } - if (pg->gl_matchc == 0) - continue; - - /* Find out if it's really a man page. */ - for (cnt = pg->gl_pathc - pg->gl_matchc; - cnt < pg->gl_pathc; ++cnt) { - - /* - * Try the _suffix key words first. - * - * XXX - * Older versions of man.conf didn't have the suffix - * key words, it was assumed that everything was a .0. - * We just test for .0 first, it's fast and probably - * going to hit. - */ - (void)snprintf(buf, sizeof(buf), "*/%s.0", page); - if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) - goto next; - - e_sufp = (sufp = getlist("_suffix")) == NULL ? - NULL : sufp->list.tqh_first; - for (found = 0; - e_sufp != NULL; e_sufp = e_sufp->q.tqe_next) { - (void)snprintf(buf, - sizeof(buf), "*/%s%s", page, e_sufp->s); - if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) { - found = 1; - break; - } - } - if (found) - goto next; - - /* Try the _build key words next. */ - e_sufp = (sufp = getlist("_build")) == NULL ? - NULL : sufp->list.tqh_first; - for (found = 0; - e_sufp != NULL; e_sufp = e_sufp->q.tqe_next) { - for (p = e_sufp->s; - *p != '\0' && !isspace(*p); ++p); - if (*p == '\0') - continue; - *p = '\0'; - (void)snprintf(buf, - sizeof(buf), "*/%s%s", page, e_sufp->s); - if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) { - if (!f_where) - build_page(p + 1, - &pg->gl_pathv[cnt]); - *p = ' '; - found = 1; - break; - } - *p = ' '; - } - if (found) { -next: anyfound = 1; - if (!f_all) { - /* Delete any other matches. */ - while (++cnt< pg->gl_pathc) - pg->gl_pathv[cnt] = ""; - break; - } - continue; - } - - /* It's not a man page, forget about it. */ - pg->gl_pathv[cnt] = ""; - } - - if (anyfound && !f_all) - break; - } - - /* If not found, enter onto the missing list. */ - if (!anyfound) { - if ((missp = getlist("_missing")) == NULL) - missp = addlist("_missing"); - if ((ep = malloc(sizeof(ENTRY))) == NULL || - (ep->s = strdup(page)) == NULL) { - warn(NULL); - (void)cleanup(); - exit(1); - } - TAILQ_INSERT_TAIL(&missp->list, ep, q); - } - return (anyfound); -} - -/* - * build_page -- - * Build a man page for display. - */ -static void -build_page(fmt, pathp) - char *fmt, **pathp; -{ - static int warned; - ENTRY *ep; - TAG *intmpp; - int fd; - char buf[MAXPATHLEN], cmd[MAXPATHLEN], tpath[sizeof(_PATH_TMP)]; - - /* Let the user know this may take awhile. */ - if (!warned) { - warned = 1; - warnx("Formatting manual page..."); - } - - /* Add a remove-when-done list. */ - if ((intmpp = getlist("_intmp")) == NULL) - intmpp = addlist("_intmp"); - - /* Move to the printf(3) format string. */ - for (; *fmt && isspace(*fmt); ++fmt); - - /* - * Get a temporary file and build a version of the file - * to display. Replace the old file name with the new one. - */ - (void)strcpy(tpath, _PATH_TMP); - if ((fd = mkstemp(tpath)) == -1) { - warn("%s", tpath); - (void)cleanup(); - exit(1); - } - (void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath); - (void)snprintf(cmd, sizeof(cmd), buf, *pathp); - (void)system(cmd); - (void)close(fd); - if ((*pathp = strdup(tpath)) == NULL) { - warn(NULL); - (void)cleanup(); - exit(1); - } - - /* Link the built file into the remove-when-done list. */ - if ((ep = malloc(sizeof(ENTRY))) == NULL) { - warn(NULL); - (void)cleanup(); - exit(1); - } - ep->s = *pathp; - TAILQ_INSERT_TAIL(&intmpp->list, ep, q); -} - -/* - * how -- - * display how information - */ -static void -how(fname) - char *fname; -{ - FILE *fp; - - int lcnt, print; - char *p, buf[256]; - - if (!(fp = fopen(fname, "r"))) { - warn("%s", fname); - (void)cleanup(); - exit (1); - } -#define S1 "SYNOPSIS" -#define S2 "S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS" -#define D1 "DESCRIPTION" -#define D2 "D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN" - for (lcnt = print = 0; fgets(buf, sizeof(buf), fp);) { - if (!strncmp(buf, S1, sizeof(S1) - 1) || - !strncmp(buf, S2, sizeof(S2) - 1)) { - print = 1; - continue; - } else if (!strncmp(buf, D1, sizeof(D1) - 1) || - !strncmp(buf, D2, sizeof(D2) - 1)) - return; - if (!print) - continue; - if (*buf == '\n') - ++lcnt; - else { - for(; lcnt; --lcnt) - (void)putchar('\n'); - for (p = buf; isspace(*p); ++p); - (void)fputs(p, stdout); - } - } - (void)fclose(fp); -} - -/* - * cat -- - * cat out the file - */ -static void -cat(fname) - char *fname; -{ - int fd, n; - char buf[2048]; - - if ((fd = open(fname, O_RDONLY, 0)) < 0) { - warn("%s", fname); - (void)cleanup(); - exit(1); - } - while ((n = read(fd, buf, sizeof(buf))) > 0) - if (write(STDOUT_FILENO, buf, n) != n) { - warn("write"); - (void)cleanup(); - exit (1); - } - if (n == -1) { - warn("read"); - (void)cleanup(); - exit(1); - } - (void)close(fd); -} - -/* - * check_pager -- - * check the user supplied page information - */ -static char * -check_pager(name) - char *name; -{ - char *p, *save; - - /* - * if the user uses "more", we make it "more -s"; watch out for - * PAGER = "mypager /usr/ucb/more" - */ - for (p = name; *p && !isspace(*p); ++p); - for (; p > name && *p != '/'; --p); - if (p != name) - ++p; - - /* make sure it's "more", not "morex" */ - if (!strncmp(p, "more", 4) && (!p[4] || isspace(p[4]))){ - save = name; - /* allocate space to add the "-s" */ - if (!(name = - malloc((u_int)(strlen(save) + sizeof("-s") + 1)))) - err(1, NULL); - (void)sprintf(name, "%s %s", save, "-s"); - } - return(name); -} - -/* - * jump -- - * strip out flag argument and jump - */ -static void -jump(argv, flag, name) - char **argv, *flag, *name; -{ - char **arg; - - argv[0] = name; - for (arg = argv + 1; *arg; ++arg) - if (!strcmp(*arg, flag)) - break; - for (; *arg; ++arg) - arg[0] = arg[1]; - execvp(name, argv); - (void)fprintf(stderr, "%s: Command not found.\n", name); - exit(1); -} - -/* - * onsig -- - * If signaled, delete the temporary files. - */ -static void -onsig(signo) - int signo; -{ - (void)cleanup(); - - (void)signal(signo, SIG_DFL); - (void)kill(getpid(), signo); - - /* NOTREACHED */ - exit (1); -} - -/* - * cleanup -- - * Clean up temporary files, show any error messages. - */ -static int -cleanup() -{ - TAG *intmpp, *missp; - ENTRY *ep; - int rval; - - rval = 0; - ep = (missp = getlist("_missing")) == NULL ? - NULL : missp->list.tqh_first; - if (ep != NULL) - for (; ep != NULL; ep = ep->q.tqe_next) { - warnx("no entry for %s in the manual.", ep->s); - rval = 1; - } - - ep = (intmpp = getlist("_intmp")) == NULL ? - NULL : intmpp->list.tqh_first; - for (; ep != NULL; ep = ep->q.tqe_next) - (void)unlink(ep->s); - return (rval); -} - -/* - * usage -- - * print usage message and die - */ -static void -usage() -{ - (void)fprintf(stderr, - "usage: man [-achw] [-C file] [-M path] [-m path] [section] title ...\n"); - exit(1); -} diff --git a/usr.bin/man/man.conf b/usr.bin/man/man.conf deleted file mode 100644 index 9faad52..0000000 --- a/usr.bin/man/man.conf +++ /dev/null @@ -1,46 +0,0 @@ -# Sheer, raging paranoia... -_version BSD.2 - -# The whatis/apropos database. -_whatdb /usr/share/man/whatis.db - -# Subdirectories for paths ending in '/', IN SEARCH ORDER. -_subdir cat{1,8,6,2,3,4,5,7,3f} - -# Files typed by suffix and their commands. -# Note the order, .Z must come after .[1-9].Z, or it will match first. -_suffix .0 -_build .[1-9] /usr/bin/nroff -man %s -_build .[1-9].Z /usr/bin/zcat %s | /usr/bin/nroff -man -_build .Z /usr/bin/zcat %s -_build .0.Z /usr/bin/zcat %s -_build .gz /usr/contrib/bin/gunzip %s -_build .z /usr/contrib/bin/gunzip %s -_build .nr /usr/bin/nroff -man %s - -# Sections and their directories. -# All paths ending in '/' are the equivalent of entries specifying that -# directory with all of the subdirectories listed for the keyword _subdir. - -# default -_default /usr/{share,X11,contrib,local}/{man,man/old}/ - -# Other sections that represent complete man subdirectories. -X11 /usr/X11R4/man/ -X11R4 /usr/X11R4/man/ -contrib /usr/contrib/man/ -local /usr/local/man/ -new /usr/contrib/man/ -old /usr/share/man/old/ - -# Specific section/directory combinations. -1 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat1 -2 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat2 -3 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat3 -3F /usr/share/man/cat3f -3f /usr/share/man/cat3f -4 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat4 -5 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat5 -6 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat6 -7 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat7 -8 /usr/{share,X11R4,contrib,local}/{man/,man/old/}cat8 diff --git a/usr.bin/man/man.conf.5 b/usr.bin/man/man.conf.5 deleted file mode 100644 index 353a302..0000000 --- a/usr.bin/man/man.conf.5 +++ /dev/null @@ -1,195 +0,0 @@ -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)man.conf.5 8.5 (Berkeley) 1/2/94 -.\" -.Dd January 2, 1994 -.Dt MAN.CONF 5 -.Os -.Sh NAME -.Nm man.conf -.Nd configuration file for -.Xr man 1 -.Sh DESCRIPTION -The -.Xr man 1 , -.Xr apropos 1 , -and -.Xr whatis 1 -commands -search for manual pages or their database files as specified by the -.Nm man.conf -file. -Manual pages are normally expected to be preformatted (see -.Xr nroff 1 ) -and named with a trailing ``.0''. -.Pp -The -.Nm man.conf -file contains two types of lines. -.Pp -The first type of line is a ``section'' line, which contains a -section name followed by one or more directory paths. -The directory paths may contain the normal shell globbing characters, -including curly braces (``{}''); to escape a shell globbing character, -precede it with a backslash (``\e''). -Lines in this format specify that manual pages for the section -may be found in the following directories. -.Pp -Directories named with a trailing slash character (``/'') are expected -to contain subdirectories of manual pages, (see the keyword ``_subdir'' -below) instead of manual pages. -These subdirectories are searched instead of the directory. -.Pp -Before searching any directory for a manual page, the -.Xr man 1 -command always searches the subdirectory with the same name -as the current machine type, if it exists. -No specification of these subdirectories is necessary in the -.Nm man.conf -file. -.Pp -Section names are unrestricted except for the reserved words specified -below; in general, you should avoid anything with a leading underscore -(``_'') to avoid future incompatibilities. -.Pp -The section named ``_default'' is the list of directories that will -be searched if no section is specified by the user. -.Pp -The second type of line is preceded with a ``keyword''. -The possible keywords and their meanings are as follows: -.Pp -.Bl -tag -width "_version" -.It _build -Man file names, regardless of their format, are expected to end in -a ``.*'' pattern, i.e. a ``.'' followed by some suffix. -The first field of a _build line lists a suffix which indicates -files which need to be reformated or manipulated in some way before -being displayed to the user. -The suffix may contain the normal shell globbing characters (NOT -including curly braces (``{}'')). -The rest of the line must be a shell command line, the standard -output of which is the manual page in a format which may be directly -displayed to the user. -Any occurrences of the string ``%s'' in the shell command line will -be replaced by the name of the file which is being reformatted. -.It _subdir -The list (in search order) of subdirectories which will be searched in -any directory named with a trailing slash (``/'') character. -This list is also used when a path is specified to the -.Xr man 1 -utility by the user, using the -.Ev MANPATH -environment variable or the -.Fl M -and -.Fl m -options. -.It _suffix -Man file names, regardless of their format are expected to end in -a ``.*'' pattern, i.e. a ``.'' followed by some suffix. -Each field of a _suffix line is a suffix which indicates -files which do not need to be reformatted or manipulated -in any way, but which may be directly displayed to the user. -Each suffix may contain the normal shell globbing characters (NOT -including curly braces (``{}'')). -.It _version -The version of the configuration file. -.It _whatdb -The full pathname (not just a directory path) for a database to be used -by the -.Xr apropos 1 -and -.Xr whatis 1 -commands. -.El -.Pp -Multiple specifications for all types of lines are cumulative and the -entries are used in the order listed in the file; multiple entries may -be listed per line, as well. -.Pp -Empty lines or lines whose first non-whitespace character is a hash -mark (``#'') are ignored. -.Sh EXAMPLES -Given the following -.Nm man.conf -file: -.Bd -literal -offset indent -_version BSD.2 -_subdir cat[123] -_suffix .0 -_build .[1-9] nroff -man %s -_build .tbl tbl %s | nroff -man -_default /usr/share/man/ -sect3 /usr/share/man/{old/,}cat3 -.Ed -.Pp -By default, the command -.Dq Li man mktemp -will search for -``mktemp.'' and ``mktemp.tbl'' -in the directories -.Dq Pa /usr/share/man/cat1 , -.Dq Pa /usr/share/man/cat2 , -and -.Dq Pa /usr/share/man/cat3 . -If on a machine of type ``vax'', the subdirectory ``vax'' in each -directory would be searched as well, before the directory was -searched. -.Pp -If ``mktemp.tbl'' was found first, the command -.Dq Li tbl | nroff -man -would be run to build a man page for display to the user. -.Pp -The command -.Dq Li man sect3 mktemp -would search the directories -.Dq Pa /usr/share/man/old/cat3 -and -.Dq Pa /usr/share/man/cat3 , -in that order, for -the mktemp manual page. -If a subdirectory with the same name as the current machine type -existed in any of them, it would be searched as well, before each -of them were searched. -.Sh FILES -.Bl -tag -width /etc/man.conf -compact -.It Pa /etc/man.conf -Standard manual directory search path. -.El -.Sh SEE ALSO -.Xr apropos 1 , -.Xr machine 1 , -.Xr man 1 , -.Xr whatis 1 , -.Xr whereis 1 , -.Xr fnmatch 3 , -.Xr glob 3 diff --git a/usr.bin/man/pathnames.h b/usr.bin/man/pathnames.h deleted file mode 100644 index 17284fe..0000000 --- a/usr.bin/man/pathnames.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pathnames.h 8.3 (Berkeley) 1/2/94 - */ - -#define _PATH_MANCONF "/etc/man.conf" -#define _PATH_PAGER "/usr/bin/more -s" -#define _PATH_TMP "/tmp/man.XXXXXX" -#define _PATH_WHATIS "whatis.db" diff --git a/usr.bin/mklocale/Japanese b/usr.bin/mklocale/Japanese deleted file mode 100644 index 55eb155..0000000 --- a/usr.bin/mklocale/Japanese +++ /dev/null @@ -1,158 +0,0 @@ -# @(#)Japanese 8.1 (Berkeley) 6/6/93 - -/* - * Japanese LOCALE_CTYPE definitions using EUC of JIS character sets - */ - -ENCODING "EUC" - -/* JIS JIS JIS */ -/* X201 X208 X201 */ -/* 00-7f 84-fe */ - -VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 - -/* - * Code Set 1 - */ -ALPHA 'A' - 'Z' 'a' - 'z' -CONTROL 0x00 - 0x1f 0x7f -DIGIT '0' - '9' -GRAPH 0x21 - 0x7e -LOWER 'a' - 'z' -PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e -SPACE 0x09 - 0x0d 0x20 -UPPER 'A' - 'Z' -XDIGIT 'a' - 'f' 'A' - 'F' -BLANK ' ' '\t' -PRINT 0x20 - 0x7e - -MAPLOWER < 'A' - 'Z' : 'a' > -MAPLOWER < 'a' - 'z' : 'a' > -MAPUPPER < 'A' - 'Z' : 'A' > -MAPUPPER < 'a' - 'z' : 'A' > -TODIGIT < '0' - '9' : 0 > -TODIGIT < 'A' - 'F' : 10 > -TODIGIT < 'a' - 'f' : 10 > - -/* - * Code Set 2 - */ - -SPACE 0xa1a1 -PHONOGRAM 0xa1bc -SPECIAL 0xa1a2 - 0xa1fe -PUNCT 0xa1a2 - 0xa1f8 /* A few too many in here... */ - -SPECIAL 0xa2a1 - 0xa2ae 0xa2ba - 0xa2c1 0xa2ca - 0xa2d0 0xa2dc - 0xa2ea -SPECIAL 0xa2f2 - 0xa2f9 0xa2fe - -DIGIT 0xa3b0 - 0xa3b9 -UPPER 0xa3c1 - 0xa3da /* Romaji */ -LOWER 0xa3e1 - 0xa3fa /* Romaji */ -MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > /* English */ -MAPLOWER < 0xa3e1 - 0xa3fa : 0xa3e1 > /* English */ -MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 > -MAPUPPER < 0xa3e1 - 0xa3fa : 0xa3c1 > - -XDIGIT 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6 - -TODIGIT < 0xa3b0 - 0xa3b9 : 0 > -TODIGIT < 0xa3c1 - 0xa3c6 : 10 > -TODIGIT < 0xa3e1 - 0xa3e6 : 10 > - -PHONOGRAM 0xa4a1 - 0xa4f3 -PHONOGRAM 0xa5a1 - 0xa5f6 - -UPPER 0xa6a1 - 0xa6b8 /* Greek */ -LOWER 0xa6c1 - 0xa6d8 /* Greek */ -MAPLOWER < 0xa6a1 - 0xa6b8 : 0xa6c1 > -MAPLOWER < 0xa6c1 - 0xa6d8 : 0xa6c1 > -MAPUPPER < 0xa6a1 - 0xa6b8 : 0xa6a1 > -MAPUPPER < 0xa6c1 - 0xa6d8 : 0xa6a1 > - -UPPER 0xa7a1 - 0xa7c1 /* Cyrillic */ -LOWER 0xa7d1 - 0xa7f1 /* Cyrillic */ -MAPLOWER < 0xa7a1 - 0xa7c1 : 0xa7d1 > -MAPLOWER < 0xa7d1 - 0xa7f1 : 0xa7d1 > -MAPUPPER < 0xa7a1 - 0xa7c1 : 0xa7a1 > -MAPUPPER < 0xa7d1 - 0xa7f1 : 0xa7a1 > - -SPECIAL 0xa8a1 - 0xa8c0 - -IDEOGRAM 0xb0a1 - 0xb0fe -IDEOGRAM 0xb1a1 - 0xb1fe -IDEOGRAM 0xb2a1 - 0xb2fe -IDEOGRAM 0xb3a1 - 0xb3fe -IDEOGRAM 0xb4a1 - 0xb4fe -IDEOGRAM 0xb5a1 - 0xb5fe -IDEOGRAM 0xb6a1 - 0xb6fe -IDEOGRAM 0xb7a1 - 0xb7fe -IDEOGRAM 0xb8a1 - 0xb8fe -IDEOGRAM 0xb9a1 - 0xb9fe -IDEOGRAM 0xbaa1 - 0xbafe -IDEOGRAM 0xbba1 - 0xbbfe -IDEOGRAM 0xbca1 - 0xbcfe -IDEOGRAM 0xbda1 - 0xbdfe -IDEOGRAM 0xbea1 - 0xbefe -IDEOGRAM 0xbfa1 - 0xbffe -IDEOGRAM 0xc0a1 - 0xc0fe -IDEOGRAM 0xc1a1 - 0xc1fe -IDEOGRAM 0xc2a1 - 0xc2fe -IDEOGRAM 0xc3a1 - 0xc3fe -IDEOGRAM 0xc4a1 - 0xc4fe -IDEOGRAM 0xc5a1 - 0xc5fe -IDEOGRAM 0xc6a1 - 0xc6fe -IDEOGRAM 0xc7a1 - 0xc7fe -IDEOGRAM 0xc8a1 - 0xc8fe -IDEOGRAM 0xc9a1 - 0xc9fe -IDEOGRAM 0xcaa1 - 0xcafe -IDEOGRAM 0xcba1 - 0xcbfe -IDEOGRAM 0xcca1 - 0xccfe -IDEOGRAM 0xcda1 - 0xcdfe -IDEOGRAM 0xcea1 - 0xcefe -IDEOGRAM 0xcfa1 - 0xcfd3 -IDEOGRAM 0xd0a1 - 0xd0fe -IDEOGRAM 0xd1a1 - 0xd1fe -IDEOGRAM 0xd2a1 - 0xd2fe -IDEOGRAM 0xd3a1 - 0xd3fe -IDEOGRAM 0xd4a1 - 0xd4fe -IDEOGRAM 0xd5a1 - 0xd5fe -IDEOGRAM 0xd6a1 - 0xd6fe -IDEOGRAM 0xd7a1 - 0xd7fe -IDEOGRAM 0xd8a1 - 0xd8fe -IDEOGRAM 0xd9a1 - 0xd9fe -IDEOGRAM 0xdaa1 - 0xdafe -IDEOGRAM 0xdba1 - 0xdbfe -IDEOGRAM 0xdca1 - 0xdcfe -IDEOGRAM 0xdda1 - 0xddfe -IDEOGRAM 0xdea1 - 0xdefe -IDEOGRAM 0xdfa1 - 0xdffe -IDEOGRAM 0xe0a1 - 0xe0fe -IDEOGRAM 0xe1a1 - 0xe1fe -IDEOGRAM 0xe2a1 - 0xe2fe -IDEOGRAM 0xe3a1 - 0xe3fe -IDEOGRAM 0xe4a1 - 0xe4fe -IDEOGRAM 0xe5a1 - 0xe5fe -IDEOGRAM 0xe6a1 - 0xe6fe -IDEOGRAM 0xe7a1 - 0xe7fe -IDEOGRAM 0xe8a1 - 0xe8fe -IDEOGRAM 0xe9a1 - 0xe9fe -IDEOGRAM 0xeaa1 - 0xeafe -IDEOGRAM 0xeba1 - 0xebfe -IDEOGRAM 0xeca1 - 0xecfe -IDEOGRAM 0xeda1 - 0xedfe -IDEOGRAM 0xeea1 - 0xeefe -IDEOGRAM 0xefa1 - 0xeffe -IDEOGRAM 0xf0a1 - 0xf0fe -IDEOGRAM 0xf1a1 - 0xf1fe -IDEOGRAM 0xf2a1 - 0xf2fe -IDEOGRAM 0xf3a1 - 0xf3fe -IDEOGRAM 0xf4a1 - 0xf4a4 - -/* - * This is for Code Set 3, half-width kana - */ -SPECIAL 0xa1 - 0xdf -PHONOGRAM 0xa1 - 0xdf -CONTROL 0x84 - 0x97 0x9b - 0x9f 0xe0 - 0xfe diff --git a/usr.bin/ncftp/Makefile.ORIG b/usr.bin/ncftp/Makefile.ORIG deleted file mode 100644 index 7fe52b8..0000000 --- a/usr.bin/ncftp/Makefile.ORIG +++ /dev/null @@ -1,287 +0,0 @@ -# Makefile for ncftp -# -# Major sections delimited by a dash lines. If several lines set the same -# make variable, you can choose between the commented #samples, or just -# type what you want manually. -#-------------------------------------------------------------------------- - - -# System dependent definitions. See the README, part B. -#-------------------------------------------------------------------------- -SDEFS = - - -# Program definitions. See the README, part C. -#-------------------------------------------------------------------------- -PDEFS = -#PDEFS = -DGETLINE -#PDEFS = -DREADLINE -DCURSES -#PDEFS = -DSOCKS -#PDEFS = -DPASSIVEMODE -#PDEFS = -DDEBUG -DDB_ERRS - - -# Choose your compiler and flags below. Make sure you use an ANSI compiler -# that handles new style function declarations and prototypes (gcc should). -#-------------------------------------------------------------------------- -CC = cc -#CC = gcc - -#CFLAGS = $(TERM_INC) -O -CFLAGS = $(TERM_INC) -O2 -#CFLAGS = $(TERM_INC) -g - -LFLAGS = -s -#LFLAGS = - - -# Additional libraries and/or object files. -# -# For each library, add -lLIBNAME to the LIBS line below, for a library -# named libLIBNAME.a. -# -# For each object file, just add the pathname of the object file. -# -# Some may need any of -lsocket, -lnet, -linet, -lintl, or -lnsl. -# You'll need -lcurses or -ltermcap if CURSES is defined. -# You'll need -lreadline AND either -lcurses or -ltermcap if you -# want to use the GNU Readline library. -# You'll need -lgetline (compile it as a library) if you want to use -# getline. -# If your system is running Yellow Pages, you'll need to add the library -# that has the YP/NIS version of getpwuid() in it (Important!) -# You'll need to know where the Rconnect.o object file is if you want -# to use Socks. -#-------------------------------------------------------------------------- -LIBS = -#LIBS = -ldbmalloc -#LIBS = -lgetline -#LIBS = -lreadline -lcurses -#LIBS = ../lib/Rconnect.o -#LIBS = -lnet -lnsl -lsocket -lcurses -#LIBS = -lcurses -ltermcap - -# If the libraries are in a non-standard directory, or you if want to use -# getline or readline and they aren't installed system-wide, add the -# extra directories to look in here, using -L's. -#-------------------------------------------------------------------------- -LIBDIRS = -#LIBDIRS = -L../getline -#LIBDIRS = -L../readline - -# To make term sources define this to your term directory -TERM_INC = -TERM_LIB = -#TERM_INC = -include /usr/local/include/termnet.h -#TERM_LIB = -ltermnet - -# Additional headers. -# -# If you defined READLINE or GETLINE, you have to tell where it's header -# file can be found. -# -# For READLINE, provide a path which would find , -# so you would put the parent directory of the readline directory below. -# If you had '/usr/local/readline/readline.h' you would use -# -I/usr/local. -# -# For GETLINE, a little different. Just supply a path that would find -# . If you had '/usr/local/getline/getline.h' you would use -# -I/usr/local/getline. -#-------------------------------------------------------------------------- -HDRDIRS = -#HDRDIRS = -I../getline -#HDRDIRS = -I.. - - -# If you want to 'make install,' edit these variables, otherwise don't -# worry about it. -# To install MAN style pages, set MANDIR to the proper location. -# To install CATMAN style pages, set CATMANDIR, NROFF, and PACK to the proper -# locations. -# To inhibit the installation of either, unset MANDIR/CATMANDIR. -#-------------------------------------------------------------------------- -#BINDIR = /usr/lbin -BINDIR = /usr/local/bin -MANDIR = /usr/man/man1 -#MANDIR = -#CATMANDIR = /usr/catman/LOCAL/g1 -CATMANDIR = -NROFF = /usr/ucb/nroff -PACK = pack -TEST = test -RM = rm -f -CP = cp -CAT = cat - - -#************************************************ -#*** SHOULD NOT NEED TO EDIT BELOW THIS POINT *** -#************************************************ - -DEFS = $(PDEFS) $(SDEFS) -MK = $(CC) $(CFLAGS) $(DEFS) $(HDRDIRS) $(LFLAGS) $(LIBDIRS) $(LIBS) - -SRCS = cmds.c cmdtab.c ftp.c ftprc.c getpass.c glob.c main.c open.c set.c \ -tips.c util.c - -HEADERS = cmds.h copyright.h defaults.h ftp.h ftprc.h getpass.h glob.h \ -main.h open.h set.h sys.h util.h - -OBJS = cmds.o cmdtab.o ftp.o ftprc.o getpass.o glob.o main.o open.o set.o \ -tips.o util.o - -NAME = ncftp -MAN = ncftp.1 -CATMAN = ncftp.z -ALL = $(SRCS) $(HEADERS) patchlevel.h Blurb README Makefile $(MAN) \ -v2_Note - -C_COMPILE = $(CC) $(CFLAGS) $(DEFS) $(HDRDIRS) -C_COMPILE2 = $(CC) $(CFLAGS) $(DEFS) -DMK='"$(MK)"' $(HDRDIRS) - -all: $(NAME) done - -$(NAME): $(OBJS) - $(CC) $(LFLAGS) $(LIBDIRS) $(OBJS) -o $(NAME) $(LIBS) $(TERM_LIB) - -install: $(NAME) - if $(TEST) -f $(BINDIR)/term ; then \ - $(CP) $(BINDIR)/term $(BINDIR)/$(NAME) ; \ - $(CAT) $(NAME) > $(BINDIR)/$(NAME) ; \ - else \ - $(CP) $(NAME) $(BINDIR)/$(NAME) ; \ - fi - @if $(TEST) -n '$(MANDIR)'; then \ - $(MAKE) install_man ; else true ; fi - @if $(TEST) -n '$(CATMANDIR)'; then \ - $(MAKE) install_catman ; else true ; fi - -install_man: $(MAN) - $(CP) $(MAN) $(MANDIR)/$(MAN) - - -install_catman: $(CATMAN) - $(CP) $(CATMAN) $(CATMANDIR)/$(CATMAN) - -uninstall: - $(RM) $(BINDIR)/$(NAME) - $(RM) $(MANDIR)/$(MAN) - $(RM) $(CATMANDIR)/$(CATMAN) - -$(CATMAN): $(MAN) - $(RM) tmp - $(NROFF) -man -Tlp $(MAN) > tmp - $(PACK) -f tmp - mv tmp.z $(CATMAN) - -cmds.o: - $(C_COMPILE2) cmds.c -c - -.c.o: - $(C_COMPILE) -c $< - -done: $(NAME) - -@ls -l $(NAME) - -@echo 'Done.' - -clean: - rm -f $(OBJS) $(NAME) - -# Dependencies: -cmds.o: cmds.c -cmds.o: sys.h -cmds.o: util.h -cmds.o: cmds.h -cmds.o: main.h -cmds.o: ftp.h -cmds.o: ftprc.h -cmds.o: getpass.h -cmds.o: glob.h -cmds.o: open.h -cmds.o: set.h -cmds.o: defaults.h -cmds.o: copyright.h -cmdtab.o: cmdtab.c -cmdtab.o: sys.h -cmdtab.o: util.h -cmdtab.o: cmds.h -cmdtab.o: main.h -cmdtab.o: ftp.h -cmdtab.o: ftprc.h -cmdtab.o: glob.h -cmdtab.o: open.h -cmdtab.o: set.h -cmdtab.o: copyright.h -ftp.o: ftp.c -ftp.o: sys.h -ftp.o: util.h -ftp.o: ftp.h -ftp.o: cmds.h -ftp.o: main.h -ftp.o: ftprc.h -ftp.o: getpass.h -ftp.o: defaults.h -ftp.o: copyright.h -ftprc.o: ftprc.c -ftprc.o: sys.h -ftprc.o: util.h -ftprc.o: ftprc.h -ftprc.o: main.h -ftprc.o: cmds.h -ftprc.o: set.h -ftprc.o: defaults.h -ftprc.o: copyright.h -getpass.o: getpass.c -getpass.o: sys.h -getpass.o: util.h -getpass.o: cmds.h -getpass.o: getpass.h -getpass.o: copyright.h -glob.o: glob.c -glob.o: sys.h -glob.o: util.h -glob.o: glob.h -glob.o: cmds.h -glob.o: copyright.h -main.o: main.c -main.o: sys.h -main.o: util.h -main.o: cmds.h -main.o: main.h -main.o: ftp.h -main.o: ftprc.h -main.o: open.h -main.o: set.h -main.o: defaults.h -main.o: copyright.h -open.o: open.c -open.o: sys.h -open.o: util.h -open.o: open.h -open.o: cmds.h -open.o: ftp.h -open.o: ftprc.h -open.o: main.h -open.o: defaults.h -open.o: copyright.h -set.o: set.c -set.o: sys.h -set.o: util.h -set.o: cmds.h -set.o: main.h -set.o: set.h -set.o: defaults.h -set.o: copyright.h -tips.o: tips.c -tips.o: sys.h -tips.o: util.h -util.o: util.c -util.o: sys.h -util.o: util.h -util.o: cmds.h -util.o: main.h -util.o: ftp.h -util.o: ftprc.h -util.o: defaults.h -util.o: copyright.h diff --git a/usr.bin/ncftp/v2_Note b/usr.bin/ncftp/v2_Note deleted file mode 100644 index 6900bf2..0000000 --- a/usr.bin/ncftp/v2_Note +++ /dev/null @@ -1,35 +0,0 @@ -Versions numbered between 1.5.0 and 1.9.9 are interim releases. No major -features are planned for these; only tweaks and fixes. - -Version 2.0 is much cooler, but I haven't had time to work on it. If -you send me email, I _will_ read it, but it may take me awhile to get to it, -and I may not answer. Please don't be offended. I really regret having -to release code that is such a mess. I should have wrote the code from -scratch, rather than built it upon the original BSD code (which is a mess -itself!). - -I apologize in advance for bugs I fixed in 2.0 but forgot to re-fix -in these interim releases (I think I got'em all, though). - -Here is a list of things that are in the 2.0 code but not this version: - -* Easy-to-read, better organized, commented code. -* Using my own "style guide," so source is coded uniformly. -* Unlimited global macros. These are really nice! They take arguments, - so you can make mini-scripts. The macros can be typed as if they - were commands; no more $macroname crap. -* No-longer using .netrc and it's format. This was necessary for the - global macros anyway, and it allowed me to add some other features, - like host aliases. Old .netrc's won't work. Sorry! -* Improved command line parser, that lets any command use > and |, so - it behaves like a real shell command line (almost). -* Improved 'redir' that works automatically, can reformat listings with - different ls flags, all without refetching it over the network. It - will also facilitate remote globbing... AND remote filename completion! -* Many little things I can't begin to list. - -Keep that in mind if you want to make a feature enhancement. I'm telling -you this now so you don't spend your time programming something that is -already done for the 2.0 release. Also note that patches would -have to be re-coded for 2.0. (The gist is that you should wait until -2.0 is done before doing anything major). diff --git a/usr.bin/passwd/kpasswd_proto.h b/usr.bin/passwd/kpasswd_proto.h deleted file mode 100644 index 465d4c7..0000000 --- a/usr.bin/passwd/kpasswd_proto.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)kpasswd_proto.h 8.1 (Berkeley) 6/6/93 - */ - -/* - * kpasswd_proto - * - * definitions for the kpasswd "protocol" - * (We hope this to be temporary until a real admin protocol is worked out.) - */ - -struct kpasswd_data { - des_cblock random_key; - char secure_msg[_PASSWORD_LEN]; -}; - -struct update_data { - char pw[_PASSWORD_LEN]; - char secure_msg[_PASSWORD_LEN]; -}; -#define SERVICE "kpasswd" -#define SECURE_STRING \ - "Kerberos password update program -- 12/9/88 UC Berkeley" diff --git a/usr.bin/passwd/krb_passwd.c b/usr.bin/passwd/krb_passwd.c deleted file mode 100644 index d4a0f15..0000000 --- a/usr.bin/passwd/krb_passwd.c +++ /dev/null @@ -1,319 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)krb_passwd.c 8.3 (Berkeley) 4/2/94"; -#endif /* not lint */ - -#ifdef KERBEROS - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kpasswd_proto.h" - -#include "extern.h" - -#define PROTO "tcp" - -static void send_update __P((int, char *, char *)); -static void recv_ack __P((int)); -static void cleanup __P((void)); -static void finish __P((void)); - -static struct timeval timeout = { CLIENT_KRB_TIMEOUT, 0 }; -static struct kpasswd_data proto_data; -static des_cblock okey; -static Key_schedule osched; -static KTEXT_ST ticket; -static Key_schedule random_schedule; -static long authopts; -static char realm[REALM_SZ], krbhst[MAX_HSTNM]; -static int sock; - -int -krb_passwd() -{ - struct servent *se; - struct hostent *host; - struct sockaddr_in sin; - CREDENTIALS cred; - fd_set readfds; - int rval; - char pass[_PASSWORD_LEN], password[_PASSWORD_LEN]; - static void finish(); - - static struct rlimit rl = { 0, 0 }; - - (void)signal(SIGHUP, SIG_IGN); - (void)signal(SIGINT, SIG_IGN); - (void)signal(SIGTSTP, SIG_IGN); - - if (setrlimit(RLIMIT_CORE, &rl) < 0) { - warn("setrlimit"); - return (1); - } - - if ((se = getservbyname(SERVICE, PROTO)) == NULL) { - warnx("couldn't find entry for service %s/%s", - SERVICE, PROTO); - return (1); - } - - if ((rval = krb_get_lrealm(realm,1)) != KSUCCESS) { - warnx("couldn't get local Kerberos realm: %s", - krb_err_txt[rval]); - return (1); - } - - if ((rval = krb_get_krbhst(krbhst, realm, 1)) != KSUCCESS) { - warnx("couldn't get Kerberos host: %s", - krb_err_txt[rval]); - return (1); - } - - if ((host = gethostbyname(krbhst)) == NULL) { - warnx("couldn't get host entry for krb host %s", - krbhst); - return (1); - } - - sin.sin_family = host->h_addrtype; - memmove((char *) &sin.sin_addr, host->h_addr, host->h_length); - sin.sin_port = se->s_port; - - if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - warn("socket"); - return (1); - } - - if (connect(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) { - warn("connect"); - (void)close(sock); - return (1); - } - - rval = krb_sendauth( - authopts, /* NOT mutual */ - sock, - &ticket, /* (filled in) */ - SERVICE, - krbhst, /* instance (krbhst) */ - realm, /* dest realm */ - (u_long) getpid(), /* checksum */ - NULL, /* msg data */ - NULL, /* credentials */ - NULL, /* schedule */ - NULL, /* local addr */ - NULL, /* foreign addr */ - "KPWDV0.1" - ); - - if (rval != KSUCCESS) { - warnx("Kerberos sendauth error: %s", krb_err_txt[rval]); - return (1); - } - - krb_get_cred("krbtgt", realm, realm, &cred); - - (void)printf("Changing Kerberos password for %s.%s@%s.\n", - cred.pname, cred.pinst, realm); - - if (des_read_pw_string(pass, - sizeof(pass)-1, "Old Kerberos password:", 0)) { - warnx("error reading old Kerberos password"); - return (1); - } - - (void)des_string_to_key(pass, okey); - (void)des_key_sched(okey, osched); - (void)des_set_key(okey, osched); - - /* wait on the verification string */ - - FD_ZERO(&readfds); - FD_SET(sock, &readfds); - - rval = - select(sock + 1, &readfds, (fd_set *) 0, (fd_set *) 0, &timeout); - - if ((rval < 1) || !FD_ISSET(sock, &readfds)) { - if(rval == 0) { - warnx("timed out (aborted)"); - cleanup(); - return (1); - } - warnx("select failed (aborted)"); - cleanup(); - return (1); - } - - /* read verification string */ - - if (des_read(sock, &proto_data, sizeof(proto_data)) != - sizeof(proto_data)) { - warnx("couldn't read verification string (aborted)"); - cleanup(); - return (1); - } - - (void)signal(SIGHUP, finish); - (void)signal(SIGINT, finish); - - if (strcmp(SECURE_STRING, proto_data.secure_msg) != 0) { - cleanup(); - /* don't complain loud if user just hit return */ - if (pass == NULL || (!*pass)) - return (0); - (void)fprintf(stderr, "Sorry\n"); - return (1); - } - - (void)des_key_sched(proto_data.random_key, random_schedule); - (void)des_set_key(proto_data.random_key, random_schedule); - (void)memset(pass, 0, sizeof(pass)); - - if (des_read_pw_string(pass, - sizeof(pass)-1, "New Kerberos password:", 0)) { - warnx("error reading new Kerberos password (aborted)"); - cleanup(); - return (1); - } - - if (des_read_pw_string(password, - sizeof(password)-1, "Retype new Kerberos password:", 0)) { - warnx("error reading new Kerberos password (aborted)"); - cleanup(); - return (1); - } - - if (strcmp(password, pass) != 0) { - warnx("password mismatch (aborted)"); - cleanup(); - return (1); - } - - if (strlen(pass) == 0) - (void)printf("using NULL password\n"); - - send_update(sock, password, SECURE_STRING); - - /* wait for ACK */ - - FD_ZERO(&readfds); - FD_SET(sock, &readfds); - - rval = - select(sock + 1, &readfds, (fd_set *) 0, (fd_set *) 0, &timeout); - if ((rval < 1) || !FD_ISSET(sock, &readfds)) { - if(rval == 0) { - warnx("timed out reading ACK (aborted)"); - cleanup(); - exit(1); - } - warnx("select failed (aborted)"); - cleanup(); - exit(1); - } - recv_ack(sock); - cleanup(); - return (0); -} - -static void -send_update(dest, pwd, str) - int dest; - char *pwd, *str; -{ - static struct update_data ud; - - (void)strncpy(ud.secure_msg, str, _PASSWORD_LEN); - (void)strncpy(ud.pw, pwd, sizeof(ud.pw)); - if (des_write(dest, &ud, sizeof(ud)) != sizeof(ud)) { - warnx("couldn't write pw update (abort)"); - memset((char *)&ud, 0, sizeof(ud)); - cleanup(); - exit(1); - } -} - -static void -recv_ack(remote) - int remote; -{ - int cc; - char buf[BUFSIZ]; - - cc = des_read(remote, buf, sizeof(buf)); - if (cc <= 0) { - warnx("error reading acknowledgement (aborted)"); - cleanup(); - exit(1); - } - (void)printf("%s", buf); -} - -static void -cleanup() -{ - - (void)memset((char *)&proto_data, 0, sizeof(proto_data)); - (void)memset((char *)okey, 0, sizeof(okey)); - (void)memset((char *)osched, 0, sizeof(osched)); - (void)memset((char *)random_schedule, 0, sizeof(random_schedule)); -} - -static void -finish() -{ - - (void)close(sock); - exit(1); -} - -#endif /* KERBEROS */ diff --git a/usr.bin/patch/EXTERN.h b/usr.bin/patch/EXTERN.h deleted file mode 100644 index 0271074..0000000 --- a/usr.bin/patch/EXTERN.h +++ /dev/null @@ -1,15 +0,0 @@ -/* $Header: EXTERN.h,v 2.0 86/09/17 15:35:37 lwall Exp $ - * - * $Log: EXTERN.h,v $ - * Revision 2.0 86/09/17 15:35:37 lwall - * Baseline for netwide release. - * - */ - -#undef EXT -#define EXT extern - -#undef INIT -#define INIT(x) - -#undef DOINIT diff --git a/usr.bin/patch/INTERN.h b/usr.bin/patch/INTERN.h deleted file mode 100644 index 8bf16f5..0000000 --- a/usr.bin/patch/INTERN.h +++ /dev/null @@ -1,15 +0,0 @@ -/* $Header: INTERN.h,v 2.0 86/09/17 15:35:58 lwall Exp $ - * - * $Log: INTERN.h,v $ - * Revision 2.0 86/09/17 15:35:58 lwall - * Baseline for netwide release. - * - */ - -#undef EXT -#define EXT - -#undef INIT -#define INIT(x) = x - -#define DOINIT diff --git a/usr.bin/patch/Makefile b/usr.bin/patch/Makefile deleted file mode 100644 index d6db9f7..0000000 --- a/usr.bin/patch/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= patch -SRCS= patch.c pch.c inp.c version.c util.c - -.include diff --git a/usr.bin/patch/README b/usr.bin/patch/README deleted file mode 100644 index 017b1a0..0000000 --- a/usr.bin/patch/README +++ /dev/null @@ -1,79 +0,0 @@ - -The Makefile and config.h files in this directory work with the current -BSD release. Don't run the Configure script, you'll get wrong results. - -Keith Bostic 1/10/88 ------------------------------------------------------------------------------ - - Patch Kit, Version 2.0 - - Copyright (c) 1986, Larry Wall - -You may copy the patch kit in whole or in part as long as you don't try to -make money off it, or pretend that you wrote it. --------------------------------------------------------------------------- - -Please read all the directions below before you proceed any further, and -then follow them carefully. Failure to do so may void your warranty. :-) - -After you have unpacked your kit, you should have all the files listed -in MANIFEST. - -Installation - -1) Run Configure. This will figure out various things about your system. - Some things Configure will figure out for itself, other things it will - ask you about. It will then proceed to make config.h, config.sh, and - Makefile. - - You might possibly have to trim # comments from the front of Configure - if your sh doesn't handle them, but all other # comments will be taken - care of. - - If you don't have sh, you'll have to rip the prototype of config.h out - of Configure and generate the defines by hand. - -2) Glance through config.h to make sure system dependencies are correct. - Most of them should have been taken care of by running the Configure script. - - If you have any additional changes to make to the C definitions, they - can be done in the Makefile, or in config.h. Bear in mind that they may - get undone next time you run Configure. - -3) make - - This will attempt to make patch in the current directory. - -4) make install - - This will put patch into a public directory (normally /usr/local/bin). - It will also try to put the man pages in a reasonable place. It will not - nroff the man page, however. - -5) Read the manual entry before running patch. - -6) IMPORTANT! Help save the world! Communicate any problems and - suggested patches to me, lwall@sdcrdcf.UUCP (Larry Wall), so we can - keep the world in sync. If you have a problem, there's someone else - out there who either has had or will have the same problem. - - If possible, send in patches such that the patch program will apply them. - Context diffs are the best, then normal diffs. Don't send ed scripts-- - I've probably changed my copy since the version you have. - - Watch for patch patches in net.sources.bugs. Patches will generally be - in a form usable by the patch program. If you are just now bringing up - patch and aren't sure how many patches there are, write to me and I'll - send any you don't have. Your current patch level is shown in patchlevel.h. - - -NEW FEATURES IN THIS RELEASE - -(Correct) support for 4.3bsd-style context diffs. -Files can be created from scratch. -You can specify a fuzz-factor for context matching. -You can force patch to ask no questions. -You can specify how much of the leading pathname to strip off filenames. -Uses a Configure script for greater portability. -You are now asked if you want to apply a reversed patch. -No limit (apart from memory) on the size of hunks. diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h deleted file mode 100644 index 42d6883..0000000 --- a/usr.bin/patch/common.h +++ /dev/null @@ -1,138 +0,0 @@ -/* $Header: common.h,v 2.0 86/09/17 15:36:39 lwall Exp $ - * - * $Log: common.h,v $ - * Revision 2.0 86/09/17 15:36:39 lwall - * Baseline for netwide release. - * - */ - -#define DEBUGGING - -#include "config.h" - -/* shut lint up about the following when return value ignored */ - -#define Signal (void)signal -#define Unlink (void)unlink -#define Lseek (void)lseek -#define Fseek (void)fseek -#define Fstat (void)fstat -#define Pclose (void)pclose -#define Close (void)close -#define Fclose (void)fclose -#define Fflush (void)fflush -#define Sprintf (void)sprintf -#define Mktemp (void)mktemp -#define Strcpy (void)strcpy -#define Strcat (void)strcat - -#include -#include -#include -#include -#include -#include - -/* constants */ - -#define TRUE (1) -#define FALSE (0) - -#define MAXHUNKSIZE 100000 /* is this enough lines? */ -#define INITHUNKMAX 125 /* initial dynamic allocation size */ -#define MAXLINELEN 1024 -#define BUFFERSIZE 1024 -#define ORIGEXT ".orig" -#define SCCSPREFIX "s." -#define GET "get -e %s" -#define RCSSUFFIX ",v" -#define CHECKOUT "co -l %s" - -/* handy definitions */ - -#define Null(t) ((t)0) -#define Nullch Null(char *) -#define Nullfp Null(FILE *) -#define Nulline Null(LINENUM) - -#define Ctl(ch) ((ch) & 037) - -#define strNE(s1,s2) (strcmp(s1, s2)) -#define strEQ(s1,s2) (!strcmp(s1, s2)) -#define strnNE(s1,s2,l) (strncmp(s1, s2, l)) -#define strnEQ(s1,s2,l) (!strncmp(s1, s2, l)) - -/* typedefs */ - -typedef char bool; -typedef long LINENUM; /* must be signed */ -typedef unsigned MEM; /* what to feed malloc */ - -/* globals */ - -EXT int Argc; /* guess */ -EXT char **Argv; -EXT int Argc_last; /* for restarting plan_b */ -EXT char **Argv_last; - -EXT struct stat filestat; /* file statistics area */ -EXT int filemode INIT(0644); - -EXT char buf[MAXLINELEN]; /* general purpose buffer */ -EXT FILE *ofp INIT(Nullfp); /* output file pointer */ -EXT FILE *rejfp INIT(Nullfp); /* reject file pointer */ - -EXT bool using_plan_a INIT(TRUE); /* try to keep everything in memory */ -EXT bool out_of_mem INIT(FALSE); /* ran out of memory in plan a */ - -#define MAXFILEC 2 -EXT int filec INIT(0); /* how many file arguments? */ -EXT char *filearg[MAXFILEC]; -EXT bool ok_to_create_file INIT(FALSE); -EXT char *bestguess INIT(Nullch); /* guess at correct filename */ - -EXT char *outname INIT(Nullch); -EXT char rejname[128]; - -EXT char *origext INIT(Nullch); - -EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX"); -EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX"); /* might want /usr/tmp here */ -EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX"); -EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX"); -EXT bool toutkeep INIT(FALSE); -EXT bool trejkeep INIT(FALSE); - -EXT LINENUM last_offset INIT(0); -#ifdef DEBUGGING -EXT int debug INIT(0); -#endif -EXT LINENUM maxfuzz INIT(2); -EXT bool force INIT(FALSE); -EXT bool verbose INIT(TRUE); -EXT bool reverse INIT(FALSE); -EXT bool noreverse INIT(FALSE); -EXT bool skip_rest_of_patch INIT(FALSE); -EXT int strippath INIT(957); -EXT bool canonicalize INIT(FALSE); - -#define CONTEXT_DIFF 1 -#define NORMAL_DIFF 2 -#define ED_DIFF 3 -#define NEW_CONTEXT_DIFF 4 -EXT int diff_type INIT(0); - -EXT bool do_defines INIT(FALSE); /* patch using ifdef, ifndef, etc. */ -EXT char if_defined[128]; /* #ifdef xyzzy */ -EXT char not_defined[128]; /* #ifndef xyzzy */ -EXT char else_defined[] INIT("#else\n");/* #else */ -EXT char end_defined[128]; /* #endif xyzzy */ - -EXT char *revision INIT(Nullch); /* prerequisite revision, if any */ - -char *malloc(); -char *realloc(); -char *strcpy(); -char *strcat(); -long atol(); -char *mktemp(); diff --git a/usr.bin/patch/config.h b/usr.bin/patch/config.h deleted file mode 100644 index 9318fe7..0000000 --- a/usr.bin/patch/config.h +++ /dev/null @@ -1,16 +0,0 @@ -#define Reg1 register /**/ -#define Reg2 register /**/ -#define Reg3 register /**/ -#define Reg4 register /**/ -#define Reg5 register /**/ -#define Reg6 register /**/ -#define Reg7 register /**/ -#define Reg8 register /**/ -#define Reg9 register /**/ -#define Reg10 register /**/ -#define Reg11 /**/ -#define Reg12 /**/ -#define Reg13 /**/ -#define Reg14 /**/ -#define Reg15 /**/ -#define Reg16 /**/ diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c deleted file mode 100644 index a3eeb90..0000000 --- a/usr.bin/patch/inp.c +++ /dev/null @@ -1,313 +0,0 @@ -/* $Header: inp.c,v 2.0 86/09/17 15:37:02 lwall Exp $ - * - * $Log: inp.c,v $ - * Revision 2.0 86/09/17 15:37:02 lwall - * Baseline for netwide release. - * - */ - -#include "EXTERN.h" -#include "common.h" -#include "util.h" -#include "pch.h" -#include "INTERN.h" -#include "inp.h" - -/* Input-file-with-indexable-lines abstract type */ - -static long i_size; /* size of the input file */ -static char *i_womp; /* plan a buffer for entire file */ -static char **i_ptr; /* pointers to lines in i_womp */ - -static int tifd = -1; /* plan b virtual string array */ -static char *tibuf[2]; /* plan b buffers */ -static LINENUM tiline[2] = {-1, -1}; /* 1st line in each buffer */ -static LINENUM lines_per_buf; /* how many lines per buffer */ -static int tireclen; /* length of records in tmp file */ - -/* New patch--prepare to edit another file. */ - -void -re_input() -{ - if (using_plan_a) { - i_size = 0; -#ifndef lint - if (i_ptr != Null(char**)) - free((char *)i_ptr); -#endif - if (i_womp != Nullch) - free(i_womp); - i_womp = Nullch; - i_ptr = Null(char **); - } - else { - using_plan_a = TRUE; /* maybe the next one is smaller */ - Close(tifd); - tifd = -1; - free(tibuf[0]); - free(tibuf[1]); - tibuf[0] = tibuf[1] = Nullch; - tiline[0] = tiline[1] = -1; - tireclen = 0; - } -} - -/* Constuct the line index, somehow or other. */ - -void -scan_input(filename) -char *filename; -{ - if (!plan_a(filename)) - plan_b(filename); - if (verbose) { - say3("Patching file %s using Plan %s...\n", filename, - (using_plan_a ? "A" : "B") ); - } -} - -/* Try keeping everything in memory. */ - -bool -plan_a(filename) -char *filename; -{ - int ifd; - Reg1 char *s; - Reg2 LINENUM iline; - - if (ok_to_create_file && stat(filename, &filestat) < 0) { - if (verbose) - say2("(Creating file %s...)\n",filename); - makedirs(filename, TRUE); - close(creat(filename, 0666)); - } - if (stat(filename, &filestat) < 0) { - Sprintf(buf, "RCS/%s%s", filename, RCSSUFFIX); - if (stat(buf, &filestat) >= 0 || stat(buf+4, &filestat) >= 0) { - Sprintf(buf, CHECKOUT, filename); - if (verbose) - say2("Can't find %s--attempting to check it out from RCS.\n", - filename); - if (system(buf) || stat(filename, &filestat)) - fatal2("Can't check out %s.\n", filename); - } - else { - Sprintf(buf, "SCCS/%s%s", SCCSPREFIX, filename); - if (stat(buf, &filestat) >= 0 || stat(buf+5, &filestat) >= 0) { - Sprintf(buf, GET, filename); - if (verbose) - say2("Can't find %s--attempting to get it from SCCS.\n", - filename); - if (system(buf) || stat(filename, &filestat)) - fatal2("Can't get %s.\n", filename); - } - else - fatal2("Can't find %s.\n", filename); - } - } - filemode = filestat.st_mode; - if ((filemode & S_IFMT) & ~S_IFREG) - fatal2("%s is not a normal file--can't patch.\n", filename); - i_size = filestat.st_size; - if (out_of_mem) { - set_hunkmax(); /* make sure dynamic arrays are allocated */ - out_of_mem = FALSE; - return FALSE; /* force plan b because plan a bombed */ - } -#ifdef lint - i_womp = Nullch; -#else - i_womp = malloc((MEM)(i_size+2)); /* lint says this may alloc less than */ - /* i_size, but that's okay, I think. */ -#endif - if (i_womp == Nullch) - return FALSE; - if ((ifd = open(filename, 0)) < 0) - fatal2("Can't open file %s\n", filename); -#ifndef lint - if (read(ifd, i_womp, (int)i_size) != i_size) { - Close(ifd); /* probably means i_size > 15 or 16 bits worth */ - free(i_womp); /* at this point it doesn't matter if i_womp was */ - return FALSE; /* undersized. */ - } -#endif - Close(ifd); - if (i_size && i_womp[i_size-1] != '\n') - i_womp[i_size++] = '\n'; - i_womp[i_size] = '\0'; - - /* count the lines in the buffer so we know how many pointers we need */ - - iline = 0; - for (s=i_womp; *s; s++) { - if (*s == '\n') - iline++; - } -#ifdef lint - i_ptr = Null(char**); -#else - i_ptr = (char **)malloc((MEM)((iline + 2) * sizeof(char *))); -#endif - if (i_ptr == Null(char **)) { /* shucks, it was a near thing */ - free((char *)i_womp); - return FALSE; - } - - /* now scan the buffer and build pointer array */ - - iline = 1; - i_ptr[iline] = i_womp; - for (s=i_womp; *s; s++) { - if (*s == '\n') - i_ptr[++iline] = s+1; /* these are NOT null terminated */ - } - input_lines = iline - 1; - - /* now check for revision, if any */ - - if (revision != Nullch) { - if (!rev_in_string(i_womp)) { - if (force) { - if (verbose) - say2("\ -Warning: this file doesn't appear to be the %s version--patching anyway.\n", - revision); - } - else { - ask2("\ -This file doesn't appear to be the %s version--patch anyway? [n] ", - revision); - if (*buf != 'y') - fatal1("Aborted.\n"); - } - } - else if (verbose) - say2("Good. This file appears to be the %s version.\n", - revision); - } - return TRUE; /* plan a will work */ -} - -/* Keep (virtually) nothing in memory. */ - -void -plan_b(filename) -char *filename; -{ - Reg3 FILE *ifp; - Reg1 int i = 0; - Reg2 int maxlen = 1; - Reg4 bool found_revision = (revision == Nullch); - - using_plan_a = FALSE; - if ((ifp = fopen(filename, "r")) == Nullfp) - fatal2("Can't open file %s\n", filename); - if ((tifd = creat(TMPINNAME, 0666)) < 0) - fatal2("Can't open file %s\n", TMPINNAME); - while (fgets(buf, sizeof buf, ifp) != Nullch) { - if (revision != Nullch && !found_revision && rev_in_string(buf)) - found_revision = TRUE; - if ((i = strlen(buf)) > maxlen) - maxlen = i; /* find longest line */ - } - if (revision != Nullch) { - if (!found_revision) { - if (force) { - if (verbose) - say2("\ -Warning: this file doesn't appear to be the %s version--patching anyway.\n", - revision); - } - else { - ask2("\ -This file doesn't appear to be the %s version--patch anyway? [n] ", - revision); - if (*buf != 'y') - fatal1("Aborted.\n"); - } - } - else if (verbose) - say2("Good. This file appears to be the %s version.\n", - revision); - } - Fseek(ifp, 0L, 0); /* rewind file */ - lines_per_buf = BUFFERSIZE / maxlen; - tireclen = maxlen; - tibuf[0] = malloc((MEM)(BUFFERSIZE + 1)); - tibuf[1] = malloc((MEM)(BUFFERSIZE + 1)); - if (tibuf[1] == Nullch) - fatal1("Can't seem to get enough memory.\n"); - for (i=1; ; i++) { - if (! (i % lines_per_buf)) /* new block */ - if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE) - fatal1("patch: can't write temp file.\n"); - if (fgets(tibuf[0] + maxlen * (i%lines_per_buf), maxlen + 1, ifp) - == Nullch) { - input_lines = i - 1; - if (i % lines_per_buf) - if (write(tifd, tibuf[0], BUFFERSIZE) < BUFFERSIZE) - fatal1("patch: can't write temp file.\n"); - break; - } - } - Fclose(ifp); - Close(tifd); - if ((tifd = open(TMPINNAME, 0)) < 0) { - fatal2("Can't reopen file %s\n", TMPINNAME); - } -} - -/* Fetch a line from the input file, \n terminated, not necessarily \0. */ - -char * -ifetch(line,whichbuf) -Reg1 LINENUM line; -int whichbuf; /* ignored when file in memory */ -{ - if (line < 1 || line > input_lines) - return ""; - if (using_plan_a) - return i_ptr[line]; - else { - LINENUM offline = line % lines_per_buf; - LINENUM baseline = line - offline; - - if (tiline[0] == baseline) - whichbuf = 0; - else if (tiline[1] == baseline) - whichbuf = 1; - else { - tiline[whichbuf] = baseline; -#ifndef lint /* complains of long accuracy */ - Lseek(tifd, (off_t)baseline / lines_per_buf * BUFFERSIZE, 0); -#endif - if (read(tifd, tibuf[whichbuf], BUFFERSIZE) < 0) - fatal2("Error reading tmp file %s.\n", TMPINNAME); - } - return tibuf[whichbuf] + (tireclen*offline); - } -} - -/* True if the string argument contains the revision number we want. */ - -bool -rev_in_string(string) -char *string; -{ - Reg1 char *s; - Reg2 int patlen; - - if (revision == Nullch) - return TRUE; - patlen = strlen(revision); - for (s = string; *s; s++) { - if (isspace(*s) && strnEQ(s+1, revision, patlen) && - isspace(s[patlen+1] )) { - return TRUE; - } - } - return FALSE; -} - diff --git a/usr.bin/patch/inp.h b/usr.bin/patch/inp.h deleted file mode 100644 index c6d2a91..0000000 --- a/usr.bin/patch/inp.h +++ /dev/null @@ -1,18 +0,0 @@ -/* $Header: inp.h,v 2.0 86/09/17 15:37:25 lwall Exp $ - * - * $Log: inp.h,v $ - * Revision 2.0 86/09/17 15:37:25 lwall - * Baseline for netwide release. - * - */ - -EXT LINENUM input_lines INIT(0); /* how long is input file in lines */ -EXT LINENUM last_frozen_line INIT(0); /* how many input lines have been */ - /* irretractibly output */ - -bool rev_in_string(); -void scan_input(); -bool plan_a(); /* returns false if insufficient memory */ -void plan_b(); -char *ifetch(); - diff --git a/usr.bin/patch/patch.1 b/usr.bin/patch/patch.1 deleted file mode 100644 index 3e4a12e..0000000 --- a/usr.bin/patch/patch.1 +++ /dev/null @@ -1,446 +0,0 @@ -''' $Header: patch.man,v 2.0 86/09/17 15:39:09 lwall Exp $ -''' -''' $Log: patch.man,v $ -''' Revision 2.0 86/09/17 15:39:09 lwall -''' Baseline for netwide release. -''' -''' Revision 1.4 86/08/01 19:23:22 lwall -''' Documented -v, -p, -F. -''' Added notes to patch senders. -''' -''' Revision 1.3 85/03/26 15:11:06 lwall -''' Frozen. -''' -''' Revision 1.2.1.4 85/03/12 16:14:27 lwall -''' Documented -p. -''' -''' Revision 1.2.1.3 85/03/12 16:09:41 lwall -''' Documented -D. -''' -''' Revision 1.2.1.2 84/12/05 11:06:55 lwall -''' Added -l switch, and noted bistability bug. -''' -''' Revision 1.2.1.1 84/12/04 17:23:39 lwall -''' Branch for sdcrdcf changes. -''' -''' Revision 1.2 84/12/04 17:22:02 lwall -''' Baseline version. -''' -.de Sh -.br -.ne 5 -.PP -\fB\\$1\fR -.PP -.. -.de Sp -.if t .sp .5v -.if n .sp -.. -''' -''' Set up \*(-- to give an unbreakable dash; -''' string Tr holds user defined translation string. -''' Bell System Logo is used as a dummy character. -''' -.ie n \{\ -.tr \(bs-\*(Tr -.ds -- \(bs- -.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch -.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch -.ds L" "" -.ds R" "" -.ds L' ' -.ds R' ' -'br\} -.el\{\ -.ds -- \(em\| -.tr \*(Tr -.ds L" `` -.ds R" '' -.ds L' ` -.ds R' ' -'br\} -.TH PATCH 1 "June 30, 1993" -.SH NAME -patch \- a program for applying a diff file to an original -.SH SYNOPSIS -.B patch -[options] orig patchfile [+ [options] orig] -.sp -but usually just -.sp -.B patch - -sets the maximum fuzz factor. -This switch only applied to context diffs, and causes -.I patch -to ignore up to that many lines in looking for places to install a hunk. -Note that a larger fuzz factor increases the odds of a faulty patch. -The default fuzz factor is 2, and it may not be set to more than -the number of lines of context in the context diff, ordinarily 3. -.TP 5 -.B \-l -causes the pattern matching to be done loosely, in case the tabs and -spaces have been munged in your input file. -Any sequence of whitespace in the pattern line will match any sequence -in the input file. -Normal characters must still match exactly. -Each line of the context must still match a line in the input file. -.TP 5 -.B \-n -forces -.I patch -to interpret the patch file as a normal diff. -.TP 5 -.B \-N -causes -.I patch -to ignore patches that it thinks are reversed or already applied. -See also -.B \-R . -.TP 5 -.B \-o -causes the next argument to be interpreted as the output file name. -.TP 5 -.B \-p -sets the pathname strip count, -which controls how pathnames found in the patch file are treated, in case -the you keep your files in a different directory than the person who sent -out the patch. -The strip count specifies how many backslashes are to be stripped from -the front of the pathname. -(Any intervening directory names also go away.) -For example, supposing the filename in the patch file was -.sp - /u/howard/src/blurfl/blurfl.c -.sp -setting -.B \-p -or -.B \-p0 -gives the entire pathname unmodified, -.B \-p1 -gives -.sp - u/howard/src/blurfl/blurfl.c -.sp -without the leading slash, -.B \-p4 -gives -.sp - blurfl/blurfl.c -.sp -and not specifying -.B \-p -at all just gives you "blurfl.c". -Whatever you end up with is looked for either in the current directory, -or the directory specified by the -.B \-d -switch. -.TP 5 -.B \-r -causes the next argument to be interpreted as the reject file name. -.TP 5 -.B \-R -tells -.I patch -that this patch was created with the old and new files swapped. -(Yes, I'm afraid that does happen occasionally, human nature being what it -is.) -.I Patch -will attempt to swap each hunk around before applying it. -Rejects will come out in the swapped format. -The -.B \-R -switch will not work with ed diff scripts because there is too little -information to reconstruct the reverse operation. -.Sp -If the first hunk of a patch fails, -.I patch -will reverse the hunk to see if it can be applied that way. -If it can, you will be asked if you want to have the -.B \-R -switch set. -If it can't, the patch will continue to be applied normally. -(Note: this method cannot detect a reversed patch if it is a normal diff -and if the first command is an append (i.e. it should have been a delete) -since appends always succeed, due to the fact that a null context will match -anywhere. -Luckily, most patches add or change lines rather than delete them, so most -reversed normal diffs will begin with a delete, which will fail, triggering -the heuristic.) -.TP 5 -.B \-s -makes -.I patch -do its work silently, unless an error occurs. -.TP 5 -.B \-S -causes -.I patch -to ignore this patch from the patch file, but continue on looking -for the next patch in the file. -Thus -.sp - patch -S + -S + -sets internal debugging flags, and is of interest only to -.I patch -patchers. -.SH ENVIRONMENT -No environment variables are used by -.IR patch . -.SH FILES -/tmp/patch* -.SH SEE ALSO -diff(1) -.SH NOTES FOR PATCH SENDERS -There are several things you should bear in mind if you are going to -be sending out patches. -First, you can save people a lot of grief by keeping a patchlevel.h file -which is patched to increment the patch level as the first diff in the -patch file you send out. -If you put a Prereq: line in with the patch, it won't let them apply -patches out of order without some warning. -Second, make sure you've specified the filenames right, either in a -context diff header, or with an Index: line. -If you are patching something in a subdirectory, be sure to tell the patch -user to specify a -.B \-p -switch as needed. -Third, you can create a file by sending out a diff that compares a -null file to the file you want to create. -This will only work if the file you want to create doesn't exist already in -the target directory. -Fourth, take care not to send out reversed patches, since it makes people wonder -whether they already applied the patch. -Fifth, while you may be able to get away with putting 582 diff listings into -one file, it is probably wiser to group related patches into separate files in -case something goes haywire. -.SH DIAGNOSTICS -Too many to list here, but generally indicative that -.I patch -couldn't parse your patch file. -.PP -The message \*(L"Hmm...\*(R" indicates that there is unprocessed text in -the patch file and that -.I patch -is attempting to intuit whether there is a patch in that text and, if so, -what kind of patch it is. -.SH CAVEATS -.I Patch -cannot tell if the line numbers are off in an ed script, and can only detect -bad line numbers in a normal diff when it finds a \*(L"change\*(R" or -a \*(L"delete\*(R" command. -A context diff using fuzz factor 3 may have the same problem. -Until a suitable interactive interface is added, you should probably do -a context diff in these cases to see if the changes made sense. -Of course, compiling without errors is a pretty good indication that the patch -worked, but not always. -.PP -.I Patch -usually produces the correct results, even when it has to do a lot of -guessing. -However, the results are guaranteed to be correct only when the patch is -applied to exactly the same version of the file that the patch was -generated from. -.SH BUGS -Could be smarter about partial matches, excessively \&deviant offsets and -swapped code, but that would take an extra pass. -.PP -If code has been duplicated (for instance with #ifdef OLDCODE ... #else ... -#endif), -.I patch -is incapable of patching both versions, and, if it works at all, will likely -patch the wrong one, and tell you that it succeeded to boot. -.PP -If you apply a patch you've already applied, -.I patch -will think it is a reversed patch, and offer to un-apply the patch. -This could be construed as a feature. diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c deleted file mode 100644 index 0f91c5c..0000000 --- a/usr.bin/patch/patch.c +++ /dev/null @@ -1,800 +0,0 @@ -#ifndef lint -static char sccsid[] = "@(#)patch.c 8.1 (Berkeley) 6/6/93"; -#endif not lint - -char rcsid[] = - "$Header: patch.c,v 2.0.1.4 87/02/16 14:00:04 lwall Exp $"; - -/* patch - a program to apply diffs to original files - * - * Copyright 1986, Larry Wall - * - * This program may be copied as long as you don't try to make any - * money off of it, or pretend that you wrote it. - * - * $Log: patch.c,v $ - * Revision 2.0.1.4 87/02/16 14:00:04 lwall - * Short replacement caused spurious "Out of sync" message. - * - * Revision 2.0.1.3 87/01/30 22:45:50 lwall - * Improved diagnostic on sync error. - * Moved do_ed_script() to pch.c. - * - * Revision 2.0.1.2 86/11/21 09:39:15 lwall - * Fuzz factor caused offset of installed lines. - * - * Revision 2.0.1.1 86/10/29 13:10:22 lwall - * Backwards search could terminate prematurely. - * - * Revision 2.0 86/09/17 15:37:32 lwall - * Baseline for netwide release. - * - * Revision 1.5 86/08/01 20:53:24 lwall - * Changed some %d's to %ld's. - * Linted. - * - * Revision 1.4 86/08/01 19:17:29 lwall - * Fixes for machines that can't vararg. - * Added fuzz factor. - * Generalized -p. - * General cleanup. - * - * 85/08/15 van%ucbmonet@berkeley - * Changes for 4.3bsd diff -c. - * - * Revision 1.3 85/03/26 15:07:43 lwall - * Frozen. - * - * Revision 1.2.1.9 85/03/12 17:03:35 lwall - * Changed pfp->_file to fileno(pfp). - * - * Revision 1.2.1.8 85/03/12 16:30:43 lwall - * Check i_ptr and i_womp to make sure they aren't null before freeing. - * Also allow ed output to be suppressed. - * - * Revision 1.2.1.7 85/03/12 15:56:13 lwall - * Added -p option from jromine@uci-750a. - * - * Revision 1.2.1.6 85/03/12 12:12:51 lwall - * Now checks for normalness of file to patch. - * - * Revision 1.2.1.5 85/03/12 11:52:12 lwall - * Added -D (#ifdef) option from joe@fluke. - * - * Revision 1.2.1.4 84/12/06 11:14:15 lwall - * Made smarter about SCCS subdirectories. - * - * Revision 1.2.1.3 84/12/05 11:18:43 lwall - * Added -l switch to do loose string comparison. - * - * Revision 1.2.1.2 84/12/04 09:47:13 lwall - * Failed hunk count not reset on multiple patch file. - * - * Revision 1.2.1.1 84/12/04 09:42:37 lwall - * Branch for sdcrdcf changes. - * - * Revision 1.2 84/11/29 13:29:51 lwall - * Linted. Identifiers uniqified. Fixed i_ptr malloc() bug. Fixed - * multiple calls to mktemp(). Will now work on machines that can only - * read 32767 chars. Added -R option for diffs with new and old swapped. - * Various cosmetic changes. - * - * Revision 1.1 84/11/09 17:03:58 lwall - * Initial revision - * - */ - -#include "INTERN.h" -#include "common.h" -#include "EXTERN.h" -#include "version.h" -#include "util.h" -#include "pch.h" -#include "inp.h" - -/* procedures */ - -void reinitialize_almost_everything(); -void get_some_switches(); -LINENUM locate_hunk(); -void abort_hunk(); -void apply_hunk(); -void init_output(); -void init_reject(); -void copy_till(); -void spew_output(); -void dump_line(); -bool patch_match(); -bool similar(); -void re_input(); -void my_exit(); - -/* Apply a set of diffs as appropriate. */ - -main(argc,argv) -int argc; -char **argv; -{ - LINENUM where; - LINENUM newwhere; - LINENUM fuzz; - LINENUM mymaxfuzz; - int hunk = 0; - int failed = 0; - int i; - - setbuf(stderr, serrbuf); - for (i = 0; i= 2) - fatal1("You may not change to a different patch file.\n"); -} - -/* Process switches and filenames up to next '+' or end of list. */ - -void -get_some_switches() -{ - Reg1 char *s; - - rejname[0] = '\0'; - Argc_last = Argc; - Argv_last = Argv; - if (!Argc) - return; - for (Argc--,Argv++; Argc; Argc--,Argv++) { - s = Argv[0]; - if (strEQ(s, "+")) { - return; /* + will be skipped by for loop */ - } - if (*s != '-' || !s[1]) { - if (filec == MAXFILEC) - fatal1("Too many file arguments.\n"); - filearg[filec++] = savestr(s); - } - else { - switch (*++s) { - case 'b': - origext = savestr(Argv[1]); - Argc--,Argv++; - break; - case 'c': - diff_type = CONTEXT_DIFF; - break; - case 'd': - if (!*++s) { - Argc--,Argv++; - s = Argv[0]; - } - if (chdir(s) < 0) - fatal2("Can't cd to %s.\n", s); - break; - case 'D': - do_defines = TRUE; - if (!*++s) { - Argc--,Argv++; - s = Argv[0]; - } - Sprintf(if_defined, "#ifdef %s\n", s); - Sprintf(not_defined, "#ifndef %s\n", s); - Sprintf(end_defined, "#endif /* %s */\n", s); - break; - case 'e': - diff_type = ED_DIFF; - break; - case 'f': - force = TRUE; - break; - case 'F': - if (*++s == '=') - s++; - maxfuzz = atoi(s); - break; - case 'l': - canonicalize = TRUE; - break; - case 'n': - diff_type = NORMAL_DIFF; - break; - case 'N': - noreverse = TRUE; - break; - case 'o': - outname = savestr(Argv[1]); - Argc--,Argv++; - break; - case 'p': - if (*++s == '=') - s++; - strippath = atoi(s); - break; - case 'r': - Strcpy(rejname, Argv[1]); - Argc--,Argv++; - break; - case 'R': - reverse = TRUE; - break; - case 's': - verbose = FALSE; - break; - case 'S': - skip_rest_of_patch = TRUE; - break; - case 'v': - version(); - break; -#ifdef DEBUGGING - case 'x': - debug = atoi(s+1); - break; -#endif - default: - fatal2("Unrecognized switch: %s\n", Argv[0]); - } - } - } -} - -/* Attempt to find the right place to apply this hunk of patch. */ - -LINENUM -locate_hunk(fuzz) -LINENUM fuzz; -{ - Reg1 LINENUM first_guess = pch_first() + last_offset; - Reg2 LINENUM offset; - LINENUM pat_lines = pch_ptrn_lines(); - Reg3 LINENUM max_pos_offset = input_lines - first_guess - - pat_lines + 1; - Reg4 LINENUM max_neg_offset = first_guess - last_frozen_line - 1 - + pch_context(); - - if (!pat_lines) /* null range matches always */ - return first_guess; - if (max_neg_offset >= first_guess) /* do not try lines < 0 */ - max_neg_offset = first_guess - 1; - if (first_guess <= input_lines && patch_match(first_guess, Nulline, fuzz)) - return first_guess; - for (offset = 1; ; offset++) { - Reg5 bool check_after = (offset <= max_pos_offset); - Reg6 bool check_before = (offset <= max_neg_offset); - - if (check_after && patch_match(first_guess, offset, fuzz)) { -#ifdef DEBUGGING - if (debug & 1) - say3("Offset changing from %ld to %ld\n", last_offset, offset); -#endif - last_offset = offset; - return first_guess+offset; - } - else if (check_before && patch_match(first_guess, -offset, fuzz)) { -#ifdef DEBUGGING - if (debug & 1) - say3("Offset changing from %ld to %ld\n", last_offset, -offset); -#endif - last_offset = -offset; - return first_guess-offset; - } - else if (!check_before && !check_after) - return Nulline; - } -} - -/* We did not find the pattern, dump out the hunk so they can handle it. */ - -void -abort_hunk() -{ - Reg1 LINENUM i; - Reg2 LINENUM pat_end = pch_end(); - /* add in last_offset to guess the same as the previous successful hunk */ - LINENUM oldfirst = pch_first() + last_offset; - LINENUM newfirst = pch_newfirst() + last_offset; - LINENUM oldlast = oldfirst + pch_ptrn_lines() - 1; - LINENUM newlast = newfirst + pch_repl_lines() - 1; - char *stars = (diff_type == NEW_CONTEXT_DIFF ? " ****" : ""); - char *minuses = (diff_type == NEW_CONTEXT_DIFF ? " ----" : " -----"); - - fprintf(rejfp, "***************\n"); - for (i=0; i<=pat_end; i++) { - switch (pch_char(i)) { - case '*': - if (oldlast < oldfirst) - fprintf(rejfp, "*** 0%s\n", stars); - else if (oldlast == oldfirst) - fprintf(rejfp, "*** %ld%s\n", oldfirst, stars); - else - fprintf(rejfp, "*** %ld,%ld%s\n", oldfirst, oldlast, stars); - break; - case '=': - if (newlast < newfirst) - fprintf(rejfp, "--- 0%s\n", minuses); - else if (newlast == newfirst) - fprintf(rejfp, "--- %ld%s\n", newfirst, minuses); - else - fprintf(rejfp, "--- %ld,%ld%s\n", newfirst, newlast, minuses); - break; - case '\n': - fprintf(rejfp, "%s", pfetch(i)); - break; - case ' ': case '-': case '+': case '!': - fprintf(rejfp, "%c %s", pch_char(i), pfetch(i)); - break; - default: - say1("Fatal internal error in abort_hunk().\n"); - abort(); - } - } -} - -/* We found where to apply it (we hope), so do it. */ - -void -apply_hunk(where) -LINENUM where; -{ - Reg1 LINENUM old = 1; - Reg2 LINENUM lastline = pch_ptrn_lines(); - Reg3 LINENUM new = lastline+1; -#define OUTSIDE 0 -#define IN_IFNDEF 1 -#define IN_IFDEF 2 -#define IN_ELSE 3 - Reg4 int def_state = OUTSIDE; - Reg5 bool R_do_defines = do_defines; - Reg6 LINENUM pat_end = pch_end(); - - where--; - while (pch_char(new) == '=' || pch_char(new) == '\n') - new++; - - while (old <= lastline) { - if (pch_char(old) == '-') { - copy_till(where + old - 1); - if (R_do_defines) { - if (def_state == OUTSIDE) { - fputs(not_defined, ofp); - def_state = IN_IFNDEF; - } - else if (def_state == IN_IFDEF) { - fputs(else_defined, ofp); - def_state = IN_ELSE; - } - fputs(pfetch(old), ofp); - } - last_frozen_line++; - old++; - } - else if (new > pat_end) - break; - else if (pch_char(new) == '+') { - copy_till(where + old - 1); - if (R_do_defines) { - if (def_state == IN_IFNDEF) { - fputs(else_defined, ofp); - def_state = IN_ELSE; - } - else if (def_state == OUTSIDE) { - fputs(if_defined, ofp); - def_state = IN_IFDEF; - } - } - fputs(pfetch(new), ofp); - new++; - } - else { - if (pch_char(new) != pch_char(old)) { - say3("Out-of-sync patch, lines %ld,%ld--mangled text or line numbers, maybe?\n", - pch_hunk_beg() + old, - pch_hunk_beg() + new); -#ifdef DEBUGGING - say3("oldchar = '%c', newchar = '%c'\n", - pch_char(old), pch_char(new)); -#endif - my_exit(1); - } - if (pch_char(new) == '!') { - copy_till(where + old - 1); - if (R_do_defines) { - fputs(not_defined, ofp); - def_state = IN_IFNDEF; - } - while (pch_char(old) == '!') { - if (R_do_defines) { - fputs(pfetch(old), ofp); - } - last_frozen_line++; - old++; - } - if (R_do_defines) { - fputs(else_defined, ofp); - def_state = IN_ELSE; - } - while (pch_char(new) == '!') { - fputs(pfetch(new), ofp); - new++; - } - if (R_do_defines) { - fputs(end_defined, ofp); - def_state = OUTSIDE; - } - } - else { - assert(pch_char(new) == ' '); - old++; - new++; - } - } - } - if (new <= pat_end && pch_char(new) == '+') { - copy_till(where + old - 1); - if (R_do_defines) { - if (def_state == OUTSIDE) { - fputs(if_defined, ofp); - def_state = IN_IFDEF; - } - else if (def_state == IN_IFNDEF) { - fputs(else_defined, ofp); - def_state = IN_ELSE; - } - } - while (new <= pat_end && pch_char(new) == '+') { - fputs(pfetch(new), ofp); - new++; - } - } - if (R_do_defines && def_state != OUTSIDE) { - fputs(end_defined, ofp); - } -} - -/* Open the new file. */ - -void -init_output(name) -char *name; -{ - ofp = fopen(name, "w"); - if (ofp == Nullfp) - fatal2("patch: can't create %s.\n", name); -} - -/* Open a file to put hunks we can't locate. */ - -void -init_reject(name) -char *name; -{ - rejfp = fopen(name, "w"); - if (rejfp == Nullfp) - fatal2("patch: can't create %s.\n", name); -} - -/* Copy input file to output, up to wherever hunk is to be applied. */ - -void -copy_till(lastline) -Reg1 LINENUM lastline; -{ - Reg2 LINENUM R_last_frozen_line = last_frozen_line; - - if (R_last_frozen_line > lastline) - say1("patch: misordered hunks! output will be garbled.\n"); - while (R_last_frozen_line < lastline) { - dump_line(++R_last_frozen_line); - } - last_frozen_line = R_last_frozen_line; -} - -/* Finish copying the input file to the output file. */ - -void -spew_output() -{ -#ifdef DEBUGGING - if (debug & 256) - say3("il=%ld lfl=%ld\n",input_lines,last_frozen_line); -#endif - if (input_lines) - copy_till(input_lines); /* dump remainder of file */ - Fclose(ofp); - ofp = Nullfp; -} - -/* Copy one line from input to output. */ - -void -dump_line(line) -LINENUM line; -{ - Reg1 char *s; - Reg2 char R_newline = '\n'; - - /* Note: string is not null terminated. */ - for (s=ifetch(line, 0); putc(*s, ofp) != R_newline; s++) ; -} - -/* Does the patch pattern match at line base+offset? */ - -bool -patch_match(base, offset, fuzz) -LINENUM base; -LINENUM offset; -LINENUM fuzz; -{ - Reg1 LINENUM pline = 1 + fuzz; - Reg2 LINENUM iline; - Reg3 LINENUM pat_lines = pch_ptrn_lines() - fuzz; - - for (iline=base+offset+fuzz; pline <= pat_lines; pline++,iline++) { - if (canonicalize) { - if (!similar(ifetch(iline, (offset >= 0)), - pfetch(pline), - pch_line_len(pline) )) - return FALSE; - } - else if (strnNE(ifetch(iline, (offset >= 0)), - pfetch(pline), - pch_line_len(pline) )) - return FALSE; - } - return TRUE; -} - -/* Do two lines match with canonicalized white space? */ - -bool -similar(a,b,len) -Reg1 char *a; -Reg2 char *b; -Reg3 int len; -{ - while (len) { - if (isspace(*b)) { /* whitespace (or \n) to match? */ - if (!isspace(*a)) /* no corresponding whitespace? */ - return FALSE; - while (len && isspace(*b) && *b != '\n') - b++,len--; /* skip pattern whitespace */ - while (isspace(*a) && *a != '\n') - a++; /* skip target whitespace */ - if (*a == '\n' || *b == '\n') - return (*a == *b); /* should end in sync */ - } - else if (*a++ != *b++) /* match non-whitespace chars */ - return FALSE; - else - len--; /* probably not necessary */ - } - return TRUE; /* actually, this is not reached */ - /* since there is always a \n */ -} - -/* Exit with cleanup. */ - -void -my_exit(status) -int status; -{ - Unlink(TMPINNAME); - if (!toutkeep) { - Unlink(TMPOUTNAME); - } - if (!trejkeep) { - Unlink(TMPREJNAME); - } - Unlink(TMPPATNAME); - exit(status); -} diff --git a/usr.bin/patch/patchlevel.h b/usr.bin/patch/patchlevel.h deleted file mode 100644 index 618bca4..0000000 --- a/usr.bin/patch/patchlevel.h +++ /dev/null @@ -1 +0,0 @@ -#define PATCHLEVEL 9 diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c deleted file mode 100644 index 8837212..0000000 --- a/usr.bin/patch/pch.c +++ /dev/null @@ -1,1108 +0,0 @@ -/* $Header: pch.c,v 2.0.1.6 87/06/04 16:18:13 lwall Exp $ - * - * $Log: pch.c,v $ - * Revision 2.0.1.6 87/06/04 16:18:13 lwall - * pch_swap didn't swap p_bfake and p_efake. - * - * Revision 2.0.1.5 87/01/30 22:47:42 lwall - * Improved responses to mangled patches. - * - * Revision 2.0.1.4 87/01/05 16:59:53 lwall - * New-style context diffs caused double call to free(). - * - * Revision 2.0.1.3 86/11/14 10:08:33 lwall - * Fixed problem where a long pattern wouldn't grow the hunk. - * Also restored p_input_line when backtracking so error messages are right. - * - * Revision 2.0.1.2 86/11/03 17:49:52 lwall - * New-style delete triggers spurious assertion error. - * - * Revision 2.0.1.1 86/10/29 15:52:08 lwall - * Could falsely report new-style context diff. - * - * Revision 2.0 86/09/17 15:39:37 lwall - * Baseline for netwide release. - * - */ - -#include "EXTERN.h" -#include "common.h" -#include "util.h" -#include "INTERN.h" -#include "pch.h" - -/* Patch (diff listing) abstract type. */ - -static long p_filesize; /* size of the patch file */ -static LINENUM p_first; /* 1st line number */ -static LINENUM p_newfirst; /* 1st line number of replacement */ -static LINENUM p_ptrn_lines; /* # lines in pattern */ -static LINENUM p_repl_lines; /* # lines in replacement text */ -static LINENUM p_end = -1; /* last line in hunk */ -static LINENUM p_max; /* max allowed value of p_end */ -static LINENUM p_context = 3; /* # of context lines */ -static LINENUM p_input_line = 0; /* current line # from patch file */ -static char **p_line = Null(char**); /* the text of the hunk */ -static short *p_len = Null(short*); /* length of each line */ -static char *p_char = Nullch; /* +, -, and ! */ -static int hunkmax = INITHUNKMAX; /* size of above arrays to begin with */ -static int p_indent; /* indent to patch */ -static LINENUM p_base; /* where to intuit this time */ -static LINENUM p_bline; /* line # of p_base */ -static LINENUM p_start; /* where intuit found a patch */ -static LINENUM p_sline; /* and the line number for it */ -static LINENUM p_hunk_beg; /* line number of current hunk */ -static LINENUM p_efake = -1; /* end of faked up lines--don't free */ -static LINENUM p_bfake = -1; /* beg of faked up lines */ - -/* Prepare to look for the next patch in the patch file. */ - -void -re_patch() -{ - p_first = Nulline; - p_newfirst = Nulline; - p_ptrn_lines = Nulline; - p_repl_lines = Nulline; - p_end = (LINENUM)-1; - p_max = Nulline; - p_indent = 0; -} - -/* Open the patch file at the beginning of time. */ - -void -open_patch_file(filename) -char *filename; -{ - if (filename == Nullch || !*filename || strEQ(filename, "-")) { - pfp = fopen(TMPPATNAME, "w"); - if (pfp == Nullfp) - fatal2("patch: can't create %s.\n", TMPPATNAME); - while (fgets(buf, sizeof buf, stdin) != Nullch) - fputs(buf, pfp); - Fclose(pfp); - filename = TMPPATNAME; - } - pfp = fopen(filename, "r"); - if (pfp == Nullfp) - fatal2("patch file %s not found\n", filename); - Fstat(fileno(pfp), &filestat); - p_filesize = filestat.st_size; - next_intuit_at(0L,1L); /* start at the beginning */ - set_hunkmax(); -} - -/* Make sure our dynamically realloced tables are malloced to begin with. */ - -void -set_hunkmax() -{ -#ifndef lint - if (p_line == Null(char**)) - p_line = (char**) malloc((MEM)hunkmax * sizeof(char *)); - if (p_len == Null(short*)) - p_len = (short*) malloc((MEM)hunkmax * sizeof(short)); -#endif - if (p_char == Nullch) - p_char = (char*) malloc((MEM)hunkmax * sizeof(char)); -} - -/* Enlarge the arrays containing the current hunk of patch. */ - -void -grow_hunkmax() -{ - hunkmax *= 2; - /* - * Note that on most systems, only the p_line array ever gets fresh memory - * since p_len can move into p_line's old space, and p_char can move into - * p_len's old space. Not on PDP-11's however. But it doesn't matter. - */ - assert(p_line != Null(char**) && p_len != Null(short*) && p_char != Nullch); -#ifndef lint - p_line = (char**) realloc((char*)p_line, (MEM)hunkmax * sizeof(char *)); - p_len = (short*) realloc((char*)p_len, (MEM)hunkmax * sizeof(short)); - p_char = (char*) realloc((char*)p_char, (MEM)hunkmax * sizeof(char)); -#endif - if (p_line != Null(char**) && p_len != Null(short*) && p_char != Nullch) - return; - if (!using_plan_a) - fatal1("patch: out of memory (grow_hunkmax)\n"); - out_of_mem = TRUE; /* whatever is null will be allocated again */ - /* from within plan_a(), of all places */ -} - -/* True if the remainder of the patch file contains a diff of some sort. */ - -bool -there_is_another_patch() -{ - if (p_base != 0L && p_base >= p_filesize) { - if (verbose) - say1("done\n"); - return FALSE; - } - if (verbose) - say1("Hmm..."); - diff_type = intuit_diff_type(); - if (!diff_type) { - if (p_base != 0L) { - if (verbose) - say1(" Ignoring the trailing garbage.\ndone\n"); - } - else - say1(" I can't seem to find a patch in there anywhere.\n"); - return FALSE; - } - if (verbose) - say3(" %sooks like %s to me...\n", - (p_base == 0L ? "L" : "The next patch l"), - diff_type == CONTEXT_DIFF ? "a context diff" : - diff_type == NEW_CONTEXT_DIFF ? "a new-style context diff" : - diff_type == NORMAL_DIFF ? "a normal diff" : - "an ed script" ); - if (p_indent && verbose) - say3("(Patch is indented %d space%s.)\n", p_indent, p_indent==1?"":"s"); - skip_to(p_start,p_sline); - while (filearg[0] == Nullch) { - if (force) { - say1("No file to patch. Skipping...\n"); - filearg[0] = savestr(bestguess); - return TRUE; - } - ask1("File to patch: "); - if (*buf != '\n') { - if (bestguess) - free(bestguess); - bestguess = savestr(buf); - filearg[0] = fetchname(buf, 0, FALSE); - } - if (filearg[0] == Nullch) { - ask1("No file found--skip this patch? [n] "); - if (*buf != 'y') { - continue; - } - if (verbose) - say1("Skipping patch...\n"); - filearg[0] = fetchname(bestguess, 0, TRUE); - skip_rest_of_patch = TRUE; - return TRUE; - } - } - return TRUE; -} - -/* Determine what kind of diff is in the remaining part of the patch file. */ - -int -intuit_diff_type() -{ - Reg4 long this_line = 0; - Reg5 long previous_line; - Reg6 long first_command_line = -1; - long fcl_line; - Reg7 bool last_line_was_command = FALSE; - Reg8 bool this_is_a_command = FALSE; - Reg9 bool stars_last_line = FALSE; - Reg10 bool stars_this_line = FALSE; - Reg3 int indent; - Reg1 char *s; - Reg2 char *t; - char *indtmp = Nullch; - char *oldtmp = Nullch; - char *newtmp = Nullch; - char *indname = Nullch; - char *oldname = Nullch; - char *newname = Nullch; - Reg11 int retval; - bool no_filearg = (filearg[0] == Nullch); - - ok_to_create_file = FALSE; - Fseek(pfp, p_base, 0); - p_input_line = p_bline - 1; - for (;;) { - previous_line = this_line; - last_line_was_command = this_is_a_command; - stars_last_line = stars_this_line; - this_line = ftell(pfp); - indent = 0; - p_input_line++; - if (fgets(buf, sizeof buf, pfp) == Nullch) { - if (first_command_line >= 0L) { - /* nothing but deletes!? */ - p_start = first_command_line; - p_sline = fcl_line; - retval = ED_DIFF; - goto scan_exit; - } - else { - p_start = this_line; - p_sline = p_input_line; - retval = 0; - goto scan_exit; - } - } - for (s = buf; *s == ' ' || *s == '\t'; s++) { - if (*s == '\t') - indent += 8 - (indent % 8); - else - indent++; - } - for (t=s; isdigit(*t) || *t == ','; t++) ; - this_is_a_command = (isdigit(*s) && - (*t == 'd' || *t == 'c' || *t == 'a') ); - if (first_command_line < 0L && this_is_a_command) { - first_command_line = this_line; - fcl_line = p_input_line; - p_indent = indent; /* assume this for now */ - } - if (!stars_last_line && strnEQ(s, "*** ", 4)) - oldtmp = savestr(s+4); - else if (strnEQ(s, "--- ", 4)) - newtmp = savestr(s+4); - else if (strnEQ(s, "Index:", 6)) - indtmp = savestr(s+6); - else if (strnEQ(s, "Prereq:", 7)) { - for (t=s+7; isspace(*t); t++) ; - revision = savestr(t); - for (t=revision; *t && !isspace(*t); t++) ; - *t = '\0'; - if (!*revision) { - free(revision); - revision = Nullch; - } - } - if ((!diff_type || diff_type == ED_DIFF) && - first_command_line >= 0L && - strEQ(s, ".\n") ) { - p_indent = indent; - p_start = first_command_line; - p_sline = fcl_line; - retval = ED_DIFF; - goto scan_exit; - } - stars_this_line = strnEQ(s, "********", 8); - if ((!diff_type || diff_type == CONTEXT_DIFF) && stars_last_line && - strnEQ(s, "*** ", 4)) { - if (!atol(s+4)) - ok_to_create_file = TRUE; - /* if this is a new context diff the character just before */ - /* the newline is a '*'. */ - while (*s != '\n') - s++; - p_indent = indent; - p_start = previous_line; - p_sline = p_input_line - 1; - retval = (*(s-1) == '*' ? NEW_CONTEXT_DIFF : CONTEXT_DIFF); - goto scan_exit; - } - if ((!diff_type || diff_type == NORMAL_DIFF) && - last_line_was_command && - (strnEQ(s, "< ", 2) || strnEQ(s, "> ", 2)) ) { - p_start = previous_line; - p_sline = p_input_line - 1; - p_indent = indent; - retval = NORMAL_DIFF; - goto scan_exit; - } - } - scan_exit: - if (no_filearg) { - if (indtmp != Nullch) - indname = fetchname(indtmp, strippath, ok_to_create_file); - if (oldtmp != Nullch) - oldname = fetchname(oldtmp, strippath, ok_to_create_file); - if (newtmp != Nullch) - newname = fetchname(newtmp, strippath, ok_to_create_file); - if (oldname && newname) { - if (strlen(oldname) < strlen(newname)) - filearg[0] = savestr(oldname); - else - filearg[0] = savestr(newname); - } - else if (oldname) - filearg[0] = savestr(oldname); - else if (newname) - filearg[0] = savestr(newname); - else if (indname) - filearg[0] = savestr(indname); - } - if (bestguess) { - free(bestguess); - bestguess = Nullch; - } - if (filearg[0] != Nullch) - bestguess = savestr(filearg[0]); - else if (indtmp != Nullch) - bestguess = fetchname(indtmp, strippath, TRUE); - else { - if (oldtmp != Nullch) - oldname = fetchname(oldtmp, strippath, TRUE); - if (newtmp != Nullch) - newname = fetchname(newtmp, strippath, TRUE); - if (oldname && newname) { - if (strlen(oldname) < strlen(newname)) - bestguess = savestr(oldname); - else - bestguess = savestr(newname); - } - else if (oldname) - bestguess = savestr(oldname); - else if (newname) - bestguess = savestr(newname); - } - if (indtmp != Nullch) - free(indtmp); - if (oldtmp != Nullch) - free(oldtmp); - if (newtmp != Nullch) - free(newtmp); - if (indname != Nullch) - free(indname); - if (oldname != Nullch) - free(oldname); - if (newname != Nullch) - free(newname); - return retval; -} - -/* Remember where this patch ends so we know where to start up again. */ - -void -next_intuit_at(file_pos,file_line) -long file_pos; -long file_line; -{ - p_base = file_pos; - p_bline = file_line; -} - -/* Basically a verbose fseek() to the actual diff listing. */ - -void -skip_to(file_pos,file_line) -long file_pos; -long file_line; -{ - char *ret; - - assert(p_base <= file_pos); - if (verbose && p_base < file_pos) { - Fseek(pfp, p_base, 0); - say1("The text leading up to this was:\n--------------------------\n"); - while (ftell(pfp) < file_pos) { - ret = fgets(buf, sizeof buf, pfp); - assert(ret != Nullch); - say2("|%s", buf); - } - say1("--------------------------\n"); - } - else - Fseek(pfp, file_pos, 0); - p_input_line = file_line - 1; -} - -/* True if there is more of the current diff listing to process. */ - -bool -another_hunk() -{ - Reg1 char *s; - Reg8 char *ret; - Reg2 int context = 0; - - while (p_end >= 0) { - if (p_end == p_efake) - p_end = p_bfake; /* don't free twice */ - else - free(p_line[p_end]); - p_end--; - } - assert(p_end == -1); - p_efake = -1; - - p_max = hunkmax; /* gets reduced when --- found */ - if (diff_type == CONTEXT_DIFF || diff_type == NEW_CONTEXT_DIFF) { - long line_beginning = ftell(pfp); - /* file pos of the current line */ - LINENUM repl_beginning = 0; /* index of --- line */ - Reg4 LINENUM fillcnt = 0; /* #lines of missing ptrn or repl */ - Reg5 LINENUM fillsrc; /* index of first line to copy */ - Reg6 LINENUM filldst; /* index of first missing line */ - bool ptrn_spaces_eaten = FALSE; /* ptrn was slightly misformed */ - Reg9 bool repl_could_be_missing = TRUE; - /* no + or ! lines in this hunk */ - bool repl_missing = FALSE; /* we are now backtracking */ - long repl_backtrack_position = 0; - /* file pos of first repl line */ - LINENUM repl_patch_line; /* input line number for same */ - Reg7 LINENUM ptrn_copiable = 0; - /* # of copiable lines in ptrn */ - - ret = pgets(buf, sizeof buf, pfp); - p_input_line++; - if (ret == Nullch || strnNE(buf, "********", 8)) { - next_intuit_at(line_beginning,p_input_line); - return FALSE; - } - p_context = 100; - p_hunk_beg = p_input_line + 1; - while (p_end < p_max) { - line_beginning = ftell(pfp); - ret = pgets(buf, sizeof buf, pfp); - p_input_line++; - if (ret == Nullch) { - if (p_max - p_end < 4) - Strcpy(buf, " \n"); /* assume blank lines got chopped */ - else { - if (repl_beginning && repl_could_be_missing) { - repl_missing = TRUE; - goto hunk_done; - } - fatal1("Unexpected end of file in patch.\n"); - } - } - p_end++; - assert(p_end < hunkmax); - p_char[p_end] = *buf; - p_line[p_end] = Nullch; - switch (*buf) { - case '*': - if (strnEQ(buf, "********", 8)) { - if (repl_beginning && repl_could_be_missing) { - repl_missing = TRUE; - goto hunk_done; - } - else - fatal2("Unexpected end of hunk at line %ld.\n", - p_input_line); - } - if (p_end != 0) { - if (repl_beginning && repl_could_be_missing) { - repl_missing = TRUE; - goto hunk_done; - } - fatal3("Unexpected *** at line %ld: %s", p_input_line, buf); - } - context = 0; - p_line[p_end] = savestr(buf); - if (out_of_mem) { - p_end--; - return FALSE; - } - for (s=buf; *s && !isdigit(*s); s++) ; - if (!*s) - goto malformed; - p_first = (LINENUM) atol(s); - while (isdigit(*s)) s++; - if (*s == ',') { - for (; *s && !isdigit(*s); s++) ; - if (!*s) - goto malformed; - p_ptrn_lines = ((LINENUM)atol(s)) - p_first + 1; - } - else if (p_first) - p_ptrn_lines = 1; - else { - p_ptrn_lines = 0; - p_first = 1; - } - p_max = p_ptrn_lines + 6; /* we need this much at least */ - while (p_max >= hunkmax) - grow_hunkmax(); - p_max = hunkmax; - break; - case '-': - if (buf[1] == '-') { - if (repl_beginning || - (p_end != p_ptrn_lines + 1 + (p_char[p_end-1] == '\n'))) - { - if (p_end == 1) { - /* `old' lines were omitted - set up to fill */ - /* them in from 'new' context lines. */ - p_end = p_ptrn_lines + 1; - fillsrc = p_end + 1; - filldst = 1; - fillcnt = p_ptrn_lines; - } - else { - if (repl_beginning) { - if (repl_could_be_missing){ - repl_missing = TRUE; - goto hunk_done; - } - fatal3( -"Duplicate \"---\" at line %ld--check line numbers at line %ld.\n", - p_input_line, p_hunk_beg + repl_beginning); - } - else { - fatal4( -"%s \"---\" at line %ld--check line numbers at line %ld.\n", - (p_end <= p_ptrn_lines - ? "Premature" - : "Overdue" ), - p_input_line, p_hunk_beg); - } - } - } - repl_beginning = p_end; - repl_backtrack_position = ftell(pfp); - repl_patch_line = p_input_line; - p_line[p_end] = savestr(buf); - if (out_of_mem) { - p_end--; - return FALSE; - } - p_char[p_end] = '='; - for (s=buf; *s && !isdigit(*s); s++) ; - if (!*s) - goto malformed; - p_newfirst = (LINENUM) atol(s); - while (isdigit(*s)) s++; - if (*s == ',') { - for (; *s && !isdigit(*s); s++) ; - if (!*s) - goto malformed; - p_repl_lines = ((LINENUM)atol(s)) - p_newfirst + 1; - } - else if (p_newfirst) - p_repl_lines = 1; - else { - p_repl_lines = 0; - p_newfirst = 1; - } - p_max = p_repl_lines + p_end; - if (p_max > MAXHUNKSIZE) - fatal4("Hunk too large (%ld lines) at line %ld: %s", - p_max, p_input_line, buf); - while (p_max >= hunkmax) - grow_hunkmax(); - if (p_repl_lines != ptrn_copiable) - repl_could_be_missing = FALSE; - break; - } - goto change_line; - case '+': case '!': - repl_could_be_missing = FALSE; - change_line: - if (!isspace(buf[1]) && buf[1] != '>' && buf[1] != '<' && - repl_beginning && repl_could_be_missing) { - repl_missing = TRUE; - goto hunk_done; - } - if (context > 0) { - if (context < p_context) - p_context = context; - context = -1000; - } - p_line[p_end] = savestr(buf+2); - if (out_of_mem) { - p_end--; - return FALSE; - } - break; - case '\t': case '\n': /* assume the 2 spaces got eaten */ - if (repl_beginning && repl_could_be_missing && - (!ptrn_spaces_eaten || diff_type == NEW_CONTEXT_DIFF) ) { - repl_missing = TRUE; - goto hunk_done; - } - p_line[p_end] = savestr(buf); - if (out_of_mem) { - p_end--; - return FALSE; - } - if (p_end != p_ptrn_lines + 1) { - ptrn_spaces_eaten |= (repl_beginning != 0); - context++; - if (!repl_beginning) - ptrn_copiable++; - p_char[p_end] = ' '; - } - break; - case ' ': - if (!isspace(buf[1]) && - repl_beginning && repl_could_be_missing) { - repl_missing = TRUE; - goto hunk_done; - } - context++; - if (!repl_beginning) - ptrn_copiable++; - p_line[p_end] = savestr(buf+2); - if (out_of_mem) { - p_end--; - return FALSE; - } - break; - default: - if (repl_beginning && repl_could_be_missing) { - repl_missing = TRUE; - goto hunk_done; - } - goto malformed; - } - /* set up p_len for strncmp() so we don't have to */ - /* assume null termination */ - if (p_line[p_end]) - p_len[p_end] = strlen(p_line[p_end]); - else - p_len[p_end] = 0; - } - - hunk_done: - if (p_end >=0 && !repl_beginning) - fatal2("No --- found in patch at line %ld\n", pch_hunk_beg()); - - if (repl_missing) { - - /* reset state back to just after --- */ - p_input_line = repl_patch_line; - for (p_end--; p_end > repl_beginning; p_end--) - free(p_line[p_end]); - Fseek(pfp, repl_backtrack_position, 0); - - /* redundant 'new' context lines were omitted - set */ - /* up to fill them in from the old file context */ - fillsrc = 1; - filldst = repl_beginning+1; - fillcnt = p_repl_lines; - p_end = p_max; - } - - if (diff_type == CONTEXT_DIFF && - (fillcnt || (p_first > 1 && ptrn_copiable > 2*p_context)) ) { - if (verbose) - say1("\ -(Fascinating--this is really a new-style context diff but without the telltale\n\ -extra asterisks on the *** line that usually indicate the new style...)\n"); - diff_type = NEW_CONTEXT_DIFF; - } - - /* if there were omitted context lines, fill them in now */ - if (fillcnt) { - p_bfake = filldst; /* remember where not to free() */ - p_efake = filldst + fillcnt - 1; - while (fillcnt-- > 0) { - while (fillsrc <= p_end && p_char[fillsrc] != ' ') - fillsrc++; - if (fillsrc > p_end) - fatal2("Replacement text or line numbers mangled in hunk at line %ld\n", - p_hunk_beg); - p_line[filldst] = p_line[fillsrc]; - p_char[filldst] = p_char[fillsrc]; - p_len[filldst] = p_len[fillsrc]; - fillsrc++; filldst++; - } - while (fillsrc <= p_end && fillsrc != repl_beginning && - p_char[fillsrc] != ' ') - fillsrc++; -#ifdef DEBUGGING - if (debug & 64) - printf("fillsrc %ld, filldst %ld, rb %ld, e+1 %ld\n", - fillsrc,filldst,repl_beginning,p_end+1); -#endif - assert(fillsrc==p_end+1 || fillsrc==repl_beginning); - assert(filldst==p_end+1 || filldst==repl_beginning); - } - } - else { /* normal diff--fake it up */ - char hunk_type; - Reg3 int i; - LINENUM min, max; - long line_beginning = ftell(pfp); - - p_context = 0; - ret = pgets(buf, sizeof buf, pfp); - p_input_line++; - if (ret == Nullch || !isdigit(*buf)) { - next_intuit_at(line_beginning,p_input_line); - return FALSE; - } - p_first = (LINENUM)atol(buf); - for (s=buf; isdigit(*s); s++) ; - if (*s == ',') { - p_ptrn_lines = (LINENUM)atol(++s) - p_first + 1; - while (isdigit(*s)) s++; - } - else - p_ptrn_lines = (*s != 'a'); - hunk_type = *s; - if (hunk_type == 'a') - p_first++; /* do append rather than insert */ - min = (LINENUM)atol(++s); - for (; isdigit(*s); s++) ; - if (*s == ',') - max = (LINENUM)atol(++s); - else - max = min; - if (hunk_type == 'd') - min++; - p_end = p_ptrn_lines + 1 + max - min + 1; - if (p_end > MAXHUNKSIZE) - fatal4("Hunk too large (%ld lines) at line %ld: %s", - p_end, p_input_line, buf); - while (p_end >= hunkmax) - grow_hunkmax(); - p_newfirst = min; - p_repl_lines = max - min + 1; - Sprintf(buf, "*** %ld,%ld\n", p_first, p_first + p_ptrn_lines - 1); - p_line[0] = savestr(buf); - if (out_of_mem) { - p_end = -1; - return FALSE; - } - p_char[0] = '*'; - for (i=1; i<=p_ptrn_lines; i++) { - ret = pgets(buf, sizeof buf, pfp); - p_input_line++; - if (ret == Nullch) - fatal2("Unexpected end of file in patch at line %ld.\n", - p_input_line); - if (*buf != '<') - fatal2("< expected at line %ld of patch.\n", p_input_line); - p_line[i] = savestr(buf+2); - if (out_of_mem) { - p_end = i-1; - return FALSE; - } - p_len[i] = strlen(p_line[i]); - p_char[i] = '-'; - } - if (hunk_type == 'c') { - ret = pgets(buf, sizeof buf, pfp); - p_input_line++; - if (ret == Nullch) - fatal2("Unexpected end of file in patch at line %ld.\n", - p_input_line); - if (*buf != '-') - fatal2("--- expected at line %ld of patch.\n", p_input_line); - } - Sprintf(buf, "--- %ld,%ld\n", min, max); - p_line[i] = savestr(buf); - if (out_of_mem) { - p_end = i-1; - return FALSE; - } - p_char[i] = '='; - for (i++; i<=p_end; i++) { - ret = pgets(buf, sizeof buf, pfp); - p_input_line++; - if (ret == Nullch) - fatal2("Unexpected end of file in patch at line %ld.\n", - p_input_line); - if (*buf != '>') - fatal2("> expected at line %ld of patch.\n", p_input_line); - p_line[i] = savestr(buf+2); - if (out_of_mem) { - p_end = i-1; - return FALSE; - } - p_len[i] = strlen(p_line[i]); - p_char[i] = '+'; - } - } - if (reverse) /* backwards patch? */ - if (!pch_swap()) - say1("Not enough memory to swap next hunk!\n"); -#ifdef DEBUGGING - if (debug & 2) { - int i; - char special; - - for (i=0; i <= p_end; i++) { - if (i == p_ptrn_lines) - special = '^'; - else - special = ' '; - fprintf(stderr, "%3d %c %c %s", i, p_char[i], special, p_line[i]); - Fflush(stderr); - } - } -#endif - if (p_end+1 < hunkmax) /* paranoia reigns supreme... */ - p_char[p_end+1] = '^'; /* add a stopper for apply_hunk */ - return TRUE; - -malformed: - fatal3("Malformed patch at line %ld: %s", p_input_line, buf); - /* about as informative as "Syntax error" in C */ - return FALSE; /* for lint */ -} - -/* Input a line from the patch file, worrying about indentation. */ - -char * -pgets(bf,sz,fp) -char *bf; -int sz; -FILE *fp; -{ - char *ret = fgets(bf, sz, fp); - Reg1 char *s; - Reg2 int indent = 0; - - if (p_indent && ret != Nullch) { - for (s=buf; indent < p_indent && (*s == ' ' || *s == '\t'); s++) { - if (*s == '\t') - indent += 8 - (indent % 7); - else - indent++; - } - if (buf != s) - Strcpy(buf, s); - } - return ret; -} - -/* Reverse the old and new portions of the current hunk. */ - -bool -pch_swap() -{ - char **tp_line; /* the text of the hunk */ - short *tp_len; /* length of each line */ - char *tp_char; /* +, -, and ! */ - Reg1 LINENUM i; - Reg2 LINENUM n; - bool blankline = FALSE; - Reg3 char *s; - - i = p_first; - p_first = p_newfirst; - p_newfirst = i; - - /* make a scratch copy */ - - tp_line = p_line; - tp_len = p_len; - tp_char = p_char; - p_line = Null(char**); /* force set_hunkmax to allocate again */ - p_len = Null(short*); - p_char = Nullch; - set_hunkmax(); - if (p_line == Null(char**) || p_len == Null(short*) || p_char == Nullch) { -#ifndef lint - if (p_line == Null(char**)) - free((char*)p_line); - p_line = tp_line; - if (p_len == Null(short*)) - free((char*)p_len); - p_len = tp_len; -#endif - if (p_char == Nullch) - free((char*)p_char); - p_char = tp_char; - return FALSE; /* not enough memory to swap hunk! */ - } - - /* now turn the new into the old */ - - i = p_ptrn_lines + 1; - if (tp_char[i] == '\n') { /* account for possible blank line */ - blankline = TRUE; - i++; - } - if (p_efake >= 0) { /* fix non-freeable ptr range */ - n = p_end - i + 1; - if (p_efake > i) - n = -n; - p_efake += n; - p_bfake += n; - } - for (n=0; i <= p_end; i++,n++) { - p_line[n] = tp_line[i]; - p_char[n] = tp_char[i]; - if (p_char[n] == '+') - p_char[n] = '-'; - p_len[n] = tp_len[i]; - } - if (blankline) { - i = p_ptrn_lines + 1; - p_line[n] = tp_line[i]; - p_char[n] = tp_char[i]; - p_len[n] = tp_len[i]; - n++; - } - assert(p_char[0] == '='); - p_char[0] = '*'; - for (s=p_line[0]; *s; s++) - if (*s == '-') - *s = '*'; - - /* now turn the old into the new */ - - assert(tp_char[0] == '*'); - tp_char[0] = '='; - for (s=tp_line[0]; *s; s++) - if (*s == '*') - *s = '-'; - for (i=0; n <= p_end; i++,n++) { - p_line[n] = tp_line[i]; - p_char[n] = tp_char[i]; - if (p_char[n] == '-') - p_char[n] = '+'; - p_len[n] = tp_len[i]; - } - assert(i == p_ptrn_lines + 1); - i = p_ptrn_lines; - p_ptrn_lines = p_repl_lines; - p_repl_lines = i; -#ifndef lint - if (tp_line == Null(char**)) - free((char*)tp_line); - if (tp_len == Null(short*)) - free((char*)tp_len); -#endif - if (tp_char == Nullch) - free((char*)tp_char); - return TRUE; -} - -/* Return the specified line position in the old file of the old context. */ - -LINENUM -pch_first() -{ - return p_first; -} - -/* Return the number of lines of old context. */ - -LINENUM -pch_ptrn_lines() -{ - return p_ptrn_lines; -} - -/* Return the probable line position in the new file of the first line. */ - -LINENUM -pch_newfirst() -{ - return p_newfirst; -} - -/* Return the number of lines in the replacement text including context. */ - -LINENUM -pch_repl_lines() -{ - return p_repl_lines; -} - -/* Return the number of lines in the whole hunk. */ - -LINENUM -pch_end() -{ - return p_end; -} - -/* Return the number of context lines before the first changed line. */ - -LINENUM -pch_context() -{ - return p_context; -} - -/* Return the length of a particular patch line. */ - -short -pch_line_len(line) -LINENUM line; -{ - return p_len[line]; -} - -/* Return the control character (+, -, *, !, etc) for a patch line. */ - -char -pch_char(line) -LINENUM line; -{ - return p_char[line]; -} - -/* Return a pointer to a particular patch line. */ - -char * -pfetch(line) -LINENUM line; -{ - return p_line[line]; -} - -/* Return where in the patch file this hunk began, for error messages. */ - -LINENUM -pch_hunk_beg() -{ - return p_hunk_beg; -} - -/* Apply an ed script by feeding ed itself. */ - -void -do_ed_script() -{ - Reg1 char *t; - Reg2 long beginning_of_this_line; - Reg3 bool this_line_is_command = FALSE; - Reg4 FILE *pipefp; - FILE *popen(); - - if (!skip_rest_of_patch) { - Unlink(TMPOUTNAME); - copy_file(filearg[0], TMPOUTNAME); - if (verbose) - Sprintf(buf, "/bin/ed %s", TMPOUTNAME); - else - Sprintf(buf, "/bin/ed - %s", TMPOUTNAME); - pipefp = popen(buf, "w"); - } - for (;;) { - beginning_of_this_line = ftell(pfp); - if (pgets(buf, sizeof buf, pfp) == Nullch) { - next_intuit_at(beginning_of_this_line,p_input_line); - break; - } - p_input_line++; - for (t=buf; isdigit(*t) || *t == ','; t++) ; - this_line_is_command = (isdigit(*buf) && - (*t == 'd' || *t == 'c' || *t == 'a') ); - if (this_line_is_command) { - if (!skip_rest_of_patch) - fputs(buf, pipefp); - if (*t != 'd') { - while (pgets(buf, sizeof buf, pfp) != Nullch) { - p_input_line++; - if (!skip_rest_of_patch) - fputs(buf, pipefp); - if (strEQ(buf, ".\n")) - break; - } - } - } - else { - next_intuit_at(beginning_of_this_line,p_input_line); - break; - } - } - if (skip_rest_of_patch) - return; - fprintf(pipefp, "w\n"); - fprintf(pipefp, "q\n"); - Fflush(pipefp); - Pclose(pipefp); - ignore_signals(); - if (move_file(TMPOUTNAME, outname) < 0) { - toutkeep = TRUE; - chmod(TMPOUTNAME, filemode); - } - else - chmod(outname, filemode); - set_signals(); -} diff --git a/usr.bin/patch/pch.h b/usr.bin/patch/pch.h deleted file mode 100644 index 97a5b28..0000000 --- a/usr.bin/patch/pch.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $Header: pch.h,v 2.0.1.1 87/01/30 22:47:16 lwall Exp $ - * - * $Log: pch.h,v $ - * Revision 2.0.1.1 87/01/30 22:47:16 lwall - * Added do_ed_script(). - * - * Revision 2.0 86/09/17 15:39:57 lwall - * Baseline for netwide release. - * - */ - -EXT FILE *pfp INIT(Nullfp); /* patch file pointer */ - -void re_patch(); -void open_patch_file(); -void set_hunkmax(); -void grow_hunkmax(); -bool there_is_another_patch(); -int intuit_diff_type(); -void next_intuit_at(); -void skip_to(); -bool another_hunk(); -bool pch_swap(); -char *pfetch(); -short pch_line_len(); -LINENUM pch_first(); -LINENUM pch_ptrn_lines(); -LINENUM pch_newfirst(); -LINENUM pch_repl_lines(); -LINENUM pch_end(); -LINENUM pch_context(); -LINENUM pch_hunk_beg(); -char pch_char(); -char *pfetch(); -char *pgets(); -void do_ed_script(); diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c deleted file mode 100644 index 5582d18..0000000 --- a/usr.bin/patch/util.c +++ /dev/null @@ -1,339 +0,0 @@ -#include "EXTERN.h" -#include "common.h" -#include "INTERN.h" -#include "util.h" - -/* Rename a file, copying it if necessary. */ - -int -move_file(from,to) -char *from, *to; -{ - char bakname[512]; - Reg1 char *s; - Reg2 int i; - Reg3 int fromfd; - - /* to stdout? */ - - if (strEQ(to, "-")) { -#ifdef DEBUGGING - if (debug & 4) - say2("Moving %s to stdout.\n", from); -#endif - fromfd = open(from, 0); - if (fromfd < 0) - fatal2("patch: internal error, can't reopen %s\n", from); - while ((i=read(fromfd, buf, sizeof buf)) > 0) - if (write(1, buf, i) != 1) - fatal1("patch: write failed\n"); - Close(fromfd); - return 0; - } - - Strcpy(bakname, to); - Strcat(bakname, origext?origext:ORIGEXT); - if (stat(to, &filestat) >= 0) { /* output file exists */ - dev_t to_device = filestat.st_dev; - ino_t to_inode = filestat.st_ino; - char *simplename = bakname; - - for (s=bakname; *s; s++) { - if (*s == '/') - simplename = s+1; - } - /* find a backup name that is not the same file */ - while (stat(bakname, &filestat) >= 0 && - to_device == filestat.st_dev && to_inode == filestat.st_ino) { - for (s=simplename; *s && !islower(*s); s++) ; - if (*s) - *s = toupper(*s); - else - Strcpy(simplename, simplename+1); - } - while (unlink(bakname) >= 0) ; /* while() is for benefit of Eunice */ -#ifdef DEBUGGING - if (debug & 4) - say3("Moving %s to %s.\n", to, bakname); -#endif - if (link(to, bakname) < 0) { - say3("patch: can't backup %s, output is in %s\n", - to, from); - return -1; - } - while (unlink(to) >= 0) ; - } -#ifdef DEBUGGING - if (debug & 4) - say3("Moving %s to %s.\n", from, to); -#endif - if (link(from, to) < 0) { /* different file system? */ - Reg4 int tofd; - - tofd = creat(to, 0666); - if (tofd < 0) { - say3("patch: can't create %s, output is in %s.\n", - to, from); - return -1; - } - fromfd = open(from, 0); - if (fromfd < 0) - fatal2("patch: internal error, can't reopen %s\n", from); - while ((i=read(fromfd, buf, sizeof buf)) > 0) - if (write(tofd, buf, i) != i) - fatal1("patch: write failed\n"); - Close(fromfd); - Close(tofd); - } - Unlink(from); - return 0; -} - -/* Copy a file. */ - -void -copy_file(from,to) -char *from, *to; -{ - Reg3 int tofd; - Reg2 int fromfd; - Reg1 int i; - - tofd = creat(to, 0666); - if (tofd < 0) - fatal2("patch: can't create %s.\n", to); - fromfd = open(from, 0); - if (fromfd < 0) - fatal2("patch: internal error, can't reopen %s\n", from); - while ((i=read(fromfd, buf, sizeof buf)) > 0) - if (write(tofd, buf, i) != i) - fatal2("patch: write (%s) failed\n", to); - Close(fromfd); - Close(tofd); -} - -/* Allocate a unique area for a string. */ - -char * -savestr(s) -Reg1 char *s; -{ - Reg3 char *rv; - Reg2 char *t; - - if (!s) - s = "Oops"; - t = s; - while (*t++); - rv = malloc((MEM) (t - s)); - if (rv == Nullch) { - if (using_plan_a) - out_of_mem = TRUE; - else - fatal1("patch: out of memory (savestr)\n"); - } - else { - t = rv; - while (*t++ = *s++); - } - return rv; -} - -#if defined(lint) && defined(CANVARARG) - -/*VARARGS ARGSUSED*/ -say(pat) char *pat; { ; } -/*VARARGS ARGSUSED*/ -fatal(pat) char *pat; { ; } -/*VARARGS ARGSUSED*/ -ask(pat) char *pat; { ; } - -#else - -/* Vanilla terminal output (buffered). */ - -void -say(pat,arg1,arg2,arg3) -char *pat; -int arg1,arg2,arg3; -{ - fprintf(stderr, pat, arg1, arg2, arg3); - Fflush(stderr); -} - -/* Terminal output, pun intended. */ - -void /* very void */ -fatal(pat,arg1,arg2,arg3) -char *pat; -int arg1,arg2,arg3; -{ - void my_exit(); - - say(pat, arg1, arg2, arg3); - my_exit(1); -} - -/* Get a response from the user, somehow or other. */ - -void -ask(pat,arg1,arg2,arg3) -char *pat; -int arg1,arg2,arg3; -{ - int ttyfd; - int r; - bool tty2 = isatty(2); - - Sprintf(buf, pat, arg1, arg2, arg3); - Fflush(stderr); - write(2, buf, strlen(buf)); - if (tty2) { /* might be redirected to a file */ - r = read(2, buf, sizeof buf); - } - else if (isatty(1)) { /* this may be new file output */ - Fflush(stdout); - write(1, buf, strlen(buf)); - r = read(1, buf, sizeof buf); - } - else if ((ttyfd = open("/dev/tty", 2)) >= 0 && isatty(ttyfd)) { - /* might be deleted or unwriteable */ - write(ttyfd, buf, strlen(buf)); - r = read(ttyfd, buf, sizeof buf); - Close(ttyfd); - } - else if (isatty(0)) { /* this is probably patch input */ - Fflush(stdin); - write(0, buf, strlen(buf)); - r = read(0, buf, sizeof buf); - } - else { /* no terminal at all--default it */ - buf[0] = '\n'; - r = 1; - } - if (r <= 0) - buf[0] = 0; - else - buf[r] = '\0'; - if (!tty2) - say1(buf); -} -#endif lint - -/* How to handle certain events when not in a critical region. */ - -void -set_signals() -{ - void my_exit(); - -#ifndef lint - if (signal(SIGHUP, SIG_IGN) != SIG_IGN) - Signal(SIGHUP, my_exit); - if (signal(SIGINT, SIG_IGN) != SIG_IGN) - Signal(SIGINT, my_exit); -#endif -} - -/* How to handle certain events when in a critical region. */ - -void -ignore_signals() -{ -#ifndef lint - Signal(SIGHUP, SIG_IGN); - Signal(SIGINT, SIG_IGN); -#endif -} - -/* Make sure we'll have the directories to create a file. */ - -void -makedirs(filename,striplast) -Reg1 char *filename; -bool striplast; -{ - char tmpbuf[256]; - Reg2 char *s = tmpbuf; - char *dirv[20]; - Reg3 int i; - Reg4 int dirvp = 0; - - while (*filename) { - if (*filename == '/') { - filename++; - dirv[dirvp++] = s; - *s++ = '\0'; - } - else { - *s++ = *filename++; - } - } - *s = '\0'; - dirv[dirvp] = s; - if (striplast) - dirvp--; - if (dirvp < 0) - return; - strcpy(buf, "mkdir"); - s = buf; - for (i=0; i<=dirvp; i++) { - while (*s) s++; - *s++ = ' '; - strcpy(s, tmpbuf); - *dirv[i] = '/'; - } - system(buf); -} - -/* Make filenames more reasonable. */ - -char * -fetchname(at,strip_leading,assume_exists) -char *at; -int strip_leading; -int assume_exists; -{ - char *s; - char *name; - Reg1 char *t; - char tmpbuf[200]; - - if (!at) - return Nullch; - s = savestr(at); - for (t=s; isspace(*t); t++) ; - name = t; -#ifdef DEBUGGING - if (debug & 128) - say4("fetchname %s %d %d\n",name,strip_leading,assume_exists); -#endif - if (strnEQ(name, "/dev/null", 9)) /* so files can be created by diffing */ - return Nullch; /* against /dev/null. */ - for (; *t && !isspace(*t); t++) - if (*t == '/') - if (--strip_leading >= 0) - name = t+1; - *t = '\0'; - if (name != s && *s != '/') { - name[-1] = '\0'; - if (stat(s, &filestat) && filestat.st_mode & S_IFDIR) { - name[-1] = '/'; - name=s; - } - } - name = savestr(name); - Sprintf(tmpbuf, "RCS/%s", name); - free(s); - if (stat(name, &filestat) < 0 && !assume_exists) { - Strcat(tmpbuf, RCSSUFFIX); - if (stat(tmpbuf, &filestat) < 0 && stat(tmpbuf+4, &filestat) < 0) { - Sprintf(tmpbuf, "SCCS/%s%s", SCCSPREFIX, name); - if (stat(tmpbuf, &filestat) < 0 && stat(tmpbuf+5, &filestat) < 0) { - free(name); - name = Nullch; - } - } - } - return name; -} diff --git a/usr.bin/patch/util.h b/usr.bin/patch/util.h deleted file mode 100644 index 9896c63..0000000 --- a/usr.bin/patch/util.h +++ /dev/null @@ -1,74 +0,0 @@ -/* $Header: util.h,v 2.0 86/09/17 15:40:06 lwall Exp $ - * - * $Log: util.h,v $ - * Revision 2.0 86/09/17 15:40:06 lwall - * Baseline for netwide release. - * - */ - -/* and for those machine that can't handle a variable argument list */ - -#ifdef CANVARARG - -#define say1 say -#define say2 say -#define say3 say -#define say4 say -#define ask1 ask -#define ask2 ask -#define ask3 ask -#define ask4 ask -#define fatal1 fatal -#define fatal2 fatal -#define fatal3 fatal -#define fatal4 fatal - -#else /* hope they allow multi-line macro actual arguments */ - -#ifdef lint - -#define say1(a) say(a, 0, 0, 0) -#define say2(a,b) say(a, (b)==(b), 0, 0) -#define say3(a,b,c) say(a, (b)==(b), (c)==(c), 0) -#define say4(a,b,c,d) say(a, (b)==(b), (c)==(c), (d)==(d)) -#define ask1(a) ask(a, 0, 0, 0) -#define ask2(a,b) ask(a, (b)==(b), 0, 0) -#define ask3(a,b,c) ask(a, (b)==(b), (c)==(c), 0) -#define ask4(a,b,c,d) ask(a, (b)==(b), (c)==(c), (d)==(d)) -#define fatal1(a) fatal(a, 0, 0, 0) -#define fatal2(a,b) fatal(a, (b)==(b), 0, 0) -#define fatal3(a,b,c) fatal(a, (b)==(b), (c)==(c), 0) -#define fatal4(a,b,c,d) fatal(a, (b)==(b), (c)==(c), (d)==(d)) - -#else /* lint */ - /* if this doesn't work, try defining CANVARARG above */ -#define say1(a) say(a, Nullch, Nullch, Nullch) -#define say2(a,b) say(a, b, Nullch, Nullch) -#define say3(a,b,c) say(a, b, c, Nullch) -#define say4 say -#define ask1(a) ask(a, Nullch, Nullch, Nullch) -#define ask2(a,b) ask(a, b, Nullch, Nullch) -#define ask3(a,b,c) ask(a, b, c, Nullch) -#define ask4 ask -#define fatal1(a) fatal(a, Nullch, Nullch, Nullch) -#define fatal2(a,b) fatal(a, b, Nullch, Nullch) -#define fatal3(a,b,c) fatal(a, b, c, Nullch) -#define fatal4 fatal - -#endif /* lint */ - -/* if neither of the above work, join all multi-line macro calls. */ -#endif - -EXT char serrbuf[BUFSIZ]; /* buffer for stderr */ - -char *fetchname(); -int move_file(); -void copy_file(); -void say(); -void fatal(); -void ask(); -char *savestr(); -void set_signals(); -void ignore_signals(); -void makedirs(); diff --git a/usr.bin/patch/version.c b/usr.bin/patch/version.c deleted file mode 100644 index 17dfb81..0000000 --- a/usr.bin/patch/version.c +++ /dev/null @@ -1,28 +0,0 @@ -/* $Header: version.c,v 2.0 86/09/17 15:40:11 lwall Exp $ - * - * $Log: version.c,v $ - * Revision 2.0 86/09/17 15:40:11 lwall - * Baseline for netwide release. - * - */ - -#include "EXTERN.h" -#include "common.h" -#include "util.h" -#include "INTERN.h" -#include "patchlevel.h" -#include "version.h" - -/* Print out the version number and die. */ - -void -version() -{ - extern char rcsid[]; - -#ifdef lint - rcsid[0] = rcsid[0]; -#else - fatal3("%s\nPatch level: %d\n", rcsid, PATCHLEVEL); -#endif -} diff --git a/usr.bin/patch/version.h b/usr.bin/patch/version.h deleted file mode 100644 index 08fe68d..0000000 --- a/usr.bin/patch/version.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $Header: version.h,v 2.0 86/09/17 15:40:14 lwall Exp $ - * - * $Log: version.h,v $ - * Revision 2.0 86/09/17 15:40:14 lwall - * Baseline for netwide release. - * - */ - -void version(); diff --git a/usr.bin/ranlib/ranlib.5.5 b/usr.bin/ranlib/ranlib.5.5 deleted file mode 100644 index e953c51..0000000 --- a/usr.bin/ranlib/ranlib.5.5 +++ /dev/null @@ -1,70 +0,0 @@ -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ranlib.5.5 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt RANLIB 5 -.Os -.Sh NAME -.Nm ranlib -.Nd archive (library) table-of-contents format -.Sh SYNOPSIS -.Fd #include -.Sh DESCRIPTION -The archive table-of-contents command -.Nm ranlib -creates a table of contents for archives, containing object files, to -be used by the link-editor -.Xr ld 1 . -It operates on archives created with the utility -.Xr ar 1 . -.Pp -The -.Nm Ranlib -function -prepends a new file to the archive which has three separate parts. -The first part is a standard archive header, which has a special name -field, "__.SYMDEF". -.Pp -The second part is a ``long'' followed by a list of ranlib structures. -The long is the size, in bytes, of the list of ranlib structures. -Each of the ranlib structures consists of a zero based offset into the -next section (a string table of symbols) and an offset from the beginning -of the archive to the start of the archive file which defines the symbol. -The actual number of ranlib structures is this number divided by the size -of an individual ranlib structure. -.Pp -The third part is a ``long'' followed by a string table. -The long is the size, in bytes of the string table. -.Sh SEE ALSO -.Xr ar 1 , -.Xr ranlib 1 diff --git a/usr.bin/rlogin/des_rw.c b/usr.bin/rlogin/des_rw.c deleted file mode 100644 index dbe47f0..0000000 --- a/usr.bin/rlogin/des_rw.c +++ /dev/null @@ -1,203 +0,0 @@ -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)des_rw.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef CRYPT -#ifdef KERBEROS -#include - -#include -#include - -#include -#include -#include -#include - -static unsigned char des_inbuf[10240], storage[10240], *store_ptr; -static bit_64 *key; -static u_char *key_schedule; - -/* XXX these should be in a kerberos include file */ -int krb_net_read __P((int, char *, int)); -#ifdef notdef -/* XXX too hard to make this work */ -int des_pcbc_encrypt __P((des_cblock *, des_cblock *, long, - des_key_schedule, des_cblock *, int)); -#endif - -/* - * NB: These routines will not function properly if NBIO - * is set - */ - -/* - * des_set_key - * - * Set des encryption/decryption key for use by the des_read and - * des_write routines - * - * The inkey parameter is actually the DES initial vector, - * and the insched is the DES Key unwrapped for faster decryption - */ - -void -des_set_key(inkey, insched) - bit_64 *inkey; - u_char *insched; -{ - key = inkey; - key_schedule = insched; -} - -void -des_clear_key() -{ - bzero((char *) key, sizeof(C_Block)); - bzero((char *) key_schedule, sizeof(Key_schedule)); -} - - -int -des_read(fd, buf, len) - int fd; - register char *buf; - int len; -{ - int nreturned = 0; - long net_len, rd_len; - int nstored = 0; - - if (nstored >= len) { - (void) bcopy(store_ptr, buf, len); - store_ptr += len; - nstored -= len; - return(len); - } else if (nstored) { - (void) bcopy(store_ptr, buf, nstored); - nreturned += nstored; - buf += nstored; - len -= nstored; - nstored = 0; - } - - if (krb_net_read(fd, (char *)&net_len, sizeof(net_len)) != - sizeof(net_len)) { - /* XXX can't read enough, pipe - must have closed */ - return(0); - } - net_len = ntohl(net_len); - if (net_len <= 0 || net_len > sizeof(des_inbuf)) { - /* preposterous length; assume out-of-sync; only - recourse is to close connection, so return 0 */ - return(0); - } - /* the writer tells us how much real data we are getting, but - we need to read the pad bytes (8-byte boundary) */ - rd_len = roundup(net_len, 8); - if (krb_net_read(fd, (char *)des_inbuf, rd_len) != rd_len) { - /* pipe must have closed, return 0 */ - return(0); - } - (void) des_pcbc_encrypt(des_inbuf, /* inbuf */ - storage, /* outbuf */ - net_len, /* length */ - key_schedule, /* DES key */ - key, /* IV */ - DECRYPT); /* direction */ - - if(net_len < 8) - store_ptr = storage + 8 - net_len; - else - store_ptr = storage; - - nstored = net_len; - if (nstored > len) { - (void) bcopy(store_ptr, buf, len); - nreturned += len; - store_ptr += len; - nstored -= len; - } else { - (void) bcopy(store_ptr, buf, nstored); - nreturned += nstored; - nstored = 0; - } - - return(nreturned); -} - -static unsigned char des_outbuf[10240]; /* > longest write */ - -int -des_write(fd, buf, len) - int fd; - char *buf; - int len; -{ - static int seeded = 0; - static char garbage_buf[8]; - long net_len, garbage; - - if(len < 8) { - if(!seeded) { - seeded = 1; - srandom((int) time((long *)0)); - } - garbage = random(); - /* insert random garbage */ - (void) bcopy(&garbage, garbage_buf, MIN(sizeof(long),8)); - /* this "right-justifies" the data in the buffer */ - (void) bcopy(buf, garbage_buf + 8 - len, len); - } - /* pcbc_encrypt outputs in 8-byte (64 bit) increments */ - - (void) des_pcbc_encrypt((len < 8) ? garbage_buf : buf, - des_outbuf, - (len < 8) ? 8 : len, - key_schedule, /* DES key */ - key, /* IV */ - ENCRYPT); - - /* tell the other end the real amount, but send an 8-byte padded - packet */ - net_len = htonl(len); - (void) write(fd, &net_len, sizeof(net_len)); - (void) write(fd, des_outbuf, roundup(len,8)); - return(len); -} -#endif /* KERBEROS */ -#endif /* CRYPT */ diff --git a/usr.bin/sccs/Makefile b/usr.bin/sccs/Makefile deleted file mode 100644 index 0ee9d1b..0000000 --- a/usr.bin/sccs/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= sccs - -.include diff --git a/usr.bin/sccs/PSD.doc/Makefile b/usr.bin/sccs/PSD.doc/Makefile deleted file mode 100644 index 4d2ba7f..0000000 --- a/usr.bin/sccs/PSD.doc/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/8/93 - -DIR= psd/14.sccs -SRCS= sccs.me -MACROS= -me - -paper.ps: ${SRCS} - ${ROFF} ${SRCS} > ${.TARGET} - -.include diff --git a/usr.bin/sccs/PSD.doc/sccs.me b/usr.bin/sccs/PSD.doc/sccs.me deleted file mode 100644 index ab598c2..0000000 --- a/usr.bin/sccs/PSD.doc/sccs.me +++ /dev/null @@ -1,1608 +0,0 @@ -.\" Copyright (c) 1986, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)sccs.me 8.1 (Berkeley) 6/8/93 -.\" -.eh '\fRPSD:14-%\fP''\fRAn Introduction to the Source Code Control System\fP' -.oh '\fRAn Introduction to the Source Code Control System\fP''\fRPSD:14-%\fP' -.ds S \s-1SCCS\s0 -.ds I \s-1SID\s0 -.nr bi 8n -.ev 1 \" only for keeps -.ss 16 -.ev -.\".he '\*S Introduction''%' -.+c -.(l C -.sz 14 -.b -An Introduction to the -Source Code Control System -.sz -.r -.sp -Eric Allman -.i "Project Ingres" -.i "University of California at Berkeley" -.)l -.sp 3 -.pp -.(f -This is version 1.21 of this document. -It was last modified on 12/5/80. -.)f -This document gives a quick introduction -to using the Source Code Control System -(\*S). -The presentation is geared to programmers -who are more concerned with -what -to do to get a task done -rather than how it works; -for this reason some of the examples -are not well explained. -For details of what the magic options do, -see the section on -.q "Further Information" . -.(l F -This is a working document. -Please send any comments or suggestions -to eric@Berkeley.Edu. -.)l -.sh 1 "Introduction" -.pp -\*S is a source management system. -Such a system maintains a record of versions of a system; -a record is kept with each set of changes -of what the changes are, -why they were made, -and who made them and when. -Old versions can be recovered, -and different versions can be maintained simultaneously. -In projects with more than one person, -\*S will insure that two people are not -editing the same file at the same time. -.pp -All versions of your program, -plus the log and other information, -is kept in a file called the -.q "s-file" . -There are three major operations -that can be performed on the s-file: -.np -Get a file for compilation (not for editing). -This operation retrieves a version of the file -from the s-file. -By default, the latest version is retrieved. -This file is intended for compilation, printing, or whatever; -it is specifically NOT intended to be edited -or changed in any way; -any changes made to a file retrieved -in this way will probably be lost. -.np -Get a file for editing. -This operation also retrieves a version of the file -from the s-file, -but this file is intended to be edited and then -incorporated back into the s-file. -Only one person may be editing a file at one time. -.np -Merge a file back into the s-file. -This is the companion operation to (2). -A new version number is assigned, -and comments are saved explaining why this change was made. -.sh 1 "Learning the Lingo" -.pp -There are a number of terms that are worth learning -before we go any farther. -.sh 2 "S-file" -.pp -The s-file -is a single file that holds all the different versions -of your file. -The s-file is stored in -differential format; -.i i.e. , -only the differences between versions are stored, -rather than the entire text of the new version. -This saves disk space -and allows selective changes to be removed later. -Also included in the s-file -is some header information for each version, -including the comments given by the person who -created the version explaining why the changes were made. -.sh 2 "Deltas" -.pp -Each set of changes to the s-file -(which is approximately [but not exactly!] equivalent -to a version of the file) -is called a -.i delta . -Although technically a delta only includes the -.i changes -made, -in practice -it is usual for -each delta to be made with respect to -all the deltas that have occurred before\**. -.(f -\**This matches normal usage, where the previous changes are not saved -at all, -so all changes are automatically based on all other changes -that have happened through history. -.)f -However, -it is possible to get a version of the file -that has selected deltas removed out of the middle -of the list of changes \*- -equivalent to removing your changes later. -.sh 2 "\*I's (or, version numbers)" -.pp -A \*I -(\*S Id) -is a number that represents a delta. -This is normally a two-part number -consisting of a -.q release -number and a -.q level -number. -Normally the release number stays the same, -however, -it is possible to move into a new release -if some major change is being made. -.pp -Since all past deltas are normally applied, -the \*I of the final delta applied -can be used to represent a version number of the file -as a whole. -.sh 2 "Id keywords" -.pp -When you get a version of a file -with intent to compile and install it -(\c -.i i.e. , -something other than edit it), -some special keywords are expanded inline -by \*S. -These -.i "Id Keywords" -can be used to include the current version number -or other information into the file. -All id keywords are of the form -.b % \c -.i x \c -.b % , -where -.i x -is an upper case letter. -For example, -.b %\&I\&% -is the \*I of the latest delta applied, -.b %\&W\&% -includes the module name, -\*I, -and a mark that makes it findable by a program, -and -.b %\&G\&% -is the date of the latest delta applied. -There are many others, -most of which are of dubious usefulness. -.pp -When you get a file for editing, -the id keywords are not expanded; -this is so that after you put them back in to the s-file, -they will be expanded automatically on each new version. -But notice: if you were to get them -expanded accidently, -then your file would appear to be the same version -forever more, -which would of course defeat the purpose. -Also, -if you should install a version of the program -without expanding the id keywords, -it will be impossible to tell what version it is -(since all it will have is -.q %\&W\&% -or whatever). -.sh 1 "Creating \*S Files" -.pp -To put source files -into -\*S -format, run the following shell script from csh: -.(b -mkdir SCCS save -foreach i (*.[ch]) - sccs admin \-i$i $i - mv $i save/$i -end -.)b -This will put the named files -into s-files -in the subdirectory -.q SCCS -The files will be removed from the current directory -and hidden away in the directory -.q save , -so the next thing you will probably want to do -is to get all the files -(described below). -When you are convinced that -\*S has correctly created the s-files, -you should remove the directory -.q save . -.pp -If you want to have id keywords in the files, -it is best to put them in before you create the s-files. -If you do not, -.i admin -will print -.q "No Id Keywords (cm7)" , -which is a warning message only. -.sh 1 "Getting Files for Compilation" -.pp -To get a copy of the latest version -of a file, -run -.(b -sccs get prog.c -.)b -\*S will respond: -.(b -1.1 -87 lines -.)b -meaning that version 1.1 was retrieved\** -.(f -\**Actually, -the \*I of the final delta applied was 1.1. -.)f -and that it has 87 lines. -The file -.i prog.c -will be created -in the current directory. -The file will be read-only -to remind you that you are not -supposed to change it. -.pp -This copy of the file -should not be changed, -since \*S is unable -to merge the changes -back into the s-file. -If you do make changes, -they will be lost the next time -someone does a -.i get . -.sh 1 "Changing Files (or, Creating Deltas)" -.sh 2 "Getting a copy to edit" -.pp -To edit a source file, -you must first get it, -requesting permission to edit it\**: -.(f -\**The -.q "edit" -command is equivalent to using the \-e -flag to -.i "get" , -as: -.(l -sccs get \-e prog.c -.)l -Keep this in mind when reading other documentation. -.)f -.(b -sccs edit prog.c -.)b -The response will be the same as with -.i get -except that it will also say: -.(b -New delta 1.2 -.)b -You then edit it, -using a standard text editor: -.(b -vi prog.c -.)b -.sh 2 "Merging the changes back into the s-file" -.pp -When the desired changes are made, -you can put your changes into the -\*S -file using the -.i delta -command: -.(b -sccs delta prog.c -.)b -.pp -Delta will prompt you for -.q "comments?" -before it merges the changes in. -At this prompt you should type a one-line description -of what the changes mean -(more lines can be entered by ending each line -except the last with a backslash\**). -.(f -\**Yes, this is a stupid default. -.)f -.i Delta -will then type: -.(b -1.2 -5 inserted -3 deleted -84 unchanged -.)b -saying that delta 1.2 was created, -and it inserted five lines, -removed three lines, -and left 84 lines unchanged\**. -.(f -\**Changes to a line are counted as a line deleted -and a line inserted. -.)f -The -.i prog.c -file will be removed; -it can be retrieved -using -.i get . -.sh 2 "When to make deltas" -.pp -It is probably unwise to make a delta -before every recompilation or test; -otherwise, -you tend to get a lot of deltas with comments like -.q "fixed compilation problem in previous delta" -or -.q "fixed botch in 1.3" . -However, -it is very important to delta everything -before installing a module for general use. -A good technique is to edit the files you need, -make all necessary changes and tests, -compiling and editing as often as necessary -without making deltas. -When you are satisfied that you have a working version, -delta everything being edited, -re-get them, -and recompile everything. -.sh 2 "What's going on: the info command" -.pp -To find out what files where being edited, -you can use: -.(b -sccs info -.)b -to print out all the files being edited -and other information such as the name of the user -who did the edit. -Also, -the command: -.(b -sccs check -.)b -is nearly equivalent to the -.i info -command, -except that it is silent if nothing is being edited, -and returns non-zero exit status if anything is being edited; -it can be used in an -.q install -entry in a makefile -to abort the install -if anything has not been properly deltaed. -.pp -If you know that everything being edited should be deltaed, -you can use: -.(b -sccs delta \`sccs tell\` -.)b -The -.i tell -command is similar to -.i info -except that only the names of files being edited -are output, -one per line. -.pp -All of these commands take a -.b \-b -flag -to ignore -.q branches -(alternate versions, described later) -and the -.b \-u -flag to only give files being edited by you. -The -.b \-u -flag takes an optional -.i user -argument, -giving only files being edited by that user. -For example, -.(b -sccs info \-ujohn -.)b -gives a listing of files being edited by john. -.sh 2 "ID keywords" -.pp -Id keywords can be inserted into your file -that will be expanded automatically by -.i get . -For example, -a line such as: -.(b -static char SccsId[] = "%\&W\&%\et%\&G\&%"; -.)b -will be replaced with something like: -.(b -static char SccsId[] = "@\&(#)prog.c 1.2 08/29/80"; -.)b -This tells you -the name and version -of the source file -and the time the delta was created. -The string -.q "@\&(#)" -is a special string -which signals the beginning -of an -\*S -Id keyword. -.sh 3 "The what command" -.pp -To find out what version of a program -is being run, -use: -.(b -sccs what prog.c /usr/bin/prog -.)b -which will print all strings -it finds that -begin with -.q "@\&(#)" . -This works on all types of files, -including binaries and libraries. -For example, the above command will output something like: -.(b -prog.c: - prog.c 1.2 08/29/80 -/usr/bin/prog: - prog.c 1.1 02/05/79 -.)b -From this I can see -that the source that I have in prog.c -will not compile into the same version -as the binary in /usr/bin/prog. -.sh 3 "Where to put id keywords" -.pp -ID keywords can be inserted anywhere, -including in comments, -but -Id Keywords that are compiled into the object module -are especially useful, -since it lets you find out what version of -the object is being run, -as well as the source. -However, -there is a cost: -data space is used up to store -the keywords, -and on small address space machines -this may be prohibitive. -.pp -When you put id keywords into header files, -it is important that you assign them to different variables. -For example, you might use: -.(b -static char AccessSid[] = "%\&W\&% %\&G\&%"; -.)b -in the file -.i access.h -and: -.(b -static char OpsysSid[] = "%\&W\&% %\&G\&%"; -.)b -in the file -.i opsys.h . -Otherwise, -you will get compilation errors because -.q SccsId -is redefined. -The problem with this is that if the header file -is included by many modules that are loaded together, -the version number of that header file is included -in the object module many times; -you may find it more to your taste -to put id keywords in header files -in comments. -.sh 2 "Keeping \*I's consistent across files" -.pp -With some care, -it is possible to keep the \*I's consistent -in multi-file systems. -The trick here is to always -.i edit -all files -at once. -The changes can then be made -to whatever files are necessary -and then all files -(even those not changed) -are redeltaed. -This can be done fairly easily -by just specifying the name of the directory -that the \*S files are in: -.(b -sccs edit SCCS -.)b -which will -.i edit -all files in that directory. -To make the delta, use: -.(b -sccs delta SCCS -.)b -You will be prompted for comments only once. -.sh 2 "Creating new releases" -.pp -When you want to create a new release -of a program, -you can specify the release number you want to create -on the -.i edit -command. -For example: -.(b -sccs edit \-r2 prog.c -.)b -will cause the next delta to be in release two -(that is, -it will be numbered 2.1). -Future deltas will automatically be in release two. -To change the release number -of an entire system, -use: -.(b -sccs edit \-r2 SCCS -.)b -.sh 1 "Restoring Old Versions" -.sh 2 "Reverting to old versions" -.pp -Suppose that after delta 1.2 -was stable -you made and released a delta 1.3. -But this introduced a bug, -so you made a delta 1.4 to correct it. -But 1.4 was still buggy, -and you decided you wanted to go back -to the old version. -You could -revert to delta 1.2 -by choosing the \*I in a get: -.(b -sccs get \-r1.2 prog.c -.)b -This will produce a version of -.i prog.c -that is delta 1.2 -that can be reinstalled so that work can proceed. -.pp -In some cases you don't know -what the \*I of the delta you want is. -However, -you can revert to the version of the program -that was running as of a certain date -by using the -.b \-c -(cutoff) flag. -For example, -.(b -sccs get \-c800722120000 prog.c -.)b -will retrieve whatever version was current -as of July 22, 1980 -at 12:00 noon. -Trailing components can be stripped off -(defaulting to their highest legal value), -and punctuation can be inserted in the obvious -places; -for example, -the above line could be equivalently stated: -.(b -sccs get \-c"80/07/22 12:00:00" prog.c -.)b -.sh 2 "Selectively deleting old deltas" -.pp -Suppose that you later decided -that you liked the changes in delta 1.4, -but that delta 1.3 should be removed. -You could do this by -.i excluding -delta 1.3: -.(b -sccs edit \-x1.3 prog.c -.)b -When delta 1.5 is made, -it will include the changes made -in delta 1.4, -but will exclude the changes made -in delta 1.3. -You can exclude a range of deltas -using a dash. -For example, -if you want to get rid of 1.3 and 1.4 -you can use: -.(b -sccs edit \-x1.3\-1.4 prog.c -.)b -which will exclude all deltas from 1.3 to 1.4. -Alternatively, -.(b -sccs edit \-x1.3\-1 prog.c -.)b -will exclude a range of deltas -from 1.3 to the current highest delta in release 1. -.pp -In certain cases when using -.b \-x -(or -.b \-i ; -see below) -there will be conflicts -between versions; -for example, it may be necessary -to both include and delete -a particular line. -If this happens, -\*S always prints out a message -telling the range of lines effected; -these lines should then be examined very carefully -to see if the version \*S got -is ok. -.pp -Since each delta -(in the sense of -.q "a set of changes" ) -can be excluded at will, -that this makes it most useful -to put each semantically distinct change -into its own delta. -.sh 1 "Auditing Changes" -.sh 2 "The prt command" -.pp -When you created a delta, -you presumably gave a reason for the delta -to the -.q "comments?" -prompt. -To print out these comments later, -use: -.(b -sccs prt prog.c -.)b -This will produce -a report -for each delta -of the \*I, -time and date of creation, -user who created the delta, -number of lines inserted, deleted, and unchanged, -and the comments associated with the delta. -For example, the output of the above command might be: -.(b -D 1.2 80/08/29 12:35:31 bill 2 1 00005/00003/00084 -removed "-q" option -.sp \n(psu -D 1.1 79/02/05 00:19:31 eric 1 0 00087/00000/00000 -date and time created 80/06/10 00:19:31 by eric -.)b -.sh 2 "Finding why lines were inserted" -.pp -To find out -why you inserted lines, -you can get a copy of the file -with each line -preceded by the \*I that created it: -.(b -sccs get \-m prog.c -.)b -You can then find out -what this delta did -by printing the comments using -.i prt . -.pp -To find out what lines are associated with a particular delta -(\c -.i e.g. , -1.3), -use: -.(b -sccs get \-m \-p prog.c \(bv grep \'^1.3\' -.)b -The -.b \-p -flag causes \*S to output the generated source -to the standard output rather than to a file. -.sh 2 "Finding what changes you have made" -.pp -When you are editing a file, -you can find out what changes you have made using: -.(b -sccs diffs prog.c -.)b -Most of the ``diff'' flags can be used. -To pass the -.b \-c -flag, -use -.b \-C . -.pp -To compare two versions that are in deltas, -use: -.(b -sccs sccsdiff -r1.3 -r1.6 prog.c -.)b -to see the differences between delta 1.3 and delta 1.6. -.sh 1 "Shorthand Notations" -.pp -There are several sequences of commands that get -executed frequently. -.i Sccs -tries to make it easy to do these. -.sh 2 "Delget" -.pp -A frequent requirement is to make a delta of some file -and then get that file. -This can be done by using: -.(b -sccs delget prog.c -.)b -which is entirely equivalent to using: -.(b -sccs delta prog.c -sccs get prog.c -.)b -The -.q deledit -command is equivalent to -.q delget -except that the -.q edit -command is used -instead of the -.q get -command. -.sh 2 "Fix" -.pp -Frequently, there are small bugs -in deltas, -e.g., compilation errors, -for which there is no reason to maintain an audit trail. -To -.i replace -a delta, use: -.(b -sccs fix \-r1.4 prog.c -.)b -This will get a copy of delta 1.4 of prog.c for you to edit -and then delete delta 1.4 from the \*S file. -When you do a delta of prog.c, -it will be delta 1.4 again. -The \-r flag must be specified, -and the delta that is specified must be a leaf delta, -i.e., no other deltas may have been made subsequent -to the creation of that delta. -.sh 2 "Unedit" -.pp -If you found you edited a file -that you did not want to edit, -you can back out by using: -.(b -sccs unedit prog.c -.)b -.sh 2 "The \-d flag" -.pp -If you are working on a project -where the \*S code is in a directory somewhere, -you may be able to simplify things -by using a shell alias. -For example, -the alias: -.(b -alias syssccs sccs \-d/usr/src -.)b -will allow you to issue commands such as: -.(b -syssccs edit cmd/who.c -.)b -which will look for the file -.q "/usr/src/cmd/SCCS/who.c" . -The file -.q who.c -will always be created in your current directory -regardless of the value of the \-d flag. -.sh 1 "Using \*S on a Project" -.pp -Working on a project with several people -has its own set of special problems. -The main problem occurs when two people -modify a file at the same time. -\*S prevents this by locking an s-file -while it is being edited. -.pp -As a result, -files should not be reserved for editing -unless they are actually being edited at the time, -since this will prevent other people on the project -from making necessary changes. -For example, -a good scenario for working might be: -.(b -sccs edit a.c g.c t.c -vi a.c g.c t.c -# do testing of the (experimental) version -sccs delget a.c g.c t.c -sccs info -# should respond "Nothing being edited" -make install -.)b -.pp -As a general rule, -all source files should be deltaed -before installing the program for general use. -This will insure that it is possible -to restore any version in use at any time. -.sh 1 "Saving Yourself" -.sh 2 "Recovering a munged edit file" -.pp -Sometimes you may find -that you have destroyed or trashed -a file that you were trying to edit\**. -.(f -\**Or given up and decided to start over. -.)f -Unfortunately, -you can't just remove it -and re-\c -.i edit -it; -\*S keeps track -of the fact -that someone is trying to edit it, -so it won't let you do it again. -Neither can you just get it using -.i get , -since that would expand the Id keywords. -Instead, -you can say: -.(b -sccs get \-k prog.c -.)b -This will not expand the Id keywords, -so it is safe to do a delta -with it. -.pp -Alternately, -you can -.i unedit -and -.i edit -the file. -.sh 2 "Restoring the s-file" -.pp -In particularly bad circumstances, -the \*S file itself -may get munged. -The most common way this happens -is that it gets edited. -Since \*S keeps a checksum, -you will get errors every time you read the file. -To fix this checksum, use: -.(b -sccs admin \-z prog.c -.)b -.sh 1 "Using the Admin Command" -.pp -There are a number of parameters that can be set -using the -.i admin -command. -The most interesting of these are flags. -Flags can be added by using the -.b \-f -flag. -For example: -.(b -sccs admin \-fd1 prog.c -.)b -sets the -.q d -flag to the value -.q 1 . -This flag can be deleted by using: -.(b -sccs admin \-dd prog.c -.)b -The most useful flags are: -.nr ii 7n -.ip "b" -Allow branches to be made using the -\-b -flag to -.i edit . -.ip "d\fISID\fP" -Default \*I to be used on a -.i get -or -.i edit . -If this is just a release number -it constrains the -version -to a particular release only. -.ip "i" -Give a fatal error -if there are no Id Keywords in a file. -This is useful to guarantee that a version of the -file does not get merged into the s-file -that has the Id Keywords inserted as constants -instead of internal forms. -.ip "y" -The -.q type -of the module. -Actually, -the value of this flag is unused by \*S -except that it replaces the -.b %\&Y\&% -keyword. -.pp -The -.b \-t\fIfile\fR -flag can be used -to store descriptive text -from -.i file . -This descriptive text might be the documentation -or a design and implementation document. -Using the -.b \-t -flag insures that if the \*S file is sent, -the documentation will be sent also. -If -.i file -is omitted, -the descriptive text is deleted. -To see the descriptive text, -use -.q "prt \-t" . -.pp -The -.i admin -command can be used safely -any number of times on files. -A file need not be gotten -for -.i admin -to work. -.sh 1 "Maintaining Different Versions (Branches)" -.pp -Sometimes it is convenient -to maintain an experimental version of a program -for an extended period -while normal maintenance continues -on the version in production. -This can be done using a -.q branch. -Normally deltas continue in a straight line, -each depending on the delta before. -Creating a branch -.q "forks off" -a version of the program. -.pp -The ability to create branches -must be enabled in advance using: -.(b -sccs admin \-fb prog.c -.)b -The -.b \-fb -flag can be specified when the -\*S file is first created. -.sh 2 "Creating a branch" -.pp -To create a branch, use: -.(b -sccs edit \-b prog.c -.)b -This will create a branch -with (for example) \*I 1.5.1.1. -The deltas for this version -will be numbered -1.5.1.\c -.i n . -.sh 2 "Getting from a branch" -.pp -Deltas in a branch are normally not included -when you do a get. -To get these versions, -you will have to say: -.(b -sccs get \-r1.5.1 prog.c -.)b -.sh 2 "Merging a branch back into the main trunk" -.pp -At some point you will have finished the experiment, -and if it was successful -you will want to incorporate it into the release version. -But in the meantime -someone may have created a delta 1.6 -that you don't want to lose. -The commands: -.(b -sccs edit \-i1.5.1.1\-1.5.1 prog.c -sccs delta prog.c -.)b -will merge all of your changes -into the release system. -If some of the changes conflict, -get will print an error; -the generated result -should be carefully examined -before the delta is made. -.sh 2 "A more detailed example" -.pp -The following technique might be used -to maintain a different version of a program. -First, -create a directory to contain the new version: -.(b -mkdir ../newxyz -cd ../newxyz -.)b -Edit a copy of the program -on a branch: -.(b -sccs \-d../xyz edit prog.c -.)b -When using the old version, -be sure to use the -.b \-b -flag to info, check, tell, and clean -to avoid confusion. -For example, use: -.(b -sccs info \-b -.)b -when in the directory -.q xyz . -.pp -If you want to save a copy of the program -(still on the branch) -back in the s-file, -you can use: -.(b -sccs -d../xyz deledit prog.c -.)b -which will do a delta on the branch -and reedit it for you. -.pp -When the experiment is complete, merge it back into the s-file -using delta: -.(b -sccs -d../xyz delta prog.c -.)b -At this point you must decide whether this version -should be merged back into the trunk -(\c -.i i.e. -the default version), -which may have undergone changes. -If so, it can be merged using the -.b \-i -flag to -.i edit -as described above. -.sh 2 "A warning" -.pp -Branches should be kept to a minimum. -After the first branch from the trunk, -\*I's are assigned rather haphazardly, -and the structure gets complex fast. -.sh 1 "Using \*S with Make" -.pp -\*S and make can be made to work together -with a little care. -A few sample makefiles -for common applications are shown. -.pp -There are a few basic entries that every makefile -ought to have. -These are: -.nr ii 1i -.ip a.out -(or whatever the makefile generates.) -This entry regenerates whatever this makefile is -supposed to regenerate. -If the makefile regenerates many things, -this should be called -.q all -and should in turn -have dependencies on everything -the makefile can generate. -.ip install -Moves the objects to the final -resting place, -doing any special -.i chmod 's -or -.i ranlib 's -as appropriate. -.ip sources -Creates all the source files from \*S files. -.ip clean -Removes all files from the current directory -that can be regenerated from \*S files. -.ip print -Prints the contents of the directory. -.lp -The examples shown below are only partial examples, -and may omit some of these entries -when they are deemed to be obvious. -.pp -The -.i clean -entry should not remove files that can be -regenerated from the \*S files. -It is sufficiently important to have the -source files around at all times -that the only time they should be removed -is when the directory is being mothballed. -To do this, the command: -.(b -sccs clean -.)b -can be used. -This will remove all files for which an s-file -exists, -but which is not being edited. -.sh 2 "To maintain single programs" -.pp -Frequently there are directories with several -largely unrelated programs -(such as simple commands). -These can be put into a single makefile: -.(b -LDFLAGS= \-i \-s -.sp \n(psu -prog: prog.o - $(CC) $(LDFLAGS) \-o prog prog.o -prog.o: prog.c prog.h -.sp \n(psu -example: example.o - $(CC) $(LDFLAGS) \-o example example.o -example.o: example.c -.sp \n(psu -\&.DEFAULT: - sccs get $< -.)b -The trick here -is that the .DEFAULT rule -is called every time -something is needed -that does not exist, -and no other rule exists to make it. -The explicit dependency of the -.b \&.o -file on the -.b \&.c -file is important. -Another way of doing the same thing is: -.(b -SRCS= prog.c prog.h example.c -.sp \n(psu -LDFLAGS= \-i \-s -.sp \n(psu -prog: prog.o - $(CC) $(LDFLAGS) \-o prog prog.o -prog.o: prog.h -.sp \n(psu -example: example.o - $(CC) $(LDFLAGS) \-o example example.o -.sp \n(psu -sources: $(SRCS) -$(SRCS): - sccs get $@ -.)b -There are a couple of advantages to this approach: -(1) the explicit dependencies of the .o on the .c files are -not needed, -(2) there is an entry called "sources" so if you want to get -all the sources you can just say -.q "make sources" , -and -(3) the makefile is less likely to do confusing things -since it won't try to -.i get -things that do not exist. -.sh 2 "To maintain a library" -.pp -Libraries that are largely static -are best updated using explicit commands, -since -.i make -doesn't know about updating them properly. -However, -libraries that are in the process of being developed -can be handled quite adequately. -The problem is that the .o files -have to be kept out of the library -as well as in the library. -.(b -# configuration information -OBJS= a.o b.o c.o d.o -SRCS= a.c b.c c.c d.s x.h y.h z.h -TARG= /usr/lib -.sp \n(psu -# programs -GET= sccs get -REL= -AR= \-ar -RANLIB= ranlib -.sp \n(psu -lib.a: $(OBJS) - $(AR) rvu lib.a $(OBJS) - $(RANLIB) lib.a -.sp \n(psu -install: lib.a - sccs check - cp lib.a $(TARG)/lib.a - $(RANLIB) $(TARG)/lib.a -.sp \n(psu -sources: $(SRCS) -$(SRCS): - $(GET) $(REL) $@ -.sp \n(psu -print: sources - pr *.h *.[cs] -clean: - rm \-f *.o - rm \-f core a.out $(LIB) -.)b -.pp -The -.q "$(REL)" -in the get -can be used to get old versions -easily; for example: -.(b -make b.o REL=\-r1.3 -.)b -.pp -The -.i install -entry includes the line -.q "sccs check" -before anything else. -This guarantees that all the s-files -are up to date -(\c -.i i.e. , -nothing is being edited), -and will abort the -.i make -if this condition is not met. -.sh 2 "To maintain a large program" -.(b -OBJS= a.o b.o c.o d.o -SRCS= a.c b.c c.y d.s x.h y.h z.h -.sp \n(psu -GET= sccs get -REL= -.sp \n(psu -a.out: $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) $(LIBS) -.sp \n(psu -sources: $(SRCS) -$(SRCS): - $(GET) $(REL) $@ -.)b -(The -.i print -and -.i clean -entries are identical to the previous case.) -This makefile requires copies of the source and object files -to be kept during development. -It is probably also wise to include lines of the form: -.(b -a.o: x.h y.h -b.o: z.h -c.o: x.h y.h z.h -z.h: x.h -.)b -so that modules will be recompiled -if header files change. -.pp -Since -.i make -does not do transitive closure on dependencies, -you may find in some makefiles lines like: -.(b -z.h: x.h - touch z.h -.)b -This would be used in cases where file z.h -has a line: -.(b -#include "x.h" -.)b -in order to bring the mod date of z.h in line -with the mod date of x.h. -When you have a makefile such as above, -the -.i touch -command can be removed completely; -the equivalent effect will be achieved -by doing an automatic -.i get -on z.h. -.sh 1 "Further Information" -.pp -The -.i "SCCS/PWB User's Manual" -gives a deeper description -of how to use \*S. -Of particular interest -are the numbering of branches, -the l-file, -which gives a description of what deltas were used on a get, -and certain other \*S commands. -.pp -The \*S manual pages -are a good last resort. -These should be read by software managers -and by people who want to know -everything about everything. -.pp -Both of these documents were written without the -.i sccs -front end in mind, -so most of the examples are slightly different from those -in this document. -.bp -.sz 12 -.ce -.b "Quick Reference" -.sz -.sp 2 -.sh 1 Commands 1 -.pp -The following commands should all be preceded with -.q sccs . -This list is not exhaustive; -for more options see -.i "Further Information" . -.ip get 9n -Gets files for compilation (not for editing). -Id keywords are expanded. -.ba 9n -.nr ii 8n -.ip \-r\fI\*I\fP -Version to get. -.ip \-p -Send to standard output rather than to the actual file. -.ip \-k -Don't expand id keywords. -.ip \-i\fIlist\fP -List of deltas to include. -.ip \-x\fIlist\fP -List of deltas to exclude. -.ip \-m -Precede each line with \*I of creating delta. -.ip \-c\fIdate\fP -Don't apply any deltas created after -.i date. -.ba -.ip edit 9n -Gets files for editing. -Id keywords are not expanded. -Should be matched with a -.i delta -command. -.ba 9n -.nr ii 8n -.ip \-r\fI\*I\fP -Same as -.i get . -If -.i \*I -specifies a release that does not yet exist, -the highest numbered delta is retrieved -and the new delta is numbered with -.i \*I . -.ip \-b -Create a branch. -.ip \-i\fIlist\fP -Same as -.i get . -.ip \-x\fIlist\fP -Same as -.i get . -.ba -.ip delta 9n -Merge a file gotten using -.i edit -back into the s-file. -Collect comments about why this delta was made. -.ip unedit 9n -Remove a file that has been edited previously -without merging the changes into the s-file. -.ip prt 9n -Produce a report of changes. -.ba 9n -.nr ii 5n -.ip \-t -Print the descriptive text. -.ip \-e -Print (nearly) everything. -.ba -.ip info 9n -Give a list of all files being edited. -.ba 9n -.nr ii 5n -.ip \-b -Ignore branches. -.ip \-u[\fIuser\fP] -Ignore files not being edited by -.i user . -.ba -.ip check 9n -Same as -.i info , -except that nothing is printed if nothing is being edited -and exit status is returned. -.ip tell 9n -Same as -.i info , -except that one line is produced per file being edited containing -only the file name. -.ip clean 9n -Remove all files that can be regenerated from the -s-file. -.ip what 9n -Find and print id keywords. -.ip admin 9n -Create or set parameters on s-files. -.ba 9n -.nr ii 8n -.ip \-i\fIfile\fP -Create, using -.i file -as the initial contents. -.ip \-z -Rebuild the checksum in case -the file has been trashed. -.ip \-f\fIflag\fP -Turn on the -.i flag . -.ip \-d\fIflag\fP -Turn off (delete) the -.i flag . -.ip \-t\fIfile\fP -Replace the descriptive text -in the s-file with the contents of -.i file . -If -.i file -is omitted, -the text is deleted. -Useful for storing documentation -or -.q "design & implementation" -documents to insure they get distributed with the -s-file. -.lp -Useful flags are: -.ip b -Allow branches to be made using the \-b flag to -.i edit. -.ip d\fI\*I\fP -Default \*I to be used -on a -.i get -or -.i edit . -.ip i -Cause -.q "No Id Keywords" -error message -to be a fatal error rather than a warning. -.ip t -The module -.q type ; -the value of this flag replaces the -.b %\&Y\&% -keyword. -.ba -.ip fix 9n -Remove a delta and reedit it. -.ip delget 9n -Do a -.i delta -followed by a -.i get . -.ip deledit 9n -Do a -.i delta -followed by an -.i edit . -.sh 1 "Id Keywords" -.nr ii 6n -.ip "%\&Z\&%" -Expands to -.q @\&(#) -for the -.i what -command to find. -.ip "%\&M\&%" -The current module name, -.i e.g., -.q prog.c . -.ip "%\&I\&%" -The highest \*I applied. -.ip "%\&W\&%" -A shorthand for -.q "%\&Z\&%%\&M\&% %\&I\&%" . -.ip "%\&G\&%" -The date of the delta -corresponding to the -.q "%\&I\&%" -keyword. -.ip "%\&R\&%" -The current release number, -.i i.e. , -the first component of the -.q "%\&I\&%" -keyword. -.ip "%\&Y\&%" -Replaced by the value of the -.b t -flag -(set by -.i admin ). diff --git a/usr.bin/sccs/PSD.doc/spell.ok b/usr.bin/sccs/PSD.doc/spell.ok deleted file mode 100644 index fb2fe24..0000000 --- a/usr.bin/sccs/PSD.doc/spell.ok +++ /dev/null @@ -1,77 +0,0 @@ -AccessSid -Admin -Allman -Berkeley.Edu -Delget -Ingres -LDFLAGS -LIB -LIBS -OBJS -OpsysSid -PS1:14 -PWB -REL -SCCS -SID -SRCS -Sccs -SccsId -System''PS1:14 -TARG -a.c -a.o -a.out -access.h -admin -b.c -b.o -backslash -bi -c.c -c.o -c.y -ch -cm7 -cmd -cs -d.o -d.s -deledit -delget -eric -example.c -example.o -fb -fd1 -foreach -g.c -info -inline -john -lib -lib.a -makefile -makefiles -mod -mothballed -newxyz -ok -opsys.h -prog -prog.c -prog.h -prog.o -prt -rvu -sccs -sccsdiff -src -syssccs -t.c -ujohn -who.c -x.h -xyz -y.h -z.h diff --git a/usr.bin/sccs/pathnames.h b/usr.bin/sccs/pathnames.h deleted file mode 100644 index 4da6874..0000000 --- a/usr.bin/sccs/pathnames.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - */ - -#include - -#define _PATH_SCCSADMIN "/usr/local/bin/admin" -#define _PATH_SCCSBDIFF "/usr/local/bin/bdiff" -#define _PATH_SCCSCOMB "/usr/local/bin/comb" -#define _PATH_SCCSDELTA "/usr/local/bin/delta" -#define _PATH_SCCSDIFF "/usr/local/bin/sccsdiff" -#define _PATH_SCCSGET "/usr/local/bin/get" -#define _PATH_SCCSHELP "/usr/local/bin/help" -#define _PATH_SCCSPRS "/usr/local/bin/prs" -#define _PATH_SCCSPRT "/usr/local/bin/prt" -#define _PATH_SCCSRMDEL "/usr/local/bin/rmdel" -#define _PATH_SCCSVAL "/usr/local/bin/val" -#define _PATH_SCCSWHAT "/usr/local/bin/what" -#undef _PATH_TMP -#define _PATH_TMP "/tmp/sccsXXXXX" diff --git a/usr.bin/sccs/sccs.1 b/usr.bin/sccs/sccs.1 deleted file mode 100644 index 7f4990c..0000000 --- a/usr.bin/sccs/sccs.1 +++ /dev/null @@ -1,398 +0,0 @@ -.\" Copyright (c) 1983, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)sccs.1 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt SCCS 1 -.Os BSD 4.2 -.Sh NAME -.Nm sccs -.Nd front end for the -.Li SCCS -subsystem -.Sh SYNOPSIS -.Nm sccs -.Op Fl r -.Op Fl d Ar path -.Op Fl p Ar path -.Ar command -.Op flags -.Op Ar -.Sh DESCRIPTION -.Nm Sccs -is a front end to the -.Li SCCS -programs -that -helps them mesh more cleanly -with -the rest of UNIX. -It -also includes the capability to run -.Dq set user id -to another user -to -provide additional protection. -.Pp -Basically, -.Nm sccs -runs the command with the specified -.Ar flags -and -.Ar args . -Each argument is normally modified to be prepended with -.Dq Li SCCS/s. . -.Pp -Flags to be interpreted by the -.Nm sccs -program must be before the -.Ar command -argument. -Flags to be passed to the actual -.Li SCCS -program must come after the -.Ar command -argument. -These flags are specific to the command and -are discussed in the documentation for that command. -.Pp -Besides the usual -.Li SCCS -commands, -several -.Dq pseudo-commands -can be issued. -These are: -.Bl -tag -width deledit -.It Cm edit -Equivalent -to -.Dq Li get \-e . -.It Cm delget -Perform a delta on the named files and -then get new versions. -The new versions will have id keywords expanded, and -will not be editable. -The -.Fl m , -.Fl p , -.Fl r , -.Fl s , -and -.Fl y -flags will be passed to -.Nm delta , -and the -.Fl b, -.Fl c , -.Fl e , -.Fl i , -.Fl k , -.Fl l , -.Fl s , -.\" anybody who has a bad xterm which is almost anyone -and -.Fl x -flags will be passed to get. -.It Cm deledit -Equivalent -to -.Nm delget -except that the -.Nm get -phase includes the -.Fl e -flag. -This -option is useful for making a -.Em checkpoint -of your current editing phase. The same flags will be passed to delta -as described above, and -all the flags listed for -.om get -above except -.Fl e -and -.Fl k -are -passed to -.Nm edit . -.It Cm create -Creates -an -.Li SCCS -file , -taking -the initial contents from the file of the same name. -Any -flags to -.Nm admin -are accepted. If the creation is successful, -the files are renamed with a comma on the front. -These should be removed when you are convinced that the -.Li SCCS -files -have been created successfully. -.It Cm fix -Must -be followed by a -.Fl r -flag. -This command essentially removes the named delta, but -leaves you with a copy of the delta -with the changes that were in it. It -is useful for fixing small compiler bugs, etc. -Since it doesn't leave audit trails, it should be used carefully. -.It Cm clean -This routine removes everything from the current directory -that can be recreated from SCCS files. -It will not remove any files being edited. -If the -.Fl b -flag is given, branches are ignored in the determination of -whether they are being edited; this -is dangerous if you are keeping the branches in the -same directory. -.It Cm unedit -This -is the opposite of an -.Nm edit -or -a -.Dq Li get \-e . -It should be used with extreme caution, since -any changes you made since the get will be irretrievably lost. -.It Cm info -Gives a listing of all files being edited. -If the -.Fl b -flag -is given, branches (i.e., -.Li SID Ns \&\'s -with two or fewer components) -are ignored. If the -.Fl u -flag is given (with an optional argument) then -only files being edited by you (or the named user) are listed. -.It Cm check -Like -.Nm info -except that nothing is printed if nothing is being edited, and -a non-zero exit status is returned if anything is being edited. -The intent is to have this included in an -.Em install -entry in a makefile to insure that everything is included into the -.Li SCCS -file before a version is installed. -.It Cm tell -Gives a newline-separated list of the files being edited -on the standard output. Takes the -.Fl b -and -.Fl u -flags like -.Nm info -and -.Nm check . -.It Cm diffs -Gives a -.Nm diff -listing between the current version of the -program(s) you have out for editing and the versions in -.Li SCCS -format. -The -.Fl r , -.Fl c , -.Fl i , -.Fl x , -and -.Fl t -flags are passed to -.if n \{\ -. br -.\} -.Nm get ; -the -.Fl l , -.Fl s , -.Fl e , -.Fl f , -.Fl h , -and -.Fl b -options are passed to -.if n \{\ -. br -.\} -.Nm diff . -The -.Fl C -flag is passed to -.Nm diff -as -.Fl c . -.It Cm print -This command prints out verbose information -about the named files. -.Pp -.It Fl r -Runs -.Nm sccs -as the real user rather than as whatever effective user -.Nm sccs -is -.Dq Li set user id -to. -.It Fl d -Specifies a root directory for the -.Li SCCS -files. -The default is the current directory. -If environment variable -.Ev PROJECT -is set, -it will be used to determine the -.Fl d -flag. -.It Fl p -Defines the pathname of the directory in which the -.Li SCCS -files will be found; -.Dq Li SCCS -is the default. -The -.Fl p -flag -differs from the -.Fl d -flag -in that the -.Fl d -argument is prepended to the entire pathname and the -.Fl p -argument is inserted before the final component of the pathname. -For example, -.Dq Li sccs \-d/x \-py get a/b -will convert to -.Dq Li get /x/a/y/s.b . -The intent here is to create aliases such as -.Dq Li alias syssccs sccs -d/usr/src -which -will be used as -.Dq Li syssccs get cmd/who.c . -.Pp -Certain -commands (such as -.Nm admin ) -cannot be run -.Dq Li set user id -by all users, since this would allow anyone to change the authorizations. -These commands are always run as the real user. -.Sh EXAMPLES -To get a file for editing, -edit it, -and produce a new delta: -.Pp -.Dl sccs get \-e file.c -.Dl ex file.c -.Dl sccs delta file.c -.Pp -To get a file from another directory: -.Pp -.Dl sccs \-p/usr/src/sccs/s. get cc.c -.Pp -or -.Pp -.Dl sccs get /usr/src/sccs/s.cc.c -.Pp -To make a delta of a large number of files -in the current directory: -.Pp -.Dl sccs delta *.c -.Pp -To get a list of files being edited that are not on branches: -.Pp -.Dl sccs info \-b -.Pp -To delta everything being edited by you: -.Pp -.Dl sccs delta \`sccs tell \-u\` -.Pp -In a makefile, to get source files -from an -.Li SCCS -file if it does not already exist: -.Pp -.Dl SRCS = -.Dl $(SRCS): -.Dl \&\tsccs get $(REL) $@ -.Sh ENVIRONMENT -.Bl -tag -width Ar -.It Ev PROJECT -The PROJECT environment variable is checked by the -.Fl d -flag. If -it begins with a slash, it is taken directly; otherwise, -the home directory of a user of that name is -examined for a subdirectory -.Dq Li src -or -.Dq Li source . -If such a directory is found, it is used. -.El -.Sh SEE ALSO -.Xr what 1 -.Xr admin SCCS , -.Xr chghist SCCS , -.Xr comb SCCS , -.Xr delta SCCS , -.Xr get SCCS , -.Xr help SCCS , -.Xr prt SCCS , -.Xr rmdel SCCS , -.Xr sccsdiff SCCS , -.Rs -.%A Eric Allman -.%T "An Introduction to the Source Code Control System" -.Re -.Sh HISTORY -The -.Nm sccs -command -appeared in -.Bx 4.3 . -.Sh BUGS -It should be able to take directory arguments on pseudo-commands -like the -.Li SCCS -commands do. diff --git a/usr.bin/sccs/sccs.c b/usr.bin/sccs/sccs.c deleted file mode 100644 index 2dfd76d..0000000 --- a/usr.bin/sccs/sccs.c +++ /dev/null @@ -1,1621 +0,0 @@ -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1980, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)sccs.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "pathnames.h" - -/* -** SCCS.C -- human-oriented front end to the SCCS system. -** -** Without trying to add any functionality to speak of, this -** program tries to make SCCS a little more accessible to human -** types. The main thing it does is automatically put the -** string "SCCS/s." on the front of names. Also, it has a -** couple of things that are designed to shorten frequent -** combinations, e.g., "delget" which expands to a "delta" -** and a "get". -** -** This program can also function as a setuid front end. -** To do this, you should copy the source, renaming it to -** whatever you want, e.g., "syssccs". Change any defaults -** in the program (e.g., syssccs might default -d to -** "/usr/src/sys"). Then recompile and put the result -** as setuid to whomever you want. In this mode, sccs -** knows to not run setuid for certain programs in order -** to preserve security, and so forth. -** -** Usage: -** sccs [flags] command [args] -** -** Flags: -** -d represents a directory to search -** out of. It should be a full pathname -** for general usage. E.g., if is -** "/usr/src/sys", then a reference to the -** file "dev/bio.c" becomes a reference to -** "/usr/src/sys/dev/bio.c". -** -p prepends to the final component -** of the pathname. By default, this is -** "SCCS". For example, in the -d example -** above, the path then gets modified to -** "/usr/src/sys/dev/SCCS/s.bio.c". In -** more common usage (without the -d flag), -** "prog.c" would get modified to -** "SCCS/s.prog.c". In both cases, the -** "s." gets automatically prepended. -** -r run as the real user. -** -** Commands: -** admin, -** get, -** delta, -** rmdel, -** cdc, -** etc. Straight out of SCCS; only difference -** is that pathnames get modified as -** described above. -** enter Front end doing "sccs admin -i " -** create Macro for "enter" followed by "get". -** edit Macro for "get -e". -** unedit Removes a file being edited, knowing -** about p-files, etc. -** delget Macro for "delta" followed by "get". -** deledit Macro for "delta" followed by "get -e". -** branch Macro for "get -b -e", followed by "delta -** -s -n", followd by "get -e -t -g". -** diffs "diff" the specified version of files -** and the checked-out version. -** print Macro for "prs -e" followed by "get -p -m". -** tell List what files are being edited. -** info Print information about files being edited. -** clean Remove all files that can be -** regenerated from SCCS files. -** check Like info, but return exit status, for -** use in makefiles. -** fix Remove a top delta & reedit, but save -** the previous changes in that delta. -** -** Compilation Flags: -** UIDUSER -- determine who the user is by looking at the -** uid rather than the login name -- for machines -** where SCCS gets the user in this way. -** SCCSDIR -- if defined, forces the -d flag to take on -** this value. This is so that the setuid -** aspects of this program cannot be abused. -** This flag also disables the -p flag. -** SCCSPATH -- the default for the -p flag. -** MYNAME -- the title this program should print when it -** gives error messages. -** -** Compilation Instructions: -** cc -O -n -s sccs.c -** The flags listed above can be -D defined to simplify -** recompilation for variant versions. -** -** Author: -** Eric Allman, UCB/INGRES -** Copyright 1980 Regents of the University of California -*/ - - -/******************* Configuration Information ********************/ - -# ifndef SCCSPATH -# define SCCSPATH "SCCS" /* pathname in which to find s-files */ -# endif NOT SCCSPATH - -# ifndef MYNAME -# define MYNAME "sccs" /* name used for printing errors */ -# endif NOT MYNAME - -/**************** End of Configuration Information ****************/ - -typedef char bool; -# define TRUE 1 -# define FALSE 0 - -# define bitset(bit, word) ((bool) ((bit) & (word))) - -struct sccsprog -{ - char *sccsname; /* name of SCCS routine */ - short sccsoper; /* opcode, see below */ - short sccsflags; /* flags, see below */ - char *sccspath; /* pathname of binary implementing */ -}; - -/* values for sccsoper */ -# define PROG 0 /* call a program */ -# define CMACRO 1 /* command substitution macro */ -# define FIX 2 /* fix a delta */ -# define CLEAN 3 /* clean out recreatable files */ -# define UNEDIT 4 /* unedit a file */ -# define SHELL 5 /* call a shell file (like PROG) */ -# define DIFFS 6 /* diff between sccs & file out */ -# define DODIFF 7 /* internal call to diff program */ -# define ENTER 8 /* enter new files */ - -/* bits for sccsflags */ -# define NO_SDOT 0001 /* no s. on front of args */ -# define REALUSER 0002 /* protected (e.g., admin) */ - -/* modes for the "clean", "info", "check" ops */ -# define CLEANC 0 /* clean command */ -# define INFOC 1 /* info command */ -# define CHECKC 2 /* check command */ -# define TELLC 3 /* give list of files being edited */ - -/* -** Description of commands known to this program. -** First argument puts the command into a class. Second arg is -** info regarding treatment of this command. Third arg is a -** list of flags this command accepts from macros, etc. Fourth -** arg is the pathname of the implementing program, or the -** macro definition, or the arg to a sub-algorithm. -*/ - -struct sccsprog SccsProg[] = { - "admin", PROG, REALUSER, _PATH_SCCSADMIN, - "cdc", PROG, 0, _PATH_SCCSRMDEL, - "comb", PROG, 0, _PATH_SCCSCOMB, - "delta", PROG, 0, _PATH_SCCSDELTA, - "get", PROG, 0, _PATH_SCCSGET, - "help", PROG, NO_SDOT, _PATH_SCCSHELP, - "prs", PROG, 0, _PATH_SCCSPRS, - "prt", PROG, 0, _PATH_SCCSPRT, - "rmdel", PROG, REALUSER, _PATH_SCCSRMDEL, - "val", PROG, 0, _PATH_SCCSVAL, - "what", PROG, NO_SDOT, _PATH_SCCSWHAT, - "sccsdiff", SHELL, REALUSER, _PATH_SCCSDIFF, - "edit", CMACRO, NO_SDOT, "get -e", - "delget", CMACRO, NO_SDOT, "delta:mysrp/get:ixbeskcl -t", - "deledit", CMACRO, NO_SDOT, - "delta:mysrp -n/get:ixbskcl -e -t -g", - "fix", FIX, NO_SDOT, NULL, - "clean", CLEAN, REALUSER|NO_SDOT, - (char *) CLEANC, - "info", CLEAN, REALUSER|NO_SDOT, - (char *) INFOC, - "check", CLEAN, REALUSER|NO_SDOT, - (char *) CHECKC, - "tell", CLEAN, REALUSER|NO_SDOT, - (char *) TELLC, - "unedit", UNEDIT, NO_SDOT, NULL, - "diffs", DIFFS, NO_SDOT|REALUSER, - NULL, - "-diff", DODIFF, NO_SDOT|REALUSER, - _PATH_SCCSBDIFF, - "print", CMACRO, 0, "prs -e/get -p -m -s", - "branch", CMACRO, NO_SDOT, - "get:ixrc -e -b/delta: -s -n -ybranch-place-holder/get:pl -e -t -g", - "enter", ENTER, NO_SDOT, NULL, - "create", CMACRO, NO_SDOT, "enter/get:ixbeskcl -t", - NULL, -1, 0, NULL -}; - -/* one line from a p-file */ -struct pfile -{ - char *p_osid; /* old SID */ - char *p_nsid; /* new SID */ - char *p_user; /* user who did edit */ - char *p_date; /* date of get */ - char *p_time; /* time of get */ - char *p_aux; /* extra info at end */ -}; - -char *SccsPath = SCCSPATH; /* pathname of SCCS files */ -# ifdef SCCSDIR -char *SccsDir = SCCSDIR; /* directory to begin search from */ -# else -char *SccsDir = ""; -# endif -char MyName[] = MYNAME; /* name used in messages */ -int OutFile = -1; /* override output file for commands */ -bool RealUser; /* if set, running as real user */ -# ifdef DEBUG -bool Debug; /* turn on tracing */ -# endif -# ifndef V6 -extern char *getenv(); -# endif V6 - -char *gstrcat(), *strcat(); -char *gstrncat(), *strncat(); -char *gstrcpy(), *strcpy(); -#define FBUFSIZ BUFSIZ -#define PFILELG 120 - -main(argc, argv) - int argc; - char **argv; -{ - register char *p; - extern struct sccsprog *lookup(); - register int i; -# ifndef V6 -# ifndef SCCSDIR - register struct passwd *pw; - extern struct passwd *getpwnam(); - char buf[FBUFSIZ]; - - /* pull "SccsDir" out of the environment (possibly) */ - p = getenv("PROJECTDIR"); - if (p != NULL && p[0] != '\0') - { - if (p[0] == '/') - SccsDir = p; - else - { - pw = getpwnam(p); - if (pw == NULL) - { - usrerr("user %s does not exist", p); - exit(EX_USAGE); - } - gstrcpy(buf, pw->pw_dir, sizeof(buf)); - gstrcat(buf, "/src", sizeof(buf)); - if (access(buf, 0) < 0) - { - gstrcpy(buf, pw->pw_dir, sizeof(buf)); - gstrcat(buf, "/source", sizeof(buf)); - if (access(buf, 0) < 0) - { - usrerr("project %s has no source!", p); - exit(EX_USAGE); - } - } - SccsDir = buf; - } - } -# endif SCCSDIR -# endif V6 - - /* - ** Detect and decode flags intended for this program. - */ - - if (argc < 2) - { - fprintf(stderr, "Usage: %s [flags] command [flags]\n", MyName); - exit(EX_USAGE); - } - argv[argc] = NULL; - - if (lookup(argv[0]) == NULL) - { - while ((p = *++argv) != NULL) - { - if (*p != '-') - break; - switch (*++p) - { - case 'r': /* run as real user */ - setuid(getuid()); - RealUser++; - break; - -# ifndef SCCSDIR - case 'p': /* path of sccs files */ - SccsPath = ++p; - if (SccsPath[0] == '\0' && argv[1] != NULL) - SccsPath = *++argv; - break; - - case 'd': /* directory to search from */ - SccsDir = ++p; - if (SccsDir[0] == '\0' && argv[1] != NULL) - SccsDir = *++argv; - break; -# endif - -# ifdef DEBUG - case 'T': /* trace */ - Debug++; - break; -# endif - - default: - usrerr("unknown option -%s", p); - break; - } - } - if (SccsPath[0] == '\0') - SccsPath = "."; - } - - i = command(argv, FALSE, ""); - exit(i); -} - -/* -** COMMAND -- look up and perform a command -** -** This routine is the guts of this program. Given an -** argument vector, it looks up the "command" (argv[0]) -** in the configuration table and does the necessary stuff. -** -** Parameters: -** argv -- an argument vector to process. -** forkflag -- if set, fork before executing the command. -** editflag -- if set, only include flags listed in the -** sccsklets field of the command descriptor. -** arg0 -- a space-seperated list of arguments to insert -** before argv. -** -** Returns: -** zero -- command executed ok. -** else -- error status. -** -** Side Effects: -** none. -*/ - -command(argv, forkflag, arg0) - char **argv; - bool forkflag; - char *arg0; -{ - register struct sccsprog *cmd; - register char *p; - char buf[FBUFSIZ]; - extern struct sccsprog *lookup(); - char *nav[1000]; - char **np; - register char **ap; - register int i; - register char *q; - extern bool unedit(); - int rval = 0; - extern char *index(); - extern char *makefile(); - char *editchs; - extern char *tail(); - -# ifdef DEBUG - if (Debug) - { - printf("command:\n\t\"%s\"\n", arg0); - for (np = argv; *np != NULL; np++) - printf("\t\"%s\"\n", *np); - } -# endif - - /* - ** Copy arguments. - ** Copy from arg0 & if necessary at most one arg - ** from argv[0]. - */ - - np = ap = &nav[1]; - editchs = NULL; - for (p = arg0, q = buf; *p != '\0' && *p != '/'; ) - { - *np++ = q; - while (*p == ' ') - p++; - while (*p != ' ' && *p != '\0' && *p != '/' && *p != ':') - *q++ = *p++; - *q++ = '\0'; - if (*p == ':') - { - editchs = q; - while (*++p != '\0' && *p != '/' && *p != ' ') - *q++ = *p; - *q++ = '\0'; - } - } - *np = NULL; - if (*ap == NULL) - *np++ = *argv++; - - /* - ** Look up command. - ** At this point, *ap is the command name. - */ - - cmd = lookup(*ap); - if (cmd == NULL) - { - usrerr("Unknown command \"%s\"", *ap); - return (EX_USAGE); - } - - /* - ** Copy remaining arguments doing editing as appropriate. - */ - - for (; *argv != NULL; argv++) - { - p = *argv; - if (*p == '-') - { - if (p[1] == '\0' || editchs == NULL || index(editchs, p[1]) != NULL) - *np++ = p; - } - else - { - if (!bitset(NO_SDOT, cmd->sccsflags)) - p = makefile(p); - if (p != NULL) - *np++ = p; - } - } - *np = NULL; - - /* - ** Interpret operation associated with this command. - */ - - switch (cmd->sccsoper) - { - case SHELL: /* call a shell file */ - *ap = cmd->sccspath; - *--ap = "sh"; - rval = callprog(_PATH_BSHELL, cmd->sccsflags, ap, forkflag); - break; - - case PROG: /* call an sccs prog */ - rval = callprog(cmd->sccspath, cmd->sccsflags, ap, forkflag); - break; - - case CMACRO: /* command macro */ - /* step through & execute each part of the macro */ - for (p = cmd->sccspath; *p != '\0'; p++) - { - q = p; - while (*p != '\0' && *p != '/') - p++; - rval = command(&ap[1], *p != '\0', q); - if (rval != 0) - break; - } - break; - - case FIX: /* fix a delta */ - if (ap[1]==0 || strncmp(ap[1], "-r", 2)!=0) - { - usrerr("-r flag needed for fix command"); - rval = EX_USAGE; - break; - } - - /* get the version with all changes */ - rval = command(&ap[1], TRUE, "get -k"); - - /* now remove that version from the s-file */ - if (rval == 0) - rval = command(&ap[1], TRUE, "rmdel:r"); - - /* and edit the old version (but don't clobber new vers) */ - if (rval == 0) - rval = command(&ap[2], FALSE, "get -e -g"); - break; - - case CLEAN: - rval = clean((int) cmd->sccspath, ap); - break; - - case UNEDIT: - for (argv = np = &ap[1]; *argv != NULL; argv++) - { - if (unedit(*argv)) - *np++ = *argv; - } - *np = NULL; - - /* get all the files that we unedited successfully */ - if (np > &ap[1]) - rval = command(&ap[1], FALSE, "get"); - break; - - case DIFFS: /* diff between s-file & edit file */ - /* find the end of the flag arguments */ - for (np = &ap[1]; *np != NULL && **np == '-'; np++) - continue; - argv = np; - - /* for each file, do the diff */ - p = argv[1]; - while (*np != NULL) - { - /* messy, but we need a null terminated argv */ - *argv = *np++; - argv[1] = NULL; - i = dodiff(ap, tail(*argv)); - if (rval == 0) - rval = i; - argv[1] = p; - } - break; - - case DODIFF: /* internal diff call */ - setuid(getuid()); - for (np = ap; *np != NULL; np++) - { - if ((*np)[0] == '-' && (*np)[1] == 'C') - (*np)[1] = 'c'; - } - - /* insert "-" argument */ - np[1] = NULL; - np[0] = np[-1]; - np[-1] = "-"; - - /* execute the diff program of choice */ -# ifndef V6 - execvp("diff", ap); -# endif - execv(cmd->sccspath, argv); - syserr("cannot exec %s", cmd->sccspath); - exit(EX_OSERR); - - case ENTER: /* enter new sccs files */ - /* skip over flag arguments */ - for (np = &ap[1]; *np != NULL && **np == '-'; np++) - continue; - argv = np; - - /* do an admin for each file */ - p = argv[1]; - while (*np != NULL) - { - printf("\n%s:\n", *np); - strcpy(buf, "-i"); - gstrcat(buf, *np, sizeof(buf)); - ap[0] = buf; - argv[0] = tail(*np); - argv[1] = NULL; - rval = command(ap, TRUE, "admin"); - argv[1] = p; - if (rval == 0) - { - strcpy(buf, ","); - gstrcat(buf, tail(*np), sizeof(buf)); - if (link(*np, buf) >= 0) - unlink(*np); - } - np++; - } - break; - - default: - syserr("oper %d", cmd->sccsoper); - exit(EX_SOFTWARE); - } -# ifdef DEBUG - if (Debug) - printf("command: rval=%d\n", rval); -# endif - return (rval); -} - -/* -** LOOKUP -- look up an SCCS command name. -** -** Parameters: -** name -- the name of the command to look up. -** -** Returns: -** ptr to command descriptor for this command. -** NULL if no such entry. -** -** Side Effects: -** none. -*/ - -struct sccsprog * -lookup(name) - char *name; -{ - register struct sccsprog *cmd; - - for (cmd = SccsProg; cmd->sccsname != NULL; cmd++) - { - if (strcmp(cmd->sccsname, name) == 0) - return (cmd); - } - return (NULL); -} - -/* -** CALLPROG -- call a program -** -** Used to call the SCCS programs. -** -** Parameters: -** progpath -- pathname of the program to call. -** flags -- status flags from the command descriptors. -** argv -- an argument vector to pass to the program. -** forkflag -- if true, fork before calling, else just -** exec. -** -** Returns: -** The exit status of the program. -** Nothing if forkflag == FALSE. -** -** Side Effects: -** Can exit if forkflag == FALSE. -*/ - -callprog(progpath, flags, argv, forkflag) - char *progpath; - short flags; - char **argv; - bool forkflag; -{ - register int i; - register int wpid; - auto int st; - register int sigcode; - register int coredumped; - register const char *sigmsg; - char sigmsgbuf[10+1]; /* "Signal 127" + terminating '\0' */ - -# ifdef DEBUG - if (Debug) - { - printf("callprog:\n"); - for (i = 0; argv[i] != NULL; i++) - printf("\t\"%s\"\n", argv[i]); - } -# endif - - if (*argv == NULL) - return (-1); - - /* - ** Fork if appropriate. - */ - - if (forkflag) - { -# ifdef DEBUG - if (Debug) - printf("Forking\n"); -# endif - i = fork(); - if (i < 0) - { - syserr("cannot fork"); - exit(EX_OSERR); - } - else if (i > 0) - { - while ((wpid = wait(&st)) != -1 && wpid != i) - ; - if ((sigcode = st & 0377) == 0) - st = (st >> 8) & 0377; - else - { - coredumped = sigcode & 0200; - sigcode &= 0177; - if (sigcode != SIGINT && sigcode != SIGPIPE) - { - if (sigcode < NSIG) - sigmsg = sys_siglist[sigcode]; - else - { - sprintf(sigmsgbuf, "Signal %d", - sigcode); - sigmsg = sigmsgbuf; - } - fprintf(stderr, "sccs: %s: %s%s", argv[0], - sigmsg, - coredumped ? " - core dumped": ""); - } - st = EX_SOFTWARE; - } - if (OutFile >= 0) - { - close(OutFile); - OutFile = -1; - } - return (st); - } - } - else if (OutFile >= 0) - { - syserr("callprog: setting stdout w/o forking"); - exit(EX_SOFTWARE); - } - - /* set protection as appropriate */ - if (bitset(REALUSER, flags)) - setuid(getuid()); - - /* change standard input & output if needed */ - if (OutFile >= 0) - { - close(1); - dup(OutFile); - close(OutFile); - } - - /* call real SCCS program */ - execv(progpath, argv); - syserr("cannot execute %s", progpath); - exit(EX_UNAVAILABLE); - /*NOTREACHED*/ -} - -/* -** MAKEFILE -- make filename of SCCS file -** -** If the name passed is already the name of an SCCS file, -** just return it. Otherwise, munge the name into the name -** of the actual SCCS file. -** -** There are cases when it is not clear what you want to -** do. For example, if SccsPath is an absolute pathname -** and the name given is also an absolute pathname, we go -** for SccsPath (& only use the last component of the name -** passed) -- this is important for security reasons (if -** sccs is being used as a setuid front end), but not -** particularly intuitive. -** -** Parameters: -** name -- the file name to be munged. -** -** Returns: -** The pathname of the sccs file. -** NULL on error. -** -** Side Effects: -** none. -*/ - -char * -makefile(name) - char *name; -{ - register char *p; - char buf[3*FBUFSIZ]; - extern char *malloc(); - extern char *rindex(); - extern bool safepath(); - extern bool isdir(); - register char *q; - - p = rindex(name, '/'); - if (p == NULL) - p = name; - else - p++; - - /* - ** Check to see that the path is "safe", i.e., that we - ** are not letting some nasty person use the setuid part - ** of this program to look at or munge some presumably - ** hidden files. - */ - - if (SccsDir[0] == '/' && !safepath(name)) - return (NULL); - - /* - ** Create the base pathname. - */ - - /* first the directory part */ - if (SccsDir[0] != '\0' && name[0] != '/' && strncmp(name, "./", 2) != 0) - { - gstrcpy(buf, SccsDir, sizeof(buf)); - gstrcat(buf, "/", sizeof(buf)); - } - else - gstrcpy(buf, "", sizeof(buf)); - - /* then the head of the pathname */ - gstrncat(buf, name, p - name, sizeof(buf)); - q = &buf[strlen(buf)]; - - /* now copy the final part of the name, in case useful */ - gstrcpy(q, p, sizeof(buf)); - - /* so is it useful? */ - if (strncmp(p, "s.", 2) != 0 && !isdir(buf)) - { - /* sorry, no; copy the SCCS pathname & the "s." */ - gstrcpy(q, SccsPath, sizeof(buf)); - gstrcat(buf, "/s.", sizeof(buf)); - - /* and now the end of the name */ - gstrcat(buf, p, sizeof(buf)); - } - - /* if i haven't changed it, why did I do all this? */ - if (strcmp(buf, name) == 0) - p = name; - else - { - /* but if I have, squirrel it away */ - p = malloc(strlen(buf) + 1); - if (p == NULL) - { - perror("Sccs: no mem"); - exit(EX_OSERR); - } - strcpy(p, buf); - } - - return (p); -} - -/* -** ISDIR -- return true if the argument is a directory. -** -** Parameters: -** name -- the pathname of the file to check. -** -** Returns: -** TRUE if 'name' is a directory, FALSE otherwise. -** -** Side Effects: -** none. -*/ - -bool -isdir(name) - char *name; -{ - struct stat stbuf; - - return (stat(name, &stbuf) >= 0 && (stbuf.st_mode & S_IFMT) == S_IFDIR); -} - -/* -** SAFEPATH -- determine whether a pathname is "safe" -** -** "Safe" pathnames only allow you to get deeper into the -** directory structure, i.e., full pathnames and ".." are -** not allowed. -** -** Parameters: -** p -- the name to check. -** -** Returns: -** TRUE -- if the path is safe. -** FALSE -- if the path is not safe. -** -** Side Effects: -** Prints a message if the path is not safe. -*/ - -bool -safepath(p) - register char *p; -{ - extern char *index(); - - if (*p != '/') - { - while (strncmp(p, "../", 3) != 0 && strcmp(p, "..") != 0) - { - p = index(p, '/'); - if (p == NULL) - return (TRUE); - p++; - } - } - - printf("You may not use full pathnames or \"..\"\n"); - return (FALSE); -} - -/* -** CLEAN -- clean out recreatable files -** -** Any file for which an "s." file exists but no "p." file -** exists in the current directory is purged. -** -** Parameters: -** mode -- tells whether this came from a "clean", "info", or -** "check" command. -** argv -- the rest of the argument vector. -** -** Returns: -** none. -** -** Side Effects: -** Removes files in the current directory. -** Prints information regarding files being edited. -** Exits if a "check" command. -*/ - -clean(mode, argv) - int mode; - char **argv; -{ - struct direct *dir; - char buf[FBUFSIZ]; - char *bufend; - register DIR *dirp; - register char *basefile; - bool gotedit; - bool gotpfent; - FILE *pfp; - bool nobranch = FALSE; - extern struct pfile *getpfent(); - register struct pfile *pf; - register char **ap; - extern char *username(); - char *usernm = NULL; - char *subdir = NULL; - char *cmdname; - - /* - ** Process the argv - */ - - cmdname = *argv; - for (ap = argv; *++ap != NULL; ) - { - if (**ap == '-') - { - /* we have a flag */ - switch ((*ap)[1]) - { - case 'b': - nobranch = TRUE; - break; - - case 'u': - if ((*ap)[2] != '\0') - usernm = &(*ap)[2]; - else if (ap[1] != NULL && ap[1][0] != '-') - usernm = *++ap; - else - usernm = username(); - break; - } - } - else - { - if (subdir != NULL) - usrerr("too many args"); - else - subdir = *ap; - } - } - - /* - ** Find and open the SCCS directory. - */ - - gstrcpy(buf, SccsDir, sizeof(buf)); - if (buf[0] != '\0') - gstrcat(buf, "/", sizeof(buf)); - if (subdir != NULL) - { - gstrcat(buf, subdir, sizeof(buf)); - gstrcat(buf, "/", sizeof(buf)); - } - gstrcat(buf, SccsPath, sizeof(buf)); - bufend = &buf[strlen(buf)]; - - dirp = opendir(buf); - if (dirp == NULL) - { - usrerr("cannot open %s", buf); - return (EX_NOINPUT); - } - - /* - ** Scan the SCCS directory looking for s. files. - ** gotedit tells whether we have tried to clean any - ** files that are being edited. - */ - - gotedit = FALSE; - while (dir = readdir(dirp)) { - if (strncmp(dir->d_name, "s.", 2) != 0) - continue; - - /* got an s. file -- see if the p. file exists */ - gstrcpy(bufend, "/p.", sizeof(buf)); - basefile = bufend + 3; - gstrcpy(basefile, &dir->d_name[2], sizeof(buf)); - - /* - ** open and scan the p-file. - ** 'gotpfent' tells if we have found a valid p-file - ** entry. - */ - - pfp = fopen(buf, "r"); - gotpfent = FALSE; - if (pfp != NULL) - { - /* the file exists -- report it's contents */ - while ((pf = getpfent(pfp)) != NULL) - { - if (nobranch && isbranch(pf->p_nsid)) - continue; - if (usernm != NULL && strcmp(usernm, pf->p_user) != 0 && mode != CLEANC) - continue; - gotedit = TRUE; - gotpfent = TRUE; - if (mode == TELLC) - { - printf("%s\n", basefile); - break; - } - printf("%12s: being edited: ", basefile); - putpfent(pf, stdout); - } - fclose(pfp); - } - - /* the s. file exists and no p. file exists -- unlink the g-file */ - if (mode == CLEANC && !gotpfent) - { - char unlinkbuf[FBUFSIZ]; - gstrcpy(unlinkbuf, &dir->d_name[2], sizeof(unlinkbuf)); - unlink(unlinkbuf); - } - } - - /* cleanup & report results */ - closedir(dirp); - if (!gotedit && mode == INFOC) - { - printf("Nothing being edited"); - if (nobranch) - printf(" (on trunk)"); - if (usernm == NULL) - printf("\n"); - else - printf(" by %s\n", usernm); - } - if (mode == CHECKC) - exit(gotedit); - return (EX_OK); -} - -/* -** ISBRANCH -- is the SID a branch? -** -** Parameters: -** sid -- the sid to check. -** -** Returns: -** TRUE if the sid represents a branch. -** FALSE otherwise. -** -** Side Effects: -** none. -*/ - -isbranch(sid) - char *sid; -{ - register char *p; - int dots; - - dots = 0; - for (p = sid; *p != '\0'; p++) - { - if (*p == '.') - dots++; - if (dots > 1) - return (TRUE); - } - return (FALSE); -} - -/* -** UNEDIT -- unedit a file -** -** Checks to see that the current user is actually editting -** the file and arranges that s/he is not editting it. -** -** Parameters: -** fn -- the name of the file to be unedited. -** -** Returns: -** TRUE -- if the file was successfully unedited. -** FALSE -- if the file was not unedited for some -** reason. -** -** Side Effects: -** fn is removed -** entries are removed from pfile. -*/ - -bool -unedit(fn) - char *fn; -{ - register FILE *pfp; - char *cp, *pfn; - static char tfn[] = _PATH_TMP; - FILE *tfp; - register char *q; - bool delete = FALSE; - bool others = FALSE; - char *myname; - extern char *username(); - struct pfile *pent; - extern struct pfile *getpfent(); - char buf[PFILELG]; - extern char *makefile(), *rindex(), *tail(); - - /* make "s." filename & find the trailing component */ - pfn = makefile(fn); - if (pfn == NULL) - return (FALSE); - q = rindex(pfn, '/'); - if (q == NULL) - q = &pfn[-1]; - if (q[1] != 's' || q[2] != '.') - { - usrerr("bad file name \"%s\"", fn); - return (FALSE); - } - - /* turn "s." into "p." & try to open it */ - *++q = 'p'; - - pfp = fopen(pfn, "r"); - if (pfp == NULL) - { - printf("%12s: not being edited\n", fn); - return (FALSE); - } - - /* create temp file for editing p-file */ - mktemp(tfn); - tfp = fopen(tfn, "w"); - if (tfp == NULL) - { - usrerr("cannot create \"%s\"", tfn); - exit(EX_OSERR); - } - - /* figure out who I am */ - myname = username(); - - /* - ** Copy p-file to temp file, doing deletions as needed. - */ - - while ((pent = getpfent(pfp)) != NULL) - { - if (strcmp(pent->p_user, myname) == 0) - { - /* a match */ - delete++; - } - else - { - /* output it again */ - putpfent(pent, tfp); - others++; - } - } - - /* - * Before changing anything, make sure we can remove - * the file in question (assuming it exists). - */ - if (delete) { - extern int errno; - - cp = tail(fn); - errno = 0; - if (access(cp, 0) < 0 && errno != ENOENT) - goto bad; - if (errno == 0) - /* - * This is wrong, but the rest of the program - * has built in assumptions about "." as well, - * so why make unedit a special case? - */ - if (access(".", 2) < 0) { - bad: - printf("%12s: can't remove\n", cp); - fclose(tfp); - fclose(pfp); - unlink(tfn); - return (FALSE); - } - } - /* do final cleanup */ - if (others) - { - /* copy it back (perhaps it should be linked?) */ - if (freopen(tfn, "r", tfp) == NULL) - { - syserr("cannot reopen \"%s\"", tfn); - exit(EX_OSERR); - } - if (freopen(pfn, "w", pfp) == NULL) - { - usrerr("cannot create \"%s\"", pfn); - return (FALSE); - } - while (fgets(buf, sizeof buf, tfp) != NULL) - fputs(buf, pfp); - } - else - { - /* it's empty -- remove it */ - unlink(pfn); - } - fclose(tfp); - fclose(pfp); - unlink(tfn); - - /* actually remove the g-file */ - if (delete) - { - /* - * Since we've checked above, we can - * use the return from unlink to - * determine if the file existed or not. - */ - if (unlink(cp) >= 0) - printf("%12s: removed\n", cp); - return (TRUE); - } - else - { - printf("%12s: not being edited by you\n", fn); - return (FALSE); - } -} - -/* -** DODIFF -- diff an s-file against a g-file -** -** Parameters: -** getv -- argv for the 'get' command. -** gfile -- name of the g-file to diff against. -** -** Returns: -** Result of get. -** -** Side Effects: -** none. -*/ - -dodiff(getv, gfile) - char **getv; - char *gfile; -{ - int pipev[2]; - int rval; - register int i; - register int pid; - auto int st; - extern int errno; - sig_t osig; - - printf("\n------- %s -------\n", gfile); - fflush(stdout); - - /* create context for diff to run in */ - if (pipe(pipev) < 0) - { - syserr("dodiff: pipe failed"); - exit(EX_OSERR); - } - if ((pid = fork()) < 0) - { - syserr("dodiff: fork failed"); - exit(EX_OSERR); - } - else if (pid > 0) - { - /* in parent; run get */ - OutFile = pipev[1]; - close(pipev[0]); - rval = command(&getv[1], TRUE, "get:rcixt -s -k -p"); - osig = signal(SIGINT, SIG_IGN); - while (((i = wait(&st)) >= 0 && i != pid) || errno == EINTR) - errno = 0; - signal(SIGINT, osig); - /* ignore result of diff */ - } - else - { - /* in child, run diff */ - if (close(pipev[1]) < 0 || close(0) < 0 || - dup(pipev[0]) != 0 || close(pipev[0]) < 0) - { - syserr("dodiff: magic failed"); - exit(EX_OSERR); - } - command(&getv[1], FALSE, "-diff:elsfhbC"); - } - return (rval); -} - -/* -** TAIL -- return tail of filename. -** -** Parameters: -** fn -- the filename. -** -** Returns: -** a pointer to the tail of the filename; e.g., given -** "cmd/ls.c", "ls.c" is returned. -** -** Side Effects: -** none. -*/ - -char * -tail(fn) - register char *fn; -{ - register char *p; - - for (p = fn; *p != 0; p++) - if (*p == '/' && p[1] != '\0' && p[1] != '/') - fn = &p[1]; - return (fn); -} - -/* -** GETPFENT -- get an entry from the p-file -** -** Parameters: -** pfp -- p-file file pointer -** -** Returns: -** pointer to p-file struct for next entry -** NULL on EOF or error -** -** Side Effects: -** Each call wipes out results of previous call. -*/ - -struct pfile * -getpfent(pfp) - FILE *pfp; -{ - static struct pfile ent; - static char buf[PFILELG]; - register char *p; - extern char *nextfield(); - - if (fgets(buf, sizeof buf, pfp) == NULL) - return (NULL); - - ent.p_osid = p = buf; - ent.p_nsid = p = nextfield(p); - ent.p_user = p = nextfield(p); - ent.p_date = p = nextfield(p); - ent.p_time = p = nextfield(p); - ent.p_aux = p = nextfield(p); - - return (&ent); -} - - -char * -nextfield(p) - register char *p; -{ - if (p == NULL || *p == '\0') - return (NULL); - while (*p != ' ' && *p != '\n' && *p != '\0') - p++; - if (*p == '\n' || *p == '\0') - { - *p = '\0'; - return (NULL); - } - *p++ = '\0'; - return (p); -} - /* -** PUTPFENT -- output a p-file entry to a file -** -** Parameters: -** pf -- the p-file entry -** f -- the file to put it on. -** -** Returns: -** none. -** -** Side Effects: -** pf is written onto file f. -*/ - -putpfent(pf, f) - register struct pfile *pf; - register FILE *f; -{ - fprintf(f, "%s %s %s %s %s", pf->p_osid, pf->p_nsid, - pf->p_user, pf->p_date, pf->p_time); - if (pf->p_aux != NULL) - fprintf(f, " %s", pf->p_aux); - else - fprintf(f, "\n"); -} - -/* -** USRERR -- issue user-level error -** -** Parameters: -** f -- format string. -** p1-p3 -- parameters to a printf. -** -** Returns: -** -1 -** -** Side Effects: -** none. -*/ - -/*VARARGS1*/ -usrerr(f, p1, p2, p3) - char *f; -{ - fprintf(stderr, "\n%s: ", MyName); - fprintf(stderr, f, p1, p2, p3); - fprintf(stderr, "\n"); - - return (-1); -} - -/* -** SYSERR -- print system-generated error. -** -** Parameters: -** f -- format string to a printf. -** p1, p2, p3 -- parameters to f. -** -** Returns: -** never. -** -** Side Effects: -** none. -*/ - -/*VARARGS1*/ -syserr(f, p1, p2, p3) - char *f; -{ - extern int errno; - - fprintf(stderr, "\n%s SYSERR: ", MyName); - fprintf(stderr, f, p1, p2, p3); - fprintf(stderr, "\n"); - if (errno == 0) - exit(EX_SOFTWARE); - else - { - perror(NULL); - exit(EX_OSERR); - } -} - /* -** USERNAME -- return name of the current user -** -** Parameters: -** none -** -** Returns: -** name of current user -** -** Side Effects: -** none -*/ - -char * -username() -{ -# ifdef UIDUSER - extern struct passwd *getpwuid(); - register struct passwd *pw; - - pw = getpwuid(getuid()); - if (pw == NULL) - { - syserr("who are you? (uid=%d)", getuid()); - exit(EX_OSERR); - } - return (pw->pw_name); -# else - extern char *getlogin(); - register char *p; - - p = getenv("USER"); - if (p == NULL || p[0] == '\0') - p = getlogin(); - return (p); -# endif UIDUSER -} - -/* -** Guarded string manipulation routines; the last argument -** is the length of the buffer into which the strcpy or strcat -** is to be done. -*/ -char *gstrcat(to, from, length) - char *to, *from; - int length; -{ - if (strlen(from) + strlen(to) >= length) { - gstrbotch(to, from); - } - return(strcat(to, from)); -} - -char *gstrncat(to, from, n, length) - char *to, *from; - int n; - int length; -{ - if (n + strlen(to) >= length) { - gstrbotch(to, from); - } - return(strncat(to, from, n)); -} - -char *gstrcpy(to, from, length) - char *to, *from; - int length; -{ - if (strlen(from) >= length) { - gstrbotch(from, (char *)0); - } - return(strcpy(to, from)); -} -gstrbotch(str1, str2) - char *str1, *str2; -{ - usrerr("Filename(s) too long: %s %s", str1, str2); -} diff --git a/usr.bin/sort/sort.1 b/usr.bin/sort/sort.1 deleted file mode 100644 index 0ff0633..0000000 --- a/usr.bin/sort/sort.1 +++ /dev/null @@ -1,310 +0,0 @@ -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the Institute of Electrical and Electronics Engineers, Inc. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)sort.1 8.1 (Berkeley) 6/10/93 -.\" -.Dd June 10, 1993 -.Dt SORT 1 -.Os -.Sh NAME -.Nm sort -.Nd sort or merge text files -.Sh SYNOPSIS -.Nm sort -.Op Fl mubdfinrtx -.Oo -.Cm \(pl Ns Ar pos1 -.Op Fl Ns Ar pos2 -.Oc -.Ar ... -.Op Fl o Ar output -.Op Fl T Ar directory -.Op Ar file -.Ar ... -.Sh DESCRIPTION -The -.Nm sort -utility -sorts text files by lines. -Comparisons are based on one or more sort keys (or fields) extracted -from each line of input, and are performed -lexicographically. By default, if keys are not given, -.Nm sort -regards each input line as a single field. -.Pp -The following options are available: -.Bl -tag -width indent -.It Fl c -Check that the single input file is sorted lexicographically. -If the file is not sorted, -.Nm sort -sorts it and writes the sorted output to the standard output or the -filename specified by the -.Fl o -option. -.It Fl m -Merge only; the input files are assumed to be pre-sorted. -.It Fl o Ar output -The argument given is the name of an -.Ar output -file to -be used instead of the standard output. -This file -can be the same as one of the input files. -.It Fl T Ar directory -The argument -.Ar directory -is used for creating temporary files. -.It Fl u -Unique: suppress all but one in each set of lines -having equal keys. -If used with the -.Fl c -option, -check that there are no lines with duplicate keys. -.El -.Pp -The following options override the default ordering rules. -When ordering options appear independent of key field -specifications, the requested field ordering rules are -applied globally to all sort keys. -.\" When attached to a -.\" specific key -.\" (see -.\" .Fl k ) , -.\" the specified ordering options override -.\" all global ordering options for that key. -.Bl -tag -width indent -.It Fl d -Only blank space and alphanumeric characters -.\" according -.\" to the current setting of LC_CTYPE -are used -in making comparisons. -.It Fl f -Considers all lowercase characters that have uppercase -equivalents to be the same for purposes of -comparison. -.It Fl i -Ignore all non-printable characters. -.It Fl n -An initial numeric string, consisting of optional -blank space, optional minus sign, and zero or more -digits (including decimal point) -.\" with -.\" optional radix character and thousands -.\" separator -.\" (as defined in the current locale), -is sorted by arithmetic value. -The -.Fl n -option implies -the -.Fl b -option. (See below.) -Note that the -.Fl b -option -is only effective when key fields have been specified -and that -.Fl \&0 -is considered equal to zero. -.optional It Fl r -Reverse the sense of comparisons. -.El -.Pp -The treatment of field separators can be altered using the -options: -.Bl -tag -width indent -.It Fl b -Leading blank spaces are ignored when determining the starting -ending positions of a restricted sort key. -If the -.Fl b -option is specified before the first -.Cm \(pl Ns Ar pos1 -argument, it shall be applied to all -.Cm \(pl Ns Ar pos1 -arguments. -Otherwise, the -.Fl b -option can be -attached independently to each -.Cm \(pl Ns Ar pos1 -or -.Fl Ar pos2 -argument (see below). -.It Fl t Ar char -.Ar Char -is used as the field separator character; -.Ar char -is not considered to be part of a field (although it -can be included in a sort key). -Each occurrence of -.Ar char -is significant (for example, -.Dq Ar charchar -delimits an empty field). -If -.Fl t -is not specified, -blank space characters are used as default field -separators. -.It Cm \(pl Ns Ar pos1 -Designates the start position of a key field. -.It Fl Ns Ar pos1 -Designates the end position of a key field. -.El -.Pp -The following operands are available: -.Bl -tag -width indent -.Ar file -The pathname of a file to be sorted, merged, or checked. -If no file -operands are specified, or if -a file operand is -.Fl , -the standard input is used. -.Pp -A field is -defined as a minimal sequence of characters followed by a -field separator or a newline character. -By default, the first -blank space of a sequence of blank spaces acts as the field separator. -All blank spaces in a sequence of blank spaces are considered -to be part of the next field; for example, all blank spaces at -the beginning of a line are considered to be part of the -first field. -.Pp -Fields are specified -by the -.Cm \(pl Ns Ar pos1 -and -.Fl Ar pos2 -arguments. A missing -.Cm \(pl Ns Ar pos1 -argument defaults to the beginning of a line. -A missing -.Fl Ar pos2 -argument defaults to the end of a line. -.Pp -The arguments -.Cm \(pl Ns Ar pos1 -and -.Fl Ar pos2 -have the form -.Em m.n -followed by one or more of the options -.Fl b , d , f , i , -.Fl n , r . -A -.Cm \(pl Ns Ar pos1 -position specified by -.Em m.n -is interpreted to -mean the -.Em n Ns th -character in the -.Em m Ns \(pl1th -field. -A missing -.Em \&.n -means -.Ql \&.0 , -indicating the first character of the -.Em m Ns \(pl1th -field. -If the -.Fl b -option is in effect, -.Em n -is counted from the first -non-blank character in the -.Em m Ns \(pl1th -field; -.Em m Ns \&.0b -refers to the first -non-blank character in the -.Em m Ns \(pl1th -field. -.Pp -A -.Fl Ar pos2 -position specified by -.Em m.n -is interpreted to mean -the -.Em n Ns th -character (including separators) after the last -character of the -.Em m Ns th -field. -A missing -.Em \&.n -means -.Ql \&.0 , -indicating -the last character of the -.Em m Ns th -field. -If the -.Fl b -option -is in effect, -.Em n -is counted from the last leading blank character in -the -.Em m Ns \(pl1th -field; -.Em m Ns \&.1b -refers to the first non-blank character in the -.Em m Ns \(pl1th -field. -.Sh FILES -.Bl -tag -width Pa -compact -.It Pa /var/tmp/stm*, /tmp/* -Default temporary directories (in order of search). -.El -.Sh SEE ALSO -.Xr comm 1 , -.Xr uniq 1 , -.Xr join 1 -.Sh DIAGNOSTICS -.Sh BUGS -Lines which are longer than 4096 are discarded and processing continues. -.Sh HISTORY -A -.Nm -command appeared in -.At v6 . diff --git a/usr.bin/timedef/Makefile b/usr.bin/timedef/Makefile deleted file mode 100644 index 80fe8d9..0000000 --- a/usr.bin/timedef/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# $Id: Makefile,v 1.3 1995/06/19 22:15:35 asami Exp $ - -LOCALES= ru_SU.KOI8-R -LOCALEDIR= ${DESTDIR}/usr/share/locale - -afterinstall: - for l in ${LOCALES}; do \ - grep -v '^#' < ${.CURDIR}/data/$$l > ${LOCALEDIR}/$$l/LC_TIME; \ - chown ${BINOWN}.${BINGRP} ${LOCALEDIR}/$$l/LC_TIME; \ - chmod 644 ${LOCALEDIR}/$$l/LC_TIME; \ - done - -.include diff --git a/usr.bin/tip/acu.c b/usr.bin/tip/acu.c deleted file mode 100644 index f7bde99..0000000 --- a/usr.bin/tip/acu.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)acu.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -static acu_t *acu = NOACU; -static int conflag; -static void acuabort(); -static acu_t *acutype(); -static jmp_buf jmpbuf; -/* - * Establish connection for tip - * - * If DU is true, we should dial an ACU whose type is AT. - * The phone numbers are in PN, and the call unit is in CU. - * - * If the PN is an '@', then we consult the PHONES file for - * the phone numbers. This file is /etc/phones, unless overriden - * by an exported shell variable. - * - * The data base files must be in the format: - * host-name[ \t]*phone-number - * with the possibility of multiple phone numbers - * for a single host acting as a rotary (in the order - * found in the file). - */ -char * -connect() -{ - register char *cp = PN; - char *phnum, string[256]; - FILE *fd; - int tried = 0; - - if (!DU) { /* regular connect message */ - if (CM != NOSTR) - pwrite(FD, CM, size(CM)); - logent(value(HOST), "", DV, "call completed"); - return (NOSTR); - } - /* - * @ =>'s use data base in PHONES environment variable - * otherwise, use /etc/phones - */ - signal(SIGINT, acuabort); - signal(SIGQUIT, acuabort); - if (setjmp(jmpbuf)) { - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - printf("\ncall aborted\n"); - logent(value(HOST), "", "", "call aborted"); - if (acu != NOACU) { - boolean(value(VERBOSE)) = FALSE; - if (conflag) - disconnect(NOSTR); - else - (*acu->acu_abort)(); - } - return ("interrupt"); - } - if ((acu = acutype(AT)) == NOACU) - return ("unknown ACU type"); - if (*cp != '@') { - while (*cp) { - for (phnum = cp; *cp && *cp != ','; cp++) - ; - if (*cp) - *cp++ = '\0'; - - if (conflag = (*acu->acu_dialer)(phnum, CU)) { - if (CM != NOSTR) - pwrite(FD, CM, size(CM)); - logent(value(HOST), phnum, acu->acu_name, - "call completed"); - return (NOSTR); - } else - logent(value(HOST), phnum, acu->acu_name, - "call failed"); - tried++; - } - } else { - if ((fd = fopen(PH, "r")) == NOFILE) { - printf("%s: ", PH); - return ("can't open phone number file"); - } - while (fgets(string, sizeof(string), fd) != NOSTR) { - for (cp = string; !any(*cp, " \t\n"); cp++) - ; - if (*cp == '\n') { - fclose(fd); - return ("unrecognizable host name"); - } - *cp++ = '\0'; - if (strcmp(string, value(HOST))) - continue; - while (any(*cp, " \t")) - cp++; - if (*cp == '\n') { - fclose(fd); - return ("missing phone number"); - } - for (phnum = cp; *cp && *cp != ',' && *cp != '\n'; cp++) - ; - if (*cp) - *cp++ = '\0'; - - if (conflag = (*acu->acu_dialer)(phnum, CU)) { - fclose(fd); - if (CM != NOSTR) - pwrite(FD, CM, size(CM)); - logent(value(HOST), phnum, acu->acu_name, - "call completed"); - return (NOSTR); - } else - logent(value(HOST), phnum, acu->acu_name, - "call failed"); - tried++; - } - fclose(fd); - } - if (!tried) - logent(value(HOST), "", acu->acu_name, "missing phone number"); - else - (*acu->acu_abort)(); - return (tried ? "call failed" : "missing phone number"); -} - -disconnect(reason) - char *reason; -{ - if (!conflag) { - logent(value(HOST), "", DV, "call terminated"); - return; - } - if (reason == NOSTR) { - logent(value(HOST), "", acu->acu_name, "call terminated"); - if (boolean(value(VERBOSE))) - printf("\r\ndisconnecting..."); - } else - logent(value(HOST), "", acu->acu_name, reason); - (*acu->acu_disconnect)(); -} - -static void -acuabort(s) -{ - signal(s, SIG_IGN); - longjmp(jmpbuf, 1); -} - -static acu_t * -acutype(s) - register char *s; -{ - register acu_t *p; - extern acu_t acutable[]; - - for (p = acutable; p->acu_name != '\0'; p++) - if (!strcmp(s, p->acu_name)) - return (p); - return (NOACU); -} diff --git a/usr.bin/tip/aculib/biz22.c b/usr.bin/tip/aculib/biz22.c deleted file mode 100644 index 93c5e53..0000000 --- a/usr.bin/tip/aculib/biz22.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)biz22.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -#define DISCONNECT_CMD "\20\04" /* disconnection string */ - -static void sigALRM(); -static int timeout = 0; -static jmp_buf timeoutbuf; - -/* - * Dial up on a BIZCOMP Model 1022 with either - * tone dialing (mod = "V") - * pulse dialing (mod = "W") - */ -static int -biz_dialer(num, mod) - char *num, *mod; -{ - register int connected = 0; - char cbuf[40]; - static int cmd(), detect(); - - if (boolean(value(VERBOSE))) - printf("\nstarting call..."); - /* - * Disable auto-answer and configure for tone/pulse - * dialing - */ - if (cmd("\02K\r")) { - printf("can't initialize bizcomp..."); - return (0); - } - strcpy(cbuf, "\02.\r"); - cbuf[1] = *mod; - if (cmd(cbuf)) { - printf("can't set dialing mode..."); - return (0); - } - strcpy(cbuf, "\02D"); - strcat(cbuf, num); - strcat(cbuf, "\r"); - write(FD, cbuf, strlen(cbuf)); - if (!detect("7\r")) { - printf("can't get dial tone..."); - return (0); - } - if (boolean(value(VERBOSE))) - printf("ringing..."); - /* - * The reply from the BIZCOMP should be: - * 2 \r or 7 \r failure - * 1 \r success - */ - connected = detect("1\r"); -#ifdef ACULOG - if (timeout) { - char line[80]; - - sprintf(line, "%d second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "biz1022", line); - } -#endif - if (timeout) - biz22_disconnect(); /* insurance */ - return (connected); -} - -biz22w_dialer(num, acu) - char *num, *acu; -{ - - return (biz_dialer(num, "W")); -} - -biz22f_dialer(num, acu) - char *num, *acu; -{ - - return (biz_dialer(num, "V")); -} - -biz22_disconnect() -{ - int rw = 2; - - write(FD, DISCONNECT_CMD, 4); - sleep(2); - ioctl(FD, TIOCFLUSH, &rw); -} - -biz22_abort() -{ - - write(FD, "\02", 1); -} - -static void -sigALRM() -{ - - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -cmd(s) - register char *s; -{ - sig_t f; - char c; - - write(FD, s, strlen(s)); - f = signal(SIGALRM, sigALRM); - if (setjmp(timeoutbuf)) { - biz22_abort(); - signal(SIGALRM, f); - return (1); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - signal(SIGALRM, f); - c &= 0177; - return (c != '\r'); -} - -static int -detect(s) - register char *s; -{ - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - timeout = 0; - while (*s) { - if (setjmp(timeoutbuf)) { - biz22_abort(); - break; - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - c &= 0177; - if (c != *s++) - return (0); - } - signal(SIGALRM, f); - return (timeout == 0); -} diff --git a/usr.bin/tip/aculib/biz31.c b/usr.bin/tip/aculib/biz31.c deleted file mode 100644 index 412974d..0000000 --- a/usr.bin/tip/aculib/biz31.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)biz31.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -#define MAXRETRY 3 /* sync up retry count */ -#define DISCONNECT_CMD "\21\25\11\24" /* disconnection string */ - -static void sigALRM(); -static int timeout = 0; -static jmp_buf timeoutbuf; - -/* - * Dial up on a BIZCOMP Model 1031 with either - * tone dialing (mod = "f") - * pulse dialing (mod = "w") - */ -static int -biz_dialer(num, mod) - char *num, *mod; -{ - register int connected = 0; - - if (!bizsync(FD)) { - logent(value(HOST), "", "biz", "out of sync"); - printf("bizcomp out of sync\n"); - delock(uucplock); - exit(0); - } - if (boolean(value(VERBOSE))) - printf("\nstarting call..."); - echo("#\rk$\r$\n"); /* disable auto-answer */ - echo("$>$.$ #\r"); /* tone/pulse dialing */ - echo(mod); - echo("$\r$\n"); - echo("$>$.$ #\re$ "); /* disconnection sequence */ - echo(DISCONNECT_CMD); - echo("\r$\n$\r$\n"); - echo("$>$.$ #\rr$ "); /* repeat dial */ - echo(num); - echo("\r$\n"); - if (boolean(value(VERBOSE))) - printf("ringing..."); - /* - * The reply from the BIZCOMP should be: - * `^G NO CONNECTION\r\n^G\r\n' failure - * ` CONNECTION\r\n^G' success - */ - connected = detect(" "); -#ifdef ACULOG - if (timeout) { - char line[80]; - - sprintf(line, "%d second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "biz", line); - } -#endif - if (!connected) - flush(" NO CONNECTION\r\n\07\r\n"); - else - flush("CONNECTION\r\n\07"); - if (timeout) - biz31_disconnect(); /* insurance */ - return (connected); -} - -biz31w_dialer(num, acu) - char *num, *acu; -{ - - return (biz_dialer(num, "w")); -} - -biz31f_dialer(num, acu) - char *num, *acu; -{ - - return (biz_dialer(num, "f")); -} - -biz31_disconnect() -{ - - write(FD, DISCONNECT_CMD, 4); - sleep(2); - ioctl(FD, TIOCFLUSH); -} - -biz31_abort() -{ - - write(FD, "\33", 1); -} - -static int -echo(s) - register char *s; -{ - char c; - - while (c = *s++) switch (c) { - - case '$': - read(FD, &c, 1); - s++; - break; - - case '#': - c = *s++; - write(FD, &c, 1); - break; - - default: - write(FD, &c, 1); - read(FD, &c, 1); - } -} - -static void -sigALRM() -{ - - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -detect(s) - register char *s; -{ - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - timeout = 0; - while (*s) { - if (setjmp(timeoutbuf)) { - printf("\07timeout waiting for reply\n"); - biz31_abort(); - break; - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - if (c != *s++) - break; - } - signal(SIGALRM, f); - return (timeout == 0); -} - -static int -flush(s) - register char *s; -{ - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - while (*s++) { - if (setjmp(timeoutbuf)) - break; - alarm(10); - read(FD, &c, 1); - alarm(0); - } - signal(SIGALRM, f); - timeout = 0; /* guard against disconnection */ -} - -/* - * This convoluted piece of code attempts to get - * the bizcomp in sync. If you don't have the capacity or nread - * call there are gory ways to simulate this. - */ -static int -bizsync(fd) -{ -#ifdef FIOCAPACITY - struct capacity b; -# define chars(b) ((b).cp_nbytes) -# define IOCTL FIOCAPACITY -#endif -#ifdef FIONREAD - long b; -# define chars(b) (b) -# define IOCTL FIONREAD -#endif - register int already = 0; - char buf[10]; - -retry: - if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0 && chars(b) > 0) - ioctl(fd, TIOCFLUSH); - write(fd, "\rp>\r", 4); - sleep(1); - if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0) { - if (chars(b) != 10) { - nono: - if (already > MAXRETRY) - return (0); - write(fd, DISCONNECT_CMD, 4); - sleep(2); - already++; - goto retry; - } else { - read(fd, buf, 10); - if (strncmp(buf, "p >\r\n\r\n>", 8)) - goto nono; - } - } - return (1); -} diff --git a/usr.bin/tip/aculib/courier.c b/usr.bin/tip/aculib/courier.c deleted file mode 100644 index 85f7b0d..0000000 --- a/usr.bin/tip/aculib/courier.c +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Copyright (c) 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)courier.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for calling up on a Courier modem. - * Derived from Hayes driver. - */ -#include "tip.h" -#include - -#define MAXRETRY 5 - -static void sigALRM(); -static int timeout = 0; -static int connected = 0; -static jmp_buf timeoutbuf, intbuf; -static int coursync(); - -cour_dialer(num, acu) - register char *num; - char *acu; -{ - register char *cp; -#ifdef ACULOG - char line[80]; -#endif - static int cour_connect(), cour_swallow(); - - if (boolean(value(VERBOSE))) - printf("Using \"%s\"\n", acu); - - ioctl(FD, TIOCHPCL, 0); - /* - * Get in synch. - */ - if (!coursync()) { -badsynch: - printf("can't synchronize with courier\n"); -#ifdef ACULOG - logent(value(HOST), num, "courier", "can't synch up"); -#endif - return (0); - } - cour_write(FD, "AT E0\r", 6); /* turn off echoing */ - sleep(1); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - cour_verbose_read(); -#endif - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ - cour_write(FD, "AT C1 E0 H0 Q0 X6 V1\r", 21); - if (!cour_swallow("\r\nOK\r\n")) - goto badsynch; - fflush(stdout); - cour_write(FD, "AT D", 4); - for (cp = num; *cp; cp++) - if (*cp == '=') - *cp = ','; - cour_write(FD, num, strlen(num)); - cour_write(FD, "\r", 1); - connected = cour_connect(); -#ifdef ACULOG - if (timeout) { - sprintf(line, "%d second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "cour", line); - } -#endif - if (timeout) - cour_disconnect(); - return (connected); -} - -cour_disconnect() -{ - /* first hang up the modem*/ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - coursync(); /* reset */ - close(FD); -} - -cour_abort() -{ - cour_write(FD, "\r", 1); /* send anything to abort the call */ - cour_disconnect(); -} - -static void -sigALRM() -{ - printf("\07timeout waiting for reply\n"); - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -cour_swallow(match) - register char *match; - { - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - timeout = 0; - do { - if (*match =='\0') { - signal(SIGALRM, f); - return (1); - } - if (setjmp(timeoutbuf)) { - signal(SIGALRM, f); - return (0); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - c &= 0177; -#ifdef DEBUG - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } while (c == *match++); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - fflush(stdout); -#endif - signal(SIGALRM, SIG_DFL); - return (0); -} - -struct baud_msg { - char *msg; - int baud; -} baud_msg[] = { - "", B300, - " 1200", B1200, - " 2400", B2400, - " 9600", B9600, - " 9600/ARQ", B9600, - 0, 0, -}; - -static int -cour_connect() -{ - char c; - int nc, nl, n; - struct sgttyb sb; - char dialer_buf[64]; - struct baud_msg *bm; - sig_t f; - - if (cour_swallow("\r\n") == 0) - return (0); - f = signal(SIGALRM, sigALRM); -again: - nc = 0; nl = sizeof(dialer_buf)-1; - bzero(dialer_buf, sizeof(dialer_buf)); - timeout = 0; - for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) { - if (setjmp(timeoutbuf)) - break; - alarm(number(value(DIALTIMEOUT))); - n = read(FD, &c, 1); - alarm(0); - if (n <= 0) - break; - c &= 0x7f; - if (c == '\r') { - if (cour_swallow("\n") == 0) - break; - if (!dialer_buf[0]) - goto again; - if (strcmp(dialer_buf, "RINGING") == 0 && - boolean(value(VERBOSE))) { -#ifdef DEBUG - printf("%s\r\n", dialer_buf); -#endif - goto again; - } - if (strncmp(dialer_buf, "CONNECT", - sizeof("CONNECT")-1) != 0) - break; - for (bm = baud_msg ; bm->msg ; bm++) - if (strcmp(bm->msg, - dialer_buf+sizeof("CONNECT")-1) == 0) { - if (ioctl(FD, TIOCGETP, &sb) < 0) { - perror("TIOCGETP"); - goto error; - } - sb.sg_ispeed = sb.sg_ospeed = bm->baud; - if (ioctl(FD, TIOCSETP, &sb) < 0) { - perror("TIOCSETP"); - goto error; - } - signal(SIGALRM, f); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - printf("%s\r\n", dialer_buf); -#endif - return (1); - } - break; - } - dialer_buf[nc] = c; -#ifdef notdef - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } -error1: - printf("%s\r\n", dialer_buf); -error: - signal(SIGALRM, f); - return (0); -} - -/* - * This convoluted piece of code attempts to get - * the courier in sync. - */ -static int -coursync() -{ - int already = 0; - int len; - char buf[40]; - - while (already++ < MAXRETRY) { - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ - cour_write(FD, "\rAT Z\r", 6); /* reset modem */ - bzero(buf, sizeof(buf)); - sleep(1); - ioctl(FD, FIONREAD, &len); - if (len) { - len = read(FD, buf, sizeof(buf)); -#ifdef DEBUG - buf[len] = '\0'; - printf("coursync: (\"%s\")\n\r", buf); -#endif - if (index(buf, '0') || - (index(buf, 'O') && index(buf, 'K'))) - return(1); - } - /* - * If not strapped for DTR control, - * try to get command mode. - */ - sleep(1); - cour_write(FD, "+++", 3); - sleep(1); - /* - * Toggle DTR to force anyone off that might have left - * the modem connected. - */ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - } - cour_write(FD, "\rAT Z\r", 6); - return (0); -} - -cour_write(fd, cp, n) -int fd; -char *cp; -int n; -{ - struct sgttyb sb; -#ifdef notdef - if (boolean(value(VERBOSE))) - write(1, cp, n); -#endif - ioctl(fd, TIOCGETP, &sb); - ioctl(fd, TIOCSETP, &sb); - cour_nap(); - for ( ; n-- ; cp++) { - write(fd, cp, 1); - ioctl(fd, TIOCGETP, &sb); - ioctl(fd, TIOCSETP, &sb); - cour_nap(); - } -} - -#ifdef DEBUG -cour_verbose_read() -{ - int n = 0; - char buf[BUFSIZ]; - - if (ioctl(FD, FIONREAD, &n) < 0) - return; - if (n <= 0) - return; - if (read(FD, buf, n) != n) - return; - write(1, buf, n); -} -#endif - -/* - * Code stolen from /usr/src/lib/libc/gen/sleep.c - */ -#define mask(s) (1<<((s)-1)) -#define setvec(vec, a) \ - vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0 - -static napms = 50; /* Give the courier 50 milliseconds between characters */ - -static int ringring; - -cour_nap() -{ - - static void cour_napx(); - int omask; - struct itimerval itv, oitv; - register struct itimerval *itp = &itv; - struct sigvec vec, ovec; - - timerclear(&itp->it_interval); - timerclear(&itp->it_value); - if (setitimer(ITIMER_REAL, itp, &oitv) < 0) - return; - setvec(ovec, SIG_DFL); - omask = sigblock(mask(SIGALRM)); - itp->it_value.tv_sec = napms/1000; - itp->it_value.tv_usec = ((napms%1000)*1000); - setvec(vec, cour_napx); - ringring = 0; - (void) sigvec(SIGALRM, &vec, &ovec); - (void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0); - while (!ringring) - sigpause(omask &~ mask(SIGALRM)); - (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0); - (void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0); - (void) sigsetmask(omask); -} - -static void -cour_napx() -{ - ringring = 1; -} diff --git a/usr.bin/tip/aculib/df.c b/usr.bin/tip/aculib/df.c deleted file mode 100644 index 5f294f9..0000000 --- a/usr.bin/tip/aculib/df.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)df.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Dial the DF02-AC or DF03-AC - */ - -#include "tip.h" - -static jmp_buf Sjbuf; -static void timeout(); - -df02_dialer(num, acu) - char *num, *acu; -{ - - return (df_dialer(num, acu, 0)); -} - -df03_dialer(num, acu) - char *num, *acu; -{ - - return (df_dialer(num, acu, 1)); -} - -df_dialer(num, acu, df03) - char *num, *acu; - int df03; -{ - register int f = FD; - struct sgttyb buf; - int speed = 0, rw = 2; - char c = '\0'; - - ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */ - if (setjmp(Sjbuf)) { - printf("connection timed out\r\n"); - df_disconnect(); - return (0); - } - if (boolean(value(VERBOSE))) - printf("\ndialing..."); - fflush(stdout); -#ifdef TIOCMSET - if (df03) { - int st = TIOCM_ST; /* secondary Transmit flag */ - - ioctl(f, TIOCGETP, &buf); - if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */ - speed = buf.sg_ospeed; - buf.sg_ospeed = buf.sg_ispeed = B1200; - ioctl(f, TIOCSETP, &buf); - ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */ - } else - ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */ - } -#endif - signal(SIGALRM, timeout); - alarm(5 * strlen(num) + 10); - ioctl(f, TIOCFLUSH, &rw); - write(f, "\001", 1); - sleep(1); - write(f, "\002", 1); - write(f, num, strlen(num)); - read(f, &c, 1); -#ifdef TIOCMSET - if (df03 && speed) { - buf.sg_ispeed = buf.sg_ospeed = speed; - ioctl(f, TIOCSETP, &buf); - } -#endif - return (c == 'A'); -} - -df_disconnect() -{ - int rw = 2; - - write(FD, "\001", 1); - sleep(1); - ioctl(FD, TIOCFLUSH, &rw); -} - - -df_abort() -{ - - df_disconnect(); -} - - -static void -timeout() -{ - - longjmp(Sjbuf, 1); -} diff --git a/usr.bin/tip/aculib/dn11.c b/usr.bin/tip/aculib/dn11.c deleted file mode 100644 index 152b376..0000000 --- a/usr.bin/tip/aculib/dn11.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)dn11.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for dialing up on DN-11 - */ -#include "tip.h" - -int dn_abort(); -void alarmtr(); -static jmp_buf jmpbuf; -static int child = -1, dn; - -dn_dialer(num, acu) - char *num, *acu; -{ - extern errno; - char *p, *q, phone[40]; - int lt, nw, connected = 1; - register int timelim; - - if (boolean(value(VERBOSE))) - printf("\nstarting call..."); - if ((dn = open(acu, 1)) < 0) { - if (errno == EBUSY) - printf("line busy..."); - else - printf("acu open error..."); - return (0); - } - if (setjmp(jmpbuf)) { - kill(child, SIGKILL); - close(dn); - return (0); - } - signal(SIGALRM, alarmtr); - timelim = 5 * strlen(num); - alarm(timelim < 30 ? 30 : timelim); - if ((child = fork()) == 0) { - /* - * ignore this stuff for aborts - */ - signal(SIGALRM, SIG_IGN); - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - sleep(2); - nw = write(dn, num, lt = strlen(num)); - exit(nw != lt); - } - /* - * open line - will return on carrier - */ - if ((FD = open(DV, 2)) < 0) { - if (errno == EIO) - printf("lost carrier..."); - else - printf("dialup line open failed..."); - alarm(0); - kill(child, SIGKILL); - close(dn); - return (0); - } - alarm(0); - ioctl(dn, TIOCHPCL, 0); - signal(SIGALRM, SIG_DFL); - while ((nw = wait(<)) != child && nw != -1) - ; - fflush(stdout); - close(dn); - if (lt != 0) { - close(FD); - return (0); - } - return (1); -} - -void -alarmtr() -{ - alarm(0); - longjmp(jmpbuf, 1); -} - -/* - * Insurance, for some reason we don't seem to be - * hanging up... - */ -dn_disconnect() -{ - - sleep(2); - if (FD > 0) - ioctl(FD, TIOCCDTR, 0); - close(FD); -} - -dn_abort() -{ - - sleep(2); - if (child > 0) - kill(child, SIGKILL); - if (dn > 0) - close(dn); - if (FD > 0) - ioctl(FD, TIOCCDTR, 0); - close(FD); -} diff --git a/usr.bin/tip/aculib/hayes.c b/usr.bin/tip/aculib/hayes.c deleted file mode 100644 index a2196f4..0000000 --- a/usr.bin/tip/aculib/hayes.c +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)hayes.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for calling up on a Hayes Modem - * (based on the old VenTel driver). - * The modem is expected to be strapped for "echo". - * Also, the switches enabling the DTR and CD lines - * must be set correctly. - * NOTICE: - * The easy way to hang up a modem is always simply to - * clear the DTR signal. However, if the +++ sequence - * (which switches the modem back to local mode) is sent - * before modem is hung up, removal of the DTR signal - * has no effect (except that it prevents the modem from - * recognizing commands). - * (by Helge Skrivervik, Calma Company, Sunnyvale, CA. 1984) - */ -/* - * TODO: - * It is probably not a good idea to switch the modem - * state between 'verbose' and terse (status messages). - * This should be kicked out and we should use verbose - * mode only. This would make it consistent with normal - * interactive use thru the command 'tip dialer'. - */ -#include "tip.h" - -#define min(a,b) ((a < b) ? a : b) - -static void sigALRM(); -static int timeout = 0; -static jmp_buf timeoutbuf; -static char gobble(); -#define DUMBUFLEN 40 -static char dumbuf[DUMBUFLEN]; - -#define DIALING 1 -#define IDLE 2 -#define CONNECTED 3 -#define FAILED 4 -static int state = IDLE; - -hay_dialer(num, acu) - register char *num; - char *acu; -{ - register char *cp; - register int connected = 0; - char dummy; -#ifdef ACULOG - char line[80]; -#endif - if (hay_sync() == 0) /* make sure we can talk to the modem */ - return(0); - if (boolean(value(VERBOSE))) - printf("\ndialing..."); - fflush(stdout); - ioctl(FD, TIOCHPCL, 0); - ioctl(FD, TIOCFLUSH, 0); /* get rid of garbage */ - write(FD, "ATv0\r", 5); /* tell modem to use short status codes */ - gobble("\r"); - gobble("\r"); - write(FD, "ATTD", 4); /* send dial command */ - write(FD, num, strlen(num)); - state = DIALING; - write(FD, "\r", 1); - connected = 0; - if (gobble("\r")) { - if ((dummy = gobble("01234")) != '1') - error_rep(dummy); - else - connected = 1; - } - if (connected) - state = CONNECTED; - else { - state = FAILED; - return (connected); /* lets get out of here.. */ - } - ioctl(FD, TIOCFLUSH, 0); -#ifdef ACULOG - if (timeout) { - sprintf(line, "%d second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "hayes", line); - } -#endif - if (timeout) - hay_disconnect(); /* insurance */ - return (connected); -} - - -hay_disconnect() -{ - char c; - int len, rlen; - - /* first hang up the modem*/ -#ifdef DEBUG - printf("\rdisconnecting modem....\n\r"); -#endif - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - goodbye(); -} - -hay_abort() -{ - - char c; - - write(FD, "\r", 1); /* send anything to abort the call */ - hay_disconnect(); -} - -static void -sigALRM() -{ - - printf("\07timeout waiting for reply\n\r"); - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static char -gobble(match) - register char *match; -{ - char c; - sig_t f; - int i, status = 0; - - f = signal(SIGALRM, sigALRM); - timeout = 0; -#ifdef DEBUG - printf("\ngobble: waiting for %s\n", match); -#endif - do { - if (setjmp(timeoutbuf)) { - signal(SIGALRM, f); - return (0); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - c &= 0177; -#ifdef DEBUG - printf("%c 0x%x ", c, c); -#endif - for (i = 0; i < strlen(match); i++) - if (c == match[i]) - status = c; - } while (status == 0); - signal(SIGALRM, SIG_DFL); -#ifdef DEBUG - printf("\n"); -#endif - return (status); -} - -error_rep(c) - register char c; -{ - printf("\n\r"); - switch (c) { - - case '0': - printf("OK"); - break; - - case '1': - printf("CONNECT"); - break; - - case '2': - printf("RING"); - break; - - case '3': - printf("NO CARRIER"); - break; - - case '4': - printf("ERROR in input"); - break; - - case '5': - printf("CONNECT 1200"); - break; - - default: - printf("Unknown Modem error: %c (0x%x)", c, c); - } - printf("\n\r"); - return; -} - -/* - * set modem back to normal verbose status codes. - */ -goodbye() -{ - int len, rlen; - char c; - - ioctl(FD, TIOCFLUSH, &len); /* get rid of trash */ - if (hay_sync()) { - sleep(1); -#ifndef DEBUG - ioctl(FD, TIOCFLUSH, 0); -#endif - write(FD, "ATH0\r", 5); /* insurance */ -#ifndef DEBUG - c = gobble("03"); - if (c != '0' && c != '3') { - printf("cannot hang up modem\n\r"); - printf("please use 'tip dialer' to make sure the line is hung up\n\r"); - } -#endif - sleep(1); - ioctl(FD, FIONREAD, &len); -#ifdef DEBUG - printf("goodbye1: len=%d -- ", len); - rlen = read(FD, dumbuf, min(len, DUMBUFLEN)); - dumbuf[rlen] = '\0'; - printf("read (%d): %s\r\n", rlen, dumbuf); -#endif - write(FD, "ATv1\r", 5); - sleep(1); -#ifdef DEBUG - ioctl(FD, FIONREAD, &len); - printf("goodbye2: len=%d -- ", len); - rlen = read(FD, dumbuf, min(len, DUMBUFLEN)); - dumbuf[rlen] = '\0'; - printf("read (%d): %s\r\n", rlen, dumbuf); -#endif - } - ioctl(FD, TIOCFLUSH, 0); /* clear the input buffer */ - ioctl(FD, TIOCCDTR, 0); /* clear DTR (insurance) */ - close(FD); -} - -#define MAXRETRY 5 - -hay_sync() -{ - int len, retry = 0; - - while (retry++ <= MAXRETRY) { - write(FD, "AT\r", 3); - sleep(1); - ioctl(FD, FIONREAD, &len); - if (len) { - len = read(FD, dumbuf, min(len, DUMBUFLEN)); - if (index(dumbuf, '0') || - (index(dumbuf, 'O') && index(dumbuf, 'K'))) - return(1); -#ifdef DEBUG - dumbuf[len] = '\0'; - printf("hay_sync: (\"%s\") %d\n\r", dumbuf, retry); -#endif - } - ioctl(FD, TIOCCDTR, 0); - ioctl(FD, TIOCSDTR, 0); - } - printf("Cannot synchronize with hayes...\n\r"); - return(0); -} diff --git a/usr.bin/tip/aculib/t3000.c b/usr.bin/tip/aculib/t3000.c deleted file mode 100644 index 5e07359..0000000 --- a/usr.bin/tip/aculib/t3000.c +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)t3000.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for calling up on a Telebit T3000 modem. - * Derived from Courier driver. - */ -#include "tip.h" -#include - -#define MAXRETRY 5 - -static void sigALRM(); -static int timeout = 0; -static int connected = 0; -static jmp_buf timeoutbuf, intbuf; -static int t3000_sync(); - -t3000_dialer(num, acu) - register char *num; - char *acu; -{ - register char *cp; -#ifdef ACULOG - char line[80]; -#endif - static int t3000_connect(), t3000_swallow(); - - if (boolean(value(VERBOSE))) - printf("Using \"%s\"\n", acu); - - ioctl(FD, TIOCHPCL, 0); - /* - * Get in synch. - */ - if (!t3000_sync()) { -badsynch: - printf("can't synchronize with t3000\n"); -#ifdef ACULOG - logent(value(HOST), num, "t3000", "can't synch up"); -#endif - return (0); - } - t3000_write(FD, "AT E0\r", 6); /* turn off echoing */ - sleep(1); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - t3000_verbose_read(); -#endif - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ - t3000_write(FD, "AT E0 H0 Q0 X4 V1\r", 18); - if (!t3000_swallow("\r\nOK\r\n")) - goto badsynch; - fflush(stdout); - t3000_write(FD, "AT D", 4); - for (cp = num; *cp; cp++) - if (*cp == '=') - *cp = ','; - t3000_write(FD, num, strlen(num)); - t3000_write(FD, "\r", 1); - connected = t3000_connect(); -#ifdef ACULOG - if (timeout) { - sprintf(line, "%d second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "t3000", line); - } -#endif - if (timeout) - t3000_disconnect(); - return (connected); -} - -t3000_disconnect() -{ - /* first hang up the modem*/ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - t3000_sync(); /* reset */ - close(FD); -} - -t3000_abort() -{ - t3000_write(FD, "\r", 1); /* send anything to abort the call */ - t3000_disconnect(); -} - -static void -sigALRM() -{ - printf("\07timeout waiting for reply\n"); - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -t3000_swallow(match) - register char *match; - { - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - timeout = 0; - do { - if (*match =='\0') { - signal(SIGALRM, f); - return (1); - } - if (setjmp(timeoutbuf)) { - signal(SIGALRM, f); - return (0); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - c &= 0177; -#ifdef DEBUG - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } while (c == *match++); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - fflush(stdout); -#endif - signal(SIGALRM, SIG_DFL); - return (0); -} - -#ifndef B19200 /* XXX */ -#define B19200 EXTA -#define B38400 EXTB -#endif - -struct tbaud_msg { - char *msg; - int baud; - int baud2; -} tbaud_msg[] = { - "", B300, 0, - " 1200", B1200, 0, - " 2400", B2400, 0, - " 4800", B4800, 0, - " 9600", B9600, 0, - " 14400", B19200, B9600, - " 19200", B19200, B9600, - " 38400", B38400, B9600, - " 57600", B38400, B9600, - " 7512", B9600, 0, - " 1275", B2400, 0, - " 7200", B9600, 0, - " 12000", B19200, B9600, - 0, 0, 0, -}; - -static int -t3000_connect() -{ - char c; - int nc, nl, n; - struct sgttyb sb; - char dialer_buf[64]; - struct tbaud_msg *bm; - sig_t f; - - if (t3000_swallow("\r\n") == 0) - return (0); - f = signal(SIGALRM, sigALRM); -again: - nc = 0; nl = sizeof(dialer_buf)-1; - bzero(dialer_buf, sizeof(dialer_buf)); - timeout = 0; - for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) { - if (setjmp(timeoutbuf)) - break; - alarm(number(value(DIALTIMEOUT))); - n = read(FD, &c, 1); - alarm(0); - if (n <= 0) - break; - c &= 0x7f; - if (c == '\r') { - if (t3000_swallow("\n") == 0) - break; - if (!dialer_buf[0]) - goto again; - if (strcmp(dialer_buf, "RINGING") == 0 && - boolean(value(VERBOSE))) { -#ifdef DEBUG - printf("%s\r\n", dialer_buf); -#endif - goto again; - } - if (strncmp(dialer_buf, "CONNECT", - sizeof("CONNECT")-1) != 0) - break; - for (bm = tbaud_msg ; bm->msg ; bm++) - if (strcmp(bm->msg, - dialer_buf+sizeof("CONNECT")-1) == 0) { - if (ioctl(FD, TIOCGETP, &sb) < 0) { - perror("TIOCGETP"); - goto error; - } - sb.sg_ispeed = sb.sg_ospeed = bm->baud; - if (ioctl(FD, TIOCSETP, &sb) < 0) { - if (bm->baud2) { - sb.sg_ispeed = - sb.sg_ospeed = - bm->baud2; - if (ioctl(FD, - TIOCSETP, - &sb) >= 0) - goto isok; - } - perror("TIOCSETP"); - goto error; - } -isok: - signal(SIGALRM, f); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - printf("%s\r\n", dialer_buf); -#endif - return (1); - } - break; - } - dialer_buf[nc] = c; -#ifdef notdef - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } -error1: - printf("%s\r\n", dialer_buf); -error: - signal(SIGALRM, f); - return (0); -} - -/* - * This convoluted piece of code attempts to get - * the t3000 in sync. - */ -static int -t3000_sync() -{ - int already = 0; - int len; - char buf[40]; - - while (already++ < MAXRETRY) { - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ - t3000_write(FD, "\rAT Z\r", 6); /* reset modem */ - bzero(buf, sizeof(buf)); - sleep(2); - ioctl(FD, FIONREAD, &len); -#if 1 -if (len == 0) len = 1; -#endif - if (len) { - len = read(FD, buf, sizeof(buf)); -#ifdef DEBUG - buf[len] = '\0'; - printf("t3000_sync: (\"%s\")\n\r", buf); -#endif - if (index(buf, '0') || - (index(buf, 'O') && index(buf, 'K'))) - return(1); - } - /* - * If not strapped for DTR control, - * try to get command mode. - */ - sleep(1); - t3000_write(FD, "+++", 3); - sleep(1); - /* - * Toggle DTR to force anyone off that might have left - * the modem connected. - */ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - } - t3000_write(FD, "\rAT Z\r", 6); - return (0); -} - -t3000_write(fd, cp, n) -int fd; -char *cp; -int n; -{ - struct sgttyb sb; - -#ifdef notdef - if (boolean(value(VERBOSE))) - write(1, cp, n); -#endif - ioctl(fd, TIOCGETP, &sb); - ioctl(fd, TIOCSETP, &sb); - t3000_nap(); - for ( ; n-- ; cp++) { - write(fd, cp, 1); - ioctl(fd, TIOCGETP, &sb); - ioctl(fd, TIOCSETP, &sb); - t3000_nap(); - } -} - -#ifdef DEBUG -t3000_verbose_read() -{ - int n = 0; - char buf[BUFSIZ]; - - if (ioctl(FD, FIONREAD, &n) < 0) - return; - if (n <= 0) - return; - if (read(FD, buf, n) != n) - return; - write(1, buf, n); -} -#endif - -/* - * Code stolen from /usr/src/lib/libc/gen/sleep.c - */ -#define mask(s) (1<<((s)-1)) -#define setvec(vec, a) \ - vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0 - -static napms = 50; /* Give the t3000 50 milliseconds between characters */ - -static int ringring; - -t3000_nap() -{ - - static void t3000_napx(); - int omask; - struct itimerval itv, oitv; - register struct itimerval *itp = &itv; - struct sigvec vec, ovec; - - timerclear(&itp->it_interval); - timerclear(&itp->it_value); - if (setitimer(ITIMER_REAL, itp, &oitv) < 0) - return; - setvec(ovec, SIG_DFL); - omask = sigblock(mask(SIGALRM)); - itp->it_value.tv_sec = napms/1000; - itp->it_value.tv_usec = ((napms%1000)*1000); - setvec(vec, t3000_napx); - ringring = 0; - (void) sigvec(SIGALRM, &vec, &ovec); - (void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0); - while (!ringring) - sigpause(omask &~ mask(SIGALRM)); - (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0); - (void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0); - (void) sigsetmask(omask); -} - -static void -t3000_napx() -{ - ringring = 1; -} diff --git a/usr.bin/tip/aculib/v3451.c b/usr.bin/tip/aculib/v3451.c deleted file mode 100644 index 1623a58..0000000 --- a/usr.bin/tip/aculib/v3451.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)v3451.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for calling up on a Vadic 3451 Modem - */ -#include "tip.h" - -static jmp_buf Sjbuf; - -v3451_dialer(num, acu) - register char *num; - char *acu; -{ - sig_t func; - int ok; - int slow = number(value(BAUDRATE)) < 1200, rw = 2; - char phone[50]; -#ifdef ACULOG - char line[80]; -#endif - static int expect(); - static void vawrite(); - - /* - * Get in synch - */ - vawrite("I\r", 1 + slow); - vawrite("I\r", 1 + slow); - vawrite("I\r", 1 + slow); - vawrite("\005\r", 2 + slow); - if (!expect("READY")) { - printf("can't synchronize with vadic 3451\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "can't synch up"); -#endif - return (0); - } - ioctl(FD, TIOCHPCL, 0); - sleep(1); - vawrite("D\r", 2 + slow); - if (!expect("NUMBER?")) { - printf("Vadic will not accept dial command\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "will not accept dial"); -#endif - return (0); - } - strcpy(phone, num); - strcat(phone, "\r"); - vawrite(phone, 1 + slow); - if (!expect(phone)) { - printf("Vadic will not accept phone number\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "will not accept number"); -#endif - return (0); - } - func = signal(SIGINT,SIG_IGN); - /* - * You cannot interrupt the Vadic when its dialing; - * even dropping DTR does not work (definitely a - * brain damaged design). - */ - vawrite("\r", 1 + slow); - vawrite("\r", 1 + slow); - if (!expect("DIALING:")) { - printf("Vadic failed to dial\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "failed to dial"); -#endif - return (0); - } - if (boolean(value(VERBOSE))) - printf("\ndialing..."); - ok = expect("ON LINE"); - signal(SIGINT, func); - if (!ok) { - printf("call failed\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "call failed"); -#endif - return (0); - } - ioctl(FD, TIOCFLUSH, &rw); - return (1); -} - -v3451_disconnect() -{ - - close(FD); -} - -v3451_abort() -{ - - close(FD); -} - -static void -vawrite(cp, delay) - register char *cp; - int delay; -{ - - for (; *cp; sleep(delay), cp++) - write(FD, cp, 1); -} - -static -expect(cp) - register char *cp; -{ - char buf[300]; - register char *rp = buf; - int timeout = 30, online = 0; - static int notin(); - static void alarmtr(); - - if (strcmp(cp, "\"\"") == 0) - return (1); - *rp = 0; - /* - * If we are waiting for the Vadic to complete - * dialing and get a connection, allow more time - * Unfortunately, the Vadic times out 24 seconds after - * the last digit is dialed - */ - online = strcmp(cp, "ON LINE") == 0; - if (online) - timeout = number(value(DIALTIMEOUT)); - signal(SIGALRM, alarmtr); - if (setjmp(Sjbuf)) - return (0); - alarm(timeout); - while (notin(cp, buf) && rp < buf + sizeof (buf) - 1) { - if (online && notin("FAILED CALL", buf) == 0) - return (0); - if (read(FD, rp, 1) < 0) { - alarm(0); - return (0); - } - if (*rp &= 0177) - rp++; - *rp = '\0'; - } - alarm(0); - return (1); -} - -static void -alarmtr() -{ - longjmp(Sjbuf, 1); -} - -static int -notin(sh, lg) - char *sh, *lg; -{ - static int prefix(); - - for (; *lg; lg++) - if (prefix(sh, lg)) - return (0); - return (1); -} - -static -prefix(s1, s2) - register char *s1, *s2; -{ - register char c; - - while ((c = *s1++) == *s2++) - if (c == '\0') - return (1); - return (c == '\0'); -} diff --git a/usr.bin/tip/aculib/v831.c b/usr.bin/tip/aculib/v831.c deleted file mode 100644 index 38aa230..0000000 --- a/usr.bin/tip/aculib/v831.c +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)v831.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for dialing up on Vadic 831 - */ -#include "tip.h" - -int v831_abort(); -static void alarmtr(); -extern int errno; - -static jmp_buf jmpbuf; -static int child = -1; - -v831_dialer(num, acu) - char *num, *acu; -{ - int status, pid, connected = 1; - register int timelim; - static int dialit(); - - if (boolean(value(VERBOSE))) - printf("\nstarting call..."); -#ifdef DEBUG - printf ("(acu=%s)\n", acu); -#endif - if ((AC = open(acu, O_RDWR)) < 0) { - if (errno == EBUSY) - printf("line busy..."); - else - printf("acu open error..."); - return (0); - } - if (setjmp(jmpbuf)) { - kill(child, SIGKILL); - close(AC); - return (0); - } - signal(SIGALRM, alarmtr); - timelim = 5 * strlen(num); - alarm(timelim < 30 ? 30 : timelim); - if ((child = fork()) == 0) { - /* - * ignore this stuff for aborts - */ - signal(SIGALRM, SIG_IGN); - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - sleep(2); - exit(dialit(num, acu) != 'A'); - } - /* - * open line - will return on carrier - */ - if ((FD = open(DV, O_RDWR)) < 0) { -#ifdef DEBUG - printf("(after open, errno=%d)\n", errno); -#endif - if (errno == EIO) - printf("lost carrier..."); - else - printf("dialup line open failed..."); - alarm(0); - kill(child, SIGKILL); - close(AC); - return (0); - } - alarm(0); -#ifdef notdef - ioctl(AC, TIOCHPCL, 0); -#endif - signal(SIGALRM, SIG_DFL); - while ((pid = wait(&status)) != child && pid != -1) - ; - if (status) { - close(AC); - return (0); - } - return (1); -} - -static void -alarmtr() -{ - alarm(0); - longjmp(jmpbuf, 1); -} - -/* - * Insurance, for some reason we don't seem to be - * hanging up... - */ -v831_disconnect() -{ - struct sgttyb cntrl; - - sleep(2); -#ifdef DEBUG - printf("[disconnect: FD=%d]\n", FD); -#endif - if (FD > 0) { - ioctl(FD, TIOCCDTR, 0); - ioctl(FD, TIOCGETP, &cntrl); - cntrl.sg_ispeed = cntrl.sg_ospeed = 0; - ioctl(FD, TIOCSETP, &cntrl); - ioctl(FD, TIOCNXCL, (struct sgttyb *)NULL); - } - close(FD); -} - -v831_abort() -{ - -#ifdef DEBUG - printf("[abort: AC=%d]\n", AC); -#endif - sleep(2); - if (child > 0) - kill(child, SIGKILL); - if (AC > 0) - ioctl(FD, TIOCNXCL, (struct sgttyb *)NULL); - close(AC); - if (FD > 0) - ioctl(FD, TIOCCDTR, 0); - close(FD); -} - -/* - * Sigh, this probably must be changed at each site. - */ -struct vaconfig { - char *vc_name; - char vc_rack; - char vc_modem; -} vaconfig[] = { - { "/dev/cua0",'4','0' }, - { "/dev/cua1",'4','1' }, - { 0 } -}; - -#define pc(x) (c = x, write(AC,&c,1)) -#define ABORT 01 -#define SI 017 -#define STX 02 -#define ETX 03 - -static int -dialit(phonenum, acu) - register char *phonenum; - char *acu; -{ - register struct vaconfig *vp; - struct sgttyb cntrl; - char c; - int i, two = 2; - static char *sanitize(); - - phonenum = sanitize(phonenum); -#ifdef DEBUG - printf ("(dial phonenum=%s)\n", phonenum); -#endif - if (*phonenum == '<' && phonenum[1] == 0) - return ('Z'); - for (vp = vaconfig; vp->vc_name; vp++) - if (strcmp(vp->vc_name, acu) == 0) - break; - if (vp->vc_name == 0) { - printf("Unable to locate dialer (%s)\n", acu); - return ('K'); - } - ioctl(AC, TIOCGETP, &cntrl); - cntrl.sg_ispeed = cntrl.sg_ospeed = B2400; - cntrl.sg_flags = RAW | EVENP | ODDP; - ioctl(AC, TIOCSETP, &cntrl); - ioctl(AC, TIOCFLUSH, &two); - pc(STX); - pc(vp->vc_rack); - pc(vp->vc_modem); - while (*phonenum && *phonenum != '<') - pc(*phonenum++); - pc(SI); - pc(ETX); - sleep(1); - i = read(AC, &c, 1); -#ifdef DEBUG - printf("read %d chars, char=%c, errno %d\n", i, c, errno); -#endif - if (i != 1) - c = 'M'; - if (c == 'B' || c == 'G') { - char cc, oc = c; - - pc(ABORT); - read(AC, &cc, 1); -#ifdef DEBUG - printf("abort response=%c\n", cc); -#endif - c = oc; - v831_disconnect(); - } - close(AC); -#ifdef DEBUG - printf("dialit: returns %c\n", c); -#endif - return (c); -} - -static char * -sanitize(s) - register char *s; -{ - static char buf[128]; - register char *cp; - - for (cp = buf; *s; s++) { - if (!isdigit(*s) && *s == '<' && *s != '_') - continue; - if (*s == '_') - *s = '='; - *cp++ = *s; - } - *cp++ = 0; - return (buf); -} diff --git a/usr.bin/tip/aculib/ventel.c b/usr.bin/tip/aculib/ventel.c deleted file mode 100644 index 28b0d28..0000000 --- a/usr.bin/tip/aculib/ventel.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)ventel.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Routines for calling up on a Ventel Modem - * The Ventel is expected to be strapped for local echo (just like uucp) - */ -#include "tip.h" - -#define MAXRETRY 5 - -static void sigALRM(); -static int timeout = 0; -static jmp_buf timeoutbuf; - -/* - * some sleep calls have been replaced by this macro - * because some ventel modems require two s in less than - * a second in order to 'wake up'... yes, it is dirty... - */ -#define delay(num,denom) busyloop(CPUSPEED*num/denom) -#define CPUSPEED 1000000 /* VAX 780 is 1MIPS */ -#define DELAY(n) { register long N = (n); while (--N > 0); } -busyloop(n) { DELAY(n); } - -ven_dialer(num, acu) - register char *num; - char *acu; -{ - register char *cp; - register int connected = 0; - char *msg, *index(), line[80]; - static int gobble(), vensync(); - static void echo(); - - /* - * Get in synch with a couple of carriage returns - */ - if (!vensync(FD)) { - printf("can't synchronize with ventel\n"); -#ifdef ACULOG - logent(value(HOST), num, "ventel", "can't synch up"); -#endif - return (0); - } - if (boolean(value(VERBOSE))) - printf("\ndialing..."); - fflush(stdout); - ioctl(FD, TIOCHPCL, 0); - echo("#k$\r$\n$D$I$A$L$:$ "); - for (cp = num; *cp; cp++) { - delay(1, 10); - write(FD, cp, 1); - } - delay(1, 10); - write(FD, "\r", 1); - gobble('\n', line); - if (gobble('\n', line)) - connected = gobble('!', line); - ioctl(FD, TIOCFLUSH); -#ifdef ACULOG - if (timeout) { - sprintf(line, "%d second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "ventel", line); - } -#endif - if (timeout) - ven_disconnect(); /* insurance */ - if (connected || timeout || !boolean(value(VERBOSE))) - return (connected); - /* call failed, parse response for user */ - cp = index(line, '\r'); - if (cp) - *cp = '\0'; - for (cp = line; cp = index(cp, ' '); cp++) - if (cp[1] == ' ') - break; - if (cp) { - while (*cp == ' ') - cp++; - msg = cp; - while (*cp) { - if (isupper(*cp)) - *cp = tolower(*cp); - cp++; - } - printf("%s...", msg); - } - return (connected); -} - -ven_disconnect() -{ - - close(FD); -} - -ven_abort() -{ - - write(FD, "\03", 1); - close(FD); -} - -static void -echo(s) - register char *s; -{ - char c; - - while (c = *s++) switch (c) { - - case '$': - read(FD, &c, 1); - s++; - break; - - case '#': - c = *s++; - write(FD, &c, 1); - break; - - default: - write(FD, &c, 1); - read(FD, &c, 1); - } -} - -static void -sigALRM() -{ - printf("\07timeout waiting for reply\n"); - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -gobble(match, response) - register char match; - char response[]; -{ - register char *cp = response; - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - timeout = 0; - do { - if (setjmp(timeoutbuf)) { - signal(SIGALRM, f); - *cp = '\0'; - return (0); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, cp, 1); - alarm(0); - c = (*cp++ &= 0177); -#ifdef notdef - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } while (c != '\n' && c != match); - signal(SIGALRM, SIG_DFL); - *cp = '\0'; - return (c == match); -} - -#define min(a,b) ((a)>(b)?(b):(a)) -/* - * This convoluted piece of code attempts to get - * the ventel in sync. If you don't have FIONREAD - * there are gory ways to simulate this. - */ -static int -vensync(fd) -{ - int already = 0, nread; - char buf[60]; - - /* - * Toggle DTR to force anyone off that might have left - * the modem connected, and insure a consistent state - * to start from. - * - * If you don't have the ioctl calls to diddle directly - * with DTR, you can always try setting the baud rate to 0. - */ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - while (already < MAXRETRY) { - /* - * After reseting the modem, send it two \r's to - * autobaud on. Make sure to delay between them - * so the modem can frame the incoming characters. - */ - write(fd, "\r", 1); - delay(1,10); - write(fd, "\r", 1); - sleep(2); - if (ioctl(fd, FIONREAD, (caddr_t)&nread) < 0) { - perror("tip: ioctl"); - continue; - } - while (nread > 0) { - read(fd, buf, min(nread, 60)); - if ((buf[nread - 1] & 0177) == '$') - return (1); - nread -= min(nread, 60); - } - sleep(1); - already++; - } - return (0); -} - diff --git a/usr.bin/tip/acutab.c b/usr.bin/tip/acutab.c deleted file mode 100644 index 112b43e..0000000 --- a/usr.bin/tip/acutab.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)acutab.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -extern int df02_dialer(), df03_dialer(), df_disconnect(), df_abort(), - biz31f_dialer(), biz31_disconnect(), biz31_abort(), - biz31w_dialer(), - biz22f_dialer(), biz22_disconnect(), biz22_abort(), - biz22w_dialer(), - ven_dialer(), ven_disconnect(), ven_abort(), - hay_dialer(), hay_disconnect(), hay_abort(), - cour_dialer(), cour_disconnect(), cour_abort(), - t3000_dialer(), t3000_disconnect(), t3000_abort(), - v3451_dialer(), v3451_disconnect(), v3451_abort(), - v831_dialer(), v831_disconnect(), v831_abort(), - dn_dialer(), dn_disconnect(), dn_abort(); - -acu_t acutable[] = { -#if BIZ1031 - "biz31f", biz31f_dialer, biz31_disconnect, biz31_abort, - "biz31w", biz31w_dialer, biz31_disconnect, biz31_abort, -#endif -#if BIZ1022 - "biz22f", biz22f_dialer, biz22_disconnect, biz22_abort, - "biz22w", biz22w_dialer, biz22_disconnect, biz22_abort, -#endif -#if DF02 - "df02", df02_dialer, df_disconnect, df_abort, -#endif -#if DF03 - "df03", df03_dialer, df_disconnect, df_abort, -#endif -#if DN11 - "dn11", dn_dialer, dn_disconnect, dn_abort, -#endif -#ifdef VENTEL - "ventel",ven_dialer, ven_disconnect, ven_abort, -#endif -#ifdef HAYES - "hayes",hay_dialer, hay_disconnect, hay_abort, -#endif -#ifdef COURIER - "courier",cour_dialer, cour_disconnect, cour_abort, -#endif -#ifdef T3000 - "t3000",t3000_dialer, t3000_disconnect, t3000_abort, -#endif -#ifdef V3451 -#ifndef V831 - "vadic",v3451_dialer, v3451_disconnect, v3451_abort, -#endif - "v3451",v3451_dialer, v3451_disconnect, v3451_abort, -#endif -#ifdef V831 -#ifndef V3451 - "vadic",v831_dialer, v831_disconnect, v831_abort, -#endif - "v831",v831_dialer, v831_disconnect, v831_abort, -#endif - 0, 0, 0, 0 -}; - diff --git a/usr.bin/tip/cmds.c b/usr.bin/tip/cmds.c deleted file mode 100644 index 63bfee2..0000000 --- a/usr.bin/tip/cmds.c +++ /dev/null @@ -1,888 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" -#include "pathnames.h" - -/* - * tip - * - * miscellaneous commands - */ - -int quant[] = { 60, 60, 24 }; - -char null = '\0'; -char *sep[] = { "second", "minute", "hour" }; -static char *argv[10]; /* argument vector for take and put */ - -void timeout(); /* timeout function called on alarm */ -void stopsnd(); /* SIGINT handler during file transfers */ -void intcopy(); /* interrupt routine for file transfers */ - -/* - * FTP - remote ==> local - * get a file from the remote host - */ -getfl(c) - char c; -{ - char buf[256], *cp, *expand(); - - putchar(c); - /* - * get the UNIX receiving file's name - */ - if (prompt("Local file name? ", copyname)) - return; - cp = expand(copyname); - if ((sfd = creat(cp, 0666)) < 0) { - printf("\r\n%s: cannot creat\r\n", copyname); - return; - } - - /* - * collect parameters - */ - if (prompt("List command for remote system? ", buf)) { - unlink(copyname); - return; - } - transfer(buf, sfd, value(EOFREAD)); -} - -/* - * Cu-like take command - */ -cu_take(cc) - char cc; -{ - int fd, argc; - char line[BUFSIZ], *expand(), *cp; - - if (prompt("[take] ", copyname)) - return; - if ((argc = args(copyname, argv)) < 1 || argc > 2) { - printf("usage: from [to]\r\n"); - return; - } - if (argc == 1) - argv[1] = argv[0]; - cp = expand(argv[1]); - if ((fd = creat(cp, 0666)) < 0) { - printf("\r\n%s: cannot create\r\n", argv[1]); - return; - } - sprintf(line, "cat %s;echo \01", argv[0]); - transfer(line, fd, "\01"); -} - -static jmp_buf intbuf; -/* - * Bulk transfer routine -- - * used by getfl(), cu_take(), and pipefile() - */ -transfer(buf, fd, eofchars) - char *buf, *eofchars; -{ - register int ct; - char c, buffer[BUFSIZ]; - register char *p = buffer; - register int cnt, eof; - time_t start; - sig_t f; - char r; - - pwrite(FD, buf, size(buf)); - quit = 0; - kill(pid, SIGIOT); - read(repdes[0], (char *)&ccc, 1); /* Wait until read process stops */ - - /* - * finish command - */ - r = '\r'; - pwrite(FD, &r, 1); - do - read(FD, &c, 1); - while ((c&0177) != '\n'); - ioctl(0, TIOCSETC, &defchars); - - (void) setjmp(intbuf); - f = signal(SIGINT, intcopy); - start = time(0); - for (ct = 0; !quit;) { - eof = read(FD, &c, 1) <= 0; - c &= 0177; - if (quit) - continue; - if (eof || any(c, eofchars)) - break; - if (c == 0) - continue; /* ignore nulls */ - if (c == '\r') - continue; - *p++ = c; - - if (c == '\n' && boolean(value(VERBOSE))) - printf("\r%d", ++ct); - if ((cnt = (p-buffer)) == number(value(FRAMESIZE))) { - if (write(fd, buffer, cnt) != cnt) { - printf("\r\nwrite error\r\n"); - quit = 1; - } - p = buffer; - } - } - if (cnt = (p-buffer)) - if (write(fd, buffer, cnt) != cnt) - printf("\r\nwrite error\r\n"); - - if (boolean(value(VERBOSE))) - prtime(" lines transferred in ", time(0)-start); - ioctl(0, TIOCSETC, &tchars); - write(fildes[1], (char *)&ccc, 1); - signal(SIGINT, f); - close(fd); -} - -/* - * FTP - remote ==> local process - * send remote input to local process via pipe - */ -pipefile() -{ - int cpid, pdes[2]; - char buf[256]; - int status, p; - extern int errno; - - if (prompt("Local command? ", buf)) - return; - - if (pipe(pdes)) { - printf("can't establish pipe\r\n"); - return; - } - - if ((cpid = fork()) < 0) { - printf("can't fork!\r\n"); - return; - } else if (cpid) { - if (prompt("List command for remote system? ", buf)) { - close(pdes[0]), close(pdes[1]); - kill (cpid, SIGKILL); - } else { - close(pdes[0]); - signal(SIGPIPE, intcopy); - transfer(buf, pdes[1], value(EOFREAD)); - signal(SIGPIPE, SIG_DFL); - while ((p = wait(&status)) > 0 && p != cpid) - ; - } - } else { - register int f; - - dup2(pdes[0], 0); - close(pdes[0]); - for (f = 3; f < 20; f++) - close(f); - execute(buf); - printf("can't execl!\r\n"); - exit(0); - } -} - -/* - * Interrupt service routine for FTP - */ -void -stopsnd() -{ - - stop = 1; - signal(SIGINT, SIG_IGN); -} - -/* - * FTP - local ==> remote - * send local file to remote host - * terminate transmission with pseudo EOF sequence - */ -sendfile(cc) - char cc; -{ - FILE *fd; - char *fnamex; - char *expand(); - - putchar(cc); - /* - * get file name - */ - if (prompt("Local file name? ", fname)) - return; - - /* - * look up file - */ - fnamex = expand(fname); - if ((fd = fopen(fnamex, "r")) == NULL) { - printf("%s: cannot open\r\n", fname); - return; - } - transmit(fd, value(EOFWRITE), NULL); - if (!boolean(value(ECHOCHECK))) { - struct sgttyb buf; - - ioctl(FD, TIOCGETP, &buf); /* this does a */ - ioctl(FD, TIOCSETP, &buf); /* wflushtty */ - } -} - -/* - * Bulk transfer routine to remote host -- - * used by sendfile() and cu_put() - */ -transmit(fd, eofchars, command) - FILE *fd; - char *eofchars, *command; -{ - char *pc, lastc; - int c, ccount, lcount; - time_t start_t, stop_t; - sig_t f; - - kill(pid, SIGIOT); /* put TIPOUT into a wait state */ - stop = 0; - f = signal(SIGINT, stopsnd); - ioctl(0, TIOCSETC, &defchars); - read(repdes[0], (char *)&ccc, 1); - if (command != NULL) { - for (pc = command; *pc; pc++) - send(*pc); - if (boolean(value(ECHOCHECK))) - read(FD, (char *)&c, 1); /* trailing \n */ - else { - struct sgttyb buf; - - ioctl(FD, TIOCGETP, &buf); /* this does a */ - ioctl(FD, TIOCSETP, &buf); /* wflushtty */ - sleep(5); /* wait for remote stty to take effect */ - } - } - lcount = 0; - lastc = '\0'; - start_t = time(0); - while (1) { - ccount = 0; - do { - c = getc(fd); - if (stop) - goto out; - if (c == EOF) - goto out; - if (c == 0177 && !boolean(value(RAWFTP))) - continue; - lastc = c; - if (c < 040) { - if (c == '\n') { - if (!boolean(value(RAWFTP))) - c = '\r'; - } - else if (c == '\t') { - if (!boolean(value(RAWFTP))) { - if (boolean(value(TABEXPAND))) { - send(' '); - while ((++ccount % 8) != 0) - send(' '); - continue; - } - } - } else - if (!boolean(value(RAWFTP))) - continue; - } - send(c); - } while (c != '\r' && !boolean(value(RAWFTP))); - if (boolean(value(VERBOSE))) - printf("\r%d", ++lcount); - if (boolean(value(ECHOCHECK))) { - timedout = 0; - alarm((int)value(ETIMEOUT)); - do { /* wait for prompt */ - read(FD, (char *)&c, 1); - if (timedout || stop) { - if (timedout) - printf("\r\ntimed out at eol\r\n"); - alarm(0); - goto out; - } - } while ((c&0177) != character(value(PROMPT))); - alarm(0); - } - } -out: - if (lastc != '\n' && !boolean(value(RAWFTP))) - send('\r'); - for (pc = eofchars; *pc; pc++) - send(*pc); - stop_t = time(0); - fclose(fd); - signal(SIGINT, f); - if (boolean(value(VERBOSE))) - if (boolean(value(RAWFTP))) - prtime(" chars transferred in ", stop_t-start_t); - else - prtime(" lines transferred in ", stop_t-start_t); - write(fildes[1], (char *)&ccc, 1); - ioctl(0, TIOCSETC, &tchars); -} - -/* - * Cu-like put command - */ -cu_put(cc) - char cc; -{ - FILE *fd; - char line[BUFSIZ]; - int argc; - char *expand(); - char *copynamex; - - if (prompt("[put] ", copyname)) - return; - if ((argc = args(copyname, argv)) < 1 || argc > 2) { - printf("usage: from [to]\r\n"); - return; - } - if (argc == 1) - argv[1] = argv[0]; - copynamex = expand(argv[0]); - if ((fd = fopen(copynamex, "r")) == NULL) { - printf("%s: cannot open\r\n", copynamex); - return; - } - if (boolean(value(ECHOCHECK))) - sprintf(line, "cat>%s\r", argv[1]); - else - sprintf(line, "stty -echo;cat>%s;stty echo\r", argv[1]); - transmit(fd, "\04", line); -} - -/* - * FTP - send single character - * wait for echo & handle timeout - */ -send(c) - char c; -{ - char cc; - int retry = 0; - - cc = c; - pwrite(FD, &cc, 1); -#ifdef notdef - if (number(value(CDELAY)) > 0 && c != '\r') - nap(number(value(CDELAY))); -#endif - if (!boolean(value(ECHOCHECK))) { -#ifdef notdef - if (number(value(LDELAY)) > 0 && c == '\r') - nap(number(value(LDELAY))); -#endif - return; - } -tryagain: - timedout = 0; - alarm((int)value(ETIMEOUT)); - read(FD, &cc, 1); - alarm(0); - if (timedout) { - printf("\r\ntimeout error (%s)\r\n", ctrl(c)); - if (retry++ > 3) - return; - pwrite(FD, &null, 1); /* poke it */ - goto tryagain; - } -} - -void -timeout() -{ - signal(SIGALRM, timeout); - timedout = 1; -} - -/* - * Stolen from consh() -- puts a remote file on the output of a local command. - * Identical to consh() except for where stdout goes. - */ -pipeout(c) -{ - char buf[256]; - int cpid, status, p; - time_t start; - - putchar(c); - if (prompt("Local command? ", buf)) - return; - kill(pid, SIGIOT); /* put TIPOUT into a wait state */ - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - ioctl(0, TIOCSETC, &defchars); - read(repdes[0], (char *)&ccc, 1); - /* - * Set up file descriptors in the child and - * let it go... - */ - if ((cpid = fork()) < 0) - printf("can't fork!\r\n"); - else if (cpid) { - start = time(0); - while ((p = wait(&status)) > 0 && p != cpid) - ; - } else { - register int i; - - dup2(FD, 1); - for (i = 3; i < 20; i++) - close(i); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); - execute(buf); - printf("can't find `%s'\r\n", buf); - exit(0); - } - if (boolean(value(VERBOSE))) - prtime("away for ", time(0)-start); - write(fildes[1], (char *)&ccc, 1); - ioctl(0, TIOCSETC, &tchars); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); -} - -#ifdef CONNECT -/* - * Fork a program with: - * 0 <-> remote tty in - * 1 <-> remote tty out - * 2 <-> local tty out - */ -consh(c) -{ - char buf[256]; - int cpid, status, p; - time_t start; - - putchar(c); - if (prompt("Local command? ", buf)) - return; - kill(pid, SIGIOT); /* put TIPOUT into a wait state */ - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - ioctl(0, TIOCSETC, &defchars); - read(repdes[0], (char *)&ccc, 1); - /* - * Set up file descriptors in the child and - * let it go... - */ - if ((cpid = fork()) < 0) - printf("can't fork!\r\n"); - else if (cpid) { - start = time(0); - while ((p = wait(&status)) > 0 && p != cpid) - ; - } else { - register int i; - - dup2(FD, 0); - dup2(3, 1); - for (i = 3; i < 20; i++) - close(i); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); - execute(buf); - printf("can't find `%s'\r\n", buf); - exit(0); - } - if (boolean(value(VERBOSE))) - prtime("away for ", time(0)-start); - write(fildes[1], (char *)&ccc, 1); - ioctl(0, TIOCSETC, &tchars); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); -} -#endif - -/* - * Escape to local shell - */ -shell() -{ - int shpid, status; - extern char **environ; - char *cp; - - printf("[sh]\r\n"); - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - unraw(); - if (shpid = fork()) { - while (shpid != wait(&status)); - raw(); - printf("\r\n!\r\n"); - signal(SIGINT, SIG_DFL); - signal(SIGQUIT, SIG_DFL); - return; - } else { - signal(SIGQUIT, SIG_DFL); - signal(SIGINT, SIG_DFL); - if ((cp = rindex(value(SHELL), '/')) == NULL) - cp = value(SHELL); - else - cp++; - shell_uid(); - execl(value(SHELL), cp, 0); - printf("\r\ncan't execl!\r\n"); - exit(1); - } -} - -/* - * TIPIN portion of scripting - * initiate the conversation with TIPOUT - */ -setscript() -{ - char c; - /* - * enable TIPOUT side for dialogue - */ - kill(pid, SIGEMT); - if (boolean(value(SCRIPT))) - write(fildes[1], value(RECORD), size(value(RECORD))); - write(fildes[1], "\n", 1); - /* - * wait for TIPOUT to finish - */ - read(repdes[0], &c, 1); - if (c == 'n') - printf("can't create %s\r\n", value(RECORD)); -} - -/* - * Change current working directory of - * local portion of tip - */ -chdirectory() -{ - char dirname[80]; - register char *cp = dirname; - - if (prompt("[cd] ", dirname)) { - if (stoprompt) - return; - cp = value(HOME); - } - if (chdir(cp) < 0) - printf("%s: bad directory\r\n", cp); - printf("!\r\n"); -} - -tipabort(msg) - char *msg; -{ - - kill(pid, SIGTERM); - disconnect(msg); - if (msg != NOSTR) - printf("\r\n%s", msg); - printf("\r\n[EOT]\r\n"); - daemon_uid(); - (void)uu_unlock(uucplock); - unraw(); - exit(0); -} - -finish() -{ - char *dismsg; - - if ((dismsg = value(DISCONNECT)) != NOSTR) { - write(FD, dismsg, strlen(dismsg)); - sleep(5); - } - tipabort(NOSTR); -} - -void -intcopy() -{ - raw(); - quit = 1; - longjmp(intbuf, 1); -} - -execute(s) - char *s; -{ - register char *cp; - - if ((cp = rindex(value(SHELL), '/')) == NULL) - cp = value(SHELL); - else - cp++; - shell_uid(); - execl(value(SHELL), cp, "-c", s, 0); -} - -args(buf, a) - char *buf, *a[]; -{ - register char *p = buf, *start; - register char **parg = a; - register int n = 0; - - do { - while (*p && (*p == ' ' || *p == '\t')) - p++; - start = p; - if (*p) - *parg = p; - while (*p && (*p != ' ' && *p != '\t')) - p++; - if (p != start) - parg++, n++; - if (*p) - *p++ = '\0'; - } while (*p); - - return(n); -} - -prtime(s, a) - char *s; - time_t a; -{ - register i; - int nums[3]; - - for (i = 0; i < 3; i++) { - nums[i] = (int)(a % quant[i]); - a /= quant[i]; - } - printf("%s", s); - while (--i >= 0) - if (nums[i] || i == 0 && nums[1] == 0 && nums[2] == 0) - printf("%d %s%c ", nums[i], sep[i], - nums[i] == 1 ? '\0' : 's'); - printf("\r\n!\r\n"); -} - -variable() -{ - char buf[256]; - - if (prompt("[set] ", buf)) - return; - vlex(buf); - if (vtable[BEAUTIFY].v_access&CHANGED) { - vtable[BEAUTIFY].v_access &= ~CHANGED; - kill(pid, SIGSYS); - } - if (vtable[SCRIPT].v_access&CHANGED) { - vtable[SCRIPT].v_access &= ~CHANGED; - setscript(); - /* - * So that "set record=blah script" doesn't - * cause two transactions to occur. - */ - if (vtable[RECORD].v_access&CHANGED) - vtable[RECORD].v_access &= ~CHANGED; - } - if (vtable[RECORD].v_access&CHANGED) { - vtable[RECORD].v_access &= ~CHANGED; - if (boolean(value(SCRIPT))) - setscript(); - } - if (vtable[TAND].v_access&CHANGED) { - vtable[TAND].v_access &= ~CHANGED; - if (boolean(value(TAND))) - tandem("on"); - else - tandem("off"); - } - if (vtable[LECHO].v_access&CHANGED) { - vtable[LECHO].v_access &= ~CHANGED; - HD = boolean(value(LECHO)); - } - if (vtable[PARITY].v_access&CHANGED) { - vtable[PARITY].v_access &= ~CHANGED; - setparity(); - } -} - -/* - * Turn tandem mode on or off for remote tty. - */ -tandem(option) - char *option; -{ - struct sgttyb rmtty; - - ioctl(FD, TIOCGETP, &rmtty); - if (strcmp(option,"on") == 0) { - rmtty.sg_flags |= TANDEM; - arg.sg_flags |= TANDEM; - } else { - rmtty.sg_flags &= ~TANDEM; - arg.sg_flags &= ~TANDEM; - } - ioctl(FD, TIOCSETP, &rmtty); - ioctl(0, TIOCSETP, &arg); -} - -/* - * Send a break. - */ -genbrk() -{ - - ioctl(FD, TIOCSBRK, NULL); - sleep(1); - ioctl(FD, TIOCCBRK, NULL); -} - -/* - * Suspend tip - */ -suspend(c) - char c; -{ - - unraw(); - kill(c == CTRL('y') ? getpid() : 0, SIGTSTP); - raw(); -} - -/* - * expand a file name if it includes shell meta characters - */ - -char * -expand(name) - char name[]; -{ - static char xname[BUFSIZ]; - char cmdbuf[BUFSIZ]; - register int pid, l, rc; - register char *cp, *Shell; - int s, pivec[2], (*sigint)(); - - if (!anyof(name, "~{[*?$`'\"\\")) - return(name); - /* sigint = signal(SIGINT, SIG_IGN); */ - if (pipe(pivec) < 0) { - perror("pipe"); - /* signal(SIGINT, sigint) */ - return(name); - } - sprintf(cmdbuf, "echo %s", name); - if ((pid = vfork()) == 0) { - Shell = value(SHELL); - if (Shell == NOSTR) - Shell = _PATH_BSHELL; - close(pivec[0]); - close(1); - dup(pivec[1]); - close(pivec[1]); - close(2); - shell_uid(); - execl(Shell, Shell, "-c", cmdbuf, 0); - _exit(1); - } - if (pid == -1) { - perror("fork"); - close(pivec[0]); - close(pivec[1]); - return(NOSTR); - } - close(pivec[1]); - l = read(pivec[0], xname, BUFSIZ); - close(pivec[0]); - while (wait(&s) != pid); - ; - s &= 0377; - if (s != 0 && s != SIGPIPE) { - fprintf(stderr, "\"Echo\" failed\n"); - return(NOSTR); - } - if (l < 0) { - perror("read"); - return(NOSTR); - } - if (l == 0) { - fprintf(stderr, "\"%s\": No match\n", name); - return(NOSTR); - } - if (l == BUFSIZ) { - fprintf(stderr, "Buffer overflow expanding \"%s\"\n", name); - return(NOSTR); - } - xname[l] = 0; - for (cp = &xname[l-1]; *cp == '\n' && cp > xname; cp--) - ; - *++cp = '\0'; - return(xname); -} - -/* - * Are any of the characters in the two strings the same? - */ - -anyof(s1, s2) - register char *s1, *s2; -{ - register int c; - - while (c = *s1++) - if (any(c, s2)) - return(1); - return(0); -} diff --git a/usr.bin/tip/cmdtab.c b/usr.bin/tip/cmdtab.c deleted file mode 100644 index f6bcb60..0000000 --- a/usr.bin/tip/cmdtab.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -extern int shell(), getfl(), sendfile(), chdirectory(); -extern int finish(), help(), pipefile(), pipeout(), consh(), variable(); -extern int cu_take(), cu_put(), dollar(), genbrk(), suspend(); - -esctable_t etable[] = { - { '!', NORM, "shell", shell }, - { '<', NORM, "receive file from remote host", getfl }, - { '>', NORM, "send file to remote host", sendfile }, - { 't', NORM, "take file from remote UNIX", cu_take }, - { 'p', NORM, "put file to remote UNIX", cu_put }, - { '|', NORM, "pipe remote file", pipefile }, - { '$', NORM, "pipe local command to remote host", pipeout }, -#ifdef CONNECT - { 'C', NORM, "connect program to remote host",consh }, -#endif - { 'c', NORM, "change directory", chdirectory }, - { '.', NORM, "exit from tip", finish }, - {CTRL('d'),NORM,"exit from tip", finish }, - {CTRL('y'),NORM,"suspend tip (local+remote)", suspend }, - {CTRL('z'),NORM,"suspend tip (local only)", suspend }, - { 's', NORM, "set variable", variable }, - { '?', NORM, "get this summary", help }, - { '#', NORM, "send break", genbrk }, - { 0, 0, 0 } -}; diff --git a/usr.bin/tip/cu.c b/usr.bin/tip/cu.c deleted file mode 100644 index fae2b3c..0000000 --- a/usr.bin/tip/cu.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)cu.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -void cleanup(); - -/* - * Botch the interface to look like cu's - */ -cumain(argc, argv) - char *argv[]; -{ - register int i; - static char sbuf[12]; - - if (argc < 2) { - printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n"); - exit(8); - } - CU = DV = NOSTR; - BR = DEFBR; - for (; argc > 1; argv++, argc--) { - if (argv[1][0] != '-') - PN = argv[1]; - else switch (argv[1][1]) { - - case 't': - HW = 1, DU = -1; - --argc; - continue; - - case 'a': - CU = argv[2]; ++argv; --argc; - break; - - case 's': - if (argc < 3 || speed(atoi(argv[2])) == 0) { - fprintf(stderr, "cu: unsupported speed %s\n", - argv[2]); - exit(3); - } - BR = atoi(argv[2]); ++argv; --argc; - break; - - case 'l': - DV = argv[2]; ++argv; --argc; - break; - - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - if (CU) - CU[strlen(CU)-1] = argv[1][1]; - if (DV) - DV[strlen(DV)-1] = argv[1][1]; - break; - - default: - printf("Bad flag %s", argv[1]); - break; - } - } - signal(SIGINT, cleanup); - signal(SIGQUIT, cleanup); - signal(SIGHUP, cleanup); - signal(SIGTERM, cleanup); - - /* - * The "cu" host name is used to define the - * attributes of the generic dialer. - */ - (void)sprintf(sbuf, "cu%d", BR); - if ((i = hunt(sbuf)) == 0) { - printf("all ports busy\n"); - exit(3); - } - if (i == -1) { - printf("link down\n"); - (void)uu_unlock(uucplock); - exit(3); - } - setbuf(stdout, NULL); - loginit(); - user_uid(); - vinit(); - setparity("none"); - boolean(value(VERBOSE)) = 0; - if (HW) - ttysetup(speed(BR)); - if (connect()) { - printf("Connect failed\n"); - daemon_uid(); - (void)uu_unlock(uucplock); - exit(1); - } - if (!HW) - ttysetup(speed(BR)); -} diff --git a/usr.bin/tip/hunt.c b/usr.bin/tip/hunt.c deleted file mode 100644 index 650ac26..0000000 --- a/usr.bin/tip/hunt.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)hunt.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -extern char *getremote(); -extern char *rindex(); - -static jmp_buf deadline; -static int deadfl; - -void -dead() -{ - deadfl = 1; - longjmp(deadline, 1); -} - -hunt(name) - char *name; -{ - register char *cp; - sig_t f; - - f = signal(SIGALRM, dead); - while (cp = getremote(name)) { - deadfl = 0; - uucplock = rindex(cp, '/')+1; - if (uu_lock(uucplock) < 0) - continue; - /* - * Straight through call units, such as the BIZCOMP, - * VADIC and the DF, must indicate they're hardwired in - * order to get an open file descriptor placed in FD. - * Otherwise, as for a DN-11, the open will have to - * be done in the "open" routine. - */ - if (!HW) - break; - if (setjmp(deadline) == 0) { - alarm(10); - FD = open(cp, O_RDWR); - } - alarm(0); - if (FD < 0) { - perror(cp); - deadfl = 1; - } - if (!deadfl) { - ioctl(FD, TIOCEXCL, 0); - ioctl(FD, TIOCHPCL, 0); - signal(SIGALRM, SIG_DFL); - return ((int)cp); - } - (void)uu_unlock(uucplock); - } - signal(SIGALRM, f); - return (deadfl ? -1 : (int)cp); -} diff --git a/usr.bin/tip/log.c b/usr.bin/tip/log.c deleted file mode 100644 index 5da2c45..0000000 --- a/usr.bin/tip/log.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -#ifdef ACULOG -static FILE *flog = NULL; - -/* - * Log file maintenance routines - */ - -logent(group, num, acu, message) - char *group, *num, *acu, *message; -{ - char *user, *timestamp; - struct passwd *pwd; - long t; - - if (flog == NULL) - return; - if (flock(fileno(flog), LOCK_EX) < 0) { - perror("tip: flock"); - return; - } - if ((user = getlogin()) == NOSTR) - if ((pwd = getpwuid(getuid())) == NOPWD) - user = "???"; - else - user = pwd->pw_name; - t = time(0); - timestamp = ctime(&t); - timestamp[24] = '\0'; - fprintf(flog, "%s (%s) <%s, %s, %s> %s\n", - user, timestamp, group, -#ifdef PRISTINE - "", -#else - num, -#endif - acu, message); - (void) fflush(flog); - (void) flock(fileno(flog), LOCK_UN); -} - -loginit() -{ - flog = fopen(value(LOG), "a"); - if (flog == NULL) - fprintf(stderr, "can't open log file %s.\r\n", value(LOG)); -} -#endif diff --git a/usr.bin/tip/partab.c b/usr.bin/tip/partab.c deleted file mode 100644 index 1da4e23..0000000 --- a/usr.bin/tip/partab.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)partab.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Even parity table for 0-0177 - */ -char evenpartab[] = { - 0000,0201,0202,0003,0204,0005,0006,0207, - 0210,0011,0012,0213,0014,0215,0216,0017, - 0220,0021,0022,0223,0024,0225,0226,0027, - 0030,0231,0232,0033,0234,0035,0036,0237, - 0240,0041,0042,0243,0044,0245,0246,0047, - 0050,0251,0252,0053,0254,0055,0056,0257, - 0060,0261,0262,0063,0264,0065,0066,0267, - 0270,0071,0072,0273,0074,0275,0276,0077, - 0300,0101,0102,0303,0104,0305,0306,0107, - 0110,0311,0312,0113,0314,0115,0116,0317, - 0120,0321,0322,0123,0324,0125,0126,0327, - 0330,0131,0132,0333,0134,0335,0336,0137, - 0140,0341,0342,0143,0344,0145,0146,0347, - 0350,0151,0152,0353,0154,0355,0356,0157, - 0360,0161,0162,0363,0164,0365,0366,0167, - 0170,0371,0372,0173,0374,0175,0176,0377, -}; diff --git a/usr.bin/tip/remcap.c b/usr.bin/tip/remcap.c deleted file mode 100644 index 7a7e0c2..0000000 --- a/usr.bin/tip/remcap.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)remcap.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * remcap - routines for dealing with the remote host data base - * - * derived from termcap - */ -#include -#include -#include -#include -#include "pathnames.h" - -#ifndef BUFSIZ -#define BUFSIZ 1024 -#endif -#define MAXHOP 32 /* max number of tc= indirections */ - -#define tgetent rgetent -#define tnchktc rnchktc -#define tnamatch rnamatch -#define tgetnum rgetnum -#define tgetflag rgetflag -#define tgetstr rgetstr -#define E_TERMCAP RM = _PATH_REMOTE -#define V_TERMCAP "REMOTE" -#define V_TERM "HOST" - -char *RM; - -/* - * termcap - routines for dealing with the terminal capability data base - * - * BUG: Should use a "last" pointer in tbuf, so that searching - * for capabilities alphabetically would not be a n**2/2 - * process when large numbers of capabilities are given. - * Note: If we add a last pointer now we will screw up the - * tc capability. We really should compile termcap. - * - * Essentially all the work here is scanning and decoding escapes - * in string capabilities. We don't use stdio because the editor - * doesn't, and because living w/o it is not hard. - */ - -static char *tbuf; -static int hopcount; /* detect infinite loops in termcap, init 0 */ -static char *tskip(); -char *tgetstr(); -static char *tdecode(); -static char *remotefile; - -/* - * Get an entry for terminal name in buffer bp, - * from the termcap file. Parse is very rudimentary; - * we just notice escaped newlines. - */ -tgetent(bp, name) - char *bp, *name; -{ - char lbuf[BUFSIZ], *cp, *p; - int rc1, rc2; - - remotefile = cp = getenv(V_TERMCAP); - if (cp == (char *)0 || strcmp(cp, _PATH_REMOTE) == 0) { - remotefile = cp = _PATH_REMOTE; - return (getent(bp, name, cp)); - } else { - if ((rc1 = getent(bp, name, cp)) != 1) - *bp = '\0'; - remotefile = cp = _PATH_REMOTE; - rc2 = getent(lbuf, name, cp); - if (rc1 != 1 && rc2 != 1) - return (rc2); - if (rc2 == 1) { - p = lbuf; - if (rc1 == 1) - while (*p++ != ':') - ; - if (strlen(bp) + strlen(p) > BUFSIZ) { - write(2, "Remcap entry too long\n", 23); - return (-1); - } - strcat(bp, p); - } - tbuf = bp; - return (1); - } -} - -getent(bp, name, cp) - char *bp, *name, *cp; -{ - register int c; - register int i = 0, cnt = 0; - char ibuf[BUFSIZ], *cp2; - int tf; - - tbuf = bp; - tf = 0; - /* - * TERMCAP can have one of two things in it. It can be the - * name of a file to use instead of /etc/termcap. In this - * case it better start with a "/". Or it can be an entry to - * use so we don't have to read the file. In this case it - * has to already have the newlines crunched out. - */ - if (cp && *cp) { - if (*cp!='/') { - cp2 = getenv(V_TERM); - if (cp2 == (char *)0 || strcmp(name,cp2) == 0) { - strcpy(bp,cp); - return (tnchktc()); - } else - tf = open(E_TERMCAP, O_RDONLY); - } else - tf = open(RM = cp, O_RDONLY); - } - if (tf == 0) - tf = open(E_TERMCAP, O_RDONLY); - if (tf < 0) - return (-1); - for (;;) { - cp = bp; - for (;;) { - if (i == cnt) { - cnt = read(tf, ibuf, BUFSIZ); - if (cnt <= 0) { - close(tf); - return (0); - } - i = 0; - } - c = ibuf[i++]; - if (c == '\n') { - if (cp > bp && cp[-1] == '\\') { - cp--; - continue; - } - break; - } - if (cp >= bp+BUFSIZ) { - write(2,"Remcap entry too long\n", 23); - break; - } else - *cp++ = c; - } - *cp = 0; - - /* - * The real work for the match. - */ - if (tnamatch(name)) { - close(tf); - return (tnchktc()); - } - } -} - -/* - * tnchktc: check the last entry, see if it's tc=xxx. If so, - * recursively find xxx and append that entry (minus the names) - * to take the place of the tc=xxx entry. This allows termcap - * entries to say "like an HP2621 but doesn't turn on the labels". - * Note that this works because of the left to right scan. - */ -tnchktc() -{ - register char *p, *q; - char tcname[16]; /* name of similar terminal */ - char tcbuf[BUFSIZ]; - char *holdtbuf = tbuf; - int l; - char *cp; - - p = tbuf + strlen(tbuf) - 2; /* before the last colon */ - while (*--p != ':') - if (p MAXHOP) { - write(2, "Infinite tc= loop\n", 18); - return (0); - } - if (getent(tcbuf, tcname, remotefile) != 1) { - if (strcmp(remotefile, _PATH_REMOTE) == 0) - return (0); - else if (getent(tcbuf, tcname, _PATH_REMOTE) != 1) - return (0); - } - for (q = tcbuf; *q++ != ':'; ) - ; - l = p - holdtbuf + strlen(q); - if (l > BUFSIZ) { - write(2, "Remcap entry too long\n", 23); - q[BUFSIZ - (p-holdtbuf)] = 0; - } - strcpy(p, q); - tbuf = holdtbuf; - return (1); -} - -/* - * Tnamatch deals with name matching. The first field of the termcap - * entry is a sequence of names separated by |'s, so we compare - * against each such name. The normal : terminator after the last - * name (before the first field) stops us. - */ -tnamatch(np) - char *np; -{ - register char *Np, *Bp; - - Bp = tbuf; - if (*Bp == '#') - return (0); - for (;;) { - for (Np = np; *Np && *Bp == *Np; Bp++, Np++) - continue; - if (*Np == 0 && (*Bp == '|' || *Bp == ':' || *Bp == 0)) - return (1); - while (*Bp && *Bp != ':' && *Bp != '|') - Bp++; - if (*Bp == 0 || *Bp == ':') - return (0); - Bp++; - } -} - -/* - * Skip to the next field. Notice that this is very dumb, not - * knowing about \: escapes or any such. If necessary, :'s can be put - * into the termcap file in octal. - */ -static char * -tskip(bp) - register char *bp; -{ - - while (*bp && *bp != ':') - bp++; - if (*bp == ':') - bp++; - return (bp); -} - -/* - * Return the (numeric) option id. - * Numeric options look like - * li#80 - * i.e. the option string is separated from the numeric value by - * a # character. If the option is not found we return -1. - * Note that we handle octal numbers beginning with 0. - */ -tgetnum(id) - char *id; -{ - register int i, base; - register char *bp = tbuf; - - for (;;) { - bp = tskip(bp); - if (*bp == 0) - return (-1); - if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) - continue; - if (*bp == '@') - return (-1); - if (*bp != '#') - continue; - bp++; - base = 10; - if (*bp == '0') - base = 8; - i = 0; - while (isdigit(*bp)) - i *= base, i += *bp++ - '0'; - return (i); - } -} - -/* - * Handle a flag option. - * Flag options are given "naked", i.e. followed by a : or the end - * of the buffer. Return 1 if we find the option, or 0 if it is - * not given. - */ -tgetflag(id) - char *id; -{ - register char *bp = tbuf; - - for (;;) { - bp = tskip(bp); - if (!*bp) - return (0); - if (*bp++ == id[0] && *bp != 0 && *bp++ == id[1]) { - if (!*bp || *bp == ':') - return (1); - else if (*bp == '@') - return (0); - } - } -} - -/* - * Get a string valued option. - * These are given as - * cl=^Z - * Much decoding is done on the strings, and the strings are - * placed in area, which is a ref parameter which is updated. - * No checking on area overflow. - */ -char * -tgetstr(id, area) - char *id, **area; -{ - register char *bp = tbuf; - - for (;;) { - bp = tskip(bp); - if (!*bp) - return (0); - if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1]) - continue; - if (*bp == '@') - return (0); - if (*bp != '=') - continue; - bp++; - return (tdecode(bp, area)); - } -} - -/* - * Tdecode does the grung work to decode the - * string capability escapes. - */ -static char * -tdecode(str, area) - register char *str; - char **area; -{ - register char *cp; - register int c; - register char *dp; - int i; - - cp = *area; - while ((c = *str++) && c != ':') { - switch (c) { - - case '^': - c = *str++ & 037; - break; - - case '\\': - dp = "E\033^^\\\\::n\nr\rt\tb\bf\f"; - c = *str++; -nextc: - if (*dp++ == c) { - c = *dp++; - break; - } - dp++; - if (*dp) - goto nextc; - if (isdigit(c)) { - c -= '0', i = 2; - do - c <<= 3, c |= *str++ - '0'; - while (--i && isdigit(*str)); - } - break; - } - *cp++ = c; - } - *cp++ = 0; - str = *area; - *area = cp; - return (str); -} diff --git a/usr.bin/tip/remote.c b/usr.bin/tip/remote.c deleted file mode 100644 index 9b86066..0000000 --- a/usr.bin/tip/remote.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1992, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)remote.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include -#include - -#include "pathnames.h" -#include "tip.h" - -/* - * Attributes to be gleened from remote host description - * data base. - */ -static char **caps[] = { - &AT, &DV, &CM, &CU, &EL, &IE, &OE, &PN, &PR, &DI, - &ES, &EX, &FO, &RC, &RE, &PA -}; - -static char *capstrings[] = { - "at", "dv", "cm", "cu", "el", "ie", "oe", "pn", "pr", - "di", "es", "ex", "fo", "rc", "re", "pa", 0 -}; - -static char *db_array[3] = { _PATH_REMOTE, 0, 0 }; - -#define cgetflag(f) (cgetcap(bp, f, ':') != NULL) - -static -getremcap(host) - register char *host; -{ - register char **p, ***q; - char *bp; - char *rempath; - int stat; - - rempath = getenv("REMOTE"); - if (rempath != NULL) - if (*rempath != '/') - /* we have an entry */ - cgetset(rempath); - else { /* we have a path */ - db_array[1] = rempath; - db_array[2] = _PATH_REMOTE; - } - - if ((stat = cgetent(&bp, db_array, host)) < 0) { - if (DV || - host[0] == '/' && access(DV = host, R_OK | W_OK) == 0) { - CU = DV; - HO = host; - HW = 1; - DU = 0; - if (!BR) - BR = DEFBR; - FS = DEFFS; - return; - } - switch(stat) { - case -1: - fprintf(stderr, "tip: unknown host %s\n", host); - break; - case -2: - fprintf(stderr, - "tip: can't open host description file\n"); - break; - case -3: - fprintf(stderr, - "tip: possible reference loop in host description file\n"); - break; - } - exit(3); - } - - for (p = capstrings, q = caps; *p != NULL; p++, q++) - if (**q == NULL) - cgetstr(bp, *p, *q); - if (!BR && (cgetnum(bp, "br", &BR) == -1)) - BR = DEFBR; - if (cgetnum(bp, "fs", &FS) == -1) - FS = DEFFS; - if (DU < 0) - DU = 0; - else - DU = cgetflag("du"); - if (DV == NOSTR) { - fprintf(stderr, "%s: missing device spec\n", host); - exit(3); - } - if (DU && CU == NOSTR) - CU = DV; - if (DU && PN == NOSTR) { - fprintf(stderr, "%s: missing phone number\n", host); - exit(3); - } - - HD = cgetflag("hd"); - - /* - * This effectively eliminates the "hw" attribute - * from the description file - */ - if (!HW) - HW = (CU == NOSTR) || (DU && equal(DV, CU)); - HO = host; - /* - * see if uppercase mode should be turned on initially - */ - if (cgetflag("ra")) - boolean(value(RAISE)) = 1; - if (cgetflag("ec")) - boolean(value(ECHOCHECK)) = 1; - if (cgetflag("be")) - boolean(value(BEAUTIFY)) = 1; - if (cgetflag("nb")) - boolean(value(BEAUTIFY)) = 0; - if (cgetflag("sc")) - boolean(value(SCRIPT)) = 1; - if (cgetflag("tb")) - boolean(value(TABEXPAND)) = 1; - if (cgetflag("vb")) - boolean(value(VERBOSE)) = 1; - if (cgetflag("nv")) - boolean(value(VERBOSE)) = 0; - if (cgetflag("ta")) - boolean(value(TAND)) = 1; - if (cgetflag("nt")) - boolean(value(TAND)) = 0; - if (cgetflag("rw")) - boolean(value(RAWFTP)) = 1; - if (cgetflag("hd")) - boolean(value(HALFDUPLEX)) = 1; - if (RE == NOSTR) - RE = (char *)"tip.record"; - if (EX == NOSTR) - EX = (char *)"\t\n\b\f"; - if (ES != NOSTR) - vstring("es", ES); - if (FO != NOSTR) - vstring("fo", FO); - if (PR != NOSTR) - vstring("pr", PR); - if (RC != NOSTR) - vstring("rc", RC); - if (cgetnum(bp, "dl", &DL) == -1) - DL = 0; - if (cgetnum(bp, "cl", &CL) == -1) - CL = 0; - if (cgetnum(bp, "et", &ET) == -1) - ET = 10; -} - -char * -getremote(host) - char *host; -{ - register char *cp; - static char *next; - static int lookedup = 0; - - if (!lookedup) { - if (host == NOSTR && (host = getenv("HOST")) == NOSTR) { - fprintf(stderr, "tip: no host specified\n"); - exit(3); - } - getremcap(host); - next = DV; - lookedup++; - } - /* - * We return a new device each time we're called (to allow - * a rotary action to be simulated) - */ - if (next == NOSTR) - return (NOSTR); - if ((cp = index(next, ',')) == NULL) { - DV = next; - next = NOSTR; - } else { - *cp++ = '\0'; - DV = next; - next = cp; - } - return (DV); -} diff --git a/usr.bin/tip/tip.1 b/usr.bin/tip/tip.1 deleted file mode 100644 index 10b8a3e..0000000 --- a/usr.bin/tip/tip.1 +++ /dev/null @@ -1,451 +0,0 @@ -.\" Copyright (c) 1980, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tip.1 8.4 (Berkeley) 4/18/94 -.\" -.Dd April 18, 1994 -.Dt TIP 1 -.Os BSD 4 -.Sh NAME -.Nm tip , -.Nm cu -.Nd connect to a remote system -.Sh SYNOPSIS -.Nm tip -.Op Fl v -.Fl Ns Ns Ar speed -.Ar system\-name -.Nm tip -.Op Fl v -.Fl Ns Ns Ar speed -.Ar phone\-number -.Nm cu -.Ar phone\-number -.Op Fl t -.Op Fl s Ar speed -.Op Fl a Ar acu -.Op Fl l Ar line -.Op Fl # -.Sh DESCRIPTION -.Nm Tip -and -.Ar cu -establish a full-duplex connection to another machine, -giving the appearance of being logged in directly on the -remote cpu. It goes without saying that you must have a login -on the machine (or equivalent) to which you wish to connect. -The preferred interface is -.Nm tip . -The -.Ar cu -interface is included for those people attached to the -``call -.Ux Ns '' -command of version 7. This manual page -describes only -.Nm tip . -.Pp -Available Option: -.Bl -tag -width indent -.It Fl v -Set verbose mode. -.El -.Pp -Typed characters are normally transmitted directly to the remote -machine (which does the echoing as well). A tilde (`~') appearing -as the first character of a line is an escape signal; the following -are recognized: -.Bl -tag -width flag -.It Ic \&~^D No or Ic \&~ . -Drop the connection and exit -(you may still be logged in on the -remote machine). -.It Ic \&~c Op Ar name -Change directory to -.Ar name -(no argument -implies change to your home directory). -.It Ic \&~! -Escape to a shell (exiting the shell will -return you to tip). -.It Ic \&~> -Copy file from local to remote. -.Nm Tip -prompts for the name of a local file to transmit. -.It Ic \&~< -Copy file from remote to local. -.Nm Tip -prompts first for the name of the file to be sent, then for -a command to be executed on the remote machine. -.It Ic \&~p Ar from Op Ar to -Send a file to a remote -.Ux -host. The put command causes the remote -.Ux -system to run the command string ``cat > 'to''', while -.Nm tip -sends it the ``from'' -file. If the ``to'' file isn't specified the ``from'' file name is used. -This command is actually a -.Ux -specific version of the ``~>'' command. -.It Ic \&~t Ar from Op Ar to -Take a file from a remote -.Ux -host. -As in the put command the ``to'' file -defaults to the ``from'' file name if it isn't specified. -The remote host -executes the command string ``cat 'from';echo ^A'' to send the file to -.Nm tip . -.It Ic \&~| -Pipe the output from a remote command to a local -.Ux -process. -The command string sent to the local -.Ux -system is processed by the shell. -.It Ic \&~$ -Pipe the output from a local -.Ux -process to the remote host. -The command string sent to the local -.Ux -system is processed by the shell. -.It Ic \&~C -Fork a child process on the local system to perform special protocols -such as \s-1XMODEM\s+1. The child program will be run with the following -somewhat unusual arrangement of file descriptors: -.nf -.in +1i -0 <-> local tty in -1 <-> local tty out -2 <-> local tty out -3 <-> remote tty in -4 <-> remote tty out -.in -1i -.fi -.It Ic \&~# -Send a -.Dv BREAK -to the remote system. -For systems which don't support the -necessary -.Ar ioctl -call the break is simulated by a sequence of line speed changes -and -.Dv DEL -characters. -.It Ic \&~s -Set a variable (see the discussion below). -.It Ic \&~^Z -Stop -.Nm tip -(only available with job control). -.It Ic \&~^Y -Stop only the ``local side'' of -.Nm tip -(only available with job control); -the ``remote side'' of -.Nm tip , -the side that displays output from the remote host, is left running. -.It Ic \&~? -Get a summary of the tilde escapes -.El -.Pp -.Nm Tip -uses the file -.Pa /etc/remote -to find how to reach a particular -system and to find out how it should operate while talking -to the system; -refer to -.Xr remote 5 -for a full description. -Each system has a default baud rate with which to -establish a connection. If this value is not suitable, the baud rate -to be used may be specified on the command line, e.g. -.Ql "tip -300 mds" . -.Pp -When -.Nm tip -establishes a connection it sends out a -connection message to the remote system; the default value, if any, -is defined in -.Pa /etc/remote -(see -.Xr remote 5 ) . -.Pp -When -.Nm tip -prompts for an argument (e.g. during setup of -a file transfer) the line typed may be edited with the standard -erase and kill characters. A null line in response to a prompt, -or an interrupt, will abort the dialogue and return you to the -remote machine. -.Pp -.Nm Tip -guards against multiple users connecting to a remote system -by opening modems and terminal lines with exclusive access, -and by honoring the locking protocol used by -.Xr uucico 8 . -.Pp -During file transfers -.Nm tip -provides a running count of the number of lines transferred. -When using the ~> and ~< commands, the ``eofread'' and ``eofwrite'' -variables are used to recognize end-of-file when reading, and -specify end-of-file when writing (see below). File transfers -normally depend on tandem mode for flow control. If the remote -system does not support tandem mode, ``echocheck'' may be set -to indicate -.Nm tip -should synchronize with the remote system on the echo of each -transmitted character. -.Pp -When -.Nm tip -must dial a phone number to connect to a system it will print -various messages indicating its actions. -.Nm Tip -supports the -.Tn DEC DN Ns-11 -and -Racal-Vadic 831 auto-call-units; -the -.Tn DEC DF Ns \&02 -and -.Tn DF Ns \&03 , -Ventel 212+, Racal-Vadic 3451, and -Bizcomp 1031 and 1032 integral call unit/modems. -.Ss VARIABLES -.Nm Tip -maintains a set of -.Ar variables -which control its operation. -Some of these variables are read-only to normal users (root is allowed -to change anything of interest). Variables may be displayed -and set through the ``s'' escape. The syntax for variables is patterned -after -.Xr vi 1 -and -.Xr Mail 1 . -Supplying ``all'' -as an argument to the set command displays all variables readable by -the user. Alternatively, the user may request display of a particular -variable by attaching a `?' to the end. For example ``escape?'' -displays the current escape character. -.Pp -Variables are numeric, string, character, or boolean values. Boolean -variables are set merely by specifying their name; they may be reset -by prepending a `!' to the name. Other variable types are set by -concatenating an `=' and the value. The entire assignment must not -have any blanks in it. A single set command may be used to interrogate -as well as set a number of variables. -Variables may be initialized at run time by placing set commands -(without the ``~s'' prefix in a file -.Pa .tiprc -in one's home directory). The -.Fl v -option causes -.Nm tip -to display the sets as they are made. -Certain common variables have abbreviations. -The following is a list of common variables, -their abbreviations, and their default values. -.Bl -tag -width Ar -.It Ar beautify -(bool) Discard unprintable characters when a session is being scripted; -abbreviated -.Ar be . -.It Ar baudrate -(num) The baud rate at which the connection was established; -abbreviated -.Ar ba . -.It Ar dialtimeout -(num) When dialing a phone number, the time (in seconds) -to wait for a connection to be established; abbreviated -.Ar dial . -.It Ar echocheck -(bool) Synchronize with the remote host during file transfer by -waiting for the echo of the last character transmitted; default is -.Ar off . -.It Ar eofread -(str) The set of characters which signify an end-of-transmission -during a ~< file transfer command; abbreviated -.Ar eofr . -.It Ar eofwrite -(str) The string sent to indicate end-of-transmission during -a ~> file transfer command; abbreviated -.Ar eofw . -.It Ar eol -(str) The set of characters which indicate an end-of-line. -.Nm Tip -will recognize escape characters only after an end-of-line. -.It Ar escape -(char) The command prefix (escape) character; abbreviated -.Ar es ; -default value is `~'. -.It Ar exceptions -(str) The set of characters which should not be discarded -due to the beautification switch; abbreviated -.Ar ex ; -default value is ``\et\en\ef\eb''. -.It Ar force -(char) The character used to force literal data transmission; -abbreviated -.Ar fo ; -default value is `^P'. -.It Ar framesize -(num) The amount of data (in bytes) to buffer between file system -writes when receiving files; abbreviated -.Ar fr . -.It Ar host -(str) The name of the host to which you are connected; abbreviated -.Ar ho . -.It Ar prompt -(char) The character which indicates an end-of-line on the remote -host; abbreviated -.Ar pr ; -default value is `\en'. This value is used to synchronize during -data transfers. The count of lines transferred during a file transfer -command is based on receipt of this character. -.It Ar raise -(bool) Upper case mapping mode; abbreviated -.Ar ra ; -default value is -.Ar off . -When this mode is enabled, all lower case letters will be mapped to -upper case by -.Nm tip -for transmission to the remote machine. -.It Ar raisechar -(char) The input character used to toggle upper case mapping mode; -abbreviated -.Ar rc ; -default value is `^A'. -.It Ar record -(str) The name of the file in which a session script is recorded; -abbreviated -.Ar rec ; -default value is ``tip.record''. -.It Ar script -(bool) Session scripting mode; abbreviated -.Ar sc ; -default is -.Ar off . -When -.Ar script -is -.Li true , -.Nm tip -will record everything transmitted by the remote machine in -the script record file specified in -.Ar record . -If the -.Ar beautify -switch is on, only printable -.Tn ASCII -characters will be included in -the script file (those characters betwee 040 and 0177). The -variable -.Ar exceptions -is used to indicate characters which are an exception to the normal -beautification rules. -.It Ar tabexpand -(bool) Expand tabs to spaces during file transfers; abbreviated -.Ar tab ; -default value is -.Ar false . -Each tab is expanded to 8 spaces. -.It Ar verbose -(bool) Verbose mode; abbreviated -.Ar verb ; -default is -.Ar true . -When verbose mode is enabled, -.Nm tip -prints messages while dialing, shows the current number -of lines transferred during a file transfer operations, -and more. -.El -.Sh ENVIRONMENT -.Nm Tip -uses the following environment variables: -.Bl -tag -width Fl -.It Ev SHELL -(str) The name of the shell to use for the ~! command; default -value is ``/bin/sh'', or taken from the environment. -.It Ev HOME -(str) The home directory to use for the ~c command; default -value is taken from the environment. -.It Ev HOST -Check for a default host if none specified. -.El -.Pp -The variables -.Ev ${REMOTE} -and -.Ev ${PHONES} -are also exported. -.Sh FILES -.Bl -tag -width /var/spool/uucp/LCK..* -compact -.It Pa /etc/remote -Global system descriptions. -.It Pa /etc/phones -Global phone number data base. -.It ${REMOTE} -Private system descriptions. -.It ${PHONES} -Private phone numbers. -.It ~/.tiprc -Initialization file. -.It Pa tip.record -Record file. -.It /var/log/aculog -Line access log. -.It Pa /var/spool/uucp/LCK..* -Lock file to avoid conflicts with -.Xr uucp . -.El -.Sh DIAGNOSTICS -Diagnostics are, hopefully, self explanatory. -.Sh SEE ALSO -.Xr remote 5 , -.Xr phones 5 -.Sh HISTORY -The -.Nm tip -appeared command in -.Bx 4.2 . -.Sh BUGS -The full set of variables is undocumented and should, probably, be -pared down. diff --git a/usr.bin/tip/value.c b/usr.bin/tip/value.c deleted file mode 100644 index ce29a21..0000000 --- a/usr.bin/tip/value.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)value.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" - -#define MIDDLE 35 - -static value_t *vlookup(); -static int col = 0; - -/* - * Variable manipulation - */ -vinit() -{ - register value_t *p; - register char *cp; - FILE *f; - char file[256]; - - for (p = vtable; p->v_name != NULL; p++) { - if (p->v_type&ENVIRON) - if (cp = getenv(p->v_name)) - p->v_value = cp; - if (p->v_type&IREMOTE) - number(p->v_value) = *address(p->v_value); - } - /* - * Read the .tiprc file in the HOME directory - * for sets - */ - strcpy(file, value(HOME)); - strcat(file, "/.tiprc"); - if ((f = fopen(file, "r")) != NULL) { - register char *tp; - - while (fgets(file, sizeof(file)-1, f) != NULL) { - if (vflag) - printf("set %s", file); - if (tp = rindex(file, '\n')) - *tp = '\0'; - vlex(file); - } - fclose(f); - } - /* - * To allow definition of exception prior to fork - */ - vtable[EXCEPTIONS].v_access &= ~(WRITE<v_access, WRITE)) { - printf("access denied\r\n"); - return; - } - switch (p->v_type&TMASK) { - - case STRING: - if (p->v_value && equal(p->v_value, v)) - return; - if (!(p->v_type&(ENVIRON|INIT))) - free(p->v_value); - if ((p->v_value = malloc(size(v)+1)) == NOSTR) { - printf("out of core\r\n"); - return; - } - p->v_type &= ~(ENVIRON|INIT); - strcpy(p->v_value, v); - break; - - case NUMBER: - if (number(p->v_value) == number(v)) - return; - number(p->v_value) = number(v); - break; - - case BOOL: - if (boolean(p->v_value) == (*v != '!')) - return; - boolean(p->v_value) = (*v != '!'); - break; - - case CHAR: - if (character(p->v_value) == *v) - return; - character(p->v_value) = *v; - } - p->v_access |= CHANGED; -} - -static void vprint(); - -vlex(s) - register char *s; -{ - register value_t *p; - static void vtoken(); - - if (equal(s, "all")) { - for (p = vtable; p->v_name; p++) - if (vaccess(p->v_access, READ)) - vprint(p); - } else { - register char *cp; - - do { - if (cp = vinterp(s, ' ')) - cp++; - vtoken(s); - s = cp; - } while (s); - } - if (col > 0) { - printf("\r\n"); - col = 0; - } -} - -static void -vtoken(s) - register char *s; -{ - register value_t *p; - register char *cp; - char *expand(); - - if (cp = index(s, '=')) { - *cp = '\0'; - if (p = vlookup(s)) { - cp++; - if (p->v_type&NUMBER) - vassign(p, atoi(cp)); - else { - if (strcmp(s, "record") == 0) - cp = expand(cp); - vassign(p, cp); - } - return; - } - } else if (cp = index(s, '?')) { - *cp = '\0'; - if ((p = vlookup(s)) && vaccess(p->v_access, READ)) { - vprint(p); - return; - } - } else { - if (*s != '!') - p = vlookup(s); - else - p = vlookup(s+1); - if (p != NOVAL) { - vassign(p, s); - return; - } - } - printf("%s: unknown variable\r\n", s); -} - -static void -vprint(p) - register value_t *p; -{ - register char *cp; - extern char *interp(), *ctrl(); - - if (col > 0 && col < MIDDLE) - while (col++ < MIDDLE) - putchar(' '); - col += size(p->v_name); - switch (p->v_type&TMASK) { - - case BOOL: - if (boolean(p->v_value) == FALSE) { - col++; - putchar('!'); - } - printf("%s", p->v_name); - break; - - case STRING: - printf("%s=", p->v_name); - col++; - if (p->v_value) { - cp = interp(p->v_value, NULL); - col += size(cp); - printf("%s", cp); - } - break; - - case NUMBER: - col += 6; - printf("%s=%-5d", p->v_name, number(p->v_value)); - break; - - case CHAR: - printf("%s=", p->v_name); - col++; - if (p->v_value) { - cp = ctrl(character(p->v_value)); - col += size(cp); - printf("%s", cp); - } - break; - } - if (col >= MIDDLE) { - col = 0; - printf("\r\n"); - return; - } -} - - -static int -vaccess(mode, rw) - register unsigned mode, rw; -{ - if (mode & (rw<v_name; p++) - if (equal(p->v_name, s) || (p->v_abrev && equal(p->v_abrev, s))) - return (p); - return (NULL); -} - -char * -vinterp(s, stop) - register char *s; - char stop; -{ - register char *p = s, c; - int num; - - while ((c = *s++) && c != stop) - switch (c) { - - case '^': - if (*s) - *p++ = *s++ - 0100; - else - *p++ = c; - break; - - case '\\': - num = 0; - c = *s++; - if (c >= '0' && c <= '7') - num = (num<<3)+(c-'0'); - else { - register char *q = "n\nr\rt\tb\bf\f"; - - for (; *q; q++) - if (c == *q++) { - *p++ = *q; - goto cont; - } - *p++ = c; - cont: - break; - } - if ((c = *s++) >= '0' && c <= '7') { - num = (num<<3)+(c-'0'); - if ((c = *s++) >= '0' && c <= '7') - num = (num<<3)+(c-'0'); - else - s--; - } else - s--; - *p++ = num; - break; - - default: - *p++ = c; - } - *p = '\0'; - return (c == stop ? s-1 : NULL); -} - -/* - * assign variable s with value v (for NUMBER or STRING or CHAR types) - */ - -vstring(s,v) - register char *s; - register char *v; -{ - register value_t *p; - char *expand(); - - p = vlookup(s); - if (p == 0) - return (1); - if (p->v_type&NUMBER) - vassign(p, atoi(v)); - else { - if (strcmp(s, "record") == 0) - v = expand(v); - vassign(p, v); - } - return (0); -} diff --git a/usr.bin/tip/vars.c b/usr.bin/tip/vars.c deleted file mode 100644 index debe01b..0000000 --- a/usr.bin/tip/vars.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)vars.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "tip.h" -#include "pathnames.h" - -/* - * Definition of variables - */ -value_t vtable[] = { - { "beautify", BOOL, (READ|WRITE)< -#include -#include -#ifdef vax -#ifdef BSD4_2 -#include -#else -#include -#endif -#endif /* vax */ -#include -#include -#include -#include -#include -#include -#include -#include "pathnames.h" - -#define NDZLINE 8 /* lines/dz */ -#define NDHLINE 16 /* lines/dh */ -#define NDMFLINE 8 /* lines/dmf */ - -#define DZ11 1 -#define DH11 2 -#define DMF 3 - -#define NLVALUE(val) (nl[val].n_value) - -struct nlist nl[] = { -#define CDEVSW 0 - { "_cdevsw" }, - -#define DZOPEN 1 - { "_dzopen" }, -#define DZINFO 2 - { "_dzinfo" }, -#define NDZ11 3 - { "_dz_cnt" }, -#define DZSCAR 4 - { "_dzsoftCAR" }, - -#define DHOPEN 5 - { "_dhopen" }, -#define DHINFO 6 - { "_dhinfo" }, -#define NDH11 7 - { "_ndh11" }, -#define DHSCAR 8 - { "_dhsoftCAR" }, - -#define DMFOPEN 9 - { "_dmfopen" }, -#define DMFINFO 10 - { "_dmfinfo" }, -#define NDMF 11 - { "_ndmf" }, -#define DMFSCAR 12 - { "_dmfsoftCAR" }, - - { "\0" } -}; - -#define ENABLE 1 -#define DISABLE 0 - -char Etcttys[] = _PATH_TTYS; -#ifdef BSD4_3 -FILE *ttysfile, *nttysfile; -char NEtcttys[] = _PATH_NEWTTYS; -extern long ftell(); -#endif BSD4_3 -char Devhome[] = _PATH_DEV; - -char usage[] = "Usage: acucntrl {dis|en}able ttydX\n"; - -struct utmp utmp; -char resettty, resetmodem; -int etcutmp; -off_t utmploc; -off_t ttyslnbeg; -extern int errno; -extern char *sys_errlist[]; -off_t lseek(); - -#define NAMSIZ sizeof(utmp.ut_name) -#define LINSIZ sizeof(utmp.ut_line) - -main(argc, argv) -int argc; char *argv[]; -{ - register char *p; - register int i; - char uname[NAMSIZ], Uname[NAMSIZ]; - int enable ; - char *device; - int devfile; - int uid, gid; - struct passwd *getpwuid(); - char *rindex(); - - /* check input arguments */ - if (argc!=3 && argc != 4) { - fprintf(stderr, usage); - exit(1); - } - - /* interpret command type */ - if (prefix(argv[1], "disable") || strcmp(argv[1], "dialout")==0) - enable = 0; - else if (prefix(argv[1], "enable") || strcmp(argv[1], "dialin")==0) - enable = 1; - else { - fprintf(stderr, usage); - exit(1); - } - - device = rindex(argv[2], '/'); - device = (device == NULL) ? argv[2]: device+1; - - opnttys(device); - -#ifdef vax - /* Get nlist info */ - nlist(_PATH_UNIX, nl); -#endif vax - - /* Chdir to /dev */ - if(chdir(Devhome) < 0) { - fprintf(stderr, "Cannot chdir to %s: %s\r\n", - Devhome, sys_errlist[errno]); - exit(1); - } - - /* Get uid information */ - uid = getuid(); - gid = getgid(); - - p = getpwuid(uid)->pw_name; - if (p==NULL) { - fprintf(stderr, "cannot get uid name\n"); - exit(1); - } - - if (strcmp(p, "uucp") == 0 && argc == 4) - p = argv[3]; - - /* to upper case */ - i = 0; - do { - uname[i] = *p; - Uname[i++] = (*p>='a' && *p<='z') ? (*p - ('a'-'A')) : *p; - } while (*p++ && i= 0 ; str++) - if (*str>='a' && *str<='z') - return(0); - return(1); -} - -/* Post name to public */ -post(device, name) -char *device, *name; -{ - (void)time((time_t *)&utmp.ut_time); - strncpy(utmp.ut_line, device, LINSIZ); - strncpy(utmp.ut_name, name, NAMSIZ); - if (lseek(etcutmp, utmploc, 0) < 0) - fprintf(stderr, "on lseek in %s: %s", - _PATH_UTMP, sys_errlist[errno]); - if (write(etcutmp, (char *)&utmp, sizeof(utmp)) < 0) - fprintf(stderr, "on write in %s: %s", - _PATH_UTMP, sys_errlist[errno]); -} - -/* poke process 1 and wait for it to do its thing */ -pokeinit(device, uname, enable) -char *uname, *device; int enable; -{ - struct utmp utmp; - register int i; - - post(device, uname); - - /* poke init */ - if (kill(1, SIGHUP)) { - fprintf(stderr, - "Cannot send hangup to init process: %s\n", - sys_errlist[errno]); - (void)settys(resettty); - (void)setmodem(device, resetmodem); - exit(1); - } - - if (enable) - return; - - /* wait till init has responded, clearing the utmp entry */ - i = 100; - do { - sleep(1); - if (lseek(etcutmp, utmploc, 0) < 0) - fprintf(stderr, "On lseek in %s: %s", - _PATH_UTMP, sys_errlist[errno]); - if (read(etcutmp, (char *)&utmp, sizeof utmp) < 0) - fprintf(stderr, "On read from %s: %s", - _PATH_UTMP, sys_errlist[errno]); - } while (utmp.ut_name[0] != '\0' && --i > 0); -} - -#ifdef BSD4_3 -/* identify terminal line in ttys */ -opnttys(device) -char *device; -{ - register int ndevice; - register char *p; - char *index(); - char linebuf[BUFSIZ]; - - ttysfile = NULL; - do { - if (ttysfile != NULL) { - fclose(ttysfile); - sleep(5); - } - ttysfile = fopen(Etcttys, "r"); - if(ttysfile == NULL) { - fprintf(stderr, "Cannot open %s: %s\n", Etcttys, - sys_errlist[errno]); - exit(1); - } - } while (flock(fileno(ttysfile), LOCK_NB|LOCK_EX) < 0); - nttysfile = fopen(NEtcttys, "w"); - if(nttysfile == NULL) { - fprintf(stderr, "Cannot open %s: %s\n", Etcttys, - sys_errlist[errno]); - exit(1); - } - - ndevice = strlen(device); -#ifndef BRL4_2 - utmploc = sizeof(utmp); -#else BRL4_2 - utmploc = 0; -#endif BRL4_2 - - while(fgets(linebuf, sizeof(linebuf) - 1, ttysfile) != NULL) { - if(strncmp(device, linebuf, ndevice) == 0) - return; - ttyslnbeg += strlen(linebuf); - if (linebuf[0] != '#' && linebuf[0] != '\0') - utmploc += sizeof(utmp); - if (fputs(linebuf, nttysfile) == NULL) { - fprintf(stderr, "On %s write: %s\n", - Etcttys, sys_errlist[errno]); - exit(1); - } - - } - fprintf(stderr, "%s not found in %s\n", device, Etcttys); - exit(1); -} - -/* modify appropriate line in _PATH_TTYS to turn on/off the device */ -settys(enable) -int enable; -{ - register char *cp, *cp2; - char lbuf[BUFSIZ]; - int i; - char c1, c2; - - (void) fseek(ttysfile, ttyslnbeg, 0); - if(fgets(lbuf, BUFSIZ, ttysfile) == NULL) { - fprintf(stderr, "On %s read: %s\n", - Etcttys, sys_errlist[errno]); - exit(1); - } - /* format is now */ - /* ttyd0 std.100 dialup on secure # comment */ - /* except, 2nd item may have embedded spaces inside quotes, Hubert */ - cp = lbuf; - for (i=0;*cp && i<3;i++) { - if (*cp == '"') { - cp++; - while (*cp && *cp != '"') - cp++; - if (*cp != '\0') - cp++; - }else { - while (*cp && *cp != ' ' && *cp != '\t') - cp++; - } - while (*cp && (*cp == ' ' || *cp == '\t')) - cp++; - } - if (*cp == '\0') { - fprintf(stderr,"Badly formatted line in %s:\n%s", - _PATH_TTYS, lbuf); - exit(1); - } - c1 = *--cp; - *cp++ = '\0'; - cp2 = cp; - while (*cp && *cp != ' ' && *cp != '\t' && *cp != '\n') - cp++; - if (*cp == '\0') { - fprintf(stderr,"Badly formatted line in %s:\n%s", - _PATH_TTYS, lbuf); - exit(1); - } - c2 = *cp; - *cp++ = '\0'; - while (*cp && (*cp == ' ' || *cp == '\t')) - cp++; - resettty = strcmp("on", cp2) != 0; - fprintf(nttysfile,"%s%c%s%c%s", lbuf, c1, enable ? "on" : "off", c2, cp); - if (ferror(nttysfile)) { - fprintf(stderr, "On %s fprintf: %s\n", - NEtcttys, sys_errlist[errno]); - exit(1); - } - while(fgets(lbuf, sizeof(lbuf) - 1, ttysfile) != NULL) { - if (fputs(lbuf, nttysfile) == NULL) { - fprintf(stderr, "On %s write: %s\n", - NEtcttys, sys_errlist[errno]); - exit(1); - } - } - - if (enable^resettty) - (void) unlink(NEtcttys); - else { - struct stat statb; - if (stat(Etcttys, &statb) == 0) { - fchmod(fileno(nttysfile) ,statb.st_mode); - fchown(fileno(nttysfile), statb.st_uid, statb.st_gid); - } - (void) rename(NEtcttys, Etcttys); - } - (void) fclose(nttysfile); - (void) fclose(ttysfile); - return enable^resettty; -} - -#else !BSD4_3 - -/* identify terminal line in ttys */ -opnttys(device) -char *device; -{ - register FILE *ttysfile; - register int ndevice, lnsiz; - register char *p; - char *index(); - char linebuf[BUFSIZ]; - - ttysfile = fopen(Etcttys, "r"); - if(ttysfile == NULL) { - fprintf(stderr, "Cannot open %s: %s\n", Etcttys, - sys_errlist[errno]); - exit(1); - } - - ndevice = strlen(device); - ttyslnbeg = 0; - utmploc = 0; - - while(fgets(linebuf, sizeof(linebuf) - 1, ttysfile) != NULL) { - lnsiz = strlen(linebuf); - if ((p = index(linebuf, '\n')) != NULL) - *p = '\0'; - if(strncmp(device, &linebuf[2], ndevice) == 0) { - (void)fclose(ttysfile); -#ifdef sequent - /* Why is the sequent off by one? */ - utmploc += sizeof(utmp); -#endif sequent - return; - } - ttyslnbeg += lnsiz; - utmploc += sizeof(utmp); - } - fprintf(stderr, "%s not found in %s\n", device, Etcttys); - exit(1); -} - -/* modify appropriate line in _PATH_TTYS to turn on/off the device */ -settys(enable) -int enable; -{ - int ittysfil; - char out, in; - - ittysfil = open(Etcttys, 2); - if(ittysfil < 0) { - fprintf(stderr, "Cannot open %s for output: %s\n", - Etcttys, sys_errlist[errno]); - exit(1); - } - (void)lseek(ittysfil, ttyslnbeg, 0); - if(read(ittysfil, &in, 1)<0) { - fprintf(stderr, "On %s write: %s\n", - Etcttys, sys_errlist[errno]); - exit(1); - } - resettty = (in == '1'); - out = enable ? '1' : '0'; - (void)lseek(ittysfil, ttyslnbeg, 0); - if(write(ittysfil, &out, 1)<0) { - fprintf(stderr, "On %s write: %s\n", - Etcttys, sys_errlist[errno]); - exit(1); - } - (void)close(ittysfil); - return(in==out); -} -#endif !BSD4_3 - -#ifdef sequent -setmodem(ttyline, enable) -char *ttyline; int enable; -{ - char *sysbuf[BUFSIZ]; - sprintf(sysbuf,"/etc/ttyconfig /dev/%s -special %s", ttyline, - enable ? "-carrier" : "-nocarrier"); - system(sysbuf); -} -#endif /* sequent */ -#ifdef vax -/* - * Excerpted from (June 8, 1983 W.Sebok) - * > ttymodem.c - enable/disable modem control for tty lines. - * > - * > Knows about DZ11s and DH11/DM11s. - * > 23.3.83 - TS - * > modified to know about DMF's (hasn't been tested) Nov 8, 1984 - WLS - */ - - -setmodem(ttyline, enable) -char *ttyline; int enable; -{ - dev_t dev; - int kmem; - int unit, line, nlines, addr, tflags; - int devtype=0; - char cflags; short sflags; -#ifdef BSD4_2 - int flags; -#else - short flags; -#endif - struct uba_device *ubinfo; - struct stat statb; - struct cdevsw cdevsw; - - if(nl[CDEVSW].n_type == 0) { - fprintf(stderr, "No namelist.\n"); - return(-1); - } - - if((kmem = open(_PATH_KMEM, 2)) < 0) { - fprintf(stderr, "%s open: %s\n", _PATH_KMEM, - sys_errlist[errno]); - return(-1); - } - - if(stat(ttyline, &statb) < 0) { - fprintf(stderr, "%s stat: %s\n", ttyline, sys_errlist[errno]); - return(-1); - } - - if((statb.st_mode&S_IFMT) != S_IFCHR) { - fprintf(stderr, "%s is not a character device.\n",ttyline); - return(-1); - } - - dev = statb.st_rdev; - (void)lseek(kmem, - (off_t) &(((struct cdevsw *)NLVALUE(CDEVSW))[major(dev)]),0); - (void)read(kmem, (char *) &cdevsw, sizeof cdevsw); - - if((int)(cdevsw.d_open) == NLVALUE(DZOPEN)) { - devtype = DZ11; - unit = minor(dev) / NDZLINE; - line = minor(dev) % NDZLINE; - addr = (int) &(((int *)NLVALUE(DZINFO))[unit]); - (void)lseek(kmem, (off_t) NLVALUE(NDZ11), 0); - } else if((int)(cdevsw.d_open) == NLVALUE(DHOPEN)) { - devtype = DH11; - unit = minor(dev) / NDHLINE; - line = minor(dev) % NDHLINE; - addr = (int) &(((int *)NLVALUE(DHINFO))[unit]); - (void)lseek(kmem, (off_t) NLVALUE(NDH11), 0); - } else if((int)(cdevsw.d_open) == NLVALUE(DMFOPEN)) { - devtype = DMF; - unit = minor(dev) / NDMFLINE; - line = minor(dev) % NDMFLINE; - addr = (int) &(((int *)NLVALUE(DMFINFO))[unit]); - (void)lseek(kmem, (off_t) NLVALUE(NDMF), 0); - } else { - fprintf(stderr, "Device %s (%d/%d) unknown.\n", ttyline, - major(dev), minor(dev)); - return(-1); - } - - (void)read(kmem, (char *) &nlines, sizeof nlines); - if(minor(dev) >= nlines) { - fprintf(stderr, "Sub-device %d does not exist (only %d).\n", - minor(dev), nlines); - return(-1); - } - - (void)lseek(kmem, (off_t)addr, 0); - (void)read(kmem, (char *) &ubinfo, sizeof ubinfo); - (void)lseek(kmem, (off_t) &(ubinfo->ui_flags), 0); - (void)read(kmem, (char *) &flags, sizeof flags); - - tflags = 1<ui_flags), 0); - (void)write(kmem, (char *) &flags, sizeof flags); - switch(devtype) { - case DZ11: - if((addr = NLVALUE(DZSCAR)) == 0) { - fprintf(stderr, "No dzsoftCAR.\n"); - return(-1); - } - cflags = flags; - (void)lseek(kmem, (off_t) &(((char *)addr)[unit]), 0); - (void)write(kmem, (char *) &cflags, sizeof cflags); - break; - case DH11: - if((addr = NLVALUE(DHSCAR)) == 0) { - fprintf(stderr, "No dhsoftCAR.\n"); - return(-1); - } - sflags = flags; - (void)lseek(kmem, (off_t) &(((short *)addr)[unit]), 0); - (void)write(kmem, (char *) &sflags, sizeof sflags); - break; - case DMF: - if((addr = NLVALUE(DMFSCAR)) == 0) { - fprintf(stderr, "No dmfsoftCAR.\n"); - return(-1); - } - cflags = flags; - (void)lseek(kmem, (off_t) &(((char *)addr)[unit]), 0); - (void)write(kmem, (char *) &cflags, sizeof cflags); - break; - default: - fprintf(stderr, "Unknown device type\n"); - return(-1); - } - return(0); -} -#endif /* vax */ - -prefix(s1, s2) - register char *s1, *s2; -{ - register char c; - - while ((c = *s1++) == *s2++) - if (c == '\0') - return (1); - return (c == '\0'); -} -#else /* !DIALINOUT */ -main() -{ - fprintf(stderr,"acucntrl is not supported on this system\n"); -} -#endif /* !DIALINOUT */ diff --git a/usr.bin/uucp/uupoll/uupoll.8 b/usr.bin/uucp/uupoll/uupoll.8 deleted file mode 100644 index f6ee49b..0000000 --- a/usr.bin/uucp/uupoll/uupoll.8 +++ /dev/null @@ -1,111 +0,0 @@ -.\" Copyright (c) 1986, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)uupoll.8 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt UUPOLL 8 -.Os BSD 4.3 -.Sh NAME -.Nm uupoll -.Nd poll a remote -.Tn UUCP -site -.Sh SYNOPSIS -.Nm uupoll -.Op Fl g Ns Ar grade -.Op Fl n -.Ar system -.Sh DESCRIPTION -.Nm Uupoll -is used to force a poll of a remote system. It queues a null job for the -remote system and then invokes -.Xr uucico 8 . -.Pp -The following options are available: -.Bl -tag -width Fl -.It Fl g Ns Ar grade -Only send jobs of grade -.Ar grade -or higher on this call. -.It Fl n -Queue the null job, but do not invoke -.Xr uucico . -.El -.Pp -.Nm Uupoll -is usually run by -.Xr cron 5 -or by a user who wants to hurry a job along. A typical entry in -.Em crontab -could be: -.Bd -literal -0 0,8,16 * * * daemon /usr/bin/uupoll ihnp4 -0 4,12,20 * * * daemon /usr/bin/uupoll ucbvax -.Ed -.Pp -This will poll -.Em ihnp4 -at midnight, 0800, and 1600, and -.Em ucbvax -at 0400, noon, and 2000. -.Pp -If the local machine is already running -.Xr uucico -every -hour and has a limited number of outgoing modems, a more elegant approach -might be: -.Bd -literal -0 0,8,16 * * * daemon /usr/bin/uupoll -n ihnp4 -0 4,12,20 * * * daemon /usr/bin/uupoll -n ucbvax -5 * * * * daemon /usr/lib/uucp/uucico -r1 -.Ed -.Pp -This will queue null jobs for the remote sites at the top of hour; they -will be processed by -.Xr uucico -when it runs five minutes later. -.Sh FILES -.Bl -tag -width /usr/lib/uucp/UUCP -compact -.It Pa /usr/lib/uucp/UUCP -internal files/utilities -.It Pa /var/spool/uucp/ -Spool directory -.El -.Sh SEE ALSO -.Xr uucp 1 , -.Xr uux 1 , -.Xr uucico 8 -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.3 . diff --git a/usr.bin/uucp/uupoll/uupoll.c b/usr.bin/uucp/uupoll/uupoll.c deleted file mode 100644 index 5d5e662..0000000 --- a/usr.bin/uucp/uupoll/uupoll.c +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * Copyright (c) 1986, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1986, 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)uupoll.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * Poll named system(s). - * - * The poll occurs even if recent attempts have failed, - * but not if L.sys prohibits the call (e.g. wrong time of day). - * - * Original Author: Tom Truscott (rti!trt) - */ - -#include "uucp.h" - -int TransferSucceeded = 1; -struct timeb Now; - -main(argc, argv) -int argc; -char **argv; -{ - char wrkpre[MAXFULLNAME]; - char file[MAXFULLNAME]; - char grade = 'A'; - int nocall = 0; - int c; - char *sysname; - extern char *optarg; - extern int optind; - - if (argc < 2) { - fprintf(stderr, "usage: uupoll [-gX] [-n] system ...\n"); - cleanup(1); - } - - if (chdir(Spool) < 0) { - syslog(LOG_WARNING, "chdir(%s) failed: %m", Spool); - cleanup(1); - } - strcpy(Progname, "uupoll"); - uucpname(Myname); - - while ((c = getopt(argc, argv, "g:n")) != EOF) - switch(c) { - case 'g': - grade = *optarg; - break; - case 'n': - nocall++; - break; - case '?': - default: - fprintf(stderr, "unknown option %s\n", - argv[optind-1]); - } - - while(optind < argc) { - sysname = argv[optind++]; - if (strcmp(sysname, Myname) == SAME) { - fprintf(stderr, "This *is* %s!\n", Myname); - continue; - } - - if (versys(&sysname)) { - fprintf(stderr, "%s: unknown system.\n", sysname); - continue; - } - /* Remove any STST file that might stop the poll */ - sprintf(wrkpre, "%s/LCK..%.*s", LOCKDIR, MAXBASENAME, sysname); - if (access(wrkpre, 0) < 0) - rmstat(sysname); - sprintf(wrkpre, "%c.%.*s", CMDPRE, SYSNSIZE, sysname); - if (!iswrk(file, "chk", Spool, wrkpre)) { - sprintf(file, "%s/%c.%.*s%cPOLL", subdir(Spool, CMDPRE), - CMDPRE, SYSNSIZE, sysname, grade); - close(creat(file, 0666)); - } - /* Attempt the call */ - if (!nocall) - xuucico(sysname); - } - cleanup(0); -} - -cleanup(code) -int code; -{ - exit(code); -} diff --git a/usr.bin/uucp/uuq/Makefile b/usr.bin/uucp/uuq/Makefile deleted file mode 100644 index 60dbe0b..0000000 --- a/usr.bin/uucp/uuq/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= uuq -CFLAGS+=-I${.CURDIR}/../includes -BINMODE=6555 -DPADD= ${LIBCOMPAT} -LDADD= ${LIBUU} -lcompat - -.include diff --git a/usr.bin/uucp/uuq/uuq.1 b/usr.bin/uucp/uuq/uuq.1 deleted file mode 100644 index 783d486..0000000 --- a/usr.bin/uucp/uuq/uuq.1 +++ /dev/null @@ -1,126 +0,0 @@ -.\" Copyright (c) 1988, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)uuq.1 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt UUQ 1 -.Os BSD 4.3 -.Sh NAME -.Nm uuq -.Nd examine or manipulate the uucp queue -.Sh SYNOPSIS -.Nm uuq -.Op Fl l -.Op Fl h -.Op Fl s Ns Ar system -.Op Fl u Ns Ar user -.Op Fl d Ns Ar jobno -.Op Fl r Ns Ar sdir -.Op Fl b Ns Ar baud -.Sh DESCRIPTION -.Nm Uuq -is used to examine (and possibly delete) entries in the uucp queue. -.Pp -When listing jobs, -.Nm uuq -uses a format reminiscent of -.Xr ls . -For the long format, -information for each job listed includes -job number, number of files to transfer, user who -spooled the job, number of bytes to send, type of command requested -(S for sending files, R for receiving files, X for remote uucp), -and file or command desired. -.Pp -Several options are available: -.Bl -tag -width Ar -.It Fl h -Print only the summary lines for each system. Summary lines give system -name, number of jobs for the system, and total number of bytes to send. -.It Fl l -Specifies a long format listing. The default is to list only the -job numbers sorted across the page. -.It Fl s Ns Ar system -Limit output to jobs for systems whose system names begin with -.Ar system . -.It Fl u Ns Ar user -Limit output to jobs for users whose login names begin with -.Ar user . -.It Fl d Ns Ar jobno -Delete job number -.Ar jobno -(as obtained from a previous -.Nm uuq -command) -from the uucp queue. -Only the -.Tn UUCP -Administrator is permitted to delete jobs. -.It Fl r Ns Ar sdir -Look for files in the spooling directory -.Ar sdir -instead of the default -directory. -.It Fl b Ns Ar baud -Use -.Ar baud -to compute the transfer time instead of the default -1200 baud. -.El -.Sh FILES -.Bl -tag -width /usr/spool/uucp/Dhostname./D.x -compact -.It Pa /usr/spool/uucp/ -Default spool directory -.It Pa /usr/spool/uucp/C./C.* -Control files -.It Pa /usr/spool/uucp/D Ns Em hostname ./D.* -Outgoing data files -.It Pa /usr/spool/uucp/X./X.* -Outgoing execution files -.El -.Sh SEE ALSO -.Xr uucp 1 , -.Xr uux 1 , -.Xr uulog 1 , -.Xr uusnap 8 -.Sh BUGS -No information is available on work requested by the remote machine. -.Pp -The user who requests a remote uucp command is unknown. -.Pp -.Dq Li uq \-l -can be horrendously slow. -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.3 . diff --git a/usr.bin/uucp/uuq/uuq.c b/usr.bin/uucp/uuq/uuq.c deleted file mode 100644 index 7abb25c..0000000 --- a/usr.bin/uucp/uuq/uuq.c +++ /dev/null @@ -1,435 +0,0 @@ -/*- - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1988, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)uuq.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * uuq - looks at uucp queues - * - * Lou Salkind - * New York University - * - */ - -#include "uucp.h" -#include - -#ifdef NDIR -#include "libndir/ndir.h" -#else !NDIR -#include -#endif !NDIR -#include - -#define NOSYS (struct sys *)0 - -#define W_TYPE wrkvec[0] -#define W_FILE1 wrkvec[1] -#define W_FILE2 wrkvec[2] -#define W_USER wrkvec[3] -#define W_OPTNS wrkvec[4] -#define W_DFILE wrkvec[5] -#define W_MODE wrkvec[6] -#define WSUFSIZE 5 /* work file name suffix size */ - -struct sys { - char s_name[8]; - int s_njobs; - off_t s_bytes; - struct job *s_jobp; - struct sys *s_sysp; -}; - -struct job { - int j_files; - int j_flags; - char j_jobno[WSUFSIZE]; - char j_user[22]; - char j_fname[128]; - char j_grade; - off_t j_bytes; - time_t j_date; - struct job *j_jobp; -}; - -struct sys *syshead; -struct sys *getsys(); -int jcompare(); -char *sysname; -char *user; -char *rmjob; -int hflag; -int lflag; - -char *malloc(), *calloc(); -double atof(); -float baudrate = 2400.; -char Username[BUFSIZ]; -char Filename[BUFSIZ]; -int Maxulen = 0; -struct timeb Now; - -main(argc, argv) -int argc; -char **argv; -{ - register int i; - register struct sys *sp; - register struct job *jp; - struct job **sortjob; - int nsys; - extern char *optarg; - extern int optind; - - strcpy(Progname, "uuq"); - uucpname(Myname); - - while ((i = getopt(argc, argv, "r:S:s:u:d:b:hl")) != EOF) - switch (i) { - case 'r': - case 'S': - Spool = optarg; - break; - case 's': - sysname = optarg; - if (strlen(sysname) > SYSNSIZE) - sysname[SYSNSIZE] = '\0'; - break; - case 'u': - user = optarg; - break; - case 'd': - rmjob = optarg; - break; - case 'b': - baudrate = atof(optarg); - break; - case 'h': - hflag++; - break; - case 'l': - lflag++; - break; - default: - fprintf(stderr, - "usage: uuq [-l] [-h] [-ssystem] [-uuser] [-djobno] [-rspool] [-bbaudrate]\n"); - exit(0); - } - - subchdir(Spool); - baudrate *= 0.7; /* reduce speed because of protocol overhead */ - baudrate *= 7.5; /* convert to chars/minute (60/8) */ - gather(); - nsys = 0; - for (sp = syshead; sp; sp = sp->s_sysp) { - if (sp->s_njobs == 0) - continue; - if (!hflag && nsys++ > 0) - putchar('\n'); - printf("%s: %d %s", sp->s_name, - sp->s_njobs, sp->s_njobs > 1 ? "jobs" : "job"); - if (lflag) { - float minutes; - int hours; - /* The 80 * njobs is because of the uucp handshaking */ - minutes = (float)(sp->s_bytes + 80 * sp->s_njobs)/baudrate; - hours = minutes/60; - printf(", %ld bytes, ", sp->s_bytes); - if (minutes > 60){ - printf("%d hour%s, ",hours, - hours > 1 ? "s": ""); - minutes -= 60 * hours; - } - printf("%3.1f minutes (@ effective baudrate of %d)", - minutes,(int)(baudrate/6)); - } - putchar('\n'); - if (hflag) - continue; - /* sort them babies! */ - sortjob = (struct job **)calloc(sp->s_njobs, sizeof (struct job *)); - for (i=0, jp=sp->s_jobp; i < sp->s_njobs; i++, jp=jp->j_jobp) - sortjob[i] = jp; - qsort(sortjob, sp->s_njobs, sizeof (struct job *), jcompare); - for (i = 0; i < sp->s_njobs; i++) { - jp = sortjob[i]; - if (lflag) { - printf("%s %2d %-*s%7ld%5.1f %-12.12s %c %.*s\n", - jp->j_jobno, jp->j_files, Maxulen, jp->j_user, jp->j_bytes, jp->j_bytes/baudrate, - ctime(&jp->j_date) + 4, jp->j_flags, sizeof (jp->j_fname), jp->j_fname - ); - } else { - printf("%s", jp->j_jobno); - putchar((i+1)%10 ? '\t' : '\n'); - } - /* There's no need to keep the force poll if jobs > 1*/ - if (sp->s_njobs > 1 && strcmp("POLL", jp->j_jobno)==0) { - char pbuf[BUFSIZ]; - sprintf(pbuf,"%s/%c.%s%cPOLL", - subdir(Spool, CMDPRE), CMDPRE, - sp->s_name, jp->j_grade); - (void) unlink(pbuf); - } - } - if (!lflag && (sp->s_njobs%10)) - putchar('\n'); - } - exit(0); -} - -jcompare(j1, j2) -struct job **j1, **j2; -{ - int delta; - - delta = (*j1)->j_grade - (*j2)->j_grade; - if (delta) - return delta; - return(strcmp((*j1)->j_jobno,(*j2)->j_jobno)); -} - -/* - * Get all the command file names - */ -gather() -{ - struct direct *d; - DIR *df; - - /* - * Find all the spool files in the spooling directory - */ - if ((df = opendir(subdir(Spool, CMDPRE))) == NULL) { - fprintf(stderr, "can't examine spooling area\n"); - exit(1); - } - for (;;) { - if ((d = readdir(df)) == NULL) - break; - if (d->d_namlen <= 2 || d->d_name[0] != CMDPRE || - d->d_name[1] != '.') - continue; - if (analjob(d->d_name) < 0) { - fprintf(stderr, "out of memory\n"); - break; - } - } - closedir(df); -} - -/* - * analjob does the grunge work of verifying jobs - */ -#include -analjob(filename) -char *filename; -{ - struct job *jp; - struct sys *sp; - char sbuf[MAXNAMLEN+1], str[256], nbuf[256]; - char *jptr, *wrkvec[20]; - char grade; - FILE *fp, *df; - struct stat statb; - int files, gotname, i; - off_t bytes; - - strncpy(sbuf, filename, MAXNAMLEN); - sbuf[MAXNAMLEN] = '\0'; - jptr = sbuf + strlen(sbuf) - WSUFSIZE; - grade = *jptr; - *jptr++ = 0; - /* - * sbuf+2 now points to sysname name (null terminated) - * jptr now points to job number (null terminated) - */ - if (rmjob) { - if (strcmp(rmjob, jptr)) - return(0); - } else { - if ((sp = getsys(sbuf+2)) == NOSYS) - return(0); - if (!lflag) { - /* SHOULD USE A SMALLER STRUCTURE HERE */ - jp = (struct job *)malloc(sizeof(struct job)); - if (jp == (struct job *)0) - return(-1); - strcpy(jp->j_jobno, jptr); - jp->j_jobp = sp->s_jobp; - jp->j_grade = grade; - sp->s_jobp = jp; - sp->s_njobs++; - return(1); - } - } - if ((fp = fopen(subfile(filename), "r")) == NULL) { - perror(subfile(filename)); - return(0); - } - files = 0; - bytes = 0; - gotname = 0; - while (fgets(str, sizeof str, fp)) { - if (getargs(str, wrkvec, 20) <= 0) - continue; - if (rmjob) { - int myuid; - struct passwd *pw; - /* - * Make sure person who is removing data files is - * the person who created it or root. - */ - myuid = getuid(); - pw = getpwnam(W_USER); - if (myuid && (pw == NULL || myuid != pw->pw_uid)) { - fprintf(stderr, "Permission denied.\n"); - exit(1); - } - if (W_TYPE[0] == 'S' && !index(W_OPTNS, 'c')) { - unlink(subfile(W_DFILE)); - fprintf(stderr, "Removing data file %s\n", W_DFILE); - } - continue; - } - if (user && (W_TYPE[0] == 'X' || !prefix(user, W_USER))) { - fclose(fp); - return(0); - } - files++; - if (W_TYPE[0] == 'S') { - if (strcmp(W_DFILE, "D.0") && - stat(subfile(W_DFILE), &statb) >= 0) - bytes += statb.st_size; - else if (stat(subfile(W_FILE1), &statb) >= 0) - bytes += statb.st_size; - } - /* amusing heuristic */ -#define isXfile(s) (s[0]=='D' && s[strlen(s)-WSUFSIZE]=='X') - if (gotname == 0 && isXfile(W_FILE1)) { - if ((df = fopen(subfile(W_FILE1), "r")) == NULL) - continue; - while (fgets(nbuf, sizeof nbuf, df)) { - nbuf[strlen(nbuf) - 1] = '\0'; - if (nbuf[0] == 'C' && nbuf[1] == ' ') { - strcpy(Filename, nbuf+2); - gotname++; - } else if (nbuf[0] == 'R' && nbuf[1] == ' ') { - register char *p, *q, *r; - r = q = p = nbuf+2; - do { - if (*p == '!' || *p == '@'){ - r = q; - q = p+1; - } - } while (*p++); - - strcpy(Username, r); - W_USER = Username; - } - } - fclose(df); - } - } - fclose(fp); - if (rmjob) { - unlink(subfile(filename)); - fprintf(stderr, "Removing command file %s\n", filename); - exit(0); - } - if (files == 0) { - static char *wtype = "X"; - static char *wfile = "forced poll"; - if (strcmp("POLL", &filename[strlen(filename)-4])) { - fprintf(stderr, "%.14s: empty command file\n", filename); - return(0); - } - W_TYPE = wtype; - W_FILE1 = wfile; - } - jp = (struct job *)malloc(sizeof(struct job)); - if (jp == (struct job *)0) - return(-1); - strcpy(jp->j_jobno, jptr); - jp->j_files = files; - jp->j_bytes = bytes; - jp->j_grade = grade; - jp->j_flags = W_TYPE[0]; - strncpy(jp->j_user, W_TYPE[0]=='X' ? "---" : W_USER, 20 ); - jp->j_user[20] = '\0'; - i = strlen(jp->j_user); - if (i > Maxulen) - Maxulen = i; - /* SHOULD ADD ALL INFORMATION IN THE WHILE LOOP */ - if (gotname) - strncpy(jp->j_fname, Filename, sizeof jp->j_fname); - else - strncpy(jp->j_fname, W_FILE1, sizeof jp->j_fname); - stat(subfile(filename), &statb); - jp->j_date = statb.st_mtime; - jp->j_jobp = sp->s_jobp; - sp->s_jobp = jp; - sp->s_njobs++; - sp->s_bytes += jp->j_bytes; - return(1); -} - -struct sys * -getsys(s) -register char *s; -{ - register struct sys *sp; - - for (sp = syshead; sp; sp = sp->s_sysp) - if (strcmp(s, sp->s_name) == 0) - return(sp); - if (sysname && !prefix(sysname, s)) - return(NOSYS); - sp = (struct sys *)malloc(sizeof(struct sys)); - if (sp == NOSYS) - return(NOSYS); - strcpy(sp->s_name, s); - sp->s_njobs = 0; - sp->s_jobp = (struct job *)0; - sp->s_sysp = syshead; - sp->s_bytes = 0; - syshead = sp; - return(sp); -} diff --git a/usr.bin/uucp/uusend/Makefile b/usr.bin/uucp/uusend/Makefile deleted file mode 100644 index 6c13fb4..0000000 --- a/usr.bin/uucp/uusend/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= uusend -LINKS= ${BINDIR}/uusend ${BINDIR}/ruusend - -.include diff --git a/usr.bin/uucp/uusend/uusend.1 b/usr.bin/uucp/uusend/uusend.1 deleted file mode 100644 index 9379307..0000000 --- a/usr.bin/uucp/uusend/uusend.1 +++ /dev/null @@ -1,96 +0,0 @@ -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)uusend.1 8.3 (Berkeley) 2/16/94 -.\" -.Dd February 16, 1994 -.Dt UUSEND 1 -.Os BSD 4 -.Sh NAME -.Nm uusend -.Nd send a file to a remote host -.Sh SYNOPSIS -.Nm uusend -.Op Fl m Ar mode -.Ar sourcefile -.Ar sys1!sys2!..!remotefile -.Sh DESCRIPTION -.Nm Uusend -sends a file to a given location on a remote system. -The system need not be directly connected to the local -system, but a chain of -.Xr uucp 1 -links must to connect the two systems. -.Pp -Available option: -.Bl -tag -width Fl -.It Fl m Ar mode -The mode of the file on the remote -end is taken from the octal number given. -Otherwise, the mode of the input file will be used. -.El -.Pp -The sourcefile -can be -.Ql Fl , -meaning to use the standard input. -Both of these options are primarily intended for internal use of -.Nm uusend . -.Pp -The remotefile can include the -.Em ~userid -syntax. -.Sh DIAGNOSTICS -If anything goes wrong any further away than the first system down -the line, you will never hear about it. -.Sh SEE ALSO -.Xr uux 1 , -.Xr uucp 1 , -.Xr uuencode 1 -.Sh BUGS -This command should not exist, since -.Xr uucp -should handle it. -.Pp -All systems along the line must have the -.Nm uusend -command available and allow remote execution of it. -.Pp -Some uucp systems have a bug where binary files cannot be the -input to a -.Xr uux 1 -command. If this bug exists in any system along the line, -the file will show up severely munged. -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.0 . diff --git a/usr.bin/uucp/uusend/uusend.c b/usr.bin/uucp/uusend/uusend.c deleted file mode 100644 index 207108e..0000000 --- a/usr.bin/uucp/uusend/uusend.c +++ /dev/null @@ -1,403 +0,0 @@ -/*- - * Copyright (c) 1980, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1980, 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)uusend.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * uusend: primitive operation to allow uucp like copy of binary files - * but handle indirection over systems. - * - * usage: uusend [-r] [-m ooo] localfile sysname1!sysname2!...!destfile - * uusend [-r] [-m ooo] - sysname1!sysname2!...!destfile - * - * Author: Mark Horton, May 1980. - * - * "-r" switch added. Has same effect as "-r" in uux. 11/82 CCW - * - * Error recovery (a la uucp) added & ifdefs for ruusend (as in rmail). - * Checks for illegal access to /usr/lib/uucp. - * February 1983 Christopher Woodbury - * Fixed mode set[ug]id loophole. 4/8/83 CCW - * - * Add '-f' to make uusend syntax more similar to UUCP. "destname" - * can now be a directory. June 1983 CCW - */ - -#include -#include -#include -#include - -/* - * define RECOVER to permit requests like 'uusend file sys1!sys2!~uucp' - * (abbreviation for 'uusend file sys1!sys2!~uucp/file'). - * define DEBUG to keep log of uusend uusage. - * define RUUSEND if neighboring sites permit 'ruusend', - * which they certainly should to avoid security holes - */ -#define RECOVER -/*#define DEBUG "/usr/spool/uucp/uusend.log"/**/ - -FILE *in, *out; -FILE *dout; - -extern FILE *popen(); -extern char *index(), *strcpy(), *strcat(), *ctime(); - -#ifdef RUUSEND -int rsend; -#endif RUUSEND -int mode = -1; /* mode to chmod new file to */ -char *nextsys; /* next system in the chain */ -char dnbuf[200]; /* buffer for result of ~user/file */ -char cmdbuf[256]; /* buffer to build uux command in */ -char *rflg = ""; /* default value of rflg ccw -- 1 Nov '82 */ - -struct passwd *user; /* entry in /etc/passwd for ~user */ -struct passwd *getpwnam(); -struct stat stbuf; - -char *excl; /* location of first ! in destname */ -char *sl; /* location of first / in destname */ -char *sourcename; /* argv[1] */ -char *destname; /* argv[2] */ -char *UULIB = "/usr/lib/uucp"; /* UUCP lib directory */ - -#ifdef RECOVER -char *UUPUB = "/usr/spool/uucppublic/"; /* public UUCP directory */ -char *filename; /* file name from end of destname */ -char *getfname(); /* routine to get filename from destname */ -int fflg; -char f[100]; /* name of default output file */ -#else !RECOVER -char *f = ""; /* so we waste a little space */ -#endif !RECOVER - -main(argc, argv) -int argc; -char **argv; -{ - register int c; - long count; - extern char **environ; - -#ifdef DEBUG - long t; - umask(022); - dout = fopen(DEBUG, "a"); - if (dout == NULL) { - printf("Cannot append to %s\n", DEBUG); - exit(1); - } - freopen(DEBUG, "a", stdout); - fprintf(dout, "\nuusend run: "); - for (c=0; c 1 && argv[1][0] == '-' && argv[1][1]) { - switch(argv[1][1]) { - case 'm': - sscanf(argv[2], "%o", &mode); - mode &= 0777; /* fix set[ug]id loophole */ - argc--; argv++; - break; - case 'r': /* -r flag for uux */ - rflg = "-r "; - break; -#ifdef RECOVER - case 'f': - fflg++; - strcpy(f, argv[1]); - break; -#endif RECOVER - default: - fprintf(stderr, "Bad flag: %s\n", argv[1]); - break; - } - argc--; argv++; - } - - if (argc != 3) { - fprintf(stderr, "Usage: uusend [-m ooo] [-r] -/file sys!sys!..!rfile\n"); - exit(1); - } - - sourcename = argv[1]; - destname = argv[2]; - - if (sourcename[0] == '-') - in = stdin; - else { -#ifdef RUUSEND - if (rsend) { - fprintf(stderr, "illegal input\n"); - exit(2); - } -#endif RUUSEND - in = fopen(sourcename, "r"); - if (in == NULL) { - perror(argv[1]); - exit(2); - } - if (!fflg || f[2] == '\0') { - strcpy(f, "-f"); - strcat(f, getfname(sourcename)); - fflg++; - } - } - - excl = index(destname, '!'); - if (excl) { - /* - * destname is on a remote system. - */ - nextsys = destname; - *excl++ = 0; - destname = excl; - if (mode < 0) { - fstat(fileno(in), &stbuf); - mode = stbuf.st_mode & 0777; - } -#ifdef RUUSEND - sprintf(cmdbuf,"uux -gn -z %s- \"%s!ruusend %s -m %o - (%s)\"", -#else !RUUSEND - sprintf(cmdbuf, "uux -gn -z %s- \"%s!uusend %s -m %o - (%s)\"", -#endif !RUUSEND - rflg, nextsys, f, mode, destname); -#ifdef DEBUG - fprintf(dout, "remote: nextsys='%s', destname='%s', cmd='%s'\n", nextsys, destname, cmdbuf); -#endif DEBUG - out = popen(cmdbuf, "w"); - } else { - /* - * destname is local. - */ - if (destname[0] == '~') { -#ifdef DEBUG - fprintf(dout, "before ~: '%s'\n", destname); -fflush(dout); -#endif DEBUG - sl = index(destname, '/'); -#ifdef RECOVER - if (sl == NULL && !fflg) { - fprintf(stderr, "Illegal ~user\n"); - exit(3); - } - for (sl = destname; *sl != '\0'; sl++) - ; /* boy, is this a hack! */ -#else !RECOVER - if (sl == NULL) { - fprintf(stderr, "Illegal ~user\n"); - exit(3); - } - *sl++ = 0; -#endif !RECOVER - user = getpwnam(destname+1); - if (user == NULL) { - fprintf(stderr, "No such user as %s\n", - destname); -#ifdef RECOVER - if ((filename =getfname(sl)) == NULL && - !fflg) - exit(4); - strcpy(dnbuf, UUPUB); - if (fflg) - strcat(dnbuf, &f[2]); - else - strcat(dnbuf, filename); - } - else { - strcpy(dnbuf, user->pw_dir); - strcat(dnbuf, "/"); - strcat(dnbuf, sl); - } -#else !RECOVER - exit(4); - } - strcpy(dnbuf, user->pw_dir); - strcat(dnbuf, "/"); - strcat(dnbuf, sl); -#endif !RECOVER - destname = dnbuf; - } -#ifdef RECOVER - else - destname = strcpy(dnbuf, destname); -#endif !RECOVER - if(strncmp(UULIB, destname, strlen(UULIB)) == 0) { - fprintf(stderr, "illegal file: %s", destname); - exit(4); - } -#ifdef RECOVER - if (stat(destname, &stbuf) == 0 && - (stbuf.st_mode & S_IFMT) == S_IFDIR && - fflg) { - strcat(destname, "/"); - strcat(destname, &f[2]); - } -#endif RECOVER - out = fopen(destname, "w"); -#ifdef DEBUG - fprintf(dout, "local, file='%s'\n", destname); -#endif DEBUG - if (out == NULL) { - perror(destname); -#ifdef RECOVER - if (strncmp(destname,UUPUB,strlen(UUPUB)) == 0) - exit(5); /* forget it! */ - filename = getfname(destname); - if (destname == dnbuf) /* cmdbuf is scratch */ - filename = strcpy(cmdbuf, filename); - destname = strcpy(dnbuf, UUPUB); - if (user != NULL) { - strcat(destname, user->pw_name); - if (stat(destname, &stbuf) == -1) { - mkdir(destname, 0777); - } - strcat(destname, "/"); - } - if (fflg) - strcat(destname, &f[2]); - else - strcat(destname, filename); - if ((out = fopen(destname, "w")) == NULL) - exit(5); /* all for naught! */ -#else !RECOVER - exit(5); -#endif !RECOVER - } - if (mode > 0) - chmod(destname, mode); /* don't bother to check it */ - } - - /* - * Now, in any case, copy from in to out. - */ - - count = 0; - while ((c=getc(in)) != EOF) { - putc(c, out); - count++; - } -#ifdef DEBUG - fprintf(dout, "count %ld bytes\n", count); - fclose(dout); -#endif DEBUG - - fclose(in); - fclose(out); /* really should pclose in that case */ - exit(0); -} - -/* - * Return the ptr in sp at which the character c appears; - * NULL if not found. Included so I don't have to fight the - * index/strchr battle. - */ - -#define NULL 0 - -char * -index(sp, c) -register char *sp, c; -{ - do { - if (*sp == c) - return(sp); - } while (*sp++); - return(NULL); -} - -#ifdef RECOVER -char * -getfname(p) -register char *p; -{ - register char *s; - s = p; - while (*p != '\0') - p++; - if (p == s) - return (NULL); - for (;p != s; p--) - if (*p == '/') { - p++; - break; - } - return (p); -} - -#ifndef BSD4_2 -makedir(dirname, mode) -char *dirname; -int mode; -{ - register int pid; - int retcode, status; - switch ((pid = fork())) { - case -1: /* error */ - return (-1); - case 0: /* child */ - umask(0); - execl("/bin/mkdir", "mkdir", dirname, (char *)0); - exit(1); - /* NOTREACHED */ - default: /* parent */ - while ((retcode=wait(&status)) != pid && retcode != -1) - ; - if (retcode == -1) - return -1; - else { - chmod(dirname, mode); - return status; - } - } - /* NOTREACHED */ -} -#endif !BSD4_2 -#endif RECOVER diff --git a/usr.bin/uucp/uusnap/uusnap.8 b/usr.bin/uucp/uusnap/uusnap.8 deleted file mode 100644 index 92f0e330..0000000 --- a/usr.bin/uucp/uusnap/uusnap.8 +++ /dev/null @@ -1,80 +0,0 @@ -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)uusnap.8 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt UUSNAP 8 -.Os BSD 4.2 -.Sh NAME -.Nm uusnap -.Nd show snapshot of the -.Tn UUCP -system -.Sh SYNOPSIS -.Nm uusnap -.Sh DESCRIPTION -.Nm Uusnap -displays in tabular format a synopsis of the current -.Tn UUCP -situation. The format of each line is as follows: -.Bd -literal -offset indent -compact - -site N Cmds N Data N Xqts Message - -.Ed -Where "site" is the name of the site with work, "N" is a count of -each of the three possible types of work (command, data, or remote execute), -and "Message" is the current status message for that -site as found in the -.Tn STST -file. -.Pp -Included in "Message" may be the time left before -.Tn UUCP -can re-try the -call, and the count of the number of times that -.Tn UUCP -has tried -(unsuccessfully) to reach the site. -.Sh SEE ALSO -.Xr uucp 1 , -.Xr uux 1 , -.Xr uuq 1 , -.Xr uucico 8 -.Rs -.%T "UUCP Implementation Guide" -.Re -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.2 . diff --git a/usr.bin/uucp/uusnap/uusnap.c b/usr.bin/uucp/uusnap/uusnap.c deleted file mode 100644 index 565c52a..0000000 --- a/usr.bin/uucp/uusnap/uusnap.c +++ /dev/null @@ -1,348 +0,0 @@ -/*- - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Rick Adams. Originally by RJKing WECo-MG6565 May 83. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1988, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)uusnap.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include "uucp.h" -#include -#ifdef NDIR -#include "ndir.h" -#else -#include -#endif -#include - -#define NSYSTEM 300 /* max # of systems queued */ - -#define CMDSLEN 5 /* Length of trailer */ -#define DATALEN 5 /* Length of trailer */ -#define XEQTLEN 5 /* Length of trailer */ -#define NUMCTRS 3 /* # file types to count */ -#define CMDTYPE 0 /* Index into scnt.cntr */ -#define DATTYPE 1 /* Index into scnt.cntr */ -#define XEQTYPE 2 /* Index into scnt.cntr */ - -struct scnt { /* System count structure */ - char name[MAXBASENAME+1]; /* Name of system */ - short cntr[NUMCTRS]; /* Count */ - char stst[32]; /* STST Message */ - time_t locked; /* If LCK..sys present */ - int st_type; /* STST Type */ - int st_count; /* STST Count */ - time_t st_lastime; /* STST Last time tried */ - time_t st_retry; /* STST Secs to retry */ - }; - -int sndx; /* Number of systems */ -struct scnt sys[NSYSTEM]; /* Systems queued */ -int xqtisrunning = 0; - -main() -{ - register int i, j, nlen = 0; - time_t curtime, t; - - dodir(CMDSDIR, "C.", CMDSLEN, '\0', CMDTYPE); - dodir(DATADIR, "D.", DATALEN, '\0', DATTYPE); - dodir(XEQTDIR, "X.", XEQTLEN, 'X', XEQTYPE); - getstst(SPOOL); - time(&curtime); - for(i=0; i nlen) - nlen = j; - for(i=0; i1?"s":" "); - else - printf(" --- "); - if(sys[i].cntr[DATTYPE]) - printf("%3.d Data ", sys[i].cntr[DATTYPE]); - else - printf(" --- "); - if(sys[i].cntr[XEQTYPE]) - printf("%3.d Xqt%s ", sys[i].cntr[XEQTYPE], - sys[i].cntr[XEQTYPE]>1?"s":" "); - else - printf(" --- "); - if(*sys[i].stst == '\0' || sys[i].locked > sys[i].st_lastime) { - if(sys[i].locked) - printf("LOCKED\n"); - else - printf("\n"); - continue; - } - printf("%s ", sys[i].stst); - /* decide if STST info is worth pursuing */ - if (-t < ONEDAY*2 && (sys[i].st_count == 0 - || sys[i].st_type == SS_WRONGTIME - || (sys[i].st_type == SS_INPROGRESS && sys[i].locked))) { - printf("\n"); - continue; - } - t = (sys[i].st_lastime +sys[i].st_retry) - curtime; - if (-t < ONEDAY*2 && sys[i].st_type != SS_FAIL) - t = 0; - - if (sys[i].st_count > MAXRECALLS) - printf("at MAX RECALLS"); - else if (-t >= ONEDAY*2) - printf("%ld days ago", (long)-t/ONEDAY); - else if (t <= 0) - printf("Retry time reached"); - else if (t < 60) - printf("Retry time %ld sec%s", (long)(t%60), - (t%60)!=1? "s": ""); - else - printf("Retry time %ld min%s", (long)(t/60), - (t/60)!=1? "s": ""); - if(sys[i].st_count > 1) - printf(" Count: %d\n", sys[i].st_count); - else - printf("\n"); - } - if (xqtisrunning) - printf("\nUuxqt is running\n"); - exit(0); -} - -dodir(dnam, prfx, flen, fchr, type) -char *dnam, *prfx; -int flen; -char fchr; -int type; -{ - register struct direct *dentp; - register DIR *dirp; - register int i, fnamlen, plen; - char fnam[MAXNAMLEN+1]; - - plen = strlen(prfx); - if(chdir(dnam) < 0) { - perror(dnam); - exit(1); - } - if ((dirp = opendir(".")) == NULL) { - perror(dnam); - exit(1); - } - while((dentp = readdir(dirp)) != NULL) { - if(*dentp->d_name == '.') - continue; - if(strncmp(dentp->d_name, prfx, plen) != SAME) { - fprintf(stderr, "strange file (%s) in %s\n", - dentp->d_name, dnam); - continue; - } - strcpy(fnam, &dentp->d_name[plen]); - fnamlen = strlen(fnam); - if(flen > 0) { - fnamlen -= flen; - fnam[fnamlen] = '\0'; - fnamlen = MAXBASENAME; /* yes, after = '\0'*/ - } else { - for(; fnamlen>0; --fnamlen) { - if(fnam[fnamlen] == fchr) { - fnam[fnamlen] = '\0'; - break; - } - } - fnamlen = MAXBASENAME; - } - for(i=0; i= NSYSTEM) { - sndx = NSYSTEM-1; - fprintf(stderr,"Too many system names.\n"); - } - } - } - closedir(dirp); -} - -getstst(sdir) -char *sdir; -{ - register int i, csys; - register char *tp; - char fnam[MAXNAMLEN+1], buff[128]; - register struct direct *dentp; - register DIR *dirp; - register FILE *st; - struct stat stbuf; - long atol(); - - if (chdir(sdir) < 0) { - perror(sdir); - exit(1); - } - if ((dirp = opendir(LOCKDIR)) == NULL) { - perror(sdir); - exit(1); - } - while ((dentp = readdir(dirp)) != NULL) { - if (strcmp(&dentp->d_name[5], X_LOCK) == SAME) { - xqtisrunning++; - continue; - } - if(strncmp(dentp->d_name, "LCK..", 5) == SAME) { - if(strncmp(&dentp->d_name[5], "tty", 3) == SAME || - strncmp(&dentp->d_name[5], "cul", 3) == SAME) - continue; - strcpy(fnam, dentp->d_name); - for(csys=0; csysd_name == '.') - continue; - strcpy(fnam, dentp->d_name); - for(csys=0; csys] -[8<0411040040114000>] -[8<0204081020408001>] -[8<0000103810000000>] -[8<6699996666999966>] -[8<0000800100001008>] -[8<81c36666c3810000>] -[8<0f0e0c0800000000>] -[8<0000000000000010>] -[8<0411040040114000>] -[8<0204081020408001>] -[8<0000001038100000>] -[8<6699996666999966>] -[8<0000800100001008>] -[8<81c36666c3810000>] -[8<0f0e0c0800000000>] -[8<0042660000246600>] -[8<0000990000990000>] -[8<0804020180402010>] -[8<2418814242811824>] -[8<6699996666999966>] -[8<8000000008000000>] -[8<00001c3e363e1c00>] -[8<0000000000000000>] -[32<00000040000000c00000004000000040000000e0000000000000000000000000>] -[32<00000000000060000000900000002000000040000000f0000000000000000000>] -[32<000000000000000000e0000000100000006000000010000000e0000000000000>] -[32<00000000000000002000000060000000a0000000f00000002000000000000000>] -[32<0000000e0000000000000000000000000000000f000000080000000e00000001>] -[32<0000090000000600000000000000000000000000000007000000080000000e00>] -[32<00010000000200000004000000040000000000000000000000000000000f0000>] -[32<0900000006000000090000000600000000000000000000000000000006000000>]] -[%ug -[8<0000020000000000>] -[8<0000020000002000>] -[8<0004020000002000>] -[8<0004020000402000>] -[8<0004060000402000>] -[8<0004060000406000>] -[8<0006060000406000>] -[8<0006060000606000>] -[8<00060e0000606000>] -[8<00060e000060e000>] -[8<00070e000060e000>] -[8<00070e000070e000>] -[8<00070e020070e000>] -[8<00070e020070e020>] -[8<04070e020070e020>] -[8<04070e024070e020>] -[8<04070e064070e020>] -[8<04070e064070e060>] -[8<06070e064070e060>] -[8<06070e066070e060>] -[8<06070f066070e060>] -[8<06070f066070f060>] -[8<060f0f066070f060>] -[8<060f0f0660f0f060>] -[8<060f0f0760f0f060>] -[8<060f0f0760f0f070>] -[8<0e0f0f0760f0f070>] -[8<0e0f0f07e0f0f070>] -[8<0e0f0f0fe0f0f070>] -[8<0e0f0f0fe0f0f0f0>] -[8<0f0f0f0fe0f0f0f0>] -[8<0f0f0f0ff0f0f0f0>] -[8<1f0f0f0ff0f0f0f0>] -[8<1f0f0f0ff1f0f0f0>] -[8<1f0f0f8ff1f0f0f0>] -[8<1f0f0f8ff1f0f0f8>] -[8<9f0f0f8ff1f0f0f8>] -[8<9f0f0f8ff9f0f0f8>] -[8<9f0f0f9ff9f0f0f8>] -[8<9f0f0f9ff9f0f0f9>] -[8<9f8f0f9ff9f0f0f9>] -[8<9f8f0f9ff9f8f0f9>] -[8<9f8f1f9ff9f8f0f9>] -[8<9f8f1f9ff9f8f1f9>] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8] -[8]] -[%mg -[8<8000000000000000>] -[8<0822080080228000>] -[8<0204081020408001>] -[8<40e0400000000000>] -[8<66999966>] -[8<8001000010080000>] -[8<81c36666c3810000>] -[8] -[16<07c00f801f003e007c00f800f001e003c007800f001f003e007c00f801f003e0>] -[16<1f000f8007c003e001f000f8007c003e001f800fc007e003f001f8007c003e00>] -[8] -[16<0040008001000200040008001000200040008000000100020004000800100020>] -[16<0040002000100008000400020001800040002000100008000400020001000080>] -[16<1fc03fe07df0f8f8f07de03fc01f800fc01fe03ff07df8f87df03fe01fc00f80>] -[8<80>] -[8<8040201000000000>] -[8<84cc000048cc0000>] -[8<9900009900000000>] -[8<08040201804020100800020180002010>] -[8<2418814242811824>] -[8<66999966>] -[8<8000000008000000>] -[8<70f8d8f870000000>] -[8<0814224180402010>] -[8] -[8<018245aa45820100>] -[8<221c224180808041>] -[8<88000000>] -[8<0855800080550800>] -[8<2844004482440044>] -[8<0810204080412214>] -[8<00>]]]def -/Dfill{ - save 6 1 roll - transform /maxy exch def /maxx exch def - transform /miny exch def /minx exch def - minx maxx gt{/minx maxx /maxx minx def def}if - miny maxy gt{/miny maxy /maxy miny def def}if - Dpatterns Dstipple 1 sub get exch 1 sub get - aload pop /stip exch def /stipw exch def /stiph 128 def - /imatrix[stipw 0 0 stiph 0 0]def - /tmatrix[stipw 0 0 stiph 0 0]def - /minx minx cvi stiph idiv stiph mul def - /miny miny cvi stipw idiv stipw mul def - eoclip 0 setgray - miny stiph maxy{ - tmatrix exch 5 exch put - minx stipw maxx{ - tmatrix exch 4 exch put tmatrix setmatrix - stipw stiph true imatrix {stip} imagemask - }for - }for - restore -}def -/Dp{Dfill Dstroke}def -/DP{Dfill currentpoint newpath moveto}def -end - -/ditstart{$DITroff begin - /nfonts 60 def % NFONTS makedev/ditroff dependent! - /fonts[nfonts{0}repeat]def - /fontnames[nfonts{()}repeat]def -/docsave save def -}def - -% character outcalls -/oc{ - /pswid exch def /cc exch def /name exch def - /ditwid pswid fontsize mul resolution mul 72000 div def - /ditsiz fontsize resolution mul 72 div def - ocprocs name known{ocprocs name get exec}{name cb}ifelse -}def -/fractm [.65 0 0 .6 0 0] def -/fraction{ - /fden exch def /fnum exch def gsave /cf currentfont def - cf fractm makefont setfont 0 .3 dm 2 copy neg rmoveto - fnum show rmoveto currentfont cf setfont(\244)show setfont fden show - grestore ditwid 0 rmoveto -}def -/oce{grestore ditwid 0 rmoveto}def -/dm{ditsiz mul}def -/ocprocs 50 dict def ocprocs begin -(14){(1)(4)fraction}def -(12){(1)(2)fraction}def -(34){(3)(4)fraction}def -(13){(1)(3)fraction}def -(23){(2)(3)fraction}def -(18){(1)(8)fraction}def -(38){(3)(8)fraction}def -(58){(5)(8)fraction}def -(78){(7)(8)fraction}def -(sr){gsave 0 .06 dm rmoveto(\326)show oce}def -(is){gsave 0 .15 dm rmoveto(\362)show oce}def -(->){gsave 0 .02 dm rmoveto(\256)show oce}def -(<-){gsave 0 .02 dm rmoveto(\254)show oce}def -(==){gsave 0 .05 dm rmoveto(\272)show oce}def -(uc){gsave currentpoint 400 .009 dm mul add translate - 8 -8 scale ucseal oce}def -end - -% an attempt at a PostScript FONT to implement ditroff special chars -% this will enable us to -% cache the little buggers -% generate faster, more compact PS out of psdit -% confuse everyone (including myself)! -50 dict dup begin -/FontType 3 def -/FontName /DIThacks def -/FontMatrix [.001 0 0 .001 0 0] def -/FontBBox [-260 -260 900 900] def% a lie but ... -/Encoding 256 array def -0 1 255{Encoding exch /.notdef put}for -Encoding - dup 8#040/space put %space - dup 8#110/rc put %right ceil - dup 8#111/lt put %left top curl - dup 8#112/bv put %bold vert - dup 8#113/lk put %left mid curl - dup 8#114/lb put %left bot curl - dup 8#115/rt put %right top curl - dup 8#116/rk put %right mid curl - dup 8#117/rb put %right bot curl - dup 8#120/rf put %right floor - dup 8#121/lf put %left floor - dup 8#122/lc put %left ceil - dup 8#140/sq put %square - dup 8#141/bx put %box - dup 8#142/ci put %circle - dup 8#143/br put %box rule - dup 8#144/rn put %root extender - dup 8#145/vr put %vertical rule - dup 8#146/ob put %outline bullet - dup 8#147/bu put %bullet - dup 8#150/ru put %rule - dup 8#151/ul put %underline - pop -/DITfd 100 dict def -/BuildChar{0 begin - /cc exch def /fd exch def - /charname fd /Encoding get cc get def - /charwid fd /Metrics get charname get def - /charproc fd /CharProcs get charname get def - charwid 0 fd /FontBBox get aload pop setcachedevice - 2 setlinejoin 40 setlinewidth - newpath 0 0 moveto gsave charproc grestore - end}def -/BuildChar load 0 DITfd put -/CharProcs 50 dict def -CharProcs begin -/space{}def -/.notdef{}def -/ru{500 0 rls}def -/rn{0 840 moveto 500 0 rls}def -/vr{0 800 moveto 0 -770 rls}def -/bv{0 800 moveto 0 -1000 rls}def -/br{0 840 moveto 0 -1000 rls}def -/ul{0 -140 moveto 500 0 rls}def -/ob{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath stroke}def -/bu{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath fill}def -/sq{80 0 rmoveto currentpoint dround newpath moveto - 640 0 rlineto 0 640 rlineto -640 0 rlineto closepath stroke}def -/bx{80 0 rmoveto currentpoint dround newpath moveto - 640 0 rlineto 0 640 rlineto -640 0 rlineto closepath fill}def -/ci{500 360 rmoveto currentpoint newpath 333 0 360 arc - 50 setlinewidth stroke}def - -/lt{0 -200 moveto 0 550 rlineto currx 800 2cx s4 add exch s4 a4p stroke}def -/lb{0 800 moveto 0 -550 rlineto currx -200 2cx s4 add exch s4 a4p stroke}def -/rt{0 -200 moveto 0 550 rlineto currx 800 2cx s4 sub exch s4 a4p stroke}def -/rb{0 800 moveto 0 -500 rlineto currx -200 2cx s4 sub exch s4 a4p stroke}def -/lk{0 800 moveto 0 300 -300 300 s4 arcto pop pop 1000 sub - 0 300 4 2 roll s4 a4p 0 -200 lineto stroke}def -/rk{0 800 moveto 0 300 s2 300 s4 arcto pop pop 1000 sub - 0 300 4 2 roll s4 a4p 0 -200 lineto stroke}def -/lf{0 800 moveto 0 -1000 rlineto s4 0 rls}def -/rf{0 800 moveto 0 -1000 rlineto s4 neg 0 rls}def -/lc{0 -200 moveto 0 1000 rlineto s4 0 rls}def -/rc{0 -200 moveto 0 1000 rlineto s4 neg 0 rls}def -end - -/Metrics 50 dict def Metrics begin -/.notdef 0 def -/space 500 def -/ru 500 def -/br 0 def -/lt 416 def -/lb 416 def -/rt 416 def -/rb 416 def -/lk 416 def -/rk 416 def -/rc 416 def -/lc 416 def -/rf 416 def -/lf 416 def -/bv 416 def -/ob 350 def -/bu 350 def -/ci 750 def -/bx 750 def -/sq 750 def -/rn 500 def -/ul 500 def -/vr 0 def -end - -DITfd begin -/s2 500 def /s4 250 def /s3 333 def -/a4p{arcto pop pop pop pop}def -/2cx{2 copy exch}def -/rls{rlineto stroke}def -/currx{currentpoint pop}def -/dround{transform round exch round exch itransform} def -end -end -/DIThacks exch definefont pop -ditstart -(psc)xT -576 1 1 xr -1(Times-Roman)xf 1 f -2(Times-Italic)xf 2 f -3(Times-Bold)xf 3 f -4(Times-BoldItalic)xf 4 f -5(Helvetica)xf 5 f -6(Helvetica-Bold)xf 6 f -7(Courier)xf 7 f -8(Courier-Bold)xf 8 f -9(Symbol)xf 9 f -10(DIThacks)xf 10 f -10 s -1 f -xi -%%EndProlog - -%%Page: 1 1 -10 s 10 xH 0 xS 1 f 1 i -3 f -12 s -1796 795(Ex/Vi)N -2055(Reference)X -2491(Manual)X -2 f -10 s -2107 975(Keith)N -2300(Bostic)X -1 f -1861 1155(Computer)N -2201(Science)X -2471(Division)X -1328 1245(Department)N -1727(of)X -1814(Electrical)X -2142(Engineering)X -2554(and)X -2690(Computer)X -3030(Science)X -1754 1335(University)N -2112(of)X -2199(California,)X -2564(Berkeley)X -1856 1425(Berkeley,)N -2186(California)X -2551(94720)X -2038 1605(August)N -2289(15,)X -2409(1994)X -2 f -2168 1965(Abstract)N -1 f -776 2244(This)N -948(document)X -1294(is)X -1377(the)X -1505 0.4531(reference)AX -1836(guide)X -2045(for)X -2170(the)X -2299(4.4BSD)X -2585(implementations)X -3149(of)X -3 f -3247(nex)X -1 f -(/)S -3 f -3389(nvi)X -1 f -3495(,)X -3546(which)X -3773(are)X -576 2334(reimplementations)N -1192(of)X -1279(the)X -1397(historic)X -1657(Berkeley)X -3 f -1967(ex)X -1 f -2043(/)X -3 f -2065(vi)X -1 f -2147(editors.)X -2 f -1996 2778(Acknowledgements)N -1 f -776 3063(Bruce)N -1005(Englar)X -1256(encouraged)X -1664(the)X -1799(early)X -1997(development)X -2448(of)X -2552(the)X -2687(historic)X -3 f -2965(ex)X -1 f -3041(/)X -3 f -3063(vi)X -1 f -3163(editor.)X -3428(Peter)X -3631(Kessler)X -576 3153(helped)N -811(bring)X -1001(sanity)X -1213(to)X -1296(version)X -1553(2's)X -1672(command)X -2009(layout.)X -2270(Bill)X -2410(Joy)X -2541(wrote)X -2744(versions)X -3031(1)X -3091(and)X -3227(2.0)X -3347(through)X -3616(2.7,)X -3756(and)X -576 3243(created)N -842(the)X -973(framework)X -1359(that)X -1512(users)X -1710(see)X -1846(in)X -1941(the)X -2072(present)X -2337(editor.)X -2597(Mark)X -2804(Horton)X -3065(added)X -3291(macros)X -3557(and)X -3707(other)X -576 3333(features)N -851(and)X -987(made)X -3 f -1181(ex)X -1 f -1257(/)X -3 f -1279(vi)X -1 f -1361(work)X -1546(on)X -1646(a)X -1702(large)X -1883(number)X -2148(of)X -2235(terminals)X -2553(and)X -2689(Unix)X -2869(systems.)X -3 f -776 3456(Nvi)N -1 f -918(is)X -993(originally)X -1326(derived)X -1589(from)X -1767(software)X -2066(contributed)X -2454(to)X -2539(the)X -2660(University)X -3021(of)X -3111(California,)X -3479(Berkeley)X -3792(by)X -576 3546(Steve)N -774(Kirkendall,)X -1157(the)X -1275(author)X -1500(of)X -1587(the)X -3 f -1705(vi)X -1 f -1787(clone)X -3 f -1981(elvis)X -1 f -2132(.)X -776 3669(IEEE)N -992(Standard)X -1319(Portable)X -1628(Operating)X -1991(System)X -2268(Interface)X -2597(for)X -2733(Computer)X -3095(Environments)X -3587(\(POSIX\))X -576 3759(1003.2)N -816(style)X -987(Regular)X -1261(Expression)X -1637(support)X -1897(was)X -2042(done)X -2218(by)X -2318(Henry)X -2539(Spencer.)X -776 3882(The)N -930(curses)X -1161(library)X -1405(was)X -1560(originally)X -1901(done)X -2087(by)X -2197(Ken)X -2361(Arnold.)X -2658(Scrolling)X -2981(and)X -3127(reworking)X -3487(for)X -3 f -3611(nvi)X -1 f -3747(was)X -576 3972(done)N -752(by)X -852(Elan)X -1019(Amir.)X -776 4095(The)N -923(Institute)X -1207(of)X -1296(Electrical)X -1626(and)X -1764(Electronics)X -2147(Engineers)X -2490(has)X -2619(given)X -2820(us)X -2914(permission)X -3288(to)X -3373(reprint)X -3610(portions)X -576 4185(of)N -682(their)X -868(documentation.)X -1423(Portions)X -1728(of)X -1834(this)X -1987(document)X -2341(are)X -2478(reprinted)X -2806(and)X -2960(reproduced)X -3360(from)X -3554(IEEE)X -3766(Std)X -576 4275(1003.2-1992,)N -1031(IEEE)X -1233(Standard)X -1546(Portable)X -1841(Operating)X -2190(System)X -2453(Interface)X -2768(for)X -2890(Computer)X -3238(Environments)X -3716(\(PO-)X -576 4365(SIX\),)N -772(copyright)X -1099(1992)X -1279(by)X -1379(the)X -1497(Institute)X -1779(of)X -1866(Electrical)X -2194(and)X -2330(Electronics)X -2711(Engineers,)X -3072(Inc.)X -776 4488(The)N -921(\256nancial)X -1217(support)X -1477(of)X -1564(UUNET)X -1856(Communications)X -2422(Services)X -2714(is)X -2787(gratefully)X -3119(acknowledged.)X - -3 p -%%Page: 3 2 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -3698(USD:13-3)X -576 762(1.)N -676(Description)X -1 f -3 f -776 885(Vi)N -1 f -876(is)X -949(a)X -1005(screen)X -1231(oriented)X -1514(text)X -1654(editor.)X -3 f -1902(Ex)X -1 f -2016(is)X -2090(a)X -2147(line-oriented)X -2578(text)X -2719(editor.)X -3 f -2967(Ex)X -1 f -3081(and)X -3 f -3218(vi)X -1 f -3301(are)X -3421(different)X -3719(interfaces)X -576 975(to)N -674(the)X -808(same)X -1009(program,)X -1336(and)X -1487(it)X -1566(is)X -1654(possible)X -1951(to)X -2048(switch)X -2292(back)X -2479(and)X -2630(forth)X -2821(during)X -3065(an)X -3176(edit)X -3331(session.)X -3 f -3637(View)X -1 f -3846(is)X -3934(the)X -576 1065(equivalent)N -930(of)X -1017(using)X -1210(the)X -3 f -9 f -1328(-)X -1330(-)X -3 f -1374(R)X -1 f -1452(\(read-only\))X -1834(option)X -2058(of)X -3 f -2145(vi)X -1 f -2207(.)X -776 1188(This)N -957 0.4531(reference)AX -1297(manual)X -1572(is)X -1664(the)X -1801(one)X -1956(provided)X -2280(with)X -2461(the)X -3 f -2598(nex)X -1 f -(/)S -3 f -2740(nvi)X -1 f -2885(versions)X -3191(of)X -3297(the)X -3 f -3434(ex)X -1 f -3510(/)X -3 f -3532(vi)X -1 f -3634(text)X -3794(editors.)X -3 f -576 1278(Nex)N -1 f -710(/)X -3 f -732(nvi)X -1 f -868(are)X -997(intended)X -1302(as)X -1398(bug-for-bug)X -1815(compatible)X -2200(replacements)X -2653(for)X -2776(the)X -2903(original)X -3181(Fourth)X -3423(Berkeley)X -3742(Software)X -576 1368(Distribution)N -987(\(4BSD\))X -3 f -1261(ex)X -1 f -1337(/)X -3 f -1359(vi)X -1 f -1446(programs.)X -1814(This)X -1981 0.4531(reference)AX -2307(manual)X -2568(is)X -2646(accompanied)X -3095(by)X -3201(a)X -3263(traditional-style)X -3796(manual)X -576 1458(page.)N -798(That)X -975(manual)X -1241(page)X -1423(describes)X -1752(the)X -1880(functionality)X -2319(found)X -2536(in)X -3 f -2627(ex)X -1 f -2703(/)X -3 f -2725(vi)X -1 f -2816(in)X -2907(far)X -3026(less)X -3175(detail)X -3382(than)X -3549(the)X -3676(description)X -576 1548(here.)N -781(In)X -874(addition,)X -1182(it)X -1252(describes)X -1578(the)X -1703(system)X -1952(interface)X -2261(to)X -3 f -2350(ex)X -1 f -2426(/)X -3 f -2448(vi)X -1 f -2510(,)X -2557(e.g.)X -2700(command)X -3043(line)X -3190(options,)X -3472(session)X -3730(recovery,)X -576 1638(signals,)N -838(environmental)X -1321(variables,)X -1651(and)X -1787(similar)X -2029(things.)X -776 1761(This)N -939 0.4531(reference)AX -1261(is)X -1336(intended)X -1634(for)X -1750(users)X -1937(already)X -2196(familiar)X -2472(with)X -3 f -2636(ex)X -1 f -2712(/)X -3 f -2734(vi)X -1 f -2796(.)X -2858(Anyone)X -3134(else)X -3281(should)X -3516(almost)X -3751(certainly)X -576 1851(read)N -737(a)X -795(good)X -977(tutorial)X -1230(on)X -1332(the)X -1452(editor)X -1661(\256rst.)X -1847(If)X -1923(you)X -2065(are)X -2186(in)X -2270(an)X -2368(unfamiliar)X -2723(environment,)X -3169(and)X -3306(you)X -3447(absolutely)X -3797(have)X -3970(to)X -576 1941(get)N -702(work)X -895(done)X -1079(immediately,)X -1527(see)X -1658(the)X -1784(section)X -2039(entitled)X -2308(``)X -3 f -2362(Fast)X -2538(Startup)X -1 f -2800('')X -2883(in)X -2974(the)X -3101(manual)X -3366(page.)X -3587(It)X -3665(is)X -3747(probably)X -576 2031(enough)N -832(to)X -914(get)X -1032(you)X -1172(started.)X -776 2154(There)N -984(are)X -1103(a)X -1159(few)X -1300(features)X -1575(in)X -3 f -1657(nex)X -1 f -(/)S -3 f -1799(nvi)X -1 f -1925(that)X -2065(are)X -2185(not)X -2308(found)X -2516(in)X -2599(historic)X -2860(versions)X -3148(of)X -3 f -3236(ex)X -1 f -3312(/)X -3 f -3334(vi)X -1 f -3396(.)X -3457(Some)X -3660(of)X -3748(the)X -3867(more)X -576 2244(interesting)N -941(of)X -1035(those)X -1231(features)X -1513(are)X -1639(brie\257y)X -1875(described)X -2210(in)X -2299(the)X -2424(section)X -2678(entitled)X -2945(``)X -3 f -2999(Additional)X -3389(Features)X -1 f -3688('')X -3769(near)X -3934(the)X -576 2334(end)N -719(of)X -813(this)X -955(document.)X -1338(For)X -1476(the)X -1601(rest)X -1744(of)X -1838(this)X -1980(document,)X -3 f -2343(nex)X -1 f -(/)S -3 f -2485(nvi)X -1 f -2618(is)X -2698(used)X -2872(only)X -3042(when)X -3244(it)X -3316(is)X -3397(necessary)X -3738(to)X -3828(distin-)X -576 2424(guish)N -769(it)X -833(from)X -1009(the)X -1127(historic)X -1387(implementations)X -1940(of)X -3 f -2027(ex)X -1 f -2103(/)X -3 f -2125(vi)X -1 f -2187(.)X -776 2547(Future)N -1012(versions)X -1306(of)X -1400(this)X -1542(software)X -1846(will)X -1997(be)X -2100(periodically)X -2510(made)X -2712(available)X -3030(by)X -3138(anonymous)X -3535(ftp,)X -3672(and)X -3816(can)X -3956(be)X -576 2637(retrieved)N -882(from)X -7 f -1058(ftp.cs.berkeley.edu)X -1 f -(,)S -2010(in)X -2092(the)X -2210(directory)X -7 f -2520(ucb/4bsd)X -1 f -(.)S -3 f -576 2823(2.)N -676(Startup)X -958(Information)X -1 f -3 f -776 2946(Ex)N -1 f -869(/)X -3 f -891(vi)X -1 f -981(interprets)X -1312(one)X -1456(of)X -1551(two)X -1699(possible)X -1989(environmental)X -2480(variables)X -2798(and)X -2942(reads)X -3140(up)X -3248(to)X -3338(three)X -3527(of)X -3622(\256ve)X -3770(possible)X -576 3036(\256les)N -737(during)X -974(startup.)X -1260(The)X -1413(variables)X -1731(and)X -1875(\256les)X -2036(are)X -2163(expected)X -2477(to)X -2567(contain)X -3 f -2831(ex)X -1 f -2935(commands,)X -3330(not)X -3 f -3460(vi)X -1 f -3550(commands.)X -3965(In)X -576 3126(addition,)N -879(they)X -1038(are)X -1158(interpreted)X -2 f -1527(before)X -1 f -1753(the)X -1872(\256le)X -1996(to)X -2080(be)X -2178(edited)X -2396(is)X -2471(read,)X -2652(and)X -2790(therefore)X -3103(many)X -3 f -3303(ex)X -1 f -3401(commands)X -3770(may)X -3930(not)X -576 3216(be)N -683(used.)X -901(Generally,)X -1269(any)X -1416(command)X -1763(that)X -1914(requires)X -2204(output)X -2439(to)X -2532(the)X -2660(screen)X -2896(or)X -2993(that)X -3143(needs)X -3356(a)X -3422(\256le)X -3554(upon)X -3744(which)X -3970(to)X -576 3306(operate,)N -853(will)X -997(cause)X -1196(an)X -1292(error)X -1469(if)X -1538(included)X -1834(in)X -1916(a)X -1972(startup)X -2210(\256le)X -2332(or)X -2419(environmental)X -2902(variable.)X -776 3429(Because)N -1071(the)X -3 f -1197(ex)X -1 f -1301(command)X -1645(set)X -1762(supported)X -2106(by)X -3 f -2214(nex)X -1 f -(/)S -3 f -2356(nvi)X -1 f -2490(is)X -2571(a)X -2635(superset)X -2926(of)X -3021(the)X -3147(command)X -3491(set)X -3608(supported)X -3952(by)X -576 3519(most)N -753(historical)X -1073(implementations)X -1628(of)X -3 f -1717(ex)X -1 f -1793(,)X -3 f -1835(nex)X -1 f -(/)S -3 f -1977(nvi)X -1 f -2105(can)X -2238(use)X -2366(the)X -2485(startup)X -2724(\256les)X -2878(created)X -3132(for)X -3247(the)X -3366(historical)X -3685(implemen-)X -576 3609(tations,)N -829(but)X -951(the)X -1069(converse)X -1375(may)X -1533(not)X -1655(be)X -1751(true.)X -776 3732(If)N -852(the)X -3 f -9 f -973(-)X -975(-)X -3 f -1019(s)X -1 f -1073(\(the)X -1221(historic)X -9 f -1484(-)X -1 f -1551(option\))X -1805(is)X -1881(speci\256ed,)X -2209(or)X -2299(if)X -2371(standard)X -2666(input)X -2853(is)X -2929(redirected)X -3274(from)X -3453(a)X -3512(\256le,)X -3657(all)X -3760(environ-)X -576 3822(mental)N -814(variables)X -1124(and)X -1260(startup)X -1498(\256les)X -1651(are)X -1770(ignored.)X -776 3945(Otherwise,)N -1146(startup)X -1384(\256les)X -1537(and)X -1673(environmental)X -2156(variables)X -2466(are)X -2585(handled)X -2859(in)X -2941(the)X -3059(following)X -3390(order:)X -616 4068(\(1\))N -830(The)X -975(\256le)X -7 f -1097(/etc/vi.exrc)X -1 f -1693(is)X -1766(read,)X -1945(as)X -2032(long)X -2194(as)X -2281(it)X -2345(is)X -2418(owned)X -2652(by)X -2752(root)X -2901(or)X -2988(the)X -3106(effective)X -3408(user)X -3562(ID)X -3667(of)X -3754(the)X -3872(user.)X -616 4191(\(2\))N -830(The)X -981(environmental)X -1471(variable)X -7 f -1757(NEXINIT)X -1 f -2120(\(or)X -2241(the)X -2366(variable)X -7 f -2652(EXINIT)X -1 f -(,)S -2987(if)X -7 f -3063(NEXINIT)X -1 f -3426(is)X -3506(not)X -3635(set\))X -3778(is)X -3858(inter-)X -830 4281(preted.)N -616 4404(\(3\))N -830(If)X -918(neither)X -7 f -1175(NEXINIT)X -1 f -1545(or)X -7 f -1646(EXINIT)X -1 f -1968(was)X -2127(set,)X -2270(and)X -2420(the)X -7 f -2552(HOME)X -1 f -2778(environmental)X -3275(variable)X -3568(is)X -3655(set,)X -3798(the)X -3930(\256le)X -7 f -830 4494($HOME/.nexrc)N -1 f -1430(\(or)X -1548(the)X -1670(\256le)X -7 f -1796($HOME/.exrc)X -1 f -(,)S -2368(if)X -7 f -2441($HOME/.nexrc)X -1 f -3041(does)X -3212(not)X -3338(exist\))X -3540(is)X -3617(read,)X -3800(as)X -3890(long)X -830 4584(as)N -917(the)X -1035(effective)X -1337(user)X -1491(ID)X -1596(of)X -1683(the)X -1801(user)X -1955(is)X -2028(root)X -2177(or)X -2264(is)X -2337(the)X -2455(same)X -2640(as)X -2727(the)X -2845(owner)X -3066(of)X -3153(the)X -3271(\256le.)X -616 4707(\(4\))N -830(If)X -921(the)X -3 f -1056(exrc)X -1 f -1241(option)X -1482(was)X -1644(turned)X -1886(on)X -2003(by)X -2120(one)X -2273(of)X -2377(the)X -2512(previous)X -2825(startup)X -3080(information)X -3495(sources,)X -3794(the)X -3930(\256le)X -7 f -830 4797(.nexrc)N -1 f -1142(\(or)X -1260(the)X -1382(\256le)X -7 f -1508(.exrc)X -1 f -(,)S -1792(if)X -7 f -1864(.nexrc)X -1 f -2175(does)X -2345(not)X -2470(exist\))X -2671(is)X -2747(read,)X -2929(as)X -3019(long)X -3184(as)X -3274(the)X -3395(effective)X -3700(user)X -3857(ID)X -3965(of)X -830 4887(the)N -948(user)X -1102(is)X -1175(the)X -1293(same)X -1478(as)X -1565(the)X -1683(owner)X -1904(of)X -1991(the)X -2109(\256le.)X -776 5010(No)N -894(startup)X -1132(\256le)X -1254(is)X -1327(read)X -1486(if)X -1555(it)X -1619(is)X -1692(writable)X -1975(by)X -2075(anyone)X -2327(other)X -2512(than)X -2670(its)X -2765(owner.)X -776 5133(It)N -845(is)X -918(not)X -1040(an)X -1136(error)X -1313(for)X -1427(any)X -1563(of)X -1650(the)X -1768(startup)X -2006(environmental)X -2489(variables)X -2799(or)X -2886(\256les)X -3039(not)X -3161(to)X -3243(exist.)X -776 5256(Once)N -978(all)X -1090(environmental)X -1585(variables)X -1907(are)X -2038(interpreted,)X -2438(and)X -2586(all)X -2698(startup)X -2948(\256les)X -3114(are)X -3246(read,)X -3438(the)X -3569(\256rst)X -3726(\256le)X -3861(to)X -3956(be)X -576 5346(edited)N -800(is)X -881(read)X -1048(in)X -1138(\(or)X -1260(a)X -1324(temporary)X -1682(\256le)X -1812(is)X -1893(created\).)X -2221(Then,)X -2434(any)X -2578(commands)X -2953(speci\256ed)X -3266(using)X -3467(the)X -3 f -9 f -3593(-)X -3595(-)X -3 f -3639(c)X -1 f -3702(option)X -3933(are)X -576 5436(executed,)N -902(in)X -984(the)X -1102(context)X -1358(of)X -1445(that)X -1585(\256le.)X - -4 p -%%Page: 4 3 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-4)N -3391(Nvi/Nex)X -3687 0.3906(Reference)AX -576 762(3.)N -676(Recovery)X -1 f -776 885(There)N -991(is)X -1071(no)X -1178(recovery)X -1487(program)X -1786(for)X -3 f -1907(nex)X -1 f -(/)S -3 f -2049(nvi)X -1 f -2155(,)X -2202(nor)X -2336(does)X -3 f -2510(nex)X -1 f -(/)S -3 f -2652(nvi)X -1 f -2785(run)X -2919(setuid.)X -3177(Recovery)X -3512(\256les)X -3672(are)X -3799(created)X -576 975(readable)N -887(and)X -1041(writable)X -1342(by)X -1460(the)X -1596(owner)X -1835(only.)X -2055(Users)X -2276(may)X -2452(recover)X -2732(any)X -2886(\256le)X -3026(which)X -3260(they)X -3436(can)X -3585(read,)X -3781(and)X -3934(the)X -576 1065(superuser)N -904(may)X -1062(recover)X -1324(any)X -1460(edit)X -1600(session.)X -776 1188(Edit)N -952(sessions)X -1257(are)X -1399(backed)X -1670(by)X -1793(\256les)X -1969(in)X -2074(the)X -2215(directory)X -2548(named)X -2805(by)X -2929(the)X -3 f -3071(recdir)X -1 f -3325(option)X -3573(\(the)X -3742(directory)X -7 f -576 1278(/var/tmp/vi.recover)N -1 f -1508(by)X -1608(default\),)X -1898(and)X -2034(are)X -2153(named)X -2387(``)X -3 f -2441(vi.XXXXXX)X -1 f -2871('',)X -2965(where)X -3182(``)X -3 f -3236(XXXXXX)X -1 f -3584('')X -3658(is)X -3731(a)X -3787(number)X -576 1368(related)N -816(to)X -899(the)X -1018(process)X -1281(ID.)X -1428(When)X -1642(a)X -1700(\256le)X -1824(is)X -1899(\256rst)X -2045(modi\256ed,)X -2371(a)X -2429(second)X -2674(recovery)X -2978(\256le)X -3102(containing)X -3462(an)X -3560(email)X -3760(message)X -576 1458(for)N -691(the)X -810(user)X -965(is)X -1039(created,)X -1313(and)X -1450(is)X -1524(named)X -1759(``)X -3 f -1813 0.3077(recover.XXXXXX)AX -1 f -2441('',)X -2536(where,)X -2774(again,)X -2989(``)X -3 f -3043(XXXXXX)X -1 f -3391('')X -3466(is)X -3540(associated)X -3890(with)X -576 1548(the)N -698(process)X -963(ID.)X -1112(Both)X -1291(\256les)X -1448(are)X -1571(removed)X -1876(at)X -1958(the)X -2080(end)X -2220(of)X -2311(a)X -2371(normal)X -2622(edit)X -2766(session,)X -3041(but)X -3168(will)X -3317(remain)X -3565(if)X -3639(the)X -3762(edit)X -3907(ses-)X -576 1638(sion)N -729(is)X -802(abnormally)X -1187(terminated)X -1550(or)X -1637(the)X -1755(user)X -1909(runs)X -2067(the)X -3 f -2185(ex)X -2281(preserve)X -1 f -2596(command.)X -776 1761(The)N -3 f -935(recdir)X -1 f -1180(option)X -1419(may)X -1592(be)X -1703(set)X -1827(in)X -1924(either)X -2142(the)X -2275(user's)X -2502(or)X -2604(system's)X -2919(startup)X -3172(information,)X -3605(changing)X -3934(the)X -576 1851(recovery)N -887(directory.)X -1246(\(Note,)X -1478(however,)X -1804(that)X -1953(if)X -2031(a)X -2096(memory)X -2392(based)X -2604(\256le)X -2735(system)X -2985(is)X -3066(used)X -3241(as)X -3336(the)X -3462(backup)X -3722(directory,)X -576 1941(each)N -752(system)X -1002(reboot)X -1235(will)X -1388(delete)X -1609(all)X -1718(of)X -1814(the)X -1941(recovery)X -2252(\256les!)X -2461(The)X -2615(same)X -2809(caution)X -3074(applies)X -3330(to)X -3421(directories)X -3789(such)X -3965(as)X -7 f -576 2031(/tmp)N -1 f -792(which)X -1012(are)X -1135(cleared)X -1392(of)X -1483(their)X -1654(contents)X -1945(by)X -2049(a)X -2108(system)X -2353(reboot,)X -2601(or)X -7 f -2691(/usr/tmp)X -1 f -3098(which)X -3317(is)X -3393(periodically)X -3799(cleared)X -576 2121(of)N -663(old)X -785(\256les)X -938(on)X -1038(many)X -1236(systems.\))X -776 2244(The)N -926(recovery)X -1233(directory)X -1548(should)X -1786(be)X -1887(owned)X -2126(by)X -2231(root,)X -2405(or)X -2497(at)X -2580(least)X -2752(by)X -2857(a)X -2918(pseudo-user.)X -3371(In)X -3463(addition,)X -3770(if)X -3844(direc-)X -576 2334(tory)N -727(``sticky-bit'')X -1159(semantics)X -1497(are)X -1618(available,)X -1950(the)X -2070(directory)X -2382(should)X -2617(have)X -2791(the)X -2911(sticky-bit)X -3234(set)X -3344(so)X -3436(that)X -3577(\256les)X -3731(may)X -3890(only)X -576 2424(be)N -676(removed)X -981(by)X -1085(their)X -1256(owners.)X -1552(The)X -1702(recovery)X -2009(directory)X -2324(must)X -2504(be)X -2605(read,)X -2789(write,)X -2999(and)X -3140(executable)X -3509(by)X -3614(any)X -3755(user,)X -3934(i.e.)X -576 2514(mode)N -774(1777.)X -776 2637(If)N -850(the)X -968(recovery)X -1270(directory)X -1581(does)X -1749(not)X -1872(exist,)X -3 f -2064(ex)X -1 f -2140(/)X -3 f -2162(vi)X -1 f -2245(will)X -2390(attempt)X -2651(to)X -2734(create)X -2948(it.)X -3053(This)X -3216(can)X -3349(result)X -3548(in)X -3631(the)X -3750(recovery)X -576 2727(directory)N -895(being)X -1102(owned)X -1345(by)X -1454(a)X -1518(normal)X -1773(user,)X -1955(which)X -2179(means)X -2412(that)X -2560(that)X -2708(user)X -2870(will)X -3022(be)X -3126(able)X -3288(to)X -3378(remove)X -3647(other)X -3840(user's)X -576 2817(recovery)N -880(and)X -1018(backup)X -1272(\256les.)X -1467(This)X -1631(is)X -1706(annoying,)X -2046(but)X -2170(is)X -2245(not)X -2369(a)X -2427(security)X -2703(issue)X -2886(as)X -2976(the)X -3097(user)X -3254(cannot)X -3491(otherwise)X -3826(access)X -576 2907(or)N -663(modify)X -914(the)X -1032(\256les.)X -776 3030(The)N -924(recovery)X -1229(\256le)X -1354(has)X -1484(all)X -1587(of)X -1677(the)X -1798(necessary)X -2134(information)X -2535(in)X -2621(it)X -2689(to)X -2775(enable)X -3009(the)X -3131(user)X -3289(to)X -3375(recover)X -3641(the)X -3763(edit)X -3907(ses-)X -576 3120(sion.)N -774(In)X -866(addition,)X -1173(it)X -1242(has)X -1374(all)X -1479(of)X -1571(the)X -1694(necessary)X -2032(email)X -2235(headers)X -2505(for)X -2 f -2623(sendmail)X -1 f -2912(\(8\).)X -3070(When)X -3286(the)X -3408(system)X -3654(is)X -3731(rebooted,)X -576 3210(all)N -677(of)X -765(the)X -884(\256les)X -1038(in)X -7 f -1121(/var/tmp/vi.recover)X -1 f -2054(named)X -2289(``)X -3 f -2343 0.3077(recover.XXXXXX)AX -1 f -2971('')X -3046(should)X -3280(be)X -3377(sent)X -3527(to)X -3611(their)X -3780(owners,)X -576 3300(by)N -684(email,)X -910(using)X -1111(the)X -3 f -9 f -1237(-)X -1239(-)X -3 f -1283(t)X -1 f -1338(option)X -1570(of)X -3 f -1665(sendmail)X -1 f -1999(\(or)X -2121(a)X -2185(similar)X -2434(mechanism)X -2826(in)X -2915(other)X -3107(mailers\).)X -3437(If)X -3 f -3518(ex)X -1 f -3594(/)X -3 f -3616(vi)X -1 f -3705(receives)X -3996(a)X -576 3390(hangup)N -839(\(SIGHUP\))X -1209(signal,)X -1447(or)X -1541(the)X -1666(user)X -1828(executes)X -2133(the)X -3 f -2259(ex)X -2363(preserve)X -1 f -2686(command,)X -3 f -3050(ex)X -1 f -3126(/)X -3 f -3148(vi)X -1 f -3238(will)X -3390(automatically)X -3854(email)X -576 3480(the)N -694(recovery)X -996(information)X -1394(to)X -1476(the)X -1594(user.)X -776 3603(If)N -853(your)X -1023(system)X -1268(does)X -1438(not)X -1564(have)X -1740(the)X -3 f -1862(sendmail)X -1 f -2192(utility)X -2406(\(or)X -2524(a)X -2584(mailer)X -2813(program)X -3109(which)X -3329(supports)X -3624(its)X -3723(interface\))X -576 3693(the)N -700(source)X -936(\256le)X -7 f -1063(nvi/common/recover.c)X -1 f -2048(will)X -2197(have)X -2374(to)X -2461(be)X -2562(modi\256ed)X -2871(to)X -2958(use)X -3090(your)X -3262(local)X -3443(mail)X -3610(delivery)X -3898(pro-)X -576 3783(grams.)N -833(Note,)X -1030(if)X -3 f -1100(nex)X -1 f -(/)S -3 f -1242(nvi)X -1 f -1369(is)X -1443(changed)X -1732(to)X -1815(use)X -1944(another)X -2207(mailer,)X -2454(it)X -2520(is)X -2595(important)X -2928(to)X -3012(remember)X -3360(that)X -3502(the)X -3622(owner)X -3845(of)X -3934(the)X -576 3873(\256le)N -708(given)X -916(to)X -1008(the)X -1136(mailer)X -1371(is)X -1454(the)X -3 f -1582(nex)X -1 f -(/)S -3 f -1724(nvi)X -1 f -1860(user,)X -2044(so)X -2145(nothing)X -2419(in)X -2511(the)X -2638(\256le)X -2769(should)X -3011(be)X -3116(trusted)X -3363(as)X -3459(it)X -3532(may)X -3699(have)X -3880(been)X -576 3963(modi\256ed)N -880(in)X -962(an)X -1058(effort)X -1257(to)X -1339(compromise)X -1755(the)X -1873(system.)X -776 4086(Finally,)N -1046(the)X -1168(owner)X -1393(execute)X -1663(bit)X -1771(is)X -1848(set)X -1961(on)X -2065(backup)X -2321(\256les)X -2478(when)X -2676(they)X -2838(are)X -2961(created,)X -3238(and)X -3378(unset)X -3571(when)X -3770(they)X -3933(are)X -576 4176(\256rst)N -724(modi\256ed,)X -1052(e.g.)X -1192(backup)X -1448(\256les)X -1605(that)X -1749(have)X -1925(no)X -2029(associated)X -2383(email)X -2585(recovery)X -2891(\256le)X -3017(will)X -3165(have)X -3341(this)X -3480(bit)X -3588(set.)X -3741(\(There)X -3979(is)X -576 4266(also)N -735(a)X -801(small)X -1004(window)X -1292(where)X -1519(empty)X -1749(\256les)X -1912(can)X -2054(be)X -2160(created)X -2424(and)X -2571(not)X -2704(yet)X -2833(have)X -3016(this)X -3162(bit)X -3277(set.)X -3437(This)X -3610(is)X -3694(due)X -3841(to)X -3934(the)X -576 4356(method)N -836(in)X -918(which)X -1134(the)X -1252(\256les)X -1405(are)X -1524(created.\))X -1844(Such)X -2024(\256les)X -2177(should)X -2410(be)X -2506(deleted)X -2758(when)X -2952(the)X -3070(system)X -3312(reboots.)X -776 4479(A)N -884(simple)X -1147(way)X -1331(to)X -1443(do)X -1573(this)X -1738(cleanup)X -2038(is)X -2141(to)X -2253(insert)X -2481(the)X -2630(following)X -2992(Bourne)X -3279(shell)X -3481(script)X -3710(into)X -3885(your)X -7 f -576 4569(/etc/rc.local)N -1 f -1224(\(or)X -1342(other)X -1531(startup\))X -1800(\256le.)X -1966(The)X -2115(script)X -2316(should)X -2552(work)X -2740(with)X -2905(the)X -3026(historic)X -3289(Bourne)X -3548(shell,)X -3742(a)X -3801(POSIX)X -576 4659(1003.2)N -818(shell)X -991(or)X -1080(the)X -1201(Korn)X -1389(shell.)X -1603(\(A)X -1711(copy)X -1890(of)X -1980(this)X -2118(script)X -2319(is)X -2395(included)X -2694(as)X -7 f -2784(nvi/install/recover.script)X -1 f -576 4749(in)N -658(the)X -3 f -776(nex)X -1 f -(/)S -3 f -918(nvi)X -1 f -1044(distribution.\))X - -5 p -%%Page: 5 4 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -3698(USD:13-5)X -7 f -896 762(#)N -1184(@\(#\)recover.script)X -2336(8.4)X -2528(\(Berkeley\))X -3056(8/13/94)X -896 852(#)N -896 942(#)N -992(Recover)X -1376(nvi)X -1568(editor)X -1904(files:)X -896 1032(RECDIR=/var/tmp/vi.recover)N -896 1122(SENDMAIL=/usr/lib/sendmail)N -896 1212(echo)N -1136('Recovering)X -1712(nvi)X -1904(editor)X -2240(sessions.')X -896 1392(#)N -992(Unmodified)X -1520(nvi)X -1712(editor)X -2048(backup)X -2384(files)X -2672(are)X -2864(either)X -3200(zero)X -3440(length)X -3776(or)X -896 1482(#)N -992(have)X -1232(the)X -1424(execute)X -1808(bit)X -2000(set.)X -2288(Delete)X -2624(both)X -2864(cases.)X -896 1572(vibackup=`echo)N -1616($RECDIR/vi.*`)X -896 1662(if)N -1040([)X -1136("$vibackup")X -1712(!=)X -1856("$RECDIR/vi.*")X -2576(];)X -2720(then)X -1184 1752(for)N -1376(i)X -1472(in)X -1616($vibackup;)X -2144(do)X -1472 1842(if)N -1616(test)X -1856(-x)X -2000($i)X -2144(-o)X -2288(!)X -2384(-s)X -2528($i;)X -2720(then)X -1760 1932(rm)N -1904($i)X -1472 2022(fi)N -1184 2112(done)N -896 2202(fi)N -896 2382(#)N -992(It)X -1136(is)X -1280(possible)X -1712(to)X -1856(get)X -2048(incomplete)X -2576(recovery)X -3008(files,)X -3344(if)X -3488(the)X -3680(editor)X -896 2472(#)N -992(crashes)X -1376(at)X -1520(the)X -1712(right)X -2000(time.)X -2336(Delete)X -2672(any)X -2864(recovery)X -3296(files)X -3584(without)X -896 2562(#)N -992(corresponding)X -1664(backup)X -2000(files,)X -2336(otherwise)X -2816(send)X -3056(mail)X -3296(to)X -3440(the)X -3632(user.)X -896 2652(virecovery=`echo)N -1712($RECDIR/recover.*`)X -896 2742(if)N -1040([)X -1136("$virecovery")X -1808(!=)X -1952("$RECDIR/recover.*")X -2912(];)X -3056(then)X -1184 2832(for)N -1376(i)X -1472(in)X -1616($virecovery;)X -2240(do)X -1472 2922(recfile=`awk)N -2096('/\303X-vi-recover-path:/{print)X -3488($2}')X -3728(<)X -3824($i`)X -1472 3012(if)N -1616(test)X -1856(!)X -1952(-n)X -2096($recfile)X -2528(-a)X -2672(-s)X -2816($recfile;)X -3296(then)X -1760 3102($SENDMAIL)N -2240(-t)X -2384(<)X -2480($i)X -1472 3192(else)N -1760 3282(rm)N -1904($i)X -1472 3372(fi)N -1184 3462(done)N -896 3552(fi)N -1 f -776 3798(If)N -859(you)X -1008(are)X -1136(not)X -1267(using)X -1469(the)X -1596(default)X -1848(value)X -2051(for)X -2174(the)X -3 f -2301(recdir)X -1 f -2540(option,)X -2793(be)X -2898(sure)X -3062(to)X -3154(substitute)X -3490(the)X -3618(value)X -3822(you're)X -576 3888(using)N -769(for)X -883(the)X -7 f -1001(RECDIR)X -1 f -1309(value)X -1503(in)X -1585(the)X -1703(recovery)X -2005(script.)X -776 4011(If)N -882(the)X -1032(path)X -1222(of)X -1341(your)X -1540(system's)X -3 f -1872(sendmail)X -1 f -2230(program)X -2555(\(or)X -2702(whatever)X -3050(mailer)X -3308(you're)X -3571(using\))X -3824(is)X -3930(not)X -7 f -576 4101(/usr/lib/sendmail)N -1 f -(,)S -1451(be)X -1566(sure)X -1739(to)X -1840(substitute)X -2184(the)X -2320(correct)X -2582(pathname)X -2932(for)X -3064(the)X -7 f -3200(SENDMAIL)X -1 f -3622(value)X -3834(in)X -3934(the)X -576 4191(recovery)N -878(script.)X -1116(Consult)X -1384(the)X -1502(manual)X -1758(page)X -1930(for)X -2044(details)X -2273(on)X -2373(recovering)X -2737(preserved)X -3070(or)X -3157(aborted)X -3418(editing)X -3660(sessions.)X -3 f -576 4377(4.)N -676(Sizing)X -904(the)X -1031(Screen)X -1 f -776 4500(The)N -926(size)X -1076(of)X -1168(the)X -1291(screen)X -1522(can)X -1659(be)X -1760(set)X -1874(in)X -1961(a)X -2022(number)X -2292(of)X -2384(ways.)X -3 f -2614(Ex)X -1 f -2707(/)X -3 f -2729(vi)X -1 f -2817(takes)X -3008(the)X -3132(following)X -3469(steps)X -3655(until)X -3827(values)X -576 4590(are)N -695(obtained)X -991(for)X -1105(both)X -1267(the)X -1385(number)X -1650(of)X -1737(rows)X -1913(and)X -2049(number)X -2314(of)X -2401(columns)X -2692(in)X -2774(the)X -2892(screen.)X -616 4713(\(1\))N -830(If)X -904(the)X -1022(environmental)X -1505(variable)X -7 f -1784(LINES)X -1 f -2044(exists,)X -2266(it)X -2330(is)X -2403(used)X -2570(to)X -2652(specify)X -2904(the)X -3022(number)X -3287(of)X -3374(rows)X -3550(in)X -3632(the)X -3750(screen.)X -616 4836(\(2\))N -830(If)X -909(the)X -1032(environmental)X -1520(variable)X -7 f -1804(COLUMNS)X -1 f -2165(exists,)X -2393(it)X -2463(is)X -2542(used)X -2715(to)X -2803(specify)X -3061(the)X -3185(number)X -3456(of)X -3549(columns)X -3846(in)X -3934(the)X -830 4926(screen.)N -616 5049(\(3\))N -830(The)X -975(TIOCGWINSZ)X -2 f -1494(ioctl)X -1 f -1636(\(2\))X -1750(is)X -1823(attempted)X -2159(on)X -2259(the)X -2377(standard)X -2669(error)X -2846(\256le)X -2968(descriptor.)X -616 5172(\(4\))N -830(The)X -978(termcap)X -1260(entry)X -1448(\(or)X -1565(terminfo)X -1864(entry)X -2053(on)X -2157(System)X -2416(V)X -2498(machines\))X -2852(is)X -2929(checked)X -3217(for)X -3335(the)X -3457(``li'')X -3633(entry)X -3822(\(rows\))X -830 5262(and)N -966(the)X -1084(``co'')X -1288(entry)X -1473(\(columns\).)X -616 5385(\(5\))N -830(The)X -975(number)X -1240(of)X -1327(rows)X -1503(is)X -1576(set)X -1685(to)X -1767(24,)X -1887(and)X -2023(the)X -2141(number)X -2406(of)X -2493(columns)X -2784(is)X -2857(set)X -2966(to)X -3048(80.)X -776 5508(If)N -851(a)X -908(window)X -1187(change)X -1436(size)X -1582(signal)X -1794(\(SIGWINCH\))X -2270(is)X -2344(received,)X -2658(the)X -2777(new)X -2932(window)X -3211(size)X -3357(is)X -3431(retrieved)X -3739(using)X -3934(the)X -576 5598(TIOCGWINSZ)N -2 f -1095(ioctl)X -1 f -1237(\(2\))X -1351(call,)X -1507(and)X -1643(all)X -1743(other)X -1928(information)X -2326(is)X -2399(ignored.)X - -6 p -%%Page: 6 5 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-6)N -3391(Nvi/Nex)X -3687 0.3906(Reference)AX -576 762(5.)N -676(Character)X -1049(Display)X -1 f -776 885(In)N -865(both)X -3 f -1030(ex)X -1 f -1129(and)X -3 f -1268(vi)X -1 f -1353(printable)X -1661(characters)X -2011(as)X -2101(de\256ned)X -2360(by)X -2 f -2463(isprint)X -1 f -2671(\(3\))X -2788(are)X -2910(displayed)X -3240(using)X -3436(the)X -3557(local)X -3736(character)X -576 975(set.)N -776 1098(Non-printable)N -1255(characters,)X -1631(for)X -1754(which)X -2 f -1980(iscntrl)X -1 f -2184(\(3\))X -2308(returns)X -2561(true,)X -2736(and)X -2882(which)X -3108(are)X -3237(less)X -3387(than)X -3555(octal)X -3741(\\076,)X -3933(are)X -576 1188(displayed)N -915(as)X -1014(the)X -1144(string)X -1357(``)X -7 f -1411(\303)X -1 f -('',)S -2092(where)X -7 f -2320()X -1 f -2879(is)X -2963(the)X -3092(character)X -3419(that)X -3570(is)X -3654(the)X -3783(original)X -576 1278 0.3250(character's)AN -961(value)X -1166(offset)X -1380(from)X -1568(the)X -1698(``)X -7 f -1752(@)X -1 f -('')S -1886(character.)X -2254(For)X -2397(example,)X -2721(the)X -2851(octal)X -3039(character)X -3367(\\001)X -3541(is)X -3626(displayed)X -3965(as)X -576 1368(``)N -7 f -630(\303A)X -1 f -(''.)S -845(If)X -2 f -924(iscntrl)X -1 f -1128(\(3\))X -1247(returns)X -1495(true)X -1645(for)X -1764(the)X -1887(octal)X -2068(character)X -2389(\\177,)X -2576(it)X -2645(is)X -2723(displayed)X -3054(as)X -3145(the)X -3267(string)X -3473(``)X -7 f -3527(\303?)X -1 f -(''.)S -3741(All)X -3867(other)X -576 1458(characters)N -947(are)X -1090(displayed)X -1441(as)X -1552(either)X -1779(hexadecimal)X -2229(values,)X -2498(in)X -2604(the)X -2746(form)X -2946(``)X -7 f -3000(0x)X -3888(...)X -576 1548(0x)N -1 f -('',)S -1469(or)X -1587(as)X -1705(octal)X -1911(values,)X -2186(in)X -2298(the)X -2446(form)X -2652(``)X -7 f -2706(\\)X -3888(...)X -576 1638(\\)N -1 f -(''.)S -1506(The)X -1651(display)X -1902(of)X -1989(unknown)X -2307(characters)X -2654(is)X -2727(based)X -2930(on)X -3030(the)X -3148(value)X -3342(of)X -3429(the)X -3 f -3547(octal)X -1 f -3732(option.)X -776 1761(In)N -3 f -864(vi)X -1 f -947(command)X -1285(mode,)X -1505(the)X -1625(cursor)X -1848(is)X -1923(always)X -2168(positioned)X -2523(on)X -2625(the)X -2745(last)X -2878(column)X -3140(of)X -3229(characters)X -3578(which)X -3796(take)X -3952(up)X -576 1851(more)N -765(than)X -927(one)X -1067(column)X -1331(on)X -1435(the)X -1557(screen.)X -1827(In)X -3 f -1918(vi)X -1 f -2003(text)X -2146(input)X -2333(mode,)X -2554(the)X -2675(cursor)X -2899(is)X -2975(positioned)X -3331(on)X -3434(the)X -3555(\256rst)X -3702(column)X -3965(of)X -576 1941(characters)N -923(which)X -1139(take)X -1293(up)X -1393(more)X -1578(than)X -1736(one)X -1872(column)X -2132(on)X -2232(the)X -2350(screen.)X -3 f -576 2127(6.)N -676(Multiple)X -989(Screens)X -1 f -3 f -776 2250(Nvi)N -1 f -916(supports)X -1207(multiple)X -1493(screens)X -1750(by)X -1851(dividing)X -2138(the)X -2257(window)X -2536(into)X -2681(regions.)X -2978(It)X -3048(also)X -3198(supports)X -3490(stacks)X -3707(of)X -3795(screens)X -576 2340(by)N -676(permitting)X -1029(the)X -1147(user)X -1301(to)X -1383(change)X -1631(the)X -1749(set)X -1858(of)X -1945(screens)X -2202(that)X -2342(are)X -2461(currently)X -2771(displayed.)X -776 2463(The)N -924(command)X -3 f -1263(split)X -1 f -1432(divides)X -1686(the)X -1807(current)X -2058(screen)X -2287(into)X -2434(two)X -2577(regions)X -2836(of)X -2926(approximately)X -3412(equal)X -3609(size.)X -3797(If)X -3875(a)X -3935(list)X -576 2553(of)N -668(\256les)X -826(are)X -950(speci\256ed)X -1260(as)X -1352(arguments)X -1711(to)X -1798(the)X -3 f -1921(split)X -1 f -2092(command,)X -2452(the)X -2574(list)X -2695(of)X -2786(\256les)X -2943(to)X -3029(be)X -3129(edited)X -3349(is)X -3426(initialized)X -3770(as)X -3861(if)X -3934(the)X -3 f -576 2643(next)N -1 f -747(command)X -1087(had)X -1227(been)X -1403(used.)X -1614(If)X -1692(no)X -1796(\256les)X -1953(are)X -2076(speci\256ed,)X -2405(the)X -2527(new)X -2685(screen)X -2915(will)X -3063(begin)X -3265(by)X -3370(editing)X -3617(the)X -3740(same)X -3930(\256le)X -576 2733(as)N -663(the)X -781(previous)X -1077(screen.)X -776 2856(When)N -992(more)X -1181(than)X -1343(one)X -1483(screen)X -1713(is)X -1790(editing)X -2036(a)X -2097(\256le,)X -2244(changes)X -2528(in)X -2615(any)X -2756(screen)X -2987(are)X -3111(re\257ected)X -3413(in)X -3500(all)X -3605(other)X -3795(screens)X -576 2946(editing)N -820(the)X -940(same)X -1127(\256le.)X -1291(Exiting)X -1548(any)X -1686(screen)X -1914(without)X -2180(saving)X -2410(any)X -2547(changes)X -2827(\(or)X -2942(explicitly)X -3265(discarding)X -3620(them\))X -3828(is)X -3902(per-)X -576 3036(mitted)N -800(until)X -966(the)X -1084(last)X -1215(screen)X -1441(editing)X -1683(the)X -1801(\256le)X -1923(is)X -1996(exited.)X -776 3159(The)N -3 f -923(resize)X -1 f -1142(command)X -1480(permits)X -1742(resizing)X -2018(of)X -2107(individual)X -2453(screens.)X -2752(Screens)X -3024(may)X -3184(be)X -3282(grown,)X -3529(shrunk)X -3769(or)X -3858(set)X -3970(to)X -576 3249(an)N -672(absolute)X -959(number)X -1224(of)X -1311(rows.)X -776 3372(The)N -3 f -921(\303W)X -1 f -1048(command)X -1384(is)X -1457(used)X -1624(to)X -1706(switch)X -1935(between)X -2223(screens.)X -2520(Each)X -3 f -2701(\303W)X -1 f -2829(moves)X -3059(to)X -3142(the)X -3261(next)X -3420(lower)X -3624(screen)X -3851(in)X -3934(the)X -576 3462(window,)N -874(or)X -961(to)X -1043(the)X -1161(\256rst)X -1305(screen)X -1531(in)X -1613(the)X -1731(window)X -2009(if)X -2078(there)X -2259(are)X -2378(no)X -2478(lower)X -2681(screens.)X -776 3585(The)N -3 f -925(bg)X -1 f -1033(command)X -1374(``backgrounds'')X -1917(the)X -2040(current)X -2293(screen.)X -2564(The)X -2714(screen)X -2945(disappears)X -3309(from)X -3490(the)X -3613(window,)X -3916(and)X -576 3675(the)N -702(rows)X -886(it)X -958(occupied)X -1276(are)X -1403(taken)X -1605(over)X -1776(by)X -1884(a)X -1948(neighboring)X -2363(screen.)X -2637(It)X -2714(is)X -2795(an)X -2899(error)X -3083(to)X -3172(attempt)X -3439(to)X -3528(background)X -3934(the)X -576 3765(only)N -738(screen)X -964(in)X -1046(the)X -1164(window.)X -776 3888(The)N -3 f -935(display)X -1212(screens)X -1 f -1496(command)X -1846(displays)X -2142(the)X -2274(names)X -2513(of)X -2614(the)X -2747(\256les)X -2915(associated)X -3280(with)X -3457(the)X -3590(current)X -3853(back-)X -576 3978(grounded)N -899(screens)X -1156(in)X -1238(the)X -1356(window.)X -776 4101(The)N -3 f -932(fg)X -1031([\256le])X -1 f -1219(command)X -1567(``foregrounds'')X -2095(the)X -2225(\256rst)X -2381(screen)X -2619(in)X -2713(the)X -2843(list)X -2972(of)X -3071(backgrounded)X -3558(screens)X -3827(that)X -3979(is)X -576 4191(associated)N -934(with)X -1103(its)X -1205(argument.)X -1575(If)X -1656(no)X -1763(\256le)X -1892(argument)X -2222(is)X -2302(speci\256ed,)X -2634(the)X -2759(\256rst)X -2910(screen)X -3143(on)X -3250(the)X -3375(list)X -3499(is)X -3579(foregrounded.)X -576 4281(Foregrounding)N -1072(consists)X -1345(of)X -1432(backgrounding)X -1933(the)X -2051(current)X -2299(screen,)X -2545(and)X -2681(replacing)X -3000(its)X -3095(space)X -3294(in)X -3376(the)X -3494(window)X -3772(with)X -3934(the)X -576 4371(foregrounded)N -1029(screen.)X -776 4494(If)N -852(the)X -972(last)X -1105(screen)X -1333(in)X -1417(the)X -1537(window)X -1817(is)X -1892(exited,)X -2131(and)X -2270(there)X -2454(are)X -2576(backgrounded)X -3054(screens,)X -3334(the)X -3455(\256rst)X -3602(screen)X -3831(on)X -3934(the)X -576 4584(list)N -693(of)X -780(backgrounded)X -1255(screens)X -1512(takes)X -1697(over)X -1860(the)X -1978(window.)X -3 f -576 4770(7.)N -676(Regular)X -972(Expressions)X -1400(and)X -1548(Replacement)X -2014(Strings)X -1 f -776 4893(Regular)N -1050(expressions)X -1444(are)X -1563(used)X -1730(in)X -1812(line)X -1952(addresses,)X -2301(as)X -2389(the)X -2508(\256rst)X -2653(part)X -2799(of)X -2887(the)X -3 f -3006(ex)X -3103(substitute)X -1 f -3436(,)X -3 f -3477(global)X -1 f -3685(,)X -3726(and)X -3 f -3863(vglo-)X -576 4983(bal)N -1 f -702(commands,)X -1089(and)X -1225(in)X -1307(search)X -1533(patterns.)X -776 5106(The)N -927(regular)X -1181(expressions)X -1581(supported)X -1923(by)X -3 f -2030(ex)X -1 f -2106(/)X -3 f -2128(vi)X -1 f -2217(are,)X -2363(by)X -2470(default,)X -2740(the)X -2865(Basic)X -3070(Regular)X -3351(Expressions)X -3765(\(BRE's\))X -576 5196(described)N -909(in)X -996(the)X -1119(IEEE)X -1318(POSIX)X -1574(Standard)X -1884(1003.2.)X -2169(The)X -3 f -2319(extended)X -1 f -2651(option)X -2880(causes)X -3115(all)X -3220(regular)X -3472(expressions)X -3870(to)X -3956(be)X -576 5286(interpreted)N -976(as)X -1095(the)X -1245(Extended)X -1600(Regular)X -1906(Expressions)X -2345(\(ERE's\))X -2661(described)X -3022(by)X -3155(the)X -3306(same)X -3524(standard.)X -3889(\(See)X -2 f -576 5376(re_format)N -1 f -(\(7\))S -1025(for)X -1154(more)X -1354(information.\))X -1834(Generally)X -2186(speaking,)X -2526(BRE's)X -2774(are)X -2908(the)X -3040(Regular)X -3328(Expressions)X -3749(found)X -3970(in)X -2 f -576 5466(ed)N -1 f -652(\(1\))X -766(and)X -2 f -902(grep)X -1 f -1049(\(1\),)X -1183(and)X -1319(ERE's)X -1548(are)X -1667(the)X -1785(Regular)X -2059(Expressions)X -2466(found)X -2673(in)X -2 f -2755(egrep)X -1 f -2938(\(1\).)X -776 5589(The)N -922(following)X -1254(is)X -1328(not)X -1451(intended)X -1748(to)X -1831(provide)X -2097(a)X -2154(description)X -2532(of)X -2621(Regular)X -2897(Expressions.)X -3346(The)X -3493(information)X -3893(here)X -576 5679(only)N -742(describes)X -1065(strings)X -1302(and)X -1442(characters)X -1793(which)X -2013(have)X -2189(special)X -2436(meanings)X -2766(in)X -2851(the)X -3 f -2972(ex)X -1 f -3048(/)X -3 f -3070(vi)X -1 f -3155(version)X -3414(of)X -3504(RE's,)X -3707(or)X -3797(options)X -576 5769(which)N -792(change)X -1040(the)X -1158(meanings)X -1485(of)X -1572(characters)X -1919(that)X -2059(normally)X -2368(have)X -2540(special)X -2783(meanings)X -3110(in)X -3192(RE's.)X - -7 p -%%Page: 7 6 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -3698(USD:13-7)X -1 f -616 762(\(1\))N -830(An)X -948(empty)X -1168(RE)X -1290(\(e.g.)X -1473(``)X -7 f -1527(//)X -1 f -('')S -1697(or)X -1784(``)X -7 f -1838(??)X -1 f -('')S -2028(is)X -2101(equivalent)X -2455(to)X -2537(the)X -2655(last)X -2786(RE)X -2908(used.)X -616 885(\(2\))N -830(The)X -975(construct)X -1289(``)X -7 f -1343(\\<)X -1 f -('')S -1513(matches)X -1796(the)X -1914(beginning)X -2254(of)X -2341(a)X -2397(word.)X -616 1008(\(3\))N -830(The)X -975(construct)X -1289(``)X -7 f -1343(\\>)X -1 f -('')S -1513(matches)X -1796(the)X -1914(end)X -2050(of)X -2137(a)X -2193(word.)X -616 1131(\(4\))N -830(The)X -975(character)X -1291(``)X -7 f -1345(\304)X -1 f -('')S -1467(matches)X -1750(the)X -1868(replacement)X -2281(part)X -2426(of)X -2513(the)X -2631(last)X -3 f -2762(substitute)X -1 f -3115(command.)X -776 1254(When)N -992(the)X -3 f -1114(magic)X -1 f -1343(option)X -1571(is)X -2 f -1648(not)X -1 f -1774(set,)X -1907(the)X -2029(only)X -2195(characters)X -2546(with)X -2712(special)X -2959(meanings)X -3290(are)X -3413(a)X -3473(``)X -7 f -3527(\303)X -1 f -('')S -3653(character)X -3974(at)X -576 1344(the)N -698(beginning)X -1042(of)X -1133(an)X -1233(RE,)X -1379(a)X -1439(``)X -7 f -1493($)X -1 f -('')S -1619(character)X -1939(at)X -2021(the)X -2143(end)X -2282(of)X -2372(an)X -2471(RE,)X -2616(and)X -2755(the)X -2876(escaping)X -3180(character)X -3499(``)X -7 f -3553(\\)X -1 f -(''.)S -3718(The)X -3866(char-)X -576 1434(acters)N -788(``)X -7 f -842(.)X -1 f -('',)S -988(``)X -7 f -1042(*)X -1 f -('',)S -1188(``)X -7 f -1242([)X -1 f -('')S -1368(and)X -1508(``)X -7 f -1562(\304)X -1 f -('')S -1688(are)X -1811(treated)X -2054(as)X -2145(ordinary)X -2441(characters)X -2793(unless)X -3018(preceded)X -3334(by)X -3439(a)X -3500(``)X -7 f -3554(\\)X -1 f -('';)S -3703(when)X -3902(pre-)X -576 1524(ceded)N -784(by)X -884(a)X -940(``)X -7 f -994(\\)X -1 f -('')S -1116(they)X -1274(regain)X -1495(their)X -1662(special)X -1905(meaning.)X -776 1647(Replacement)N -1215(strings)X -1448(are)X -1567(the)X -1685(second)X -1928(part)X -2073(of)X -2160(a)X -3 f -2216(substitute)X -1 f -2569(command.)X -776 1770(The)N -924(character)X -1243(``)X -7 f -1297(&)X -1 f -('')S -1422(\(or)X -1539(``)X -7 f -1593(\\&)X -1 f -('')S -1766(if)X -1839(the)X -3 f -1961(magic)X -1 f -2190(option)X -2418(is)X -2 f -2495(not)X -1 f -2621(set\))X -2761(in)X -2847(the)X -2969(replacement)X -3386(string)X -3592(stands)X -3816(for)X -3934(the)X -576 1860(text)N -717(matched)X -1010(by)X -1111(the)X -1230(RE)X -1353(that)X -1494(is)X -1568(being)X -1767(replaced.)X -2101(The)X -2247(character)X -2564(``)X -7 f -2618(\304)X -1 f -('')S -2741(\(or)X -2856(``)X -7 f -2910(\\\304)X -1 f -('')S -3081(if)X -3151(the)X -3 f -3270(magic)X -1 f -3496(option)X -3721(is)X -2 f -3794(not)X -1 f -3916(set\))X -576 1950(stands)N -806(for)X -931(the)X -1060(replacement)X -1484(part)X -1640(of)X -1738(the)X -1867(previous)X -3 f -2174(substitute)X -1 f -2538(command.)X -2925(It)X -3005(is)X -3089(only)X -3262(valid)X -3453(after)X -3632(a)X -3 f -3699(substitute)X -1 f -576 2040(command)N -912(has)X -1039(been)X -1211(performed.)X -776 2163(The)N -922(string)X -1125(``)X -7 f -1179(\\#)X -1 f -('',)S -1370(where)X -1588(``)X -7 f -1642(#)X -1 f -('')S -1765(is)X -1839(an)X -1936(integer)X -2180(value)X -2376(from)X -2554(1)X -2616(to)X -2700(9,)X -2782(stands)X -3004(for)X -3120(the)X -3240(text)X -3382(matched)X -3676(by)X -3778(the)X -3898(por-)X -576 2253(tion)N -728(of)X -823(the)X -949(RE)X -1079(enclosed)X -1388(in)X -1478(the)X -1604(``)X -7 f -1658(#)X -1 f -('''th)S -1877(set)X -1994(of)X -2089(escaped)X -2372(parentheses,)X -2794(e.g.)X -2957(``)X -7 f -3011(\\\()X -1 f -('')S -3188(and)X -3331(``)X -7 f -3385(\\\))X -1 f -(''.)S -3602(For)X -3740(example,)X -576 2343(``)N -7 f -630(s/abc\\\(.*\\\)def/\\1/)X -1 f -('')S -1568(deletes)X -1811(the)X -1929(strings)X -2162(``)X -7 f -2216(abc)X -1 f -('')S -2434(and)X -2570(``)X -7 f -2624(def)X -1 f -('')S -2842(from)X -3018(the)X -3136(matched)X -3428(pattern.)X -776 2466(The)N -934(strings)X -1180(``)X -7 f -1234(\\l)X -1 f -('',)S -1437(``)X -7 f -1491(\\u)X -1 f -('',)S -1694(``)X -7 f -1748(\\L)X -1 f -('')S -1931(and)X -2080(``)X -7 f -2134(\\U)X -1 f -('')S -2317(can)X -2462(be)X -2571(used)X -2752(to)X -2848(modify)X -3113(the)X -3245(case)X -3418(of)X -3519(elements)X -3838(in)X -3934(the)X -576 2556(replacement)N -999(string.)X -1251(The)X -1406(string)X -1618(``)X -7 f -1672(\\l)X -1 f -('')S -1852(causes)X -2092(the)X -2220(next)X -2388(character)X -2714(to)X -2806(be)X -2912(converted)X -3259(to)X -3350(lowercase;)X -3723(the)X -3850(string)X -576 2646(``)N -7 f -630(\\u)X -1 f -('')S -815(behaves)X -1109(similarly,)X -1448(but)X -1585(converts)X -1892(to)X -1989(uppercase)X -2346(\(e.g.)X -7 f -2544(s/abc/\\U&/)X -1 f -3059(replaces)X -3358(the)X -3492(string)X -7 f -3710(abc)X -1 f -3890(with)X -7 f -576 2736(ABC)N -1 f -(\).)S -810(The)X -958(strings)X -1194(``)X -7 f -1248(\\L)X -1 f -('')S -1421(causes)X -1654(characters)X -2004(up)X -2107(to)X -2192(the)X -2313(end)X -2452(of)X -2541(the)X -2661(string)X -2865(or)X -2954(the)X -3074(next)X -3234 0.3611(occurrence)AX -3610(of)X -3699(the)X -3819(strings)X -576 2826(``)N -7 f -630(\\e)X -1 f -('')S -806(or)X -899(``)X -7 f -953(\\E)X -1 f -('')S -1129(to)X -1217(be)X -1319(converted)X -1663(to)X -1752(lowercase;)X -2123(the)X -2248(string)X -2457(``)X -7 f -2511(\\U)X -1 f -('')S -2688(behaves)X -2974(similarly,)X -3305(but)X -3434(converts)X -3733(to)X -3822(upper-)X -576 2916(case.)N -776 3039(If)N -850(the)X -968(entire)X -1171(replacement)X -1584(pattern)X -1827(is)X -1900(``)X -7 f -1954(%)X -1 f -('',)S -2096(then)X -2254(the)X -2372(last)X -2503(replacement)X -2916(pattern)X -3159(is)X -3232(used)X -3399(again.)X -776 3162(In)N -3 f -867(vi)X -1 f -929(,)X -973(inserting)X -1278(a)X -7 f -1339()X -1 f -1892(into)X -2041(the)X -2164(replacement)X -2582(string)X -2789(will)X -2938(cause)X -3142(the)X -3265(matched)X -3562(line)X -3707(to)X -3794(be)X -3895(split)X -576 3252(into)N -720(two)X -860(lines)X -1031(at)X -1109(that)X -1249(point.)X -1473(\(The)X -7 f -1645()X -1 f -2193(will)X -2337(be)X -2433(discarded.\))X -3 f -576 3438(8.)N -676(General)X -972(Editor)X -1214(Description)X -1 f -776 3561(When)N -3 f -989(ex)X -1 f -1086(or)X -3 f -1174(vi)X -1 f -1257(are)X -1377(executed,)X -1704(the)X -1823(text)X -1964(of)X -2052(a)X -2109(\256le)X -2232(is)X -2306(read)X -2466(\(or)X -2581(a)X -2638(temporary)X -2989(\256le)X -3112(is)X -3186(created\),)X -3487(and)X -3624(then)X -3783(all)X -3885(edit-)X -576 3651(ing)N -700(changes)X -981(happen)X -1235(within)X -1461(the)X -1581(context)X -1838(of)X -1926(the)X -2045(copy)X -2222(of)X -2310(the)X -2429(\256le.)X -2 f -2592(No)X -2706(changes)X -2990(affect)X -3189(the)X -3308(actual)X -3529(\256le)X -3648(until)X -3815(the)X -3934(\256le)X -576 3741(is)N -662(written)X -921(out)X -1 f -1023(,)X -1076(either)X -1293(using)X -1500(a)X -1570(write)X -1769(command)X -2119(or)X -2220(another)X -2495(command)X -2845(which)X -3075(is)X -3162(affected)X -3456(by)X -3570(the)X -3 f -3702(autowrite)X -1 f -576 3831(option.)N -776 3954(All)N -898(\256les)X -1052(are)X -1172(locked)X -1407(\(using)X -1628(the)X -2 f -1747(\257ock)X -1 f -1899(\(2\))X -2014(or)X -2 f -2102(fcntl)X -1 f -2244(\(2\))X -2359(interfaces\))X -2720(during)X -2950(the)X -3069(edit)X -3210(session,)X -3482(to)X -3565(avoid)X -3764(inadver-)X -576 4044(tently)N -781(making)X -1044(modi\256cations)X -1502(to)X -1587(multiple)X -1876(copies)X -2104(of)X -2194(the)X -2315(\256le.)X -2480(If)X -2557(a)X -2616(lock)X -2777(cannot)X -3014(be)X -3113(obtained)X -3412(for)X -3529(a)X -3587(\256le)X -3711(because)X -3988(it)X -576 4134(is)N -657(locked)X -899(by)X -1007(another)X -1276(process,)X -1565(the)X -1691(edit)X -1840(session)X -2100(is)X -2182(read-only)X -2519(\(as)X -2642(if)X -2720(the)X -3 f -2847(readonly)X -1 f -3178(option)X -3411(or)X -3507(the)X -3 f -9 f -3634(-)X -3636(-)X -3 f -3680(R)X -1 f -3767(\257ag)X -3916(had)X -576 4224(been)N -754(speci\256ed\).)X -1132(If)X -1212(a)X -1274(lock)X -1438(cannot)X -1678(be)X -1780(obtained)X -2082(for)X -2202(other)X -2393(reasons,)X -2680(the)X -2804(edit)X -2950(session)X -3207(will)X -3357(continue,)X -3679(but)X -3807(the)X -3930(\256le)X -576 4314(status)N -778(information)X -1176(\(see)X -1326(the)X -3 f -1444()X -1 f -1890(command\))X -2253(will)X -2397(re\257ect)X -2618(this)X -2753(fact.)X -776 4437(Both)N -3 f -955(ex)X -1 f -1055(and)X -3 f -1195(vi)X -1 f -1281(are)X -1405(modeful)X -1697(editors,)X -1960(i.e.)X -2083(they)X -2246(have)X -2423(two)X -2568(modes,)X -2822(``command'')X -3271(mode)X -3474(and)X -3615(``text)X -3814(input'')X -576 4527(mode.)N -817(The)X -965(former)X -1207(is)X -1283(intended)X -1582(to)X -1667(permit)X -1898(you)X -2040(to)X -2124(enter)X -2307(commands)X -2676(which)X -2894(modi\256es)X -3191(already)X -3450(existing)X -3725(text.)X -3907(The)X -576 4617(latter)N -762(is)X -836(intended)X -1133(to)X -1216(permit)X -1446(you)X -1588(to)X -1672(enter)X -1855(new)X -2011(text.)X -2193(When)X -3 f -2407(ex)X -1 f -2505(\256rst)X -2651(starts)X -2842(running,)X -3133(it)X -3199(is)X -3274(in)X -3358(command)X -3696(mode,)X -3916(and)X -576 4707(usually)N -838(displays)X -1131(a)X -1198(prompt)X -1460(\(see)X -1621(the)X -3 f -1750(prompt)X -1 f -2039(option)X -2274(for)X -2398(more)X -2593(information\).)X -3068(The)X -3223(prompt)X -3484(is)X -3567(a)X -3633(single)X -3854(colon)X -576 4797(\(``)N -7 f -657(:)X -1 f -(''\))S -817(character.)X -1184(There)X -1403(are)X -1533(three)X -1725(commands)X -2103(that)X -2255(switch)X -3 f -2496(ex)X -1 f -2604(into)X -2760(text)X -2912(input)X -3108(mode:)X -3 f -3340(append)X -1 f -3592(,)X -3 f -3644(change)X -1 f -3916(and)X -3 f -576 4887(insert)N -1 f -772(.)X -840(Once)X -1038(in)X -1128(input)X -1320(mode,)X -1546(entering)X -1837(a)X -1901(line)X -2049(containing)X -2415(only)X -2585(a)X -2649(single)X -2868(period)X -3101(\(``)X -7 f -3182(.)X -1 f -(''\))S -3359(terminates)X -3721(text)X -3868(input)X -576 4977(mode)N -774(and)X -910(returns)X -1153(to)X -1235(command)X -1571(mode,)X -1789(where)X -2006(the)X -2124(prompt)X -2375(is)X -2448(redisplayed.)X -776 5100(When)N -3 f -989(vi)X -1 f -1072(\256rst)X -1217(starts)X -1407(running,)X -1697(it)X -1763(is)X -1838(in)X -1922(command)X -2260(mode)X -2460(as)X -2549(well.)X -2749(There)X -2959(are)X -3080(eleven)X -3312(commands)X -3681(that)X -3823(switch)X -3 f -576 5190(vi)N -1 f -659(into)X -804(text)X -945(input)X -1130(mode:)X -3 f -1351(A)X -1 f -1409(,)X -3 f -1450(a)X -1 f -(,)S -3 f -1531(C)X -1 f -1589(,)X -3 f -1629(c)X -1 f -1665(,)X -3 f -1705(I)X -1 f -1736(,)X -3 f -1776(i)X -1 f -1798(,)X -3 f -1838(O)X -1 f -1900(,)X -3 f -1940(o)X -1 f -(,)S -3 f -2020(R)X -1 f -2078(,)X -3 f -2118(S)X -1 f -2182(and)X -3 f -2318(s)X -1 f -2349(.)X -2409(Once)X -2599(in)X -2681(input)X -2865(mode,)X -3083(entering)X -3366(an)X -7 f -3462()X -1 f -3866(char-)X -576 5280(acter)N -753(terminates)X -1107(text)X -1247(input)X -1431(mode)X -1629(and)X -1765(returns)X -2008(to)X -2090(command)X -2426(mode.)X -776 5403(The)N -921(following)X -1252(words)X -1468(have)X -1640(special)X -1883(meanings)X -2210(in)X -2292(both)X -2454(the)X -3 f -2572(ex)X -1 f -2668(and)X -3 f -2804(vi)X -1 f -2886(command)X -3222(descriptions:)X -3 f -576 5583()N -1 f -776 5673(The)N -927(interrupt)X -1229(character)X -1551(is)X -1630(used)X -1803(to)X -1891(interrupt)X -2193(the)X -2317(current)X -2571(operation.)X -2940(Normally)X -7 f -3274()X -1 f -(,)S -3849(what-)X -776 5763(ever)N -935(character)X -1251(is)X -1324(set)X -1433(for)X -1547(the)X -1665(current)X -1913(terminal)X -2200(is)X -2273(used.)X - -8 p -%%Page: 8 7 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-8)N -3391(Nvi/Nex)X -3687 0.3906(Reference)AX -576 762()X -1 f -776 852(The)N -923(literal)X -1132(next)X -1292(character)X -1610(is)X -1685(used)X -1854(to)X -1938(escape)X -2175(the)X -2295(subsequent)X -2673(character)X -2991(from)X -3169(any)X -3307(special)X -3552(meaning.)X -3890(This)X -776 942(character)N -1102(is)X -1185(always)X -7 f -1438()X -1 f -(.)S -2036(If)X -2120(the)X -2248(terminal)X -2545(is)X -2627(not)X -2758(set)X -2876(up)X -2985(to)X -3076(do)X -3185(XON/XOFF)X -3614(\257ow)X -3785(control,)X -776 1032(then)N -7 f -934()X -1 f -1482(is)X -1555(used)X -1722(to)X -1804(mean)X -1998(literal)X -2205(next)X -2363(as)X -2450(well.)X -3 f -576 1212(current)N -855(pathname)X -1 f -776 1302(The)N -923(pathname)X -1257(of)X -1346(the)X -1467(\256le)X -1592(currently)X -1905(being)X -2106(edited)X -2325(by)X -2428(vi.)X -2553(When)X -2768(the)X -2889(percent)X -3149(character)X -3468(\(``)X -7 f -3549(%)X -1 f -(''\))S -3701(appears)X -3970(in)X -776 1392(a)N -833(\256le)X -956(name)X -1151(entered)X -1409(as)X -1497(part)X -1643(of)X -1731(an)X -3 f -1828(ex)X -1 f -1925(command)X -2262(argument,)X -2606(it)X -2671(is)X -2745(replaced)X -3039(by)X -3140(the)X -3259(current)X -3508(pathname.)X -3880(\(The)X -776 1482(``)N -7 f -830(%)X -1 f -('')S -952(character)X -1268(can)X -1400(be)X -1496(escaped)X -1771(by)X -1871(preceding)X -2208(it)X -2272(with)X -2434(a)X -2490(backslash.\))X -3 f -576 1662(alternate)N -904(pathname)X -1 f -776 1752(The)N -921(name)X -1115(of)X -1202(the)X -1320(last)X -1451(\256le)X -1573(name)X -1767(mentioned)X -2125(in)X -2207(an)X -3 f -2304(ex)X -1 f -2401(command,)X -2758(or,)X -2866(the)X -2985(previous)X -3282(current)X -3531(pathname)X -3864(if)X -3934(the)X -776 1842(last)N -913(\256le)X -1041(mentioned)X -1404(becomes)X -1710(the)X -1833(current)X -2086(\256le.)X -2253(When)X -2470(the)X -2593(hash)X -2765(mark)X -2955(character)X -3276(\(``)X -7 f -3357(#)X -1 f -(''\))S -3511(appears)X -3782(in)X -3869(a)X -3930(\256le)X -776 1932(name)N -979(entered)X -1245(as)X -1341(part)X -1495(of)X -1591(an)X -3 f -1696(ex)X -1 f -1801(command)X -2146(argument,)X -2498(it)X -2571(is)X -2653(replaced)X -2955(by)X -3064(the)X -3191(alternate)X -3498(pathname.)X -3880(\(The)X -776 2022(``)N -7 f -830(#)X -1 f -('')S -952(character)X -1268(can)X -1400(be)X -1496(escaped)X -1771(by)X -1871(preceding)X -2208(it)X -2272(with)X -2434(a)X -2490(backslash.\))X -3 f -576 2202(buffer)N -1 f -776 2292(One)N -931(of)X -1019(a)X -1076(number)X -1342(of)X -1430(named)X -1665(areas)X -1852(for)X -1968(saving)X -2199(copies)X -2426(of)X -2515(text.)X -2697(Commands)X -3083(that)X -3225(change)X -3475(or)X -3564(delete)X -3778(text)X -3920(can)X -776 2382(save)N -941(the)X -1061(changed)X -1351(or)X -1440(deleted)X -1693(text)X -1834(into)X -1979(a)X -2036(speci\256c)X -2302(buffer,)X -2540(for)X -2655(later)X -2819(use,)X -2967(if)X -3037(the)X -3156(command)X -3493(allows)X -3723(it)X -3788(\(i.e.)X -3934(the)X -3 f -776 2472(ex)N -872(change)X -1 f -1132(command)X -1468(cannot)X -1702(save)X -1866(the)X -1985(changed)X -2274(text)X -2415(in)X -2498(a)X -2555(named)X -2790(buffer\).)X -3075(Buffers)X -3337(are)X -3457(named)X -3692(with)X -3855(a)X -3912(sin-)X -776 2562(gle)N -895(character,)X -1232(preceded)X -1544(by)X -1645(a)X -1702(double)X -1941(quote,)X -2160(e.g.)X -7 f -2317(")X -1 f -(.)S -2954(Historic)X -3232(implementations)X -3785(of)X -3 f -3872(ex)X -1 f -3948(/)X -3 f -3970(vi)X -1 f -776 2652(limited)N -7 f -1022()X -1 f -1570(to)X -1652(the)X -1770(alphanumeric)X -2227(characters;)X -3 f -2596(nex)X -1 f -(/)S -3 f -2738(nvi)X -1 f -2864(permits)X -3124(the)X -3242(use)X -3369(of)X -3456(any)X -3592(character.)X -776 2832(Buffers)N -1041(named)X -1279(by)X -1383(uppercase)X -1729(characters)X -2080(are)X -2203(the)X -2325(same)X -2514(as)X -2605(buffers)X -2857(named)X -3095(by)X -3199(lowercase)X -3545(characters,)X -3916(e.g.)X -776 2922(the)N -904(buffer)X -1131(named)X -1375(by)X -1485(the)X -1613(English)X -1887(character)X -2213(``)X -7 f -2267(A)X -1 f -('')S -2399(is)X -2482(the)X -2610(same)X -2805(as)X -2902(the)X -3030(buffer)X -3257(named)X -3500(by)X -3609(the)X -3736(character)X -776 3012(``)N -7 f -830(a)X -1 f -('',)S -977(with)X -1144(the)X -1267(exception)X -1604(that,)X -1769(if)X -1843(the)X -1966(buffer)X -2188(contents)X -2480(are)X -2604(being)X -2807(changed)X -3100(\(as)X -3219(with)X -3386(a)X -3447(text)X -3593(deletion)X -3877(or)X -3 f -3970(vi)X -776 3102(change)N -1 f -1036(command\),)X -1419(the)X -1537(text)X -1677(is)X -2 f -1750(appended)X -1 f -2082(to)X -2164(the)X -2282(buffer,)X -2519(instead)X -2766(of)X -2853(replacing)X -3172(the)X -3290(current)X -3538(contents.)X -776 3282(The)N -925(buffers)X -1177(named)X -1415(by)X -1519(the)X -1641(numeric)X -1928(characters)X -2279(\(in)X -2392(English,)X -2680(``)X -7 f -2734(1)X -1 f -('')S -2860(through)X -3133(``)X -7 f -3187(9)X -1 f -(''\),)S -3360(are)X -3483(special,)X -3751(in)X -3838(that)X -3983(if)X -776 3372(at)N -864(least)X -1041(one)X -1187(line)X -1337(is)X -1420(changed)X -1718(or)X -1814(deleted)X -2075(in)X -2166(the)X -2293(\256le,)X -2444(\(or)X -2567(a)X -2632(command)X -2977(changes)X -3265(or)X -3361(deletes)X -3613(a)X -3678(region)X -3912(that)X -776 3462(crosses)N -1032(a)X -1093(line)X -1238(boundary\))X -1593(a)X -1654(copy)X -1835(of)X -1927(the)X -2050(text)X -2195(is)X -2273(placed)X -2508(into)X -2657(the)X -2780(numeric)X -3068(buffer)X -3290(``)X -7 f -3344(1)X -1 f -('',)S -3491(regardless)X -3842(of)X -3934(the)X -776 3552(user)N -933(specifying)X -1290(another)X -1553(buffer)X -1772(in)X -1856(which)X -2074(to)X -2158(save)X -2323(it.)X -2429(Before)X -2670(this)X -2807(copy)X -2985(is)X -3060(done,)X -3258(the)X -3378(previous)X -3676(contents)X -3965(of)X -776 3642(buffer)N -1000(``)X -7 f -1054(1)X -1 f -('')S -1183(are)X -1309(moved)X -1555(into)X -1707(buffer)X -1932(``)X -7 f -1986(2)X -1 f -('',)S -2136(``)X -7 f -2190(2)X -1 f -('')S -2320(into)X -2472(buffer)X -2697(``)X -7 f -2751(3)X -1 f -('',)S -2901(and)X -3045(so)X -3144(on.)X -3292(The)X -3445(contents)X -3740(of)X -3835(buffer)X -776 3732(``)N -7 f -830(9)X -1 f -('')S -961(are)X -1089(discarded.)X -1466(In)X -3 f -1562(vi)X -1 f -1624(,)X -1672(text)X -1820(may)X -1986(be)X -2090(explicitly)X -2420(stored)X -2644(into)X -2796(the)X -2922(numeric)X -3213(buffers.)X -3509(In)X -3604(this)X -3747(case,)X -3934(the)X -776 3822(buffer)N -995(rotation)X -1266(described)X -1596(above)X -1810(occurs)X -2042(before)X -2270(the)X -2390(replacement)X -2805(of)X -2894(the)X -3014(buffer's)X -3291(contents.)X -3621(\(Text)X -3818(cannot)X -776 3912(be)N -874(explicitly)X -1198(stored)X -1416(into)X -1562(the)X -1682(numeric)X -1966(buffers)X -2215(in)X -3 f -2298(ex)X -1 f -2395(because)X -2671(of)X -2759(ambiguities)X -3153(that)X -3294(this)X -3430(would)X -3651(cause)X -3851(in)X -3934(the)X -3 f -776 4002(ex)N -1 f -872(command)X -1208(syntax.\))X -776 4182(When)N -991(a)X -3 f -1051(vi)X -1 f -1137(command)X -1477(synopsis)X -1776(shows)X -2000(both)X -2166(a)X -7 f -2226([buffer])X -1 f -2634(and)X -2774(a)X -7 f -2834([count])X -1 f -(,)S -3214(they)X -3376(may)X -3538(be)X -3638(presented)X -3970(in)X -776 4272(any)N -912(order.)X -776 4452(Finally,)N -1052(all)X -1162(buffers)X -1420(are)X -1549(either)X -1762(``line'')X -2020(or)X -2117 0.3750(``character'')AX -2551(oriented.)X -2884(All)X -3 f -3016(ex)X -1 f -3122(commands)X -3499(which)X -3725(store)X -3912(text)X -776 4542(into)N -922(buffers)X -1172(are)X -1293(line)X -1435(oriented.)X -1760(Some)X -3 f -1964(vi)X -1 f -2048(commands)X -2417(which)X -2635(store)X -2813(text)X -2955(into)X -3101(buffers)X -3351(are)X -3471(line)X -3612(oriented,)X -3916(and)X -776 4632(some)N -980(are)X -1114(character)X -1445(oriented;)X -1765(the)X -1898(description)X -2289(for)X -2418(each)X -2601(applicable)X -3 f -2966(vi)X -1 f -3063(command)X -3414(notes)X -3618(whether)X -3912(text)X -776 4722(copied)N -1020(into)X -1174(buffers)X -1432(using)X -1635(the)X -1762(command)X -2107(is)X -2189(line)X -2338(or)X -2434(character)X -2759(oriented.)X -3091(In)X -3187(addition,)X -3498(the)X -3 f -3625(vi)X -1 f -3716(command)X -3 f -776 4812(display)N -1053(buffers)X -1 f -1332(displays)X -1628(the)X -1760(current)X -2023(orientation)X -2405(for)X -2534(each)X -2717(buffer.)X -2989(Generally,)X -3361(the)X -3494(only)X -3671(importance)X -776 4902(attached)N -1074(to)X -1166(this)X -1311(orientation)X -1688(is)X -1771(that)X -1921(if)X -2000(the)X -2128(buffer)X -2355(is)X -2438(subsequently)X -2886(inserted)X -3170(into)X -3324(the)X -3451(text,)X -3620(line)X -3769(oriented)X -776 4992(buffers)N -1027(create)X -1243(new)X -1400(lines)X -1574(for)X -1691(each)X -1862(of)X -1952(the)X -2073(lines)X -2247(they)X -2408(contain,)X -2687(and)X -2826(character)X -3145(oriented)X -3431(buffers)X -3682(create)X -3898(new)X -776 5082(lines)N -951(for)X -1069(any)X -1209(lines)X -2 f -1384(other)X -1 f -1577(than)X -1739(the)X -1860(\256rst)X -2007(and)X -2146(last)X -2280(lines)X -2454(they)X -2615(contain.)X -2914(The)X -3062(\256rst)X -3209(and)X -3348(last)X -3482(lines)X -3656(are)X -3778(inserted)X -776 5172(into)N -927(the)X -1052(text)X -1199(at)X -1284(the)X -1409(current)X -1664(cursor)X -1892(position,)X -2196(becoming)X -2539(part)X -2691(of)X -2785(the)X -2910(current)X -3165(line.)X -3352(If)X -3433(there)X -3621(is)X -3701(more)X -3894(than)X -776 5262(one)N -912(line)X -1052(in)X -1134(the)X -1252(buffer,)X -1489(however,)X -1806(the)X -1924(current)X -2172(line)X -2312(itself)X -2492(will)X -2636(be)X -2732(split.)X -3 f -576 5442(unnamed)N -915(buffer)X -1 f -776 5532(The)N -924(unnamed)X -1241(buffer)X -1461(is)X -1537(a)X -1596(text)X -1739(storage)X -1994(area)X -2152(which)X -2371(is)X -2447(used)X -2617(by)X -2720(commands)X -3090(that)X -3233(take)X -3390(a)X -3450(buffer)X -3671(as)X -3762(an)X -3862(argu-)X -776 5622(ment,)N -976(when)X -1170(no)X -1270(buffer)X -1487(is)X -1560(speci\256ed)X -1865(by)X -1965(the)X -2083(user.)X -2277(There)X -2485(is)X -2558(no)X -2658(way)X -2812(to)X -2894(explicitly)X -3216 0.4531(reference)AX -3537(this)X -3672(buffer.)X - -9 p -%%Page: 9 8 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Vi)X -1364(Commands\))X -3698(USD:13-9)X -576 762(9.)N -676(Vi)X -776(Description)X -1 f -3 f -776 885(Vi)N -1 f -879(takes)X -1067(up)X -1170(the)X -1291(entire)X -1497(screen)X -1727(to)X -1813(display)X -2068(the)X -2190(edited)X -2410(\256le,)X -2556(except)X -2790(for)X -2908(the)X -3030(bottom)X -3280(line)X -3424(of)X -3515(the)X -3637(screen.)X -3907(The)X -576 975(bottom)N -824(line)X -966(of)X -1055(the)X -1175(screen)X -1403(is)X -1478(used)X -1647(to)X -1731(enter)X -3 f -1914(ex)X -1 f -2012(commands,)X -2401(and)X -2539(for)X -3 f -2655(vi)X -1 f -2739(error)X -2918(and)X -3056(informational)X -3513(messages.)X -3877(If)X -3952(no)X -576 1065(other)N -777(information)X -1191(is)X -1281(being)X -1496(displayed,)X -1860(the)X -1995(default)X -2255(display)X -2523(can)X -2672(show)X -2878(the)X -3013(current)X -3278(cursor)X -3516(row)X -3678(and)X -3831(cursor)X -576 1155(column,)N -863(an)X -966(indication)X -1313(of)X -1407(whether)X -1693(the)X -1818(\256le)X -1947(has)X -2081(been)X -2260(modi\256ed,)X -2591(and)X -2734(the)X -2859(current)X -3114(mode)X -3319(of)X -3413(the)X -3538(editor.)X -3792(See)X -3934(the)X -3 f -576 1245(ruler)N -1 f -750(,)X -3 f -790(showdirty)X -1 f -1152(and)X -3 f -1288(showmode)X -1 f -1668(options)X -1923(for)X -2037(more)X -2222(information.)X -776 1368(Empty)N -1012(lines)X -1186(do)X -1289(not)X -1414(have)X -1589(any)X -1729(special)X -1976(representation)X -2455(on)X -2559(the)X -2681(screen,)X -2931(but)X -3057(lines)X -3232(on)X -3336(the)X -3458(screen)X -3688(that)X -3832(would)X -576 1458(logically)N -886(come)X -1090(after)X -1268(the)X -1396(end)X -1542(of)X -1639(the)X -1767(\256le)X -1899(are)X -2028(displayed)X -2365(as)X -2461(a)X -2526(single)X -2746(tilde)X -2917(\(``)X -7 f -2998(\304)X -1 f -(''\))S -3156(character.)X -3521(To)X -3639(differentiate)X -576 1548(between)N -871(empty)X -1098(lines)X -1276(and)X -1419(lines)X -1597(consisting)X -1948(of)X -2042(only)X -2211(whitespace)X -2596(characters,)X -2971(use)X -3106(the)X -3 f -3232(list)X -1 f -3362(option.)X -3634(Historically,)X -576 1638(implementations)N -1130(of)X -3 f -1218(vi)X -1 f -1301(have)X -1474(also)X -1624(displayed)X -1952(some)X -2141(lines)X -2312(as)X -2399(single)X -2610(asterisk)X -2875(\(``)X -7 f -2956(@)X -1 f -(''\))S -3105(characters.)X -3492(These)X -3704(were)X -3881(lines)X -576 1728(that)N -717(were)X -895(not)X -1018(correctly)X -1326(displayed,)X -1675(i.e.)X -1795(lines)X -1968(on)X -2070(the)X -2190(screen)X -2418(that)X -2560(did)X -2684(not)X -2808(correspond)X -3187(to)X -3271(lines)X -3444(in)X -3528(the)X -3648(\256le,)X -3792(or)X -3881(lines)X -576 1818(that)N -716(did)X -838(not)X -960(\256t)X -1046(on)X -1146(the)X -1264(current)X -1512(screen.)X -3 f -1778(Nvi)X -1 f -1918(never)X -2117(displays)X -2399(lines)X -2570(in)X -2652(this)X -2787(fashion.)X -3 f -776 1941(Vi)N -1 f -881(is)X -959(a)X -1020(modeful)X -1312(editor,)X -1544(i.e.)X -1667(it)X -1736(has)X -1868(two)X -2013(modes,)X -2268(``command'')X -2718(mode)X -2922(and)X -3064(``text)X -3264(input'')X -3508(mode.)X -3752(When)X -3 f -3970(vi)X -1 f -576 2031(\256rst)N -724(starts,)X -937(it)X -1005(is)X -1082(in)X -1168(command)X -1508(mode.)X -1750(There)X -1962(are)X -2085(several)X -2337(commands)X -2708(that)X -2852(change)X -3 f -3104(vi)X -1 f -3189(into)X -3336(text)X -3479(input)X -3666(mode.)X -3907(The)X -7 f -576 2121()N -1 f -980(character)X -1296(is)X -1369(used)X -1536(to)X -1618(resolve)X -1870(the)X -1988(text)X -2128(input)X -2312(into)X -2456(the)X -2574(\256le,)X -2716(and)X -2852(exit)X -2992(back)X -3164(into)X -3308(command)X -3644(mode.)X -3882(In)X -3 f -3970(vi)X -1 f -576 2211(command)N -916(mode,)X -1138(the)X -1260(cursor)X -1485(is)X -1562(always)X -1809(positioned)X -2166(on)X -2269(the)X -2390(last)X -2524(column)X -2787(of)X -2877(characters)X -3227(which)X -3446(take)X -3603(up)X -3706(more)X -3894(than)X -576 2301(one)N -714(column)X -976(on)X -1078(the)X -1198(screen.)X -1466(In)X -3 f -1555(vi)X -1 f -1639(text)X -1782(insert)X -1983(mode,)X -2204(the)X -2325(cursor)X -2549(is)X -2625(positioned)X -2981(on)X -3084(the)X -3205(\256rst)X -3352(column)X -3615(of)X -3705(characters)X -576 2391(which)N -792(take)X -946(up)X -1046(more)X -1231(than)X -1389(one)X -1525(column)X -1785(on)X -1885(the)X -2003(screen.)X -776 2514(Generally,)N -1138(if)X -1212(the)X -1335(cursor)X -1561(line)X -1707(and)X -1849(cursor)X -2076(column)X -2342(are)X -2467(not)X -2595(on)X -2701(the)X -2825(screen,)X -3077(then)X -3241(the)X -3365(screen)X -3597(is)X -3676(scrolled)X -3956(\(if)X -576 2604(the)N -695(target)X -899(cursor)X -1121(is)X -1195(close\))X -1407(or)X -1494(repainted)X -1813(\(if)X -1909(the)X -2027(target)X -2230(cursor)X -2451(is)X -2524(far)X -2634(away\))X -2851(so)X -2942(that)X -3082(the)X -3200(cursor)X -3421(is)X -3494(on)X -3594(the)X -3712(screen.)X -3978(If)X -576 2694(the)N -699(screen)X -930(is)X -1009(scrolled,)X -1309(it)X -1379(is)X -1458(moved)X -1702(a)X -1764(minimal)X -2056(amount,)X -2342(and)X -2484(the)X -2608(cursor)X -2835(line)X -2981(will)X -3131(usually)X -3388(appear)X -3629(at)X -3713(the)X -3837(top)X -3965(or)X -576 2784(bottom)N -832(of)X -929(the)X -1057(screen.)X -1333(In)X -1430(the)X -1558(screen)X -1794(is)X -1877(repainted,)X -2226(the)X -2354(cursor)X -2585(line)X -2735(will)X -2889(appear)X -3134(in)X -3226(the)X -3354(center)X -3581(of)X -3678(the)X -3806(screen,)X -576 2874(unless)N -799(the)X -920(cursor)X -1144(is)X -1220(suf\256ciently)X -1603(close)X -1791(to)X -1876(the)X -1997(beginning)X -2340(or)X -2430(end)X -2569(of)X -2660(the)X -2782(\256le)X -2908(that)X -3052(this)X -3191(is)X -3268(not)X -3394(possible.)X -3720(If)X -3798(the)X -3 f -3920(lef-)X -576 2964(tright)N -1 f -794(option)X -1020(is)X -1095(set,)X -1226(the)X -1346(screen)X -1574(may)X -1734(be)X -1832(scrolled)X -2108(or)X -2197(repainted)X -2518(in)X -2602(a)X -2660(horizontal)X -3007(direction)X -3314(as)X -3403(well)X -3563(as)X -3651(in)X -3734(a)X -3791(vertical)X -576 3054(one.)N -776 3177(A)N -869(major)X -1091(difference)X -1453(between)X -1756(the)X -1889(historical)X -3 f -2222(vi)X -1 f -2319(presentation)X -2746(and)X -3 f -2897(nvi)X -1 f -3038(is)X -3126(in)X -3224(the)X -3358(scrolling)X -3674(and)X -3826(screen)X -576 3267(oriented)N -893(position)X -1204(commands,)X -3 f -1625()X -1 f -2042(,)X -3 f -2116()X -1 f -2538(,)X -3 f -2612()X -1 f -3029(,)X -3 f -3103()X -1 f -3516(,)X -3 f -3590()X -1 f -4012(,)X -3 f -576 3357()N -1 f -998(,)X -3 f -1049(H)X -1 f -1111(,)X -3 f -1162(L)X -1 f -1246(and)X -3 f -1394(M)X -1 f -1470(.)X -1542(In)X -1641(historical)X -1971(implementations)X -2536(of)X -3 f -2635(vi)X -1 f -2697(,)X -2749(these)X -2946(commands)X -3325(acted)X -3527(on)X -3639(physical)X -3938(\(as)X -576 3447(opposed)N -877(to)X -973(logical,)X -1245(or)X -1346(screen\))X -1613(lines.)X -1838(For)X -1982(lines)X -2166(that)X -2319(were)X -2509(suf\256ciently)X -2902(long)X -3077(in)X -3172(relation)X -3450(to)X -3545(the)X -3676(size)X -3834(of)X -3934(the)X -576 3537(screen,)N -822(this)X -957(meant)X -1174(that)X -1315(single)X -1527(line)X -1668(scroll)X -1867(commands)X -2235(might)X -2442(repaint)X -2686(the)X -2805(entire)X -3009(screen,)X -3256(scrolling)X -3557(or)X -3645(screen)X -3872(posi-)X -576 3627(tioning)N -823(command)X -1160(might)X -1367(not)X -1489(change)X -1737(the)X -1855(screen)X -2081(or)X -2168(move)X -2366(the)X -2484(cursor)X -2705(at)X -2783(all,)X -2903(and)X -3039(some)X -3228(lines)X -3399(simply)X -3636(could)X -3834(not)X -3956(be)X -576 3717(displayed,)N -927(even)X -1104(though)X -3 f -1351(vi)X -1 f -1438(would)X -1663(edit)X -1808(the)X -1931(\256le)X -2058(that)X -2203(contained)X -2540(them.)X -2765(In)X -3 f -2857(nvi)X -1 f -2963(,)X -3008(these)X -3198(commands)X -3570(act)X -3689(on)X -3794(logical,)X -576 3807(i.e.)N -718(screen)X -968(lines.)X -1203(You)X -1385(are)X -1528(unlikely)X -1834(to)X -1939(notice)X -2178(any)X -2337(difference)X -2707(unless)X -2950(you)X -3113(are)X -3255(editing)X -3520(\256les)X -3696(with)X -3881(lines)X -576 3897(signi\256cantly)N -991(longer)X -1216(than)X -1374(a)X -1430(screen)X -1656(width.)X -3 f -776 4020(Vi)N -1 f -883(keeps)X -1094(track)X -1283(of)X -1378(the)X -1504(currently)X -1822(``most)X -2059(attractive'')X -2440(cursor)X -2669(position.)X -2994(Each)X -3183(command)X -3527(description)X -3911(\(for)X -576 4110(commands)N -945(that)X -1087(can)X -1221(change)X -1471(the)X -1591(current)X -1841(cursor)X -2064(position\),)X -2390(speci\256es)X -2688(if)X -2759(the)X -2879(cursor)X -3101(is)X -3175(set)X -3285(to)X -3368(a)X -3425(speci\256c)X -3691(location)X -3970(in)X -576 4200(the)N -705(line,)X -876(or)X -974(if)X -1054(it)X -1129(is)X -1213(moved)X -1462(to)X -1555(the)X -1685(``most)X -1926(attractive)X -2257(cursor)X -2490(position''.)X -2873(The)X -3030(latter)X -3227(means)X -3464(that)X -3616(the)X -3746(cursor)X -3979(is)X -576 4290(moved)N -825(to)X -918(the)X -1047(cursor)X -1279(position)X -1567(that)X -1717(is)X -1800(vertically)X -2133(as)X -2230(close)X -2425(as)X -2522(possible)X -2814(to)X -2906(the)X -3034(current)X -3292(cursor)X -3523(position.)X -3850(If)X -3934(the)X -576 4380(current)N -826(line)X -968(is)X -1043(shorter)X -1288(than)X -1448(the)X -1568(cursor)X -1791(position)X -3 f -2070(vi)X -1 f -2154(would)X -2376(select,)X -2601(the)X -2722(cursor)X -2946(is)X -3022(positioned)X -3378(on)X -3481(the)X -3602(last)X -3736(character)X -576 4470(in)N -666(the)X -792(line.)X -980(\(If)X -1089(the)X -1215(line)X -1363(is)X -1444(empty,)X -1692(the)X -1818(cursor)X -2047(is)X -2128(positioned)X -2489(on)X -2596(the)X -2721(\256rst)X -2872(column)X -3139(of)X -3233(the)X -3358(line.\))X -3572(If)X -3653(a)X -3716(command)X -576 4560(moves)N -810(the)X -933(cursor)X -1159(to)X -1246(the)X -1369(most)X -1549(attractive)X -1873(position,)X -2175(it)X -2245(does)X -2418(not)X -2546(alter)X -2715(the)X -2839(current)X -3093(cursor)X -3320(position,)X -3623(and)X -3765(a)X -3827(subse-)X -576 4650(quent)N -775(movement)X -1134(will)X -1279(again)X -1474(attempt)X -1735(to)X -1818(move)X -2017(the)X -2136(cursor)X -2358(to)X -2441(that)X -2581(position.)X -2898(Therefore,)X -3256(although)X -3556(a)X -3612(movement)X -3970(to)X -576 4740(a)N -640(line)X -788(shorter)X -1039(than)X -1205(the)X -1331(currently)X -1649(most)X -1832(attractive)X -2159(position)X -2444(will)X -2596(cause)X -2803(the)X -2929(cursor)X -3158(to)X -3248(move)X -3454(to)X -3544(the)X -3671(end)X -3816(of)X -3912(that)X -576 4830(line,)N -737(a)X -794(subsequent)X -1171(movement)X -1530(to)X -1613(a)X -1670(longer)X -1896(line)X -2037(will)X -2182(cause)X -2382(the)X -2501(cursor)X -2723(to)X -2806(move)X -3005(back)X -3178(to)X -3260(the)X -3378(most)X -3553(attractive)X -3872(posi-)X -576 4920(tion.)N -776 5043(In)N -864(addition,)X -1167(the)X -3 f -1286($)X -1 f -1347(command)X -1684(makes)X -1910(the)X -2029(end)X -2166(of)X -2254(each)X -2423(line)X -2564(the)X -2684(most)X -2861(attractive)X -3182(cursor)X -3405(position)X -3684(rather)X -3894(than)X -576 5133(a)N -632(speci\256c)X -897(column.)X -776 5256(Each)N -3 f -958(vi)X -1 f -1042(command)X -1380(described)X -1710(below)X -1928(notes)X -2119(where)X -2338(the)X -2458(cursor)X -2681(ends)X -2850(up)X -2952(after)X -3122(it)X -3188(is)X -3263(executed.)X -3611(This)X -3775(position)X -576 5346(is)N -653(described)X -985(in)X -1071(terms)X -1273(of)X -1364(characters)X -1715(on)X -1819(the)X -1940(line,)X -2103(i.e.)X -2244(``the)X -2419(previous)X -2718 0.3409(character'',)AX -3111(or,)X -3221(``the)X -3396(last)X -3530(character)X -3849(in)X -3934(the)X -576 5436(line''.)N -810(This)X -972(is)X -1045(to)X -1127(avoid)X -1325(needing)X -1599(to)X -1681(continually)X -2061(refer)X -2234(to)X -2316(on)X -2416(what)X -2592(part)X -2737(of)X -2824(the)X -2942(character)X -3258(the)X -3376(cursor)X -3597(rests.)X -776 5559(The)N -921(following)X -1252(words)X -1468(have)X -1640(special)X -1883(meaning)X -2179(for)X -3 f -2293(vi)X -1 f -2375(commands.)X - -10 p -%%Page: 10 9 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-10)N -2826(Nvi/Nex)X -3122 0.3906(Reference)AX -3487(\(Vi)X -3614(Commands\))X -576 762(previous)N -889(context)X -1 f -776 852(The)N -927(position)X -1210(of)X -1303(the)X -1427(cursor)X -1654(before)X -1886(the)X -2010(command)X -2352(which)X -2574(caused)X -2819(the)X -2944(last)X -3082(absolute)X -3376(movement)X -3741(was)X -3893(exe-)X -776 942(cuted.)N -1012(Each)X -3 f -1195(vi)X -1 f -1279(command)X -1617(described)X -1947(in)X -2031(the)X -2151(next)X -2311(section)X -2559(that)X -2700(is)X -2774(considered)X -3143(an)X -3240(absolute)X -3528(movement)X -3887(is)X -3961(so)X -776 1032(noted.)N -1014(In)X -1101(addition,)X -1403(specifying)X -2 f -1757(any)X -1 f -1893(address)X -2154(to)X -2236(an)X -3 f -2332(ex)X -1 f -2428(command)X -2764(is)X -2837(considered)X -3205(an)X -3301(absolute)X -3588(movement.)X -3 f -576 1212(motion)N -1 f -776 1302(A)N -863(second)X -3 f -1115(vi)X -1 f -1206(command)X -1551(can)X -1693(be)X -1799(used)X -1976(as)X -2073(an)X -2179(optional)X -2471(trailing)X -2732(argument)X -3065(to)X -3157(the)X -3 f -3285(vi)X -3377(!)X -1 f -3404(,)X -3 f -3454(<)X -1 f -3500(,)X -3 f -3550(>)X -1 f -3596(,)X -3 f -3646(c)X -1 f -3682(,)X -3 f -3732(d)X -1 f -3776(,)X -3 f -3826(y)X -1 f -(,)S -3916(and)X -776 1392(\(depending)N -1158(on)X -1259(the)X -3 f -1378(tildeop)X -1 f -1633(option\))X -3 f -1884(\304)X -1 f -1931(commands.)X -2338(This)X -2500(command)X -2836(indicates)X -3141(the)X -3259(end)X -3395(of)X -3482(the)X -3600(region)X -3825(of)X -3912(text)X -776 1482(that's)N -993(affected)X -1292(by)X -1411(the)X -1548(command.)X -1943(The)X -2107(motion)X -2372(command)X -2727(may)X -2904(be)X -3019(either)X -3242(the)X -3380(command)X -3736(character)X -776 1572(repeated)N -1070(\(in)X -1180(which)X -1397(case)X -1557(it)X -1622(means)X -1848(the)X -1967(current)X -2216(line\))X -2384(or)X -2472(a)X -2528(cursor)X -2749(movement)X -3107(command.)X -3483(In)X -3570(the)X -3688(latter)X -3873(case,)X -776 1662(the)N -894(region)X -1119(affected)X -1399(by)X -1499(the)X -1617(command)X -1953(is)X -2026(from)X -2202(the)X -2320(starting)X -2581(or)X -2669(stopping)X -2965(cursor)X -3187(position)X -3465(which)X -3682(comes)X -3908(\256rst)X -776 1752(in)N -859(the)X -978(\256le,)X -1120(to)X -1202(immediately)X -1622(before)X -1848(the)X -1966(starting)X -2226(or)X -2313(stopping)X -2608(cursor)X -2829(position)X -3106(which)X -3322(comes)X -3547(later)X -3710(in)X -3792(the)X -3910(\256le.)X -776 1842(Commands)N -1166(that)X -1313(operate)X -1577(on)X -1684(lines)X -1862(instead)X -2116(of)X -2210(using)X -2410(beginning)X -2757(and)X -2900(ending)X -3145(cursor)X -3373(positions)X -3688(operate)X -3952(on)X -776 1932(all)N -880(of)X -971(the)X -1093(lines)X -1268(that)X -1412(are)X -1535(wholly)X -1781(or)X -1872(partially)X -2163(in)X -2248(the)X -2369(region.)X -2637(In)X -2727(addition,)X -3032(some)X -3224(other)X -3412(commands)X -3782(become)X -776 2022(line)N -922(oriented)X -1211(depending)X -1571(on)X -1677(where)X -1900(in)X -1988(the)X -2112(text)X -2258(they)X -2422(are)X -2548(used.)X -2762(The)X -2914(command)X -3257(descriptions)X -3671(below)X -3894(note)X -776 2112(these)N -961(special)X -1204(cases.)X -776 2292(The)N -921(following)X -1252(commands)X -1619(may)X -1777(all)X -1877(be)X -1973(used)X -2140(as)X -2227(motion)X -2473(components)X -2880(for)X -3 f -2994(vi)X -1 f -3076(commands:)X -7 f -776 2505()N -1472()X -2120()X -2768()X -776 2595()N -1472()X -2312()X -3248($)X -1256 2685(%)N -1424(')X -2600(\()X -3248(\))X -1256 2775(+)N -1952(,)X -2600(-)X -3248(/)X -1256 2865(0)N -1952(;)X -2600(?)X -3248(B)X -1256 2955(E)N -1952(F)X -2600(G)X -3248(H)X -1256 3045(L)N -1952(M)X -2600(N)X -3248(T)X -1256 3135(W)N -1904([[)X -2552(]])X -3248(\303)X -1256 3225(_)N -1424(`)X -2600(b)X -3248(e)X -1256 3315(f)N -1952(h)X -2600(j)X -3248(k)X -1256 3405(l)N -1952(n)X -2600(t)X -3248(w)X -1256 3495({)N -1952(|)X -2600(})X -1 f -776 3708(The)N -923(optional)X -1207(count)X -1407(pre\256x)X -1617(available)X -1930(for)X -2047(some)X -2239(of)X -2329(the)X -3 f -2450(vi)X -1 f -2535(commands)X -2905(that)X -3048(take)X -3205(motion)X -3454(commands,)X -3844(or)X -3934(the)X -776 3798(count)N -975(pre\256x)X -1183(available)X -1494(for)X -1609(the)X -3 f -1728(vi)X -1 f -1811(commands)X -2179(that)X -2320(are)X -2439(used)X -2606(as)X -2693(motion)X -2939(components,)X -3366(may)X -3524(be)X -3620(included)X -3916(and)X -776 3888(is)N -2 f -850(always)X -1 f -1093(considered)X -1463(part)X -1610(of)X -1699(the)X -1819(motion)X -2067(argument.)X -2432(For)X -2565(example,)X -2879(the)X -2999(commands)X -3368(``)X -7 f -3422(c2w)X -1 f -('')S -3642(and)X -3780(``)X -7 f -3834(2cw)X -1 f -('')S -776 3978(are)N -903(equivalent,)X -1285(and)X -1429(the)X -1555(region)X -1788(affected)X -2076(by)X -2184(the)X -3 f -2310(c)X -1 f -2374(command)X -2718(is)X -2799(two)X -2947(words)X -3171(of)X -3266(text.)X -3454(In)X -3549(addition,)X -3858(if)X -3934(the)X -776 4068(optional)N -1066(count)X -1272(pre\256x)X -1487(is)X -1568(speci\256ed)X -1881(for)X -2003(both)X -2173(the)X -3 f -2299(vi)X -1 f -2389(command)X -2733(and)X -2877(its)X -2980(motion)X -3234(component,)X -3639(the)X -3766(effect)X -3979(is)X -776 4158(multiplicative)N -1246(and)X -1388(is)X -1467(considered)X -1841(part)X -1992(of)X -2085(the)X -2209(motion)X -2461(argument.)X -2830(For)X -2967(example,)X -3285(the)X -3408(commands)X -3780(``)X -7 f -3834(4cw)X -1 f -('')S -776 4248(and)N -912(``)X -7 f -966(2c2w)X -1 f -('')S -1232(are)X -1351(equivalent,)X -1725(and)X -1861(the)X -1979(region)X -2204(affected)X -2484(by)X -2584(the)X -3 f -2702(c)X -1 f -2758(command)X -3094(is)X -3167(four)X -3321(words)X -3537(of)X -3624(text.)X -3 f -576 4428(count)N -1 f -776 4518(A)N -859(positive)X -1137(number)X -1407(used)X -1579(as)X -1671(an)X -1772(optional)X -2059(argument)X -2387(to)X -2474(most)X -2654(commands,)X -3046(either)X -3254(to)X -3341(give)X -3504(a)X -3566(size)X -3717(or)X -3810(a)X -3872(posi-)X -776 4608(tion)N -930(\(for)X -1081(display)X -1342(or)X -1439(movement)X -1807(commands\),)X -2231(or)X -2328(as)X -2425(a)X -2491(repeat)X -2718(count)X -2926(\(for)X -3077(commands)X -3454(that)X -3604(modify)X -3865(text\).)X -776 4698(The)N -932(count)X -1141(argument)X -1475(is)X -1559(always)X -1813(optional)X -2106(and)X -2254(defaults)X -2540(to)X -2634(1)X -2706(unless)X -2938(otherwise)X -3282(noted)X -3492(in)X -3586(the)X -3716(command)X -776 4788(description.)N -776 4968(When)N -995(a)X -3 f -1059(vi)X -1 f -1149(command)X -1493(synopsis)X -1796(shows)X -2024(both)X -2194(a)X -7 f -2258([buffer])X -1 f -2670(and)X -7 f -2814([count])X -1 f -(,)S -3198(they)X -3364(may)X -3530(be)X -3634(presented)X -3970(in)X -776 5058(any)N -912(order.)X -3 f -576 5238(bigword)N -1 f -776 5328(A)N -854(set)X -963(of)X -1050(non-whitespace)X -1575(characters)X -1923(preceded)X -2235(and)X -2372(followed)X -2678(by)X -2779(whitespace)X -3157(characters)X -3505(or)X -3593(the)X -3712(beginning)X -776 5418(or)N -863(end)X -999(of)X -1086(the)X -1204(\256le)X -1326(or)X -1413(line.)X -776 5598(Groups)N -1040(of)X -1135(empty)X -1363(lines)X -1542(\(or)X -1664(lines)X -1843(containing)X -2209(only)X -2379(whitespace)X -2764 0.3250(characters\))AX -3146(are)X -3274(treated)X -3522(as)X -3618(a)X -3683(single)X -3903(big-)X -776 5688(word.)N - -11 p -%%Page: 11 10 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Vi)X -1364(Commands\))X -3658(USD:13-11)X -576 762(word)N -1 f -776 852(Generally,)N -1133(in)X -1215(languages)X -1556(where)X -1773(it)X -1837(is)X -1910(applicable,)X -3 f -2280(vi)X -1 f -2362(recognizes)X -2726(two)X -2866(kinds)X -3060(of)X -3148(words.)X -3405(First,)X -3592(a)X -3649(sequence)X -3965(of)X -776 942(letters,)N -1027(digits)X -1239(and)X -1390(underscores,)X -1829(delimited)X -2166(at)X -2259(both)X -2435(ends)X -2616(by:)X -2752(characters)X -3113(other)X -3312(than)X -3484(letters,)X -3734(digits,)X -3965(or)X -776 1032(underscores;)N -1206(the)X -1328(beginning)X -1672(or)X -1763(end)X -1903(of)X -1994(a)X -2054(line;)X -2220(the)X -2343(beginning)X -2688(or)X -2780(end)X -2921(of)X -3013(the)X -3136(\256le.)X -3303(Second,)X -3584(a)X -3645(sequence)X -3965(of)X -776 1122(characters)N -1126(other)X -1313(than)X -1473(letters,)X -1711(digits,)X -1930(underscores,)X -2356(or)X -2445(whitespace)X -2824(characters,)X -3193(delimited)X -3517(at)X -3597(both)X -3761(ends)X -3930(by:)X -776 1212(a)N -838(letter,)X -1049(digit,)X -1241(underscore,)X -1640(or)X -1733(whitespace)X -2116(character;)X -2460(the)X -2584(beginning)X -2930(or)X -3024(end)X -3167(of)X -3261(a)X -3324(line;)X -3493(the)X -3618(beginning)X -3965(or)X -776 1302(end)N -912(of)X -999(the)X -1117(\256le.)X -776 1482(Groups)N -1032(of)X -1119(empty)X -1339(lines)X -1510(\(or)X -1624(lines)X -1795(containing)X -2153(only)X -2315(whitespace)X -2692 0.3250(characters\))AX -3066(are)X -3185(treated)X -3424(as)X -3511(a)X -3567(single)X -3778(word.)X -3 f -576 1662(paragraph)N -1 f -776 1752(An)N -898(area)X -1057(of)X -1148(text)X -1292(that)X -1436(begins)X -1670(with)X -1837(either)X -2045(the)X -2168(beginning)X -2513(of)X -2605(a)X -2666(\256le,)X -2813(an)X -2914(empty)X -3139(line,)X -3304(or)X -3396(a)X -3457(section)X -3709(boundary,)X -776 1842(and)N -912(continues)X -1239(until)X -1405(either)X -1608(an)X -1704(empty)X -1924(line,)X -2084(section)X -2331(boundary,)X -2674(or)X -2761(the)X -2879(end)X -3015(of)X -3102(the)X -3220(\256le.)X -776 2022(Groups)N -1037(of)X -1129(empty)X -1355(lines)X -1532(\(or)X -1652(lines)X -1829(containing)X -2193(only)X -2361(whitespace)X -2744 0.3250(characters\))AX -3124(are)X -3249(treated)X -3494(as)X -3587(a)X -3649(single)X -3866(para-)X -776 2112(graph.)N -776 2292(Additional)N -1138(paragraph)X -1480(boundaries)X -1852(can)X -1984(be)X -2080(de\256ned)X -2336(using)X -2529(the)X -3 f -2647(paragraph)X -1 f -3031(option.)X -3 f -576 2472(section)N -1 f -776 2562(An)N -903(area)X -1067(of)X -1163(text)X -1312(that)X -1461(starts)X -1659(with)X -1830(the)X -1957(beginning)X -2306(of)X -2402(the)X -2529(\256le)X -2660(or)X -2756(a)X -2822(line)X -2972(whose)X -3207(\256rst)X -3361(character)X -3687(is)X -3770(an)X -3876(open)X -776 2652(brace)N -971(\(``)X -7 f -1052({)X -1 f -(''\))S -1201(and)X -1337(continues)X -1664(until)X -1830(the)X -1948(next)X -2106(section)X -2353(or)X -2440(the)X -2558(end)X -2694(of)X -2781(the)X -2899(\256le.)X -776 2832(Additional)N -1138(section)X -1385(boundaries)X -1757(can)X -1889(be)X -1985(de\256ned)X -2241(using)X -2434(the)X -3 f -2552(sections)X -1 f -2839(option.)X -3 f -576 3012(sentence)N -1 f -776 3102(An)N -895(area)X -1051(of)X -1139(text)X -1280(that)X -1421(begins)X -1651(with)X -1814(either)X -2018(the)X -2137(beginning)X -2478(of)X -2566(the)X -2685(\256le)X -2808(or)X -2896(the)X -3015(\256rst)X -3160(nonblank)X -3479(character)X -3796(follow-)X -776 3192(ing)N -901(the)X -1022(previous)X -1321(sentence,)X -1641(paragraph,)X -2006(or)X -2096(section)X -2346(boundary)X -2672(and)X -2811(continues)X -3141(until)X -3310(the)X -3431(end)X -3570(of)X -3660(the)X -3781(\256le)X -3906(or)X -3996(a)X -776 3282(or)N -866(a)X -926(period)X -1155(\(``)X -7 f -1236(.)X -1 f -(''\))S -1409(exclamation)X -1825(point)X -2013(\(``)X -7 f -2094(!)X -1 f -(''\))S -2267(or)X -2358(question)X -2653(mark)X -2842(\(``)X -7 f -2923(?)X -1 f -(''\))S -3096(character,)X -3436(followed)X -3745(by)X -3849(either)X -776 3372(an)N -882(end-of-line)X -1269(or)X -1366(two)X -1516(whitespace)X -1903(characters.)X -2300(Any)X -2468(number)X -2743(of)X -2840(closing)X -3101(parentheses)X -3505(\(``)X -7 f -3586(\))X -1 f -(''\),)S -3764(brackets)X -776 3462(\(``)N -7 f -857(])X -1 f -(''\))S -1007(or)X -1095(double-quote)X -1540(\(``)X -7 f -1621(")X -1 f -(''\))S -1772(characters)X -2121(can)X -2255(appear)X -2492(between)X -2782(the)X -2902(period,)X -3149(exclamation)X -3563(point,)X -3769(or)X -3858(ques-)X -776 3552(tion)N -920(mark)X -1105(and)X -1241(the)X -1359(whitespace)X -1736(characters)X -2083(or)X -2170(end-of-line.)X -776 3732(Groups)N -1040(of)X -1135(empty)X -1363(lines)X -1542(\(or)X -1664(lines)X -1843(containing)X -2209(only)X -2379(whitespace)X -2764 0.3250(characters\))AX -3146(are)X -3273(treated)X -3520(as)X -3615(a)X -3679(single)X -3898(sen-)X -776 3822(tence.)N -3 f -576 4008(10.)N -716(Vi)X -816(Commands)X -1 f -776 4131(The)N -926(following)X -1262(section)X -1514(describes)X -1838(the)X -1961(commands)X -2333(available)X -2649(in)X -2737(the)X -2861(command)X -3203(mode)X -3407(of)X -3500(the)X -3 f -3624(vi)X -1 f -3712(editor.)X -3965(In)X -576 4221(each)N -745(entry)X -931(below,)X -1168(the)X -1287(tag)X -1406(line)X -1547(is)X -1621(a)X -1678(usage)X -1882(synopsis)X -2178(for)X -2293(the)X -2412(command)X -2749(character.)X -3106(In)X -3194(addition,)X -3496(the)X -3614(\256nal)X -3776(line)X -3916(and)X -576 4311(column)N -836(the)X -954(cursor)X -1175(rests)X -1342(upon,)X -1542(and)X -1678(any)X -1814(options)X -2069(which)X -2285(affect)X -2489(the)X -2607(command)X -2943(are)X -3062(noted.)X -3 f -576 4491([count])N -841()X -1 f -776 4581(Search)N -1034(forward)X -7 f -1328(count)X -1 f -1607(times)X -1819(for)X -1952(the)X -2089(current)X -2356(word.)X -2600(The)X -2764(current)X -3031(word)X -3236(begins)X -3485(at)X -3583(the)X -3721(\256rst)X -3885(non-)X -776 4671(whitespace)N -1164(character)X -1491(on)X -1602(or)X -1699(after)X -1877(the)X -2005(current)X -2263(cursor)X -2494(position,)X -2801(and)X -2947(extends)X -3222(up)X -3332(to)X -3424(the)X -3552(next)X -3720(non-word)X -776 4761(character)N -1095(or)X -1185(the)X -1306(end)X -1445(of)X -1535(the)X -1656(line.)X -1839(The)X -1987(search)X -2216(is)X -2292(literal,)X -2522(i.e.)X -2643(no)X -2746(characters)X -3096(in)X -3182(the)X -3304(word)X -3493(have)X -3669(any)X -3809(special)X -776 4851(meaning)N -1076(in)X -1162(terms)X -1364(of)X -1455(Regular)X -1733(Expressions.)X -2184(It)X -2257(is)X -2334(an)X -2434(error)X -2615(if)X -2687(no)X -2790(matching)X -3111(pattern)X -3357(is)X -3433(found)X -3643(between)X -3934(the)X -776 4941(starting)N -1036(position)X -1313(and)X -1449(the)X -1567(end)X -1703(of)X -1790(the)X -1908(\256le.)X -776 5121(The)N -3 f -926()X -1 f -1373(command)X -1714(is)X -1792(an)X -1893(absolute)X -2185(movement.)X -2588(The)X -3 f -2738()X -1 f -3185(command)X -3526(may)X -3690(be)X -3792(used)X -3965(as)X -776 5211(the)N -896(motion)X -1144(component)X -1522(of)X -1611(other)X -3 f -1798(vi)X -1 f -1881(commands,)X -2269(in)X -2352(which)X -2569(case)X -2729(any)X -2866(text)X -3007(copied)X -3242(into)X -3387(a)X -3444(buffer)X -3662(is)X -3736(character)X -776 5301(oriented.)N -776 5481(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(where)X -1815(the)X -1933(word)X -2118(is)X -2191(found.)X -776 5571(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(character)X -1918(of)X -2005(the)X -2123(word.)X -776 5661(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(extended)X -1 f -1963(,)X -3 f -2003(ignorecase)X -1 f -2384(and)X -3 f -2520(wrapscan)X -1 f -2869(options.)X - -12 p -%%Page: 12 11 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-12)N -2826(Nvi/Nex)X -3122 0.3906(Reference)AX -3487(\(Vi)X -3614(Commands\))X -576 762([count])N -841()X -1 f -776 852(Page)N -965(backward)X -7 f -1311(count)X -1 f -1585(screens.)X -1896(Two)X -2077(lines)X -2262(of)X -2363(overlap)X -2638(are)X -2771(maintained)X -3161(by)X -3275(displaying)X -3642(the)X -3774(window)X -776 942(starting)N -1042(at)X -1126(line)X -7 f -1272(\(top_line)X -1758(-)X -1860(count)X -2154(*)X -2256(window_size\))X -2886(+)X -2988(2)X -1 f -(,)S -3081(where)X -7 f -3303(window_size)X -1 f -3856(is)X -3934(the)X -776 1032(value)N -973(of)X -1063(the)X -3 f -1184(window)X -1 f -1473(option.)X -1741(\(In)X -1859(the)X -1981(case)X -2144(of)X -2235(split)X -2396(screens,)X -2677(this)X -2816(size)X -2965(is)X -3042(corrected)X -3366(to)X -3452(the)X -3574(current)X -3826(screen)X -776 1122(size.\))N -988(This)X -1150(is)X -1223(an)X -1319(error)X -1496(if)X -1565(the)X -1683(movement)X -2041(is)X -2114(past)X -2263(the)X -2381(beginning)X -2721(of)X -2808(the)X -2926(\256le.)X -776 1302(The)N -3 f -921()X -1 f -1358(command)X -1694(is)X -1767(an)X -1863(absolute)X -2150(movement.)X -776 1482(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(line)X -1729(of)X -1816(text)X -1956(displayed)X -2283(on)X -2383(the)X -2501(screen.)X -776 1572(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(of)X -2323(the)X -2441(line.)X -776 1662(Options:)N -1136(None.)X -3 f -576 1842([count])N -841()X -1 f -776 1932(Scroll)N -990(forward)X -7 f -1268(count)X -1 f -1531(lines.)X -1745(If)X -7 f -1822(count)X -1 f -2085(is)X -2161(not)X -2286(speci\256ed,)X -2614(scroll)X -2815(forward)X -3093(the)X -3214(number)X -3482(of)X -3572(lines)X -3747(speci\256ed)X -776 2022(by)N -881(the)X -1004(last)X -3 f -1140()X -1 f -1587(or)X -3 f -1679()X -1 f -2126(command.)X -2507(If)X -2586(this)X -2726(is)X -2803(the)X -2925(\256rst)X -3 f -3073()X -1 f -3519(or)X -3 f -3610()X -1 f -776 2112(command,)N -1141(scroll)X -1348(forward)X -1632(half)X -1786(the)X -1913(number)X -2188(of)X -2285(lines)X -2466(in)X -2558(the)X -2686(screen.)X -2962(\(In)X -3086(the)X -3214(case)X -3383(of)X -3480(split)X -3647(screens,)X -3934(the)X -776 2202(default)N -1026(scrolling)X -1333(distance)X -1623(is)X -1703(corrected)X -2029(to)X -2117(half)X -2268(the)X -2392(current)X -2646(screen)X -2878(size.\))X -3096(This)X -3264(is)X -3343(an)X -3445(error)X -3628(if)X -3703(the)X -3827(move-)X -776 2292(ment)N -956(is)X -1029(past)X -1178(the)X -1296(end)X -1432(of)X -1519(the)X -1637(\256le.)X -776 2472(The)N -3 f -921()X -1 f -1363(command)X -1699(is)X -1772(an)X -1868(absolute)X -2155(movement.)X -776 2652(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(current)X -1706(line)X -1846(plus)X -1999(the)X -2117(number)X -2382(of)X -2469(lines)X -2640(scrolled.)X -776 2742(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(of)X -2323(the)X -2441(line.)X -776 2832(Options:)N -1136(None.)X -3 f -576 3012([count])N -841()X -1 f -776 3102(Scroll)N -987(forward)X -7 f -1262(count)X -1 f -1522(lines,)X -1713(leaving)X -1969(the)X -2087(cursor)X -2308(on)X -2408(the)X -2526(current)X -2774(line)X -2914(and)X -3050(column,)X -3330(if)X -3399(possible.)X -3721(This)X -3883(is)X -3956(an)X -776 3192(error)N -953(if)X -1022(the)X -1140(movement)X -1498(is)X -1571(past)X -1720(the)X -1838(end)X -1974(of)X -2061(the)X -2179(\256le.)X -776 3372(Line:)N -1136(Unchanged)X -1524(unless)X -1747(the)X -1868(current)X -2119(line)X -2262(scrolls)X -2494(off)X -2611(the)X -2732(screen,)X -2981(in)X -3066(which)X -3285(case)X -3447(it)X -3514(is)X -3590(set)X -3702(to)X -3787(the)X -3908(\256rst)X -1136 3462(line)N -1276(on)X -1376(the)X -1494(screen.)X -776 3552(Column:)N -1136(Unchanged)X -1523(unless)X -1744(the)X -1863(current)X -2112(line)X -2253(scrolls)X -2483(off)X -2598(the)X -2717(screen,)X -2964(in)X -3047(which)X -3264(case)X -3424(it)X -3489(is)X -3563(set)X -3673(to)X -3757(the)X -3877(most)X -1136 3642(attractive)N -1455(cursor)X -1676(position.)X -776 3732(Options:)N -1136(None.)X -3 f -576 3912([count])N -841()X -1 f -776 4002(Page)N -955(forward)X -7 f -1233(count)X -1 f -1496(screens.)X -1797(Two)X -1968(lines)X -2143(of)X -2234(overlap)X -2499(are)X -2622(maintained)X -3002(by)X -3106(displaying)X -3463(the)X -3585(window)X -3867(start-)X -776 4092(ing)N -900(at)X -980(line)X -7 f -1122(top_line)X -1556(+)X -1654(count)X -1944(*)X -2042(window_size)X -2620(-)X -2718(2)X -1 f -(,)S -2808(where)X -7 f -3027(window_size)X -1 f -3577(is)X -3651(the)X -3770(value)X -3965(of)X -776 4182(the)N -3 f -903(window)X -1 f -1198(option.)X -1471(\(In)X -1594(the)X -1721(case)X -1889(of)X -1985(split)X -2151(screens,)X -2437(this)X -2581(size)X -2735(is)X -2817(corrected)X -3146(to)X -3238(the)X -3366(current)X -3624(screen)X -3860(size.\))X -776 4272(This)N -938(is)X -1011(an)X -1107(error)X -1284(if)X -1353(the)X -1471(movement)X -1829(is)X -1902(past)X -2051(the)X -2169(end)X -2305(of)X -2392(the)X -2510(\256le.)X -776 4452(The)N -3 f -921()X -1 f -1354(command)X -1690(is)X -1763(an)X -1859(absolute)X -2146(movement.)X -776 4632(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(line)X -1742(on)X -1842(the)X -1960(screen.)X -776 4722(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(of)X -2323(the)X -2441(current)X -2689(line.)X -776 4812(Options:)N -1136(None.)X -3 f -576 4992()N -1 f -776 5082(Display)N -1055(the)X -1183(\256le)X -1315(information.)X -1763(The)X -1918(information)X -2326(includes)X -2624(the)X -2753(current)X -3012(pathname,)X -3375(the)X -3504(current)X -3763(line,)X -3934(the)X -776 5172(number)N -1043(of)X -1132(total)X -1296(lines)X -1469(in)X -1553(the)X -1673(\256le,)X -1817(the)X -1937(current)X -2187(line)X -2329(as)X -2418(a)X -2476(percentage)X -2847(of)X -2936(the)X -3056(total)X -3220(lines)X -3393(in)X -3477(the)X -3597(\256le,)X -3741(if)X -3811(the)X -3930(\256le)X -776 5262(has)N -905(been)X -1079(modi\256ed,)X -1405(was)X -1552(able)X -1708(to)X -1792(be)X -1890(locked,)X -2146(if)X -2217(the)X -2337(\256le's)X -2519(name)X -2715(has)X -2844(been)X -3018(changed,)X -3328(and)X -3466(if)X -3537(the)X -3658(edit)X -3801(session)X -776 5352(is)N -849(read-only.)X -776 5532(Line:)N -1136(Unchanged.)X -776 5622(Column:)N -1136(Unchanged.)X -776 5712(Options:)N -1136(None.)X - -13 p -%%Page: 13 12 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Vi)X -1364(Commands\))X -3658(USD:13-13)X -576 762()N -576 852([count])N -841(h)X -1 f -776 942(Move)N -989(the)X -1113(cursor)X -1340(back)X -7 f -1518(count)X -1 f -1784(characters)X -2137(in)X -2225(the)X -2349(current)X -2603(line.)X -2789(This)X -2957(is)X -3036(an)X -3138(error)X -3321(if)X -3396(the)X -3520(cursor)X -3747(is)X -3827(on)X -3934(the)X -776 1032(\256rst)N -920(character)X -1236(in)X -1318(the)X -1436(line.)X -776 1212(The)N -3 f -923()X -1 f -1372(and)X -3 f -1511(h)X -1 f -1578(commands)X -1948(may)X -2109(be)X -2208(used)X -2378(as)X -2468(the)X -2589(motion)X -2838(component)X -3217(of)X -3307(other)X -3 f -3495(vi)X -1 f -3580(commands,)X -3970(in)X -776 1302(which)N -992(case)X -1151(any)X -1287(text)X -1427(copied)X -1661(into)X -1805(a)X -1861(buffer)X -2078(is)X -2151(character)X -2467(oriented.)X -776 1482(Line:)N -1136(Unchanged.)X -776 1572(Column:)N -1136(Set)X -1263(to)X -1350(the)X -7 f -1473(current)X -1862(-)X -1963(count)X -1 f -2229(character,)X -2571(or,)X -2684(the)X -2808(\256rst)X -2958(character)X -3280(in)X -3368(the)X -3492(line)X -3638(if)X -7 f -3713(count)X -1 f -3979(is)X -1136 1662(greater)N -1380(than)X -1538(or)X -1625(equal)X -1819(to)X -1901(the)X -2019(number)X -2284(of)X -2371(characters)X -2718(in)X -2800(the)X -2918(line)X -3058(before)X -3284(the)X -3402(cursor.)X -776 1752(Options:)N -1136(None.)X -3 f -576 1932([count])N -841()X -576 2022([count])N -841()X -576 2112([count])N -841(j)X -1 f -776 2202(Move)N -993(the)X -1121(cursor)X -1352(down)X -7 f -1560(count)X -1 f -1830(lines)X -2011(without)X -2285(changing)X -2609(the)X -2737(current)X -2995(column.)X -3305(This)X -3477(is)X -3560(an)X -3666(error)X -3854(if)X -3934(the)X -776 2292(movement)N -1134(is)X -1207(past)X -1356(the)X -1474(end)X -1610(of)X -1697(the)X -1815(\256le.)X -776 2472(The)N -3 f -927()X -1 f -1331(,)X -3 f -1377()X -1 f -1825(and)X -3 f -1967(j)X -1 f -2020(commands)X -2393(may)X -2557(be)X -2659(used)X -2832(as)X -2925(the)X -3049(motion)X -3301(component)X -3684(of)X -3778(other)X -3 f -3970(vi)X -1 f -776 2562(commands,)N -1163(in)X -1245(which)X -1461(case)X -1620(any)X -1756(text)X -1896(copied)X -2130(into)X -2274(a)X -2330(buffer)X -2547(is)X -2620(line)X -2760(oriented.)X -776 2742(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(current)X -1706(line)X -1846(plus)X -7 f -1999(count)X -1 f -(.)S -776 2832(Column:)N -1136(The)X -1281(most)X -1456(attractive)X -1775(cursor)X -1996(position.)X -776 2922(Options:)N -1136(None.)X -3 f -576 3102()N -576 3192()N -1 f -776 3282(Repaint)N -1045(the)X -1163(screen.)X -776 3462(Line:)N -1136(Unchanged.)X -776 3552(Column:)N -1136(Unchanged.)X -776 3642(Options:)N -1136(None.)X -3 f -576 3822([count])N -841()X -576 3912([count])N -841(+)X -1 f -776 4002(Move)N -984(the)X -1103(cursor)X -1325(down)X -7 f -1524(count)X -1 f -1785(lines)X -1957(to)X -2040(the)X -2159(\256rst)X -2304(nonblank)X -2623(character)X -2940(of)X -3028(that)X -3169(line.)X -3350(This)X -3513(is)X -3587(an)X -3684(error)X -3863(if)X -3934(the)X -776 4092(movement)N -1134(is)X -1207(past)X -1356(the)X -1474(end)X -1610(of)X -1697(the)X -1815(\256le.)X -776 4272(The)N -3 f -922()X -1 f -1384(and)X -3 f -1522(+)X -1 f -1590(commands)X -1959(may)X -2119(be)X -2217(used)X -2386(as)X -2475(the)X -2595(motion)X -2843(component)X -3221(of)X -3310(other)X -3 f -3497(vi)X -1 f -3581(commands,)X -3970(in)X -776 4362(which)N -992(case)X -1151(any)X -1287(text)X -1427(copied)X -1661(into)X -1805(a)X -1861(buffer)X -2078(is)X -2151(line)X -2291(oriented.)X -776 4542(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(current)X -1706(line)X -1846(plus)X -7 f -1999(count)X -1 f -(.)S -776 4632(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(in)X -2318(the)X -2436(line.)X -776 4722(Options:)N -1136(None.)X -3 f -576 4902([count])N -841()X -576 4992([count])N -841(k)X -1 f -776 5082(Move)N -983(the)X -1101(cursor)X -1323(up)X -7 f -1424(count)X -1 f -1685(lines,)X -1877(without)X -2142(changing)X -2457(the)X -2576(current)X -2825(column.)X -3126(This)X -3289(is)X -3363(an)X -3460(error)X -3638(if)X -3708(the)X -3827(move-)X -776 5172(ment)N -956(is)X -1029(past)X -1178(the)X -1296(beginning)X -1636(of)X -1723(the)X -1841(\256le.)X -776 5352(The)N -3 f -924()X -1 f -1360(and)X -3 f -1499(k)X -1 f -1566(commands)X -1937(may)X -2099(be)X -2199(used)X -2370(as)X -2461(the)X -2583(motion)X -2833(component)X -3213(of)X -3304(other)X -3 f -3493(vi)X -1 f -3579(commands,)X -3970(in)X -776 5442(which)N -992(case)X -1151(any)X -1287(text)X -1427(copied)X -1661(into)X -1805(a)X -1861(buffer)X -2078(is)X -2151(line)X -2291(oriented.)X -776 5622(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(current)X -1706(line)X -1846(minus)X -2061(count.)X -776 5712(Column:)N -1136(The)X -1281(most)X -1456(attractive)X -1775(cursor)X -1996(position.)X - -14 p -%%Page: 14 13 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-14)N -2826(Nvi/Nex)X -3122 0.3906(Reference)AX -3487(\(Vi)X -3614(Commands\))X -1 f -776 762(Options:)N -1136(None.)X -3 f -576 942()N -1 f -776 1032(Return)N -1014(to)X -1096(the)X -1214(most)X -1389(recent)X -1606(tag)X -1724(context.)X -2020(The)X -3 f -2165()X -1 f -2602(command)X -2938(is)X -3011(an)X -3107(absolute)X -3394(movement.)X -776 1212(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(context)X -1714(of)X -1801(the)X -1919(previous)X -2215(tag)X -2333(command.)X -776 1302(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(context)X -1714(of)X -1801(the)X -1919(previous)X -2215(tag)X -2333(command.)X -776 1392(Options:)N -1136(None.)X -3 f -576 1572()N -1 f -776 1662(Scroll)N -1003(backward)X -7 f -1352(count)X -1 f -1628(lines.)X -1856(If)X -7 f -1947(count)X -1 f -2224(is)X -2314(not)X -2453(speci\256ed,)X -2795(scroll)X -3010(backward)X -3360(the)X -3495(number)X -3777(of)X -3881(lines)X -776 1752(speci\256ed)N -1096(by)X -1211(the)X -1344(last)X -3 f -1490()X -1 f -1947(or)X -3 f -2049()X -1 f -2505(command.)X -2895(If)X -2983(this)X -3132(is)X -3219(the)X -3351(\256rst)X -3 f -3509()X -1 f -3965(or)X -3 f -776 1842()N -1 f -1221(command,)X -1580(scroll)X -1781(backward)X -2117(half)X -2266(the)X -2388(number)X -2657(of)X -2748(lines)X -2923(in)X -3009(the)X -3131(screen.)X -3401(\(In)X -3519(the)X -3641(case)X -3804(of)X -3895(split)X -776 1932(screens,)N -1057(the)X -1179(default)X -1426(scrolling)X -1729(distance)X -2015(is)X -2091(corrected)X -2414(to)X -2499(half)X -2647(the)X -2768(current)X -3019(screen)X -3248(size.\))X -3463(This)X -3628(is)X -3704(an)X -3803(error)X -3983(if)X -776 2022(the)N -894(movement)X -1252(is)X -1325(past)X -1474(the)X -1592(beginning)X -1932(of)X -2019(the)X -2137(\256le.)X -776 2202(The)N -3 f -921()X -1 f -1363(command)X -1699(is)X -1772(an)X -1868(absolute)X -2155(movement.)X -776 2382(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(current)X -1706(line)X -1846(minus)X -2061(the)X -2179(amount)X -2439(scrolled.)X -776 2472(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(in)X -2318(the)X -2436(line.)X -776 2562(Options:)N -1136(None.)X -3 f -576 2742()N -1 f -776 2832(Switch)N -1021(to)X -1106(the)X -1227(next)X -1388(lower)X -1594(screen)X -1823(in)X -1908(the)X -2029(window,)X -2330(or,)X -2440(to)X -2525(the)X -2646(\256rst)X -2793(screen)X -3022(if)X -3094(there)X -3278(are)X -3400(no)X -3503(lower)X -3709(screens)X -3970(in)X -776 2922(the)N -894(window.)X -776 3102(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(previous)X -1754(cursor)X -1975(position)X -2252(in)X -2334(the)X -2452(window.)X -776 3192(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(previous)X -1754(cursor)X -1975(position)X -2252(in)X -2334(the)X -2452(window.)X -776 3282(Options:)N -1136(None.)X -3 f -576 3462()N -1 f -776 3552(Scroll)N -989(backward)X -7 f -1324(count)X -1 f -1586(lines,)X -1779(leaving)X -2037(the)X -2157(current)X -2407(line)X -2550(and)X -2689(column)X -2952(as)X -3042(is,)X -3138(if)X -3210(possible.)X -3535(This)X -3700(is)X -3776(an)X -3875(error)X -776 3642(if)N -845(the)X -963(movement)X -1321(is)X -1394(past)X -1543(the)X -1661(beginning)X -2001(of)X -2088(the)X -2206(\256le.)X -776 3822(Line:)N -1136(Unchanged)X -1525(unless)X -1748(the)X -1869(current)X -2120(line)X -2263(scrolls)X -2496(off)X -2614(the)X -2736(screen,)X -2986(in)X -3072(which)X -3292(case)X -3455(it)X -3523(is)X -3600(set)X -3713(to)X -3799(the)X -3921(last)X -1136 3912(line)N -1276(of)X -1363(text)X -1503(displayed)X -1830(on)X -1930(the)X -2048(screen.)X -776 4002(Column:)N -1136(Unchanged)X -1536(unless)X -1770(the)X -1902(current)X -2164(line)X -2318(scrolls)X -2561(off)X -2689(the)X -2821(screen,)X -3081(in)X -3177(which)X -3407(case)X -3580(it)X -3658(is)X -3745(the)X -3877(most)X -1136 4092(attractive)N -1455(cursor)X -1676(position.)X -776 4182(Options:)N -1136(None.)X -3 f -576 4362()N -1 f -776 4452(Suspend)N -1069(the)X -1189(current)X -1439(editor)X -1648(session.)X -1941(If)X -2017(the)X -2137(\256le)X -2261(has)X -2390(been)X -2564(modi\256ed)X -2870(since)X -3057(it)X -3124(was)X -3272(last)X -3406(completely)X -3785(written,)X -776 4542(and)N -914(the)X -3 f -1034(autowrite)X -1 f -1386(option)X -1612(is)X -1687(set,)X -1817(the)X -1936(\256le)X -2059(is)X -2133(written)X -2381(before)X -2608(the)X -2727(editor)X -2935(session)X -3187(is)X -3261(suspended.)X -3656(If)X -3731(this)X -3867(write)X -776 4632(fails,)N -954(the)X -1072(editor)X -1279(session)X -1530(is)X -1603(not)X -1725(suspended.)X -776 4812(Line:)N -1136(Unchanged.)X -776 4902(Column:)N -1136(Unchanged.)X -776 4992(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(autowrite)X -1 f -2006(option.)X -3 f -576 5172()N -1 f -776 5262(Execute)N -3 f -1055(ex)X -1 f -1151(commands)X -1518(or)X -1605(cancel)X -1831(partial)X -2056(commands.)X -2463(If)X -2537(an)X -3 f -2633(ex)X -1 f -2729(command)X -3065(is)X -3138(being)X -3336(entered)X -3593(\(e.g.)X -3 f -3776(/)X -1 f -3798(,)X -3 f -3838(?)X -1 f -(,)S -3 f -3918(:)X -1 f -3965(or)X -3 f -776 5352(!)N -1 f -803(\),)X -877(the)X -1002(command)X -1345(is)X -1425(executed.)X -1778(If)X -1859(a)X -1922(partial)X -2154(command)X -2497(has)X -2631(been)X -2810(entered,)X -3093(e.g.)X -3255(or)X -3348(the)X -3472(command)X -3814(is)X -3893(can-)X -776 5442(celled.)N -1028(Otherwise,)X -1398(it)X -1462(is)X -1535(an)X -1631(error.)X -776 5622(Line:)N -1136(When)X -1350(an)X -3 f -1448(ex)X -1 f -1546(command)X -1884(is)X -1959(being)X -2159(executed,)X -2487(the)X -2607(current)X -2857(line)X -2999(is)X -3074(set)X -3186(as)X -3276(described)X -3607(for)X -3724(that)X -3867(com-)X -1136 5712(mand.)N -1374(Otherwise,)X -1744(unchanged.)X - -15 p -%%Page: 15 14 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Vi)X -1364(Commands\))X -3658(USD:13-15)X -1 f -776 762(Column:)N -1136(When)X -1354(an)X -3 f -1456(ex)X -1 f -1558(command)X -1901(is)X -1981(being)X -2186(executed,)X -2519(the)X -2644(current)X -2899(column)X -3166(is)X -3246(set)X -3362(as)X -3456(described)X -3791(for)X -3912(that)X -1136 852(command.)N -1512(Otherwise,)X -1882(unchanged.)X -776 942(Options:)N -1136(None.)X -3 f -576 1122()N -1 f -776 1212(Push)N -953(a)X -1011(tag)X -1131 0.4531(reference)AX -1454(onto)X -1618(the)X -1738(tag)X -1858(stack.)X -2085(The)X -2232(tags)X -2383(\256les)X -2538(\(see)X -2691(the)X -3 f -2812(tags)X -1 f -2973(option)X -3200(for)X -3317(more)X -3505(information\))X -3933(are)X -776 1302(searched)N -1086(for)X -1207(a)X -1270(tag)X -1395(matching)X -1720(the)X -1845(current)X -2100(word.)X -2332(The)X -2484(current)X -2739(word)X -2931(begins)X -3167(at)X -3252(the)X -3377(\256rst)X -3528(non-whitespace)X -776 1392(character)N -1092(on)X -1192(or)X -1279(after)X -1447(the)X -1565(current)X -1813(cursor)X -2034(position,)X -2331(and)X -2468(extends)X -2734(up)X -2835(to)X -2918(the)X -3037(next)X -3196(non-word)X -3529(character)X -3846(or)X -3934(the)X -776 1482(end)N -914(of)X -1003(the)X -1123(line.)X -1305(If)X -1381(a)X -1439(matching)X -1759(tag)X -1879(is)X -1954(found,)X -2183(the)X -2302(current)X -2551(\256le)X -2674(is)X -2748(discarded)X -3077(and)X -3214(the)X -3333(\256le)X -3456(containing)X -3815(the)X -3934(tag)X -776 1572 0.4531(reference)AN -1097(is)X -1170(edited.)X -776 1752(If)N -851(the)X -971(current)X -1221(\256le)X -1345(has)X -1474(been)X -1648(modi\256ed)X -1954(since)X -2141(it)X -2207(was)X -2354(last)X -2487(completely)X -2865(written,)X -3134(the)X -3254(command)X -3592(will)X -3738(fail.)X -3907(The)X -3 f -776 1842()N -1 f -1187(command)X -1523(is)X -1596(an)X -1692(absolute)X -1979(movement.)X -776 2022(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(containing)X -1956(the)X -2074(matching)X -2392(tag)X -2510(string.)X -776 2112(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(start)X -1616(of)X -1703(the)X -1821(matching)X -2139(tag)X -2257(string.)X -776 2202(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(tags)X -1 f -1814(and)X -3 f -1950(taglength)X -1 f -2290(options.)X -3 f -576 2382()N -1 f -776 2472(Switch)N -1018(to)X -1100(the)X -1218(most)X -1393(recently)X -1672(edited)X -1888(\256le.)X -776 2652(If)N -852(the)X -972(\256le)X -1096(has)X -1225(been)X -1399(modi\256ed)X -1705(since)X -1892(it)X -1958(was)X -2105(last)X -2238(completely)X -2616(written,)X -2886(and)X -3025(the)X -3 f -3146(autowrite)X -1 f -3499(option)X -3726(is)X -3802(set,)X -3934(the)X -776 2742(\256le)N -905(is)X -984(written)X -1237(out.)X -1405(If)X -1485(this)X -1626(write)X -1817(fails,)X -2001(the)X -2125(command)X -2467(will)X -2617(fail.)X -2790(Otherwise,)X -3166(if)X -3241(the)X -3365(current)X -3619(\256le)X -3747(has)X -3880(been)X -776 2832(modi\256ed)N -1080(since)X -1265(it)X -1329(was)X -1474(last)X -1605(completely)X -1981(written,)X -2248(the)X -2366(command)X -2702(will)X -2846(fail.)X -776 3012(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(the)X -1716(cursor)X -1937(was)X -2082(on)X -2182(when)X -2376(the)X -2494(\256le)X -2616(was)X -2761(last)X -2892(edited.)X -776 3102(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(column)X -1718(the)X -1836(cursor)X -2057(was)X -2202(on)X -2302(when)X -2496(the)X -2614(\256le)X -2736(was)X -2881(last)X -3012(edited.)X -776 3192(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(autowrite)X -1 f -2006(option.)X -3 f -576 3372([count])N -841()X -576 3462([count])N -841(l)X -1 f -776 3552(Move)N -984(the)X -1103(cursor)X -1325(forward)X -7 f -1602(count)X -1 f -1864(characters)X -2213(without)X -2479(changing)X -2795(the)X -2915(current)X -3165(line.)X -3347(This)X -3511(is)X -3586(an)X -3684(error)X -3863(if)X -3934(the)X -776 3642(cursor)N -997(is)X -1070(on)X -1170(the)X -1288(last)X -1419(character)X -1735(in)X -1817(the)X -1935(line.)X -776 3822(The)N -3 f -921()X -1 f -1220(and)X -3 f -1356(l)X -1 f -1398(commands)X -1765(may)X -1923(be)X -2019(used)X -2186(as)X -2273(the)X -2391(motion)X -2637(component)X -3013(of)X -3100(other)X -3 f -3285(vi)X -1 f -3367(commands,)X -3754(in)X -3836(which)X -776 3912(case)N -937(any)X -1075(text)X -1217(copied)X -1453(into)X -1599(a)X -1657(buffer)X -1876(is)X -1951(character)X -2269(oriented.)X -2594(In)X -2683(addition,)X -2987(these)X -3173(commands)X -3541(may)X -3700(be)X -3797(used)X -3965(as)X -776 4002(the)N -908(motion)X -1168(components)X -1589(of)X -1690(other)X -1889(commands)X -2271(when)X -2480(the)X -2613(cursor)X -2849(is)X -2937(on)X -3052(the)X -3185(last)X -3331(character)X -3662(in)X -3759(the)X -3892(line,)X -776 4092(without)N -1040(error.)X -776 4272(Line:)N -1136(Unchanged.)X -776 4362(Column:)N -1136(Set)X -1259(to)X -1342(the)X -1461(current)X -1710(character)X -2027(plus)X -2181(the)X -2300(next)X -7 f -2459(count)X -1 f -2720(characters,)X -3088(or)X -3177(to)X -3261(the)X -3381(last)X -3514(character)X -3832(on)X -3934(the)X -1136 4452(line)N -1278(if)X -7 f -1349(count)X -1 f -1611(is)X -1686(greater)X -1932(than)X -2092(the)X -2212(number)X -2478(of)X -2566(characters)X -2914(in)X -2997(the)X -3116(line)X -3257(after)X -3426(the)X -3545(current)X -3794(charac-)X -1136 4542(ter.)N -776 4632(Options:)N -1136(None.)X -3 f -576 4812([count])N -841(!)X -888(motion)X -1148(shell-argument\(s\))X -1 f -776 4902(Replace)N -1055(text)X -1195(with)X -1357(results)X -1586(from)X -1762(a)X -1818(shell)X -1989(command.)X -2366(Pass)X -2529(the)X -2648(lines)X -2820(speci\256ed)X -3126(by)X -3227(the)X -7 f -3346(count)X -1 f -3607(and)X -7 f -3744(motion)X -1 f -776 4992(arguments)N -1136(as)X -1229(standard)X -1527(input)X -1717(to)X -1805(the)X -1928(program)X -2225(named)X -2464(by)X -2569(the)X -3 f -2692(shell)X -1 f -2872(option,)X -3121(and)X -3262(replace)X -3520(those)X -3714(lines)X -3890(with)X -776 5082(the)N -894(output)X -1118(\(both)X -1307(standard)X -1599(error)X -1776(and)X -1912(standard)X -2204(output\))X -2455(of)X -2542(that)X -2682(command.)X -776 5262(After)N -966(the)X -1084(motion)X -1330(is)X -1403(entered,)X -3 f -1680(vi)X -1 f -1762(prompts)X -2044(for)X -2158(arguments)X -2512(to)X -2594(the)X -2712(shell)X -2883(command.)X -776 5442(Within)N -1026(those)X -1223(arguments,)X -1605(``)X -7 f -1659(%)X -1 f -('')S -1790(and)X -1935(``)X -7 f -1989(#)X -1 f -('')S -2120(characters)X -2476(are)X -2604(expanded)X -2941(to)X -3032(the)X -3159(current)X -3416(and)X -3561(alternate)X -3867(path-)X -776 5532(names,)N -1024(respectively.)X -1475(The)X -1623(``)X -7 f -1677(!)X -1 f -('')S -1822(character)X -2141(is)X -2217(expanded)X -2548(with)X -2713(the)X -2833(command)X -3171(text)X -3313(of)X -3402(the)X -3522(previous)X -3 f -3820(!)X -1 f -3889(or)X -3 f -3978(:!)X -1 f -776 5622(commands.)N -1183 0.3125(\(Therefore,)AX -1568(the)X -1686(command)X -3 f -2022(!!)X -1 f -2116(repeats)X -2364(the)X -2482(previous)X -3 f -2778(!)X -1 f -2845(command.\))X -3248(The)X -3393(special)X -3637(meanings)X -3965(of)X -776 5712(``)N -7 f -830(%)X -1 f -('',)S -975(``)X -7 f -1029(#)X -1 f -('')S -1154(and)X -1293(``)X -7 f -1347(!)X -1 f -('')S -1492(can)X -1627(be)X -1726(overridden)X -2097(by)X -2200(escaping)X -2504(them)X -2687(with)X -2852(a)X -2910(backslash.)X -3284(If)X -3360(no)X -3 f -3462(!)X -1 f -3531(or)X -3 f -3620(:!)X -1 f -3716(command)X -776 5802(has)N -907(yet)X -1029(been)X -1205(executed,)X -1535(it)X -1603(is)X -1680(an)X -1780(error)X -1961(to)X -2047(use)X -2178(an)X -2278(unescaped)X -2637(``)X -7 f -2691(!)X -1 f -('')S -2837(character.)X -3197(The)X -3 f -3346(!)X -1 f -3417(command)X -3758(does)X -2 f -3930(not)X - -16 p -%%Page: 16 15 -10 s 10 xH 0 xS 2 f 1 i -3 f -576 474(USD:13-16)N -2826(Nvi/Nex)X -3122 0.3906(Reference)AX -3487(\(Vi)X -3614(Commands\))X -1 f -776 762(do)N -880(shell)X -1055(expansion)X -1404(on)X -1508(the)X -1630(strings)X -1867(provided)X -2175(as)X -2265(arguments.)X -2662(If)X -2739(any)X -2878(of)X -2968(the)X -3089(above)X -3304(expansions)X -3683(change)X -3934(the)X -776 852(arguments)N -1130(the)X -1248(user)X -1402(entered,)X -1679(the)X -1797(command)X -2133(is)X -2206(redisplayed)X -2596(at)X -2674(the)X -2792(bottom)X -3038(of)X -3125(the)X -3243(screen.)X -3 f -776 1032(Vi)N -1 f -882(then)X -1046(executes)X -1349(the)X -1473(program)X -1771(named)X -2011(by)X -2117(the)X -3 f -2241(shell)X -1 f -2422(option,)X -2672(with)X -2840(a)X -3 f -9 f -2902(-)X -2904(-)X -3 f -2948(c)X -1 f -3010(\257ag)X -3156(followed)X -3467(by)X -3573(the)X -3698(arguments)X -776 1122(\(which)N -1019(are)X -1138(bundled)X -1416(into)X -1560(a)X -1616(single)X -1827(argument\).)X -776 1302(The)N -3 f -921(!)X -1 f -988(command)X -1324(is)X -1397(permitted)X -1724(in)X -1806(an)X -1902(empty)X -2122(\256le.)X -776 1482(If)N -850(the)X -968(\256le)X -1090(has)X -1217(been)X -1389(modi\256ed)X -1693(since)X -1878(it)X -1942(was)X -2087(last)X -2218(completely)X -2594(written,)X -2861(the)X -3 f -2979(!)X -1 f -3046(command)X -3382(will)X -3526(warn)X -3707(you.)X -776 1662(Line:)N -1136(The)X -1281(\256rst)X -1425(line)X -1565(of)X -1652(the)X -1770(replaced)X -2063(text.)X -776 1752(Column:)N -1136(The)X -1281(\256rst)X -1425(column)X -1685(of)X -1772(the)X -1890(replaced)X -2183(text.)X -776 1842(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(shell)X -1 f -1831(option.)X -3 f -576 2022([count])N -841(#)X -901(+|-|#)X -1 f -776 2112(Increment)N -1135(or)X -1235(decrement)X -1603(the)X -1734(current)X -1996(number.)X -2315(The)X -2474(current)X -2736(number)X -3015(begins)X -3258(at)X -3350(the)X -3482(\256rst)X -3640(non-number)X -776 2202(character)N -1095(on)X -1198(or)X -1288(before)X -1517(the)X -1638(current)X -1889(cursor)X -2113(position,)X -2413(or)X -2503(the)X -2624(beginning)X -2967(of)X -3057(the)X -3178(line,)X -3341(and)X -3480(extends)X -3748(up)X -3850(to)X -3934(the)X -776 2292(\256rst)N -920(non-number)X -1332(character)X -1649(on)X -1750(or)X -1838(after)X -2007(the)X -2126(current)X -2375(cursor)X -2597(position)X -2875(or)X -2963(the)X -3082(end)X -3219(of)X -3307(the)X -3426(line.)X -3607(If)X -3682(the)X -3801(trailing)X -776 2382(character)N -1094(is)X -1169(a)X -7 f -1227(+)X -1 f -(,)S -1317(the)X -1437(number)X -1704(is)X -1779(incremented)X -2198(by)X -7 f -2300(count)X -1 f -(.)S -2602(If)X -2678(the)X -2798(trailing)X -3051(character)X -3369(is)X -3444(a)X -7 f -3502(-)X -1 f -(,)S -3592(the)X -3712(number)X -3979(is)X -776 2472(decremented)N -1220(by)X -7 f -1333(count)X -1 f -(.)S -1646(If)X -1733(the)X -1864(trailing)X -2128(character)X -2457(is)X -2543(a)X -7 f -2612(#)X -1 f -(,)S -2713(the)X -2844(previous)X -3154(increment)X -3509(or)X -3610(decrement)X -3979(is)X -776 2562(repeated.)N -776 2742(The)N -927(format)X -1167(of)X -1260(the)X -1384(number)X -1656(\(decimal,)X -1984(hexadecimal,)X -2437(and)X -2580(octal,)X -2783(and)X -2926(leading)X -3189(0's\))X -3341(is)X -3421(retained)X -3707(unless)X -3934(the)X -776 2832(new)N -930(value)X -1124(cannot)X -1358(be)X -1454(represented)X -1845(in)X -1927(the)X -2045(previous)X -2341(format.)X -776 3012(Line:)N -1136(Unchanged.)X -776 3102(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(character)X -1918(in)X -2000(the)X -2118(cursor)X -2339(word.)X -776 3192(Options:)N -1136(None.)X -3 f -576 3372([count])N -841($)X -1 f -776 3462(Move)N -989(the)X -1113(cursor)X -1340(to)X -1428(the)X -1552(end)X -1694(of)X -1787(a)X -1849(line.)X -2035(If)X -7 f -2115(count)X -1 f -2381(is)X -2460(speci\256ed,)X -2792(the)X -2917(cursor)X -3145(moves)X -3381(down)X -7 f -3586(count)X -3881(-)X -3984(1)X -1 f -776 3552(lines.)N -776 3732(It)N -845(is)X -918(not)X -1040(an)X -1136(error)X -1313(to)X -1395(use)X -1522(the)X -3 f -1640($)X -1 f -1700(command)X -2036(when)X -2230(the)X -2348(cursor)X -2569(is)X -2642(on)X -2742(the)X -2860(last)X -2991(character)X -3308(in)X -3391(the)X -3510(line)X -3651(or)X -3739(when)X -3934(the)X -776 3822(line)N -916(is)X -989(empty.)X -776 4002(The)N -3 f -921($)X -1 f -981(command)X -1317(may)X -1475(be)X -1571(used)X -1739(as)X -1827(the)X -1946(motion)X -2193(component)X -2570(of)X -2658(other)X -3 f -2844(vi)X -1 f -2927(commands,)X -3315(in)X -3398(which)X -3615(case)X -3775(any)X -3912(text)X -776 4092(copied)N -1014(into)X -1161(a)X -1220(buffer)X -1440(is)X -1516(character)X -1835(oriented,)X -2141(unless)X -2364(the)X -2485(cursor)X -2709(is)X -2785(at,)X -2886(or)X -2976(before)X -3205(the)X -3326(\256rst)X -3473(nonblank)X -3794(charac-)X -776 4182(ter)N -885(in)X -971(the)X -1093(line,)X -1257(in)X -1343(which)X -1563(case)X -1726(it)X -1794(is)X -1871(line)X -2015(oriented.)X -2343(It)X -2417(is)X -2495(not)X -2622(an)X -2723(error)X -2905(to)X -2992(use)X -3124(the)X -3 f -3247($)X -1 f -3312(command)X -3653(as)X -3745(a)X -3806(motion)X -776 4272(component)N -1154(when)X -1350(the)X -1470(cursor)X -1693(is)X -1768(on)X -1870(the)X -1990(last)X -2123(character)X -2441(in)X -2525(the)X -2645(line,)X -2807(although)X -3109(it)X -3175(is)X -3249(an)X -3346(error)X -3524(when)X -3719(the)X -3838(line)X -3979(is)X -776 4362(empty.)N -776 4542(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(current)X -1706(line)X -1846(plus)X -7 f -1999(count)X -1 f -2259(minus)X -2474(1.)X -776 4632(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(in)X -1987(the)X -2105(line.)X -776 4722(Options:)N -1136(None.)X -3 f -576 4902(%)N -1 f -776 4992(Move)N -986(to)X -1071(the)X -1192(matching)X -1513(character.)X -1872(The)X -2020(cursor)X -2244(moves)X -2477(to)X -2563(the)X -2685(parenthesis)X -3070(or)X -3161(curly)X -3350(brace)X -3549(which)X -2 f -3769(matches)X -1 f -776 5082(the)N -900(parenthesis)X -1287(or)X -1380(curly)X -1570(brace)X -1770(found)X -1982(at)X -2065(the)X -2188(current)X -2441(cursor)X -2667(position)X -2949(or)X -3041(which)X -3262(is)X -3340(the)X -3463(closest)X -3706(one)X -3847(to)X -3934(the)X -776 5172(right)N -964(of)X -1068(the)X -1203(cursor)X -1441(on)X -1558(the)X -1693(line.)X -1890(It)X -1976(is)X -2066(an)X -2179(error)X -2373(to)X -2472(execute)X -2756(the)X -3 f -2892(%)X -1 f -3010(command)X -3364(on)X -3482(a)X -3556(line)X -3714(without)X -3996(a)X -776 5262(parenthesis)N -1157(or)X -1244(curly)X -1429(brace.)X -1664(Historically,)X -2082(any)X -7 f -2218(count)X -1 f -2478(speci\256ed)X -2783(to)X -2865(the)X -3 f -2983(%)X -1 f -3083(command)X -3419(was)X -3564(ignored.)X -776 5442(The)N -3 f -921(%)X -1 f -1021(command)X -1357(is)X -1430(an)X -1527(absolute)X -1815(movement.)X -2214(The)X -3 f -2360(%)X -1 f -2461(command)X -2798(may)X -2957(be)X -3054(used)X -3222(as)X -3310(the)X -3429(motion)X -3676(component)X -776 5532(of)N -871(other)X -3 f -1064(vi)X -1 f -1153(commands,)X -1547(in)X -1636(which)X -1859(case)X -2025(any)X -2168(text)X -2315(copied)X -2556(into)X -2707(a)X -2770(buffer)X -2994(is)X -3074(character)X -3397(oriented,)X -3707(unless)X -3934(the)X -776 5622(starting)N -1036(point)X -1220(of)X -1307(the)X -1425(region)X -1650(is)X -1723(at)X -1801(or)X -1888(before)X -2115(the)X -2234(\256rst)X -2379(nonblank)X -2698(character)X -3015(on)X -3116(its)X -3212(line,)X -3373(and)X -3510(the)X -3629(ending)X -3868(point)X -776 5712(is)N -849(at)X -927(or)X -1014(after)X -1182(the)X -1300(last)X -1431(nonblank)X -1749(character)X -2065(on)X -2165(its)X -2260(line,)X -2420(in)X -2502(which)X -2718(case)X -2877(it)X -2941(is)X -3014(line)X -3154(oriented.)X - -17 p -%%Page: 17 16 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Vi)X -1364(Commands\))X -3658(USD:13-17)X -1 f -776 762(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(containing)X -1956(the)X -2074(matching)X -2392(character.)X -776 852(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(matching)X -1776(character.)X -776 942(Options:)N -1136(None.)X -3 f -576 1122(&)N -1 f -776 1212(Repeat)N -1019(the)X -1137(previous)X -1433(substitution)X -1825(command)X -2161(on)X -2261(the)X -2379(current)X -2627(line.)X -776 1392(Historically,)N -1194(any)X -7 f -1330(count)X -1 f -1590(speci\256ed)X -1895(to)X -1977(the)X -3 f -2095(&)X -1 f -2182(command)X -2518(was)X -2663(ignored.)X -776 1572(Line:)N -1136(Unchanged.)X -776 1662(Column:)N -1136(Unchanged)X -1531(if)X -1609(the)X -1736(cursor)X -1966(was)X -2120(on)X -2229(the)X -2356(last)X -2496(character)X -2821(in)X -2912(the)X -3039(line,)X -3208(otherwise,)X -3569(set)X -3688(to)X -3780(the)X -3908(\256rst)X -1136 1752(nonblank)N -1454(character)X -1770(in)X -1852(the)X -1970(line.)X -776 1842(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(edcompatible)X -1 f -2114(,)X -3 f -2154(extended)X -1 f -2461(,)X -3 f -2501(ignorecase)X -1 f -2882(and)X -3 f -3018(magic)X -1 f -3243(options.)X -3 f -576 2022 0.3182(\302)AN -576 2112 0.3182(`)AN -1 f -776 2202(Return)N -1014(to)X -1096(a)X -1152(context)X -1408(marked)X -1669(by)X -1769(the)X -1888(character)X -7 f -2205()X -1 f -(.)S -2794(If)X -7 f -2869()X -1 f -3418(is)X -3492(the)X -3611(``)X -7 f -3665(')X -1 f -('')S -3788(or)X -3876(``)X -7 f -3930(`)X -1 f -('')S -776 2292(character,)N -1113(return)X -1326(to)X -1409(the)X -1528(previous)X -1825(context.)X -2122(If)X -7 f -2197()X -1 f -2746(is)X -2820(any)X -2956(other)X -3141(character,)X -3477(return)X -3689(to)X -3771(the)X -3889(con-)X -776 2382(text)N -921(marked)X -1187(by)X -1292(that)X -1437(character)X -1759(\(see)X -1915(the)X -3 f -2039(m)X -1 f -2132(command)X -2474(for)X -2594(more)X -2785(information\).)X -3256(If)X -3336(the)X -3460(command)X -3802(is)X -3881(the)X -3 f -4005(\302)X -1 f -776 2472(command,)N -1137(only)X -1304(the)X -1427(line)X -1572(value)X -1771(is)X -1848(restored,)X -2151(and)X -2291(the)X -2413(cursor)X -2638(is)X -2715(placed)X -2949(on)X -3053(the)X -3175(\256rst)X -3323(nonblank)X -3645(character)X -3965(of)X -776 2562(that)N -916(line.)X -1096(If)X -1170(the)X -1288(command)X -1624(is)X -1697(the)X -3 f -1815(`)X -1 f -1862(command,)X -2218(both)X -2380(the)X -2498(line)X -2638(and)X -2774(column)X -3034(values)X -3259(are)X -3378(restored.)X -776 2742(It)N -849(is)X -926(an)X -1026(error)X -1207(if)X -1280(the)X -1402(context)X -1662(no)X -1766(longer)X -1995(exists)X -2202(because)X -2482(of)X -2574(line)X -2719(deletion.)X -3042(\(Contexts)X -3378(follow)X -3612(lines)X -3788(that)X -3933(are)X -776 2832(moved,)N -1034(or)X -1121(which)X -1337(are)X -1456(deleted)X -1708(and)X -1844(then)X -2002(restored.\))X -776 3012(The)N -3 f -924(\302)X -1 f -974(and)X -3 f -1113(`)X -1 f -1163(commands)X -1533(are)X -1655(both)X -1820(absolute)X -2110(movements.)X -2542(They)X -2730(may)X -2891(be)X -2990(used)X -3160(as)X -3250(a)X -3309(motion)X -3558(component)X -3938(for)X -776 3102(other)N -3 f -962(vi)X -1 f -1045(commands.)X -1453(For)X -1585(the)X -3 f -1704(\302)X -1 f -1752(command,)X -2108(any)X -2244(text)X -2384(copied)X -2618(into)X -2762(a)X -2818(buffer)X -3035(is)X -3108(line)X -3248(oriented.)X -3571(For)X -3702(the)X -3 f -3820(`)X -1 f -3867(com-)X -776 3192(mand,)N -1002(any)X -1146(text)X -1294(copied)X -1536(into)X -1688(a)X -1752(buffer)X -1977(is)X -2058(character)X -2382(oriented,)X -2693(unless)X -2921(it)X -2993(both)X -3163(starts)X -3360(and)X -3504(stops)X -3696(at)X -3782(the)X -3908(\256rst)X -776 3282(character)N -1099(in)X -1188(the)X -1313(line,)X -1480(in)X -1569(which)X -1792(case)X -1958(it)X -2029(is)X -2109(line)X -2255(oriented.)X -2584(In)X -2677(addition,)X -2985(when)X -3185(using)X -3384(the)X -3 f -3508(`)X -1 f -3561(command)X -3903(as)X -3996(a)X -776 3372(motion)N -1025(component,)X -1424(commands)X -1794(which)X -2013(move)X -2214(backward)X -2550(and)X -2689(started)X -2926(at)X -3007(the)X -3128(\256rst)X -3275(character)X -3594(in)X -3679(the)X -3801(line,)X -3965(or)X -776 3462(move)N -983(forward)X -1267(and)X -1412(ended)X -1633(at)X -1719(the)X -1845(\256rst)X -1997(character)X -2321(in)X -2411(the)X -2537(line,)X -2705(are)X -2832(corrected)X -3160(to)X -3250(the)X -3376(last)X -3515(character)X -3839(of)X -3934(the)X -776 3552(starting)N -1036(and)X -1172(ending)X -1410(lines,)X -1601(respectively.)X -776 3732(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(from)X -1774(the)X -1892(context.)X -776 3822(Column:)N -1136(Set)X -1261(to)X -1346(the)X -1467(\256rst)X -1614(nonblank)X -1935(character)X -2254(in)X -2340(the)X -2462(line,)X -2626(for)X -2744(the)X -3 f -2866(\302)X -1 f -2917(command,)X -3277(and)X -3417(set)X -3530(to)X -3616(the)X -3738(context's)X -1136 3912(column)N -1396(for)X -1510(the)X -3 f -1628(`)X -1 f -1675(command.)X -776 4002(Options:)N -1136(None.)X -3 f -576 4182([count])N -841(\()X -1 f -776 4272(Back)N -961(up)X -7 f -1061(count)X -1 f -1321(sentences.)X -776 4452(The)N -3 f -922(\()X -1 f -970(command)X -1307(is)X -1382(an)X -1480(absolute)X -1769(movement.)X -2169(The)X -3 f -2316(\()X -1 f -2365(command)X -2703(may)X -2863(be)X -2961(used)X -3130(as)X -3219(the)X -3339(motion)X -3587(component)X -3965(of)X -776 4542(other)N -3 f -963(vi)X -1 f -1047(commands,)X -1436(in)X -1520(which)X -1738(case)X -1899(any)X -2036(text)X -2177(copied)X -2412(into)X -2557(a)X -2614(buffer)X -2832(is)X -2906(character)X -3223(oriented,)X -3527(unless)X -3748(the)X -3867(start-)X -776 4632(ing)N -913(and)X -1064(stopping)X -1374(points)X -1604(of)X -1706(the)X -1839(region)X -2079(are)X -2213(the)X -2346(\256rst)X -2505(character)X -2836(in)X -2933(the)X -3066(line,)X -3241(in)X -3338(which)X -3569(case)X -3743(it)X -3823(is)X -3912(line)X -776 4722(oriented.)N -1111(In)X -1210(the)X -1340(latter)X -1537(case,)X -1728(the)X -1858(stopping)X -2165(point)X -2361(of)X -2460(the)X -2590(region)X -2827(is)X -2911(adjusted)X -3209(to)X -3302(be)X -3409(the)X -3538(end)X -3685(of)X -3783(the)X -3912(line)X -776 4812(immediately)N -1196(before)X -1422(it,)X -1506(and)X -1642(not)X -1764(the)X -1882(original)X -2151(cursor)X -2372(position.)X -776 4992(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(containing)X -1956(the)X -2074(beginning)X -2414(of)X -2501(the)X -2619(sentence.)X -776 5082(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(of)X -2323(the)X -2441(sentence.)X -776 5172(Options:)N -1136(None.)X -3 f -576 5352([count])N -841(\))X -1 f -776 5442(Move)N -983(forward)X -7 f -1258(count)X -1 f -1518(sentences.)X -776 5622(The)N -3 f -922(\))X -1 f -970(command)X -1307(is)X -1382(an)X -1480(absolute)X -1769(movement.)X -2169(The)X -3 f -2316(\))X -1 f -2365(command)X -2703(may)X -2863(be)X -2961(used)X -3130(as)X -3219(the)X -3339(motion)X -3587(component)X -3965(of)X -776 5712(other)N -3 f -963(vi)X -1 f -1047(commands,)X -1436(in)X -1520(which)X -1738(case)X -1899(any)X -2036(text)X -2177(copied)X -2412(into)X -2557(a)X -2614(buffer)X -2832(is)X -2906(character)X -3223(oriented,)X -3527(unless)X -3748(the)X -3867(start-)X -776 5802(ing)N -901(point)X -1088(of)X -1179(the)X -1301(region)X -1530(is)X -1607(the)X -1729(\256rst)X -1877(character)X -2197(in)X -2283(the)X -2405(line,)X -2569(in)X -2655(which)X -2875(case)X -3038(it)X -3106(is)X -3183(line)X -3327(oriented.)X -3654(In)X -3745(the)X -3867(latter)X - -18 p -%%Page: 18 17 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-18)N -2826(Nvi/Nex)X -3122 0.3906(Reference)AX -3487(\(Vi)X -3614(Commands\))X -1 f -776 762(case,)N -961(if)X -1036(the)X -1160(stopping)X -1461(point)X -1651(of)X -1744(the)X -1868(region)X -2099(is)X -2178(also)X -2333(the)X -2457(\256rst)X -2607(character)X -2929(in)X -3017(the)X -3141(line,)X -3307(it)X -3376(is)X -3454(adjusted)X -3746(to)X -3833(be)X -3934(the)X -776 852(end)N -912(of)X -999(the)X -1117(line)X -1257(immediately)X -1677(before)X -1903(it.)X -776 1032(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(containing)X -1956(the)X -2074(beginning)X -2414(of)X -2501(the)X -2619(sentence.)X -776 1122(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(of)X -2323(the)X -2441(sentence.)X -776 1212(Options:)N -1136(None.)X -3 f -576 1392([count])N -841(,)X -1 f -776 1482(Reverse)N -1055(\256nd)X -1199(character)X -7 f -1515(count)X -1 f -1775(times.)X -2008(Reverse)X -2288(the)X -2407(last)X -3 f -2539(F)X -1 f -2588(,)X -3 f -2629(f)X -1 f -2656(,)X -3 f -2697(T)X -1 f -2771(or)X -3 f -2859(t)X -1 f -2907(command,)X -3264(searching)X -3593(the)X -3712(other)X -3898(way)X -776 1572(in)N -858(the)X -976(line,)X -7 f -1136(count)X -1 f -1396(times.)X -776 1752(The)N -3 f -922(,)X -1 f -963(command)X -1300(may)X -1460(be)X -1558(used)X -1727(as)X -1816(the)X -1936(motion)X -2184(component)X -2562(of)X -2651(other)X -3 f -2838(vi)X -1 f -2922(commands,)X -3311(in)X -3395(which)X -3613(case)X -3774(any)X -3912(text)X -776 1842(copied)N -1010(into)X -1154(a)X -1210(buffer)X -1427(is)X -1500(character)X -1816(oriented.)X -776 2022(Line:)N -1136(Unchanged.)X -776 2112(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458 0.3068(searched-for)AX -1881(character.)X -776 2202(Options:)N -1136(None.)X -3 f -576 2382([count])N -9 f -841(-)X -843(-)X -1 f -776 2472(Move)N -983(to)X -1065(\256rst)X -1209(nonblank)X -1527(of)X -1614(the)X -1732(previous)X -2028(line,)X -7 f -2188(count)X -1 f -2448(times.)X -776 2652(This)N -938(is)X -1011(an)X -1107(error)X -1284(if)X -1353(the)X -1471(movement)X -1829(is)X -1902(past)X -2051(the)X -2169(beginning)X -2509(of)X -2596(the)X -2714(\256le.)X -776 2832(The)N -3 f -922(-)X -1 f -970(command)X -1307(may)X -1466(be)X -1563(used)X -1731(as)X -1819(the)X -1938(motion)X -2185(component)X -2562(of)X -2651(other)X -3 f -2838(vi)X -1 f -2922(commands,)X -3311(in)X -3395(which)X -3613(case)X -3774(any)X -3912(text)X -776 2922(copied)N -1010(into)X -1154(a)X -1210(buffer)X -1427(is)X -1500(line)X -1640(oriented.)X -776 3102(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(current)X -1706(line)X -1846(minus)X -7 f -2061(count)X -1 f -(.)S -776 3192(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(in)X -2318(the)X -2436(line.)X -776 3282(Options:)N -1136(None.)X -3 f -576 3462([count])N -841(.)X -1 f -776 3552(Repeat)N -1031(the)X -1161(last)X -3 f -1304(vi)X -1 f -1398(command)X -1746(that)X -1898(modi\256ed)X -2214(text.)X -2406(The)X -2563(repeated)X -2869(command)X -3218(may)X -3389(be)X -3498(a)X -3567(command)X -3916(and)X -776 3642(motion)N -1030(component)X -1413(combination.)X -1880(If)X -7 f -1961(count)X -1 f -2228(is)X -2308(speci\256ed,)X -2640(it)X -2711(replaces)X -2 f -3002(both)X -1 f -3171(the)X -3296(count)X -3501(speci\256ed)X -3813(for)X -3934(the)X -776 3732(repeated)N -1093(command,)X -1473(and,)X -1653(if)X -1746(applicable,)X -2140(for)X -2278(the)X -2420(repeated)X -2737(motion)X -3007(component.)X -3448(If)X -7 f -3547(count)X -1 f -3832(is)X -3930(not)X -776 3822(speci\256ed,)N -1101(the)X -1219(counts)X -1448(originally)X -1779(speci\256ed)X -2084(to)X -2166(the)X -2284(command)X -2620(being)X -2818(repeated)X -3111(are)X -3230(used)X -3397(again.)X -776 4002(As)N -887(a)X -945(special)X -1190(case,)X -1371(if)X -1442(the)X -3 f -1562(.)X -1 f -1624(command)X -1962(is)X -2037(executed)X -2345(immediately)X -2767(after)X -2937(the)X -3 f -3057(u)X -1 f -3123(command,)X -3482(the)X -3603(change)X -3854(log)X -3979(is)X -776 4092(rolled)N -983(forward)X -1258(or)X -1345(backward,)X -1698(depending)X -2052(on)X -2152(the)X -2270(action)X -2486(of)X -2573(the)X -3 f -2691(u)X -1 f -2755(command.)X -776 4272(Line:)N -1136(Set)X -1258(as)X -1345(described)X -1673(for)X -1787(the)X -1905(repeated)X -2198(command.)X -776 4362(Column:)N -1136(Set)X -1258(as)X -1345(described)X -1673(for)X -1787(the)X -1905(repeated)X -2198(command.)X -776 4452(Options:)N -1136(None.)X -3 f -576 4632 0.1776(/RE)AN -576 4722(/RE/)N -751 0.2500([offset])AX -576 4812 0.1908(?RE)AN -576 4902(?RE?)N -787 0.2500([offset])AX -576 4992(N)N -576 5082(n)N -1 f -776 5172(Search)N -1017(forward)X -1295(or)X -1385(backward)X -1721(for)X -1838(a)X -1897(regular)X -2148(expression.)X -2554(The)X -2702(commands)X -3072(beginning)X -3415(with)X -3580(a)X -3639(slash)X -3822(\(``)X -7 f -3903(/)X -1 f -(''\))S -776 5262(character)N -1095(are)X -1217(forward)X -1495(searches,)X -1811(the)X -1932(commands)X -2302(beginning)X -2644(with)X -2808(a)X -2866(question)X -3159(mark)X -3346(\(``)X -7 f -3427(?)X -1 f -(''\))S -3598(are)X -3719(backward)X -776 5352(searches.)N -3 f -1117(Vi)X -1 f -1225(prompts)X -1515(with)X -1685(the)X -1811(leading)X -2075(character)X -2399(on)X -2507(the)X -2633(last)X -2772(line)X -2920(of)X -3015(the)X -3142(screen)X -3377(for)X -3500(a)X -3565(string.)X -3816(It)X -3894(then)X -776 5442(searches)N -1071(forward)X -1348(or)X -1437(backward)X -1772(in)X -1856(the)X -1976(\256le)X -2100(for)X -2216(the)X -2336(next)X -2496 0.3611(occurrence)AX -2872(of)X -2961(the)X -3081(string,)X -3305(which)X -3522(is)X -3596(interpreted)X -3965(as)X -776 5532(a)N -832(Basic)X -1030(Regular)X -1304(Expression.)X -776 5712(The)N -3 f -928(/)X -1 f -977(and)X -3 f -1120(?)X -1 f -1207(commands)X -1581(are)X -1707(absolute)X -2001(movements.)X -2437(They)X -2630(may)X -2796(be)X -2900(used)X -3075(as)X -3170(the)X -3296(motion)X -3550(components)X -3965(of)X -776 5802(other)N -3 f -974(vi)X -1 f -1069(commands,)X -1469(in)X -1564(which)X -1793(case)X -1965(any)X -2114(text)X -2267(copied)X -2514(into)X -2671(a)X -2740(buffer)X -2970(is)X -3056(character)X -3385(oriented,)X -3701(unless)X -3934(the)X - -19 p -%%Page: 19 18 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Vi)X -1364(Commands\))X -3658(USD:13-19)X -1 f -776 762(search)N -1007(started)X -1246(and)X -1387(ended)X -1604(on)X -1709(the)X -1832(\256rst)X -1981(column)X -2246(of)X -2338(a)X -2399(line,)X -2564(in)X -2651(which)X -2872(case)X -3036(it)X -3105(is)X -3183(line)X -3328(oriented.)X -3657(In)X -3750(addition,)X -776 852(forward)N -1056(searches)X -1354(ending)X -1597(at)X -1680(the)X -1803(\256rst)X -1951(character)X -2271(of)X -2362(a)X -2422(line,)X -2586(and)X -2726(backward)X -3063(searches)X -3360(beginning)X -3704(at)X -3786(the)X -3908(\256rst)X -776 942(character)N -1098(in)X -1186(the)X -1310(line,)X -1476(are)X -1601(corrected)X -1927(to)X -2015(begin)X -2219(or)X -2312(end)X -2454(at)X -2538(the)X -2662(last)X -2799(character)X -3121(of)X -3214(the)X -3339(previous)X -3642(line.)X -3829(\(Note,)X -776 1032(forward)N -1061(and)X -1207(backward)X -1550(searches)X -1853(can)X -1995(occur)X -2204(for)X -2328(both)X -3 f -2500(/)X -1 f -2552(and)X -3 f -2698(?)X -1 f -2787(commands,)X -3183(if)X -3261(the)X -3 f -3388(wrapscan)X -1 f -3746(option)X -3979(is)X -776 1122(set.\))N -776 1302(If)N -852(an)X -950(offset)X -1155(from)X -1333(the)X -1453(matched)X -1747(line)X -1889(is)X -1964(speci\256ed)X -2271(\(i.e.)X -2418(a)X -2476(trailing)X -2729(``)X -7 f -2783(/)X -1 f -('')S -2907(or)X -2996(``)X -7 f -3050(?)X -1 f -('')S -3194(character)X -3512(is)X -3587(followed)X -3894(by)X -3996(a)X -776 1392(signed)N -1009(offset\),)X -1263(the)X -1385(buffer)X -1606(will)X -1754(always)X -2001(be)X -2100(line)X -2243(oriented)X -2529(\(e.g.)X -2715(``)X -7 f -2769(/string/+0)X -1 f -('')S -3326(will)X -3473(always)X -3719(guarantee)X -776 1482(a)N -832(line)X -972(orientation\).)X -776 1662(The)N -3 f -921(n)X -1 f -985(command)X -1321(repeats)X -1569(the)X -1687(previous)X -1983(search.)X -776 1842(The)N -3 f -921(N)X -1 f -999(command)X -1335(repeats)X -1583(the)X -1701(previous)X -1997(search,)X -2243(but)X -2365(in)X -2447(the)X -2565(reverse)X -2818(direction.)X -776 2022(Missing)N -1194(RE's)X -1515(\(e.g.)X -1839(``)X -7 f -1893(//)X -1 f -('',)S -3040(``)X -7 f -3094(/)X -1 f -('',)S -776 2112(``)N -7 f -830(??)X -1 f -('',)S -1847(or)X -1945(``)X -7 f -1999(?)X -1 f -('')S -2948(search)X -3185(for)X -3310(the)X -3439(last)X -3581(search)X -3818(RE,)X -3970(in)X -776 2202(the)N -894(indicated)X -1208(direction.)X -776 2382(Searches)N -1082(may)X -1240(be)X -1336(interrupted)X -1708(using)X -1901(the)X -7 f -2019()X -1 f -2567(character.)X -776 2562(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(in)X -1680(which)X -1896(the)X -2014(match)X -2230(occurred.)X -776 2652(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(character)X -1918(of)X -2005(the)X -2123(matched)X -2415(string.)X -776 2742(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(edcompatible)X -1 f -2114(,)X -3 f -2154(extended)X -1 f -2461(,)X -3 f -2501(ignorecase)X -1 f -2862(,)X -3 f -2902(magic)X -1 f -3107(,)X -3147(and)X -3 f -3283(wrapscan)X -1 f -3632(options.)X -3 f -576 2922(0)N -1 f -776 3012(Move)N -985(to)X -1069(the)X -1189(\256rst)X -1335(character)X -1654(in)X -1739(the)X -1860(current)X -2111(line.)X -2294(It)X -2366(is)X -2442(not)X -2567(an)X -2666(error)X -2846(to)X -2931(use)X -3061(the)X -3 f -3182(0)X -1 f -3245(command)X -3584(when)X -3781(the)X -3902(cur-)X -776 3102(sor)N -894(is)X -967(on)X -1067(the)X -1185(\256rst)X -1329(character)X -1645(in)X -1727(the)X -1845(line,)X -776 3282(The)N -3 f -923(0)X -1 f -986(command)X -1325(may)X -1486(be)X -1585(used)X -1755(as)X -1845(the)X -1966(motion)X -2215(component)X -2594(of)X -2684(other)X -3 f -2872(vi)X -1 f -2957(commands,)X -3347(in)X -3432(which)X -3651(case)X -3813(it)X -3880(is)X -3956(an)X -776 3372(error)N -953(if)X -1022(the)X -1140(cursor)X -1361(is)X -1434(on)X -1534(the)X -1652(\256rst)X -1796(character)X -2112(in)X -2194(the)X -2312(line.)X -776 3552(Line:)N -1136(Unchanged.)X -776 3642(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(character)X -1918(in)X -2000(the)X -2118(line.)X -776 3732(Options:)N -1136(None.)X -3 f -576 3912(:)N -1 f -776 4002(Execute)N -1055(an)X -1152(ex)X -1249(command.)X -3 f -1626(Vi)X -1 f -1727(prompts)X -2010(for)X -2125(an)X -3 f -2222(ex)X -1 f -2319(command)X -2656(on)X -2757(the)X -2876(last)X -3008(line)X -3149(of)X -3237(the)X -3356(screen,)X -3603(using)X -3797(a)X -3854(colon)X -776 4092(\(``)N -7 f -857(:)X -1 f -(''\))S -1029(character.)X -1408(The)X -1575(command)X -1933(is)X -2028(terminated)X -2413(by)X -2535(a)X -7 f -2613()X -1 f -(,)S -7 f -3491()X -1 f -3965(or)X -7 f -776 4182()N -1 f -1184(character;)X -1526(all)X -1630(of)X -1721(these)X -1910(characters)X -2261(may)X -2423(be)X -2523(escaped)X -2802(by)X -2906(using)X -3103(a)X -7 f -3164()X -1 f -3866(char-)X -776 4272(acter.)N -993(The)X -1138(command)X -1474(is)X -1547(then)X -1705(executed.)X -776 4452(If)N -850(the)X -3 f -968(ex)X -1 f -1064(command)X -1400(writes)X -1616(to)X -1698(the)X -1816(screen,)X -3 f -2063(vi)X -1 f -2146(will)X -2291(prompt)X -2543(the)X -2662(user)X -2817(for)X -2932(a)X -7 f -2989()X -1 f -3826(before)X -776 4542(continuing)N -1144(when)X -1344(the)X -3 f -1468(ex)X -1 f -1570(command)X -1912(\256nishes.)X -2222(Large)X -2436(amounts)X -2733(of)X -2826(output)X -3056(from)X -3238(the)X -3 f -3362(ex)X -1 f -3464(command)X -3806(will)X -3956(be)X -776 4632(paged)N -994(for)X -1114(the)X -1238(user,)X -1418(and)X -1560(the)X -1684(user)X -1844(prompted)X -2177(for)X -2297(a)X -7 f -2359()X -1 f -3201(or)X -7 f -3294()X -1 f -3657(key)X -3800(to)X -3889(con-)X -776 4722(tinue.)N -999(In)X -1089(some)X -1281(cases,)X -1494(a)X -1553(quit)X -1700(\(normally)X -2039(a)X -2098(``q'')X -2269 0.3750(character\))AX -2615(or)X -7 f -2705()X -1 f -3256(may)X -3417(be)X -3515(entered)X -3774(to)X -3858(inter-)X -776 4812(rupt)N -925(the)X -3 f -1043(ex)X -1 f -1139(command.)X -776 4992(When)N -988(the)X -3 f -1106(ex)X -1 f -1202(command)X -1538(\256nishes,)X -1822(and)X -1958(the)X -2076(user)X -2230(is)X -2303(prompted)X -2631(to)X -2714(resume)X -2967(visual)X -3179(mode,)X -3398(it)X -3463(is)X -3537(also)X -3687(possible)X -3970(to)X -776 5082(enter)N -957(another)X -1218(``)X -7 f -1272(:)X -1 f -('')S -1394(character)X -1710(followed)X -2015(by)X -2115(another)X -3 f -2376(ex)X -1 f -2472(command.)X -776 5262(Line:)N -1136(The)X -1281(current)X -1529(line)X -1669(is)X -1742(set)X -1851(as)X -1938(described)X -2266(for)X -2380(the)X -3 f -2498(ex)X -1 f -2594(command.)X -776 5352(Column:)N -1136(The)X -1281(current)X -1529(column)X -1789(is)X -1862(set)X -1971(as)X -2058(described)X -2386(for)X -2500(the)X -3 f -2618(ex)X -1 f -2714(command.)X -776 5442(Options:)N -1136(None.)X -3 f -576 5622([count])N -841(;)X -1 f -776 5712(Repeat)N -1025(the)X -1149(last)X -1286(character)X -1608(\256nd)X -7 f -1758(count)X -1 f -2024(times.)X -2263(The)X -2415(last)X -2553(character)X -2876(\256nd)X -3027(is)X -3107(one)X -3250(of)X -3344(the)X -3 f -3469(F)X -1 f -3518(,)X -3 f -3565(f)X -1 f -3592(,)X -3 f -3639(T)X -1 f -3719(or)X -3 f -3813(t)X -1 f -3867(com-)X -776 5802(mands.)N - -20 p -%%Page: 20 19 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-20)N -2826(Nvi/Nex)X -3122 0.3906(Reference)AX -3487(\(Vi)X -3614(Commands\))X -1 f -776 762(The)N -3 f -922(;)X -1 f -970(command)X -1307(may)X -1466(be)X -1563(used)X -1731(as)X -1819(the)X -1938(motion)X -2185(component)X -2562(of)X -2651(other)X -3 f -2838(vi)X -1 f -2922(commands,)X -3311(in)X -3395(which)X -3613(case)X -3774(any)X -3912(text)X -776 852(copied)N -1010(into)X -1154(a)X -1210(buffer)X -1427(is)X -1500(character)X -1816(oriented.)X -776 1032(Line:)N -1136(Unchanged.)X -776 1122(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458 0.3068(searched-for)AX -1881(character.)X -776 1212(Options:)N -1136(None.)X -3 f -576 1392([count])N -841(<)X -907(motion)X -576 1482([count])N -841(>)X -907(motion)X -1 f -776 1572(Shift)N -956(lines)X -1132(left)X -1264(or)X -1357(right.)X -1574(Shift)X -1755(the)X -1879(number)X -2150(of)X -2243(lines)X -2420(in)X -2508(the)X -2632(region)X -2863(speci\256ed)X -3174(by)X -3280(the)X -3404(motion)X -3656(component,)X -776 1662(times)N -7 f -980(count)X -1 f -(,)S -1271(left)X -1409(\(for)X -1561(the)X -3 f -1690(<)X -1 f -1767(command\))X -2141(or)X -2239(right)X -2421(\(for)X -2573(the)X -3 f -2702(>)X -1 f -2778(command\))X -3151(by)X -3261(the)X -3389(number)X -3664(of)X -3761(columns)X -776 1752(speci\256ed)N -1086(by)X -1191(the)X -3 f -1314(shiftwidth)X -1 f -1685(option.)X -1954(Only)X -2139(whitespace)X -2521(characters)X -2873(are)X -2997(deleted)X -3255(when)X -3455(shifting)X -3725(left;)X -3880(once)X -776 1842(the)N -901(\256rst)X -1052(character)X -1375(in)X -1464(the)X -1589(line)X -1736(contains)X -2030(a)X -2092(nonblank)X -2416(character,)X -2758(the)X -3 f -2882(shift)X -1 f -3059(will)X -3209(succeed,)X -3510(but)X -3638(the)X -3762(line)X -3908(will)X -776 1932(not)N -898(be)X -994(modi\256ed.)X -776 2112(Line:)N -1136(Unchanged.)X -776 2202(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(in)X -2318(the)X -2436(line.)X -776 2292(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(shiftwidth)X -1 f -2022(option.)X -3 f -576 2472(@)N -670(buffer)X -1 f -776 2562(Execute)N -1065(a)X -1131(named)X -1375(buffer.)X -1642(Execute)X -1931(the)X -2059(named)X -2303(buffer)X -2530(as)X -3 f -2627(vi)X -1 f -2719(commands.)X -3136(The)X -3292(buffer)X -3520(may)X -3689(include)X -3 f -3956(ex)X -1 f -776 2652(commands,)N -1170(too,)X -1319(but)X -1448(they)X -1613(must)X -1795(be)X -1898(expressed)X -2241(as)X -2334(a)X -3 f -2396(:)X -1 f -2449(command.)X -2831(If)X -2911(the)X -3035(buffer)X -3258(is)X -3337(line)X -3483(oriented,)X -7 f -3792()N -1 f -1054(characters)X -1419(are)X -1556(logically)X -1874(appended)X -2220(to)X -2320(each)X -2506(line)X -2664(of)X -2769(the)X -2905(buffer.)X -3180(If)X -3272(the)X -3408(buffer)X -3644(is)X -3736(character)X -776 2832(oriented,)N -7 f -1079()X -1 f -1531(characters)X -1878(are)X -1997(logically)X -2297(appended)X -2625(to)X -2707(all)X -2807(but)X -2929(the)X -3047(last)X -3178(line)X -3318(in)X -3400(the)X -3518(buffer.)X -776 3012(If)N -861(the)X -990(buffer)X -1218(name)X -1423(is)X -1507(``)X -7 f -1561(@)X -1 f -('',)S -1714(or)X -1812(``)X -7 f -1866(*)X -1 f -('',)S -2019(then)X -2188(the)X -2317(last)X -2459(buffer)X -2687(executed)X -3004(shall)X -3186(be)X -3293(used.)X -3511(It)X -3591(is)X -3675(an)X -3782(error)X -3970(to)X -776 3102(specify)N -1033(``)X -7 f -1087(@@)X -1 f -('')S -1262(or)X -1354(``)X -7 f -1408(**)X -1 f -('')S -1583(if)X -1657(there)X -1843(were)X -2025(no)X -2130(buffer)X -2351(previous)X -2651(executions.)X -3058(The)X -3207(text)X -3351(of)X -3442(a)X -3502(macro)X -3727(may)X -3889(con-)X -776 3192(tain)N -919(an)X -3 f -1019(@)X -1 f -1117(command,)X -1477(and)X -1617(it)X -1685(is)X -1762(possible)X -2048(to)X -2134(create)X -2351(in\256nite)X -2601(loops)X -2798(in)X -2884(this)X -3023(manner.)X -3328(\(The)X -7 f -3504()X -1 f -776 3282(character)N -1092(may)X -1250(be)X -1346(used)X -1513(to)X -1595(interrupt)X -1891(the)X -2009(loop.\))X -776 3462(Line:)N -1136(The)X -1281(current)X -1529(line)X -1669(is)X -1742(set)X -1851(as)X -1938(described)X -2266(for)X -2380(the)X -2498(command\(s\).)X -776 3552(Column:)N -1136(The)X -1281(current)X -1529(column)X -1789(is)X -1862(set)X -1971(as)X -2058(described)X -2386(for)X -2500(the)X -2618(command\(s\).)X -776 3642(Options:)N -1136(None.)X -3 f -576 3822([count])N -841(A)X -1 f -776 3912(Enter)N -981(input)X -1176(mode,)X -1405(appending)X -1770(the)X -1899(text)X -2050(after)X -2229(the)X -2358(end)X -2505(of)X -2603(the)X -2732(line.)X -2923(If)X -7 f -3008(count)X -1 f -3279(is)X -3363(speci\256ed,)X -3699(the)X -3828(text)X -3979(is)X -776 4002(repeatedly)N -1131(input)X -7 f -1315(count)X -1603(-)X -1699(1)X -1 f -1767(more)X -1952(times)X -2145(after)X -2313(input)X -2497(mode)X -2695(is)X -2768(exited.)X -776 4182(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(line)X -1729(upon)X -1909(which)X -2125(characters)X -2472(were)X -2649(entered.)X -776 4272(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(entered.)X -776 4362(Options:)N -1136(Affected)X -1440(by)X -1542(the)X -3 f -1662(altwerase)X -1 f -1988(,)X -3 f -2030(autoindent)X -1 f -2398(,)X -3 f -2440(beautify)X -1 f -(,)S -3 f -2762(showmatch)X -1 f -3149(,)X -3 f -3191(ttywerase)X -1 f -3545(and)X -3 f -3684(wrapmar-)X -1136 4452(gin)N -1 f -1262(options.)X -3 f -576 4632([count])N -841(B)X -1 f -776 4722(Move)N -995(backward)X -7 f -1340(count)X -1 f -1612(bigwords.)X -1982(Move)X -2201(the)X -2331(cursor)X -2564(backward)X -2909(to)X -3003(the)X -3133(beginning)X -3485(of)X -3584(a)X -3652(bigword)X -3952(by)X -776 4812(repeating)N -1096(the)X -1215(following)X -1547(algorithm:)X -1901(if)X -1971(the)X -2090(current)X -2339(position)X -2617(is)X -2691(at)X -2770(the)X -2889(beginning)X -3230(of)X -3318(a)X -3374(bigword)X -3661(or)X -3748(the)X -3866(char-)X -776 4902(acter)N -955(at)X -1036(the)X -1157(current)X -1408(position)X -1688(cannot)X -1925(be)X -2024(part)X -2172(of)X -2262(a)X -2321(bigword,)X -2631(move)X -2832(to)X -2917(the)X -3038(\256rst)X -3185(character)X -3504(of)X -3594(the)X -3715(preceding)X -776 4992(bigword.)N -1105(Otherwise,)X -1477(move)X -1677(to)X -1761(the)X -1881(\256rst)X -2027(character)X -2345(of)X -2434(the)X -2554(bigword)X -2843(at)X -2923(the)X -3043(current)X -3293(position.)X -3612(If)X -3688(no)X -3790(preced-)X -776 5082(ing)N -908(bigword)X -1205(exists)X -1418(on)X -1529(the)X -1658(current)X -1917(line,)X -2088(move)X -2297(to)X -2390(the)X -2519(\256rst)X -2674(character)X -3001(of)X -3099(the)X -3228(last)X -3370(bigword)X -3668(on)X -3779(the)X -3908(\256rst)X -776 5172(preceding)N -1113(line)X -1253(that)X -1393(contains)X -1680(a)X -1736(bigword.)X -776 5352(The)N -3 f -921(B)X -1 f -994(command)X -1330(may)X -1488(be)X -1584(used)X -1751(as)X -1838(the)X -1956(motion)X -2202(component)X -2578(of)X -2665(other)X -3 f -2850(vi)X -1 f -2932(commands,)X -3319(in)X -3401(which)X -3617(case)X -3776(any)X -3912(text)X -776 5442(copied)N -1010(into)X -1154(a)X -1210(buffer)X -1427(is)X -1500(character)X -1816(oriented.)X -776 5622(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(containing)X -1956(the)X -2074(word)X -2259(selected.)X -776 5712(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(character)X -1918(of)X -2005(the)X -2123(word)X -2308(selected.)X - -21 p -%%Page: 21 20 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Vi)X -1364(Commands\))X -3658(USD:13-21)X -1 f -776 762(Options:)N -1136(None.)X -3 f -576 942([buffer])N -864([count])X -1129(C)X -1 f -776 1032(Change)N -1058(text)X -1215(from)X -1408(the)X -1543(current)X -1808(position)X -2102(to)X -2201(the)X -2336(end-of-line.)X -2770(If)X -7 f -2862(count)X -1 f -3140(is)X -3231(speci\256ed,)X -3574(the)X -3710(input)X -3912(text)X -776 1122(replaces)N -1060(from)X -1236(the)X -1354(current)X -1602(position)X -1879(to)X -1961(the)X -2079(end-of-line,)X -2476(plus)X -7 f -2629(count)X -2917(-)X -3013(1)X -1 f -3081(subsequent)X -3457(lines.)X -776 1302(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(line)X -1729(upon)X -1909(which)X -2125(characters)X -2472(were)X -2649(entered.)X -776 1392(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(entered.)X -776 1482(Options:)N -1136(Affected)X -1440(by)X -1542(the)X -3 f -1662(altwerase)X -1 f -1988(,)X -3 f -2030(autoindent)X -1 f -2398(,)X -3 f -2440(beautify)X -1 f -(,)S -3 f -2762(showmatch)X -1 f -3149(,)X -3 f -3191(ttywerase)X -1 f -3545(and)X -3 f -3684(wrapmar-)X -1136 1572(gin)N -1 f -1262(options.)X -3 f -576 1752([buffer])N -864(D)X -1 f -776 1842(Delete)N -1006(text)X -1146(from)X -1322(the)X -1440(current)X -1688(position)X -1965(to)X -2047(the)X -2165(end-of-line.)X -776 2022(It)N -845(is)X -918(not)X -1040(an)X -1136(error)X -1313(to)X -1395(execute)X -1661(the)X -3 f -1779(D)X -1 f -1857(command)X -2193(on)X -2293(an)X -2389(empty)X -2609(line.)X -776 2202(Line:)N -1136(Unchanged.)X -776 2292(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(character)X -1774(before)X -2000(the)X -2118(current)X -2367(character,)X -2704(or,)X -2812(column)X -3073(1)X -3134(if)X -3204(the)X -3323(cursor)X -3545(was)X -3691(on)X -3792(column)X -1136 2382(1.)N -776 2472(Options:)N -1136(None.)X -3 f -576 2652([count])N -841(E)X -1 f -776 2742(Move)N -983(forward)X -7 f -1258(count)X -1 f -1518(end-of-bigwords.)X -2113(Move)X -2320(the)X -2438(cursor)X -2659(forward)X -2935(to)X -3018(the)X -3137(end)X -3274(of)X -3362(a)X -3419(bigword)X -3707(by)X -3808(repeat-)X -776 2832(ing)N -906(the)X -1032(following)X -1371(algorithm:)X -1732(if)X -1809(the)X -1935(current)X -2191(position)X -2476(is)X -2557(the)X -2683(end)X -2827(of)X -2922(a)X -2986(bigword)X -3281(or)X -3376(the)X -3502(character)X -3826(at)X -3912(that)X -776 2922(position)N -1061(cannot)X -1303(be)X -1407(part)X -1560(of)X -1655(a)X -1719(bigword,)X -2034(move)X -2240(to)X -2331(the)X -2458(last)X -2598(character)X -2923(of)X -3019(the)X -3146(following)X -3486(bigword.)X -3822(Other-)X -776 3012(wise,)N -973(move)X -1181(to)X -1273(the)X -1401(last)X -1542(character)X -1868(of)X -1965(the)X -2093(bigword)X -2390(at)X -2477(the)X -2604(current)X -2861(position.)X -3187(If)X -3270(no)X -3379(succeeding)X -3765(bigword)X -776 3102(exists)N -984(on)X -1090(the)X -1214(current)X -1468(line,)X -1634(move)X -1838(to)X -1927(the)X -2052(last)X -2190(character)X -2513(of)X -2607(the)X -2732(\256rst)X -2883(bigword)X -3177(on)X -3284(the)X -3409(next)X -3574(following)X -3912(line)X -776 3192(that)N -916(contains)X -1203(a)X -1259(bigword.)X -776 3372(The)N -3 f -921(E)X -1 f -994(command)X -1330(may)X -1488(be)X -1584(used)X -1751(as)X -1838(the)X -1956(motion)X -2202(component)X -2578(of)X -2665(other)X -3 f -2850(vi)X -1 f -2932(commands,)X -3319(in)X -3401(which)X -3617(case)X -3776(any)X -3912(text)X -776 3462(copied)N -1010(into)X -1154(a)X -1210(buffer)X -1427(is)X -1500(character)X -1816(oriented.)X -776 3642(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(containing)X -1956(the)X -2074(word)X -2259(selected.)X -776 3732(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(of)X -1992(the)X -2110(word)X -2295(selected.)X -776 3822(Options:)N -1136(None.)X -3 f -576 4002([count])N -841(F)X -910 0.3125()AX -1 f -776 4092(Search)N -7 f -1015(count)X -1 f -1275(times)X -1468(backward)X -1801(through)X -2070(the)X -2188(current)X -2436(line)X -2576(for)X -7 f -2690()X -1 f -(.)S -776 4272(The)N -3 f -921(F)X -1 f -990(command)X -1326(may)X -1484(be)X -1580(used)X -1747(as)X -1834(the)X -1952(motion)X -2198(component)X -2574(of)X -2661(other)X -3 f -2846(vi)X -1 f -2928(commands,)X -3315(in)X -3398(which)X -3615(case)X -3775(any)X -3912(text)X -776 4362(copied)N -1010(into)X -1154(a)X -1210(buffer)X -1427(is)X -1500(character)X -1816(oriented.)X -776 4542(Line:)N -1136(Unchanged.)X -776 4632(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458 0.3068(searched-for)AX -1881(character.)X -776 4722(Options:)N -1136(None.)X -3 f -576 4902([count])N -841(G)X -1 f -776 4992(Move)N -983(to)X -1065(line)X -7 f -1205(count)X -1 f -(,)S -1485(or)X -1572(the)X -1690(last)X -1821(line)X -1961(of)X -2048(the)X -2166(\256le)X -2288(if)X -7 f -2357(count)X -1 f -2617(not)X -2739(speci\256ed.)X -776 5172(The)N -3 f -924(G)X -1 f -1009(command)X -1348(is)X -1424(an)X -1523(absolute)X -1813(movement.)X -2214(The)X -3 f -2362(G)X -1 f -2447(command)X -2786(may)X -2947(be)X -3046(used)X -3216(as)X -3306(the)X -3427(motion)X -3676(component)X -776 5262(of)N -863(other)X -3 f -1048(vi)X -1 f -1130(commands,)X -1517(in)X -1599(which)X -1815(case)X -1974(any)X -2110(text)X -2250(copied)X -2484(into)X -2628(a)X -2684(buffer)X -2901(is)X -2974(line)X -3114(oriented.)X -776 5442(Line:)N -1136(Set)X -1258(to)X -7 f -1340(count)X -1 f -(,)S -1620(if)X -1689(speci\256ed,)X -2014(otherwise,)X -2366(the)X -2484(last)X -2615(line.)X -776 5532(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(in)X -2318(the)X -2436(line.)X -776 5622(Options:)N -1136(None.)X - -22 p -%%Page: 22 21 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-22)N -2826(Nvi/Nex)X -3122 0.3906(Reference)AX -3487(\(Vi)X -3614(Commands\))X -576 762([count])N -841(H)X -1 f -776 852(Move)N -983(to)X -1065(the)X -1183(screen)X -1409(line)X -7 f -1549(count)X -1837(-)X -1933(1)X -1 f -2001(lines)X -2172(below)X -2388(the)X -2506(top)X -2628(of)X -2715(the)X -2833(screen.)X -776 1032(The)N -3 f -924(H)X -1 f -1009(command)X -1348(is)X -1424(an)X -1523(absolute)X -1813(movement.)X -2214(The)X -3 f -2362(H)X -1 f -2447(command)X -2786(may)X -2947(be)X -3046(used)X -3216(as)X -3306(the)X -3427(motion)X -3676(component)X -776 1122(of)N -863(other)X -3 f -1048(vi)X -1 f -1130(commands,)X -1517(in)X -1599(which)X -1815(case)X -1974(any)X -2110(text)X -2250(copied)X -2484(into)X -2628(a)X -2684(buffer)X -2901(is)X -2974(line)X -3114(oriented.)X -776 1302(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -7 f -1598(count)X -1886(-)X -1982(1)X -1 f -2050(lines)X -2221(below)X -2437(the)X -2555(top)X -2677(of)X -2764(the)X -2882(screen.)X -776 1392(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(of)X -2323(the)X -2 f -2441(screen)X -1 f -2671(line.)X -776 1482(Options:)N -1136(None.)X -3 f -576 1662([count])N -841(I)X -1 f -776 1752(Enter)N -971(input)X -1156(mode,)X -1375(inserting)X -1676(the)X -1795(text)X -1936(at)X -2015(the)X -2134(beginning)X -2475(of)X -2564(the)X -2684(line.)X -2866(If)X -7 f -2942(count)X -1 f -3204(is)X -3279(speci\256ed,)X -3606(the)X -3726(text)X -3868(input)X -776 1842(is)N -849(repeatedly)X -1204(input)X -7 f -1388(count)X -1676(-)X -1772(1)X -1 f -1840(more)X -2025(times.)X -776 2022(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(line)X -1729(upon)X -1909(which)X -2125(characters)X -2472(were)X -2649(entered.)X -776 2112(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(entered.)X -776 2202(Options:)N -1136(None.)X -3 f -576 2382([count])N -841(J)X -1 f -776 2472(Join)N -929(lines.)X -1140(If)X -7 f -1214(count)X -1 f -1474(is)X -1547(speci\256ed,)X -7 f -1872(count)X -1 f -2132(lines)X -2303(are)X -2422(joined;)X -2664(a)X -2720(minimum)X -3050(of)X -3137(two)X -3277(lines)X -3448(are)X -3568(always)X -3812(joined,)X -776 2562(regardless)N -1122(of)X -1209(the)X -1327(value)X -1521(of)X -7 f -1608(count)X -1 f -(.)S -776 2742(If)N -859(the)X -986(current)X -1244(line)X -1394(ends)X -1571(with)X -1743(a)X -1809(whitespace)X -2196(character,)X -2542(all)X -2652(whitespace)X -3039(is)X -3122(stripped)X -3410(from)X -3596(the)X -3724(next)X -3892(line.)X -776 2832(Otherwise,)N -1148(if)X -1219(the)X -1338(next)X -1497(line)X -1638(starts)X -1828(with)X -1991(a)X -2048(open)X -2225(parenthesis)X -2607(\(``)X -7 f -2688(\()X -1 f -(''\))S -2838(do)X -2939(nothing.)X -3244(Otherwise,)X -3615(if)X -3685(the)X -3804(current)X -776 2922(line)N -917(ends)X -1086(with)X -1250(a)X -1308(question)X -1601(mark)X -1788(\(``)X -7 f -1869(?)X -1 f -(''\),)S -2040(period)X -2267(\(``)X -7 f -2348(.)X -1 f -(''\))S -2519(or)X -2608(exclamation)X -3022(point)X -3208(\(``)X -7 f -3289(!)X -1 f -(''\),)S -3460(insert)X -3660(two)X -3802(spaces.)X -776 3012(Otherwise,)N -1146(insert)X -1344(a)X -1400(single)X -1611(space.)X -776 3192(It)N -845(is)X -918(not)X -1040(an)X -1136(error)X -1313(to)X -1395(join)X -1539(lines)X -1710(past)X -1859(the)X -1977(end)X -2113(of)X -2200(the)X -2318(\256le,)X -2460(i.e.)X -2578(lines)X -2749(that)X -2889(do)X -2989(not)X -3111(exist.)X -776 3372(Line:)N -1136(Unchanged.)X -776 3462(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(character)X -1774(after)X -1942(the)X -2060(last)X -2191(character)X -2507(of)X -2594(the)X -2712(next-to-last)X -3097(joined)X -3317(line.)X -776 3552(Options:)N -1136(None.)X -3 f -576 3732([count])N -841(L)X -1 f -776 3822(Move)N -983(to)X -1065(the)X -1183(screen)X -1409(line)X -7 f -1549(count)X -1837(-)X -1933(1)X -1 f -2001(lines)X -2172(above)X -2384(the)X -2502(bottom)X -2748(of)X -2835(the)X -2953(screen.)X -776 4002(The)N -3 f -925(L)X -1 f -1002(command)X -1342(is)X -1419(an)X -1519(absolute)X -1810(movement.)X -2212(The)X -3 f -2361(L)X -1 f -2438(command)X -2778(may)X -2940(be)X -3040(used)X -3211(as)X -3302(the)X -3425(motion)X -3676(component)X -776 4092(of)N -863(other)X -3 f -1048(vi)X -1 f -1130(commands,)X -1517(in)X -1599(which)X -1815(case)X -1974(any)X -2110(text)X -2250(copied)X -2484(into)X -2628(a)X -2684(buffer)X -2901(is)X -2974(line)X -3114(oriented.)X -776 4272(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -7 f -1598(count)X -1886(-)X -1982(1)X -1 f -2050(lines)X -2221(above)X -2433(the)X -2551(bottom)X -2797(of)X -2884(the)X -3002(screen.)X -776 4362(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(of)X -2323(the)X -2 f -2441(screen)X -1 f -2671(line.)X -776 4452(Options:)N -1136(None.)X -3 f -596 4632(M)N -1 f -776 4722(Move)N -983(to)X -1065(the)X -1183(screen)X -1409(line)X -1549(in)X -1631(the)X -1749(middle)X -1991(of)X -2078(the)X -2196(screen.)X -776 4902(The)N -3 f -922(M)X -1 f -1019(command)X -1356(is)X -1430(an)X -1527(absolute)X -1815(movement.)X -2214(The)X -3 f -2360(M)X -1 f -2457(command)X -2794(may)X -2953(be)X -3050(used)X -3219(as)X -3308(the)X -3428(motion)X -3676(component)X -776 4992(of)N -863(other)X -3 f -1048(vi)X -1 f -1130(commands,)X -1517(in)X -1599(which)X -1815(case)X -1974(any)X -2110(text)X -2250(copied)X -2484(into)X -2628(a)X -2684(buffer)X -2901(is)X -2974(line)X -3114(oriented.)X -776 5172(Historically,)N -1194(any)X -7 f -1330(count)X -1 f -1590(speci\256ed)X -1895(to)X -1977(the)X -3 f -2095(M)X -1 f -2191(command)X -2527(was)X -2672(ignored.)X -776 5352(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(in)X -1680(the)X -1798(middle)X -2040(of)X -2127(the)X -2245(screen.)X -776 5442(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(of)X -2323(the)X -2 f -2441(screen)X -1 f -2671(line.)X -776 5532(Options:)N -1136(None.)X -3 f -576 5712([count])N -841(O)X -1 f -776 5802(Enter)N -970(input)X -1154(mode,)X -1372(appending)X -1726(text)X -1866(in)X -1948(a)X -2004(new)X -2158(line)X -2298(above)X -2510(the)X -2628(current)X -2876(line.)X -3057(If)X -7 f -3132(count)X -1 f -3393(is)X -3467(speci\256ed,)X -3793(the)X -3912(text)X - -23 p -%%Page: 23 22 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Vi)X -1364(Commands\))X -3658(USD:13-23)X -1 f -776 762(input)N -960(is)X -1033(repeatedly)X -1388(input)X -7 f -1572(count)X -1860(-)X -1956(1)X -1 f -2024(more)X -2209(times.)X -776 942(Historically,)N -1194(any)X -7 f -1330(count)X -1 f -1590(speci\256ed)X -1895(to)X -1977(the)X -3 f -2095(O)X -1 f -2177(command)X -2513(was)X -2658(ignored.)X -776 1122(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(line)X -1729(upon)X -1909(which)X -2125(characters)X -2472(were)X -2649(entered.)X -776 1212(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(entered.)X -776 1302(Options:)N -1136(Affected)X -1440(by)X -1542(the)X -3 f -1662(altwerase)X -1 f -1988(,)X -3 f -2030(autoindent)X -1 f -2398(,)X -3 f -2440(beautify)X -1 f -(,)S -3 f -2762(showmatch)X -1 f -3149(,)X -3 f -3191(ttywerase)X -1 f -3545(and)X -3 f -3684(wrapmar-)X -1136 1392(gin)N -1 f -1262(options.)X -3 f -576 1572([buffer])N -864(P)X -1 f -776 1662(Insert)N -980(text)X -1121(from)X -1298(a)X -1355(buffer.)X -1613(Text)X -1782(from)X -1960(the)X -2080(buffer)X -2299(\(the)X -2446(unnamed)X -2762(buffer)X -2981(by)X -3083(default\))X -3355(is)X -3430(inserted)X -3706(before)X -3934(the)X -776 1752(current)N -1024(column)X -1284(or,)X -1391(if)X -1460(the)X -1578(buffer)X -1795(is)X -1868(line)X -2008(oriented,)X -2311(before)X -2537(the)X -2655(current)X -2903(line.)X -776 1932(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(lowest)X -1687(numbered)X -2028(line)X -2168(insert,)X -2386(if)X -2455(the)X -2573(buffer)X -2790(is)X -2863(line)X -3003(oriented,)X -3306(otherwise)X -3638(unchanged.)X -776 2022(Column:)N -1136(Set)X -1261(to)X -1346(the)X -1467(\256rst)X -1614(nonblank)X -1935(character)X -2254(of)X -2344(the)X -2465(appended)X -2796(text,)X -2959(if)X -3032(the)X -3154(buffer)X -3375(is)X -3452(line)X -3596(oriented,)X -3903(oth-)X -1136 2112(erwise,)N -1386(the)X -1504(last)X -1635(character)X -1951(of)X -2038(the)X -2156(appended)X -2484(text.)X -776 2202(Options:)N -1136(None.)X -3 f -576 2382(Q)N -1 f -776 2472(Exit)N -3 f -929(vi)X -1 f -1011(\(or)X -1125(visual\))X -1363(mode)X -1561(and)X -1697(switch)X -1926(to)X -3 f -2008(ex)X -1 f -2104(mode.)X -776 2652(Line:)N -1136(Unchanged.)X -776 2742(Column:)N -1136(No)X -1254(longer)X -1479(relevant.)X -776 2832(Options:)N -1136(None.)X -3 f -576 3012([count])N -841(R)X -1 f -776 3102(Enter)N -971(input)X -1156(mode,)X -1375(replacing)X -1695(the)X -1814(characters)X -2162(in)X -2245(the)X -2364(current)X -2613(line.)X -2794(If)X -7 f -2869(count)X -1 f -3130(is)X -3204(speci\256ed,)X -3531(the)X -3651(text)X -3793(input)X -3979(is)X -776 3192(repeatedly)N -1131(input)X -7 f -1315(count)X -1603(-)X -1699(1)X -1 f -1767(more)X -1952(times.)X -776 3372(If)N -855(the)X -978(end)X -1119(of)X -1211(the)X -1334(current)X -1587(line)X -1732(is)X -1810(reached,)X -2106(no)X -2211(more)X -2401(characters)X -2753(are)X -2877(replaced)X -3176(and)X -3318(any)X -3460(further)X -3705(characters)X -776 3462(input)N -960(are)X -1079(appended)X -1407(to)X -1489(the)X -1607(line.)X -776 3642(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(line)X -1729(upon)X -1909(which)X -2125(characters)X -2472(were)X -2649(entered.)X -776 3732(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(entered.)X -776 3822(Options:)N -1136(Affected)X -1440(by)X -1542(the)X -3 f -1662(altwerase)X -1 f -1988(,)X -3 f -2030(autoindent)X -1 f -2398(,)X -3 f -2440(beautify)X -1 f -(,)S -3 f -2762(showmatch)X -1 f -3149(,)X -3 f -3191(ttywerase)X -1 f -3545(and)X -3 f -3684(wrapmar-)X -1136 3912(gin)N -1 f -1262(options.)X -3 f -576 4092([buffer])N -864([count])X -1129(S)X -1 f -776 4182(Substitute)N -7 f -1115(count)X -1 f -1375(lines.)X -776 4362(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(line)X -1729(upon)X -1909(which)X -2125(characters)X -2472(were)X -2649(entered.)X -776 4452(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(entered.)X -776 4542(Options:)N -1136(Affected)X -1440(by)X -1542(the)X -3 f -1662(altwerase)X -1 f -1988(,)X -3 f -2030(autoindent)X -1 f -2398(,)X -3 f -2440(beautify)X -1 f -(,)S -3 f -2762(showmatch)X -1 f -3149(,)X -3 f -3191(ttywerase)X -1 f -3545(and)X -3 f -3684(wrapmar-)X -1136 4632(gin)N -1 f -1262(options.)X -3 f -576 4812([count])N -841(T)X -914 0.3125()AX -1 f -776 4902(Search)N -1014(backward,)X -7 f -1366(count)X -1 f -1625(times,)X -1837(through)X -2105(the)X -2222(current)X -2469(line)X -2608(for)X -2721(the)X -2838(character)X -2 f -3153(after)X -1 f -3323(the)X -3440(speci\256ed)X -7 f -3744()N -1 f -(.)S -776 5172(The)N -3 f -921(T)X -1 f -994(command)X -1330(may)X -1488(be)X -1584(used)X -1751(as)X -1838(the)X -1956(motion)X -2202(component)X -2578(of)X -2665(other)X -3 f -2850(vi)X -1 f -2932(commands,)X -3319(in)X -3401(which)X -3617(case)X -3776(any)X -3912(text)X -776 5262(copied)N -1010(into)X -1154(a)X -1210(buffer)X -1427(is)X -1500(character)X -1816(oriented.)X -776 5442(Line:)N -1136(Unchanged.)X -776 5532(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(character)X -2 f -1774(after)X -1 f -1945(the)X -2063 0.3068(searched-for)AX -2486(character.)X -776 5622(Options:)N -1136(None.)X - -24 p -%%Page: 24 23 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-24)N -2826(Nvi/Nex)X -3122 0.3906(Reference)AX -3487(\(Vi)X -3614(Commands\))X -576 762(U)N -1 f -776 852(Restore)N -1041(the)X -1159(current)X -1407(line)X -1547(to)X -1629(its)X -1724(state)X -1891(before)X -2117(the)X -2235(cursor)X -2456(last)X -2587(moved)X -2825(to)X -2907(it.)X -776 1032(Line:)N -1136(Unchanged.)X -776 1122(Column:)N -1136(The)X -1281(\256rst)X -1425(character)X -1741(in)X -1823(the)X -1941(line.)X -776 1212(Options:)N -1136(None.)X -3 f -576 1392([count])N -841(W)X -1 f -776 1482(Move)N -985(forward)X -7 f -1262(count)X -1 f -1524(bigwords.)X -1884(Move)X -2094(the)X -2215(cursor)X -2439(forward)X -2717(to)X -2802(the)X -2923(beginning)X -3266(of)X -3356(a)X -3415(bigword)X -3705(by)X -3808(repeat-)X -776 1572(ing)N -903(the)X -1026(following)X -1362(algorithm:)X -1720(if)X -1794(the)X -1917(current)X -2170(position)X -2452(is)X -2530(within)X -2759(a)X -2820(bigword)X -3112(or)X -3204(the)X -3326(character)X -3646(at)X -3728(that)X -3872(posi-)X -776 1662(tion)N -926(cannot)X -1166(be)X -1268(part)X -1419(of)X -1512(a)X -1574(bigword,)X -1887(move)X -2091(to)X -2179(the)X -2303(\256rst)X -2453(character)X -2775(of)X -2868(the)X -2992(next)X -3156(bigword.)X -3489(If)X -3569(no)X -3676(subsequent)X -776 1752(bigword)N -1066(exists)X -1271(on)X -1374(the)X -1495(current)X -1746(line,)X -1909(move)X -2110(to)X -2195(the)X -2316(\256rst)X -2463(character)X -2782(of)X -2872(the)X -2993(\256rst)X -3139(bigword)X -3428(on)X -3530(the)X -3650(\256rst)X -3796(follow-)X -776 1842(ing)N -898(line)X -1038(that)X -1178(contains)X -1465(a)X -1521(bigword.)X -776 2022(The)N -3 f -927(W)X -1 f -1033(command)X -1375(may)X -1539(be)X -1641(used)X -1814(as)X -1908(the)X -2033(motion)X -2286(component)X -2669(of)X -2763(other)X -3 f -2955(vi)X -1 f -3044(commands,)X -3438(in)X -3527(which)X -3750(case)X -3916(any)X -776 2112(text)N -916(copied)X -1150(into)X -1294(a)X -1350(buffer)X -1567(is)X -1640(character)X -1956(oriented.)X -776 2292(Line:)N -1136(The)X -1281(line)X -1421(containing)X -1779(the)X -1897(word)X -2082(selected.)X -776 2382(Column:)N -1136(The)X -1281(\256rst)X -1425(character)X -1741(of)X -1828(the)X -1946(word)X -2131(selected.)X -776 2472(Options:)N -1136(None.)X -3 f -576 2652([buffer])N -864([count])X -1129(X)X -1 f -776 2742(Delete)N -7 f -1008(count)X -1 f -1270(characters)X -1619(before)X -1847(the)X -1967(cursor.)X -2230(If)X -2306(the)X -2426(number)X -2693(of)X -2782(characters)X -3132(to)X -3217(be)X -3316(deleted)X -3571(is)X -3647(greater)X -3894(than)X -776 2832(or)N -874(equal)X -1079(to)X -1172(the)X -1301(number)X -1577(of)X -1675(characters)X -2033(to)X -2126(the)X -2255(beginning)X -2606(of)X -2704(the)X -2833(line,)X -3004(all)X -3115(of)X -3213(the)X -3341(characters)X -3698(before)X -3934(the)X -776 2922(current)N -1024(cursor)X -1245(position,)X -1542(to)X -1624(the)X -1742(beginning)X -2082(of)X -2169(the)X -2287(line,)X -2447(are)X -2566(deleted.)X -776 3102(Line:)N -1136(Unchanged.)X -776 3192(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(current)X -1706(character)X -2022(minus)X -7 f -2237(count)X -1 f -(,)S -2518(or)X -2606(the)X -2725(\256rst)X -2870(character)X -3187(if)X -3257(count)X -3456(is)X -3530(greater)X -3775(than)X -3934(the)X -1136 3282(number)N -1401(of)X -1488(characters)X -1835(in)X -1917(the)X -2035(line)X -2175(before)X -2401(the)X -2519(cursor.)X -776 3372(Options:)N -1136(None.)X -3 f -576 3552([buffer])N -864([count])X -1129(Y)X -1 f -776 3642(Copy)N -969(\(or)X -1083(``yank''\))X -7 f -1394(count)X -1 f -1654(lines)X -1825(into)X -1969(the)X -2087(speci\256ed)X -2392(buffer.)X -776 3822(Line:)N -1136(Unchanged.)X -776 3912(Column:)N -1136(Unchanged.)X -776 4002(Options:)N -1136(None.)X -3 f -576 4182(ZZ)N -1 f -776 4272(Write)N -979(the)X -1097(\256le)X -1219(and)X -1356(exit)X -3 f -1497(vi)X -1 f -1559(.)X -1620(The)X -1766(\256le)X -1889(is)X -1963(only)X -2126(written)X -2374(if)X -2444(it)X -2509(has)X -2637(been)X -2810(modi\256ed)X -3115(since)X -3301(the)X -3420(last)X -3552(complete)X -3867(write)X -776 4362(of)N -863(the)X -981(\256le)X -1103(to)X -1185(any)X -1321(\256le.)X -776 4542(The)N -3 f -922(ZZ)X -1 f -1050(command)X -1388(will)X -1534(exit)X -1676(the)X -1796(editor)X -2005(after)X -2175(writing)X -2428(the)X -2548(\256le,)X -2692(if)X -2763(there)X -2946(are)X -3067(no)X -3169(further)X -3410(\256les)X -3565(to)X -3649(edit.)X -3831(Enter-)X -776 4632(ing)N -901(two)X -1044(``quit'')X -1299(commands)X -1669(\(i.e.)X -3 f -1837(wq)X -1 f -1939(,)X -3 f -1981(quit)X -1 f -2118(,)X -3 f -2160(xit)X -1 f -2271(or)X -3 f -2360(ZZ)X -1 f -2466(\))X -2515(in)X -2599(a)X -2657(row)X -2804(will)X -2950(override)X -3240(this)X -3377(check)X -3587(and)X -3725(the)X -3845(editor)X -776 4722(will)N -920(exit,)X -1080(ignoring)X -1371(any)X -1507(\256les)X -1660(that)X -1800(have)X -1972(not)X -2094(yet)X -2212(been)X -2384(edited.)X -776 4902(Line:)N -1136(Unchanged.)X -776 4992(Column:)N -1136(Unchanged.)X -776 5082(Options:)N -1136(None.)X -3 f -576 5262([count])N -841([[)X -1 f -776 5352(Back)N -961(up)X -7 f -1061(count)X -1 f -1321(section)X -1568(boundaries.)X -776 5532(The)N -3 f -925([[)X -1 f -1003(command)X -1343(is)X -1420(an)X -1520(absolute)X -1811(movement.)X -2213(The)X -3 f -2362([[)X -1 f -2440(command)X -2780(may)X -2942(be)X -3042(used)X -3213(as)X -3304(the)X -3426(motion)X -3676(component)X -776 5622(of)N -871(other)X -3 f -1064(vi)X -1 f -1153(commands,)X -1547(in)X -1636(which)X -1859(case)X -2025(any)X -2168(text)X -2315(copied)X -2556(into)X -2707(a)X -2770(buffer)X -2994(is)X -3074(character)X -3397(oriented,)X -3707(unless)X -3934(the)X -776 5712(starting)N -1036(position)X -1313(is)X -1386(column)X -1646(0,)X -1726(in)X -1808(which)X -2024(case)X -2183(it)X -2247(is)X -2320(line)X -2460(oriented.)X - -25 p -%%Page: 25 24 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Vi)X -1364(Commands\))X -3658(USD:13-25)X -1 f -776 762(This)N -938(is)X -1011(an)X -1107(error)X -1284(if)X -1353(the)X -1471(movement)X -1829(is)X -1902(past)X -2051(the)X -2169(beginning)X -2509(of)X -2596(the)X -2714(\256le.)X -776 942(Line:)N -1136(Set)X -1261(to)X -1346(the)X -1467(previous)X -1766(line)X -1909(that)X -2052(is)X -7 f -2128(count)X -1 f -2391(section)X -2641(boundaries)X -3016(back,)X -3212(or)X -3303(the)X -3425(\256rst)X -3573(line)X -3717(of)X -3808(the)X -3930(\256le)X -1136 1032(if)N -1205(no)X -1305(more)X -1490(section)X -1737(boundaries)X -2109(exist)X -2280(preceding)X -2617(the)X -2735(current)X -2983(line.)X -776 1122(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(in)X -2318(the)X -2436(line.)X -776 1212(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(sections)X -1 f -1943(option.)X -3 f -576 1392([count])N -841(]])X -1 f -776 1482(Move)N -983(forward)X -7 f -1258(count)X -1 f -1518(section)X -1765(boundaries.)X -776 1662(The)N -3 f -925(]])X -1 f -1003(command)X -1343(is)X -1420(an)X -1520(absolute)X -1811(movement.)X -2213(The)X -3 f -2362(]])X -1 f -2440(command)X -2780(may)X -2942(be)X -3042(used)X -3213(as)X -3304(the)X -3426(motion)X -3676(component)X -776 1752(of)N -871(other)X -3 f -1064(vi)X -1 f -1153(commands,)X -1547(in)X -1636(which)X -1859(case)X -2025(any)X -2168(text)X -2315(copied)X -2556(into)X -2707(a)X -2770(buffer)X -2994(is)X -3074(character)X -3397(oriented,)X -3707(unless)X -3934(the)X -776 1842(starting)N -1036(position)X -1313(is)X -1386(column)X -1646(0,)X -1726(in)X -1808(which)X -2024(case)X -2183(it)X -2247(is)X -2320(line)X -2460(oriented.)X -776 2022(This)N -938(is)X -1011(an)X -1107(error)X -1284(if)X -1353(the)X -1471(movement)X -1829(is)X -1902(past)X -2051(the)X -2169(end)X -2305(of)X -2392(the)X -2510(\256le.)X -776 2202(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(that)X -1738(is)X -7 f -1811(count)X -1 f -2072(section)X -2320(boundaries)X -2693(forward,)X -2989(or)X -3077(to)X -3160(the)X -3279(last)X -3411(line)X -3552(of)X -3640(the)X -3759(\256le)X -3882(if)X -3952(no)X -1136 2292(more)N -1321(section)X -1568(boundaries)X -1940(exist)X -2111(following)X -2442(the)X -2560(current)X -2808(line.)X -776 2382(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(in)X -2318(the)X -2436(line.)X -776 2472(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(sections)X -1 f -1943(option.)X -3 f -576 2652(\303)N -1 f -776 2742(Move)N -983(to)X -1065(\256rst)X -1209(nonblank)X -1527(character)X -1843(on)X -1943(the)X -2061(current)X -2309(line.)X -776 2922(The)N -3 f -922(\303)X -1 f -970(command)X -1307(may)X -1466(be)X -1563(used)X -1731(as)X -1819(the)X -1938(motion)X -2185(component)X -2562(of)X -2651(other)X -3 f -2838(vi)X -1 f -2922(commands,)X -3311(in)X -3395(which)X -3613(case)X -3774(any)X -3912(text)X -776 3012(copied)N -1010(into)X -1154(a)X -1210(buffer)X -1427(is)X -1500(character)X -1816(oriented.)X -776 3192(Line:)N -1136(Unchanged.)X -776 3282(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(of)X -2323(the)X -2441(current)X -2689(line.)X -776 3372(Options:)N -1136(None.)X -3 f -576 3552([count])N -841(_)X -1 f -776 3642(Move)N -985(down)X -7 f -1185(count)X -1475(-)X -1573(1)X -1 f -1643(lines,)X -1836(to)X -1920(the)X -2040(\256rst)X -2186(nonblank)X -2506(character.)X -2864(The)X -3 f -3012(_)X -1 f -3075(command)X -3414(may)X -3575(be)X -3674(used)X -3844(as)X -3934(the)X -776 3732(motion)N -1022(component)X -1398(of)X -1485(other)X -3 f -1670(vi)X -1 f -1752(commands,)X -2139(in)X -2221(which)X -2437(case)X -2596(any)X -2732(text)X -2872(copied)X -3106(into)X -3250(a)X -3306(buffer)X -3523(is)X -3596(line)X -3736(oriented.)X -776 3912(It)N -845(is)X -918(not)X -1040(an)X -1136(error)X -1313(to)X -1395(execute)X -1661(the)X -3 f -1779(_)X -1 f -1839(command)X -2175(when)X -2369(the)X -2487(cursor)X -2708(is)X -2781(on)X -2881(the)X -2999(\256rst)X -3143(character)X -3459(in)X -3541(the)X -3659(line.)X -776 4092(Line:)N -1136(The)X -1281(current)X -1529(line)X -1669(plus)X -7 f -1822(count)X -2110(-)X -2206(1)X -1 f -(.)S -776 4182(Column:)N -1136(The)X -1281(\256rst)X -1425(nonblank)X -1743(character)X -2059(in)X -2141(the)X -2259(line.)X -776 4272(Options:)N -1136(None.)X -3 f -576 4452([count])N -841(a)X -1 f -776 4542(Enter)N -971(input)X -1156(mode,)X -1375(appending)X -1730(the)X -1850(text)X -1992(after)X -2162(the)X -2282(cursor.)X -2545(If)X -7 f -2621(count)X -1 f -2883(is)X -2958(speci\256ed,)X -3285(the)X -3405(text)X -3547(input)X -3733(is)X -3808(repeat-)X -776 4632(edly)N -934(input)X -7 f -1118(count)X -1406(-)X -1502(1)X -1 f -1570(more)X -1755(times.)X -776 4812(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(line)X -1729(upon)X -1909(which)X -2125(characters)X -2472(were)X -2649(entered.)X -776 4902(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(entered.)X -776 4992(Options:)N -1136(Affected)X -1440(by)X -1542(the)X -3 f -1662(altwerase)X -1 f -1988(,)X -3 f -2030(autoindent)X -1 f -2398(,)X -3 f -2440(beautify)X -1 f -(,)S -3 f -2762(showmatch)X -1 f -3149(,)X -3 f -3191(ttywerase)X -1 f -3545(and)X -3 f -3684(wrapmar-)X -1136 5082(gin)N -1 f -1262(options.)X -3 f -576 5262([count])N -841(b)X -1 f -776 5352(Move)N -986(backward)X -7 f -1322(count)X -1 f -1585(words.)X -1844(Move)X -2054(the)X -2175(cursor)X -2400(backward)X -2737(to)X -2823(the)X -2945(beginning)X -3289(of)X -3380(a)X -3440(word)X -3629(by)X -3733(repeating)X -776 5442(the)N -895(following)X -1227(algorithm:)X -1581(if)X -1651(the)X -1770(current)X -2018(position)X -2295(is)X -2368(at)X -2446(the)X -2564(beginning)X -2904(of)X -2991(a)X -3047(word,)X -3252(move)X -3450(to)X -3532(the)X -3650(\256rst)X -3794(charac-)X -776 5532(ter)N -883(of)X -972(the)X -1092(preceding)X -1431(word.)X -1658(Otherwise,)X -2030(the)X -2150(current)X -2400(position)X -2679(moves)X -2910(to)X -2994(the)X -3114(\256rst)X -3260(character)X -3578(of)X -3667(the)X -3787(word)X -3974(at)X -776 5622(the)N -895(current)X -1144(position.)X -1462(If)X -1537(no)X -1638(preceding)X -1976(word)X -2161(exists)X -2363(on)X -2463(the)X -2581(current)X -2829(line,)X -2989(move)X -3187(to)X -3269(the)X -3387(\256rst)X -3531(character)X -3847(of)X -3934(the)X -776 5712(last)N -907(word)X -1092(on)X -1192(the)X -1310(\256rst)X -1454(preceding)X -1791(line)X -1931(that)X -2071(contains)X -2358(a)X -2414(word.)X - -26 p -%%Page: 26 25 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-26)N -2826(Nvi/Nex)X -3122 0.3906(Reference)AX -3487(\(Vi)X -3614(Commands\))X -1 f -776 762(The)N -3 f -921(b)X -1 f -985(command)X -1321(may)X -1479(be)X -1575(used)X -1742(as)X -1829(the)X -1947(motion)X -2193(component)X -2570(of)X -2658(other)X -3 f -2844(vi)X -1 f -2927(commands,)X -3315(in)X -3398(which)X -3615(case)X -3775(any)X -3912(text)X -776 852(copied)N -1010(into)X -1154(a)X -1210(buffer)X -1427(is)X -1500(character)X -1816(oriented.)X -776 1032(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(containing)X -1956(the)X -2074(word)X -2259(selected.)X -776 1122(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(character)X -1918(of)X -2005(the)X -2123(word)X -2308(selected.)X -776 1212(Options:)N -1136(None.)X -3 f -576 1392([buffer])N -864([count])X -1129(c)X -1185(motion)X -1 f -776 1482(Change)N -1041(a)X -1097(region)X -1322(of)X -1409(text.)X -1589(If)X -1663(only)X -1825(part)X -1970(of)X -2057(a)X -2113(single)X -2324(line)X -2464(is)X -2537(affected,)X -2838(then)X -2997(the)X -3116(last)X -3248(character)X -3565(being)X -3764(changed)X -776 1572(is)N -849(marked)X -1110(with)X -1272(a)X -1328(``)X -7 f -1382($)X -1 f -(''.)S -1544(Otherwise,)X -1914(the)X -2032(region)X -2257(of)X -2344(text)X -2484(is)X -2557(deleted,)X -2829(and)X -2965(input)X -3149(mode)X -3347(is)X -3420(entered.)X -776 1752(If)N -7 f -850(count)X -1 f -1110(is)X -1183(speci\256ed,)X -1508(it)X -1572(is)X -1645(applied)X -1901(to)X -1983(the)X -7 f -2101(motion)X -1 f -(.)S -776 1932(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(line)X -1729(upon)X -1909(which)X -2125(characters)X -2472(were)X -2649(entered.)X -776 2022(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(entered.)X -776 2112(Options:)N -1136(Affected)X -1440(by)X -1542(the)X -3 f -1662(altwerase)X -1 f -1988(,)X -3 f -2030(autoindent)X -1 f -2398(,)X -3 f -2440(beautify)X -1 f -(,)S -3 f -2762(showmatch)X -1 f -3149(,)X -3 f -3191(ttywerase)X -1 f -3545(and)X -3 f -3684(wrapmar-)X -1136 2202(gin)N -1 f -1262(options.)X -3 f -576 2382([buffer])N -864([count])X -1129(d)X -1193(motion)X -1 f -776 2472(Delete)N -1006(a)X -1062(region)X -1287(of)X -1374(text.)X -1554(If)X -7 f -1628(count)X -1 f -1888(is)X -1961(speci\256ed,)X -2286(it)X -2350(is)X -2423(applied)X -2679(to)X -2761(the)X -7 f -2879(motion)X -1 f -(.)S -776 2652(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(where)X -1815(the)X -1933(region)X -2158(starts.)X -776 2742(Column:)N -1136(Set)X -1261(to)X -1346(the)X -1467(\256rst)X -1615(character)X -1935(in)X -2021(the)X -2143(line)X -2287(after)X -2459(the)X -2581(last)X -2716(character)X -3036(in)X -3122(the)X -3244(region.)X -3513(If)X -3591(no)X -3695(such)X -3866(char-)X -1136 2832(acter)N -1313(exists,)X -1535(set)X -1644(to)X -1726(the)X -1844(last)X -1975(character)X -2291(before)X -2517(the)X -2635(region.)X -776 2922(Options:)N -1136(None.)X -3 f -576 3102([count])N -841(e)X -1 f -776 3192(Move)N -984(forward)X -7 f -1260(count)X -1 f -1521(end-of-words.)X -2015(Move)X -2223(the)X -2342(cursor)X -2564(forward)X -2840(to)X -2923(the)X -3042(end)X -3179(of)X -3267(a)X -3324(word)X -3511(by)X -3613(repeating)X -3934(the)X -776 3282(following)N -1108(algorithm:)X -1462(if)X -1532(the)X -1651(current)X -1900(position)X -2178(is)X -2252(the)X -2371(end)X -2508(of)X -2596(a)X -2653(word,)X -2859(move)X -3058(to)X -3141(the)X -3260(last)X -3392(character)X -3709(of)X -3797(the)X -3916(fol-)X -776 3372(lowing)N -1034(word.)X -1275(Otherwise,)X -1661(move)X -1876(to)X -1975(the)X -2110(last)X -2258(character)X -2591(of)X -2695(the)X -2830(word)X -3032(at)X -3127(the)X -3262(current)X -3527(position.)X -3861(If)X -3952(no)X -776 3462(succeeding)N -1161(word)X -1354(exists)X -1564(on)X -1672(the)X -1798(current)X -2053(line,)X -2220(move)X -2425(to)X -2514(the)X -2639(last)X -2777(character)X -3100(of)X -3194(the)X -3319(\256rst)X -3470(word)X -3662(on)X -3769(the)X -3894(next)X -776 3552(following)N -1107(line)X -1247(that)X -1387(contains)X -1674(a)X -1730(word.)X -776 3732(The)N -3 f -921(e)X -1 f -978(command)X -1315(may)X -1474(be)X -1571(used)X -1739(as)X -1827(the)X -1946(motion)X -2193(component)X -2570(of)X -2658(other)X -3 f -2844(vi)X -1 f -2927(commands,)X -3315(in)X -3398(which)X -3615(case)X -3775(any)X -3912(text)X -776 3822(copied)N -1010(into)X -1154(a)X -1210(buffer)X -1427(is)X -1500(character)X -1816(oriented.)X -776 4002(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(containing)X -1956(the)X -2074(word)X -2259(selected.)X -776 4092(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(of)X -1992(the)X -2110(word)X -2295(selected.)X -776 4182(Options:)N -1136(None.)X -3 f -576 4362([count])N -841(f)X -888 0.3125()AX -1 f -776 4452(Search)N -1015(forward,)X -7 f -1310(count)X -1 f -1570(times,)X -1783(through)X -2052(the)X -2170(rest)X -2306(of)X -2393(the)X -2511(current)X -2759(line)X -2899(for)X -7 f -3013()X -1 f -(.)S -776 4632(The)N -3 f -922(f)X -1 f -970(command)X -1307(may)X -1466(be)X -1563(used)X -1731(as)X -1819(the)X -1938(motion)X -2185(component)X -2562(of)X -2651(other)X -3 f -2838(vi)X -1 f -2922(commands,)X -3311(in)X -3395(which)X -3613(case)X -3774(any)X -3912(text)X -776 4722(copied)N -1010(into)X -1154(a)X -1210(buffer)X -1427(is)X -1500(character)X -1816(oriented.)X -776 4902(Line:)N -1136(Unchanged.)X -776 4992(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458 0.3068(searched-for)AX -1881(character.)X -776 5082(Options:)N -1136(None.)X -3 f -576 5262([count])N -841(i)X -1 f -776 5352(Enter)N -971(input)X -1156(mode,)X -1375(inserting)X -1676(the)X -1795(text)X -1936(before)X -2163(the)X -2282(cursor.)X -2545(If)X -7 f -2621(count)X -1 f -2883(is)X -2958(speci\256ed,)X -3285(the)X -3405(text)X -3547(input)X -3733(is)X -3808(repeat-)X -776 5442(edly)N -934(input)X -7 f -1118(count)X -1406(-)X -1502(1)X -1 f -1570(more)X -1755(times.)X -776 5622(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(line)X -1729(upon)X -1909(which)X -2125(characters)X -2472(were)X -2649(entered.)X -776 5712(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(entered.)X - -27 p -%%Page: 27 26 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Vi)X -1364(Commands\))X -3658(USD:13-27)X -1 f -776 762(Options:)N -1136(Affected)X -1440(by)X -1542(the)X -3 f -1662(altwerase)X -1 f -1988(,)X -3 f -2030(autoindent)X -1 f -2398(,)X -3 f -2440(beautify)X -1 f -(,)S -3 f -2762(showmatch)X -1 f -3149(,)X -3 f -3191(ttywerase)X -1 f -3545(and)X -3 f -3684(wrapmar-)X -1136 852(gin)N -1 f -1262(options.)X -3 f -576 1032(m)N -663 0.3125()AX -1 f -776 1122(Save)N -956(the)X -1078(current)X -1330(context)X -1590(\(line)X -1761(and)X -1902(column\))X -2194(as)X -7 f -2286()X -1 f -(.)S -2879(The)X -3029(exact)X -3224(position)X -3506(is)X -3584(referred)X -3865(to)X -3952(by)X -776 1212(``)N -7 f -830(`)X -1 f -(''.)S -1520(The)X -1665(line)X -1805(is)X -1878(referred)X -2154(to)X -2236(by)X -2336(``)X -7 f -2390(')X -1 f -(''.)S -776 1392(Historically,)N -7 f -1205()X -1 f -1764(was)X -1920(restricted)X -2250(to)X -2343(lower-case)X -2723(letters)X -2950(only,)X -3 f -3143(nvi)X -1 f -3280(permits)X -3551(the)X -3680(use)X -3818(of)X -3916(any)X -776 1482(character.)N -776 1662(Line:)N -1136(Unchanged.)X -776 1752(Column:)N -1136(Unchanged.)X -776 1842(Options:)N -1136(None.)X -3 f -576 2022([count])N -841(o)X -1 f -776 2112(Enter)N -970(input)X -1154(mode,)X -1372(appending)X -1727(text)X -1868(in)X -1951(a)X -2008(new)X -2163(line)X -2304(under)X -2508(the)X -2627(current)X -2876(line.)X -3057(If)X -7 f -3132(count)X -1 f -3393(is)X -3467(speci\256ed,)X -3793(the)X -3912(text)X -776 2202(input)N -960(is)X -1033(repeatedly)X -1388(input)X -7 f -1572(count)X -1860(-)X -1956(1)X -1 f -2024(more)X -2209(times.)X -776 2382(Historically,)N -1194(any)X -7 f -1330(count)X -1 f -1590(speci\256ed)X -1895(to)X -1977(the)X -3 f -2095(o)X -1 f -2155(command)X -2491(was)X -2636(ignored.)X -776 2562(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(line)X -1729(upon)X -1909(which)X -2125(characters)X -2472(were)X -2649(entered.)X -776 2652(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(entered.)X -776 2742(Options:)N -1136(Affected)X -1440(by)X -1542(the)X -3 f -1662(altwerase)X -1 f -1988(,)X -3 f -2030(autoindent)X -1 f -2398(,)X -3 f -2440(beautify)X -1 f -(,)S -3 f -2762(showmatch)X -1 f -3149(,)X -3 f -3191(ttywerase)X -1 f -3545(and)X -3 f -3684(wrapmar-)X -1136 2832(gin)N -1 f -1262(options.)X -3 f -576 3012([buffer])N -864(p)X -1 f -776 3102(Append)N -1055(text)X -1200(from)X -1381(a)X -1442(buffer.)X -1704(Text)X -1876(from)X -2057(the)X -2180(buffer)X -2402(\(the)X -2552(unnamed)X -2871(buffer)X -3093(by)X -3198(default\))X -3473(is)X -3551(appended)X -3884(after)X -776 3192(the)N -894(current)X -1142(column)X -1402(or,)X -1509(if)X -1578(the)X -1696(buffer)X -1913(is)X -1986(line)X -2126(oriented,)X -2429(after)X -2597(the)X -2715(current)X -2963(line.)X -776 3372(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(line)X -1742(appended,)X -2090(if)X -2159(the)X -2277(buffer)X -2494(is)X -2567(line)X -2707(oriented,)X -3010(otherwise)X -3342(unchanged.)X -776 3462(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2237(of)X -2325(the)X -2444(appended)X -2773(text)X -2914(if)X -2984(the)X -3103(buffer)X -3321(is)X -3395(line)X -3536(oriented,)X -3840(other-)X -1136 3552(wise,)N -1323(the)X -1441(last)X -1572(character)X -1888(of)X -1975(the)X -2093(appended)X -2421(text.)X -776 3642(Options:)N -1136(None.)X -3 f -576 3822([count])N -841(r)X -897 0.3125()AX -1 f -776 3912(Replace)N -1073(characters.)X -1478(The)X -1641(next)X -7 f -1817(count)X -1 f -2095(characters)X -2460(in)X -2560(the)X -2696(line)X -2854(are)X -2991(replaced)X -3303(with)X -7 f -3484()X -1 f -(.)S -776 4002(Replacing)N -1121(characters)X -1468(with)X -7 f -1630()X -1 f -2082(characters)X -2429(results)X -2658(in)X -2740(creating)X -3019(new,)X -3193(empty)X -3413(lines)X -3584(into)X -3728(the)X -3846(\256le.)X -776 4182(If)N -7 f -850()X -1 f -1398(is)X -7 f -1471()X -1 f -(,)S -1895(the)X -2013(command)X -2349(is)X -2422(cancelled.)X -776 4362(Line:)N -1136(Unchanged)X -1527(unless)X -1752(the)X -1875(replacement)X -2293(character)X -2614(is)X -2692(a)X -7 f -2753()X -1 f -(,)S -3231(in)X -3319(which)X -3541(case)X -3706(it)X -3776(is)X -3855(set)X -3970(to)X -1136 4452(the)N -1254(current)X -1502(line)X -1642(plus)X -7 f -1795(count)X -2083(-)X -2179(1)X -1 f -(.)S -776 4542(Column:)N -1136(Set)X -1264(to)X -1352(the)X -1476(last)X -1613(character)X -1935(replaced,)X -2254(unless)X -2480(the)X -2605(replacement)X -3025(character)X -3348(is)X -3428(a)X -7 f -3491()X -1 f -(,)S -3970(in)X -1136 4632(which)N -1352(case)X -1511(the)X -1629(cursor)X -1850(is)X -1923(in)X -2005(column)X -2265(1)X -2325(of)X -2412(the)X -2530(last)X -2661(line)X -2801(inserted.)X -776 4722(Options:)N -1136(None.)X -3 f -576 4902([buffer])N -864([count])X -1129(s)X -1 f -776 4992(Substitute)N -7 f -1115(count)X -1 f -1375(characters)X -1722(in)X -1804(the)X -1922(current)X -2170(line)X -2310(starting)X -2570(with)X -2732(the)X -2850(current)X -3098(character.)X -776 5172(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(line)X -1729(upon)X -1909(which)X -2125(characters)X -2472(were)X -2649(entered.)X -776 5262(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(last)X -1589(character)X -1905(entered.)X -776 5352(Options:)N -1136(Affected)X -1440(by)X -1542(the)X -3 f -1662(altwerase)X -1 f -1988(,)X -3 f -2030(autoindent)X -1 f -2398(,)X -3 f -2440(beautify)X -1 f -(,)S -3 f -2762(showmatch)X -1 f -3149(,)X -3 f -3191(ttywerase)X -1 f -3545(and)X -3 f -3684(wrapmar-)X -1136 5442(gin)N -1 f -1262(options.)X -3 f -576 5622([count])N -841(t)X -888 0.3125()AX -1 f -776 5712(Search)N -1014(forward,)X -7 f -1308(count)X -1 f -1567(times,)X -1779(through)X -2047(the)X -2164(current)X -2411(line)X -2551(for)X -2665(the)X -2783(character)X -3099(immediately)X -2 f -3519(before)X -7 f -3744()N -1 f -(.)S - -28 p -%%Page: 28 27 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-28)N -2826(Nvi/Nex)X -3122 0.3906(Reference)AX -3487(\(Vi)X -3614(Commands\))X -1 f -776 762(The)N -3 f -922(t)X -1 f -970(command)X -1307(may)X -1466(be)X -1563(used)X -1731(as)X -1819(the)X -1938(motion)X -2185(component)X -2562(of)X -2651(other)X -3 f -2838(vi)X -1 f -2922(commands,)X -3311(in)X -3395(which)X -3613(case)X -3774(any)X -3912(text)X -776 852(copied)N -1010(into)X -1154(a)X -1210(buffer)X -1427(is)X -1500(character)X -1816(oriented.)X -776 1032(Line:)N -1136(Unchanged.)X -776 1122(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(character)X -2 f -1774(before)X -1 f -1999(the)X -2117 0.3068(searched-for)AX -2540(character.)X -776 1212(Options:)N -1136(None.)X -3 f -576 1392(u)N -1 f -776 1482(Undo)N -985(the)X -1114(last)X -1256(change)X -1515(made)X -1720(to)X -1813(the)X -1942(\256le.)X -2115(If)X -2200(repeated,)X -2524(the)X -3 f -2653(u)X -1 f -2728(command)X -3075(alternates)X -3415(between)X -3715(these)X -3912(two)X -776 1572(states,)N -997(and)X -1136(is)X -1212(its)X -1310(own)X -1471(inverse.)X -1766(When)X -1981(used)X -2151(after)X -2322(an)X -2421(insert)X -2622(that)X -2765(inserted)X -3042(text)X -3185(on)X -3287(more)X -3474(than)X -3634(one)X -3772(line,)X -3934(the)X -776 1662(lines)N -947(are)X -1066(saved)X -1269(in)X -1351(the)X -1469(numeric)X -1752(buffers.)X -776 1842(The)N -3 f -928(.)X -1 f -995(command,)X -1358(when)X -1560(used)X -1735(immediately)X -2163(after)X -2339(the)X -3 f -2465(u)X -1 f -2537(command,)X -2901(causes)X -3139(the)X -3265(change)X -3521(log)X -3651(to)X -3741(be)X -3845(rolled)X -776 1932(forward)N -1051(or)X -1138(backward,)X -1491(depending)X -1845(on)X -1945(the)X -2063(action)X -2279(of)X -2366(the)X -3 f -2484(u)X -1 f -2548(command.)X -776 2112(Line:)N -1136(Set)X -1276(to)X -1376(the)X -1512(position)X -1807(of)X -1912(the)X -2048(\256rst)X -2211(line)X -2370(changed,)X -2697(if)X -2785(the)X -2922(reversal)X -3216(affects)X -3470(only)X -3651(one)X -3806(line)X -3965(or)X -1136 2202(represents)N -1482(an)X -1578(addition)X -1860(or)X -1947(change;)X -2217(otherwise,)X -2569(the)X -2687(line)X -2827(preceding)X -3164(the)X -3282(deleted)X -3534(text.)X -776 2292(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(cursor)X -1679(position)X -1956(before)X -2182(the)X -2300(change)X -2548(was)X -2693(made.)X -776 2382(Options:)N -1136(None.)X -3 f -576 2562([count])N -841(w)X -1 f -776 2652(Move)N -986(forward)X -7 f -1264(count)X -1 f -1527(words.)X -1786(Move)X -1996(the)X -2117(cursor)X -2341(forward)X -2619(to)X -2704(the)X -2825(beginning)X -3168(of)X -3258(a)X -3318(word)X -3507(by)X -3611(repeating)X -3934(the)X -776 2742(following)N -1111(algorithm:)X -1468(if)X -1541(the)X -1663(current)X -1915(position)X -2196(is)X -2273(at)X -2355(the)X -2477(beginning)X -2821(of)X -2912(a)X -2972(word,)X -3181(move)X -3383(to)X -3468(the)X -3589(\256rst)X -3736(character)X -776 2832(of)N -866(the)X -987(next)X -1148(word.)X -1376(If)X -1453(no)X -1556(subsequent)X -1935(word)X -2123(exists)X -2328(on)X -2431(the)X -2552(current)X -2803(line,)X -2966(move)X -3167(to)X -3253(the)X -3375(\256rst)X -3523(character)X -3843(of)X -3934(the)X -776 2922(\256rst)N -920(word)X -1105(on)X -1205(the)X -1323(\256rst)X -1467(following)X -1798(line)X -1938(that)X -2078(contains)X -2365(a)X -2421(word.)X -776 3102(The)N -3 f -928(w)X -1 f -1014(command)X -1358(may)X -1524(be)X -1628(used)X -1803(as)X -1898(the)X -2024(motion)X -2278(component)X -2662(of)X -2757(other)X -3 f -2950(vi)X -1 f -3040(commands,)X -3435(in)X -3525(which)X -3749(case)X -3916(any)X -776 3192(text)N -916(copied)X -1150(into)X -1294(a)X -1350(buffer)X -1567(is)X -1640(character)X -1956(oriented.)X -776 3372(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(containing)X -1956(the)X -2074(word)X -2259(selected.)X -776 3462(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(character)X -1918(of)X -2005(the)X -2123(word)X -2308(selected.)X -776 3552(Options:)N -1136(None.)X -3 f -576 3732([buffer])N -864([count])X -1129(x)X -1 f -776 3822(Delete)N -7 f -1007(count)X -1 f -1268(characters.)X -1656(The)X -1802(deletion)X -2081(is)X -2155(at)X -2235(the)X -2355(current)X -2605(character)X -2923(position.)X -3242(If)X -3318(the)X -3438(number)X -3705(of)X -3794(charac-)X -776 3912(ters)N -915(to)X -1000(be)X -1099(deleted)X -1354(is)X -1430(greater)X -1676(than)X -1836(or)X -1925(equal)X -2121(to)X -2205(the)X -2325(number)X -2592(of)X -2681(characters)X -3030(to)X -3114(the)X -3234(end)X -3372(of)X -3461(the)X -3581(line,)X -3743(all)X -3845(of)X -3934(the)X -776 4002(characters)N -1123(from)X -1299(the)X -1417(current)X -1665(cursor)X -1886(position)X -2163(to)X -2245(the)X -2363(end)X -2499(of)X -2586(the)X -2704(line)X -2844(are)X -2963(deleted.)X -776 4182(Line:)N -1136(Unchanged.)X -776 4272(Column:)N -1136(Unchanged)X -1525(unless)X -1748(the)X -1869(last)X -2003(character)X -2322(in)X -2407(the)X -2528(line)X -2671(is)X -2747(deleted)X -3002(and)X -3141(the)X -3263(cursor)X -3488(is)X -3565(not)X -3691(already)X -3952(on)X -1136 4362(the)N -1254(\256rst)X -1398(character)X -1714(in)X -1796(the)X -1914(line,)X -2074(in)X -2156(which)X -2372(case)X -2531(it)X -2595(is)X -2668(set)X -2777(to)X -2859(the)X -2977(previous)X -3273(character.)X -776 4452(Options:)N -1136(None.)X -3 f -576 4632([buffer])N -864([count])X -1129(y)X -1189(motion)X -1 f -776 4722(Copy)N -981(\(or)X -1107(``yank''\))X -1430(a)X -1498(text)X -1650(region)X -1887(speci\256ed)X -2204(by)X -2316(the)X -7 f -2446(count)X -1 f -2718(and)X -2866(motion)X -3124(into)X -3280(a)X -3349(buffer.)X -3619(If)X -7 f -3706(count)X -1 f -3979(is)X -776 4812(speci\256ed,)N -1101(it)X -1165(is)X -1238(applied)X -1494(to)X -1576(the)X -7 f -1694(motion)X -1 f -(.)S -776 4992(Line:)N -1136(Unchanged,)X -1544(unless)X -1766(the)X -1886(region)X -2113(covers)X -2345(more)X -2532(than)X -2692(a)X -2751(single)X -2965(line,)X -3128(in)X -3213(which)X -3432(case)X -3594(it)X -3661(is)X -3737(set)X -3849(to)X -3934(the)X -1136 5082(line)N -1276(where)X -1493(the)X -1611(region)X -1836(starts.)X -776 5172(Column:)N -1136(Unchanged,)X -1544(unless)X -1766(the)X -1886(region)X -2113(covers)X -2345(more)X -2532(than)X -2692(a)X -2751(single)X -2965(line,)X -3128(in)X -3213(which)X -3432(case)X -3594(it)X -3661(is)X -3737(set)X -3849(to)X -3934(the)X -1136 5262(character)N -1452(were)X -1629(the)X -1747(region)X -1972(starts.)X -776 5352(Options:)N -1136(None.)X -3 f -576 5532([count1])N -881(z)X -937([count2])X -1242(type)X -1 f -776 5622(Redraw)N -1049(the)X -1170(screen)X -1399(with)X -1564(a)X -1623(window)X -7 f -1904(count2)X -1 f -2215(lines)X -2389(long,)X -2574(with)X -2740(line)X -7 f -2884(count1)X -1 f -3196(placed)X -3430(as)X -3521(speci\256ed)X -3830(by)X -3934(the)X -7 f -776 5712(type)N -1 f -1005(character.)X -1378(If)X -7 f -1469(count1)X -1 f -1794(is)X -1884(not)X -2023(speci\256ed,)X -2365(it)X -2445(defaults)X -2735(to)X -2833(the)X -2967(current)X -3231(line.)X -3427(If)X -7 f -3517(count2)X -1 f -3841(is)X -3930(not)X -776 5802(speci\256ed,)N -1101(it)X -1165(defaults)X -1439(to)X -1521(the)X -1639(current)X -1887(window)X -2165(size.)X - -29 p -%%Page: 29 28 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Vi)X -1364(Commands\))X -3658(USD:13-29)X -1 f -776 762(The)N -921(following)X -7 f -1252(type)X -1 f -1464(characters)X -1811(may)X -1969(be)X -2065(used:)X -776 942(+)N -1136(If)X -7 f -1225(count1)X -1 f -1548(is)X -1636(speci\256ed,)X -1977(place)X -2183(the)X -2317(line)X -7 f -2473(count1)X -1 f -2797(at)X -2891(the)X -3025(top)X -3163(of)X -3266(the)X -3400(screen.)X -3682(Otherwise,)X -1136 1032(display)N -1387(the)X -1505(screen)X -1731(after)X -1899(the)X -2017(current)X -2265(screen,)X -2511(similarly)X -2815(to)X -2897(the)X -3 f -3015()X -1 f -3448(command.)X -776 1122 0.2266()AN -1136 1212(Place)N -1330(the)X -1448(line)X -7 f -1588(count1)X -1 f -1896(at)X -1974(the)X -2092(top)X -2214(of)X -2301(the)X -2419(screen.)X -776 1302(.)N -1136(Place)X -1330(the)X -1448(line)X -7 f -1588(count1)X -1 f -1896(in)X -1978(the)X -2096(center)X -2313(of)X -2400(the)X -2518(screen.)X -9 f -776 1392(-)N -1 f -1136(Place)X -1330(the)X -1448(line)X -7 f -1588(count1)X -1 f -1896(at)X -1974(the)X -2092(bottom)X -2338(of)X -2425(the)X -2543(screen.)X -776 1482(\303)N -1136(If)X -7 f -1214(count1)X -1 f -1526(is)X -1603(speci\256ed,)X -1932(place)X -2126(the)X -2248(line)X -2392(that)X -2536(is)X -2613(at)X -2695(the)X -2817(top)X -2943(of)X -3034(the)X -3156(screen)X -3386(when)X -7 f -3584(count1)X -1 f -3896(is)X -3974(at)X -1136 1572(the)N -1264(bottom)X -1520(of)X -1617(the)X -1745(screen,)X -2001(at)X -2089(the)X -2217(bottom)X -2472(of)X -2568(the)X -2695(screen,)X -2950(i.e.)X -3077(display)X -3337(the)X -3464(screen)X -3699(before)X -3934(the)X -1136 1662(screen)N -1362(before)X -7 f -1588(count1)X -1 f -(.)S -1937(Otherwise,)X -2308(display)X -2560(the)X -2679(screen)X -2906(before)X -3133(the)X -3252(current)X -3501(screen,)X -3748(similarly)X -1136 1752(to)N -1218(the)X -3 f -1336()X -1 f -1773(command.)X -776 1932(Line:)N -1136(Set)X -1263(to)X -7 f -1350(count1)X -1 f -1663(unless)X -7 f -1888(count1)X -1 f -2201(is)X -2279(not)X -2406(speci\256ed)X -2716(and)X -2857(the)X -7 f -2980(type)X -1 f -3197(character)X -3518(was)X -3668(either)X -3876(``)X -7 f -3930(\303)X -1 f -('')S -1136 2022(or)N -1224(``)X -7 f -1278(+)X -1 f -('',)S -1421(in)X -1504(which)X -1721(case)X -1881(it)X -1946(is)X -2020(set)X -2130(to)X -2213(the)X -2332(line)X -2473(before)X -2700(the)X -2819(\256rst)X -2964(line)X -3105(on)X -3206(the)X -3325(previous)X -3621(screen)X -3847(or)X -3934(the)X -1136 2112(line)N -1276(after)X -1444(the)X -1562(last)X -1693(line)X -1833(on)X -1933(the)X -2051(previous)X -2347(screen,)X -2593(respectively.)X -776 2202(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(in)X -2318(the)X -2436(line.)X -776 2292(Options:)N -1136(None.)X -3 f -576 2472([count])N -841({)X -1 f -776 2562(Move)N -983(backward)X -7 f -1316(count)X -1 f -1576(paragraphs.)X -776 2742(The)N -3 f -922({)X -1 f -975(command)X -1312(is)X -1386(an)X -1483(absolute)X -1771(movement.)X -2170(The)X -3 f -2316({)X -1 f -2369(command)X -2706(may)X -2865(be)X -2962(used)X -3130(as)X -3219(the)X -3339(motion)X -3587(component)X -3965(of)X -776 2832(other)N -3 f -963(vi)X -1 f -1047(commands,)X -1436(in)X -1520(which)X -1738(case)X -1899(any)X -2036(text)X -2177(copied)X -2412(into)X -2557(a)X -2614(buffer)X -2832(is)X -2906(character)X -3223(oriented,)X -3527(unless)X -3748(the)X -3867(start-)X -776 2922(ing)N -898(character)X -1214(is)X -1287(the)X -1405(\256rst)X -1549(character)X -1865(on)X -1965(its)X -2060(line,)X -2220(in)X -2302(which)X -2518(case)X -2677(it)X -2741(is)X -2814(line)X -2954(oriented.)X -776 3102(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(containing)X -1956(the)X -2074(beginning)X -2414(of)X -2501(the)X -2619(previous)X -2915(paragraph.)X -776 3192(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(in)X -2318(the)X -2436(line.)X -776 3282(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(paragraph)X -1 f -2040(option.)X -3 f -576 3462([count])N -841(|)X -1 f -776 3552(Move)N -983(to)X -1065(a)X -1121(speci\256c)X -2 f -1386(column)X -1 f -1642(position)X -1919(on)X -2019(the)X -2137(current)X -2385(line.)X -776 3732(The)N -3 f -922(|)X -1 f -962(command)X -1300(may)X -1460(be)X -1558(used)X -1727(as)X -1816(the)X -1936(motion)X -2184(component)X -2562(of)X -2651(other)X -3 f -2838(vi)X -1 f -2922(commands,)X -3311(in)X -3395(which)X -3613(case)X -3774(any)X -3912(text)X -776 3822(copied)N -1012(into)X -1158(a)X -1216(buffer)X -1435(is)X -1510(character)X -1828(oriented.)X -2153(It)X -2224(is)X -2299(an)X -2397(error)X -2576(to)X -2660(use)X -2789(the)X -3 f -2908(|)X -1 f -2947(command)X -3284(as)X -3372(a)X -3429(motion)X -3676(component)X -776 3912(and)N -912(for)X -1026(the)X -1144(cursor)X -1365(not)X -1487(to)X -1569(move.)X -776 4092(Line:)N -1136(Unchanged.)X -776 4182(Column:)N -1136(Set)X -1265(to)X -1355(the)X -1481(character)X -1805(occupying)X -2167(the)X -2293(column)X -2561(position)X -2846(identi\256ed)X -3176(by)X -7 f -3284(count)X -1 f -(,)S -3572(if)X -3649(the)X -3775(position)X -1136 4272(exists)N -1339(in)X -1422(the)X -1541(line.)X -1722(If)X -1797(the)X -1916(column)X -2176(length)X -2396(of)X -2483(the)X -2601(current)X -2849(line)X -2989(is)X -3062(less)X -3202(than)X -7 f -3360(count)X -1 f -(,)S -3640(the)X -3758(cursor)X -3979(is)X -1136 4362(moved)N -1374(to)X -1456(the)X -1574(last)X -1705(character)X -2021(in)X -2103(the)X -2221(line.)X -776 4452(Options:)N -1136(None.)X -3 f -576 4632([count])N -841(})X -1 f -776 4722(Move)N -983(forward)X -7 f -1258(count)X -1 f -1518(paragraphs.)X -776 4902(The)N -3 f -922(})X -1 f -975(command)X -1312(is)X -1386(an)X -1483(absolute)X -1771(movement.)X -2170(The)X -3 f -2316(})X -1 f -2369(command)X -2706(may)X -2865(be)X -2962(used)X -3130(as)X -3219(the)X -3339(motion)X -3587(component)X -3965(of)X -776 4992(other)N -3 f -963(vi)X -1 f -1047(commands,)X -1436(in)X -1520(which)X -1738(case)X -1899(any)X -2036(text)X -2177(copied)X -2412(into)X -2557(a)X -2614(buffer)X -2832(is)X -2906(character)X -3223(oriented,)X -3527(unless)X -3748(the)X -3867(start-)X -776 5082(ing)N -898(character)X -1214(is)X -1287(at)X -1365(or)X -1452(before)X -1678(any)X -1814(nonblank)X -2132(characters)X -2479(in)X -2561(its)X -2656(line,)X -2816(in)X -2898(which)X -3114(case)X -3273(it)X -3337(is)X -3410(line)X -3550(oriented.)X -776 5262(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(containing)X -1956(the)X -2074(beginning)X -2414(of)X -2501(the)X -2619(next)X -2777(paragraph.)X -776 5352(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(\256rst)X -1602(nonblank)X -1920(character)X -2236(in)X -2318(the)X -2436(line.)X -776 5442(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(paragraph)X -1 f -2040(option.)X -3 f -576 5622([count])N -841(\304)X -1 f -776 5712(Reverse)N -1062(the)X -1187(case)X -1353(of)X -1447(the)X -1572(next)X -7 f -1738(count)X -1 f -2006 0.3021(character\(s\).)AX -2455(This)X -2625(is)X -2706(the)X -2832(historic)X -3100(semantic)X -3413(for)X -3535(the)X -3 f -3661(\304)X -1 f -3716(command)X -776 5802(and)N -912(it)X -976(is)X -1049(only)X -1211(in)X -1293(effect)X -1497(if)X -1566(the)X -3 f -1684(tildeop)X -1 f -1939(option)X -2163(is)X -2236(not)X -2358(set.)X - -30 p -%%Page: 30 29 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-30)N -2826(Nvi/Nex)X -3122 0.3906(Reference)AX -3487(\(Vi)X -3614(Commands\))X -1 f -776 762(Lowercase)N -1148(alphabetic)X -1501(characters)X -1851(are)X -1974(changed)X -2266(to)X -2352(uppercase,)X -2718(and)X -2858(uppercase)X -3204(characters)X -3555(are)X -3678(changed)X -3970(to)X -776 852(lowercase.)N -1158(No)X -1276(other)X -1461(characters)X -1808(are)X -1927(affected.)X -776 1032(Historically,)N -1203(the)X -3 f -1330(\304)X -1 f -1386(command)X -1731(did)X -1863(not)X -1995(take)X -2159(an)X -2265(associated)X -2625(count,)X -2853(nor)X -2990(did)X -3122(it)X -3196(move)X -3404(past)X -3563(the)X -3691(end)X -3837(of)X -3934(the)X -776 1122(current)N -1025(line.)X -1206(As)X -1316(it)X -1381(had)X -1518(no)X -1619(associated)X -1970(motion)X -2217(it)X -2282(was)X -2428(dif\256cult)X -2701(to)X -2783(change)X -3031(the)X -3149(case)X -3308(of)X -3395(large)X -3576(blocks)X -3805(of)X -3892(text.)X -776 1212(In)N -3 f -868(nvi)X -1 f -974(,)X -1019(if)X -1093(the)X -1216(cursor)X -1442(is)X -1520(on)X -1625(the)X -1748(last)X -1884(character)X -2205(of)X -2297(a)X -2359(line,)X -2525(and)X -2667(there)X -2854(are)X -2979(more)X -3170(lines)X -3347(in)X -3435(the)X -3559(\256le,)X -3707(the)X -3831(cursor)X -776 1302(moves)N -1005(to)X -1087(the)X -1205(next)X -1363(line.)X -776 1482(It)N -849(is)X -926(not)X -1052(an)X -1152(error)X -1333(to)X -1419(specify)X -1675(a)X -1735(count)X -1938(larger)X -2151(than)X -2314(the)X -2437(number)X -2707(of)X -2799(characters)X -3151(between)X -3444(the)X -3567(cursor)X -3793(and)X -3934(the)X -776 1572(end)N -912(of)X -999(the)X -1117(\256le.)X -776 1752(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(of)X -1685(the)X -1803(character)X -2119(after)X -7 f -2287(count)X -1 f -2547(characters,)X -2914(or,)X -3021(end)X -3157(of)X -3244(\256le.)X -776 1842(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(character)X -1774(after)X -7 f -1942(count)X -1 f -2202(characters,)X -2569(or,)X -2676(end-of-\256le.)X -776 1932(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(tildeop)X -1 f -1911(option.)X -3 f -576 2112([count])N -841(\304)X -888(motion)X -1 f -776 2202(Reverse)N -1063(the)X -1189(case)X -1356(of)X -1451(the)X -1577(characters)X -1932(in)X -2022(a)X -2086(text)X -2234(region)X -2467(speci\256ed)X -2780(by)X -2888(the)X -7 f -3014(count)X -1 f -3282(and)X -7 f -3426(motion)X -1 f -(.)S -3782(Only)X -3970(in)X -776 2292(effect)N -980(if)X -1049(the)X -3 f -1167(tildeop)X -1 f -1422(option)X -1646(is)X -1719(set.)X -776 2472(Lowercase)N -1147(characters)X -1496(are)X -1617(changed)X -1908(to)X -1993(uppercase,)X -2358(and)X -2497(uppercase)X -2842(characters)X -3192(are)X -3314(changed)X -3605(to)X -3690(lowercase.)X -776 2562(No)N -894(other)X -1079(characters)X -1426(are)X -1545(affected.)X -776 2742(Line:)N -1136(Set)X -1258(to)X -1340(the)X -1458(line)X -1598(of)X -1685(the)X -1803(character)X -2119(after)X -2287(the)X -2405(last)X -2536(character)X -2852(in)X -2934(the)X -3052(region.)X -776 2832(Column:)N -1136(Set)X -1258(to)X -1340(the)X -1458(character)X -1774(after)X -1942(the)X -2060(last)X -2191(character)X -2507(in)X -2589(the)X -2707(region.)X -776 2922(Options:)N -1136(Affected)X -1438(by)X -1538(the)X -3 f -1656(tildeop)X -1 f -1911(option.)X -3 f -576 3102()N -1 f -776 3192(Interrupt)N -1087(the)X -1215(current)X -1473(operation.)X -1846(Many)X -2063(of)X -2160(the)X -2289(potentially)X -2662(long-running)X -3 f -3111(vi)X -1 f -3204(commands)X -3582(may)X -3751(be)X -3858(inter-)X -776 3282(rupted)N -1014(using)X -1220(the)X -1351(terminal)X -1650(interrupt)X -1958(character.)X -2326(These)X -2550(operations)X -2916(include)X -3184(searches,)X -3509(\256le)X -3643(reading)X -3916(and)X -776 3372(writing,)N -1059(\256lter)X -1242(operations)X -1608(and)X -1756(map)X -1927(character)X -2256(expansion.)X -2654(Interrupts)X -2999(are)X -3131(also)X -3293(enabled)X -3576(when)X -3783(running)X -776 3462(commands)N -1143(outside)X -1394(of)X -3 f -1481(vi)X -1 f -1543(.)X -776 3642(If)N -853(the)X -7 f -974()X -1 f -1525(character)X -1844(is)X -1920(used)X -2090(to)X -2175(interrupt)X -2474(while)X -2675(entering)X -2961(an)X -3 f -3060(ex)X -1 f -3159(command,)X -3518(the)X -3639(command)X -3979(is)X -776 3732(aborted,)N -1057(the)X -1175(cursor)X -1396(returns)X -1639(to)X -1721(its)X -1816(previous)X -2112(position,)X -2409(and)X -3 f -2545(vi)X -1 f -2627(remains)X -2901(in)X -2983(command)X -3319(mode.)X -776 3912(Generally,)N -1145(if)X -1226(the)X -7 f -1356()X -1 f -1916(character)X -2244(is)X -2329(used)X -2508(to)X -2603(interrupt)X -2912(any)X -3061(operation,)X -3417(any)X -3566(changes)X -3858(made)X -776 4002(before)N -1002(the)X -1120(interrupt)X -1416(are)X -1535(left)X -1662(in)X -1744(place.)X -776 4182(Line:)N -1136(Dependent)X -1504(on)X -1604(the)X -1722(operation)X -2045(being)X -2243(interrupted.)X -776 4272(Column:)N -1136(Dependent)X -1504(on)X -1604(the)X -1722(operation)X -2045(being)X -2243(interrupted.)X -776 4362(Options:)N -1136(None.)X -3 f -776 4548(11.)N -916(Vi)X -1016(Text)X -1192(Input)X -1402(Commands)X -1 f -976 4671(The)N -1121(following)X -1452(section)X -1699(describes)X -2018(the)X -2136(commands)X -2503(available)X -2813(in)X -2895(the)X -3013(text)X -3153(input)X -3337(mode)X -3535(of)X -3622(the)X -3 f -3740(vi)X -1 f -3822(editor.)X -976 4794(Historically,)N -3 f -1394(vi)X -1 f -1476(implementations)X -2030(only)X -2193(permitted)X -2521(the)X -2640(characters)X -2988(inserted)X -3263(on)X -3364(the)X -3483(current)X -3732(line)X -3873(to)X -3956(be)X -776 4884(erased.)N -1060(In)X -1165(addition,)X -1485(only)X -1665(the)X -7 f -1801()X -1 f -2367(erase)X -2571(character)X -2905(and)X -3059(the)X -3195(``)X -7 f -3249(0)X -1 f -('')S -3916(and)X -776 4974(``)N -7 f -830(\303)X -1 f -('')S -1488(erase)X -1683(strings)X -1925(could)X -2132(erase)X -2327(autoindent)X -2694(characters.)X -3090(This)X -3261(implementation)X -3792(permits)X -776 5064(erasure)N -1038(to)X -1129(continue)X -1434(past)X -1592(the)X -1719(beginning)X -2068(of)X -2164(the)X -2291(current)X -2548(line,)X -2717(and)X -2862(back)X -3043(to)X -3134(where)X -3360(text)X -3509(input)X -3701(mode)X -3907(was)X -776 5154(entered.)N -1080(In)X -1174(addition,)X -1483(autoindent)X -1848(characters)X -2202(may)X -2367(be)X -2471(erased)X -2705(using)X -2906(the)X -3032(standard)X -3332(erase)X -3526(characters.)X -3921(For)X -776 5244(the)N -908(line)X -1061(and)X -1210(word)X -1408(erase)X -1607(characters,)X -1987(reaching)X -2297(the)X -2428(autoindent)X -2799(characters)X -3159(forms)X -3379(a)X -3448(``soft'')X -3709(boundary,)X -776 5334(denoting)N -1081(the)X -1204(end)X -1345(of)X -1437(the)X -1561(current)X -1815(word)X -2006(or)X -2099(line)X -2245(erase.)X -2477(Repeating)X -2828(the)X -2952(word)X -3143(or)X -3236(line)X -3382(erase)X -3574(key)X -3716(will)X -3866(erase)X -776 5424(the)N -894(autoindent)X -1252(characters.)X -976 5547(Historically,)N -3 f -1396(vi)X -1 f -1480(always)X -1725(used)X -7 f -1894()X -1 f -2444(and)X -7 f -2582()X -1 f -3132(as)X -3221(character)X -3539(and)X -3678(word)X -3866(erase)X -776 5637(characters,)N -1148(respectively,)X -1581(regardless)X -1932(of)X -2024(the)X -2146(current)X -2398(terminal)X -2689(settings.)X -2997(This)X -3163(implementation)X -3689(accepts,)X -3970(in)X -776 5727(addition)N -1058(to)X -1140(these)X -1325(two)X -1465(characters,)X -1832(the)X -1950(current)X -2198(terminal)X -2485(characters)X -2832(for)X -2946(those)X -3135(operations.)X - -31 p -%%Page: 31 30 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Vi)X -1364(Commands\))X -3658(USD:13-31)X -776 762()N -1 f -976 852(If)N -1050(the)X -1168(\256rst)X -1312(character)X -1628(of)X -1715(the)X -1833(input)X -2017(is)X -2090(a)X -7 f -2146()X -1 f -(,)S -2426(the)X -2544(previous)X -2840(input)X -3024(is)X -3097(replayed,)X -3414(as)X -3501(if)X -3570(just)X -3705(entered.)X -3 f -776 1032()N -1 f -976 1122(If)N -1058(the)X -1184(previous)X -1488(character)X -1813(on)X -1922(the)X -2049(line)X -2198(was)X -2352(an)X -2457(autoindent)X -2824(character,)X -3169(erase)X -3364(it.)X -3477(Otherwise,)X -3856(if)X -3934(the)X -976 1212(user)N -1135(is)X -1213(entering)X -1501(the)X -1624(\256rst)X -1773(character)X -2094(in)X -2181(the)X -2304(line,)X -7 f -2469()X -1 f -3022(is)X -3100(ignored.)X -3410(Otherwise,)X -3785(a)X -3845(literal)X -7 f -976 1302()N -1 f -1524(character)X -1840(is)X -1913(entered.)X -3 f -776 1482(\303)N -1 f -976 1572(If)N -1058(the)X -1184(previous)X -1488(character)X -1812(on)X -1920(the)X -2047(line)X -2196(was)X -2350(an)X -2455(autoindent)X -2822(character,)X -3167(erase)X -3362(all)X -3471(of)X -3567(the)X -3694(autoindent)X -976 1662(characters)N -1323(on)X -1423(the)X -1541(line.)X -1721(In)X -1808(addition,)X -2110(the)X -2228(autoindent)X -2586(level)X -2762(is)X -2835(reset)X -3007(to)X -3089(0.)X -3 f -776 1842(0)N -1 f -976 1932(If)N -1058(the)X -1184(previous)X -1488(character)X -1812(on)X -1920(the)X -2047(line)X -2196(was)X -2350(an)X -2455(autoindent)X -2822(character,)X -3167(erase)X -3362(all)X -3471(of)X -3567(the)X -3694(autoindent)X -976 2022(characters)N -1323(on)X -1423(the)X -1541(line.)X -3 f -776 2202()N -1 f -976 2292(Insert)N -1191(suf\256cient)X -7 f -1521()X -1 f -1793(and)X -7 f -1941()X -1 f -2309(characters)X -2669(to)X -2764(move)X -2975(the)X -3106(cursor)X -3340(forward)X -3628(to)X -3723(a)X -3792(column)X -976 2382(immediately)N -1396(after)X -1564(the)X -1682(next)X -1840(column)X -2100(which)X -2316(is)X -2389(an)X -2485(even)X -2657(multiple)X -2943(of)X -3030(the)X -3 f -3148(shiftwidth)X -1 f -3514(option.)X -976 2562(Historically,)N -3 f -1397(vi)X -1 f -1482(did)X -1607(not)X -1732(permit)X -1965(the)X -7 f -2087()X -1 f -2639(command)X -2979(to)X -3065(be)X -3165(used)X -3336(unless)X -3560(the)X -3682(cursor)X -3907(was)X -976 2652(at)N -1056(the)X -1176(\256rst)X -1322(column)X -1584(of)X -1673(a)X -1731(new)X -1887(line)X -2029(or)X -2117(it)X -2182(was)X -2328(preceded)X -2640(only)X -2803(by)X -2904(autoindent)X -3263(characters.)X -3 f -3651(Nvi)X -1 f -3792(permits)X -976 2742(it)N -1040(to)X -1122(be)X -1218(used)X -1385(at)X -1463(any)X -1599(time)X -1761(during)X -1990(insert)X -2188(mode.)X -3 f -776 2922()N -776 3012()N -1 f -976 3102(Erase)N -1175(the)X -1293(last)X -1424(character.)X -3 f -776 3282()X -1 f -976 3372(Quote)N -1197(the)X -1320(next)X -1483(character.)X -1844(The)X -1994(next)X -2157(character)X -2479(will)X -2629(not)X -2757(be)X -2859(mapped)X -3139(\(see)X -3295(the)X -3 f -3419(map)X -1 f -3596(command)X -3938(for)X -976 3462(more)N -1162(information\))X -1588(or)X -1676(interpreted)X -2045(specially.)X -2391(A)X -2470(carat)X -2648(\(``)X -7 f -2729(\303)X -1 f -(''\))S -2878(character)X -3194(will)X -3338(be)X -3434(displayed)X -3761(immedi-)X -976 3552(ately)N -1152(as)X -1239(a)X -1295(placeholder,)X -1710(but)X -1832(will)X -1976(be)X -2072(replaced)X -2365(by)X -2465(the)X -2583(next)X -2741(character.)X -3 f -776 3732()N -1 f -976 3822(Resolve)N -1254(all)X -1354(text)X -1494(input)X -1678(into)X -1822(the)X -1940(\256le,)X -2082(and)X -2218(return)X -2430(to)X -2512(command)X -2848(mode.)X -3 f -776 4002()X -1 f -976 4092(Erase)N -1175(the)X -1293(current)X -1541(line.)X -3 f -776 4272()N -776 4362()X -1 f -976 4452(Erase)N -1188(the)X -1319(last)X -1463(word.)X -1701(The)X -1859(de\256nition)X -2198(of)X -2298(word)X -2496(is)X -2582(dependent)X -2945(on)X -3059(the)X -3 f -3191(altwerase)X -1 f -3551(and)X -3 f -3701(ttywerase)X -1 f -976 4542(options.)N -3 f -776 4722 0.2102([0-9A-Fa-f]*)AN -1 f -976 4812(Insert)N -1179(a)X -1235(character)X -1551(with)X -1713(the)X -1831(speci\256ed)X -2136(hexadecimal)X -2562(value)X -2756(into)X -2900(the)X -3018(text.)X -3 f -776 4992()N -1 f -976 5082(Interrupt)N -1288(text)X -1439(input)X -1634(mode,)X -1863(returning)X -2188(to)X -2281(command)X -2628(mode.)X -2877(If)X -2962(the)X -7 f -3091()X -1 f -3651(character)X -3979(is)X -976 5172(used)N -1151(to)X -1241(interrupt)X -1545(inserting)X -1852(text)X -1999(into)X -2150(the)X -2275(\256le,)X -2424(it)X -2495(is)X -2575(as)X -2669(if)X -2745(the)X -7 f -2870()X -1 f -3281(character)X -3604(was)X -3756(used;)X -3952(all)X -976 5262(text)N -1116(input)X -1300(up)X -1400(to)X -1482(the)X -1600(interruption)X -1998(is)X -2071(resolved)X -2363(into)X -2507(the)X -2625(\256le.)X -3 f -776 5448(12.)N -916(Ex)X -1029(Addressing)X -1 f -976 5571(Addressing)N -1363(in)X -3 f -1447(ex)X -1 f -1545(\(and)X -1710(when)X -3 f -1906(ex)X -1 f -2004(commands)X -2373(are)X -2494(executed)X -2802(from)X -3 f -2980(vi)X -1 f -3042(\))X -3092(relates)X -3325(to)X -3410(the)X -3531(current)X -3782(line.)X -3965(In)X -776 5661(general,)N -1054(the)X -1172(current)X -1420(line)X -1560(is)X -1633(the)X -1751(last)X -1882(line)X -2022(affected)X -2302(by)X -2402(a)X -2458(command.)X -2834(The)X -2979(exact)X -3169(effect)X -3373(on)X -3473(the)X -3591(current)X -3839(line)X -3979(is)X -776 5751(discussed)N -1103(under)X -1306(the)X -1424(description)X -1800(of)X -1888(each)X -2057(command.)X -2434(When)X -2647(the)X -2766(\256le)X -2889(contains)X -3177(no)X -3278(lines,)X -3470(the)X -3589(current)X -3838(line)X -3979(is)X - -32 p -%%Page: 32 31 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-32)N -3391(Nvi/Nex)X -3687 0.3906(Reference)AX -1 f -776 762(zero.)N -976 885(Addresses)N -1326(are)X -1445(constructed)X -1835(by)X -1935(one)X -2071(or)X -2158(more)X -2343(of)X -2430(the)X -2548(following)X -2879(methods:)X -816 1008(\(1\))N -1030(The)X -1175(address)X -1436(``)X -7 f -1490(.)X -1 f -('')S -1632(refers)X -1836(to)X -1918(the)X -2036(current)X -2284(line.)X -816 1131(\(2\))N -1030(The)X -1175(address)X -1436(``)X -7 f -1490($)X -1 f -('')S -1612(refers)X -1816(to)X -1898(the)X -2016(last)X -2147(line)X -2287(of)X -2374(the)X -2492(\256le.)X -816 1254(\(3\))N -1030(The)X -1175(address)X -1436(``)X -7 f -1490(N)X -1 f -('',)S -1632(where)X -7 f -1849(N)X -1 f -1917(is)X -1990(a)X -2046(positive)X -2319(number,)X -2604(refers)X -2808(to)X -2890(the)X -3008(N-th)X -3175(line)X -3315(of)X -3402(the)X -3520(\256le.)X -816 1377(\(4\))N -1030(The)X -1178(address)X -1442(``)X -7 f -1496(')X -1 f -('')S -2149(or)X -2239(``)X -7 f -2293(`)X -1 f -('')S -2946(refers)X -3153(to)X -3238(the)X -3359(line)X -3503(marked)X -3768(with)X -3934(the)X -1030 1467(name)N -7 f -1234()X -1 f -(.)S -1832(\(See)X -2005(the)X -3 f -2133(k)X -1 f -2207(or)X -3 f -2304(m)X -1 f -2400(commands)X -2776(for)X -2899(more)X -3093(information)X -3500(on)X -3609(how)X -3776(to)X -3867(mark)X -1030 1557(lines.\))N -816 1680(\(5\))N -1030(A)X -1113(regular)X -1366(expression)X -1734(\(RE\))X -1915(enclosed)X -2221(by)X -2326(slashes)X -2578(\(``)X -7 f -2659(/)X -1 f -(''\))S -2813(is)X -2891(an)X -2992(address,)X -3278(and)X -3419(it)X -3488(refers)X -3697(to)X -3784(the)X -3908(\256rst)X -1030 1770(line)N -1171(found)X -1379(by)X -1480(searching)X -1809(forward)X -2085(from)X -2262(the)X -2381(line)X -2 f -2522(after)X -1 f -2694(the)X -2813(current)X -3062(line)X -3203(toward)X -3447(the)X -3566(end)X -3703(of)X -3791(the)X -3910(\256le,)X -1030 1860(and)N -1170(stopping)X -1469(at)X -1551(the)X -1673(\256rst)X -1821(line)X -1965(containing)X -2327(a)X -2387(string)X -2593(matching)X -2915(the)X -3037(RE.)X -3203(\(The)X -3379(trailing)X -3634(slash)X -3819(can)X -3956(be)X -1030 1950(omitted)N -1294(at)X -1372(the)X -1490(end)X -1626(of)X -1713(the)X -1831(command)X -2167(line.\))X -1030 2130(If)N -1104(no)X -1204(RE)X -1326(is)X -1399(speci\256ed,)X -1724(i.e.)X -1842(the)X -1960(pattern)X -2203(is)X -2276(``)X -7 f -2330(//)X -1 f -('',)S -2520(the)X -2638(last)X -2769(RE)X -2891(used)X -3058(in)X -3140(any)X -3276(command)X -3612(is)X -3685(used)X -3852(in)X -3934(the)X -1030 2220(search.)N -1030 2400(If)N -1111(the)X -3 f -1236(extended)X -1 f -1570(option)X -1801(is)X -1881(set,)X -2017(the)X -2142(RE)X -2271(is)X -2351(handled)X -2632(as)X -2726(an)X -2829(extended)X -3146(RE,)X -3295(not)X -3425(a)X -3489(basic)X -3682(RE.)X -3852(If)X -3934(the)X -3 f -1030 2490(wrapscan)N -1 f -1381(option)X -1607(is)X -1681(set,)X -1811(the)X -1930(search)X -2157(wraps)X -2370(around)X -2614(to)X -2697(the)X -2816(beginning)X -3157(of)X -3245(the)X -3364(\256le)X -3487(and)X -3624(continues)X -3952(up)X -1030 2580(to)N -1112(and)X -1248(including)X -1570(the)X -1688(current)X -1936(line,)X -2096(so)X -2187(that)X -2327(the)X -2445(entire)X -2648(\256le)X -2770(is)X -2843(searched.)X -1030 2760(The)N -1175(form)X -1351(``)X -7 f -1405(\\/)X -1 f -('')S -1575(is)X -1648(accepted)X -1950(for)X -2064(historic)X -2324(reasons,)X -2605(and)X -2741(is)X -2814(identical)X -3110(to)X -3192(``)X -7 f -3246(//)X -1 f -(''.)S -816 2883(\(6\))N -1030(An)X -1153(RE)X -1280(enclosed)X -1586(in)X -1673(question)X -1969(marks)X -2190(\(``)X -7 f -2271(?)X -1 f -(''\))S -2446(addresses)X -2780(the)X -2904(\256rst)X -3054(line)X -3200(found)X -3413(by)X -3519(searching)X -3853(back-)X -1030 2973(ward)N -1212(from)X -1389(the)X -1508(line)X -2 f -1648(preceding)X -1 f -1989(the)X -2107(current)X -2355(line,)X -2515(toward)X -2758(the)X -2876(beginning)X -3216(of)X -3303(the)X -3421(\256le)X -3543(and)X -3679(stopping)X -3974(at)X -1030 3063(the)N -1149(\256rst)X -1294(line)X -1435(containing)X -1794(a)X -1851(string)X -2054(matching)X -2373(the)X -2492(RE.)X -2655(\(The)X -2828(trailing)X -3080(question)X -3372(mark)X -3558(can)X -3691(be)X -3788(omitted)X -1030 3153(at)N -1108(the)X -1226(end)X -1362(of)X -1449(a)X -1505(command)X -1841(line.\))X -1030 3333(If)N -1104(no)X -1204(RE)X -1326(is)X -1399(speci\256ed,)X -1724(i.e.)X -1842(the)X -1960(pattern)X -2203(is)X -2276(``)X -7 f -2330(??)X -1 f -('',)S -2520(the)X -2638(last)X -2769(RE)X -2891(used)X -3058(in)X -3140(any)X -3276(command)X -3612(is)X -3685(used)X -3852(in)X -3934(the)X -1030 3423(search.)N -1030 3603(If)N -1111(the)X -3 f -1236(extended)X -1 f -1570(option)X -1801(is)X -1881(set,)X -2017(the)X -2142(RE)X -2271(is)X -2351(handled)X -2632(as)X -2726(an)X -2829(extended)X -3146(RE,)X -3295(not)X -3425(a)X -3489(basic)X -3682(RE.)X -3852(If)X -3934(the)X -3 f -1030 3693(wrapscan)N -1 f -1382(option)X -1609(is)X -1685(set,)X -1817(the)X -1938(search)X -2187(wraps)X -2402(around)X -2648(from)X -2827(the)X -2948(beginning)X -3290(of)X -3379(the)X -3499(\256le)X -3623(to)X -3707(the)X -3827(end)X -3965(of)X -1030 3783(the)N -1148(\256le)X -1270(and)X -1406(continues)X -1733(up)X -1833(to)X -1915(and)X -2051(including)X -2373(the)X -2491(current)X -2739(line,)X -2899(so)X -2990(that)X -3130(the)X -3248(entire)X -3451(\256le)X -3573(is)X -3646(searched.)X -1030 3963(The)N -1175(form)X -1351(``)X -7 f -1405(\\?)X -1 f -('')S -1595(is)X -1668(accepted)X -1970(for)X -2084(historic)X -2344(reasons,)X -2625(and)X -2761(is)X -2834(identical)X -3130(to)X -3212(``)X -7 f -3266(??)X -1 f -(''.)S -816 4086(\(7\))N -1030(An)X -1148(address)X -1409(followed)X -1714(by)X -1814(a)X -1870(plus)X -2023(sign)X -2176(\(``)X -7 f -2257(+)X -1 f -(''\))S -2406(or)X -2494(a)X -2551(minus)X -2767(sign)X -2921(\(``)X -7 f -3002(-)X -1 f -(''\))S -3152(followed)X -3458(by)X -3559(a)X -3616(number)X -3882(is)X -3956(an)X -1030 4176(offset)N -1237(address)X -1502(and)X -1642(refers)X -1850(to)X -1936(the)X -2058(address)X -2323(plus)X -2480(\(or)X -2598(minus\))X -2844(the)X -2966(indicated)X -3284(number)X -3553(of)X -3643(lines.)X -3857(If)X -3934(the)X -1030 4266(address)N -1291(is)X -1364(omitted,)X -1648(the)X -1766(addition)X -2048(or)X -2135(subtraction)X -2511(is)X -2584(done)X -2760(with)X -2922(respect)X -3170(to)X -3252(the)X -3370(current)X -3618(line.)X -816 4389(\(8\))N -1030(An)X -1158(address)X -1429(of)X -1526(``)X -7 f -1580(+)X -1 f -('')S -1712(or)X -1809(``)X -7 f -9 f -1863(-)X -1 f -1907('')X -1991(followed)X -2306(by)X -2416(a)X -2482(number)X -2757(is)X -2840(an)X -2946(offset)X -3159(from)X -3345(the)X -3473(current)X -3731(line.)X -3921(For)X -1030 4479(example,)N -1342(``)X -7 f -9 f -1396(-)X -7 f -1440(5)X -1 f -('')S -1562(is)X -1635(the)X -1753(same)X -1938(as)X -2025(``)X -7 f -2079(.)X -9 f -(-)S -7 f -2171(5)X -1 f -(''.)S -816 4602(\(9\))N -1030(An)X -1151(address)X -1415(ending)X -1656(with)X -1821(``)X -7 f -1875(+)X -1 f -('')S -2000(or)X -2090(``)X -7 f -2144(-)X -1 f -('')S -2270(has)X -2401(1)X -2465(added)X -2681(to)X -2767(or)X -2858(subtracted)X -3212(from)X -3392(the)X -3514(address,)X -3799(respec-)X -1030 4692(tively.)N -1276(As)X -1389(a)X -1449(consequence)X -1884(of)X -1975(this)X -2114(rule)X -2263(and)X -2403(of)X -2494(the)X -2615(previous)X -2914(rule,)X -3082(the)X -3203(address)X -3467(``)X -7 f -9 f -3521(-)X -1 f -3565('')X -3642(refers)X -3849(to)X -3934(the)X -1030 4782(line)N -1173(preceding)X -1513(the)X -1634(current)X -1886(line.)X -2070(Moreover,)X -2431(trailing)X -2686(``)X -7 f -2740(+)X -1 f -('')S -2866(and)X -3006(``)X -7 f -9 f -3060(-)X -1 f -3104('')X -3182(characters)X -3533(have)X -3709(a)X -3769(cumula-)X -1030 4872(tive)N -1170(effect.)X -1414(For)X -1545(example,)X -1857(``)X -7 f -1911(++)X -9 f -(-)S -7 f -2051(++)X -1 f -('')S -2221(refers)X -2425(to)X -2507(the)X -2625(current)X -2873(line)X -3013(plus)X -3166(3.)X -816 4995(\(10\))N -1030(A)X -1108(percent)X -1365(sign)X -1518(\(``)X -7 f -1599(%)X -1 f -(''\))S -1748(is)X -1821(equivalent)X -2175(to)X -2257(the)X -2375(address)X -2636(range)X -2835(``)X -7 f -2889(1,$)X -1 f -(''.)S -3 f -976 5118(Ex)N -1 f -1099(commands)X -1476(require)X -1734(zero,)X -1923(one,)X -2089(or)X -2186(two)X -2336(addresses.)X -2714(It)X -2793(is)X -2876(an)X -2982(error)X -3169(to)X -3261(specify)X -3524(an)X -3631(address)X -3903(to)X -3996(a)X -776 5208(command)N -1112(which)X -1328(requires)X -1607(zero)X -1766(addresses.)X -976 5331(If)N -1053(the)X -1174(user)X -1331(provides)X -1630(more)X -1818(than)X -1979(the)X -2100(expected)X -2409(number)X -2677(of)X -2768(addresses)X -3100(to)X -3186(any)X -3 f -3326(ex)X -1 f -3426(command,)X -3786(the)X -3908(\256rst)X -776 5421(addresses)N -1108(speci\256ed)X -1417(are)X -1540(discarded.)X -1912(For)X -2047(example,)X -2362(``)X -7 f -2416(1,2,3,5)X -1 f -(''print)S -2980(prints)X -3185(lines)X -3359(3)X -3422(through)X -3694(5,)X -3777(because)X -776 5511(the)N -3 f -894(print)X -1 f -1087(command)X -1423(only)X -1585(takes)X -1770(two)X -1910(addresses.)X -976 5634(The)N -1131(addresses)X -1469(in)X -1561(a)X -1627(range)X -1836(are)X -1965(separated)X -2299(from)X -2485(each)X -2663(other)X -2858(by)X -2968(a)X -3034(comma)X -3300(\(``)X -7 f -3381(,)X -1 f -(''\))S -3540(or)X -3637(a)X -3703(semicolon)X -776 5724(\(``)N -7 f -857(;)X -1 f -(''\).)S -1058(In)X -1157(the)X -1287(latter)X -1484(case,)X -1675(the)X -1805(current)X -2065(line)X -2217(\(``)X -7 f -2298(.)X -1 f -(''\))S -2479(is)X -2564(set)X -2685(to)X -2779(the)X -2909(\256rst)X -3065(address,)X -3358(and)X -3506(only)X -3680(then)X -3850(is)X -3934(the)X - -33 p -%%Page: 33 32 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -3658(USD:13-33)X -1 f -776 762(second)N -1026(address)X -1295(calculated.)X -1689(This)X -1859(feature)X -2111(can)X -2251(be)X -2355(used)X -2530(to)X -2620(determine)X -2969(the)X -3095(starting)X -3363(line)X -3511(for)X -3633(forward)X -3916(and)X -776 852(backward)N -1116(searches)X -1416(\(see)X -1572(rules)X -1754(\(5\))X -1874(and)X -2016(\(6\))X -2136(above\).)X -2421(The)X -2572(second)X -2821(address)X -3088(of)X -3181(any)X -3323(two-address)X -3737(sequence)X -776 942(corresponds)N -1193(to)X -1284(a)X -1349(line)X -1498(that)X -1647(follows,)X -1936(in)X -2027(the)X -2154(\256le,)X -2305(the)X -2432(line)X -2581(corresponding)X -3069(to)X -3160(the)X -3288(\256rst)X -3442(address.)X -3753(The)X -3908(\256rst)X -776 1032(address)N -1044(must)X -1226(be)X -1329(less)X -1475(than)X -1639(or)X -1732(equal)X -1932(to)X -2020(the)X -2144(second)X -2393(address.)X -2700(The)X -2851(\256rst)X -3001(address)X -3268(must)X -3449(be)X -3551(greater)X -3801(than)X -3965(or)X -776 1122(equal)N -973(to)X -1058(the)X -1179(\256rst)X -1326(line)X -1469(of)X -1559(the)X -1680(\256le,)X -1825(and)X -1964(the)X -2085(last)X -2219(address)X -2483(must)X -2661(be)X -2761(less)X -2905(than)X -3067(or)X -3158(equal)X -3356(to)X -3442(the)X -3564(last)X -3699(line)X -3843(of)X -3934(the)X -776 1212(\256le.)N -3 f -776 1398(13.)N -916(Ex)X -1029(Description)X -1 f -976 1521(The)N -1121(following)X -1452(words)X -1668(have)X -1840(special)X -2083(meanings)X -2410(for)X -3 f -2524(ex)X -1 f -2620(commands.)X -3 f -776 1701()N -1 f -976 1791(The)N -1130(end-of-\256le)X -1498(character)X -1823(is)X -1905(used)X -2081(to)X -2172(scroll)X -2379(the)X -2506(screen)X -2741(in)X -2832(the)X -3 f -2959(ex)X -1 f -3064(editor.)X -3320(This)X -3491(character)X -3816(is)X -3898(nor-)X -976 1881(mally)N -7 f -1178()X -1 f -(,)S -1746(however,)X -2063(whatever)X -2378(character)X -2694(is)X -2767(set)X -2876(for)X -2990(the)X -3108(current)X -3356(terminal)X -3643(is)X -3716(used.)X -3 f -776 2061(line)N -1 f -976 2151(A)N -1054(single-line)X -1412(address,)X -1693(given)X -1891(in)X -1973(any)X -2109(of)X -2196(the)X -2314(forms)X -2521(described)X -2849(in)X -2931(the)X -3049(section)X -3296(entitled)X -3557(``)X -3 f -3611(Ex)X -3725(Address-)X -976 2241(ing)N -1 f -1082(''.)X -1196(The)X -1341(default)X -1584(for)X -7 f -1698(line)X -1 f -1910(is)X -1983(the)X -2101(current)X -2349(line.)X -3 f -776 2421(range)N -1 f -976 2511(A)N -1058(line,)X -1222(or)X -1313(a)X -1373(pair)X -1522(of)X -1613(line)X -1757(addresses,)X -2109(separated)X -2437(by)X -2541(a)X -2601(comma)X -2861(or)X -2952(semicolon.)X -3345(\(See)X -3512(the)X -3634(section)X -3885(enti-)X -976 2601(tled)N -1123(``)X -3 f -1177(Ex)X -1297(Addressing)X -1 f -1683('')X -1764(for)X -1884(more)X -2075(information.\))X -2546(The)X -2697(default)X -2946(for)X -3066(range)X -3271(is)X -3350(the)X -3474(current)X -3728(line)X -2 f -3874(only)X -1 f -4012(,)X -976 2691(i.e.)N -1114(``)X -7 f -1168(.,.)X -1 f -(''.)S -1426(A)X -1504(percent)X -1761(sign)X -1914(\(``)X -7 f -1995(%)X -1 f -(''\))S -2144(stands)X -2364(for)X -2479(the)X -2598(range)X -2798(``)X -7 f -2852(1,$)X -1 f -(''.)S -3111(The)X -3257(starting)X -3518(address)X -3780(must)X -3956(be)X -976 2781(less)N -1116(than,)X -1294(or)X -1381(equal)X -1575(to,)X -1677(the)X -1795(ending)X -2033(address.)X -3 f -776 2961(count)N -1 f -976 3051(A)N -1058(positive)X -1335(integer,)X -1602(specifying)X -1961(the)X -2084(number)X -2354(of)X -2446(lines)X -2622(to)X -2709(be)X -2810(affected)X -3095(by)X -3200(the)X -3323(command;)X -3686(the)X -3809(default)X -976 3141(is)N -1055(1.)X -1161(Generally,)X -1524(a)X -1586(count)X -1790(past)X -1945(the)X -2068(end-of-\256le)X -2432(may)X -2595(be)X -2696(speci\256ed,)X -3026(e.g.)X -3167(the)X -3290(command)X -3631(``)X -7 f -3685(p)X -3786(3000)X -1 f -('')S -976 3231(in)N -1064(a)X -1127(10)X -1234(line)X -1381(\256le)X -1510(is)X -1590(acceptable,)X -1977(and)X -2120(will)X -2271(print)X -2449(from)X -2632(the)X -2757(current)X -3012(line)X -3159(through)X -3435(the)X -3560(last)X -3698(line)X -3845(in)X -3934(the)X -976 3321(\256le.)N -3 f -776 3501(\257ags)N -1 f -976 3591(One)N -1132(or)X -1221(more)X -1408(of)X -1497(the)X -1617(characters)X -1966(``#'',)X -2156(``p'',)X -2346(and)X -2484(``l''.)X -2677(When)X -2892(a)X -2951(command)X -3290(that)X -3433(accepts)X -3693(these)X -3881(\257ags)X -976 3681(completes,)N -1343(the)X -1463(addressed)X -1802(line\(s\))X -2029(are)X -2150(written)X -2399(out)X -2523(as)X -2612(if)X -2683(by)X -2785(the)X -2905(corresponding)X -3 f -3386(#)X -1 f -(,)S -3 f -3468(l)X -1 f -3512(or)X -3 f -3600(p)X -1 f -3665(commands.)X -976 3771(In)N -1064(addition,)X -1367(any)X -1504(number)X -1770(of)X -1858(``)X -7 f -1912(+)X -1 f -('')S -2035(or)X -2123(``)X -7 f -9 f -2177(-)X -1 f -2221('')X -2296(characters)X -2644(can)X -2777(be)X -2874(speci\256ed)X -3180(before,)X -3427(after,)X -3616(or)X -3704(during)X -3934(the)X -976 3861(\257ags,)N -1175(in)X -1265(which)X -1489(case)X -1656(the)X -1782(line)X -1930(written)X -2185(is)X -2266(not)X -2396(necessarily)X -2780(the)X -2905(one)X -3048(affected)X -3335(by)X -3442(the)X -3567(command,)X -3930(but)X -976 3951(rather)N -1184(the)X -1302(line)X -1442(addressed)X -1779(by)X -1879(the)X -1997(offset)X -2200(address)X -2461(speci\256ed.)X -2806(The)X -2951(default)X -3194(for)X -7 f -3308(flags)X -1 f -3568(is)X -3641(none.)X -3 f -776 4131(\256le)N -1 f -976 4221(A)N -1055(pattern)X -1299(used)X -1467(to)X -1550(derive)X -1772(a)X -1829(pathname;)X -2184(the)X -2303(default)X -2547(is)X -2621(the)X -2740(current)X -2989(\256le.)X -3152(File)X -3297(names)X -3524(are)X -3645(subjected)X -3970(to)X -976 4311(normal)N -2 f -1223(sh)X -1 f -1294(\(1\))X -1408(word)X -1593(expansions.)X -976 4434(Anywhere)N -1336(a)X -1397(\256le)X -1524(name)X -1723(is)X -1801(speci\256ed,)X -2131(it)X -2200(is)X -2279(also)X -2434(possible)X -2722(to)X -2810(use)X -2943(the)X -3067(special)X -3316(string)X -3524(``)X -7 f -3578(/tmp)X -1 f -(''.)S -3890(This)X -776 4524(will)N -936(be)X -1048(replaced)X -1357(with)X -1535(a)X -1607(temporary)X -1973(\256le)X -2111(name)X -2321(which)X -2553(can)X -2701(be)X -2813(used)X -2996(for)X -3126(temporary)X -3491(work,)X -3711(e.g.)X -3882(``)X -7 f -3936(:e)X -776 4614(/tmp)N -1 f -('')S -1042(creates)X -1286(and)X -1422(edits)X -1593(a)X -1649(new)X -1803(\256le.)X -976 4737(If)N -1052(both)X -1216(a)X -1274(count)X -1474(and)X -1613(a)X -1672(range)X -1874(are)X -1996(speci\256ed)X -2304(for)X -2421(commands)X -2791(that)X -2934(use)X -3064(either,)X -3290(the)X -3411(starting)X -3674(line)X -3817(for)X -3934(the)X -776 4827(command)N -1120(is)X -1200(the)X -2 f -1325(last)X -1 f -1467(line)X -1614(addressed)X -1958(by)X -2065(the)X -2190(range,)X -2416(and)X -7 f -2559(count)X -1 f -(-)S -2853(subsequent)X -3236(lines)X -3414(are)X -3540(affected)X -3827(by)X -3934(the)X -776 4917(command,)N -1132(e.g.)X -1268(the)X -1386(command)X -1722(``)X -7 f -1776(2,3p4)X -1 f -('')S -2090(prints)X -2292(out)X -2414(lines)X -2585(3,)X -2665(4,)X -2745(5)X -2805(and)X -2941(6.)X -976 5040(When)N -1188(only)X -1350(a)X -1406(line)X -1546(or)X -1633(range)X -1833(is)X -1907(speci\256ed,)X -2233(with)X -2396(no)X -2497(command,)X -2854(the)X -2973(implied)X -3238(command)X -3575(is)X -3649(either)X -3853(a)X -3 f -3910(list)X -1 f -4012(,)X -3 f -776 5130(number)N -1 f -1073(or)X -3 f -1166(print)X -1 f -1365(command.)X -1747(The)X -1898(command)X -2240(used)X -2413(is)X -2492(the)X -2616(most)X -2797(recent)X -3020(of)X -3112(the)X -3235(three)X -3421(commands)X -3793(to)X -3880(have)X -776 5220(been)N -949(used)X -1117(\(including)X -1467(any)X -1604(use)X -1732(as)X -1820(a)X -1877(\257ag\).)X -2085(If)X -2160(none)X -2337(of)X -2425(these)X -2611(commands)X -2979(have)X -3152(been)X -3325(used)X -3493(before,)X -3740(the)X -3 f -3859(print)X -1 f -776 5310(command)N -1117(is)X -1195(the)X -1318(implied)X -1587(command.)X -1968(When)X -2185(no)X -2290(range)X -2494(or)X -2585(count)X -2787(is)X -2864(speci\256ed)X -3173(and)X -3313(the)X -3435(command)X -3775(line)X -3919(is)X -3996(a)X -776 5400(blank)N -974(line,)X -1134(the)X -1252(current)X -1500(line)X -1640(is)X -1713(incremented)X -2130(by)X -2230(1)X -2290(and)X -2426(then)X -2584(the)X -2702(current)X -2950(line)X -3090(is)X -3163(displayed.)X -976 5523(Zero)N -1149(or)X -1237(more)X -1423(whitespace)X -1801(characters)X -2149(may)X -2308(precede)X -2580(or)X -2668(follow)X -2898(the)X -3017(addresses,)X -3366(count,)X -3585(\257ags,)X -3778(or)X -3867(com-)X -776 5613(mand)N -980(name.)X -1220(Any)X -1384(object)X -1606(following)X -1943(a)X -2004(command)X -2345(name)X -2544(\(such)X -2743(as)X -2835(buffer,)X -3077(\256le,)X -3224(etc.\),)X -3410(that)X -3555(begins)X -3789(with)X -3956(an)X -776 5703(alphabetic)N -1130(character,)X -1471(should)X -1709(be)X -1810(separated)X -2139(from)X -2320(the)X -2443(command)X -2784(name)X -2983(by)X -3088(at)X -3171(least)X -3343(one)X -3484(whitespace)X -3866(char-)X -776 5793(acter.)N - -34 p -%%Page: 34 33 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-34)N -2813(Nvi/Nex)X -3109 0.3906(Reference)AX -3474(\(Ex)X -3614(Commands\))X -1 f -976 762(Any)N -1148(character,)X -1498(including)X -7 f -1834()X -1 f -(,)S -2704(``)X -7 f -2758(%)X -1 f -('')S -2894(and)X -3045(``)X -7 f -3099(#)X -1 f -('')S -3236(retain)X -3454(their)X -3636(literal)X -3858(value)X -776 852(when)N -970(preceded)X -1281(by)X -1381(a)X -1437(backslash.)X -3 f -776 1038(14.)N -916(Ex)X -1029(Commands)X -1 f -976 1161(The)N -1122(following)X -1454(section)X -1702(describes)X -2022(the)X -2141(commands)X -2509(available)X -2820(in)X -2903(the)X -3 f -3023(ex)X -1 f -3121(editor.)X -3370(In)X -3459(each)X -3629(entry)X -3816(below,)X -776 1251(the)N -894(tag)X -1012(line)X -1152(is)X -1225(a)X -1281(usage)X -1484(synopsis)X -1779(for)X -1893(the)X -2011(command.)X -976 1374(Each)N -1161(command)X -1501(can)X -1637(be)X -1737(entered)X -1998(as)X -2089(the)X -2211(abbreviation)X -2636(\(those)X -2856(characters)X -3207(in)X -3293(the)X -3416(synopsis)X -3716(command)X -776 1464(word)N -966(preceding)X -1307(the)X -1429(``['')X -1588 0.3375(character\),)AX -1955(the)X -2077(full)X -2212(command)X -2552(\(all)X -2683(characters)X -3034(shown)X -3267(for)X -3385(the)X -3507(command)X -3847(word,)X -776 1554(omitting)N -1067(the)X -1187(``['')X -1344(and)X -1482(``]'')X -1639 0.2955(characters\),)AX -2035(or)X -2124(any)X -2262(leading)X -2520(subset)X -2742(of)X -2831(the)X -2951(full)X -3084(command)X -3422(down)X -3622(to)X -3706(the)X -3826(abbre-)X -776 1644(viation.)N -1064(For)X -1201(example,)X -1519(the)X -1643(args)X -1803(command)X -2145(\(shown)X -2407(as)X -2500(``)X -7 f -2554(ar[gs])X -1 f -('')S -2922(in)X -3010(the)X -3134(synopsis\))X -3462(can)X -3600(be)X -3702(entered)X -3965(as)X -776 1734(``)N -7 f -830(ar)X -1 f -('',)S -1020(``)X -7 f -1074(arg)X -1 f -('')S -1292(or)X -1379(``)X -7 f -1433(args)X -1 f -(''.)S -976 1857(Each)N -3 f -1163(ex)X -1 f -1265(command)X -1607(described)X -1941(below)X -2163(notes)X -2359(the)X -2484(new)X -2645(current)X -2900(line)X -3047(after)X -3222(it)X -3293(is)X -3373(executed,)X -3706(as)X -3800(well)X -3965(as)X -776 1947(any)N -912(options)X -1167(that)X -1307(affect)X -1511(the)X -1629(command.)X -976 2127(A)N -1063(comment.)X -1430(Command)X -1792(lines)X -1972(beginning)X -2321(with)X -2492(the)X -2619(double-quote)X -3072(character)X -3398(\(``)X -7 f -3479(")X -1 f -(''\))S -3638(are)X -3767(ignored.)X -976 2217(This)N -1138(permits)X -1398(comments)X -1747(in)X -1829(editor)X -2036(scripts)X -2265(and)X -2401(startup)X -2639(\256les.)X -3 f -776 2397()N -1 f -976 2487(Scroll)N -1189(the)X -1309(screen.)X -1577(Write)X -1782(the)X -1902(next)X -2062(N)X -2142(lines,)X -2336(where)X -2556(N)X -2637(is)X -2713(the)X -2834(value)X -3031(of)X -3121(the)X -3 f -3242(scroll)X -1 f -3452(option.)X -3719(The)X -3867(com-)X -976 2577(mand)N -1191(is)X -1281(the)X -1416(end-of-\256le)X -1792(terminal)X -2096(character,)X -2449(which)X -2682(may)X -2857(be)X -2970(different)X -3284(on)X -3401(different)X -3714(terminals.)X -976 2667(Traditionally,)N -1434(it)X -1498(is)X -1571(the)X -7 f -1689()X -1 f -2237(key.)X -976 2847(Historically,)N -1397(the)X -3 f -1518(eof)X -1 f -1644(command)X -1984(ignored)X -2253(any)X -2393(preceding)X -2734(count,)X -2956(and)X -3096(the)X -7 f -3218()X -1 f -3866(char-)X -976 2937(acter)N -1155(was)X -1302(ignored)X -1569(unless)X -1791(it)X -1857(was)X -2004(entered)X -2263(as)X -2352(the)X -2472(\256rst)X -2618(character)X -2936(of)X -3025(the)X -3145(command.)X -3522(This)X -3685(implemen-)X -976 3027(tation)N -1178(treats)X -1372(it)X -1436(as)X -1523(a)X -1579(command)X -2 f -1915(only)X -1 f -2073(if)X -2142(entered)X -2399(as)X -2486(the)X -2604(\256rst)X -2748(character)X -3064(of)X -3151(the)X -3269(command)X -3605(line,)X -3766(and)X -3903(oth-)X -976 3117(erwise)N -1206(treats)X -1400(it)X -1464(as)X -1551(any)X -1687(other)X -1872(character.)X -976 3297(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(last)X -1789(line)X -1929(written.)X -976 3387(Options:)N -1336(None.)X -3 f -776 3567(!)N -823(argument\(s\))X -776 3657([range]!)N -1073(argument\(s\))X -1 f -976 3747(Execute)N -1263(a)X -1327(shell)X -1506(command,)X -1870(or)X -1966(\256lter)X -2146(lines)X -2326(through)X -2604(a)X -2669(shell)X -2849(command.)X -3234(In)X -3330(the)X -3457(\256rst)X -3610(synopsis,)X -3934(the)X -976 3837(remainder)N -1333(of)X -1430(the)X -1558(line)X -1708(after)X -1886(the)X -2014(``)X -7 f -2068(!)X -1 f -('')S -2220(character)X -2546(is)X -2629(passed)X -2873(to)X -2965(the)X -3093(program)X -3395(named)X -3639(by)X -3749(the)X -3 f -3877(shell)X -1 f -976 3927(option,)N -1220(as)X -1307(a)X -1363(single)X -1574(argument.)X -976 4107(Within)N -1227(the)X -1354(rest)X -1499(of)X -1595(the)X -1722(line,)X -1891(``)X -7 f -1945(%)X -1 f -('')S -2076(and)X -2221(``)X -7 f -2275(#)X -1 f -('')S -2407(are)X -2536(expanded)X -2874(into)X -3028(the)X -3156(current)X -3414(and)X -3560(alternate)X -3867(path-)X -976 4197(names,)N -1223(respectively.)X -1673(The)X -1820(character)X -2138(``)X -7 f -2192(!)X -1 f -('')S -2336(is)X -2411(expanded)X -2741(with)X -2904(the)X -3023(command)X -3360(text)X -3501(of)X -3589(the)X -3708(previous)X -3 f -4005(!)X -1 f -976 4287(command.)N -1354 0.3125(\(Therefore,)AX -1741(the)X -1861(command)X -3 f -2199(!!)X -1 f -2295(repeats)X -2545(the)X -2665(previous)X -3 f -2963(!)X -1 f -3032(command.\))X -3437(The)X -3585(special)X -3831(mean-)X -976 4377(ings)N -1130(of)X -1218(``)X -7 f -1272(%)X -1 f -('',)S -1415(``)X -7 f -1469(#)X -1 f -('',)S -1612(and)X -1749(``)X -7 f -1803(!)X -1 f -('')S -1946(can)X -2079(be)X -2176(overridden)X -2545(by)X -2646(escaping)X -2948(them)X -3129(with)X -3292(a)X -3349(backslash.)X -3722(If)X -3797(no)X -3 f -3898(!)X -1 f -3965(or)X -3 f -976 4467(:!)N -1 f -1075(command)X -1416(has)X -1548(yet)X -1671(been)X -1848(executed,)X -2179(it)X -2248(is)X -2326(an)X -2427(error)X -2609(to)X -2696(use)X -2828(an)X -2929(unescaped)X -3290(``)X -7 f -3344(!)X -1 f -('')S -3492(character.)X -3854(The)X -3 f -4005(!)X -1 f -976 4557(command)N -1325(does)X -2 f -1505(not)X -1 f -1640(do)X -1752(shell)X -1935(expansion)X -2292(on)X -2404(the)X -2534(strings)X -2779(provided)X -3096(as)X -3195(arguments.)X -3601(If)X -3687(any)X -3835(of)X -3934(the)X -976 4647(above)N -1197(expansions)X -1582(change)X -1839(the)X -1966(command)X -2311(the)X -2438(user)X -2602(entered,)X -2889(the)X -3017(command)X -3363(is)X -3446(redisplayed)X -3846(at)X -3934(the)X -976 4737(bottom)N -1222(of)X -1309(the)X -1427(screen.)X -3 f -976 4917(Ex)N -1 f -1092(then)X -1253(executes)X -1553(the)X -1674(program)X -1969(named)X -2206(by)X -2309(the)X -3 f -2430(shell)X -1 f -2608(option,)X -2855(with)X -3020(a)X -3 f -9 f -3079(-)X -3081(-)X -3 f -3125(c)X -1 f -3184(\257ag)X -3327(followed)X -3636(by)X -3740(the)X -3862(argu-)X -976 5007(ments)N -1187(\(which)X -1430(are)X -1549(bundled)X -1827(into)X -1971(a)X -2027(single)X -2238(argument\).)X -976 5187(The)N -3 f -1121(!)X -1 f -1188(command)X -1524(is)X -1597(permitted)X -1924(in)X -2006(an)X -2102(empty)X -2322(\256le.)X -976 5367(If)N -1050(the)X -1168(\256le)X -1290(has)X -1417(been)X -1589(modi\256ed)X -1893(since)X -2078(it)X -2142(was)X -2287(last)X -2418(completely)X -2794(written,)X -3061(the)X -3179(command)X -3515(will)X -3659(warn)X -3840(you.)X -976 5547(A)N -1054(single)X -1265(``)X -7 f -1319(!)X -1 f -('')S -1461(character)X -1777(is)X -1850(displayed)X -2177(when)X -2371(the)X -2489(command)X -2825(completes.)X -976 5727(In)N -1064(the)X -1183(second)X -1427(form)X -1604(of)X -1692(the)X -3 f -1811(!)X -1 f -1879(command,)X -2236(the)X -2355(remainder)X -2702(of)X -2790(the)X -2909(line)X -3051(after)X -3221(the)X -3341(``)X -7 f -3395(!)X -1 f -('')S -3539(is)X -3614(passed)X -3850(to)X -3934(the)X - -35 p -%%Page: 35 34 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Ex)X -1377(Commands\))X -3658(USD:13-35)X -1 f -976 762(program)N -1273(named)X -1512(by)X -1617(the)X -3 f -1740(shell)X -1 f -1920(option,)X -2169(as)X -2261(described)X -2594(above.)X -2851(The)X -3001(speci\256ed)X -3311(lines)X -3487(are)X -3610(passed)X -3848(to)X -3934(the)X -976 852(program)N -1273(as)X -1365(standard)X -1662(input,)X -1871(and)X -2012(the)X -2135(standard)X -2432(and)X -2573(standard)X -2871(error)X -3054(output)X -3284(of)X -3377(the)X -3501(program)X -3799(replace)X -976 942(the)N -1094(original)X -1363(lines.)X -976 1122(Line:)N -1336(Unchanged)X -1722(if)X -1791(no)X -1891(range)X -2090(was)X -2235(speci\256ed,)X -2560(otherwise)X -2892(set)X -3001(to)X -3083(the)X -3201(\256rst)X -3345(line)X -3485(of)X -3572(the)X -3690(range.)X -976 1212(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -3 f -1856(autowrite)X -1 f -2206(and)X -3 f -2342(writeany)X -1 f -2665(options.)X -3 f -776 1392([range])N -1046(nu[mber])X -1391([count])X -1656([\257ags])X -776 1482([range])N -1046(#)X -1106([count])X -1371([\257ags])X -1 f -976 1572(Display)N -1245(the)X -1363(selected)X -1642(lines,)X -1833(each)X -2001(preceded)X -2312(with)X -2474(its)X -2569(line)X -2709(number.)X -976 1752(The)N -1121(line)X -1261(number)X -1526(format)X -1760(is)X -1833(``%6d'',)X -2128(followed)X -2433(by)X -2533(two)X -2673(spaces.)X -976 1932(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(last)X -1789(line)X -1929(displayed.)X -976 2022(Options:)N -1336(None.)X -3 f -776 2202(@)N -870(buffer)X -776 2292(*)N -836(buffer)X -1 f -976 2382(Execute)N -1255(a)X -1311(buffer.)X -1568(Each)X -1749(line)X -1890(in)X -1973(the)X -2092(named)X -2327(buffer)X -2545(is)X -2619(executed)X -2926(as)X -3014(an)X -3 f -3111(ex)X -1 f -3208(command.)X -3585(If)X -3660(no)X -3761(buffer)X -3979(is)X -976 2472(speci\256ed,)N -1301(or)X -1388(if)X -1457(the)X -1575(speci\256ed)X -1880(buffer)X -2097(is)X -2170(``)X -7 f -2224(@)X -1 f -('')S -2346(or)X -2433(``)X -7 f -2487(*)X -1 f -('',)S -2629(the)X -2747(last)X -2878(buffer)X -3095(executed)X -3401(is)X -3474(used.)X -3 f -776 2652([range])N -1046(<[<)X -1185(...])X -1292([count])X -1557([\257ags])X -1 f -976 2742(Shift)N -1154(lines)X -1328(left)X -1458(or)X -1548(right.)X -1762(The)X -1910(speci\256ed)X -2218(lines)X -2392(are)X -2514(shifted)X -2755(to)X -2840(the)X -2961(left)X -3091(\(for)X -3235(the)X -3 f -3356(<)X -1 f -3425(command\))X -3791(or)X -3881(right)X -976 2832(\(for)N -1130(the)X -3 f -1261(>)X -1 f -1340(command\),)X -1736(by)X -1849(the)X -1980(number)X -2257(of)X -2356(columns)X -2659(speci\256ed)X -2976(by)X -3088(the)X -3 f -3218(shiftwidth)X -1 f -3596(option.)X -3872(Only)X -976 2922(leading)N -1237(whitespace)X -1619(characters)X -1971(are)X -2095(deleted)X -2352(when)X -2552(shifting)X -2822(left;)X -2977(once)X -3155(the)X -3279(\256rst)X -3429(column)X -3695(of)X -3788(the)X -3912(line)X -976 3012(contains)N -1283(a)X -1359(nonblank)X -1697(character,)X -2053(the)X -3 f -2191(shift)X -1 f -2382(command)X -2738(will)X -2901(succeed,)X -3215(but)X -3356(the)X -3493(line)X -3652(will)X -3815(not)X -3956(be)X -976 3102(modi\256ed.)N -976 3282(If)N -1050(the)X -1168(command)X -1504(character)X -3 f -1820(<)X -1 f -1886(or)X -3 f -1973(>)X -1 f -2039(is)X -2112(repeated)X -2405(more)X -2590(than)X -2748(once,)X -2941(the)X -3060(command)X -3397(is)X -3471(repeated)X -3765(once)X -3938(for)X -976 3372(each)N -1144(additional)X -1484(command)X -1820(character.)X -976 3552(Line:)N -1336(If)X -1416(the)X -1540(current)X -1794(line)X -1940(is)X -2019(set)X -2134(to)X -2222(one)X -2364(of)X -2457(the)X -2581(lines)X -2758(that)X -2904(are)X -3029(affected)X -3315(by)X -3421(the)X -3545(command,)X -3908(it)X -3979(is)X -1336 3642(unchanged.)N -1751(Otherwise,)X -2128(it)X -2199(is)X -2279(set)X -2395(to)X -2484(the)X -2609(\256rst)X -2760(nonblank)X -3085(character)X -3408(of)X -3502(the)X -3627(lowest)X -3863(num-)X -1336 3732(bered)N -1535(line)X -1675(shifted.)X -976 3822(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -3 f -1856(shiftwidth)X -1 f -2222(option.)X -3 f -776 4002([line])N -974(=)X -1040([\257ags])X -1 f -976 4092(Display)N -1250(the)X -1373(line)X -1518(number.)X -1828(Display)X -2102(the)X -2225(line)X -2370(number)X -2640(of)X -7 f -2732(line)X -1 f -2949(\(which)X -3197(defaults)X -3476(to)X -3563(the)X -3687(last)X -3824(line)X -3970(in)X -976 4182(the)N -1094(\256le\).)X -976 4362(Line:)N -1336(Unchanged.)X -976 4452(Options:)N -1336(None.)X -3 f -776 4632([range])N -1046(>[>)X -1185(...])X -1292([count])X -1557([\257ags])X -1 f -976 4722(Shift)N -1155(right.)X -1370(The)X -1519(speci\256ed)X -1828(lines)X -2003(are)X -2127(shifted)X -2370(to)X -2457(the)X -2580(right)X -2756(by)X -2861(the)X -2984(number)X -3254(of)X -3346(columns)X -3642(speci\256ed)X -3952(by)X -976 4812(the)N -3 f -1094(shiftwidth)X -1 f -1460(option,)X -1704(by)X -1804(inserting)X -2104(tab)X -2222(and)X -2358(space)X -2557(characters.)X -2944(Empty)X -3177(lines)X -3348(are)X -3467(not)X -3589(changed.)X -976 4992(If)N -1053(the)X -1174(command)X -1513(character)X -1832(``)X -7 f -1886(>)X -1 f -('')S -2011(is)X -2087(repeated)X -2383(more)X -2571(than)X -2732(once,)X -2927(the)X -3048(command)X -3388(is)X -3465(repeated)X -3762(once)X -3938(for)X -976 5082(each)N -1144(additional)X -1484(command)X -1820(character.)X -976 5262(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(last)X -1789(line)X -1929(modi\256ed)X -2233(by)X -2333(the)X -2451(command.)X -976 5352(Options:)N -1336(None.)X -3 f -776 5532(ab[brev])N -1090(lhs)X -1207(rhs)X -1 f -976 5622(Add)N -1135(an)X -1232(abbreviation)X -1654(to)X -1737(the)X -1856(current)X -2105(abbreviation)X -2527(list.)X -2686(In)X -3 f -2775(vi)X -1 f -2837(,)X -2879(if)X -7 f -2950(lhs)X -1 f -3116(is)X -3191(entered)X -3450(such)X -3619(that)X -3761(it)X -3827(is)X -3902(pre-)X -976 5712(ceded)N -1194(and)X -1340(followed)X -1655(by)X -1765(characters)X -2122(that)X -2272(cannot)X -2516(be)X -2622(part)X -2777(of)X -2874(a)X -2940(word,)X -3155(it)X -3229(is)X -3312(replaced)X -3614(by)X -3723(the)X -3850(string)X -7 f -976 5802(rhs)N -1 f -(.)S - -36 p -%%Page: 36 35 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-36)N -2813(Nvi/Nex)X -3109 0.3906(Reference)AX -3474(\(Ex)X -3614(Commands\))X -1 f -976 762(Line:)N -1336(Unchanged.)X -976 852(Options:)N -1336(None.)X -3 f -776 1032([line])N -974(a[ppend][!])X -1 f -976 1122(The)N -1123(input)X -1309(text)X -1451(is)X -1526(appended)X -1856(to)X -1940(the)X -2060(speci\256ed)X -2367(line.)X -2549(If)X -2626(line)X -2769(0)X -2832(is)X -2908(speci\256ed,)X -3236(the)X -3357(text)X -3500(is)X -3576(inserted)X -3853(at)X -3934(the)X -976 1212(beginning)N -1317(of)X -1405(the)X -1524(\256le.)X -1687(Set)X -1810(to)X -1893(the)X -2012(last)X -2144(line)X -2285(input.)X -2510(If)X -2585(no)X -2686(lines)X -2858(are)X -2978(input,)X -3183(then)X -3342(set)X -3451(to)X -7 f -3533(line)X -1 f -(,)S -3765(or)X -3852(to)X -3934(the)X -976 1302(\256rst)N -1125(line)X -1270(of)X -1362(the)X -1485(\256le)X -1612(if)X -1686(a)X -7 f -1747(line)X -1 f -1965(of)X -2058(0)X -2124(was)X -2275(speci\256ed.)X -2626(Following)X -2980(the)X -3104(command)X -3446(name)X -3646(with)X -3814(a)X -3876(``)X -7 f -3930(!)X -1 f -('')S -976 1392(character)N -1292(causes)X -1522(the)X -3 f -1640(autoindent)X -1 f -2028(option)X -2252(to)X -2334(be)X -2430(toggled)X -2690(for)X -2804(the)X -2922(duration)X -3209(of)X -3296(the)X -3414(command.)X -976 1572(Line:)N -1336(Unchanged.)X -976 1662(Options:)N -1336(Affected)X -1661(by)X -1784(the)X -3 f -1925(altwerase)X -1 f -2251(,)X -3 f -2314(autoindent)X -1 f -2682(,)X -3 f -2746(beautify)X -1 f -(,)S -3 f -3090(showmatch)X -1 f -3477(,)X -3 f -3541(ttywerase)X -1 f -3916(and)X -3 f -1336 1752(wrapmargin)N -1 f -1783(options.)X -3 f -776 1932(ar[gs])N -1 f -976 2022(Display)N -1248(the)X -1369(argument)X -1695(list.)X -1855(The)X -2003(current)X -2254(argument)X -2580(is)X -2657(displayed)X -2988(inside)X -3203(of)X -3294(``)X -7 f -3348([)X -1 f -('')S -3474(and)X -3614(``)X -7 f -3668(])X -1 f -('')S -3794(charac-)X -976 2112(ters.)N -1154(The)X -1300(argument)X -1624(list)X -1742(is)X -1816(the)X -1935(list)X -2053(of)X -2141(operands)X -2452(speci\256ed)X -2758(on)X -2859(startup,)X -3118(which)X -3335(can)X -3468(be)X -3565(replaced)X -3859(using)X -976 2202(the)N -3 f -1094(next)X -1 f -1261(command.)X -976 2382(Line:)N -1336(Unchanged.)X -976 2472(Options:)N -1336(None.)X -3 f -776 2652(bg)N -976 2742(Vi)N -1 f -1076(mode)X -1274(only.)X -1476(Background)X -1888(the)X -2006(current)X -2254(screen.)X -976 2922(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(current)X -1906(line)X -2046(when)X -2240(the)X -2358(screen)X -2584(was)X -2729(last)X -2860(edited.)X -976 3012(Options:)N -1336(None.)X -3 f -776 3192([range])N -1046(c[hange][!])X -1441([count])X -1 f -976 3282(Replace)N -1256(the)X -1375(lines)X -1548(with)X -1712(input)X -1898(text.)X -2080(Following)X -2430(the)X -2550(command)X -2888(name)X -3084(with)X -3248(a)X -3306(``)X -7 f -3360(!)X -1 f -('')S -3504(character)X -3822(causes)X -976 3372(the)N -3 f -1094(autoindent)X -1 f -1482(option)X -1706(to)X -1788(be)X -1884(toggled)X -2144(for)X -2258(the)X -2376(duration)X -2663(of)X -2750(the)X -2868(command.)X -976 3552(Line:)N -1336(Set)X -1463(to)X -1550(the)X -1673(last)X -1809(line)X -1954(input,)X -2163(or,)X -2275(if)X -2349(no)X -2454(lines)X -2630(were)X -2812(input,)X -3021(set)X -3135(to)X -3223(the)X -3347(line)X -3493(before)X -3725(the)X -3849(target)X -1336 3642(line,)N -1496(or)X -1583(to)X -1665(the)X -1783(\256rst)X -1927(line)X -2067(of)X -2154(the)X -2272(\256le)X -2394(if)X -2463(there)X -2644(are)X -2763(no)X -2863(lines)X -3034(preceding)X -3371(the)X -3489(target)X -3692(line.)X -976 3732(Options:)N -1336(Affected)X -1661(by)X -1784(the)X -3 f -1925(altwerase)X -1 f -2251(,)X -3 f -2314(autoindent)X -1 f -2682(,)X -3 f -2746(beautify)X -1 f -(,)S -3 f -3090(showmatch)X -1 f -3477(,)X -3 f -3541(ttywerase)X -1 f -3916(and)X -3 f -1336 3822(wrapmargin)N -1 f -1783(options.)X -3 f -776 4002(chd[ir][!])N -1113([directory])X -776 4092(cd[!])N -957([directory])X -1 f -976 4182(Change)N -1244(the)X -1365(current)X -1616(working)X -1906(directory.)X -2259(The)X -7 f -2407(directory)X -1 f -2862(argument)X -3188(is)X -3265(subjected)X -3592(to)X -2 f -3678(sh)X -1 f -3749(\(1\))X -3867(word)X -976 4272(expansions.)N -1395(When)X -1610(invoked)X -1891(with)X -2056(no)X -2159(directory)X -2472(argument)X -2798(and)X -2937(the)X -7 f -3057(HOME)X -1 f -3271(environment)X -3698(variable)X -3979(is)X -976 4362(set,)N -1105(the)X -1223(directory)X -1533(named)X -1767(by)X -1867(the)X -7 f -1985(HOME)X -1 f -2197(environment)X -2622(variable)X -2901(becomes)X -3202(the)X -3320(new)X -3474(current)X -3722(directory.)X -976 4452(Otherwise,)N -1353(the)X -1478(new)X -1639(current)X -1894(directory)X -2211(becomes)X -2519(the)X -2644(directory)X -2961(returned)X -3256(by)X -3363(the)X -2 f -3488(getpwent)X -1 f -3777(\(3\))X -3898(rou-)X -976 4542(tine.)N -976 4722(The)N -3 f -1125(chdir)X -1 f -1331(command)X -1671(will)X -1819(fail)X -1950(if)X -2023(the)X -2145(\256le)X -2271(has)X -2402(been)X -2578(modi\256ed)X -2886(since)X -3075(the)X -3197(last)X -3333(complete)X -3652(write)X -3842(of)X -3934(the)X -976 4812(\256le.)N -1138(You)X -1296(can)X -1428(override)X -1716(this)X -1851(check)X -2059(by)X -2159(appending)X -2513(a)X -2569(``)X -7 f -2623(!)X -1 f -('')S -2765(character)X -3081(to)X -3163(the)X -3281(command.)X -976 4992(Line:)N -1336(Unchanged.)X -976 5082(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -3 f -1856(cdpath)X -1 f -2111(option.)X -3 f -776 5262([range])N -1046(co[py])X -1280(line)X -1424([\257ags])X -776 5352([range])N -1046(t)X -1093(line)X -1237([\257ags])X -1 f -976 5442(Copy)N -1169(the)X -1288(speci\256ed)X -1594(lines)X -1766(\(range\))X -2020(after)X -2189(the)X -2308(destination)X -2680(line.)X -2861(Line)X -3029(0)X -3090(may)X -3249(be)X -3346(speci\256ed)X -3652(to)X -3735(insert)X -3934(the)X -976 5532(lines)N -1147(at)X -1225(the)X -1343(beginning)X -1683(of)X -1770(the)X -1888(\256le.)X -976 5712(Line:)N -1336(Unchanged.)X - -37 p -%%Page: 37 36 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Ex)X -1377(Commands\))X -3658(USD:13-37)X -1 f -976 762(Options:)N -1336(None.)X -3 f -776 942([range])N -1046(d[elete])X -1321([buffer])X -1609([count])X -1874([\257ags])X -1 f -976 1032(Delete)N -1208(the)X -1329(lines)X -1503(from)X -1682(the)X -1803(\256le.)X -1968(The)X -2116(deleted)X -2371(text)X -2514(is)X -2590(saved)X -2796(in)X -2881(the)X -3002(speci\256ed)X -3310(buffer,)X -3550(or,)X -3660(if)X -3732(no)X -3835(buffer)X -976 1122(is)N -1051(speci\256ed,)X -1378(in)X -1462(the)X -1582(unnamed)X -1898(buffer.)X -2157(If)X -2233(the)X -2353(command)X -2691(name)X -2887(is)X -2962(followed)X -3269(by)X -3371(a)X -3429(letter)X -3616(that)X -3757(could)X -3956(be)X -976 1212(interpreted)N -1346(as)X -1435(either)X -1640(a)X -1698(buffer)X -1917(name)X -2113(or)X -2202(a)X -2261(\257ag)X -2404(value)X -2601(\(because)X -2906(neither)X -3152(a)X -7 f -3211(count)X -1 f -3474(or)X -7 f -3564(flags)X -1 f -3827(values)X -976 1302(were)N -1160(given\),)X -3 f -1412(ex)X -1 f -1515(treats)X -1716(the)X -1841(letter)X -2033(as)X -2127(a)X -7 f -2190(flags)X -1 f -2457(value)X -2658(if)X -2734(the)X -2859(letter)X -3051(immediately)X -3477(follows)X -3743(the)X -3867(com-)X -976 1392(mand)N -1174(name,)X -1388(without)X -1652(any)X -1788(whitespace)X -2165(separation.)X -2555(If)X -2629(the)X -2747(letter)X -2932(is)X -3005(preceded)X -3316(by)X -3416(whitespace)X -3794(charac-)X -976 1482(ters,)N -1132(it)X -1196(treats)X -1390(it)X -1454(as)X -1541(a)X -1597(buffer)X -1814(name.)X -976 1662(Line:)N -1336(Set)X -1459(to)X -1542(the)X -1661(line)X -1802(following)X -2134(the)X -2253(deleted)X -2506(lines,)X -2698(or)X -2786(to)X -2869(the)X -2988(last)X -3120(line)X -3261(if)X -3331(the)X -3450(deleted)X -3703(lines)X -3875(were)X -1336 1752(at)N -1414(the)X -1532(end.)X -976 1842(Options:)N -1336(None.)X -3 f -776 2022(di[splay])N -1093(b[uffers])X -1412(|)X -1450(s[creens])X -1774(|)X -1812(t[ags])X -1 f -976 2112(Display)N -1256(buffers,)X -1535(screens)X -1803(or)X -1901(tags.)X -2101(The)X -3 f -2257(display)X -1 f -2531(command)X -2878(takes)X -3074(one)X -3221(of)X -3319(three)X -3511(additional)X -3862(argu-)X -976 2202(ments,)N -1207(which)X -1423(are)X -1542(as)X -1629(follows:)X -976 2382(b[uffers])N -1336(Display)X -1605(all)X -1705(buffers)X -1953(\(including)X -2302(named,)X -2556(unnamed,)X -2890(and)X -3026(numeric\))X -3336(that)X -3476(contain)X -3732(text.)X -976 2472(s[creens])N -1336(Display)X -1605(the)X -1723(\256le)X -1845(names)X -2070(of)X -2157(all)X -2257(background)X -2656(screens.)X -976 2562(t[ags])N -1336(Display)X -1605(the)X -1723(tags)X -1872(stack.)X -976 2742(Line:)N -1336(Unchanged.)X -976 2832(Options:)N -1336(None.)X -3 f -776 3012(e[dit][!])N -1060([+cmd])X -1327([\256le])X -776 3102(ex[!])N -953([+cmd])X -1220([\256le])X -1 f -976 3192(Edit)N -1133(a)X -1193(different)X -1494(\256le.)X -1661(If)X -1740(the)X -1863(current)X -2116(buffer)X -2338(has)X -2470(been)X -2647(modi\256ed)X -2956(since)X -3146(the)X -3269(last)X -3405(complete)X -3724(write,)X -3934(the)X -976 3282(command)N -1324(will)X -1480(fail.)X -1659(You)X -1829(can)X -1972(override)X -2271(this)X -2417(by)X -2528(appending)X -2893(a)X -2960(``)X -7 f -3014(!)X -1 f -('')S -3167(character)X -3494(to)X -3587(the)X -3716(command)X -976 3372(name.)N -976 3552(If)N -1053(the)X -1174(``)X -7 f -1228(+cmd)X -1 f -('')S -1497(option)X -1724(is)X -1800(speci\256ed,)X -2128(that)X -3 f -2271(ex)X -1 f -2370(command)X -2709(will)X -2856(be)X -2955(executed)X -3264(in)X -3349(the)X -3470(new)X -3628(\256le.)X -3794(Any)X -3 f -3956(ex)X -1 f -976 3642(command)N -1326(may)X -1498(be)X -1607(used,)X -1807(although)X -2120(the)X -2251(most)X -2439(common)X -2752(use)X -2892(of)X -2992(this)X -3140(feature)X -3397(is)X -3483(to)X -3578(specify)X -3843(a)X -3912(line)X -976 3732(number)N -1241(or)X -1328(search)X -1554(pattern)X -1797(to)X -1879(set)X -1988(the)X -2106(initial)X -2312(location)X -2590(in)X -2672(the)X -2790(new)X -2944(\256le.)X -976 3912(Line:)N -1336(If)X -1415(you)X -1560(have)X -1737(previously)X -2100(edited)X -2321(the)X -2444(\256le,)X -2591(the)X -2714(current)X -2967(line)X -3112(will)X -3261(be)X -3362(set)X -3476(to)X -3563(your)X -3735(last)X -3872(posi-)X -1336 4002(tion)N -1482(in)X -1566(the)X -1686(\256le.)X -1850(If)X -1926(that)X -2068(position)X -2347(does)X -2516(not)X -2640(exist,)X -2833(or)X -2921(you)X -3062(have)X -3235(not)X -3358(previously)X -3717(edited)X -3934(the)X -1336 4092(\256le,)N -1481(the)X -1602(current)X -1853(line)X -1996(will)X -2143(be)X -2242(set)X -2354(to)X -2439(the)X -2560(\256rst)X -2707(line)X -2850(of)X -2940(the)X -3061(\256le)X -3186(if)X -3258(you)X -3401(are)X -3523(in)X -3 f -3608(vi)X -1 f -3694(mode,)X -3916(and)X -1336 4182(the)N -1454(last)X -1585(line)X -1725(of)X -1812(the)X -1930(\256le)X -2052(if)X -2121(you)X -2261(are)X -2380(in)X -3 f -2462(ex)X -1 f -2538(.)X -976 4272(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -3 f -1856(autowrite)X -1 f -2206(and)X -3 f -2342(writeany)X -1 f -2665(options.)X -3 f -776 4452(exu[sage])N -1117([command])X -1 f -976 4542(Display)N -1249(usage)X -1456(for)X -1574(an)X -3 f -1674(ex)X -1 f -1774(command.)X -2154(If)X -7 f -2233(command)X -1 f -2594(is)X -2672(speci\256ed,)X -3002(a)X -3063(usage)X -3271(statement)X -3603(for)X -3722(that)X -3867(com-)X -976 4632(mand)N -1174(is)X -1247(displayed.)X -1614(Otherwise,)X -1984(usage)X -2187(statements)X -2545(for)X -2659(all)X -3 f -2759(ex)X -1 f -2855(commands)X -3222(are)X -3341(displayed.)X -976 4812(Line:)N -1336(Unchanged.)X -976 4902(Options:)N -1336(None.)X -3 f -776 5082(f[ile])N -957([\256le])X -1 f -976 5172(Display)N -1249(and)X -1389(optionally)X -1737(change)X -1989(the)X -2111(\256le)X -2237(name.)X -2475(If)X -2553(a)X -2613(\256le)X -2739(name)X -2937(is)X -3014(speci\256ed,)X -3344(the)X -3467(current)X -3720(pathname)X -976 5262(is)N -1054(changed)X -1347(to)X -1434(the)X -1557(speci\256ed)X -1867(name.)X -2106(The)X -2256(current)X -2509(pathname,)X -2865(the)X -2987(number)X -3256(of)X -3347(lines,)X -3542(and)X -3682(the)X -3804(current)X -976 5352(position)N -1253(in)X -1335(the)X -1453(\256le)X -1575(are)X -1694(displayed.)X -976 5532(Line:)N -1336(Unchanged.)X -976 5622(Options:)N -1336(None.)X - -38 p -%%Page: 38 37 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-38)N -2813(Nvi/Nex)X -3109 0.3906(Reference)AX -3474(\(Ex)X -3614(Commands\))X -776 762(fg)N -863([name])X -976 852(Vi)N -1 f -1085(mode)X -1292(only.)X -1503(Foreground)X -1906(the)X -2033(speci\256ed)X -2347(screen.)X -2622(Swap)X -2829(the)X -2956(current)X -3213(screen)X -3448(with)X -3619(the)X -3747(speci\256ed)X -976 942(backgrounded)N -1451(screen.)X -1717(If)X -1791(no)X -1891(screen)X -2117(is)X -2190(speci\256ed,)X -2515(the)X -2633(\256rst)X -2777(background)X -3176(screen)X -3402(is)X -3475(foregrounded.)X -976 1122(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(current)X -1906(line)X -2046(when)X -2240(the)X -2358(screen)X -2584(was)X -2729(last)X -2860(edited.)X -976 1212(Options:)N -1336(None.)X -3 f -776 1392([range])N -1046(g[lobal])X -1328(/pattern/)X -1646([commands])X -776 1482([range])N -1046(v)X -1106(/pattern/)X -1424([commands])X -1 f -976 1572(Apply)N -1206(commands)X -1583(to)X -1675(lines)X -1856(matching)X -2184(\(or)X -2308(not)X -2440(matching\))X -2795(a)X -2861(pattern.)X -3154(The)X -3309(lines)X -3490(within)X -3725(the)X -3854(given)X -976 1662(range)N -1191(that)X -1347(match)X -1579(\(``)X -7 f -1660(g[lobal])X -1 f -(''\),)S -2181(or)X -2284(do)X -2400(not)X -2538(match)X -2770(\(``)X -7 f -2851(v)X -1 f -(''\))S -3015(the)X -3148(given)X -3361(pattern)X -3619(are)X -3753(selected.)X -976 1752(Then,)N -1197(the)X -1331(speci\256ed)X -3 f -1652(ex)X -1 f -1764(command\(s\))X -2201(are)X -2336(executed)X -2658(with)X -2836(the)X -2970(current)X -3235(line)X -3392(\(``)X -7 f -3473(.)X -1 f -(''\))S -3659(set)X -3785(to)X -3884(each)X -976 1842(selected)N -1257(line.)X -1439(If)X -1515(no)X -1617(range)X -1818(is)X -1893(speci\256ed,)X -2220(the)X -2340(entire)X -2545(\256le)X -2669(is)X -2744(searched)X -3048(for)X -3164(matching,)X -3503(or)X -3591(not)X -3714(matching,)X -976 1932(lines.)N -976 2112(Multiple)N -1279(commands)X -1654(can)X -1794(be)X -1899(speci\256ed,)X -2233(one)X -2378(per)X -2510(line,)X -2679(by)X -2788(escaping)X -3098(each)X -7 f -3275()X -1 f -3736(character)X -976 2202(with)N -1152(a)X -1222(backslash,)X -1588(or)X -1689(by)X -1803(separating)X -2167(commands)X -2548(with)X -2724(a)X -2794(``)X -7 f -2848(|)X -1 f -('')S -2984(character.)X -3353(If)X -3440(no)X -3553(commands)X -3933(are)X -976 2292(speci\256ed,)N -1301(the)X -1419(command)X -1755(defaults)X -2029(to)X -2111(the)X -3 f -2229(print)X -1 f -2422(command.)X -976 2472(For)N -1111(the)X -3 f -1233(append)X -1 f -1485(,)X -3 f -1529(change)X -1 f -1793(and)X -3 f -1933(insert)X -1 f -2153(commands,)X -2544(the)X -2666(input)X -2854(text)X -2998(must)X -3177(be)X -3277(part)X -3427(of)X -3519(the)X -3642(global)X -3867(com-)X -976 2562(mand)N -1174(line.)X -1354(In)X -1441(this)X -1576(case,)X -1755(the)X -1873(terminating)X -2262(period)X -2487(can)X -2619(be)X -2715(omitted)X -2979(if)X -3048(it)X -3112(ends)X -3279(the)X -3397(commands.)X -976 2742(The)N -3 f -1123(visual)X -1 f -1344(command)X -1682(may)X -1842(also)X -1993(be)X -2091(speci\256ed)X -2398(as)X -2487(one)X -2625(of)X -2714(the)X -3 f -2834(ex)X -1 f -2933(commands.)X -3343(In)X -3433(this)X -3571(mode,)X -3792(input)X -3979(is)X -976 2832(taken)N -1173(from)X -1352(the)X -1473(terminal.)X -1803(Entering)X -2102(a)X -3 f -2161(Q)X -1 f -2246(command)X -2585(in)X -3 f -2670(vi)X -1 f -2755(mode)X -2956(causes)X -3189(the)X -3310(next)X -3471(line)X -3614(matching)X -3934(the)X -976 2922(pattern)N -1219(to)X -1301(be)X -1397(selected)X -1676(and)X -3 f -1812(vi)X -1 f -1894(to)X -1976(be)X -2072(reentered,)X -2412(until)X -2578(the)X -2696(list)X -2813(is)X -2886(exhausted.)X -976 3102(The)N -3 f -1121(global)X -1 f -1329(,)X -3 f -1369(v)X -1 f -1429(and)X -3 f -1565(undo)X -1 f -1757(commands)X -2124(cannot)X -2358(be)X -2454(used)X -2621(as)X -2708(part)X -2853(of)X -2940(these)X -3125(commands.)X -976 3282(The)N -1131(editor)X -1348(options)X -3 f -1613(autoprint)X -1 f -1937(,)X -3 f -1987(autoindent)X -1 f -2355(,)X -2405(and)X -3 f -2551(report)X -1 f -2800(are)X -2929(turned)X -3164(off)X -3288(for)X -3412(the)X -3540(duration)X -3837(of)X -3934(the)X -3 f -976 3372(global)N -1 f -1204(and)X -3 f -1340(v)X -1 f -1400(commands.)X -976 3552(Line:)N -1336(The)X -1481(last)X -1612(line)X -1752(modi\256ed.)X -976 3642(Options:)N -1336(None.)X -3 f -776 3822(he[lp])N -1 f -3912(Display)Y -1245(a)X -1301(help)X -1459(message.)X -976 4092(Line:)N -1336(Unchanged.)X -976 4182(Options:)N -1336(None.)X -3 f -776 4362([line])N -974(i[nsert][!])X -1 f -976 4452(The)N -1123(input)X -1309(text)X -1451(is)X -1526(inserted)X -1803(before)X -2032(the)X -2153(speci\256ed)X -2461(line.)X -2644(Following)X -2995(the)X -3116(command)X -3455(name)X -3652(with)X -3817(a)X -3876(``)X -7 f -3930(!)X -1 f -('')S -976 4542(character)N -1292(causes)X -1522(the)X -3 f -1640(autoindent)X -1 f -2028(option)X -2252(setting)X -2485(to)X -2567(be)X -2663(toggled)X -2923(for)X -3037(the)X -3155(duration)X -3442(of)X -3529(this)X -3664(command.)X -976 4722(Line:)N -1336(Set)X -1460(to)X -1544(the)X -1664(last)X -1797(line)X -1939(input;)X -2147(if)X -2218(no)X -2320(lines)X -2493(were)X -2672(input,)X -2878(set)X -2989(to)X -3073(the)X -3193(line)X -3336(before)X -3565(the)X -3686(target)X -3892(line,)X -1336 4812(or)N -1423(to)X -1505(the)X -1623(\256rst)X -1767(line)X -1907(of)X -1994(the)X -2112(\256le)X -2234(if)X -2303(there)X -2484(are)X -2603(no)X -2703(lines)X -2874(preceding)X -3211(the)X -3329(target)X -3532(line.)X -976 4902(Options:)N -1336(Affected)X -1661(by)X -1784(the)X -3 f -1925(altwerase)X -1 f -2251(,)X -3 f -2314(autoindent)X -1 f -2682(,)X -3 f -2746(beautify)X -1 f -(,)S -3 f -3090(showmatch)X -1 f -3477(,)X -3 f -3541(ttywerase)X -1 f -3916(and)X -3 f -1336 4992(wrapmargin)N -1 f -1783(options.)X -3 f -776 5172([range])N -1046(j[oin][!])X -1334([count])X -1599([\257ags])X -1 f -976 5262(Join)N -1129(lines)X -1300(of)X -1387(text)X -1527(together.)X -976 5442(A)N -7 f -1056(count)X -1 f -1318(speci\256ed)X -1625(to)X -1709(the)X -1829(command)X -2167(speci\256es)X -2465(that)X -2607(the)X -2727(last)X -2860(line)X -3002(of)X -3091(the)X -7 f -3212(range)X -1 f -3475(plus)X -7 f -3631(count)X -1 f -3894(sub-)X -976 5532(sequent)N -1258(lines)X -1445(will)X -1605(be)X -1717(joined.)X -1993(\(Note,)X -2232(this)X -2383(differs)X -2629(by)X -2745(one)X -2897(from)X -3089(the)X -3223(general)X -3496(rule)X -3657(where)X -3890(only)X -7 f -976 5622(count)N -1 f -(-)S -1263(subsequent)X -1639(lines)X -1810(are)X -1929(affected.\))X -976 5802(If)N -1057(the)X -1182(current)X -1438(line)X -1586(ends)X -1761(with)X -1931(a)X -1995(whitespace)X -2380(character,)X -2724(all)X -2832(whitespace)X -3217(is)X -3298(stripped)X -3584(from)X -3768(the)X -3894(next)X - -39 p -%%Page: 39 38 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Ex)X -1377(Commands\))X -3658(USD:13-39)X -1 f -976 762(line.)N -1160(Otherwise,)X -1534(if)X -1607(the)X -1729(next)X -1891(line)X -2035(starts)X -2228(with)X -2394(a)X -2454(open)X -2634(parenthesis)X -3019(\(``)X -7 f -3100(\()X -1 f -(''\),)S -3272(do)X -3375(nothing.)X -3682(Otherwise,)X -976 852(if)N -1061(the)X -1195(current)X -1459(line)X -1615(ends)X -1798(with)X -1976(a)X -2049(question)X -2357(mark)X -2559(\(``)X -7 f -2640(?)X -1 f -(''\),)S -2826(period)X -3068(\(``)X -7 f -3149(.)X -1 f -(''\))S -3335(or)X -3439(exclamation)X -3868(point)X -976 942(\(``)N -7 f -1057(!)X -1 f -(''\),)S -1226(insert)X -1424(two)X -1564(spaces.)X -1834(Otherwise,)X -2204(insert)X -2402(a)X -2458(single)X -2669(space.)X -976 1122(Appending)N -1355(a)X -1414(``)X -7 f -1468(!)X -1 f -('')S -1613(character)X -1932(to)X -2017(the)X -2138(command)X -2477(name)X -2674(causes)X -2907(a)X -2966(simpler)X -3230(join)X -3378(with)X -3544(no)X -3648(white-space)X -976 1212(processing.)N -976 1392(Line:)N -1336(Unchanged.)X -976 1482(Options:)N -1336(None.)X -3 f -776 1662([range])N -1046(l[ist])X -1222([count])X -1487([\257ags])X -1 f -976 1752(Display)N -1258(the)X -1389(lines)X -1573(unambiguously.)X -2139(Tabs)X -2328(are)X -2460(displayed)X -2801(as)X -2902(``)X -7 f -2956(\303I)X -1 f -('',)S -3160(and)X -3310(the)X -3442(end)X -3592(of)X -3693(the)X -3825(line)X -3979(is)X -976 1842(marked)N -1237(with)X -1399(a)X -1455(``)X -7 f -1509($)X -1 f -('')S -1631(character.)X -976 2022(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(last)X -1789(line)X -1929(displayed.)X -976 2112(Options:)N -1336(None.)X -3 f -776 2292(map[!])N -1028([lhs)X -1172(rhs])X -1 f -976 2382(De\256ne)N -1210(or)X -1297(display)X -1548(maps)X -1737(\(for)X -3 f -1878(vi)X -1 f -1960(only\).)X -976 2562(If)N -1050(``)X -7 f -1104(lhs)X -1 f -('')S -1322(and)X -1458(``)X -7 f -1512(rhs)X -1 f -('')S -1730(are)X -1849(not)X -1971(speci\256ed,)X -2296(the)X -2414(current)X -2662(set)X -2771(of)X -2859(command)X -3196(mode)X -3395(maps)X -3585(are)X -3705(displayed.)X -976 2652(If)N -1050(a)X -1106(``)X -7 f -1160(!)X -1 f -('')S -1302(character)X -1618(is)X -1691(appended)X -2019(to)X -2101(to)X -2183(the)X -2301(command,)X -2657(the)X -2775(text)X -2915(input)X -3099(mode)X -3297(maps)X -3486(are)X -3605(displayed.)X -976 2832(Otherwise,)N -1365(when)X -1578(the)X -1715(``)X -7 f -1769(lhs)X -1 f -('')S -2006(character)X -2342(sequence)X -2677(is)X -2770(entered)X -3047(in)X -3 f -3149(vi)X -1 f -3211(,)X -3271(the)X -3409(action)X -3645(is)X -3738(as)X -3845(if)X -3934(the)X -976 2922(corresponding)N -1466(``)X -7 f -1520(rhs)X -1 f -('')S -1749(had)X -1896(been)X -2079(entered.)X -2387(If)X -2472(a)X -2539(``)X -7 f -2593(!)X -1 f -('')S -2746(character)X -3073(is)X -3157(appended)X -3496(to)X -3588(the)X -3716(command)X -976 3012(name,)N -1196(the)X -1320(mapping)X -1626(is)X -1705(effective)X -2013(during)X -2249(text)X -2396(input)X -2587(mode,)X -2812(otherwise,)X -3171(it)X -3242(is)X -3322(effective)X -3631(during)X -3867(com-)X -976 3102(mand)N -1175(mode.)X -1414(This)X -1577(allows)X -1807(``)X -7 f -1861(lhs)X -1 f -('')S -2080(to)X -2163(have)X -2336(two)X -2476(different)X -2773(macro)X -2994(de\256nitions)X -3351(at)X -3429(the)X -3547(same)X -3732(time:)X -3916(one)X -976 3192(for)N -1090(command)X -1426(mode)X -1624(and)X -1760(one)X -1896(for)X -2010(input)X -2194(mode.)X -976 3372(Whitespace)N -1373(characters)X -1722(require)X -1972(escaping)X -2275(with)X -2439(a)X -7 f -2497()S -3086(character)X -3405(to)X -3490(be)X -3589(entered)X -3849(in)X -3934(the)X -7 f -976 3462(lhs)N -1 f -1140(string)X -1342(in)X -1424(visual)X -1635(mode.)X -976 3642(Normally,)N -1330(keys)X -1504(in)X -1593(the)X -7 f -1718(rhs)X -1 f -1889(string)X -2098(are)X -2224(remapped)X -2569(\(see)X -2727(the)X -3 f -2853(remap)X -1 f -3104(option\),)X -3383(and)X -3527(it)X -3599(is)X -3680(possible)X -3970(to)X -976 3732(create)N -1207(in\256nite)X -1471(loops.)X -1722(However,)X -2075(keys)X -2260(which)X -2494(map)X -2670(to)X -2770(themselves)X -3164(are)X -3300(not)X -3439(further)X -3695(remapped,)X -976 3822(regardless)N -1327(of)X -1419(the)X -1542(setting)X -1780(of)X -1872(the)X -3 f -1995(remap)X -1 f -2243(option.)X -2512(For)X -2648(example,)X -2966(the)X -3090(command)X -3432(``)X -7 f -3486(:map)X -3732(n)X -3834(nz.)X -1 f -('')S -976 3912(maps)N -1165(the)X -1283(``)X -7 f -1337(n)X -1 f -('')S -1459(key)X -1595(to)X -1677(the)X -3 f -1795(n)X -1 f -1859(and)X -3 f -1995(z)X -1 f -2051(commands.)X -976 4092(To)N -1085(exit)X -1225(an)X -1321(in\256nitely)X -1629(looping)X -1893(map,)X -2071(use)X -2198(the)X -2316(terminal)X -7 f -2603()X -1 f -3151(character.)X -976 4272(Line:)N -1336(Unchanged.)X -976 4362(Options:)N -1336(None.)X -3 f -776 4542([line])N -974(ma[rk])X -1235 0.3125()AX -776 4632([line])N -974(k)X -1038 0.3125()AX -1 f -976 4722(Mark)N -1189(the)X -1326(line)X -1485(with)X -1666(the)X -1803(mark)X -7 f -2007()X -1 f -(.)S -2614(The)X -2778(expressions)X -3192(``)X -7 f -3246(')X -1 f -('')S -3916(and)X -976 4812(``)N -7 f -1030(`)X -1 f -('')S -1680(can)X -1812(then)X -1970(be)X -2066(used)X -2233(as)X -2320(an)X -2416(address)X -2677(in)X -2759(any)X -2895(command)X -3231(that)X -3371(uses)X -3529(one.)X -976 4992(Line:)N -1336(Unchanged.)X -976 5082(Options:)N -1336(None.)X -3 f -776 5262([range])N -1046(m[ove])X -1303(line)X -1 f -976 5352(Move)N -1188(the)X -1312(speci\256ed)X -1623(lines)X -1800(after)X -1974(the)X -2098(target)X -2307(line.)X -2493(A)X -2577(target)X -2786(line)X -2932(of)X -3025(0)X -3091(places)X -3318(the)X -3442(lines)X -3619(at)X -3703(the)X -3827(begin-)X -976 5442(ning)N -1138(of)X -1225(the)X -1343(\256le.)X -976 5622(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(\256rst)X -1802(of)X -1889(the)X -2007(moved)X -2245(lines.)X -976 5712(Options:)N -1336(None.)X - -40 p -%%Page: 40 39 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-40)N -2813(Nvi/Nex)X -3109 0.3906(Reference)AX -3474(\(Ex)X -3614(Commands\))X -776 762 0.3250(mk[exrc][!])AN -1190(\256le)X -1 f -976 852(Write)N -1180(the)X -1299(abbreviations,)X -1772(editor)X -1980(options)X -2237(and)X -2375(maps)X -2566(to)X -2650(the)X -2770(speci\256ed)X -3077(\256le.)X -3241(Information)X -3646(is)X -3721(written)X -3970(in)X -976 942(a)N -1034(form)X -1212(which)X -1430(can)X -1564(later)X -1729(be)X -1827(read)X -1988(back)X -2162(in)X -2246(using)X -2441(the)X -3 f -2561(ex)X -2659(source)X -1 f -2904(command.)X -3282(If)X -7 f -3358(file)X -1 f -3572(already)X -3830(exists,)X -976 1032(the)N -3 f -1097(mkexrc)X -1 f -1379(command)X -1718(will)X -1865(fail.)X -2035(This)X -2200(check)X -2411(can)X -2546(be)X -2645(overridden)X -3016(by)X -3119(appending)X -3476(a)X -3536(``)X -7 f -3590(!)X -1 f -('')S -3736(character)X -976 1122(to)N -1058(the)X -1176(command.)X -976 1302(Line:)N -1336(Unchanged.)X -976 1392(Options:)N -1336(None.)X -3 f -776 1572(n[ext][!])N -1078([\256le)X -1227(...])X -1 f -976 1662(Edit)N -1142(the)X -1273(next)X -1444(\256le)X -1579(from)X -1768(the)X -1899(argument)X -2235(list.)X -2405(The)X -3 f -2563(next)X -1 f -2743(command)X -3092(will)X -3249(fail)X -3389(if)X -3471(the)X -3603(\256le)X -3739(has)X -3880(been)X -976 1752(modi\256ed)N -1287(since)X -1478(the)X -1602(last)X -1739(complete)X -2059(write.)X -2290(This)X -2458(check)X -2672(can)X -2810(be)X -2912(overridden)X -3286(by)X -3392(appending)X -3752(the)X -3876(``)X -7 f -3930(!)X -1 f -('')S -976 1842(character)N -1294(to)X -1378(the)X -1498(command)X -1836(name.)X -2072(The)X -2219(argument)X -2544(list)X -2663(can)X -2797(optionally)X -3143(be)X -3241(replaced)X -3536(by)X -3639(specifying)X -3996(a)X -976 1932(new)N -1131(one)X -1268(as)X -1355(arguments)X -1709(to)X -1791(this)X -1926(command.)X -2302(In)X -2389(this)X -2524(case,)X -2703(editing)X -2945(starts)X -3134(with)X -3296(the)X -3414(\256rst)X -3558(\256le)X -3680(on)X -3780(the)X -3898(new)X -976 2022(list.)N -976 2202(Line:)N -1336(Set)X -1458(as)X -1545(described)X -1873(for)X -1987(the)X -3 f -2105(edit)X -1 f -2254(command.)X -976 2292(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -1856(options)X -3 f -2111(autowrite)X -1 f -2461(and)X -3 f -2597(writeany)X -1 f -2900(.)X -3 f -776 2472([line])N -974(o[pen])X -1212(/pattern/)X -1530([\257ags])X -1 f -976 2562(Enter)N -1172(open)X -1350(mode.)X -1590(Open)X -1786(mode)X -1987(is)X -2063(the)X -2184(same)X -2372(as)X -2462(being)X -2663(in)X -3 f -2748(vi)X -1 f -2810(,)X -2853(but)X -2978(with)X -3143(a)X -3202(one-line)X -3488(window.)X -3809(All)X -3934(the)X -976 2652(standard)N -3 f -1278(vi)X -1 f -1370(commands)X -1747(are)X -1876(available.)X -2236(If)X -2320(a)X -2386(match)X -2612(is)X -2694(found)X -2910(for)X -3033(the)X -3160(optional)X -3451(RE)X -3582(argument,)X -3934(the)X -976 2742(cursor)N -1197(is)X -1270(set)X -1379(to)X -1461(the)X -1579(start)X -1737(of)X -1824(the)X -1942(matching)X -2260(pattern.)X -2 f -976 2922(This)N -1133(command)X -1465(is)X -1538(not)X -1660(yet)X -1774(implemented.)X -1 f -976 3102(Line:)N -1336(Unchanged,)X -1750(unless)X -1978(the)X -2104(optional)X -2394(RE)X -2524(is)X -2605(speci\256ed,)X -2938(in)X -3028(which)X -3253(case)X -3421(it)X -3494(is)X -3576(set)X -3694(to)X -3785(the)X -3912(line)X -1336 3192(where)N -1553(the)X -1671(matching)X -1989(pattern)X -2232(is)X -2305(found.)X -976 3282(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -3 f -1856(open)X -1 f -2040(option.)X -3 f -776 3462(pre[serve])N -1 f -976 3552(Save)N -1161(the)X -1288(\256le)X -1419(in)X -1510(a)X -1575(form)X -1760(that)X -1909(can)X -2050(later)X -2222(be)X -2327(recovered)X -2674(using)X -2877(the)X -3 f -3005(ex)X -9 f -3111(-)X -3113(-)X -3 f -3157(r)X -1 f -3223(option.)X -3497(When)X -3719(the)X -3847(\256le)X -3979(is)X -976 3642(preserved,)N -1329(an)X -1425(email)X -1623(message)X -1915(is)X -1988(sent)X -2137(to)X -2219(the)X -2337(user.)X -976 3822(Line:)N -1336(Unchanged.)X -976 3912(Options:)N -1336(None.)X -3 f -776 4092(prev[ious][!])N -1 f -976 4182(Edit)N -1136(the)X -1261(previous)X -1564(\256le)X -1693(from)X -1876(the)X -2001(argument)X -2331(list.)X -2495(The)X -3 f -2647(previous)X -1 f -2967(command)X -3310(will)X -3461(fail)X -3595(if)X -3671(the)X -3796(\256le)X -3925(has)X -976 4272(been)N -1155(modi\256ed)X -1466(since)X -1658(the)X -1783(last)X -1921(complete)X -2241(write.)X -2472(This)X -2640(check)X -2854(can)X -2992(be)X -3094(overridden)X -3468(by)X -3574(appending)X -3934(the)X -976 4362(``)N -7 f -1030(!)X -1 f -('')S -1172(character)X -1488(to)X -1570(the)X -1688(command)X -2024(name.)X -976 4542(Line:)N -1336(Set)X -1458(as)X -1545(described)X -1873(for)X -1987(the)X -3 f -2105(edit)X -1 f -2254(command.)X -976 4632(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -1856(options)X -3 f -2111(autowrite)X -1 f -2461(and)X -3 f -2597(writeany)X -1 f -2900(.)X -2960(None.)X -3 f -776 4812([range])N -1046(p[rint])X -1293([count])X -1558([\257ags])X -1 f -976 4902(Display)N -1245(the)X -1363(speci\256ed)X -1668(lines.)X -976 5082(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(last)X -1789(line)X -1929(displayed.)X -976 5172(Options:)N -1336(None.)X -3 f -776 5352([line])N -974(pu[t])X -1163([buffer])X -1 f -976 5442(Append)N -1250(buffer)X -1467(contents)X -1755(to)X -1838(the)X -1957(current)X -2206(line.)X -2387(If)X -2462(a)X -2519(buffer)X -2737(is)X -2811(speci\256ed,)X -3137(its)X -3233(contents)X -3521(are)X -3641(appended)X -3970(to)X -976 5532(the)N -1094(line,)X -1254(otherwise,)X -1606(the)X -1724(contents)X -2011(of)X -2098(the)X -2216(unnamed)X -2530(buffer)X -2747(are)X -2866(used.)X -976 5712(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(line)X -1798(after)X -1966(the)X -2084(current)X -2332(line.)X - -41 p -%%Page: 41 40 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Ex)X -1377(Commands\))X -3658(USD:13-41)X -1 f -976 762(Options:)N -1336(None.)X -3 f -776 942(q[uit][!])N -1 f -976 1032(End)N -1133(the)X -1259(editing)X -1509(session.)X -1808(If)X -1890(the)X -2016(\256le)X -2146(has)X -2281(been)X -2461(modi\256ed)X -2773(since)X -2966(the)X -3092(last)X -3231(complete)X -3554(write,)X -3768(the)X -3 f -3895(quit)X -1 f -976 1122(command)N -1314(will)X -1460(fail.)X -1629(This)X -1793(check)X -2003(may)X -2163(be)X -2261(overridden)X -2631(by)X -2733(appending)X -3089(a)X -3147(``)X -7 f -3201(!)X -1 f -('')S -3345(character)X -3663(to)X -3747(the)X -3867(com-)X -976 1212(mand.)N -976 1392(If)N -1053(there)X -1237(are)X -1359(more)X -1547(\256les)X -1703(to)X -1788(edit,)X -1951(the)X -3 f -2072(quit)X -1 f -2232(command)X -2571(will)X -2718(fail.)X -2888(Appending)X -3268(a)X -3328(``)X -7 f -3382(!)X -1 f -('')S -3528(character)X -3848(to)X -3934(the)X -976 1482(command)N -1315(name)X -1511(or)X -1600(entering)X -1885(two)X -3 f -2027(quit)X -1 f -2186(commands)X -2555(\(i.e.)X -3 f -2722(wq)X -1 f -2824(,)X -3 f -2866(quit)X -1 f -3003(,)X -3 f -3045(xit)X -1 f -3156(or)X -3 f -3245(ZZ)X -1 f -3351(\))X -3400(in)X -3484(a)X -3542(row\))X -3716(will)X -3862(over-)X -976 1572(ride)N -1121(this)X -1256(check)X -1464(and)X -1600(the)X -1718(editor)X -1925(will)X -2069(exit.)X -976 1752(Line:)N -1336(Unchanged.)X -976 1842(Options:)N -1336(None.)X -3 f -776 2022([line])N -974(r[ead][!])X -1285([\256le])X -1 f -976 2112(Read)N -1171(a)X -1237(\256le.)X -1409(A)X -1497(copy)X -1683(of)X -1780(the)X -1908(speci\256ed)X -2223(\256le)X -2355(is)X -2438(appended)X -2776(to)X -2868(the)X -2996(line.)X -3186(If)X -7 f -3270(line)X -1 f -3492(is)X -3575(0,)X -3665(the)X -3793(copy)X -3979(is)X -976 2202(inserted)N -1252(at)X -1332(the)X -1452(beginning)X -1794(of)X -1883(the)X -2003(\256le.)X -2167(If)X -2243(no)X -2345(\256le)X -2469(is)X -2544(speci\256ed,)X -2871(the)X -2991(current)X -3241(\256le)X -3365(is)X -3440(read;)X -3623(if)X -3694(there)X -3877(is)X -3952(no)X -976 2292(current)N -1233(\256le,)X -1384(then)X -7 f -1552(file)X -1 f -1774(becomes)X -2085(the)X -2213(current)X -2471(\256le.)X -2643(If)X -2727(there)X -2918(is)X -3001(no)X -3111(current)X -3369(\256le)X -3501(and)X -3647(no)X -7 f -3757(file)X -1 f -3979(is)X -976 2382(speci\256ed,)N -1301(then)X -1459(the)X -3 f -1577(read)X -1 f -1753(command)X -2089(will)X -2233(fail.)X -976 2562(If)N -7 f -1054(file)X -1 f -1270(is)X -1347(preceded)X -1662(by)X -1766(a)X -1826(``)X -7 f -1880(!)X -1 f -('')S -2026(character,)X -7 f -2366(file)X -1 f -2582(is)X -2659(treated)X -2902(as)X -2993(if)X -3067(it)X -3136(were)X -3318(a)X -3379(shell)X -3555(command,)X -3916(and)X -976 2652(passed)N -1213(to)X -1298(the)X -1419(program)X -1713(named)X -1949(by)X -2051(the)X -7 f -2171(SHELL)X -1 f -2433(environment)X -2860(variable.)X -3181(The)X -3328(standard)X -3622(and)X -3760(standard)X -976 2742(error)N -1155(outputs)X -1412(of)X -1501(that)X -1643(command)X -1981(are)X -2102(read)X -2263(into)X -2409(the)X -2529(\256le)X -2654(after)X -2825(the)X -2946(speci\256ed)X -3254(line.)X -3437(The)X -3585(special)X -3831(mean-)X -976 2832(ing)N -1098(of)X -1185(the)X -1303(``)X -7 f -1357(!)X -1 f -('')S -1499(character)X -1815(can)X -1947(be)X -2043(overridden)X -2411(by)X -2511(escaping)X -2812(it)X -2876(with)X -3038(a)X -3094(backslash)X -3426(\(``)X -7 f -3507(\\)X -1 f -(''\))S -3656(character.)X -976 3012(Line:)N -1336(When)X -1550(executed)X -1858(from)X -3 f -2036(ex)X -1 f -2112(,)X -2154(the)X -2274(current)X -2524(line)X -2666(is)X -2741(set)X -2852(to)X -2936(the)X -3056(last)X -3189(line)X -3331(read.)X -3532(When)X -3746(executed)X -1336 3102(from)N -3 f -1512(vi)X -1 f -1574(,)X -1614(the)X -1732(current)X -1980(line)X -2120(is)X -2193(set)X -2302(to)X -2384(the)X -2502(\256rst)X -2646(line)X -2786(read.)X -976 3192(Options:)N -1336(None.)X -3 f -776 3372 0.4063(rec[over])AN -1110(\256le)X -1 f -976 3462(Recover)N -7 f -1273(file)X -1 f -1494(if)X -1572(it)X -1645(was)X -1799(previously)X -2166(saved.)X -2418(If)X -2501(no)X -2610(saved)X -2822(\256le)X -2953(by)X -3062(that)X -3211(name)X -3414(exists,)X -3645(the)X -3 f -3772(recover)X -1 f -976 3552(command)N -1312(behaves)X -1591(similarly)X -1895(to)X -1977(the)X -3 f -2095(edit)X -1 f -2244(command.)X -976 3732(Line:)N -1336(Set)X -1458(as)X -1545(described)X -1873(for)X -1987(the)X -3 f -2105(edit)X -1 f -2254(command.)X -976 3822(Options:)N -1336(None.)X -3 f -776 4002(res[ize])N -1047([+|-]size)X -976 4092(Vi)N -1 f -1081(mode)X -1284(only.)X -1492(Grow)X -1701(or)X -1794(shrink)X -2020(the)X -2144(current)X -2398(screen.)X -2670(If)X -7 f -2750(size)X -1 f -2968(is)X -3047(a)X -3109(positive,)X -3408(signed)X -3643(number,)X -3934(the)X -976 4182(current)N -1227(screen)X -1456(is)X -1532(grown)X -1760(by)X -1863(that)X -2006(many)X -2207(lines.)X -2421(If)X -7 f -2498(size)X -1 f -2713(is)X -2789(a)X -2848(negative,)X -3163(signed)X -3395(number,)X -3683(the)X -3804(current)X -976 4272(screen)N -1212(is)X -1295(shrunk)X -1543(by)X -1653(that)X -1803(many)X -2011(lines.)X -2232(If)X -7 f -2316(size)X -1 f -2538(is)X -2621(not)X -2753(signed,)X -3012(the)X -3141(current)X -3400(screen)X -3637(is)X -3721(set)X -3841(to)X -3934(the)X -976 4362(speci\256ed)N -7 f -1281(size)X -1 f -(.)S -1533(Applicable)X -1905(only)X -2067(to)X -2149(split)X -2306(screens.)X -976 4542(Line:)N -1336(Unchanged.)X -976 4632(Options:)N -1336(None.)X -3 f -776 4812(rew[ind][!])N -1 f -976 4902(Rewind)N -1251(the)X -1375(argument)X -1704(list.)X -1867(If)X -1947(the)X -2071(current)X -2325(\256le)X -2453(has)X -2586(been)X -2764(modi\256ed)X -3074(since)X -3265(the)X -3389(last)X -3526(complete)X -3847(write,)X -976 4992(the)N -3 f -1097(rewind)X -1 f -1360(command)X -1699(will)X -1846(fail.)X -2016(This)X -2180(check)X -2390(may)X -2550(be)X -2648(overridden)X -3018(by)X -3120(appending)X -3476(the)X -3596(``)X -7 f -3650(!)X -1 f -('')S -3794(charac-)X -976 5082(ter)N -1081(to)X -1163(the)X -1281(command.)X -976 5262(Otherwise,)N -1346(the)X -1464(current)X -1712(\256le)X -1834(is)X -1907(set)X -2016(to)X -2098(the)X -2216(\256rst)X -2360(\256le)X -2482(in)X -2564(the)X -2682(argument)X -3005(list.)X -976 5442(Line:)N -1336(Set)X -1458(as)X -1545(described)X -1873(for)X -1987(the)X -3 f -2105(edit)X -1 f -2254(command.)X -976 5532(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -3 f -1856(autowrite)X -1 f -2206(and)X -3 f -2342(writeany)X -1 f -2665(options.)X -3 f -776 5712(se[t])N -944([option[=[value]])X -1544(...])X -1651([nooption)X -1999(...])X -2106([option?)X -2410(...])X -2517([all])X -1 f -976 5802(Display)N -1252(or)X -1346(set)X -1462(editor)X -1676(options.)X -1979(When)X -2199(no)X -2307(arguments)X -2669(are)X -2796(speci\256ed,)X -3129(the)X -3255(editor)X -3470(option)X -3 f -3702(term)X -1 f -3868(,)X -3916(and)X - -42 p -%%Page: 42 41 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-42)N -2813(Nvi/Nex)X -3109 0.3906(Reference)AX -3474(\(Ex)X -3614(Commands\))X -1 f -976 762(any)N -1115(editor)X -1325(options)X -1583(whose)X -1811(values)X -2039(have)X -2214(been)X -2389(changed)X -2679(from)X -2857(the)X -2977(default)X -3222(settings)X -3488(are)X -3609(displayed.)X -3978(If)X -976 852(the)N -1094(argument)X -7 f -1417(all)X -1 f -1581(is)X -1654(speci\256ed,)X -1979(the)X -2097(values)X -2322(of)X -2409(all)X -2509(of)X -2596(editor)X -2803(options)X -3058(are)X -3177(displayed.)X -976 1032(Specifying)N -1353(an)X -1459(option)X -1693(name)X -1897(followed)X -2212(by)X -2322(the)X -2450(character)X -2776(``)X -7 f -2830(?)X -1 f -('')S -2982(causes)X -3222(the)X -3350(current)X -3609(value)X -3814(of)X -3912(that)X -976 1122(option)N -1203(to)X -1288(be)X -1387(displayed.)X -1757(The)X -1905(``)X -7 f -1959(?)X -1 f -('')S -2104(can)X -2239(be)X -2338(separated)X -2665(from)X -2843(the)X -2963(option)X -3189(name)X -3385(by)X -3487(whitespace)X -3866(char-)X -976 1212(acters.)N -1225(The)X -1371(``)X -7 f -1425(?)X -1 f -('')S -1568(is)X -1642(necessary)X -1976(only)X -2139(for)X -2254(Boolean)X -2543(valued)X -2779(options.)X -3076(Boolean)X -3365(options)X -3622(can)X -3756(be)X -3854(given)X -976 1302(values)N -1209(by)X -1317(the)X -1443(form)X -1627(``)X -7 f -1681(set)X -1881(option)X -1 f -('')S -2251(to)X -2341(turn)X -2498(them)X -2686(on,)X -2814(or)X -2909(``)X -7 f -2963(set)X -3162(nooption)X -1 f -('')S -3627(to)X -3716(turn)X -3872(them)X -976 1392(off.)N -1131(String)X -1347(and)X -1484(numeric)X -1768(options)X -2024(can)X -2158(be)X -2256(assigned)X -2554(by)X -2656(the)X -2776(form)X -2954(``)X -7 f -3008(set)X -3202(option=value)X -1 f -(''.)S -3894(Any)X -976 1482(whitespace)N -1359(characters)X -1712(in)X -1800(strings)X -2039(can)X -2176(be)X -2277(included)X -2578(literally)X -2852(by)X -2957(preceding)X -3299(each)X -3472(with)X -3639(a)X -3700(backslash.)X -976 1572(More)N -1180(than)X -1349(one)X -1496(option)X -1731(can)X -1874(be)X -1981(set)X -2101(or)X -2199(listed)X -2403(by)X -2514(a)X -2581(single)X -2803(set)X -2923(command,)X -3290(by)X -3401(specifying)X -3766(multiple)X -976 1662(arguments,)N -1350(each)X -1518(separated)X -1842(from)X -2018(the)X -2136(next)X -2294(by)X -2394(whitespace)X -2771(characters.)X -976 1842(Line:)N -1336(Unchanged.)X -976 1932(Options:)N -1336(None.)X -3 f -776 2112(sh[ell])N -1 f -976 2202(Run)N -1131(a)X -1189(shell)X -1362(program.)X -1696(The)X -1843(program)X -2137(named)X -2373(by)X -2475(the)X -3 f -2596(shell)X -1 f -2774(option)X -3001(is)X -3077(run)X -3207(with)X -3372(a)X -3 f -9 f -3431(-)X -3433(-)X -3 f -3477(i)X -1 f -3522(\(for)X -3666(interactive\))X -976 2292(\257ag.)N -1156(Editing)X -1411(is)X -1484(resumed)X -1776(when)X -1970(that)X -2110(program)X -2402(exits.)X -976 2472(Line:)N -1336(Unchanged.)X -976 2562(Options:)N -1336(None.)X -3 f -776 2742(so[urce])N -1073(\256le)X -1 f -976 2832(Read)N -1161(and)X -1297(execute)X -3 f -1563(ex)X -1 f -1659(commands)X -2026(from)X -2202(a)X -2258(\256le.)X -3 f -2420(Source)X -1 f -2676(commands)X -3043(may)X -3201(be)X -3297(nested.)X -976 3012(Line:)N -1336(Unchanged.)X -976 3102(Options:)N -1336(None.)X -3 f -776 3282(sp[lit])N -996([\256le)X -1145(...])X -976 3372(Vi)N -1 f -1078(mode)X -1278(only.)X -1482(Split)X -1655(the)X -1776(screen.)X -2045(The)X -2193(current)X -2444(screen)X -2673(is)X -2749(split)X -2909(into)X -3056(two)X -3199(screens,)X -3479(of)X -3569(approximately)X -976 3462(equal)N -1173(size.)X -1361(If)X -1438(the)X -1559(cursor)X -1783(is)X -1859(in)X -1944(the)X -2065(lower)X -2271(half)X -2419(of)X -2509(the)X -2630(screen,)X -2879(the)X -3000(screen)X -3229(will)X -3376(split)X -3536(up,)X -3658(i.e.)X -3778(the)X -3898(new)X -976 3552(screen)N -1213(will)X -1368(be)X -1475(above)X -1699(the)X -1829(old)X -1963(one.)X -2151(If)X -2237(the)X -2367(cursor)X -2600(is)X -2685(in)X -2779(the)X -2909(upper)X -3124(half)X -3281(of)X -3380(the)X -3510(screen,)X -3768(the)X -3898(new)X -976 3642(screen)N -1202(will)X -1346(be)X -1442(below)X -1658(the)X -1776(old)X -1898(one.)X -976 3822(If)N -7 f -1052(file)X -1 f -1267(is)X -1343(speci\256ed,)X -1671(the)X -1792(new)X -1949(screen)X -2178(is)X -2254(editing)X -2499(that)X -2642(\256le,)X -2787(otherwise,)X -3142(both)X -3307(screens)X -3567(are)X -3689(editing)X -3934(the)X -976 3912(same)N -1165(\256le,)X -1310(and)X -1449(changes)X -1731(in)X -1816(each)X -1987(will)X -2134(be)X -2233(be)X -2332(re\257ected)X -2632(in)X -2717(the)X -2838(other.)X -3066(The)X -3214(argument)X -3540(list)X -3660(for)X -3777(the)X -3898(new)X -976 4002(screen)N -1204(consists)X -1479(of)X -1568(the)X -1688(list)X -1807(of)X -1896(\256les)X -2051(speci\256ed)X -2358(as)X -2447(arguments)X -2803(to)X -2888(this)X -3026(command,)X -3385(or,)X -3495(the)X -3616(current)X -3867(path-)X -976 4092(name)N -1170(if)X -1239(no)X -1339(\256les)X -1492(are)X -1611(speci\256ed.)X -976 4272(Line:)N -1336(If)X -7 f -1410(file)X -1 f -1622(is)X -1695(speci\256ed,)X -2020(set)X -2129(as)X -2216(for)X -2330(the)X -3 f -2448(edit)X -1 f -2597(command,)X -2953(otherwise)X -3285(unchanged.)X -976 4362(Options:)N -1336(None.)X -3 f -776 4542([range])N -1046(s[ubstitute])X -1453([/pattern/replace/])X -2097([options])X -2419([count])X -2684([\257ags])X -776 4632([range])N -1046(&)X -1133([options])X -1455([count])X -1720([\257ags])X -776 4722([range])N -1046(\304)X -1093([options])X -1415([count])X -1680([\257ags])X -1 f -976 4812(Make)N -1185(substitutions.)X -1654(Replace)X -1939(the)X -2063(\256rst)X -2214(instance)X -2504(of)X -7 f -2598(pattern)X -1 f -2961(with)X -3130(the)X -3255(string)X -7 f -3464(replace)X -1 f -3827(on)X -3934(the)X -976 4902(speci\256ed)N -1343(line\(s\).)X -1670(If)X -1806(the)X -1986(``)X -7 f -2040(/pattern/repl/)X -1 f -('')S -2847(argument)X -3231(is)X -3365(not)X -3548(speci\256ed,)X -3934(the)X -976 4992(``)N -7 f -1030(/pattern/repl/)X -1 f -('')S -1776(from)X -1952(the)X -2070(previous)X -3 f -2366(substitute)X -1 f -2719(command)X -3055(is)X -3128(used.)X -976 5172(If)N -7 f -1054(options)X -1 f -1414(includes)X -1705(the)X -1827(letter)X -2017(``)X -7 f -2071(c)X -1 f -('')S -2198(\(con\256rm\),)X -2546(you)X -2691(will)X -2840(be)X -2941(prompted)X -3273(for)X -3392(con\256rmation)X -3826(before)X -976 5262(each)N -1152(replacement)X -1573(is)X -1654(done.)X -1878(An)X -2004(af\256rmative)X -2384(response)X -2693(\(in)X -2810(English,)X -3101(a)X -3164(``)X -7 f -3218(y)X -1 f -('')S -3347 0.3750(character\))AX -3697(causes)X -3934(the)X -976 5352(replacement)N -1393(to)X -1479(be)X -1579(made.)X -1817(A)X -1899(quit)X -2047(response)X -2352(\(in)X -2465(English,)X -2753(a)X -2813(``)X -7 f -2867(q)X -1 f -('')S -2993 0.3750(character\))AX -3341(causes)X -3576(the)X -3 f -3699(substitute)X -1 f -976 5442(command)N -1320(to)X -1410(be)X -1514(terminated.)X -1925(Any)X -2091(other)X -2284(response)X -2592(causes)X -2829(the)X -2954(replacement)X -3374(not)X -3503(to)X -3592(be)X -3695(made,)X -3916(and)X -976 5532(the)N -3 f -1094(substitute)X -1 f -1447(command)X -1783(continues.)X -2150(If)X -7 f -2224(options)X -1 f -2580(includes)X -2867(the)X -2985(letter)X -3170(``)X -7 f -3224(g)X -1 f -('')S -3346(\(global\),)X -3641(all)X -3742(nonover-)X -976 5622(lapping)N -1236(instances)X -1550(of)X -7 f -1637(pattern)X -1 f -1993(in)X -2075(the)X -2193(line)X -2333(are)X -2452(replaced.)X -976 5802(The)N -3 f -1122(&)X -1 f -1210(version)X -1467(of)X -1555(the)X -1674(command)X -2011(is)X -2085(the)X -2204(same)X -2390(as)X -2479(not)X -2603(specifying)X -2959(a)X -3017(pattern)X -3262(or)X -3351(replacement)X -3766(string)X -3970(to)X - -43 p -%%Page: 43 42 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Ex)X -1377(Commands\))X -3658(USD:13-43)X -1 f -976 762(the)N -3 f -1098(substitute)X -1 f -1455(command,)X -1815(and)X -1955(the)X -2077(``)X -7 f -2131(&)X -1 f -('')S -2257(is)X -2333(replaced)X -2629(by)X -2732(the)X -2853(pattern)X -3099(and)X -3238(replacement)X -3654(information)X -976 852(from)N -1152(the)X -1270(previous)X -1566(substitute)X -1892(command.)X -976 1032(The)N -3 f -1121(\304)X -1 f -1168(version)X -1424(of)X -1511(the)X -1629(command)X -1966(is)X -2040(the)X -2159(same)X -2345(as)X -3 f -2433(&)X -1 f -2521(and)X -3 f -2658(s)X -1 f -2689(,)X -2730(except)X -2961(that)X -3102(the)X -3221(search)X -3448(pattern)X -3692(used)X -3860(is)X -3934(the)X -976 1122(last)N -1107(RE)X -1229(used)X -1396(in)X -2 f -1478(any)X -1 f -1614(command,)X -1970(not)X -2092(necessarily)X -2469(the)X -2587(one)X -2723(used)X -2890(in)X -2972(the)X -3090(last)X -3 f -3221(substitute)X -1 f -3574(command.)X -976 1302(For)N -1107(example,)X -1419(in)X -1501(the)X -1619(sequence)X -7 f -1296 1425(s/red/blue/)N -1296 1515(/green)N -1296 1605(\304)N -1 f -976 1728(the)N -1094(``)X -7 f -1148(\304)X -1 f -('')S -1270(is)X -1343(equivalent)X -1697(to)X -1779(``)X -7 f -1833(s/green/blue/)X -1 f -(''.)S -976 1908(The)N -3 f -1126(substitute)X -1 f -1484(command)X -1825(may)X -1988(be)X -2089(interrupted,)X -2486(using)X -2685(the)X -2809(terminal)X -3102(interrupt)X -3404(character.)X -3766(All)X -3894(sub-)X -976 1998(stitutions)N -1288(completed)X -1642(before)X -1868(the)X -1986(interrupt)X -2282(are)X -2401(retained.)X -976 2178(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(last)X -1789(line)X -1929(upon)X -2109(which)X -2325(a)X -2381(substitution)X -2773(was)X -2918(made.)X -976 2268(Options:)N -1336(None.)X -3 f -776 2448(su[spend][!])N -776 2538(st[op][!])N -776 2628()N -1 f -976 2718(Suspend)N -1285(the)X -1422(edit)X -1581(session.)X -1891(Appending)X -2286(a)X -2361(``)X -7 f -2415(!)X -1 f -('')S -2576(character)X -2911(to)X -3012(these)X -3216(commands)X -3602(turns)X -3801(off)X -3934(the)X -3 f -976 2808(autowrite)N -1 f -1326(option)X -1550(for)X -1664(the)X -1782(command.)X -976 2988(Line:)N -1336(Unchanged.)X -976 3078(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -3 f -1856(autowrite)X -1 f -2206(option.)X -3 f -776 3258(ta[g][!])N -1038(tagstring)X -1 f -976 3348(Edit)N -1133(the)X -1255(\256le)X -1381(containing)X -1743(the)X -1865(speci\256ed)X -2174(tag.)X -2337(Search)X -2581(for)X -2700(the)X -2823(tagstring,)X -3148(which)X -3369(can)X -3506(be)X -3607(in)X -3694(a)X -3755(different)X -976 3438(\256le.)N -1149(If)X -1234(the)X -1363(tag)X -1492(is)X -1576(in)X -1669(a)X -1736(different)X -2044(\256le,)X -2197(then)X -2366(the)X -2495(new)X -2660(\256le)X -2792(is)X -2875(edited.)X -3141(If)X -3225(the)X -3353(current)X -3611(\256le)X -3743(has)X -3880(been)X -976 3528(modi\256ed)N -1283(since)X -1471(the)X -1592(last)X -1726(complete)X -2043(write,)X -2251(the)X -3 f -2372(tag)X -1 f -2502(command)X -2841(will)X -2988(fail.)X -3159(This)X -3325(check)X -3537(can)X -3673(be)X -3773(overrid-)X -976 3618(den)N -1112(by)X -1212(appending)X -1566(the)X -1684(``)X -7 f -1738(!)X -1 f -('')S -1880(character)X -2196(to)X -2278(the)X -2396(command)X -2732(name.)X -976 3798(The)N -3 f -1128(tag)X -1 f -1262(command)X -1605(searches)X -1905(for)X -7 f -2026(tagstring)X -1 f -2485(in)X -2574(the)X -2699(tags)X -2855(\256le\(s\))X -3070(speci\256ed)X -3383(by)X -3491(the)X -3617(option.)X -3889(\(See)X -2 f -976 3888(ctags)N -1 f -1145(\(1\))X -1259(for)X -1373(more)X -1558(information)X -1956(on)X -2056(tags)X -2205(\256les.\))X -976 4068(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(line)X -1798(indicated)X -2112(by)X -2212(the)X -2330(tag.)X -976 4158(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -3 f -1856(autowrite)X -1 f -2186(,)X -3 f -2226(taglength)X -1 f -(,)S -3 f -2586(tags)X -1 f -2744(and)X -3 f -2880(writeany)X -1 f -3203(options.)X -3 f -776 4338(tagp[op][!])N -1166([\256le)X -1315(|)X -1353(number])X -1 f -976 4428(Pop)N -1122(to)X -1206(the)X -1326(speci\256ed)X -1633(tag)X -1753(in)X -1837(the)X -1957(tags)X -2108(stack.)X -2335(If)X -2411(neither)X -7 f -2656(file)X -1 f -2871(or)X -7 f -2961(number)X -1 f -3272(is)X -3348(speci\256ed,)X -3676(the)X -3 f -3797(tagpop)X -1 f -976 4518(command)N -1313(pops)X -1485(to)X -1568(the)X -1686(most)X -1861(recent)X -2078(entry)X -2263(on)X -2363(the)X -2481(tags)X -2630(stack.)X -2855(If)X -7 f -2929(file)X -1 f -3141(or)X -7 f -3228(number)X -1 f -3536(is)X -3609(speci\256ed,)X -3934(the)X -3 f -976 4608(tagpop)N -1 f -1242(command)X -1589(pops)X -1771(to)X -1864(the)X -1993(most)X -2179(recent)X -2407(entry)X -2603(in)X -2696(the)X -2825(tags)X -2985(stack)X -3181(for)X -3306(that)X -3458(\256le,)X -3612(or)X -3711(numbered)X -976 4698(entry)N -1165(in)X -1251(the)X -1373(tags)X -1526(stack,)X -1735(respectively.)X -2186(\(See)X -2352(the)X -3 f -2473(display)X -1 f -2739(command)X -3078(for)X -3195(information)X -3596(on)X -3699(displaying)X -976 4788(the)N -1094(tags)X -1243(stack.\))X -976 4968(If)N -1051(the)X -1170(\256le)X -1293(has)X -1421(been)X -1594(modi\256ed)X -1899(since)X -2085(the)X -2204(last)X -2337(complete)X -2653(write,)X -2860(the)X -3 f -2980(tagpop)X -1 f -3237(command)X -3575(will)X -3721(fail.)X -3890(This)X -976 5058(check)N -1184(may)X -1342(be)X -1438(overridden)X -1806(by)X -1906(appending)X -2260(a)X -2316(``)X -7 f -2370(!)X -1 f -('')S -2512(character)X -2828(to)X -2910(the)X -3028(command)X -3364(name.)X -976 5238(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(line)X -1798(indicated)X -2112(by)X -2212(the)X -2330(tag.)X -976 5328(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -3 f -1856(autowrite)X -1 f -2186(,)X -2226(and)X -3 f -2362(writeany)X -1 f -2685(options.)X -3 f -776 5508(tagt[op][!])N -1 f -976 5598(Pop)N -1120(to)X -1202(the)X -1320(least)X -1487(recent)X -1704(tag)X -1822(on)X -1922(the)X -2040(tags)X -2189(stack,)X -2394(clearing)X -2673(the)X -2791(tags)X -2940(stack.)X -976 5778(If)N -1051(the)X -1170(\256le)X -1293(has)X -1421(been)X -1594(modi\256ed)X -1899(since)X -2085(the)X -2204(last)X -2337(complete)X -2653(write,)X -2860(the)X -3 f -2980(tagpop)X -1 f -3237(command)X -3575(will)X -3721(fail.)X -3890(This)X - -44 p -%%Page: 44 43 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-44)N -2813(Nvi/Nex)X -3109 0.3906(Reference)AX -3474(\(Ex)X -3614(Commands\))X -1 f -976 762(check)N -1184(may)X -1342(be)X -1438(overridden)X -1806(by)X -1906(appending)X -2260(a)X -2316(``)X -7 f -2370(!)X -1 f -('')S -2512(character)X -2828(to)X -2910(the)X -3028(command)X -3364(name.)X -976 942(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(line)X -1798(indicated)X -2112(by)X -2212(the)X -2330(tag.)X -976 1032(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -3 f -1856(autowrite)X -1 f -2186(,)X -2226(and)X -3 f -2362(writeany)X -1 f -2685(options.)X -3 f -776 1212(una[bbrev])N -1178(lhs)X -1 f -976 1302(Delete)N -1206(an)X -1302(abbreviation.)X -1763(Delete)X -7 f -1993(lhs)X -1 f -2157(from)X -2333(the)X -2451(current)X -2699(list)X -2816(of)X -2903(abbreviations.)X -976 1482(Line:)N -1336(Unchanged.)X -976 1572(Options:)N -1336(None.)X -3 f -776 1752(u[ndo])N -1 f -976 1842(Undo)N -1177(the)X -1298(last)X -1432(change)X -1683(made)X -1880(to)X -1965(the)X -2086(\256le.)X -2251(Changes)X -2550(made)X -2747(by)X -3 f -2850(global)X -1 f -3058(,)X -3 f -3101(v)X -1 f -(,)S -3 f -3184(visual)X -1 f -3406(and)X -3545(map)X -3706(sequences)X -976 1932(are)N -1103(considered)X -1479(a)X -1543(single)X -1762(command.)X -2146(If)X -2228(repeated,)X -2549(the)X -3 f -2675(u)X -1 f -2747(command)X -3090(alternates)X -3425(between)X -3720(these)X -3912(two)X -976 2022(states,)N -1194(and)X -1330(is)X -1403(its)X -1498(own)X -1656(inverse.)X -976 2202(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(last)X -1789(line)X -1929(modi\256ed)X -2233(by)X -2333(the)X -2451(command.)X -976 2292(Options:)N -1336(None.)X -3 f -776 2472(unm[ap][!])N -1170(lhs)X -1 f -976 2562(Unmap)N -1235(a)X -1294(mapped)X -1571(string.)X -1816(Delete)X -2049(the)X -2170(command)X -2509(mode)X -2710(map)X -2872(de\256nition)X -3202(for)X -7 f -3320(lhs)X -1 f -(.)S -3528(If)X -3606(a)X -3666(``)X -7 f -3720(!)X -1 f -('')S -3866(char-)X -976 2652(acter)N -1153(is)X -1226(appended)X -1554(to)X -1636(the)X -1754(command)X -2090(name,)X -2304(delete)X -2516(the)X -2634(text)X -2774(input)X -2958(mode)X -3156(map)X -3314(de\256nition)X -3640(instead.)X -976 2832(Line:)N -1336(Unchanged.)X -976 2922(Options:)N -1336(None.)X -3 f -776 3102(ve[rsion])N -1 f -976 3192(Display)N -1245(the)X -1363(version)X -1619(of)X -1706(the)X -3 f -1824(ex/vi)X -1 f -2004(editor.)X -3 f -776 3372([line])N -974(vi[sual])X -1247([type])X -1468([count])X -1733([\257ags])X -976 3462(Ex)N -1 f -1092(mode)X -1293(only.)X -1498(Enter)X -3 f -1695(vi)X -1 f -1757(.)X -1820(The)X -7 f -1968(type)X -1 f -2183(is)X -2259(optional,)X -2564(and)X -2703(can)X -2838(be)X -2937(``)X -7 f -9 f -2991(-)X -1 f -3035('',)X -3132(``)X -7 f -3186(+)X -1 f -('')S -3311(or)X -3401(``)X -7 f -3455(\303)X -1 f -('',)S -3600(as)X -3690(in)X -3775(the)X -3 f -3896(ex)X -3996(z)X -1 f -976 3552(command,)N -1337(to)X -1424(specify)X -1681(the)X -1804(the)X -1926(position)X -2207(of)X -2298(the)X -2420(speci\256ed)X -2729(line)X -2873(in)X -2959(the)X -3081(screen)X -3311(window.)X -3633(\(The)X -3809(default)X -976 3642(is)N -1054(to)X -1141(place)X -1336(the)X -1459(line)X -1605(at)X -1689(the)X -1813(top)X -1941(of)X -2034(the)X -2158(screen)X -2390(window.\))X -2741(A)X -7 f -2825(count)X -1 f -3091(speci\256es)X -3393(the)X -3517(number)X -3788(of)X -3881(lines)X -976 3732(that)N -1116(will)X -1260(initially)X -1528(be)X -1624(displayed.)X -1991(\(The)X -2163(default)X -2406(is)X -2479(the)X -2597(value)X -2791(of)X -2878(the)X -3 f -2996(window)X -1 f -3282(editor)X -3489(option.\))X -976 3912(Line:)N -1336(Unchanged)X -1722(unless)X -7 f -1942(line)X -1 f -2154(is)X -2227(speci\256ed,)X -2552(in)X -2634(which)X -2850(case)X -3009(it)X -3073(is)X -3146(set)X -3255(to)X -3337(that)X -3477(line.)X -976 4002(Options:)N -1336(None.)X -3 f -776 4182(vi[sual][!])N -1130([+cmd])X -1397([\256le])X -976 4272(Vi)N -1 f -1076(mode)X -1274(only.)X -1476(Edit)X -1629(a)X -1685(new)X -1839(\256le.)X -2001(Identical)X -2302(to)X -2384(the)X -2502(``)X -7 f -2556(edit[!])X -2940([+cmd])X -3276([file])X -1 f -('')S -3638(command.)X -3 f -776 4452(viu[sage])N -1103([command])X -1 f -976 4542(Display)N -1253(usage)X -1464(for)X -1586(a)X -3 f -1650(vi)X -1 f -1740(command.)X -2124(If)X -7 f -2206(command)X -1 f -2570(is)X -2651(speci\256ed,)X -2984(a)X -3048(usage)X -3259(statement)X -3595(for)X -3718(that)X -3867(com-)X -976 4632(mand)N -1174(is)X -1247(displayed.)X -1614(Otherwise,)X -1984(usage)X -2187(statements)X -2545(for)X -2659(all)X -3 f -2759(vi)X -1 f -2841(commands)X -3208(are)X -3327(displayed.)X -976 4812(Line:)N -1336(Unchanged.)X -976 4902(Options:)N -1336(None.)X -3 f -776 5082([range])N -1046 0.3611(w[rite][!])AX -1380([>>])X -1546([\256le])X -776 5172([range])N -1046(w[rite])X -1299([!])X -1400([\256le])X -776 5262([range])N -1046(wn[!])X -1249([>>])X -1415([\256le])X -776 5352([range])N -1046(wq[!])X -1249([>>])X -1415([\256le])X -1 f -976 5442(Write)N -1183(the)X -1305(\256le.)X -1472(The)X -1622(speci\256ed)X -1932(lines)X -2108(\(the)X -2258(entire)X -2466(\256le,)X -2613(if)X -2687(no)X -2792(range)X -2996(is)X -3074(given\))X -3304(is)X -3382(written)X -3634(to)X -7 f -3721(file)X -1 f -(.)S -3978(If)X -7 f -976 5532(file)N -1 f -1195(is)X -1275(not)X -1403(speci\256ed,)X -1734(the)X -1858(current)X -2112(pathname)X -2450(is)X -2529(used.)X -2742(If)X -7 f -2822(file)X -1 f -3040(is)X -3119(speci\256ed,)X -3450(and)X -3592(it)X -3662(exists,)X -3890(or)X -3983(if)X -976 5622(the)N -1101(current)X -1356(pathname)X -1695(was)X -1847(set)X -1963(using)X -2163(the)X -3 f -2288(\256le)X -1 f -2417(command,)X -2780(and)X -2923(the)X -3049(\256le)X -3179(already)X -3444(exists,)X -3674(these)X -3867(com-)X -976 5712(mands)N -1212(will)X -1363(fail.)X -1537(Appending)X -1919(a)X -1981(``)X -7 f -2035(!)X -1 f -('')S -2183(character)X -2505(to)X -2593(the)X -2717(command)X -3059(name)X -3259(will)X -3409(override)X -3703(this)X -3844(check)X -976 5802(and)N -1112(the)X -1230(write)X -1415(will)X -1559(be)X -1655(attempted,)X -2011(regardless.)X - -45 p -%%Page: 45 44 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -1237(\(Ex)X -1377(Commands\))X -3658(USD:13-45)X -1 f -976 762(Specifying)N -1348(the)X -1471(optional)X -1758(``)X -7 f -1812(>>)X -1 f -('')S -1987(string)X -2194(will)X -2344(cause)X -2549(the)X -2673(write)X -2864(to)X -2952(be)X -3054(appended)X -3388(to)X -3476(the)X -3600(\256le,)X -3748(in)X -3836(which)X -976 852(case)N -1135(no)X -1235(tests)X -1397(are)X -1516(made)X -1710(for)X -1824(the)X -1942(\256le)X -2064(already)X -2321(existing.)X -976 1032(If)N -1060(the)X -1188(\256le)X -1320(is)X -1403(preceded)X -1724(by)X -1834(a)X -1900(``)X -7 f -1954(!)X -1 f -('')S -2106(character,)X -2452(the)X -2580(program)X -2882(named)X -3126(in)X -3218(the)X -3347(SHELL)X -3627(environment)X -976 1122(variable)N -1258(is)X -1334(invoked)X -1615(with)X -1780(\256le)X -1905(as)X -1995(its)X -2093(second)X -2339(argument,)X -2685(and)X -2824(the)X -2945(speci\256ed)X -3253(lines)X -3427(are)X -3549(passed)X -3786(as)X -3876(stan-)X -976 1212(dard)N -1143(input)X -1331(to)X -1417(that)X -1561(command.)X -1941(The)X -2090(``)X -7 f -2144(!)X -1 f -('')S -2291(in)X -2378(this)X -2518(usage)X -2726(must)X -2906(be)X -3007(separated)X -3336(from)X -3517(command)X -3858(name)X -976 1302(by)N -1080(at)X -1162(least)X -1333(one)X -1473(whitespace)X -1854(character.)X -2214(The)X -2363(special)X -2610(meaning)X -2910(of)X -3001(the)X -3122(``)X -7 f -3176(!)X -1 f -('')S -3321(may)X -3482(be)X -3581(overridden)X -3952(by)X -976 1392(escaping)N -1277(it)X -1341(with)X -1503(a)X -1559(backslash)X -1891(\(``)X -7 f -1972(\\)X -1 f -(''\))S -2121(character.)X -976 1572(The)N -3 f -1124(wq)X -1 f -1249(version)X -1509(of)X -1600(the)X -1722(write)X -1911(command)X -2251(will)X -2399(exit)X -2543(the)X -2665(editor)X -2876(after)X -3048(writing)X -3303(the)X -3425(\256le,)X -3571(if)X -3644(there)X -3829(are)X -3952(no)X -976 1662(further)N -1232(\256les)X -1402(to)X -1501(edit.)X -1698(Appending)X -2091(a)X -2164(``)X -7 f -2218(!)X -1 f -('')S -2377(character)X -2710(to)X -2809(the)X -2944(command)X -3297(name)X -3508(or)X -3612(entering)X -3912(two)X -976 1752(``quit'')N -1232(commands)X -1603(\(i.e.)X -3 f -1772(wq)X -1 f -1874(,)X -3 f -1918(quit)X -1 f -2055(,)X -3 f -2099(xit)X -1 f -2212(or)X -3 f -2303(ZZ)X -1 f -2409(\))X -2461(in)X -2548(a)X -2609(row\))X -2786(will)X -2935(override)X -3228(this)X -3368(check)X -3581(and)X -3722(the)X -3845(editor)X -976 1842(will)N -1120(exit,)X -1280(ignoring)X -1571(any)X -1707(\256les)X -1860(that)X -2000(have)X -2172(not)X -2294(yet)X -2412(been)X -2584(edited.)X -976 2022(The)N -3 f -1127(wn)X -1 f -1255(version)X -1517(of)X -1610(the)X -1734(write)X -1925(command)X -2267(will)X -2417(move)X -2621(to)X -2709(the)X -2833(next)X -2997(\256le)X -3125(after)X -3300(writing)X -3558(the)X -3683(\256le,)X -3832(unless)X -976 2112(the)N -1094(write)X -1279(fails.)X -976 2292(Line:)N -1336(Unchanged.)X -976 2382(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -3 f -1856(readonly)X -1 f -2178(and)X -3 f -2314(writeany)X -1 f -2637(options.)X -3 f -776 2562([range])N -1046(x[it][!])X -1290([\256le])X -1 f -976 2652(Write)N -1185(the)X -1309(\256le)X -1437(if)X -1512(it)X -1582(has)X -1715(been)X -1894(modi\256ed.)X -2245(The)X -2397(speci\256ed)X -2709(lines)X -2887(are)X -3013(written)X -3267(to)X -7 f -3356(file)X -1 f -(,)S -3595(if)X -3671(the)X -3796(\256le)X -3925(has)X -976 2742(been)N -1149(modi\256ed)X -1454(since)X -1640(the)X -1759(last)X -1891(complete)X -2206(write)X -2392(to)X -2475(any)X -2612(\256le.)X -2775(If)X -2850(no)X -7 f -2951(range)X -1 f -3211(is)X -3284(speci\256ed,)X -3609(the)X -3727(entire)X -3930(\256le)X -976 2832(is)N -1049(written.)X -976 3012(The)N -3 f -1126(xit)X -1 f -1240(command)X -1581(will)X -1730(exit)X -1875(the)X -1998(editor)X -2210(after)X -2383(writing)X -2639(the)X -2762(\256le,)X -2909(if)X -2983(there)X -3169(are)X -3294(no)X -3400(further)X -3645(\256les)X -3804(to)X -3892(edit.)X -976 3102(Appending)N -1362(a)X -1428(``)X -7 f -1482(!)X -1 f -('')S -1634(character)X -1960(to)X -2052(the)X -2180(command)X -2526(name)X -2730(or)X -2827(entering)X -3120(two)X -3270(``quit'')X -3531(commands)X -3907(\(i.e.)X -3 f -976 3192(wq)N -1 f -1078(,)X -3 f -1125(quit)X -1 f -1262(,)X -3 f -1309(xit)X -1 f -1425(or)X -3 f -1519(ZZ)X -1 f -1625(\))X -1679(in)X -1768(a)X -1831(row\))X -2010(will)X -2161(override)X -2456(this)X -2598(check)X -2813(and)X -2956(the)X -3082(editor)X -3297(will)X -3449(exit,)X -3617(ignoring)X -3916(any)X -976 3282(\256les)N -1129(that)X -1269(have)X -1441(not)X -1563(yet)X -1681(been)X -1853(edited.)X -976 3462(Line:)N -1336(Unchanged.)X -976 3552(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -3 f -1856(readonly)X -1 f -2178(and)X -3 f -2314(writeany)X -1 f -2637(options.)X -3 f -776 3732([range])N -1046(ya[nk])X -1288([buffer])X -1576([count])X -1 f -976 3822(Copy)N -1169(the)X -1287(speci\256ed)X -1592(lines)X -1763(to)X -1845(a)X -1901(buffer.)X -2158(If)X -2232(no)X -2332(buffer)X -2549(is)X -2622(speci\256ed,)X -2947(the)X -3065(unnamed)X -3379(buffer)X -3596(is)X -3669(used.)X -976 4002(Line:)N -1336(Unchanged.)X -976 4092(Options:)N -1336(None.)X -3 f -776 4272([line])N -974(z)X -1030([type])X -1251([count])X -1516([\257ags])X -1 f -976 4362(Adjust)N -1210(the)X -1329(window.)X -1648(If)X -1723(no)X -7 f -1824(type)X -1 f -2037(is)X -2111(speci\256ed,)X -2437(then)X -7 f -2596(count)X -1 f -2858(lines)X -3031(following)X -3364(the)X -3484(speci\256ed)X -3791(line)X -3933(are)X -976 4452(displayed.)N -1362(The)X -1526(default)X -7 f -1788(count)X -1 f -2067(is)X -2159(the)X -2296(value)X -2509(of)X -2614(the)X -3 f -2750(window)X -1 f -3054(option.)X -3336(The)X -7 f -3499(type)X -1 f -3729(argument)X -976 4542(changes)N -1266(the)X -1395(position)X -1683(at)X -1772(which)X -7 f -1999(line)X -1 f -2222(is)X -2306(displayed)X -2644(on)X -2755(the)X -2884(screen)X -3121(by)X -3232(changing)X -3558(the)X -3688(number)X -3965(of)X -976 4632(lines)N -1147(displayed)X -1474(before)X -1700(and)X -1836(after)X -7 f -2004(line)X -1 f -(.)S -2256(The)X -2401(following)X -7 f -2732(type)X -1 f -2944(characters)X -3291(may)X -3449(be)X -3545(used:)X -9 f -976 4812(-)N -1 f -1336(Place)X -1530(the)X -1648(line)X -1788(at)X -1866(the)X -1984(bottom)X -2230(of)X -2317(the)X -2435(screen.)X -976 4902(+)N -1336(Place)X -1530(the)X -1648(line)X -1788(at)X -1866(the)X -1984(top)X -2106(of)X -2193(the)X -2311(screen.)X -976 4992(.)N -1336(Place)X -1530(the)X -1648(line)X -1788(in)X -1870(the)X -1988(middle)X -2230(of)X -2317(the)X -2435(screen.)X -976 5082(\303)N -1336(Write)X -1540(out)X -1663(count)X -1862(lines)X -2034(starting)X -7 f -2295(count)X -2584(*)X -2681(2)X -1 f -2750(lines)X -2922(before)X -7 f -3149(line)X -1 f -(;)S -3384(the)X -3503(net)X -3622(effect)X -3828(of)X -3917(this)X -1336 5172(is)N -1409(that)X -1549(a)X -1605(``)X -7 f -1659(z\303)X -1 f -('')S -1829(command)X -2165(following)X -2496(a)X -3 f -2552(z)X -1 f -2608(command)X -2944(writes)X -3160(the)X -3278(previous)X -3574(page.)X -976 5262(=)N -1336(Center)X -7 f -1580(line)X -1 f -1802(on)X -1912(the)X -2040(screen)X -2276(with)X -2448(a)X -2514(line)X -2664(of)X -2761(hyphens)X -3058(displayed)X -3395(immediately)X -3826(before)X -1336 5352(and)N -1485(after)X -1666(it.)X -1783(The)X -1941(number)X -2219(of)X -2319(preceding)X -2669(and)X -2817(following)X -3160(lines)X -3343(of)X -3442(text)X -3594(displayed)X -3933(are)X -1336 5442(reduced)N -1611(to)X -1693(account)X -1963(for)X -2077(those)X -2266(lines.)X -976 5622(Line:)N -1336(Set)X -1458(to)X -1540(the)X -1658(last)X -1789(line)X -1929(displayed,)X -2276(with)X -2438(the)X -2556(exception)X -2888(of)X -2975(the)X -7 f -3093(type)X -1 f -(,)S -3326(where)X -3544(the)X -3663(current)X -3912(line)X -1336 5712(is)N -1409(set)X -1518(to)X -1600(the)X -1718(line)X -1858(speci\256ed)X -2163(by)X -2263(the)X -2381(command.)X - -46 p -%%Page: 46 45 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-46)N -2813(Nvi/Nex)X -3109 0.3906(Reference)AX -3474(\(Ex)X -3614(Commands\))X -1 f -976 762(Options:)N -1336(Affected)X -1638(by)X -1738(the)X -1856(option.)X -3 f -776 948(15.)N -916(Set)X -1043(Options)X -1 f -976 1071(There)N -1186(are)X -1307(a)X -1365(large)X -1548(number)X -1815(of)X -1904(options)X -2161(that)X -2303(may)X -2463(be)X -2561(set)X -2672(\(or)X -2788(unset\))X -3006(to)X -3091(change)X -3342(the)X -3463(editor's)X -3731(behavior.)X -776 1161(This)N -938(section)X -1185(describes)X -1504(the)X -1622(options,)X -1897(their)X -2064(abbreviations)X -2516(and)X -2652(their)X -2819(default)X -3062(values.)X -976 1284(In)N -1064(each)X -1233(entry)X -1419(below,)X -1656(the)X -1775(\256rst)X -1920(part)X -2066(of)X -2154(the)X -2273(tag)X -2392(line)X -2533(is)X -2607(the)X -2726(full)X -2858(name)X -3053(of)X -3141(the)X -3261(option,)X -3507(followed)X -3814(by)X -3916(any)X -776 1374(equivalent)N -1135(abbreviations.)X -1632(\(Regardless)X -2036(of)X -2128(the)X -2251(abbreviations,)X -2728(it)X -2797(is)X -2875(only)X -3042(necessary)X -3380(to)X -3467(use)X -3599(the)X -3722(minimum)X -776 1464(number)N -1047(of)X -1140(characters)X -1493(necessary)X -1832(to)X -1920(distinguish)X -2296(an)X -2398(abbreviation)X -2825(from)X -3007(all)X -3113(other)X -3304(commands)X -3677(for)X -3797(it)X -3867(to)X -3956(be)X -776 1554(accepted,)N -1099(in)X -3 f -1182(nex)X -1 f -(/)S -3 f -1324(nvi)X -1 f -1430(.)X -1491(Historically,)X -1910(only)X -2073(the)X -2192(full)X -2324(name)X -2519(and)X -2656(the)X -2774(of\256cial)X -3021(abbreviations)X -3473(were)X -3650(accepted)X -3952(by)X -3 f -776 1644(ex)N -1 f -852(/)X -3 f -874(vi)X -1 f -936(.)X -1002(Using)X -1220(full)X -1358(names)X -1590(in)X -1679(your)X -1853(startup)X -2098(\256les)X -2258(and)X -2401(environmental)X -2891(variables)X -3208(will)X -3359(probably)X -3671(make)X -3872(them)X -776 1734(more)N -968(portable.\))X -1325(The)X -1477(part)X -1629(in)X -1718(square)X -1955(brackets)X -2250(is)X -2330(the)X -2454(default)X -2703(value)X -2903(of)X -2996(the)X -3120(option.)X -3390(Most)X -3580(of)X -3673(the)X -3797(options)X -776 1824(are)N -895(boolean,)X -1189(i.e.)X -1307(they)X -1465(are)X -1584(either)X -1787(on)X -1887(or)X -1974(off,)X -2108(and)X -2244(do)X -2344(not)X -2466(have)X -2638(an)X -2734(associated)X -3084(value.)X -976 1947(Options)N -1249(apply)X -1447(to)X -1529(both)X -3 f -1691(ex)X -1 f -1787(and)X -3 f -1923(vi)X -1 f -2005(modes,)X -2254(unless)X -2474(otherwise)X -2806(speci\256ed.)X -976 2070(For)N -1107(information)X -1505(on)X -1605(modifying)X -1958(the)X -2076(options)X -2331(or)X -2419(to)X -2502(display)X -2754(the)X -2873(options)X -3129(and)X -3266(their)X -3434(current)X -3683(values,)X -3929(see)X -776 2160(the)N -894(``set'')X -1111(command)X -1447(in)X -1529(the)X -1647(section)X -1894(entitled)X -2154(``)X -3 f -2208(Ex)X -2321(Commands)X -1 f -2712(''.)X -3 f -776 2340(altwerase)N -1122([off])X -976 2430(Vi)N -1 f -1084(only.)X -1295(Change)X -1569(how)X -3 f -1736(vi)X -1 f -1827(does)X -2003(word)X -2197(erase)X -2392(during)X -2630(text)X -2779(input.)X -3012(When)X -3233(this)X -3377(option)X -3610(is)X -3692(set,)X -3830(text)X -3979(is)X -976 2520(broken)N -1230(up)X -1340(into)X -1494(three)X -1685(classes:)X -1960(alphabetic,)X -2340(numeric)X -2633(and)X -2779(underscore)X -3162(characters,)X -3539(other)X -3734(nonblank)X -976 2610(characters,)N -1343(and)X -1479(blank)X -1677(characters.)X -2064(Changing)X -2395(from)X -2571(one)X -2707(class)X -2884(to)X -2967(another)X -3229(marks)X -3446(the)X -3565(end)X -3702(of)X -3790(a)X -3847(word.)X -976 2700(In)N -1070(addition,)X -1379(the)X -1504(class)X -1687(of)X -1781(the)X -1906(\256rst)X -2057(character)X -2380(erased)X -2612(is)X -2691(ignored)X -2962(\(which)X -3211(is)X -3290(exactly)X -3548(what)X -3730(you)X -3876(want)X -976 2790(when)N -1170(erasing)X -1422(pathname)X -1754(components\).)X -3 f -776 2970(autoindent,)N -1184(ai)X -1266([off])X -1 f -976 3060(If)N -1052(this)X -1189(option)X -1415(is)X -1490(set,)X -1621(whenever)X -1956(you)X -2098(create)X -2313(a)X -2371(new)X -2527(line)X -2669(\(using)X -2891(the)X -3 f -3012(vi)X -3097(A)X -1 f -3155(,)X -3 f -3198(a)X -1 f -(,)S -3 f -3281(C)X -1 f -3339(,)X -3 f -3382(c)X -1 f -3418(,)X -3 f -3461(I)X -1 f -3492(,)X -3 f -3535(i)X -1 f -3557(,)X -3 f -3600(O)X -1 f -3662(,)X -3 f -3705(o)X -1 f -(,)S -3 f -3788(R)X -1 f -3846(,)X -3 f -3889(r)X -1 f -3925(,)X -3 f -3968(S)X -1 f -4012(,)X -976 3150(and)N -3 f -1117(s)X -1 f -1173(commands,)X -1565(or)X -1657(the)X -3 f -1780(ex)X -1881(append)X -1 f -2133(,)X -3 f -2178(change)X -1 f -(,)S -2463(and)X -3 f -2604(insert)X -1 f -2825(commands\))X -3224(the)X -3346(new)X -3504(line)X -3648(is)X -3725(automati-)X -976 3240(cally)N -1156(indented)X -1456(to)X -1542(align)X -1726(the)X -1848(cursor)X -2073(with)X -2239(the)X -2361(\256rst)X -2509(nonblank)X -2831(character)X -3151(of)X -3242(the)X -3365(line)X -3510(from)X -3691(which)X -3912(you)X -976 3330(created)N -1231(it.)X -1337(Lines)X -1537(are)X -1658(indented)X -1956(using)X -2150(tab)X -2269(characters)X -2617(to)X -2700(the)X -2819(extent)X -3036(possible)X -3319(\(based)X -3550(on)X -3651(the)X -3770(value)X -3965(of)X -976 3420(the)N -3 f -1094(tabstop)X -1 f -1367(option\))X -1618(and)X -1754(then)X -1912(using)X -2105(space)X -2304(characters)X -2651(as)X -2738(necessary.)X -3111(For)X -3243(commands)X -3611(inserting)X -3912(text)X -976 3510(into)N -1124(the)X -1246(middle)X -1492(of)X -1583(a)X -1643(line,)X -1807(any)X -1947(blank)X -2149(characters)X -2500(to)X -2586(the)X -2708(right)X -2883(of)X -2974(the)X -3096(cursor)X -3321(are)X -3444(discarded,)X -3795(and)X -3934(the)X -976 3600(\256rst)N -1120(nonblank)X -1438(character)X -1754(to)X -1836(the)X -1954(right)X -2125(of)X -2212(the)X -2330(cursor)X -2551(is)X -2624(aligned)X -2880(as)X -2967(described)X -3295(above.)X -976 3780(The)N -1128(indent)X -1355(characters)X -1709(are)X -1835(themselves)X -2218(somewhat)X -2570(special.)X -2860(If)X -2941(you)X -3088(do)X -3195(not)X -3324(enter)X -3512(more)X -3705(characters)X -976 3870(on)N -1085(the)X -1212(new)X -1375(line)X -1524(before)X -1759(moving)X -2032(to)X -2123(another)X -2393(line,)X -2562(or)X -2658(entering)X -7 f -2950()X -1 f -(,)S -3382(the)X -3508(indent)X -3736(character)X -976 3960(will)N -1121(be)X -1218(deleted)X -1471(and)X -1608(the)X -1727(line)X -1868(will)X -2013(be)X -2111(empty.)X -2373(For)X -2506(example,)X -2820(if)X -2891(you)X -3033(enter)X -7 f -3216()X -1 f -976 4050(twice)N -1181(in)X -1274(succession,)X -1668(the)X -1797(line)X -1947(created)X -2210(by)X -2320(the)X -2448(\256rst)X -7 f -2602()X -1 f -3448(will)X -3602(not)X -3734(have)X -3916(any)X -976 4140(characters)N -1323(in)X -1405(it,)X -1489(regardless)X -1835(of)X -1922(the)X -2040(indentation)X -2420(of)X -2507(the)X -2625(previous)X -2921(or)X -3008(subsequent)X -3384(line.)X -976 4320(Indent)N -1210(characters)X -1566(also)X -1725(require)X -1983(that)X -2133(you)X -2283(enter)X -2474(additional)X -2824(erase)X -3020(characters)X -3377(to)X -3469(delete)X -3691(them.)X -3921(For)X -976 4410(example,)N -1290(if)X -1361(you)X -1503(have)X -1677(an)X -1775(indented)X -2072(line,)X -2233(containing)X -2592(only)X -2755(blanks,)X -3005(the)X -3124(\256rst)X -7 f -3269()X -1 f -3866(char-)X -976 4500(acter)N -1156(you)X -1299(enter)X -1483(will)X -1630(erase)X -1819(up)X -1922(to)X -2007(end)X -2146(of)X -2236(the)X -2357(indent)X -2580(characters,)X -2950(and)X -3089(the)X -3210(second)X -3456(will)X -3604(erase)X -3794(back)X -3970(to)X -976 4590(the)N -1094(beginning)X -1434(of)X -1521(the)X -1639(line.)X -1819(\(Historically,)X -2264(only)X -2426(the)X -3 f -2544()X -1 f -2986(key)X -3122(would)X -3342(erase)X -3528(the)X -3646(indent)X -3866(char-)X -976 4680(acters.)N -1231(Both)X -1413(the)X -3 f -1538()X -1 f -1988(key)X -2132(and)X -2276(the)X -2402(usual)X -2599(erase)X -2793(keys)X -2968(work)X -3161(in)X -3 f -3251(nvi)X -1 f -3357(.\))X -3452(In)X -3547(addition,)X -3857(if)X -3934(the)X -976 4770(cursor)N -1211(is)X -1298(positioned)X -1665(at)X -1756(the)X -1887(end)X -2036(of)X -2136(the)X -2267(indent)X -2500(characters,)X -2880(the)X -3011(keys)X -3191(``)X -7 f -3245(0)X -1 f -('')S -3908(will)X -976 4860(erase)N -1163(all)X -1264(of)X -1352(the)X -1472(indent)X -1694(characters)X -2043(for)X -2159(the)X -2279(current)X -2529(line,)X -2691(resetting)X -2989(the)X -3109(indentation)X -3491(level)X -3669(to)X -3753(0.)X -3855(Simi-)X -976 4950(larly,)N -1168(the)X -1291(keys)X -1462(``)X -7 f -1516(\303)X -1 f -('')S -2170(will)X -2318(erase)X -2508(all)X -2612(of)X -2703(the)X -2825(indent)X -3049(characters)X -3400(for)X -3518(the)X -3640(current)X -3892(line,)X -976 5040(leaving)N -1232(the)X -1350(indentation)X -1730(level)X -1906(for)X -2020(future)X -2232(created)X -2485(lines)X -2656(unaffected.)X -976 5220(Finally,)N -1243(if)X -1313(the)X -3 f -1432(autoindent)X -1 f -1821(option)X -2047(is)X -2122(set,)X -2253(the)X -3 f -2373(S)X -1 f -2439(and)X -3 f -2577(cc)X -1 f -2671(commands)X -3040(change)X -3290(from)X -3468(the)X -3588(\256rst)X -3734(nonblank)X -976 5310(of)N -1063(the)X -1181(line)X -1321(to)X -1403(the)X -1521(end)X -1657(of)X -1744(the)X -1862(line,)X -2022(instead)X -2269(of)X -2356(from)X -2532(the)X -2650(beginning)X -2990(of)X -3077(the)X -3195(line)X -3335(to)X -3417(the)X -3535(end)X -3671(of)X -3758(the)X -3876(line.)X -3 f -776 5490(autoprint,)N -1140(ap)X -1244([off])X -976 5580(Ex)N -1 f -1099(only.)X -1311(Cause)X -1537(the)X -1665(current)X -1923(line)X -2073(to)X -2165(be)X -2271(automatically)X -2738(displayed)X -3076(after)X -3255(the)X -3 f -3384(ex)X -1 f -3491(commands)X -3 f -3869(<)X -1 f -3915(,)X -3 f -3966(>)X -1 f -4012(,)X -3 f -976 5670(copy)N -1 f -(,)S -3 f -1176(delete)X -1 f -1377(,)X -3 f -1417(join)X -1 f -1550(,)X -3 f -1590(move)X -1 f -1773(,)X -3 f -1813(put)X -1 f -1928(,)X -3 f -1968(t)X -1 f -1995(,)X -3 f -2035(Undo)X -1 f -2221(,)X -2261(and)X -3 f -2397(undo)X -1 f -2569(.)X -2629(This)X -2791(automatic)X -3127(display)X -3378(is)X -3451(suppressed)X -3823(during)X -3 f -976 5760(global)N -1 f -1226(and)X -3 f -1384(vglobal)X -1 f -1675(commands,)X -2085(and)X -2244(for)X -2381(any)X -2540(command)X -2899(where)X -3139(optional)X -3444(\257ags)X -3638(are)X -3780(used)X -3970(to)X - -47 p -%%Page: 47 46 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -3658(USD:13-47)X -1 f -976 762(explicitly)N -1298(display)X -1549(the)X -1667(line.)X -3 f -776 942(autowrite,)N -1146(aw)X -1264([off])X -1 f -976 1032(If)N -1053(this)X -1191(option)X -1418(is)X -1494(set,)X -1626(the)X -3 f -1747(vi)X -1832(!)X -1 f -1859(,)X -3 f -1902(\303\303)X -1 f -1956(,)X -3 f -1999(\303])X -1 f -2076(and)X -3 f -2215()X -1 f -2655(commands,)X -3046(and)X -3186(the)X -3 f -3308(ex)X -3408(edit)X -1 f -3537(,)X -3 f -3581(next)X -1 f -3728(,)X -3 f -3772(rewind)X -1 f -(,)S -3 f -976 1122(stop)N -1 f -1118(,)X -3 f -1161(suspend)X -1 f -1435(,)X -3 f -1478(tag)X -1 f -1585(,)X -3 f -1628(tagpop)X -1 f -1863(,)X -1906(and)X -3 f -2045(tagtop)X -1 f -2286(commands)X -2656(automatically)X -3115(write)X -3302(the)X -3422(current)X -3672(\256le)X -3796(back)X -3970(to)X -976 1212(the)N -1103(current)X -1360(\256le)X -1491(name)X -1694(if)X -1772(it)X -1845(has)X -1981(been)X -2163(modi\256ed)X -2477(since)X -2672(it)X -2746(was)X -2901(last)X -3042(written.)X -3339(If)X -3423(the)X -3551(write)X -3746(fails,)X -3934(the)X -976 1302(command)N -1312(fails)X -1470(and)X -1606(goes)X -1773(no)X -1873(further.)X -976 1482(Appending)N -1363(the)X -1492(optional)X -1785(force)X -1982(\257ag)X -2133(character)X -2460(``)X -7 f -2514(!)X -1 f -('')S -2668(to)X -2762(the)X -3 f -2892(ex)X -1 f -3000(commands)X -3 f -3379(next)X -1 f -3526(,)X -3 f -3578(rewind)X -1 f -(,)S -3 f -3870(stop)X -1 f -4012(,)X -3 f -976 1572(suspend)N -1 f -1250(,)X -3 f -1290(tag)X -1 f -1397(,)X -3 f -1437(tagpop)X -1 f -1672(,)X -1712(and)X -3 f -1848(tagtop)X -1 f -2086(stops)X -2270(the)X -2388(automatic)X -2724(write)X -2909(from)X -3085(being)X -3283(attempted.)X -976 1752(\(Historically,)N -1421(the)X -3 f -1539(next)X -1 f -1706(command)X -2042(ignored)X -2307(the)X -2425(optional)X -2707(force)X -2894(\257ag.\))X -3102(Note,)X -3299(the)X -3 f -3418(ex)X -1 f -3515(commands)X -3 f -3883(edit)X -1 f -4012(,)X -3 f -976 1842(quit)N -1 f -1113(,)X -3 f -1153(shell)X -1 f -1308(,)X -1348(and)X -3 f -1484(xit)X -1 f -1593(are)X -2 f -1712(not)X -1 f -1834(affected)X -2114(by)X -2214(the)X -3 f -2332(autowrite)X -1 f -2682(option.)X -3 f -776 2022(beautify,)N -1096(bf)X -1187([off])X -1 f -976 2112(If)N -1061(this)X -1207(option)X -1442(is)X -1527(set,)X -1668(all)X -1780(control)X -2039(characters)X -2398(that)X -2550(are)X -2681(not)X -2815(currently)X -3137(being)X -3347(specially)X -3664(interpreted,)X -976 2202(other)N -1166(than)X -7 f -1329()X -1 f -(,)S -7 f -1613()X -1 f -(,)S -2089(and)X -7 f -2229()X -1 f -(,)S -2801(are)X -2924(discarded)X -3256(from)X -3436(commands)X -3807(read)X -3970(in)X -976 2292(by)N -3 f -1078(ex)X -1 f -1176(from)X -1354(command)X -1692(\256les,)X -1867(and)X -2005(from)X -2183(input)X -2369(text)X -2511(entered)X -2770(to)X -3 f -2854(vi)X -1 f -2938(\(either)X -3170(into)X -3316(the)X -3436(\256le)X -3560(or)X -3649(to)X -3733(the)X -3854(colon)X -976 2382(command)N -1312(line\).)X -1519(Text)X -1686(\256les)X -1839(read)X -1998(by)X -3 f -2098(ex)X -1 f -2174(/)X -3 f -2196(vi)X -1 f -2278(are)X -2 f -2397(not)X -1 f -2519(affected)X -2799(by)X -2899(the)X -3 f -3017(beautify)X -1 f -3317(option.)X -3 f -776 2562(cdpath)N -1031([environment)X -1514(variable)X -1814(CDPATH,)X -2192(or)X -2288(current)X -2567(directory])X -1 f -976 2652(This)N -1152(option)X -1390(is)X -1477(used)X -1658(to)X -1754(specify)X -2020(a)X -2090(colon)X -2302(separated)X -2640(list)X -2771(of)X -2872(directories)X -3245(which)X -3476(are)X -3610(used)X -3792(as)X -3894(path)X -976 2742(pre\256xes)N -1252(for)X -1368(any)X -1506(relative)X -1769(path)X -1929(names)X -2156(used)X -2325(as)X -2414(arguments)X -2770(for)X -2886(the)X -3 f -3006(cd)X -1 f -3108(command.)X -3486(The)X -3633(value)X -3829(of)X -3917(this)X -976 2832(option)N -1202(defaults)X -1478(to)X -1562(the)X -1682(value)X -1878(of)X -1967(the)X -2088(environmental)X -2574(variable)X -7 f -2856(CDPATH)X -1 f -3167(if)X -3239(it)X -3306(is)X -3382(set,)X -3514(otherwise)X -3849(to)X -3934(the)X -976 2922(current)N -1232(directory.)X -1590(For)X -1729(compatibility)X -2183(with)X -2353(the)X -2478(POSIX)X -2736(1003.2)X -2983(shell,)X -3181(the)X -3 f -3306(cd)X -1 f -3413(command)X -3756(does)X -2 f -3930(not)X -1 f -976 3012(check)N -1200(the)X -1334(current)X -1598(directory)X -1924(as)X -2027(a)X -2099(path)X -2273(pre\256x)X -2496(for)X -2627(relative)X -2905(path)X -3080(names)X -3322(unless)X -3559(it)X -3640(is)X -3730(explicitly)X -976 3102(speci\256ed.)N -1334(It)X -1416(may)X -1586(be)X -1694(so)X -1797(speci\256ed)X -2114(by)X -2226(entering)X -2521(an)X -2629(empty)X -2861(string)X -3075(or)X -3174(a)X -3242(``)X -7 f -3296(.)X -1 f -('')S -3450(character)X -3778(into)X -3934(the)X -7 f -976 3192(CDPATH)N -1 f -1284(variable)X -1563(or)X -1650(the)X -1768(option)X -1992(value.)X -3 f -776 3372(columns,)N -1100(co)X -1196([80])X -1 f -976 3462(The)N -1132(number)X -1408(of)X -1506(columns)X -1808(in)X -1901(the)X -2030(screen.)X -2307(Setting)X -2565(this)X -2712(option)X -2948(causes)X -3 f -3190(ex)X -1 f -3266(/)X -3 f -3288(vi)X -1 f -3382(to)X -3476(set)X -3597(\(or)X -3723(reset\))X -3934(the)X -976 3552(environmental)N -1464(variable)X -7 f -1748(COLUMNS)X -1 f -(.)S -2149(See)X -2290(the)X -2413(section)X -2665(entitled)X -2930(``)X -3 f -2984(Sizing)X -3217(the)X -3349(Screen)X -1 f -3581('')X -3660(more)X -3849(infor-)X -976 3642(mation.)N -3 f -776 3822(comment)N -1113([off])X -976 3912(Vi)N -1 f -1079(only.)X -1284(If)X -1361(the)X -1482(\256rst)X -1629(non-empty)X -1999(line)X -2142(of)X -2232(the)X -2354(\256le)X -2480(begins)X -2713(with)X -2879(the)X -3001(string)X -3207(``)X -7 f -3261(/*)X -1 f -('',)S -3455(this)X -3594(option)X -3822(causes)X -3 f -976 4002(vi)N -1 f -1072(to)X -1167(skip)X -1333(to)X -1428(the)X -1559(end)X -1708(of)X -1808(that)X -1961(C-language)X -2364(comment)X -2695(\(probably)X -3040(a)X -3109(terribly)X -3378(boring)X -3620(legal)X -3809(notice\))X -976 4092(before)N -1202(displaying)X -1555(the)X -1673(\256le.)X -3 f -776 4272(directory,)N -1133(dir)X -1255([environment)X -1738(variable)X -2038(TMPDIR,)X -2403(or)X -2499(/tmp])X -1 f -976 4362(The)N -1123(directory)X -1435(where)X -1655(temporary)X -2008(\256les)X -2164(are)X -2286(created.)X -2582(The)X -2730(environmental)X -3216(variable)X -7 f -3498(TMPDIR)X -1 f -3809(is)X -3885(used)X -976 4452(as)N -1063(the)X -1181(default)X -1424(value)X -1618(if)X -1687(it)X -1751(exists,)X -1973(otherwise)X -7 f -2305(/tmp)X -1 f -2517(is)X -2590(used.)X -3 f -776 4632(edcompatible,)N -1274(ed)X -1374([off])X -1 f -976 4722(Remember)N -1349(the)X -1468(values)X -1694(of)X -1782(the)X -1901(``c'')X -2066(and)X -2203(``g'')X -2372(suf\256ces)X -2638(to)X -2721(the)X -3 f -2840(substitute)X -1 f -3194(commands,)X -3583(instead)X -3832(of)X -3921(ini-)X -976 4812(tializing)N -1262(them)X -1446(as)X -1537(unset)X -1730(for)X -1848(each)X -2020(new)X -2178(command.)X -2558(Specifying)X -2929(pattern)X -3176(and)X -3316(replacement)X -3733(strings)X -3970(to)X -976 4902(the)N -3 f -1094(substitute)X -1 f -1447(command)X -1783(unsets)X -2003(the)X -2121(``c'')X -2285(and)X -2421(``g'')X -2589(suf\256ces)X -2854(as)X -2941(well.)X -3 f -776 5082(errorbells,)N -1155(eb)X -1255([off])X -976 5172(Ex)N -1 f -1089(only.)X -3 f -1292(Ex)X -1 f -1406(error)X -1584(messages)X -1908(are)X -2028(normally)X -2338(presented)X -2667(in)X -2750(inverse)X -3003(video.)X -3242(If)X -3317(that)X -3458(is)X -3532(not)X -3655(possible)X -3938(for)X -976 5262(the)N -1096(terminal,)X -1405(setting)X -1640(this)X -1777(option)X -2003(causes)X -2235(error)X -2414(messages)X -2739(to)X -2823(be)X -2921(announced)X -3291(by)X -3393(ringing)X -3646(the)X -3765(terminal)X -976 5352(bell.)N -3 f -776 5532(exrc,)N -964(ex)X -1060([off])X -1 f -976 5622(If)N -1061(this)X -1207(option)X -1442(is)X -1526(turned)X -1762(off)X -1887(in)X -1980(the)X -2109(system)X -2362(or)X -2460($HOME)X -2767(startup)X -3016(\256les,)X -3200(the)X -3330(local)X -3518(startup)X -3768(\256les)X -3933(are)X -976 5712(never)N -1177(read)X -1338(\(unless)X -1587(they)X -1747(are)X -1868(the)X -1988(same)X -2175(as)X -2264(the)X -2384(system)X -2628(or)X -2717($HOME)X -3015(startup)X -3255(\256les\).)X -3477(Turning)X -3757(it)X -3823(on)X -3925(has)X -976 5802(no)N -1091(effect,)X -1330(i.e.)X -1463(the)X -1596(normal)X -1858(checks)X -2112(for)X -2241(local)X -2432(startup)X -2685(\256les)X -2854(are)X -2989(performed,)X -3380(regardless.)X -3782(See)X -3934(the)X - -48 p -%%Page: 48 47 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-48)N -3391(Nvi/Nex)X -3687 0.3906(Reference)AX -1 f -976 762(section)N -1223(entitled)X -1483(``)X -3 f -1537(Startup)X -1819(Information)X -1 f -2237('')X -2311(for)X -2425(more)X -2610(information.)X -3 f -776 942(extended)N -1103([off])X -1 f -976 1032(This)N -1147(option)X -1380(causes)X -1619(all)X -1728(regular)X -1986(expressions)X -2390(to)X -2482(be)X -2588(treated)X -2837(as)X -2934(POSIX)X -3195(1003.2)X -3445(Extended)X -3778(Regular)X -976 1122(Expressions)N -1383(\(which)X -1626(are)X -1745(similar)X -1987(to)X -2069(historic)X -2 f -2329(egrep)X -1 f -2512(\(1\))X -2626(style)X -2797(expressions\).)X -3 f -776 1302(\257ash)N -955([on])X -1 f -976 1392(This)N -1139(option)X -1364(causes)X -1595(the)X -1714(screen)X -1941(to)X -2025(\257ash)X -2198(instead)X -2447(of)X -2536(beeping)X -2812(the)X -2932(keyboard,)X -3273(on)X -3375(error,)X -3574(if)X -3645(the)X -3765(terminal)X -976 1482(has)N -1103(the)X -1221(capability.)X -3 f -776 1662(hardtabs,)N -1122(ht)X -1213([8])X -1 f -976 1752(This)N -1141(option)X -1369(de\256nes)X -1620(the)X -1742(spacing)X -2011(between)X -2303(hardware)X -2627(tab)X -2749(settings,)X -3037(i.e.)X -3179(the)X -3301(tab)X -3423(expansion)X -3772(done)X -3952(by)X -976 1842(the)N -1099(operating)X -1427(system)X -1674(and/or)X -1904(the)X -2027(terminal)X -2319(itself.)X -2544(As)X -3 f -2658(nex)X -1 f -(/)S -3 f -2800(nvi)X -1 f -2931(never)X -3135(writes)X -7 f -3355()X -1 f -3619(characters)X -3970(to)X -976 1932(the)N -1094(terminal,)X -1401(unlike)X -1621(historic)X -1881(versions)X -2168(of)X -3 f -2255(ex)X -1 f -2331(/)X -3 f -2353(vi)X -1 f -2415(,)X -2455(this)X -2590(option)X -2814(does)X -2981(not)X -3103(currently)X -3413(have)X -3585(any)X -3721(affect.)X -3 f -776 2112(ignorecase,)N -1177(ic)X -1255([off])X -1 f -976 2202(This)N -1141(option)X -1368(causes)X -1602(regular)X -1854(expressions,)X -2272(both)X -2438(in)X -3 f -2524(ex)X -1 f -2624(commands)X -2995(and)X -3135(in)X -3221(searches,)X -3538(to)X -3624(be)X -3724(evaluated)X -976 2292(in)N -1058(a)X -1114(case-insensitive)X -1642(manner.)X -3 f -776 2472(keytime)N -1068([6])X -1 f -976 2562(The)N -1121(10th's)X -1341(of)X -1428(a)X -1484(second)X -3 f -1727(ex)X -1 f -1803(/)X -3 f -1825(vi)X -1 f -1907(waits)X -2096(for)X -2210(a)X -2266(subsequent)X -2642(key)X -2778(to)X -2860(complete)X -3174(a)X -3230(key)X -3366(mapping.)X -3 f -776 2742(leftright)N -1077([off])X -976 2832(Vi)N -1 f -1083(only.)X -1293(This)X -1463(option)X -1695(causes)X -1933(the)X -2059(screen)X -2293(to)X -2383(be)X -2487(scrolled)X -2769(left-right)X -3082(to)X -3172(view)X -3356(lines)X -3535(longer)X -3768(than)X -3934(the)X -976 2922(screen,)N -1232(instead)X -1489(of)X -1586(the)X -1714(traditional)X -3 f -2073(vi)X -1 f -2165(screen)X -2401(interface)X -2713(which)X -2939(folds)X -3129(long)X -3301(lines)X -3482(at)X -3570(the)X -3698(right-hand)X -976 3012(margin)N -1223(of)X -1310(the)X -1428(terminal.)X -3 f -776 3192(lines,)N -971(li)X -1035([24])X -976 3282(Vi)N -1 f -1076(only.)X -1278(The)X -1423(number)X -1688(of)X -1775(lines)X -1946(in)X -2028(the)X -2146(screen.)X -2412(Setting)X -2658(this)X -2793(option)X -3017(causes)X -3 f -3247(ex)X -1 f -3323(/)X -3 f -3345(vi)X -1 f -3427(to)X -3509(set)X -3619(\(or)X -3734(reset\))X -3934(the)X -976 3372(environmental)N -1462(variable)X -7 f -1744(LINES)X -1 f -(.)S -2047(See)X -2186(the)X -2307(section)X -2557(entitled)X -2820(``)X -3 f -2874(Sizing)X -3105(the)X -3235(Screen)X -1 f -3467('')X -3544(for)X -3661(more)X -3849(infor-)X -976 3462(mation.)N -3 f -776 3642(lisp)N -915([off])X -976 3732(Vi)N -1 f -1078(only.)X -1282(This)X -1447(option)X -1674(changes)X -1956(the)X -2077(behavior)X -2381(of)X -2471(the)X -3 f -2592(vi)X -2677(\()X -1 f -2704(,)X -3 f -2747(\))X -1 f -2774(,)X -3 f -2817({)X -1 f -2849(,)X -3 f -2892(})X -1 f -2924(,)X -3 f -2967([[)X -1 f -3044(and)X -3 f -3183(]])X -1 f -3260(commands)X -3630(to)X -3715(match)X -3934(the)X -976 3822(Lisp)N -1138(language.)X -1488(Also,)X -1679(the)X -3 f -1797(autoindent)X -1 f -2185(option's)X -2467(behavior)X -2768(is)X -2841(changed)X -3129(to)X -3211(be)X -3307(appropriate)X -3693(for)X -3807(Lisp.)X -2 f -976 4002(This)N -1133(option)X -1357(is)X -1430(not)X -1552(yet)X -1666(implemented.)X -3 f -776 4182(list)N -898([off])X -1 f -976 4272(This)N -1151(option)X -1388(causes)X -1631(lines)X -1815(to)X -1910(be)X -2019(displayed)X -2359(in)X -2454(an)X -2563(unambiguous)X -3028(fashion.)X -3338(Speci\256cally,)X -3770(tabs)X -3933(are)X -976 4362(displayed)N -1305(as)X -1394(control)X -1643(characters,)X -2012(i.e.)X -2152(``)X -7 f -2206(\303I)X -1 f -('',)S -2398(and)X -2536(the)X -2656(ends)X -2825(of)X -2914(lines)X -3087(are)X -3207(marked)X -3469(with)X -3632(a)X -3689(``)X -7 f -3743($)X -1 f -('')S -3866(char-)X -976 4452(acter.)N -3 f -776 4632(magic)N -1001([on])X -1 f -976 4722(This)N -1141(option)X -1368(is)X -1444(on)X -1547(by)X -1650(default.)X -1936(Turning)X -2217(the)X -3 f -2338(magic)X -1 f -2566(option)X -2793(off)X -2910(causes)X -3143(all)X -3247(regular)X -3499(expression)X -3866(char-)X -976 4812(acters)N -1189(except)X -1423(for)X -1541(``)X -7 f -1595(\303)X -1 f -('')S -1721(and)X -1861(``)X -7 f -1915($)X -1 f -('',)S -2061(to)X -2147(be)X -2247(treated)X -2490(as)X -2581(ordinary)X -2877(characters.)X -3268(To)X -3381(re-enable)X -3705(characters)X -976 4902(individually,)N -1402(when)X -1597(the)X -3 f -1716(magic)X -1 f -1942(option)X -2167(is)X -2241(off,)X -2376(precede)X -2648(them)X -2829(with)X -2992(a)X -3049(backslash)X -3382(``)X -7 f -3436(\\)X -1 f -('')S -3559(character.)X -3916(See)X -976 4992(the)N -1094(section)X -1341(entitled)X -1601(``)X -3 f -1655(Regular)X -1951(Expressions)X -2379(and)X -2527(Replacement)X -2993(Strings)X -1 f -3237('')X -3311(for)X -3425(more)X -3610(information.)X -3 f -776 5172(matchtime)N -1162([7])X -976 5262(Vi)N -1 f -1078(only.)X -1282(The)X -1429(10th's)X -1651(of)X -1740(a)X -1798(second)X -3 f -2043(ex)X -1 f -2119(/)X -3 f -2141(vi)X -1 f -2226(pauses)X -2463(on)X -2566(the)X -2687(matching)X -3008(character)X -3327(when)X -3524(the)X -3 f -3645(showmatch)X -1 f -976 5352(option)N -1200(is)X -1273(set.)X -3 f -776 5532(mesg)N -970([on])X -1 f -976 5622(This)N -1140(option)X -1366(allows)X -1597(other)X -1784(users)X -1972(to)X -2057(contact)X -2312(you)X -2455(using)X -2651(the)X -2 f -2772(talk)X -1 f -(\(1\))S -3009(and)X -2 f -3148(write)X -1 f -3312(\(1\))X -3429(utilities,)X -3711(while)X -3912(you)X -976 5712(are)N -1101(editing.)X -3 f -1389(Ex)X -1 f -1482(/)X -3 f -1504(vi)X -1 f -1592(does)X -1764(not)X -1891(turn)X -2045(message)X -2342(on,)X -2467(i.e.)X -2590(if)X -2664(messages)X -2992(were)X -3174(turned)X -3404(off)X -3523(when)X -3722(the)X -3845(editor)X -976 5802(was)N -1124(invoked,)X -1425(they)X -1586(will)X -1733(stay)X -1885(turned)X -2113(off.)X -2270(This)X -2435(option)X -2662(only)X -2827(permits)X -3090(you)X -3233(to)X -3318(disallow)X -3612(messages)X -3938(for)X - -49 p -%%Page: 49 48 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -3658(USD:13-49)X -1 f -976 762(the)N -1094(edit)X -1234(session.)X -1525(See)X -1661(the)X -2 f -1779(mesg)X -1 f -1944(\(1\))X -2058(utility)X -2268(for)X -2382(more)X -2567(information.)X -3 f -776 942(modelines,)N -1158(modeline)X -1489([off])X -1 f -976 1032(If)N -1052(the)X -3 f -1172(modelines)X -1 f -1536(option)X -1762(is)X -1837(set,)X -3 f -1968(ex)X -1 f -2044(/)X -3 f -2066(vi)X -1 f -2150(has)X -2279(historically)X -2661(scanned)X -2942(the)X -3062(\256rst)X -3208(and)X -3346(last)X -3479(\256ve)X -3621(lines)X -3794(of)X -3884(each)X -976 1122(\256le)N -1101(as)X -1191(it)X -1258(is)X -1334(read)X -1496(for)X -1613(editing,)X -1877(looking)X -2143(for)X -2259(any)X -3 f -2397(ex)X -1 f -2495(commands)X -2864(that)X -3006(have)X -3180(been)X -3354(placed)X -3586(in)X -3670(those)X -3861(lines.)X -976 1212(After)N -1167(the)X -1286(startup)X -1525(information)X -1924(has)X -2052(been)X -2225(processed,)X -2583(and)X -2720(before)X -2947(the)X -3066(user)X -3221(starts)X -3411(editing)X -3654(the)X -3773(\256le,)X -3916(any)X -976 1302(commands)N -1343(embedded)X -1693(in)X -1775(the)X -1893(\256le)X -2015(are)X -2134(executed.)X -976 1482(Commands)N -1362(were)X -1541(recognized)X -1916(by)X -2018(the)X -2138(letters)X -2356(``e'')X -2522(or)X -2611(``v'')X -2781(followed)X -3088(by)X -3191(``x'')X -3362(or)X -3452(``i'',)X -3625(at)X -3706(the)X -3827(begin-)X -976 1572(ning)N -1144(of)X -1237(a)X -1299(line)X -1445(or)X -1538(following)X -1875(a)X -1937(tab)X -2061(or)X -2154(space)X -2359(character,)X -2701(and)X -2843(followed)X -3153(by)X -3258(a)X -3319(``:'',)X -3494(an)X -3 f -3595(ex)X -1 f -3696(command,)X -976 1662(and)N -1112(another)X -1373(``:''.)X -976 1842(This)N -1144(option)X -1374(is)X -1453(a)X -1516(security)X -1797(problem)X -2091(of)X -2185(immense)X -2501(proportions,)X -2917(and)X -3060(should)X -3300(not)X -3429(be)X -3532(used)X -3706(under)X -3916(any)X -976 1932(circumstances.)N -2 f -976 2112(This)N -1133(option)X -1357(will)X -1496(never)X -1695(be)X -1791(implemented.)X -3 f -776 2292(number,)N -1087(nu)X -1195([off])X -1 f -976 2382(Precede)N -1251(each)X -1419(line)X -1559(displayed)X -1886(with)X -2048(its)X -2143(current)X -2391(line)X -2531(number.)X -3 f -776 2562(octal)N -961([off])X -1 f -976 2652(Display)N -1245(unknown)X -1563(characters)X -1910(as)X -1997(octal)X -2173(numbers,)X -2489(instead)X -2736(of)X -2823(the)X -2941(default)X -3184(hexadecimal.)X -3 f -776 2832(open)N -960([on])X -976 2922(Ex)N -1 f -1089(only.)X -1291(If)X -1365(this)X -1500(option)X -1724(is)X -1797(not)X -1919(set,)X -2048(the)X -3 f -2166(open)X -1 f -2350(and)X -3 f -2486(visual)X -1 f -2705(commands)X -3072(are)X -3191(disallowed.)X -3 f -776 3102(optimize,)N -1110(opt)X -1241([on])X -976 3192(Vi)N -1 f -1081(only.)X -1288(Throughput)X -1691(of)X -1783(text)X -1929(is)X -2008(expedited)X -2346(by)X -2452(setting)X -2691(the)X -2815(terminal)X -3108(not)X -3236(to)X -3324(do)X -3430(automatic)X -3772(carriage)X -976 3282(returns)N -1222(when)X -1419(printing)X -1695(more)X -1883(than)X -2044(one)X -2183(\(logical\))X -2478(line)X -2621(of)X -2710(output,)X -2956(greatly)X -3201(speeding)X -3508(output)X -3734(on)X -3836(termi-)X -976 3372(nals)N -1125(without)X -1389(addressable)X -1784(cursors)X -2036(when)X -2230(text)X -2370(with)X -2532(leading)X -2788(white)X -2986(space)X -3185(is)X -3258(printed.)X -2 f -976 3552(This)N -1133(option)X -1357(is)X -1430(not)X -1552(yet)X -1666(implemented.)X -3 f -776 3732(paragraphs,)N -1211(para)X -1391([IPLPPPQPP)X -1878 -0.3625(LIpplpipbp])AX -976 3822(Vi)N -1 f -1079(only.)X -1284(De\256ne)X -1521(additional)X -1864(paragraph)X -2209(boundaries)X -2584(for)X -2701(the)X -3 f -2822({)X -1 f -2877(and)X -3 f -3016(})X -1 f -3071(commands.)X -3481(The)X -3629(value)X -3826(of)X -3917(this)X -976 3912(option)N -1200(must)X -1375(be)X -1471(a)X -1527(character)X -1843(string)X -2045(consisting)X -2389(of)X -2476(zero)X -2635(or)X -2722(more)X -2907(character)X -3223(pairs.)X -976 4092(In)N -1070(the)X -1195(text)X -1342(to)X -1431(be)X -1534(edited,)X -1777(the)X -1902(character)X -2226(string)X -7 f -2436(.)X -1 f -(,)S -3492(\(where)X -7 f -3744()N -1 f -1241(is)X -1319(one)X -1460(of)X -1552(the)X -1675(character)X -1996(pairs)X -2177(in)X -2264(the)X -2386(option's)X -2672(value\))X -2897(de\256nes)X -3148(a)X -3208(paragraph)X -3554(boundary.)X -3921(For)X -976 4272(example,)N -1291(if)X -1363(the)X -1484(option)X -1711(were)X -1891(set)X -2003(to)X -7 f -2088(LaA##)X -1 f -(,)S -2708(then)X -2870(all)X -2974(of)X -3065(the)X -3187(following)X -3522(additional)X -3866(para-)X -976 4362(graph)N -1179(boundaries)X -1551(would)X -1771(be)X -1867(recognized:)X -1296 4575(.La)N -1296 4665(.A)N -1296 4755(.##)N -3 f -776 4968(prompt)N -1054([on])X -976 5058(Ex)N -1 f -1090(only.)X -1293(This)X -1456(option)X -1681(causes)X -3 f -1912(ex)X -1 f -2009(to)X -2092(prompt)X -2344(for)X -2459(command)X -2796(input)X -2981(with)X -3144(a)X -3201(``)X -7 f -3255(:)X -1 f -('')S -3378(character;)X -3717(when)X -3913(it)X -3979(is)X -976 5148(not)N -1098(set,)X -1227(no)X -1327(prompt)X -1578(is)X -1651(displayed.)X -3 f -776 5328(readonly,)N -1118(ro)X -1214([off])X -1 f -976 5418(This)N -1138(option)X -1362(causes)X -1592(a)X -1648(force)X -1834(\257ag)X -1974(to)X -2056(be)X -2152(required)X -2440(to)X -2522(attempt)X -2782(to)X -2864(write)X -3049(the)X -3167(\256le)X -3289(back)X -3461(to)X -3543(the)X -3661(original)X -3930(\256le)X -976 5508(name.)N -1215(Setting)X -1466(this)X -1605(option)X -1833(is)X -1910(equivalent)X -2268(to)X -2354(using)X -2551(the)X -3 f -9 f -2673(-)X -2675(-)X -3 f -2719(R)X -1 f -2801(command)X -3141(line)X -3285(option,)X -3533(or)X -3624(editing)X -3870(a)X -3930(\256le)X -976 5598(which)N -1192(lacks)X -1377(write)X -1562(permission.)X - -50 p -%%Page: 50 49 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-50)N -3391(Nvi/Nex)X -3687 0.3906(Reference)AX -776 762(recdir)N -1006([/var/tmp/vi.recover])X -1 f -976 852(The)N -1121(directory)X -1431(where)X -1648(recovery)X -1950(\256les)X -2103(are)X -2222(stored.)X -976 1032(If)N -1051(you)X -1192(change)X -1441(the)X -1561(value)X -1757(of)X -3 f -1846(recdir)X -1 f -2056(,)X -2098(be)X -2196(careful)X -2442(to)X -2526(choose)X -2771(a)X -2829(directory)X -3141(whose)X -3368(contents)X -3657(are)X -3778(not)X -3902(reg-)X -976 1122(ularly)N -1197(deleted.)X -1503(Bad)X -1666(choices)X -1941(include)X -2211(directories)X -2584(in)X -2680(memory)X -2981(based)X -3198(\256lesystems,)X -3607(or)X -7 f -3707(/tmp)X -1 f -(,)S -3952(on)X -976 1212(most)N -1151(systems,)X -1444(as)X -1531(their)X -1698(contents)X -1985(are)X -2104(removed)X -2405(when)X -2599(the)X -2717(machine)X -3009(is)X -3082(rebooted.)X -976 1392(Public)N -1219(directories)X -1597(like)X -7 f -1757(/usr/tmp)X -1 f -2181(and)X -7 f -2337(/var/tmp)X -1 f -2761(are)X -2900(usually)X -3171(safe,)X -3361(although)X -3681(some)X -3890(sites)X -976 1482(periodically)N -1387(prune)X -1598(old)X -1728(\256les)X -1889(from)X -2073(them.)X -2301(There)X -2517(is)X -2598(no)X -2706(requirement)X -3122(that)X -3270(you)X -3418(use)X -3553(a)X -3617(public)X -3844(direc-)X -976 1572(tory,)N -1145(e.g.)X -1281(a)X -1337(sub-directory)X -1785(of)X -1872(your)X -2039(home)X -2237(directory)X -2547(will)X -2691(work)X -2876(\256ne.)X -976 1752(Finally,)N -1248(if)X -1323(you)X -1469(change)X -1723(the)X -1847(value)X -2047(of)X -3 f -2140(recdir)X -1 f -2350(,)X -2396(you)X -2542(must)X -2723(modify)X -2980(the)X -3104(recovery)X -3412(script)X -3617(to)X -3706(operate)X -3970(in)X -976 1842(your)N -1143(chosen)X -1386(recovery)X -1688(area.)X -976 2022(See)N -1112(the)X -1230(section)X -1477(entitled)X -1737(``)X -3 f -1791(Recovery)X -1 f -2113('')X -2187(for)X -2301(further)X -2540(information.)X -3 f -776 2202(redraw,)N -1066(re)X -1158([off])X -976 2292(Vi)N -1 f -1087(only.)X -1301(The)X -1458(editor)X -1677(simulates)X -2011(\(using)X -2243(great)X -2436(amounts)X -2739(of)X -2838(output\),)X -3121(an)X -3229(intelligent)X -3585(terminal)X -3884(on)X -3996(a)X -976 2382(dumb)N -1200(terminal)X -1509(\(e.g.)X -1694(during)X -1945(insertions)X -2297(in)X -3 f -2400(vi)X -1 f -2503(the)X -2642(characters)X -3010(to)X -3113(the)X -3252(right)X -3444(of)X -3552(the)X -3691(cursor)X -3933(are)X -976 2472(refreshed)N -1296(as)X -1383(each)X -1551(input)X -1735(character)X -2051(is)X -2124(typed\).)X -2 f -976 2652(This)N -1133(option)X -1357(is)X -1430(not)X -1552(yet)X -1666(implemented.)X -3 f -776 2832(remap)N -1019([on])X -1 f -976 2922(If)N -1055(this)X -1195(option)X -1424(is)X -1502(set,)X -1636(it)X -1705(is)X -1783(possible)X -2070(to)X -2157(de\256ne)X -2378(macros)X -2635(in)X -2722(terms)X -2926(of)X -3019(other)X -3210(macros.)X -3508(Otherwise,)X -3884(each)X -976 3012(key)N -1121(is)X -1203(only)X -1374(remapped)X -1720(up)X -1829(to)X -1920(one)X -2064(time.)X -2274(For)X -2413(example,)X -2733(if)X -2810(``)X -7 f -2864(A)X -1 f -('')S -2994(is)X -3075(mapped)X -3357(to)X -3447(``)X -7 f -3501(B)X -1 f -('',)S -3651(and)X -3795(``)X -7 f -3849(B)X -1 f -('')S -3979(is)X -976 3102(mapped)N -1251(to)X -1334(``)X -7 f -1388(C)X -1 f -('',)S -1531(The)X -1677(keystroke)X -2010(``)X -7 f -2064(A)X -1 f -('')S -2187(will)X -2332(be)X -2429(mapped)X -2704(to)X -2787(``)X -7 f -2841(C)X -1 f -('')S -2964(if)X -3035(the)X -3 f -3155(remap)X -1 f -3400(option)X -3626(is)X -3701(set,)X -3832(and)X -3970(to)X -976 3192(``)N -7 f -1030(B)X -1 f -('')S -1152(if)X -1221(it)X -1285(is)X -1358(not)X -1480(set.)X -3 f -776 3372(report)N -1015([5])X -1 f -976 3462(Set)N -1103(the)X -1226(threshold)X -1549(of)X -1642(the)X -1766(number)X -2037(of)X -2130(lines)X -2307(that)X -2453(need)X -2631(to)X -2719(be)X -2821(changed)X -3115(or)X -3208(yanked)X -3466(before)X -3698(a)X -3760(message)X -976 3552(will)N -1127(be)X -1230(displayed)X -1564(to)X -1653(the)X -1778(user.)X -1979(For)X -2117(everything)X -2487(but)X -2616(the)X -2741(yank)X -2924(command,)X -3287(the)X -3412(value)X -3613(is)X -3693(the)X -3818(largest)X -976 3642(value)N -1172(about)X -1372(which)X -1590(the)X -1711(editor)X -1921(is)X -1997(silent,)X -2213(i.e.)X -2334(by)X -2437(default,)X -2703(6)X -2766(lines)X -2940(must)X -3118(be)X -3217(deleted)X -3472(before)X -3701(the)X -3822(user)X -3979(is)X -976 3732(noti\256ed.)N -1283(However,)X -1621(if)X -1693(the)X -1814(number)X -2082(of)X -2172(lines)X -2346(yanked)X -2601(is)X -2677(greater)X -2924(than)X -2 f -3085(or)X -3179(equal)X -3380(to)X -1 f -3465(the)X -3586(set)X -3697(value,)X -3913(it)X -3979(is)X -976 3822(reported)N -1264(to)X -1346(the)X -1464(user.)X -3 f -776 4002(ruler)N -970([off])X -976 4092(Vi)N -1 f -1076(only.)X -1278(Display)X -1547(a)X -1603(row/column)X -2010(ruler)X -2182(on)X -2282(the)X -2400(colon)X -2598(command)X -2934(line.)X -3 f -776 4272(scroll,)N -1003(scr)X -1126([window)X -1439(/)X -1481(2])X -1 f -976 4362(Set)N -1098(the)X -1216(number)X -1481(of)X -1568(lines)X -1739(scrolled)X -2013(by)X -2113(the)X -3 f -2231(vi)X -2313()X -1 f -2755(and)X -3 f -2891()X -1 f -3333(commands.)X -976 4542(Historically,)N -1395(the)X -3 f -1514(ex)X -1611(z)X -1 f -1668(command,)X -2025(when)X -2221(speci\256ed)X -2528(without)X -2794(a)X -2852(count,)X -3072(used)X -3241(two)X -3383(times)X -3578(the)X -3698(size)X -3845(of)X -3934(the)X -976 4632(scroll)N -1174(value;)X -1390(the)X -1508(POSIX)X -1759(1003.2)X -1999(standard)X -2291(speci\256ed)X -2596(the)X -2714(window)X -2992(size,)X -3157(which)X -3373(is)X -3446(a)X -3502(better)X -3705(choice.)X -3 f -776 4812(sections,)N -1083(sect)X -1233([NHSHH)X -1568(HUnhsh])X -976 4902(Vi)N -1 f -1076(only.)X -1278(De\256ne)X -1512(additional)X -1852(section)X -2099(boundaries)X -2471(for)X -2585(the)X -3 f -2703([[)X -1 f -2777(and)X -3 f -2913(]])X -1 f -2987(commands.)X -3394(The)X -3 f -3540(sections)X -1 f -3828(option)X -976 4992(should)N -1213(be)X -1313(set)X -1426(to)X -1512(a)X -1572(character)X -1892(string)X -2098(consisting)X -2446(of)X -2537(zero)X -2700(or)X -2791(more)X -2979(character)X -3298(pairs.)X -3517(In)X -3607(the)X -3728(text)X -3871(to)X -3956(be)X -976 5082(edited,)N -1219(the)X -1344(character)X -1667(string)X -7 f -1876(.)X -1 f -(,)S -2932(\(where)X -7 f -3184()X -1 f -3740(is)X -3821(one)X -3965(of)X -976 5172(the)N -1100(character)X -1422(pairs)X -1604(in)X -1692(the)X -1816(option's)X -2104(value\),)X -2351(de\256nes)X -2604(a)X -2666(section)X -2918(boundary)X -3246(in)X -3333(the)X -3456(same)X -3646(manner)X -3912(that)X -3 f -976 5262(paragraph)N -1 f -1360(option)X -1584(boundaries)X -1956(are)X -2075(de\256ned.)X -3 f -776 5442(shell,)N -971(sh)X -1066([environment)X -1549(variable)X -1849(SHELL,)X -2154(or)X -2250(/bin/sh])X -1 f -976 5532(Select)N -1195(the)X -1316(shell)X -1490(used)X -1660(by)X -1763(the)X -1884(editor.)X -2134(The)X -2282(speci\256ed)X -2590(path)X -2751(is)X -2827(the)X -2948(pathname)X -3283(of)X -3373(the)X -3495(shell)X -3670(invoked)X -3952(by)X -976 5622(the)N -3 f -1103(vi)X -1194(!)X -1 f -1270(shell)X -1450(escape)X -1694(command)X -2038(and)X -2182(by)X -2290(the)X -3 f -2416(ex)X -2520(shell)X -1 f -2703(command.)X -3087(This)X -3257(program)X -3557(is)X -3638(also)X -3795(used)X -3970(to)X -976 5712(resolve)N -1228(any)X -1364(shell)X -1535 0.2679(meta-characters)AX -2065(in)X -3 f -2147(ex)X -1 f -2243(commands.)X - -51 p -%%Page: 51 50 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -3658(USD:13-51)X -776 762(shiftwidth,)N -1162(sw)X -1271([8])X -1 f -976 852(Set)N -1098(the)X -1216(autoindent)X -1575(and)X -1712(shift)X -1875(command)X -2212(indentation)X -2593(width.)X -2836(This)X -2999(width)X -3202(is)X -3276(used)X -3444(by)X -3545(the)X -3 f -3664(autoindent)X -1 f -976 942(option)N -1200(and)X -1336(by)X -1436(the)X -3 f -1554(<)X -1 f -1600(,)X -3 f -1640(>)X -1 f -1686(,)X -1726(and)X -3 f -1862(shift)X -1 f -2033(commands.)X -3 f -776 1122(showdirty)N -1138([off])X -976 1212(Vi)N -1 f -1076(only.)X -1278(Display)X -1547(an)X -1643(asterisk)X -1908(on)X -2008(the)X -2126(colon)X -2324(command)X -2660(line)X -2800(if)X -2869(the)X -2987(\256le)X -3109(has)X -3236(been)X -3408(modi\256ed.)X -3 f -776 1392(showmatch,)N -1203(sm)X -1321([off])X -976 1482(Vi)N -1 f -1078(only.)X -1282(This)X -1446(option)X -1673(causes)X -3 f -1906(vi)X -1 f -1968(,)X -2011(when)X -2208(a)X -2267(``)X -7 f -2321(})X -1 f -('')S -2446(or)X -2536(``)X -7 f -2590(\))X -1 f -('')S -2715(is)X -2791(entered,)X -3071(to)X -3156(brie\257y)X -3388(move)X -3589(the)X -3710(cursor)X -3934(the)X -976 1572(matching)N -1294(``)X -7 f -1348({)X -1 f -('')S -1470(or)X -1557(``)X -7 f -1611(\()X -1 f -(''.)S -1773(See)X -1909(the)X -3 f -2027(matchtime)X -1 f -2413(option)X -2637(for)X -2751(more)X -2936(information.)X -3 f -776 1752(showmode)N -1156([off])X -976 1842(Vi)N -1 f -1083(only.)X -1292(This)X -1461(option)X -1693(causes)X -3 f -1931(vi)X -1 f -2021(to)X -2111(display)X -2370(a)X -2434(string)X -2644(identifying)X -3023(the)X -3149(current)X -3405(editor)X -3620(mode)X -3826(on)X -3934(the)X -976 1932(colon)N -1174(command)X -1510(line.)X -3 f -776 2112(sidescroll)N -1116([16])X -976 2202(Vi)N -1 f -1078(only.)X -1282(Sets)X -1437(the)X -1557(number)X -1825(of)X -1915(columns)X -2209(that)X -2352(are)X -2474(shifted)X -2715(to)X -2800(the)X -2921(left)X -3051(or)X -3141(right,)X -3335(when)X -3 f -3532(vi)X -1 f -3617(is)X -3693(doing)X -3898(left-)X -976 2292(right)N -1151(scrolling)X -1455(and)X -1595(the)X -1717(left)X -1848(or)X -1939(right)X -2114(margin)X -2365(is)X -2442(crossed.)X -2747(See)X -2887(the)X -3 f -3009(leftright)X -1 f -3314(option)X -3542(for)X -3660(more)X -3849(infor-)X -976 2382(mation.)N -3 f -776 2562(slowopen,)N -1131(slow)X -1302([off])X -1 f -976 2652(This)N -1141(option)X -1368(affects)X -1606(the)X -1727(display)X -1981(algorithm)X -2315(used)X -2485(by)X -3 f -2588(vi)X -1 f -2650(,)X -2693(holding)X -2960(off)X -3077(display)X -3331(updating)X -3635(during)X -3868(input)X -976 2742(of)N -1063(new)X -1217(text)X -1357(to)X -1439(improve)X -1726(throughput)X -2097(when)X -2291(the)X -2409(terminal)X -2696(in)X -2778(use)X -2905(is)X -2978(slow)X -3149(and)X -3285(unintelligent.)X -2 f -976 2922(This)N -1133(option)X -1357(is)X -1430(not)X -1552(yet)X -1666(implemented.)X -3 f -776 3102(sourceany)N -1143([off])X -1 f -976 3192(If)N -1054(this)X -1193(option)X -1421(is)X -1498(turned)X -1727(on,)X -3 f -1851(vi)X -1 f -1937(historically)X -2321(read)X -2485(startup)X -2728(\256les)X -2886(that)X -3031(were)X -3213(owned)X -3452(by)X -3557(someone)X -3867(other)X -976 3282(than)N -1142(the)X -1268(editor)X -1483(user.)X -1685(See)X -1829(the)X -1955(section)X -2210(entitled)X -2478(``)X -3 f -2532(Startup)X -2822(Information)X -1 f -3240('')X -3321(for)X -3442(more)X -3634(information.)X -976 3372(This)N -1144(option)X -1374(is)X -1453(a)X -1516(security)X -1797(problem)X -2091(of)X -2185(immense)X -2501(proportions,)X -2917(and)X -3060(should)X -3300(not)X -3429(be)X -3532(used)X -3706(under)X -3916(any)X -976 3462(circumstances.)N -2 f -976 3642(This)N -1133(option)X -1357(will)X -1496(never)X -1695(be)X -1791(implemented.)X -3 f -776 3822(tabstop,)N -1069(ts)X -1147([8])X -1 f -976 3912(This)N -1138(option)X -1362(sets)X -1502(tab)X -1620(widths)X -1853(for)X -1967(the)X -2085(editor)X -2292(display.)X -3 f -776 4092(taglength,)N -1136(tl)X -1205([0])X -1 f -976 4182(This)N -1148(option)X -1383(sets)X -1534(the)X -1663(maximum)X -2018(number)X -2294(of)X -2392(characters)X -2750(that)X -2901(are)X -3031(considered)X -3410(signi\256cant)X -3774(in)X -3867(a)X -3934(tag)X -976 4272(name.)N -1210(Setting)X -1456(the)X -1574(value)X -1768(to)X -1850(0)X -1910(makes)X -2135(all)X -2235(of)X -2322(the)X -2440(characters)X -2787(in)X -2869(the)X -2987(tag)X -3105(name)X -3299(signi\256cant.)X -3 f -776 4452(tags,)N -954(tag)X -1081([tags)X -1266(/var/db/libc.tags)X -1838(/sys/kern/tags])X -1 f -976 4542(Sets)N -1129(the)X -1247(list)X -1364(of)X -1451(tags)X -1600(\256les,)X -1773(in)X -1855(search)X -2081(order,)X -2291(which)X -2507(are)X -2626(used)X -2793(when)X -2987(the)X -3105(editor)X -3312(searches)X -3605(for)X -3719(a)X -3775(tag.)X -3 f -776 4722(term,)N -982(ttytype,)X -1263(tty)X -1377([environment)X -1860(variable)X -2160(TERM])X -1 f -976 4812(Set)N -1101(the)X -1223(terminal)X -1514(type.)X -1716(Setting)X -1966(this)X -2105(option)X -2333(causes)X -3 f -2567(ex)X -1 f -2643(/)X -3 f -2665(vi)X -1 f -2751(to)X -2837(set)X -2950(\(or)X -3068(reset\))X -3271(the)X -3393(environmental)X -3880(vari-)X -976 4902(able)N -7 f -1130(TERM)X -1 f -(.)S -3 f -776 5082(terse)N -962([off])X -1 f -976 5172(This)N -1142(option)X -1370(has)X -1501(historically)X -1885(made)X -2083(editor)X -2294(messages)X -2621(less)X -2765(verbose.)X -3079(It)X -3152(has)X -3283(no)X -3387(effect)X -3596(in)X -3683(this)X -3823(imple-)X -976 5262(mentation.)N -1356(See)X -1492(the)X -3 f -1610(verbose)X -1 f -1893(option)X -2117(for)X -2231(more)X -2416(information.)X -3 f -776 5442(tildeop)N -1 f -976 5532(Modify)N -1236(the)X -3 f -1354(\304)X -1 f -1401(command)X -1737(to)X -1819(take)X -1973(an)X -2069(associated)X -2419(motion.)X -3 f -776 5712(timeout,)N -1079(to)X -1166([on])X -1 f -976 5802(If)N -1057(this)X -1199(option)X -1431(is)X -1512(set,)X -3 f -1649(ex)X -1 f -1725(/)X -3 f -1747(vi)X -1 f -1837(waits)X -2034(for)X -2156(a)X -2220(speci\256c)X -2493(period)X -2726(for)X -2848(a)X -2912(subsequent)X -3296(key)X -3440(to)X -3530(complete)X -3852(a)X -3916(key)X - -52 p -%%Page: 52 51 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-52)N -3391(Nvi/Nex)X -3687 0.3906(Reference)AX -1 f -976 762(mapping)N -1282(\(see)X -1438(the)X -3 f -1561(keytime)X -1 f -1858(option\).)X -2154(If)X -2233(the)X -2356(option)X -2585(is)X -2663(not)X -2790(set,)X -2924(the)X -3047(editor)X -3259(waits)X -3453(until)X -3624(enough)X -3885(keys)X -976 852(are)N -1095(entered)X -1352(to)X -1434(resolve)X -1686(the)X -1804(ambiguity,)X -2168(regardless)X -2514(of)X -2601(how)X -2759(long)X -2921(it)X -2985(takes.)X -3 f -776 1032(ttywerase)N -1127([off])X -976 1122(Vi)N -1 f -1082(only.)X -1290(This)X -1458(option)X -1688(changes)X -1973(how)X -3 f -2137(vi)X -1 f -2225(does)X -2398(word)X -2589(erase)X -2781(during)X -3016(text)X -3162(input.)X -3392(If)X -3472(this)X -3613(option)X -3843(is)X -3923(set,)X -976 1212(text)N -1123(is)X -1203(broken)X -1452(up)X -1558(into)X -1708(two)X -1854(classes,)X -2123(blank)X -2327(characters)X -2680(and)X -2822(nonblank)X -3146(characters.)X -3539(Changing)X -3876(from)X -976 1302(one)N -1112(class)X -1288(to)X -1370(another)X -1631(marks)X -1847(the)X -1965(end)X -2101(of)X -2188(a)X -2244(word.)X -3 f -776 1482(verbose)N -1059([off])X -976 1572(Vi)N -1 f -1078(only.)X -3 f -1282(Vi)X -1 f -1384(historically)X -1766(bells)X -1939(the)X -2059(terminal)X -2348(for)X -2464(many)X -2665(obvious)X -2941(mistakes,)X -3264(e.g.)X -3403(trying)X -3617(to)X -3702(move)X -3903(past)X -976 1662(the)N -1108(left-hand)X -1432(margin,)X -1713(or)X -1814(past)X -1977(the)X -2109(end)X -2259(of)X -2360(the)X -2492(\256le.)X -2668(If)X -2756(this)X -2905(option)X -3143(is)X -3230(set,)X -3373(an)X -3483(error)X -3674(message)X -3979(is)X -976 1752(displayed)N -1303(for)X -1417(all)X -1517(errors.)X -3 f -776 1932(w300)N -974([no)X -1105(default])X -976 2022(Vi)N -1 f -1080(only.)X -1286(Set)X -1412(the)X -1534(window)X -1816(size)X -1965(if)X -2038(the)X -2160(baud)X -2340(rate)X -2485(is)X -2562(less)X -2706(than)X -2868(1200)X -3052(baud.)X -3273(See)X -3414(the)X -3 f -3537(window)X -1 f -3828(option)X -976 2112(for)N -1090(more)X -1275(information.)X -3 f -776 2292(w1200)N -1014([no)X -1145(default])X -976 2382(Vi)N -1 f -1081(only.)X -1288(Set)X -1415(the)X -1538(window)X -1821(size)X -1971(if)X -2045(the)X -2168(baud)X -2349(rate)X -2495(is)X -2574(equal)X -2774(to)X -2862(1200)X -3048(baud.)X -3270(See)X -3412(the)X -3 f -3536(window)X -1 f -3828(option)X -976 2472(for)N -1090(more)X -1275(information.)X -3 f -776 2652(w9600)N -1014([no)X -1145(default])X -976 2742(Vi)N -1 f -1087(only.)X -1300(Set)X -1433(the)X -1562(window)X -1851(size)X -2007(if)X -2087(the)X -2216(baud)X -2404(rate)X -2557(is)X -2642(greater)X -2898(than)X -3068(1200)X -3260(baud.)X -3488(See)X -3636(the)X -3 f -3766(window)X -1 f -976 2832(option)N -1200(for)X -1314(more)X -1499(information.)X -3 f -776 3012(warn)N -974([on])X -976 3102(Ex)N -1 f -1094(only.)X -1302(This)X -1470(option)X -1700(causes)X -1936(a)X -1998(warning)X -2287(message)X -2585(to)X -2673(the)X -2797(terminal)X -3090(if)X -3165(the)X -3289(\256le)X -3417(has)X -3550(been)X -3728(modi\256ed,)X -976 3192(since)N -1161(it)X -1225(was)X -1370(last)X -1501(written,)X -1768(before)X -1994(a)X -3 f -2050(!)X -1 f -2117(command.)X -3 f -776 3372(window,)N -1082(w,)X -1180(wi)X -1280([environment)X -1763(variable)X -2063(LINES])X -1 f -976 3462(This)N -1148(option)X -1382(determines)X -1764(the)X -1892(default)X -2145(number)X -2420(of)X -2517(lines)X -2698(in)X -2791(a)X -2858(screenful,)X -3204(as)X -3302(written)X -3560(by)X -3671(the)X -3 f -3800(z)X -1 f -3867(com-)X -976 3552(mand.)N -1221(It)X -1297(also)X -1453(determines)X -1832(the)X -1957(number)X -2229(of)X -2323(lines)X -2501(scrolled)X -2782(by)X -2889(the)X -3 f -3014(vi)X -1 f -3103(commands)X -3 f -3477()X -1 f -3916(and)X -3 f -976 3642()N -1 f -1393(.)X -1457(The)X -1606(value)X -1804(of)X -1895(window)X -2177(can)X -2313(be)X -2413(unrelated)X -2736(to)X -2822(the)X -2944(real)X -3089(screen)X -3319(size,)X -3489(although)X -3794(it)X -3863(starts)X -976 3732(out)N -1110(as)X -1209(the)X -1338(number)X -1614(of)X -1712(lines)X -1894(on)X -2005(the)X -2134(screen)X -2371(\(see)X -2532(the)X -2661(section)X -2919(entitled)X -3190(``)X -3 f -3244(Sizing)X -3483(the)X -3621(Screen)X -1 f -3853('')X -3938(for)X -976 3822(more)N -1165(information\).)X -1634(Setting)X -1884(the)X -2006(value)X -2204(of)X -2295(the)X -3 f -2417(window)X -1 f -2707(option)X -2935(is)X -3012(the)X -3135(same)X -3325(as)X -3417(using)X -3615(the)X -3 f -9 f -3738(-)X -3740(-)X -3 f -3784(w)X -1 f -3867(com-)X -976 3912(mand)N -1174(line)X -1314(option.)X -976 4092(If)N -1055(the)X -1178(value)X -1377(of)X -1469(the)X -3 f -1592(window)X -1 f -1883(option)X -2112(\(as)X -2231(set)X -2345(by)X -2450(the)X -3 f -2574(window)X -1 f -2840(,)X -3 f -2886(w300)X -1 f -3064(,)X -3 f -3110(w1200)X -1 f -3354(or)X -3 f -3447(w9600)X -1 f -3691(options\))X -3979(is)X -976 4182(smaller)N -1233(than)X -1391(the)X -1509(actual)X -1721(size)X -1866(of)X -1953(the)X -2071(screen,)X -2317(large)X -2498(screen)X -2724(movements)X -3113(will)X -3257(result)X -3455(in)X -3537(displaying)X -3890(only)X -976 4272(that)N -1116(smaller)X -1373(number)X -1639(of)X -1727(lines)X -1899(on)X -2000(the)X -2119(screen.)X -2386(\(Further)X -2670(movements)X -3060(in)X -3143(that)X -3284(same)X -3470(area)X -3626(will)X -3771(result)X -3970(in)X -976 4362(the)N -1097(screen)X -1325(being)X -1525(\256lled.\))X -1778(This)X -1942(can)X -2076(provide)X -2343(a)X -2401(performance)X -2830(improvement)X -3279(when)X -3475(viewing)X -3755(different)X -976 4452(places)N -1197(in)X -1279(one)X -1415(or)X -1502(more)X -1687(\256les)X -1840(over)X -2003(a)X -2059(slow)X -2230(link.)X -3 f -776 4632(wrapmargin,)N -1243(wm)X -1388([0])X -976 4722(Vi)N -1 f -1077(only.)X -1280(If)X -1356(the)X -1476(value)X -1672(of)X -1761(the)X -3 f -1881(wrapmargin)X -1 f -2330(option)X -2556(is)X -2631(non-zero,)X -3 f -2959(vi)X -1 f -3043(will)X -3189(split)X -3348(lines)X -3521(so)X -3614(that)X -3756(they)X -3916(end)X -976 4812(at)N -1057(least)X -1227(that)X -1370(number)X -1638(of)X -1728(characters)X -2078(before)X -2307(the)X -2428(right-hand)X -2785(margin)X -3035(of)X -3125(the)X -3245(screen.)X -3513(\(Note,)X -3738(the)X -3858(value)X -976 4902(of)N -3 f -1063(wrapmargin)X -1 f -1510(is)X -2 f -1583(not)X -1 f -1705(a)X -1761(text)X -1901(length.)X -2161(In)X -2248(a)X -2304(screen)X -2530(that)X -2670(is)X -2743(80)X -2843(columns)X -3134(wide,)X -3330(the)X -3449(command)X -3786(``)X -7 f -3840(:set)X -976 4992(wrapmargin=8)N -1 f -('')S -1626(attempts)X -1917(to)X -1999(keep)X -2171(the)X -2289(lines)X -2460(less)X -2600(than)X -2758(or)X -2845(equal)X -3039(to)X -3121(72)X -3221(columns)X -3512(wide.\))X -976 5172(Lines)N -1181(are)X -1307(split)X -1471(at)X -1556(the)X -1681(previous)X -1984(whitespace)X -2368(character)X -2691(closest)X -2936(to)X -3025(the)X -3150(number.)X -3462(Any)X -3627(trailing)X -3885(whi-)X -976 5262(tespace)N -1239(characters)X -1592(before)X -1824(that)X -1970(character)X -2292(are)X -2417(deleted.)X -2715(If)X -2795(the)X -2919(line)X -3065(is)X -3143(split)X -3305(because)X -3585(of)X -3677(an)X -3778(inserted)X -7 f -976 5352()N -1 f -1346(or)X -7 f -1447()X -1 f -1721(character,)X -2072(and)X -2223(you)X -2378(then)X -2551(enter)X -2747(another)X -7 f -3023()X -1 f -3394(character,)X -3745(it)X -3824(is)X -3912(dis-)X -976 5442(carded.)N -976 5622(If)N -1052(wrapmargin)X -1462(is)X -1537(set)X -1648(to)X -1732(0,)X -1815(or)X -1905(if)X -1977(there)X -2161(is)X -2237(no)X -2340(blank)X -2541(character)X -2860(upon)X -3043(which)X -3262(to)X -3347(split)X -3507(the)X -3628(line,)X -3791(the)X -3912(line)X -976 5712(is)N -1049(not)X -1171(broken.)X - -53 p -%%Page: 53 52 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -3658(USD:13-53)X -776 762(wrapscan,)N -1145(ws)X -1254([on])X -1 f -976 852(This)N -1138(option)X -1362(causes)X -1592(searches)X -1885(to)X -1967(wrap)X -2148(around)X -2391(the)X -2509(end)X -2645(or)X -2732(the)X -2850(beginning)X -3191(of)X -3279(the)X -3398(\256le,)X -3541(and)X -3678(back)X -3851(to)X -3934(the)X -976 942(starting)N -1236(point.)X -1460(Otherwise,)X -1830(the)X -1948(end)X -2084(or)X -2171(beginning)X -2511(of)X -2598(the)X -2716(\256le)X -2838(terminates)X -3192(the)X -3310(search.)X -3 f -776 1122(writeany,)N -1119(wa)X -1237([off])X -1 f -976 1212(If)N -1056(this)X -1197(option)X -1427(is)X -1506(set,)X -1641(\256le-overwriting)X -2170(checks)X -2416(that)X -2563(would)X -2790(usually)X -3048(be)X -3151(made)X -3352(before)X -3585(the)X -3 f -3710(write)X -1 f -3916(and)X -3 f -976 1302(xit)N -1 f -1094(commands,)X -1490(or)X -1586(before)X -1821(an)X -1926(automatic)X -2271(write)X -2465(\(see)X -2624(the)X -3 f -2751(autowrite)X -1 f -3110(option\),)X -3390(are)X -3518(not)X -3648(made.)X -3890(This)X -976 1392(allows)N -1205(a)X -1261(write)X -1446(to)X -1528(any)X -1664(\256le,)X -1806(provided)X -2111(the)X -2229(\256le)X -2351(permissions)X -2753(allow)X -2951(it.)X -3 f -776 1578(16.)N -916(Additional)X -1299(Features)X -1618(in)X -1704(Nex/Nvi)X -1 f -976 1701(There)N -1190(are)X -1315(a)X -1377(few)X -1524(features)X -1805(in)X -3 f -1894(nex)X -1 f -(/)S -3 f -2036(nvi)X -1 f -2169(that)X -2316(are)X -2442(not)X -2571(found)X -2785(in)X -2874(historic)X -3141(versions)X -3435(of)X -3 f -3529(ex)X -1 f -3605(/)X -3 f -3627(vi)X -1 f -3689(.)X -3756(Some)X -3965(of)X -776 1791(the)N -894(more)X -1079(interesting)X -1437(of)X -1524(those)X -1713(features)X -1988(are)X -2107(as)X -2194(follows:)X -3 f -776 1971(8-bit)N -956(clean)X -1154(data,)X -1345(large)X -1539(lines,)X -1734(\256les)X -976 2061(Nex)N -1 f -1110(/)X -3 f -1132(nvi)X -1 f -1260(will)X -1407(edit)X -1550(any)X -1689(format)X -1926(\256le.)X -2091(Line)X -2261(lengths)X -2515(are)X -2637(limited)X -2886(by)X -2989(available)X -3302(memory,)X -3612(and)X -3751(\256le)X -3876(sizes)X -976 2151(are)N -1099(limited)X -1349(by)X -1453(available)X -1767(disk)X -1924(space.)X -2167(The)X -3 f -2316(vi)X -1 f -2402(text)X -2546(input)X -2734(mode)X -2935(command)X -3 f -3274()X -1 f -3719(can)X -3854(insert)X -976 2241(any)N -1112(possible)X -1394(character)X -1710(value)X -1904(into)X -2048(the)X -2166(text.)X -3 f -776 2421(Split)N -955(screens)X -1 f -976 2511(The)N -3 f -1127(split)X -1 f -1299(command)X -1641(divides)X -1898(the)X -2022(screen)X -2254(into)X -2404(multiple)X -2696(editing)X -2944(regions.)X -3246(The)X -3 f -3397()X -1 f -3867(com-)X -976 2601(mand)N -1183(rotates)X -1426(between)X -1723(the)X -1850(foreground)X -2236(screens.)X -2541(The)X -3 f -2694(resize)X -1 f -2919(command)X -3263(can)X -3403(be)X -3507(used)X -3682(to)X -3772(grow)X -3965(or)X -976 2691(shrink)N -1196(a)X -1252(particular)X -1580(screen.)X -3 f -776 2871(Background)N -1217(and)X -1365(foreground)X -1772(screens)X -1 f -976 2961(The)N -3 f -1134(bg)X -1 f -1251(command)X -1600(backgrounds)X -2044(the)X -2176(current)X -2438(screen,)X -2698(and)X -2848(the)X -3 f -2980(fg)X -1 f -3081(command)X -3431(foregrounds)X -3853(back-)X -976 3051(grounded)N -1299(screens.)X -1596(The)X -3 f -1741(display)X -1 f -2004(command)X -2340(can)X -2472(be)X -2568(used)X -2735(to)X -2817(list)X -2934(the)X -3052(background)X -3451(screens.)X -3 f -776 3231(Tag)N -929(stacks)X -1 f -976 3321(Tags)N -1159(are)X -1285(now)X -1450(maintained)X -1834(in)X -1924(a)X -1988(stack.)X -2221(The)X -3 f -2374()X -1 f -2819(command)X -3163(returns)X -3414(to)X -3504(the)X -3630(previous)X -3934(tag)X -976 3411(location.)N -1299(The)X -3 f -1449(tagpop)X -1 f -1709(command)X -2050(returns)X -2298(to)X -2385(the)X -2508(most)X -2688(recent)X -2910(tag)X -3033(location)X -3316(by)X -3421(default,)X -3689(or,)X -3801(option-)X -976 3501(ally)N -1119(to)X -1204(a)X -1263(speci\256c)X -1531(tag)X -1652(number)X -1920(in)X -2005(the)X -2126(tag)X -2248(stack,)X -2457(or)X -2548(the)X -2670(most)X -2849(recent)X -3070(tag)X -3192(from)X -3372(a)X -3432(speci\256ed)X -3741(\256le.)X -3907(The)X -3 f -976 3591(display)N -1 f -1241(command)X -1579(can)X -1713(be)X -1810(used)X -1978(to)X -2061(list)X -2179(the)X -2298(tags)X -2448(stack.)X -2674(The)X -3 f -2820(tagtop)X -1 f -3059(command)X -3396(returns)X -3640(to)X -3723(the)X -3842(top)X -3965(of)X -976 3681(the)N -1094(tag)X -1212(stack.)X -3 f -776 3861(New)N -948(displays)X -1 f -976 3951(The)N -3 f -1128(display)X -1 f -1398(command)X -1741(can)X -1880(be)X -1984(used)X -2159(to)X -2249(display)X -2508(the)X -2634(current)X -2890(buffers,)X -3166(the)X -3292(backgrounded)X -3775(screens,)X -976 4041(and)N -1112(the)X -1230(tags)X -1379(stack.)X -3 f -776 4221(In\256nite)N -1044(undo)X -1 f -976 4311(Changes)N -1282(made)X -1486(during)X -1725(an)X -1832(edit)X -1983(session)X -2245(may)X -2414(be)X -2521(rolled)X -2739(backward)X -3083(and)X -3230(forward.)X -3556(A)X -3 f -3645(.)X -1 f -3716(command)X -976 4401(immediately)N -1403(after)X -1578(a)X -3 f -1640(u)X -1 f -1710(command)X -2052(continues)X -2385(either)X -2594(forward)X -2875(or)X -2968(backward)X -3307(depending)X -3667(on)X -3773(whether)X -976 4491(the)N -3 f -1094(u)X -1 f -1158(command)X -1494(was)X -1639(an)X -1735(undo)X -1915(or)X -2002(a)X -2058(redo.)X -3 f -776 4671(Usage)N -1001(information)X -1 f -976 4761(The)N -3 f -1126(exusage)X -1 f -1418(and)X -3 f -1559(viusage)X -1 f -1837(commands)X -2209(provide)X -2479(usage)X -2688(information)X -3092(for)X -3212(all)X -3318(of)X -3411(the)X -3 f -3535(ex)X -1 f -3637(and)X -3 f -3779(vi)X -1 f -3867(com-)X -976 4851(mands)N -1205(by)X -1305(default,)X -1568(or,)X -1675(optionally,)X -2039(for)X -2153(a)X -2209(speci\256c)X -2474(command)X -2810(or)X -2897(key.)X -3 f -776 5031(Extended)N -1120(Regular)X -1416(Expressions)X -1 f -976 5121(The)N -3 f -1133(extended)X -1 f -1472(option)X -1708(causes)X -1950(Regular)X -2237(Expressions)X -2657(to)X -2752(be)X -2861(interpreted)X -3242(as)X -3342(as)X -3442(Extended)X -3778(Regular)X -976 5211(Expressions,)N -1403(\(i.e.)X -2 f -1548(egrep)X -1 f -1731(\(1\))X -1845(style)X -2016(Regular)X -2290(Expressions\).)X -3 f -776 5391(Word)N -996(search)X -1 f -976 5481(The)N -3 f -1121()X -1 f -1563(command)X -1899(searches)X -2192(for)X -2306(the)X -2424(word)X -2609 0.4028(referenced)AX -2970(by)X -3070(the)X -3188(cursor.)X -3 f -776 5661(Number)N -1081(increment)X -1 f -976 5751(The)N -3 f -1121(#)X -1 f -1181(command)X -1517(increments)X -1889(or)X -1976(decrements)X -2362(the)X -2480(number)X -2745 0.4028(referenced)AX -3106(by)X -3206(the)X -3324(cursor.)X - -54 p -%%Page: 54 53 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-54)N -3391(Nvi/Nex)X -3687 0.3906(Reference)AX -776 762(Previous)N -1094(\256le)X -1 f -976 852(The)N -3 f -1121(previous)X -1 f -1434(command)X -1770(edits)X -1941(the)X -2059(previous)X -2355(\256le)X -2477(from)X -2653(the)X -2771(argument)X -3094(list.)X -3 f -776 1032(Left-right)N -1135(scrolling)X -1 f -976 1122(The)N -3 f -1130(leftright)X -1 f -1440(option)X -1673(causes)X -3 f -1912(nvi)X -1 f -2047(to)X -2138(do)X -2248(left-right)X -2563(screen)X -2799(scrolling,)X -3129(instead)X -3386(of)X -3483(the)X -3611(traditional)X -3 f -3970(vi)X -1 f -976 1212(line)N -1116(wrapping.)X - -55 p -%%Page: 55 54 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(Nvi/Nex)N -872 0.3906(Reference)AX -3658(USD:13-55)X -776 762(17.)N -916(Index)X -1 f -776 885(.)N -1549(18)X -776 975(!)N -1429(15,)X -1549(34)X -776 1065("")N -1549(34)X -776 1155(#)N -1429(16,)X -1549(35)X -776 1245($)N -1549(16)X -776 1335(%)N -1549(16)X -776 1425(&)N -1429(17,)X -1549(42)X -776 1515(\()N -1549(17)X -776 1605(\))N -1549(17)X -776 1695(*)N -1549(35)X -776 1785(+)N -1549(13)X -776 1875(,)N -1549(18)X -776 1965(/RE/)N -1549(18)X -776 2055(0)N -1549(19)X -776 2145(0)N -1549(31)X -776 2235(:)N -1549(19)X -776 2325(;)N -1549(19)X -776 2415(<)N -1429(20,)X -1549(35)X -776 2505()N -1549(11)X -776 2595()N -1549(11)X -776 2685()N -1429(12,)X -1549(31)X -776 2775()N -1549(12)X -776 2865()N -1549(12)X -776 2955()N -1549(12)X -776 3045()N -1429(12,)X -1549(31)X -776 3135()N -1549(13)X -776 3225()N -1549(13)X -776 3315()N -1549(13)X -776 3405()N -1549(13)X -776 3495()N -1549(13)X -776 3585()N -1549(13)X -776 3675()N -1429(14,)X -1549(31)X -776 3765()N -1549(14)X -776 3855()N -1429(14,)X -1549(31)X -776 3945()N -1549(31)X -776 4035()N -1549(14)X -776 4125()N -1429(14,)X -1549(43)X -776 4215()N -1549(15)X -776 4305()N -1549(15)X -776 4395()N -1549(34)X -776 4485()N -1549(33)X -776 4575()N -1549(31)X -776 4665()N -1429(14,)X -1549(31)X -776 4755()N -1349(7,)X -1429(30,)X -1549(31)X -776 4845()X -1549(31)X -776 4935()X -1469(7,)X -1549(31)X -776 5025()N -1549(30)X -776 5115()N -1549(15)X -776 5205()X -1549(31)X -776 5295(=)N -1549(35)X -776 5385(>)N -1429(20,)X -1549(35)X -776 5475(?RE?)N -1549(18)X -776 5565(@)N -1429(20,)X -1549(35)X -776 5655(A)N -1549(20)X -776 5745(B)N -1549(20)X -2077 885(C)N -2850(21)X -2077 975(D)N -2850(21)X -2077 1065(E)N -2850(21)X -2077 1155(F)N -2850(21)X -2077 1245(G)N -2850(21)X -2077 1335(H)N -2850(21)X -2077 1425(I)N -2850(22)X -2077 1515(J)N -2850(22)X -2077 1605(L)N -2850(22)X -2077 1695(M)N -2850(22)X -2077 1785(N)N -2850(18)X -2077 1875(O)N -2850(22)X -2077 1965(P)N -2850(23)X -2077 2055(Q)N -2850(23)X -2077 2145(R)N -2850(23)X -2077 2235(S)N -2850(23)X -2077 2325(T)N -2850(23)X -2077 2415(U)N -2850(23)X -2077 2505(W)N -2850(24)X -2077 2595(X)N -2850(24)X -2077 2685(Y)N -2850(24)X -2077 2775(ZZ)N -2850(24)X -2077 2865([[)N -2850(24)X -9 f -2077 2955(-)N -1 f -2850(18)X -2077 3045(]])N -2850(25)X -2077 3135(\303)N -2850(25)X -2077 3225(\303)N -2850(31)X -2077 3315(_)N -2850(25)X -2077 3405 0.2841(`)AN -2850(17)X -2077 3495(a)N -2850(25)X -2077 3585(abbrev)N -2850(35)X -2077 3675(alternate)N -2374(pathname)X -2890(8)X -2077 3765(altwerase)N -2850(46)X -2077 3855(append)N -2850(36)X -2077 3945(args)N -2850(36)X -2077 4035(autoindent)N -2850(46)X -2077 4125(autoprint)N -2850(46)X -2077 4215(autowrite)N -2850(47)X -2077 4305(b)N -2850(25)X -2077 4395(beautify)N -2850(47)X -2077 4485(bg)N -2850(36)X -2077 4575(bigword)N -2850(10)X -2077 4665(buffer)N -2890(8)X -2077 4755(c)N -2850(26)X -2077 4845(cd)N -2850(36)X -2077 4935(cdpath)N -2850(47)X -2077 5025(change)N -2850(36)X -2077 5115(chdir)N -2850(36)X -2077 5205(columns)N -2850(47)X -2077 5295(comment)N -2850(47)X -2077 5385(copy)N -2850(36)X -2077 5475(count)N -2730(10,)X -2850(33)X -2077 5565(current)N -2325(pathname)X -2890(8)X -2077 5655(d)N -2850(26)X -2077 5745(delete)N -2850(37)X -3378 885(directory)N -4151(47)X -3378 975(display)N -4151(37)X -3378 1065(e)N -4151(26)X -3378 1155(edcompatible)N -4151(47)X -3378 1245(edit)N -4151(37)X -3378 1335(errorbells)N -4151(47)X -3378 1425(exrc)N -4151(47)X -3378 1515(extended)N -4151(48)X -3378 1605(exusage)N -4151(37)X -3378 1695(f)N -4151(26)X -3378 1785(fg)N -4151(37)X -3378 1875(\256le)N -4031(33,)X -4151(37)X -3378 1965(\257ags)N -4151(33)X -3378 2055(\257ash)N -4151(48)X -3378 2145(global)N -4151(38)X -3378 2235(hardtabs)N -4151(48)X -3378 2325(help)N -4151(38)X -3378 2415(i)N -4151(26)X -3378 2505(ignorecase)N -4151(48)X -3378 2595(insert)N -4151(38)X -3378 2685(j)N -4151(13)X -3378 2775(join)N -4151(38)X -3378 2865(k)N -4031(13,)X -4151(39)X -3378 2955(keytime)N -4151(48)X -3378 3045(l)N -4151(15)X -3378 3135(leftright)N -4151(48)X -3378 3225(line)N -4151(33)X -3378 3315(lines)N -4151(48)X -3378 3405(lisp)N -4151(48)X -3378 3495(list)N -4031(39,)X -4151(48)X -3378 3585(m)N -4151(27)X -3378 3675(magic)N -4151(48)X -3378 3765(map)N -4151(39)X -3378 3855(mark)N -4151(39)X -3378 3945(matchtime)N -4151(48)X -3378 4035(mesg)N -4151(48)X -3378 4125(mkexrc)N -4151(39)X -3378 4215(modelines)N -4151(49)X -3378 4305(motion)N -4151(10)X -3378 4395(move)N -4151(39)X -3378 4485(n)N -4151(18)X -3378 4575(next)N -4151(40)X -3378 4665(number)N -4031(35,)X -4151(49)X -3378 4755(o)N -4151(27)X -3378 4845(octal)N -4151(49)X -3378 4935(open)N -4031(40,)X -4151(49)X -3378 5025(optimize)N -4151(49)X -3378 5115(p)N -4151(27)X -3378 5205(paragraph)N -4151(11)X -3378 5295(paragraphs)N -4151(49)X -3378 5385(preserve)N -4151(40)X -3378 5475(previous)N -4151(40)X -3378 5565(previous)N -3674(context)X -4191(9)X -3378 5655(print)N -4151(40)X -3378 5745(prompt)N -4151(49)X - -56 p -%%Page: 56 55 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-56)N -3391(Nvi/Nex)X -3687 0.3906(Reference)AX -1 f -776 762(put)N -1549(40)X -776 852(quit)N -1549(41)X -776 942(r)N -1549(27)X -776 1032(range)N -1549(33)X -776 1122(read)N -1549(41)X -776 1212(readonly)N -1549(49)X -776 1302(recdir)N -1549(49)X -776 1392(recover)N -1549(41)X -776 1482(redraw)N -1549(50)X -776 1572(remap)N -1549(50)X -776 1662(report)N -1549(50)X -776 1752(resize)N -1549(41)X -776 1842(rewind)N -1549(41)X -776 1932(ruler)N -1549(50)X -776 2022(s)N -1549(27)X -776 2112(scroll)N -1549(50)X -776 2202(section)N -1549(11)X -776 2292(sections)N -1549(50)X -776 2382(sentence)N -1549(11)X -776 2472(set)N -1549(41)X -776 2562(shell)N -1429(42,)X -1549(50)X -776 2652(shiftwidth)N -1549(50)X -776 2742(showdirty)N -1549(51)X -776 2832(showmatch)N -1549(51)X -776 2922(showmode)N -1549(51)X -776 3012(sidescroll)N -1549(51)X -776 3102(slowopen)N -1549(51)X -776 3192(source)N -1549(42)X -776 3282(sourceany)N -1549(51)X -776 3372(split)N -1549(42)X -776 3462(stop)N -1549(43)X -776 3552(substitute)N -1549(42)X -776 3642(suspend)N -1549(43)X -776 3732(t)N -1429(27,)X -1549(36)X -776 3822(tabstop)N -1549(51)X -776 3912(tag)N -1549(43)X -776 4002(taglength)N -1549(51)X -776 4092(tagpop)N -1549(43)X -776 4182(tags)N -1549(51)X -776 4272(tagtop)N -1549(43)X -776 4362(term)N -1549(51)X -776 4452(terse)N -1549(51)X -776 4542(tildeop)N -1549(51)X -776 4632(timeout)N -1549(51)X -776 4722(ttywerase)N -1549(52)X -776 4812(u)N -1549(28)X -776 4902(unabbrev)N -1549(44)X -776 4992(undo)N -1549(44)X -776 5082(unmap)N -1549(44)X -776 5172(unnamed)N -1090(buffer)X -1589(8)X -776 5262(v)N -1549(38)X -776 5352(verbose)N -1549(52)X -776 5442(version)N -1549(44)X -776 5532(visual)N -1549(44)X -776 5622(viusage)N -1549(44)X -776 5712(w)N -1549(28)X -776 5802(w1200)N -1549(52)X -2077 762(w300)N -2850(52)X -2077 852(w9600)N -2850(52)X -2077 942(warn)N -2850(52)X -2077 1032(window)N -2850(52)X -2077 1122(wn)N -2850(44)X -2077 1212(word)N -2850(10)X -2077 1302(wq)N -2850(44)X -2077 1392(wrapmargin)N -2850(52)X -2077 1482(wrapscan)N -2850(52)X -2077 1572(write)N -2850(44)X -2077 1662(writeany)N -2850(53)X -2077 1752(x)N -2850(28)X -2077 1842(xit)N -2850(45)X -2077 1932(y)N -2850(28)X -2077 2022(yank)N -2850(45)X -2077 2112(z)N -2730(28,)X -2850(45)X -2077 2202({)N -2850(29)X -2077 2292(|)N -2850(29)X -2077 2382(})N -2850(29)X -2077 2472(\304)N -2610(29,)X -2730(30,)X -2850(42)X - -2 p -%%Page: 2 56 -10 s 10 xH 0 xS 1 f 1 i -3 f -576 474(USD:13-2)N -3391(Nvi/Nex)X -3687 0.3906(Reference)AX -12 s -2039 762(Table)N -2298(of)X -2402(Contents)X -1 f -10 s -776 961(Description)N -1184(................................................................................................................................)X -3992(3)X -776 1070(Startup)N -1027(Information)X -1444(...................................................................................................................)X -3992(3)X -776 1179(Recovery)N -1104(....................................................................................................................................)X -3992(3)X -776 1288(Sizing)N -1000(the)X -1118(Screen)X -1364(.......................................................................................................................)X -3992(5)X -776 1397(Character)N -1109(Display)X -1384(......................................................................................................................)X -3992(5)X -776 1506(Multiple)N -1071(Screens)X -1344(........................................................................................................................)X -3992(6)X -776 1615(Regular)N -1050(Expressions)X -1457(and)X -1593(Replacement)X -2032(Strings)X -2284(.........................................................................)X -3992(6)X -776 1724(General)N -1051(Editor)X -1271(Description)X -1684(.......................................................................................................)X -3992(7)X -776 1833(Vi)N -876(Description)X -1284(...........................................................................................................................)X -3992(8)X -776 1942(Vi)N -876(Commands)X -1264(............................................................................................................................)X -3952(11)X -776 2051(Vi)N -876(Text)X -1043(Input)X -1232(Commands)X -1624(..........................................................................................................)X -3952(30)X -776 2160(Ex)N -885(Addressing)X -1284(...........................................................................................................................)X -3952(31)X -776 2269(Ex)N -885(Description)X -1284(...........................................................................................................................)X -3952(33)X -776 2378(Ex)N -885(Commands)X -1284(...........................................................................................................................)X -3952(34)X -776 2487(Set)N -898(Options)X -1184(................................................................................................................................)X -3952(46)X -776 2596(Additional)N -1138(Features)X -1430(in)X -1512(Nex/Nvi)X -1824(................................................................................................)X -3952(53)X -776 2705(Index)N -984(..........................................................................................................................................)X -3952(55)X - -56 p -%%Trailer -xt - -xs diff --git a/usr.bin/vi/USD.doc/vi.ref/vi.ref.txt b/usr.bin/vi/USD.doc/vi.ref/vi.ref.txt deleted file mode 100644 index 88a98c7..0000000 --- a/usr.bin/vi/USD.doc/vi.ref/vi.ref.txt +++ /dev/null @@ -1,5544 +0,0 @@ - - - - - - - - - EExx//VVii RReeffeerreennccee MMaannuuaall - - _K_e_i_t_h _B_o_s_t_i_c - - Computer Science Division - Department of Electrical Engineering and Computer Science - University of California, Berkeley - Berkeley, California 94720 - - August 15, 1994 - - - - _A_b_s_t_r_a_c_t - - - - - This document is the reference guide for the 4.4BSD -implementations of nneexx/nnvvii, which are reimplementations -of the historic Berkeley eexx/vvii editors. - - - - - - _A_c_k_n_o_w_l_e_d_g_e_m_e_n_t_s - - - - - Bruce Englar encouraged the early development of -the historic eexx/vvii editor. Peter Kessler helped bring -sanity to version 2's command layout. Bill Joy wrote -versions 1 and 2.0 through 2.7, and created the frame- -work that users see in the present editor. Mark Horton -added macros and other features and made eexx/vvii work on a -large number of terminals and Unix systems. - - NNvvii is originally derived from software contributed -to the University of California, Berkeley by Steve Kirk- -endall, the author of the vvii clone eellvviiss. - - IEEE Standard Portable Operating System Interface -for Computer Environments (POSIX) 1003.2 style Regular -Expression support was done by Henry Spencer. - - The curses library was originally done by Ken -Arnold. Scrolling and reworking for nnvvii was done by -Elan Amir. - - - - - - - - - - - - - - - - The Institute of Electrical and Electronics Engi- -neers has given us permission to reprint portions of -their documentation. Portions of this document are -reprinted and reproduced from IEEE Std 1003.2-1992, IEEE -Standard Portable Operating System Interface for Comput- -er Environments (POSIX), copyright 1992 by the Institute -of Electrical and Electronics Engineers, Inc. - - The financial support of UUNET Communications Ser- -vices is gratefully acknowledged. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--33 - - -11.. DDeessccrriippttiioonn - - VVii is a screen oriented text editor. EExx is a line- -oriented text editor. EExx and vvii are different interfaces to -the same program, and it is possible to switch back and -forth during an edit session. VViieeww is the equivalent of -using the --RR (read-only) option of vvii. - - This reference manual is the one provided with the -nneexx/nnvvii versions of the eexx/vvii text editors. NNeexx/nnvvii are -intended as bug-for-bug compatible replacements for the -original Fourth Berkeley Software Distribution (4BSD) eexx/vvii -programs. This reference manual is accompanied by a tradi- -tional-style manual page. That manual page describes the -functionality found in eexx/vvii in far less detail than the -description here. In addition, it describes the system -interface to eexx/vvii, e.g. command line options, session -recovery, signals, environmental variables, and similar -things. - - This reference is intended for users already familiar -with eexx/vvii. Anyone else should almost certainly read a good -tutorial on the editor first. If you are in an unfamiliar -environment, and you absolutely have to get work done imme- -diately, see the section entitled "FFaasstt SSttaarrttuupp" in the man- -ual page. It is probably enough to get you started. - - There are a few features in nneexx/nnvvii that are not found -in historic versions of eexx/vvii. Some of the more interesting -of those features are briefly described in the section enti- -tled "AAddddiittiioonnaall FFeeaattuurreess" near the end of this document. -For the rest of this document, nneexx/nnvvii is used only when it -is necessary to distinguish it from the historic implementa- -tions of eexx/vvii. - - Future versions of this software will be periodically -made available by anonymous ftp, and can be retrieved from -ffttpp..ccss..bbeerrkkeelleeyy..eedduu, in the directory uuccbb//44bbssdd. - -22.. SSttaarrttuupp IInnffoorrmmaattiioonn - - EExx/vvii interprets one of two possible environmental -variables and reads up to three of five possible files dur- -ing startup. The variables and files are expected to con- -tain eexx commands, not vvii commands. In addition, they are -interpreted _b_e_f_o_r_e the file to be edited is read, and there- -fore many eexx commands may not be used. Generally, any com- -mand that requires output to the screen or that needs a file -upon which to operate, will cause an error if included in a -startup file or environmental variable. - - Because the eexx command set supported by nneexx/nnvvii is a -superset of the command set supported by most historical - - - - - - - - - - -UUSSDD::1133--44 NNvvii//NNeexx RReeffeerreennccee - - -implementations of eexx, nneexx/nnvvii can use the startup files -created for the historical implementations, but the converse -may not be true. - - If the --ss (the historic - option) is specified, or if -standard input is redirected from a file, all environmental -variables and startup files are ignored. - - Otherwise, startup files and environmental variables -are handled in the following order: - - (1) The file //eettcc//vvii..eexxrrcc is read, as long as it is owned - by root or the effective user ID of the user. - - (2) The environmental variable NNEEXXIINNIITT (or the variable - EEXXIINNIITT, if NNEEXXIINNIITT is not set) is interpreted. - - (3) If neither NNEEXXIINNIITT or EEXXIINNIITT was set, and the HHOOMMEE - environmental variable is set, the file $$HHOOMMEE//..nneexxrrcc - (or the file $$HHOOMMEE//..eexxrrcc, if $$HHOOMMEE//..nneexxrrcc does not - exist) is read, as long as the effective user ID of - the user is root or is the same as the owner of the - file. - - (4) If the eexxrrcc option was turned on by one of the previ- - ous startup information sources, the file ..nneexxrrcc (or - the file ..eexxrrcc, if ..nneexxrrcc does not exist) is read, as - long as the effective user ID of the user is the same - as the owner of the file. - - No startup file is read if it is writable by anyone -other than its owner. - - It is not an error for any of the startup environmental -variables or files not to exist. - - Once all environmental variables are interpreted, and -all startup files are read, the first file to be edited is -read in (or a temporary file is created). Then, any com- -mands specified using the --cc option are executed, in the -context of that file. - -33.. RReeccoovveerryy - - There is no recovery program for nneexx/nnvvii, nor does -nneexx/nnvvii run setuid. Recovery files are created readable and -writable by the owner only. Users may recover any file -which they can read, and the superuser may recover any edit -session. - - Edit sessions are backed by files in the directory -named by the rreeccddiirr option (the directory -//vvaarr//ttmmpp//vvii..rreeccoovveerr by default), and are named "vvii..XXXXXXXXXXXX", - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--55 - - -where "XXXXXXXXXXXX" is a number related to the process ID. When -a file is first modified, a second recovery file containing -an email message for the user is created, and is named -"rreeccoovveerr..XXXXXXXXXXXX", where, again, "XXXXXXXXXXXX" is associated with -the process ID. Both files are removed at the end of a nor- -mal edit session, but will remain if the edit session is -abnormally terminated or the user runs the eexx pprreesseerrvvee com- -mand. - - The rreeccddiirr option may be set in either the user's or -system's startup information, changing the recovery direc- -tory. (Note, however, that if a memory based file system is -used as the backup directory, each system reboot will delete -all of the recovery files! The same caution applies to -directories such as //ttmmpp which are cleared of their contents -by a system reboot, or //uussrr//ttmmpp which is periodically -cleared of old files on many systems.) - - The recovery directory should be owned by root, or at -least by a pseudo-user. In addition, if directory "sticky- -bit" semantics are available, the directory should have the -sticky-bit set so that files may only be removed by their -owners. The recovery directory must be read, write, and -executable by any user, i.e. mode 1777. - - If the recovery directory does not exist, eexx/vvii will -attempt to create it. This can result in the recovery -directory being owned by a normal user, which means that -that user will be able to remove other user's recovery and -backup files. This is annoying, but is not a security issue -as the user cannot otherwise access or modify the files. - - The recovery file has all of the necessary information -in it to enable the user to recover the edit session. In -addition, it has all of the necessary email headers for -_s_e_n_d_m_a_i_l(8). When the system is rebooted, all of the files -in //vvaarr//ttmmpp//vvii..rreeccoovveerr named "rreeccoovveerr..XXXXXXXXXXXX" should be sent -to their owners, by email, using the --tt option of sseennddmmaaiill -(or a similar mechanism in other mailers). If eexx/vvii -receives a hangup (SIGHUP) signal, or the user executes the -eexx pprreesseerrvvee command, eexx/vvii will automatically email the -recovery information to the user. - - If your system does not have the sseennddmmaaiill utility (or a -mailer program which supports its interface) the source file -nnvvii//ccoommmmoonn//rreeccoovveerr..cc will have to be modified to use your -local mail delivery programs. Note, if nneexx/nnvvii is changed -to use another mailer, it is important to remember that the -owner of the file given to the mailer is the nneexx/nnvvii user, -so nothing in the file should be trusted as it may have been -modified in an effort to compromise the system. - - - - - - - - - - - - -UUSSDD::1133--66 NNvvii//NNeexx RReeffeerreennccee - - - Finally, the owner execute bit is set on backup files -when they are created, and unset when they are first modi- -fied, e.g. backup files that have no associated email recov- -ery file will have this bit set. (There is also a small -window where empty files can be created and not yet have -this bit set. This is due to the method in which the files -are created.) Such files should be deleted when the system -reboots. - - A simple way to do this cleanup is to insert the fol- -lowing Bourne shell script into your //eettcc//rrcc..llooccaall (or other -startup) file. The script should work with the historic -Bourne shell, a POSIX 1003.2 shell or the Korn shell. (A -copy of this script is included as -nnvvii//iinnssttaallll//rreeccoovveerr..ssccrriipptt in the nneexx/nnvvii distribution.) - - - ## @@((##))rreeccoovveerr..ssccrriipptt 88..44 ((BBeerrkkeelleeyy)) 88//1133//9944 - ## - ## RReeccoovveerr nnvvii eeddiittoorr ffiilleess:: - RREECCDDIIRR==//vvaarr//ttmmpp//vvii..rreeccoovveerr - SSEENNDDMMAAIILL==//uussrr//lliibb//sseennddmmaaiill - eecchhoo ''RReeccoovveerriinngg nnvvii eeddiittoorr sseessssiioonnss..'' - - ## UUnnmmooddiiffiieedd nnvvii eeddiittoorr bbaacckkuupp ffiilleess aarree eeiitthheerr zzeerroo lleennggtthh oorr - ## hhaavvee tthhee eexxeeccuuttee bbiitt sseett.. DDeelleettee bbootthh ccaasseess.. - vviibbaacckkuupp==``eecchhoo $$RREECCDDIIRR//vvii..**`` - iiff [[ ""$$vviibbaacckkuupp"" !!== ""$$RREECCDDIIRR//vvii..**"" ]];; tthheenn - ffoorr ii iinn $$vviibbaacckkuupp;; ddoo - iiff tteesstt --xx $$ii --oo !! --ss $$ii;; tthheenn - rrmm $$ii - ffii - ddoonnee - ffii - - ## IItt iiss ppoossssiibbllee ttoo ggeett iinnccoommpplleettee rreeccoovveerryy ffiilleess,, iiff tthhee eeddiittoorr - ## ccrraasshheess aatt tthhee rriigghhtt ttiimmee.. DDeelleettee aannyy rreeccoovveerryy ffiilleess wwiitthhoouutt - ## ccoorrrreessppoonnddiinngg bbaacckkuupp ffiilleess,, ootthheerrwwiissee sseenndd mmaaiill ttoo tthhee uusseerr.. - vviirreeccoovveerryy==``eecchhoo $$RREECCDDIIRR//rreeccoovveerr..**`` - iiff [[ ""$$vviirreeccoovveerryy"" !!== ""$$RREECCDDIIRR//rreeccoovveerr..**"" ]];; tthheenn - ffoorr ii iinn $$vviirreeccoovveerryy;; ddoo - rreeccffiillee==``aawwkk ''//^^XX--vvii--rreeccoovveerr--ppaatthh:://{{pprriinntt $$22}}'' << $$ii`` - iiff tteesstt !! --nn $$rreeccffiillee --aa --ss $$rreeccffiillee;; tthheenn - $$SSEENNDDMMAAIILL --tt << $$ii - eellssee - rrmm $$ii - ffii - ddoonnee - ffii - - - - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--77 - - - If you are not using the default value for the rreeccddiirr -option, be sure to substitute the value you're using for the -RREECCDDIIRR value in the recovery script. - - If the path of your system's sseennddmmaaiill program (or what- -ever mailer you're using) is not //uussrr//lliibb//sseennddmmaaiill, be sure -to substitute the correct pathname for the SSEENNDDMMAAIILL value in -the recovery script. Consult the manual page for details on -recovering preserved or aborted editing sessions. - -44.. SSiizziinngg tthhee SSccrreeeenn - - The size of the screen can be set in a number of ways. -EExx/vvii takes the following steps until values are obtained -for both the number of rows and number of columns in the -screen. - - (1) If the environmental variable LLIINNEESS exists, it is - used to specify the number of rows in the screen. - - (2) If the environmental variable CCOOLLUUMMNNSS exists, it is - used to specify the number of columns in the screen. - - (3) The TIOCGWINSZ _i_o_c_t_l(2) is attempted on the standard - error file descriptor. - - (4) The termcap entry (or terminfo entry on System V - machines) is checked for the "li" entry (rows) and - the "co" entry (columns). - - (5) The number of rows is set to 24, and the number of - columns is set to 80. - - If a window change size signal (SIGWINCH) is received, -the new window size is retrieved using the TIOCGWINSZ -_i_o_c_t_l(2) call, and all other information is ignored. - -55.. CChhaarraacctteerr DDiissppllaayy - - In both eexx and vvii printable characters as defined by -_i_s_p_r_i_n_t(3) are displayed using the local character set. - - Non-printable characters, for which _i_s_c_n_t_r_l(3) returns -true, and which are less than octal \076, are displayed as -the string "^^<>", where <> is the charac- -ter that is the original character's value offset from the -"@@" character. For example, the octal character \001 is -displayed as "^^AA". If _i_s_c_n_t_r_l(3) returns true for the octal -character \177, it is displayed as the string "^^??". All -other characters are displayed as either hexadecimal values, -in the form "00xx<> ...... 00xx<>", or as -octal values, in the form "\\<> ...... -\\<>". The display of unknown characters is - - - - - - - - - - -UUSSDD::1133--88 NNvvii//NNeexx RReeffeerreennccee - - -based on the value of the ooccttaall option. - - In vvii command mode, the cursor is always positioned on -the last column of characters which take up more than one -column on the screen. In vvii text input mode, the cursor is -positioned on the first column of characters which take up -more than one column on the screen. - -66.. MMuullttiippllee SSccrreeeennss - - NNvvii supports multiple screens by dividing the window -into regions. It also supports stacks of screens by permit- -ting the user to change the set of screens that are cur- -rently displayed. - - The command sspplliitt divides the current screen into two -regions of approximately equal size. If a list of files are -specified as arguments to the sspplliitt command, the list of -files to be edited is initialized as if the nneexxtt command had -been used. If no files are specified, the new screen will -begin by editing the same file as the previous screen. - - When more than one screen is editing a file, changes in -any screen are reflected in all other screens editing the -same file. Exiting any screen without saving any changes -(or explicitly discarding them) is permitted until the last -screen editing the file is exited. - - The rreessiizzee command permits resizing of individual -screens. Screens may be grown, shrunk or set to an absolute -number of rows. - - The ^^WW command is used to switch between screens. Each -^^WW moves to the next lower screen in the window, or to the -first screen in the window if there are no lower screens. - - The bbgg command "backgrounds" the current screen. The -screen disappears from the window, and the rows it occupied -are taken over by a neighboring screen. It is an error to -attempt to background the only screen in the window. - - The ddiissppllaayy ssccrreeeennss command displays the names of the -files associated with the current backgrounded screens in -the window. - - The ffgg [[ffiillee]] command "foregrounds" the first screen in -the list of backgrounded screens that is associated with its -argument. If no file argument is specified, the first -screen on the list is foregrounded. Foregrounding consists -of backgrounding the current screen, and replacing its space -in the window with the foregrounded screen. - - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--99 - - - If the last screen in the window is exited, and there -are backgrounded screens, the first screen on the list of -backgrounded screens takes over the window. - -77.. RReegguullaarr EExxpprreessssiioonnss aanndd RReeppllaacceemmeenntt SSttrriinnggss - - Regular expressions are used in line addresses, as the -first part of the eexx ssuubbssttiittuuttee, gglloobbaall, and vvgglloobbaall com- -mands, and in search patterns. - - The regular expressions supported by eexx/vvii are, by -default, the Basic Regular Expressions (BRE's) described in -the IEEE POSIX Standard 1003.2. The eexxtteennddeedd option causes -all regular expressions to be interpreted as the Extended -Regular Expressions (ERE's) described by the same standard. -(See _r_e___f_o_r_m_a_t(7) for more information.) Generally speak- -ing, BRE's are the Regular Expressions found in _e_d(1) and -_g_r_e_p(1), and ERE's are the Regular Expressions found in -_e_g_r_e_p(1). - - The following is not intended to provide a description -of Regular Expressions. The information here only describes -strings and characters which have special meanings in the -eexx/vvii version of RE's, or options which change the meanings -of characters that normally have special meanings in RE's. - - (1) An empty RE (e.g. "////" or "????" is equivalent to the - last RE used. - - (2) The construct "\\<<" matches the beginning of a word. - - (3) The construct "\\>>" matches the end of a word. - - (4) The character "~~" matches the replacement part of the - last ssuubbssttiittuuttee command. - - When the mmaaggiicc option is _n_o_t set, the only characters -with special meanings are a "^^" character at the beginning -of an RE, a "$$" character at the end of an RE, and the -escaping character "\\". The characters "..", "**", "[[" and -"~~" are treated as ordinary characters unless preceded by a -"\\"; when preceded by a "\\" they regain their special mean- -ing. - - Replacement strings are the second part of a ssuubbssttiittuuttee -command. - - The character "&&" (or "\\&&" if the mmaaggiicc option is _n_o_t -set) in the replacement string stands for the text matched -by the RE that is being replaced. The character "~~" (or -"\\~~" if the mmaaggiicc option is _n_o_t set) stands for the replace- -ment part of the previous ssuubbssttiittuuttee command. It is only -valid after a ssuubbssttiittuuttee command has been performed. - - - - - - - - - - -UUSSDD::1133--1100 NNvvii//NNeexx RReeffeerreennccee - - - The string "\\##", where "##" is an integer value from 1 -to 9, stands for the text matched by the portion of the RE -enclosed in the "##"'th set of escaped parentheses, e.g. -"\\((" and "\\))". For example, "ss//aabbcc\\((..**\\))ddeeff//\\11//" deletes -the strings "aabbcc" and "ddeeff" from the matched pattern. - - The strings "\\ll", "\\uu", "\\LL" and "\\UU" can be used to -modify the case of elements in the replacement string. The -string "\\ll" causes the next character to be converted to -lowercase; the string "\\uu" behaves similarly, but converts -to uppercase (e.g. ss//aabbcc//\\UU&&// replaces the string aabbcc with -AABBCC). The strings "\\LL" causes characters up to the end of -the string or the next occurrence of the strings "\\ee" or -"\\EE" to be converted to lowercase; the string "\\UU" behaves -similarly, but converts to uppercase. - - If the entire replacement pattern is "%%", then the last -replacement pattern is used again. - - In vvii, inserting a <> into the replacement -string will cause the matched line to be split into two -lines at that point. (The <> will be discarded.) - -88.. GGeenneerraall EEddiittoorr DDeessccrriippttiioonn - - When eexx or vvii are executed, the text of a file is read -(or a temporary file is created), and then all editing -changes happen within the context of the copy of the file. -_N_o _c_h_a_n_g_e_s _a_f_f_e_c_t _t_h_e _a_c_t_u_a_l _f_i_l_e _u_n_t_i_l _t_h_e _f_i_l_e _i_s _w_r_i_t_t_e_n -_o_u_t, either using a write command or another command which -is affected by the aauuttoowwrriittee option. - - All files are locked (using the _f_l_o_c_k(2) or _f_c_n_t_l(2) -interfaces) during the edit session, to avoid inadvertently -making modifications to multiple copies of the file. If a -lock cannot be obtained for a file because it is locked by -another process, the edit session is read-only (as if the -rreeaaddoonnllyy option or the --RR flag had been specified). If a -lock cannot be obtained for other reasons, the edit session -will continue, but the file status information (see the -<> command) will reflect this fact. - - Both eexx and vvii are modeful editors, i.e. they have two -modes, "command" mode and "text input" mode. The former is -intended to permit you to enter commands which modifies -already existing text. The latter is intended to permit you -to enter new text. When eexx first starts running, it is in -command mode, and usually displays a prompt (see the pprroommpptt -option for more information). The prompt is a single colon -("::") character. There are three commands that switch eexx -into text input mode: aappppeenndd, cchhaannggee and iinnsseerrtt. Once in -input mode, entering a line containing only a single period -("..") terminates text input mode and returns to command - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--1111 - - -mode, where the prompt is redisplayed. - - When vvii first starts running, it is in command mode as -well. There are eleven commands that switch vvii into text -input mode: AA, aa, CC, cc, II, ii, OO, oo, RR, SS and ss. Once in -input mode, entering an <> character terminates text -input mode and returns to command mode. - - The following words have special meanings in both the -eexx and vvii command descriptions: - -<> - The interrupt character is used to interrupt the cur- - rent operation. Normally <>, whatever charac- - ter is set for the current terminal is used. - -<> - The literal next character is used to escape the subse- - quent character from any special meaning. This charac- - ter is always <>. If the terminal is not set - up to do XON/XOFF flow control, then <> is - used to mean literal next as well. - -ccuurrrreenntt ppaatthhnnaammee - The pathname of the file currently being edited by vi. - When the percent character ("%%") appears in a file name - entered as part of an eexx command argument, it is - replaced by the current pathname. (The "%%" character - can be escaped by preceding it with a backslash.) - -aalltteerrnnaattee ppaatthhnnaammee - The name of the last file name mentioned in an eexx com- - mand, or, the previous current pathname if the last - file mentioned becomes the current file. When the hash - mark character ("##") appears in a file name entered as - part of an eexx command argument, it is replaced by the - alternate pathname. (The "##" character can be escaped - by preceding it with a backslash.) - -bbuuffffeerr - One of a number of named areas for saving copies of - text. Commands that change or delete text can save the - changed or deleted text into a specific buffer, for - later use, if the command allows it (i.e. the eexx cchhaannggee - command cannot save the changed text in a named - buffer). Buffers are named with a single character, - preceded by a double quote, e.g. ""<>. His- - toric implementations of eexx/vvii limited <> to - the alphanumeric characters; nneexx/nnvvii permits the use of - any character. - - Buffers named by uppercase characters are the same as - buffers named by lowercase characters, e.g. the buffer - - - - - - - - - - -UUSSDD::1133--1122 NNvvii//NNeexx RReeffeerreennccee - - - named by the English character "AA" is the same as the - buffer named by the character "aa", with the exception - that, if the buffer contents are being changed (as with - a text deletion or vvii cchhaannggee command), the text is - _a_p_p_e_n_d_e_d to the buffer, instead of replacing the cur- - rent contents. - - The buffers named by the numeric characters (in - English, "11" through "99"), are special, in that if at - least one line is changed or deleted in the file, (or a - command changes or deletes a region that crosses a line - boundary) a copy of the text is placed into the numeric - buffer "11", regardless of the user specifying another - buffer in which to save it. Before this copy is done, - the previous contents of buffer "11" are moved into - buffer "22", "22" into buffer "33", and so on. The con- - tents of buffer "99" are discarded. In vvii, text may be - explicitly stored into the numeric buffers. In this - case, the buffer rotation described above occurs before - the replacement of the buffer's contents. (Text cannot - be explicitly stored into the numeric buffers in eexx - because of ambiguities that this would cause in the eexx - command syntax.) - - When a vvii command synopsis shows both a [[bbuuffffeerr]] and a - [[ccoouunntt]], they may be presented in any order. - - Finally, all buffers are either "line" or "character" - oriented. All eexx commands which store text into - buffers are line oriented. Some vvii commands which - store text into buffers are line oriented, and some are - character oriented; the description for each applicable - vvii command notes whether text copied into buffers using - the command is line or character oriented. In addi- - tion, the vvii command ddiissppllaayy bbuuffffeerrss displays the cur- - rent orientation for each buffer. Generally, the only - importance attached to this orientation is that if the - buffer is subsequently inserted into the text, line - oriented buffers create new lines for each of the lines - they contain, and character oriented buffers create new - lines for any lines _o_t_h_e_r than the first and last lines - they contain. The first and last lines are inserted - into the text at the current cursor position, becoming - part of the current line. If there is more than one - line in the buffer, however, the current line itself - will be split. - -uunnnnaammeedd bbuuffffeerr - The unnamed buffer is a text storage area which is used - by commands that take a buffer as an argument, when no - buffer is specified by the user. There is no way to - explicitly reference this buffer. - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--1133 - - -99.. VVii DDeessccrriippttiioonn - - VVii takes up the entire screen to display the edited -file, except for the bottom line of the screen. The bottom -line of the screen is used to enter eexx commands, and for vvii -error and informational messages. If no other information -is being displayed, the default display can show the current -cursor row and cursor column, an indication of whether the -file has been modified, and the current mode of the editor. -See the rruulleerr, sshhoowwddiirrttyy and sshhoowwmmooddee options for more -information. - - Empty lines do not have any special representation on -the screen, but lines on the screen that would logically -come after the end of the file are displayed as a single -tilde ("~~") character. To differentiate between empty lines -and lines consisting of only whitespace characters, use the -lliisstt option. Historically, implementations of vvii have also -displayed some lines as single asterisk ("@@") characters. -These were lines that were not correctly displayed, i.e. -lines on the screen that did not correspond to lines in the -file, or lines that did not fit on the current screen. NNvvii -never displays lines in this fashion. - - VVii is a modeful editor, i.e. it has two modes, "com- -mand" mode and "text input" mode. When vvii first starts, it -is in command mode. There are several commands that change -vvii into text input mode. The <> character is used to -resolve the text input into the file, and exit back into -command mode. In vvii command mode, the cursor is always -positioned on the last column of characters which take up -more than one column on the screen. In vvii text insert mode, -the cursor is positioned on the first column of characters -which take up more than one column on the screen. - - Generally, if the cursor line and cursor column are not -on the screen, then the screen is scrolled (if the target -cursor is close) or repainted (if the target cursor is far -away) so that the cursor is on the screen. If the screen is -scrolled, it is moved a minimal amount, and the cursor line -will usually appear at the top or bottom of the screen. In -the screen is repainted, the cursor line will appear in the -center of the screen, unless the cursor is sufficiently -close to the beginning or end of the file that this is not -possible. If the lleeffttrriigghhtt option is set, the screen may be -scrolled or repainted in a horizontal direction as well as -in a vertical one. - - A major difference between the historical vvii presenta- -tion and nnvvii is in the scrolling and screen oriented posi- -tion commands, <>, <>, <>, <>, <>, <>, HH, LL and MM. In histori- -cal implementations of vvii, these commands acted on physical - - - - - - - - - - -UUSSDD::1133--1144 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - -(as opposed to logical, or screen) lines. For lines that -were sufficiently long in relation to the size of the -screen, this meant that single line scroll commands might -repaint the entire screen, scrolling or screen positioning -command might not change the screen or move the cursor at -all, and some lines simply could not be displayed, even -though vvii would edit the file that contained them. In nnvvii, -these commands act on logical, i.e. screen lines. You are -unlikely to notice any difference unless you are editing -files with lines significantly longer than a screen width. - - VVii keeps track of the currently "most attractive" cur- -sor position. Each command description (for commands that -can change the current cursor position), specifies if the -cursor is set to a specific location in the line, or if it -is moved to the "most attractive cursor position". The lat- -ter means that the cursor is moved to the cursor position -that is vertically as close as possible to the current cur- -sor position. If the current line is shorter than the cur- -sor position vvii would select, the cursor is positioned on -the last character in the line. (If the line is empty, the -cursor is positioned on the first column of the line.) If a -command moves the cursor to the most attractive position, it -does not alter the current cursor position, and a subsequent -movement will again attempt to move the cursor to that posi- -tion. Therefore, although a movement to a line shorter than -the currently most attractive position will cause the cursor -to move to the end of that line, a subsequent movement to a -longer line will cause the cursor to move back to the most -attractive position. - - In addition, the $$ command makes the end of each line -the most attractive cursor position rather than a specific -column. - - Each vvii command described below notes where the cursor -ends up after it is executed. This position is described in -terms of characters on the line, i.e. "the previous charac- -ter", or, "the last character in the line". This is to -avoid needing to continually refer to on what part of the -character the cursor rests. - - The following words have special meaning for vvii com- -mands. - -pprreevviioouuss ccoonntteexxtt - The position of the cursor before the command which - caused the last absolute movement was executed. Each - vvii command described in the next section that is con- - sidered an absolute movement is so noted. In addition, - specifying _a_n_y address to an eexx command is considered - an absolute movement. - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--1155 - - -mmoottiioonn - A second vvii command can be used as an optional trailing - argument to the vvii !!, <<, >>, cc, dd, yy, and (depending on - the ttiillddeeoopp option) ~~ commands. This command indicates - the end of the region of text that's affected by the - command. The motion command may be either the command - character repeated (in which case it means the current - line) or a cursor movement command. In the latter - case, the region affected by the command is from the - starting or stopping cursor position which comes first - in the file, to immediately before the starting or - stopping cursor position which comes later in the file. - Commands that operate on lines instead of using begin- - ning and ending cursor positions operate on all of the - lines that are wholly or partially in the region. In - addition, some other commands become line oriented - depending on where in the text they are used. The com- - mand descriptions below note these special cases. - - The following commands may all be used as motion compo- - nents for vvii commands: - - - <> <> <> <> - <> <> <> $$ - %% ''<> (( )) - ++ ,, -- // - 00 ;; ?? BB - EE FF GG HH - LL MM NN TT - WW [[[[ ]]]] ^^ - __ ``<> bb ee - ff hh jj kk - ll nn tt ww - {{ || }} - - - The optional count prefix available for some of the vvii - commands that take motion commands, or the count prefix - available for the vvii commands that are used as motion - components, may be included and is _a_l_w_a_y_s considered - part of the motion argument. For example, the commands - "cc22ww" and "22ccww" are equivalent, and the region affected - by the cc command is two words of text. In addition, if - the optional count prefix is specified for both the vvii - command and its motion component, the effect is multi- - plicative and is considered part of the motion argu- - ment. For example, the commands "44ccww" and "22cc22ww" are - equivalent, and the region affected by the cc command is - four words of text. - - - - - - - - - - - - - -UUSSDD::1133--1166 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - -ccoouunntt - A positive number used as an optional argument to most - commands, either to give a size or a position (for dis- - play or movement commands), or as a repeat count (for - commands that modify text). The count argument is - always optional and defaults to 1 unless otherwise - noted in the command description. - - When a vvii command synopsis shows both a [[bbuuffffeerr]] and - [[ccoouunntt]], they may be presented in any order. - -bbiiggwwoorrdd - A set of non-whitespace characters preceded and fol- - lowed by whitespace characters or the beginning or end - of the file or line. - - Groups of empty lines (or lines containing only whites- - pace characters) are treated as a single bigword. - -wwoorrdd - Generally, in languages where it is applicable, vvii rec- - ognizes two kinds of words. First, a sequence of let- - ters, digits and underscores, delimited at both ends - by: characters other than letters, digits, or under- - scores; the beginning or end of a line; the beginning - or end of the file. Second, a sequence of characters - other than letters, digits, underscores, or whitespace - characters, delimited at both ends by: a letter, digit, - underscore, or whitespace character; the beginning or - end of a line; the beginning or end of the file. - - Groups of empty lines (or lines containing only whites- - pace characters) are treated as a single word. - -ppaarraaggrraapphh - An area of text that begins with either the beginning - of a file, an empty line, or a section boundary, and - continues until either an empty line, section boundary, - or the end of the file. - - Groups of empty lines (or lines containing only whites- - pace characters) are treated as a single paragraph. - - Additional paragraph boundaries can be defined using - the ppaarraaggrraapphh option. - -sseeccttiioonn - An area of text that starts with the beginning of the - file or a line whose first character is an open brace - ("{{") and continues until the next section or the end - of the file. - - Additional section boundaries can be defined using the - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--1177 - - - sseeccttiioonnss option. - -sseenntteennccee - An area of text that begins with either the beginning - of the file or the first nonblank character following - the previous sentence, paragraph, or section boundary - and continues until the end of the file or a or a - period ("..") exclamation point ("!!") or question mark - ("??") character, followed by either an end-of-line or - two whitespace characters. Any number of closing - parentheses ("))"), brackets ("]]") or double-quote ("""") - characters can appear between the period, exclamation - point, or question mark and the whitespace characters - or end-of-line. - - Groups of empty lines (or lines containing only whites- - pace characters) are treated as a single sentence. - -1100.. VVii CCoommmmaannddss - - The following section describes the commands available -in the command mode of the vvii editor. In each entry below, -the tag line is a usage synopsis for the command character. -In addition, the final line and column the cursor rests -upon, and any options which affect the command are noted. - -[[ccoouunntt]] <> - Search forward ccoouunntt times for the current word. The - current word begins at the first non-whitespace charac- - ter on or after the current cursor position, and - extends up to the next non-word character or the end of - the line. The search is literal, i.e. no characters in - the word have any special meaning in terms of Regular - Expressions. It is an error if no matching pattern is - found between the starting position and the end of the - file. - - The <> command is an absolute movement. The - <> command may be used as the motion component - of other vvii commands, in which case any text copied - into a buffer is character oriented. - - Line: Set to the line where the word is found. - Column: Set to the first character of the word. - Options: Affected by the eexxtteennddeedd, iiggnnoorreeccaassee and wwrraapp-- - ssccaann options. - -[[ccoouunntt]] <> - Page backward ccoouunntt screens. Two lines of overlap are - maintained by displaying the window starting at line - ((ttoopp__lliinnee -- ccoouunntt ** wwiinnddooww__ssiizzee)) ++ 22, where wwiinnddooww__ssiizzee - is the value of the wwiinnddooww option. (In the case of - split screens, this size is corrected to the current - - - - - - - - - - -UUSSDD::1133--1188 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - screen size.) This is an error if the movement is past - the beginning of the file. - - The <> command is an absolute movement. - - Line: Set to the last line of text displayed on the - screen. - Column: Set to the first nonblank character of the - line. - Options: None. - -[[ccoouunntt]] <> - Scroll forward ccoouunntt lines. If ccoouunntt is not specified, - scroll forward the number of lines specified by the - last <> or <> command. If this is - the first <> or <> command, scroll - forward half the number of lines in the screen. (In - the case of split screens, the default scrolling dis- - tance is corrected to half the current screen size.) - This is an error if the movement is past the end of the - file. - - The <> command is an absolute movement. - - Line: Set to the current line plus the number of - lines scrolled. - Column: Set to the first nonblank character of the - line. - Options: None. - -[[ccoouunntt]] <> - Scroll forward ccoouunntt lines, leaving the cursor on the - current line and column, if possible. This is an error - if the movement is past the end of the file. - - Line: Unchanged unless the current line scrolls off - the screen, in which case it is set to the - first line on the screen. - Column: Unchanged unless the current line scrolls off - the screen, in which case it is set to the - most attractive cursor position. - Options: None. - -[[ccoouunntt]] <> - Page forward ccoouunntt screens. Two lines of overlap are - maintained by displaying the window starting at line - ttoopp__lliinnee ++ ccoouunntt ** wwiinnddooww__ssiizzee -- 22, where wwiinnddooww__ssiizzee - is the value of the wwiinnddooww option. (In the case of - split screens, this size is corrected to the current - screen size.) This is an error if the movement is past - the end of the file. - - The <> command is an absolute movement. - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--1199 - - - Line: Set to the first line on the screen. - Column: Set to the first nonblank character of the - current line. - Options: None. - -<> - Display the file information. The information includes - the current pathname, the current line, the number of - total lines in the file, the current line as a percent- - age of the total lines in the file, if the file has - been modified, was able to be locked, if the file's - name has been changed, and if the edit session is read- - only. - - Line: Unchanged. - Column: Unchanged. - Options: None. - -<> -[[ccoouunntt]] hh - Move the cursor back ccoouunntt characters in the current - line. This is an error if the cursor is on the first - character in the line. - - The <> and hh commands may be used as the - motion component of other vvii commands, in which case - any text copied into a buffer is character oriented. - - Line: Unchanged. - Column: Set to the ccuurrrreenntt -- ccoouunntt character, or, the - first character in the line if ccoouunntt is - greater than or equal to the number of charac- - ters in the line before the cursor. - Options: None. - -[[ccoouunntt]] <> -[[ccoouunntt]] <> -[[ccoouunntt]] jj - Move the cursor down ccoouunntt lines without changing the - current column. This is an error if the movement is - past the end of the file. - - The <>, <> and jj commands may be used - as the motion component of other vvii commands, in which - case any text copied into a buffer is line oriented. - - Line: Set to the current line plus ccoouunntt. - Column: The most attractive cursor position. - Options: None. - -<> -<> - Repaint the screen. - - - - - - - - - - -UUSSDD::1133--2200 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - Line: Unchanged. - Column: Unchanged. - Options: None. - -[[ccoouunntt]] <> -[[ccoouunntt]] ++ - Move the cursor down ccoouunntt lines to the first nonblank - character of that line. This is an error if the move- - ment is past the end of the file. - - The <> and ++ commands may be used as the - motion component of other vvii commands, in which case - any text copied into a buffer is line oriented. - - Line: Set to the current line plus ccoouunntt. - Column: Set to the first nonblank character in the - line. - Options: None. - -[[ccoouunntt]] <> -[[ccoouunntt]] kk - Move the cursor up ccoouunntt lines, without changing the - current column. This is an error if the movement is - past the beginning of the file. - - The <> and kk commands may be used as the - motion component of other vvii commands, in which case - any text copied into a buffer is line oriented. - - Line: Set to the current line minus count. - Column: The most attractive cursor position. - Options: None. - -<> - Return to the most recent tag context. The <> - command is an absolute movement. - - Line: Set to the context of the previous tag com- - mand. - Column: Set to the context of the previous tag com- - mand. - Options: None. - -<> - Scroll backward ccoouunntt lines. If ccoouunntt is not speci- - fied, scroll backward the number of lines specified by - the last <> or <> command. If this - is the first <> or <> command, scroll - backward half the number of lines in the screen. (In - the case of split screens, the default scrolling dis- - tance is corrected to half the current screen size.) - This is an error if the movement is past the beginning - of the file. - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--2211 - - - The <> command is an absolute movement. - - Line: Set to the current line minus the amount - scrolled. - Column: Set to the first nonblank character in the - line. - Options: None. - -<> - Switch to the next lower screen in the window, or, to - the first screen if there are no lower screens in the - window. - - Line: Set to the previous cursor position in the - window. - Column: Set to the previous cursor position in the - window. - Options: None. - -<> - Scroll backward ccoouunntt lines, leaving the current line - and column as is, if possible. This is an error if the - movement is past the beginning of the file. - - Line: Unchanged unless the current line scrolls off - the screen, in which case it is set to the - last line of text displayed on the screen. - Column: Unchanged unless the current line scrolls off - the screen, in which case it is the most - attractive cursor position. - Options: None. - -<> - Suspend the current editor session. If the file has - been modified since it was last completely written, and - the aauuttoowwrriittee option is set, the file is written before - the editor session is suspended. If this write fails, - the editor session is not suspended. - - Line: Unchanged. - Column: Unchanged. - Options: Affected by the aauuttoowwrriittee option. - -<> - Execute eexx commands or cancel partial commands. If an - eexx command is being entered (e.g. //, ??, :: or !!), the - command is executed. If a partial command has been - entered, e.g. or the command is cancelled. Otherwise, - it is an error. - - Line: When an eexx command is being executed, the cur- - rent line is set as described for that com- - mand. Otherwise, unchanged. - - - - - - - - - - -UUSSDD::1133--2222 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - Column: When an eexx command is being executed, the cur- - rent column is set as described for that com- - mand. Otherwise, unchanged. - Options: None. - -<> - Push a tag reference onto the tag stack. The tags - files (see the ttaaggss option for more information) are - searched for a tag matching the current word. The cur- - rent word begins at the first non-whitespace character - on or after the current cursor position, and extends up - to the next non-word character or the end of the line. - If a matching tag is found, the current file is dis- - carded and the file containing the tag reference is - edited. - - If the current file has been modified since it was last - completely written, the command will fail. The <> command is an absolute movement. - - Line: Set to the line containing the matching tag - string. - Column: Set to the start of the matching tag string. - Options: Affected by the ttaaggss and ttaagglleennggtthh options. - -<> - Switch to the most recently edited file. - - If the file has been modified since it was last com- - pletely written, and the aauuttoowwrriittee option is set, the - file is written out. If this write fails, the command - will fail. Otherwise, if the current file has been - modified since it was last completely written, the com- - mand will fail. - - Line: Set to the line the cursor was on when the - file was last edited. - Column: Set to the column the cursor was on when the - file was last edited. - Options: Affected by the aauuttoowwrriittee option. - -[[ccoouunntt]] <> -[[ccoouunntt]] ll - Move the cursor forward ccoouunntt characters without chang- - ing the current line. This is an error if the cursor - is on the last character in the line. - - The <> and ll commands may be used as the motion - component of other vvii commands, in which case any text - copied into a buffer is character oriented. In addi- - tion, these commands may be used as the motion compo- - nents of other commands when the cursor is on the last - character in the line, without error. - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--2233 - - - Line: Unchanged. - Column: Set to the current character plus the next - ccoouunntt characters, or to the last character on - the line if ccoouunntt is greater than the number - of characters in the line after the current - character. - Options: None. - -[[ccoouunntt]] !! mmoottiioonn sshheellll--aarrgguummeenntt((ss)) - Replace text with results from a shell command. Pass - the lines specified by the ccoouunntt and mmoottiioonn arguments - as standard input to the program named by the sshheellll - option, and replace those lines with the output (both - standard error and standard output) of that command. - - After the motion is entered, vvii prompts for arguments - to the shell command. - - Within those arguments, "%%" and "##" characters are - expanded to the current and alternate pathnames, - respectively. The "!!" character is expanded with the - command text of the previous !! or ::!! commands. - (Therefore, the command !!!! repeats the previous !! - command.) The special meanings of "%%", "##" and "!!" - can be overridden by escaping them with a backslash. - If no !! or ::!! command has yet been executed, it is an - error to use an unescaped "!!" character. The !! com- - mand does _n_o_t do shell expansion on the strings pro- - vided as arguments. If any of the above expansions - change the arguments the user entered, the command is - redisplayed at the bottom of the screen. - - VVii then executes the program named by the sshheellll option, - with a --cc flag followed by the arguments (which are - bundled into a single argument). - - The !! command is permitted in an empty file. - - If the file has been modified since it was last com- - pletely written, the !! command will warn you. - - Line: The first line of the replaced text. - Column: The first column of the replaced text. - Options: Affected by the sshheellll option. - -[[ccoouunntt]] ## ++||--||## - Increment or decrement the current number. The current - number begins at the first non-number character on or - before the current cursor position, or the beginning of - the line, and extends up to the first non-number char- - acter on or after the current cursor position or the - end of the line. If the trailing character is a ++, the - number is incremented by ccoouunntt. If the trailing - - - - - - - - - - -UUSSDD::1133--2244 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - character is a --, the number is decremented by ccoouunntt. - If the trailing character is a ##, the previous incre- - ment or decrement is repeated. - - The format of the number (decimal, hexadecimal, and - octal, and leading 0's) is retained unless the new - value cannot be represented in the previous format. - - Line: Unchanged. - Column: Set to the first character in the cursor word. - Options: None. - -[[ccoouunntt]] $$ - Move the cursor to the end of a line. If ccoouunntt is - specified, the cursor moves down ccoouunntt -- 11 lines. - - It is not an error to use the $$ command when the cursor - is on the last character in the line or when the line - is empty. - - The $$ command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented, unless the cursor is at, - or before the first nonblank character in the line, in - which case it is line oriented. It is not an error to - use the $$ command as a motion component when the cursor - is on the last character in the line, although it is an - error when the line is empty. - - Line: Set to the current line plus ccoouunntt minus 1. - Column: Set to the last character in the line. - Options: None. - -%% - Move to the matching character. The cursor moves to - the parenthesis or curly brace which _m_a_t_c_h_e_s the paren- - thesis or curly brace found at the current cursor posi- - tion or which is the closest one to the right of the - cursor on the line. It is an error to execute the %% - command on a line without a parenthesis or curly brace. - Historically, any ccoouunntt specified to the %% command was - ignored. - - The %% command is an absolute movement. The %% command - may be used as the motion component of other vvii com- - mands, in which case any text copied into a buffer is - character oriented, unless the starting point of the - region is at or before the first nonblank character on - its line, and the ending point is at or after the last - nonblank character on its line, in which case it is - line oriented. - - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--2255 - - - Line: Set to the line containing the matching char- - acter. - Column: Set to the matching character. - Options: None. - -&& - Repeat the previous substitution command on the current - line. - - Historically, any ccoouunntt specified to the && command was - ignored. - - Line: Unchanged. - Column: Unchanged if the cursor was on the last char- - acter in the line, otherwise, set to the first - nonblank character in the line. - Options: Affected by the eeddccoommppaattiibbllee, eexxtteennddeedd, - iiggnnoorreeccaassee and mmaaggiicc options. - -''<> -``<> - Return to a context marked by the character <>. If <> is the "''" or "``" character, - return to the previous context. If <> is any - other character, return to the context marked by that - character (see the mm command for more information). If - the command is the '' command, only the line value is - restored, and the cursor is placed on the first non- - blank character of that line. If the command is the `` - command, both the line and column values are restored. - - It is an error if the context no longer exists because - of line deletion. (Contexts follow lines that are - moved, or which are deleted and then restored.) - - The '' and `` commands are both absolute movements. They - may be used as a motion component for other vvii com- - mands. For the '' command, any text copied into a - buffer is line oriented. For the `` command, any text - copied into a buffer is character oriented, unless it - both starts and stops at the first character in the - line, in which case it is line oriented. In addition, - when using the `` command as a motion component, com- - mands which move backward and started at the first - character in the line, or move forward and ended at the - first character in the line, are corrected to the last - character of the starting and ending lines, respec- - tively. - - Line: Set to the line from the context. - Column: Set to the first nonblank character in the - line, for the '' command, and set to the con- - text's column for the `` command. - - - - - - - - - - -UUSSDD::1133--2266 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - Options: None. - -[[ccoouunntt]] (( - Back up ccoouunntt sentences. - - The (( command is an absolute movement. The (( command - may be used as the motion component of other vvii com- - mands, in which case any text copied into a buffer is - character oriented, unless the starting and stopping - points of the region are the first character in the - line, in which case it is line oriented. In the latter - case, the stopping point of the region is adjusted to - be the end of the line immediately before it, and not - the original cursor position. - - Line: Set to the line containing the beginning of - the sentence. - Column: Set to the first nonblank character of the - sentence. - Options: None. - -[[ccoouunntt]] )) - Move forward ccoouunntt sentences. - - The )) command is an absolute movement. The )) command - may be used as the motion component of other vvii com- - mands, in which case any text copied into a buffer is - character oriented, unless the starting point of the - region is the first character in the line, in which - case it is line oriented. In the latter case, if the - stopping point of the region is also the first charac- - ter in the line, it is adjusted to be the end of the - line immediately before it. - - Line: Set to the line containing the beginning of - the sentence. - Column: Set to the first nonblank character of the - sentence. - Options: None. - -[[ccoouunntt]] ,, - Reverse find character ccoouunntt times. Reverse the last - FF, ff, TT or tt command, searching the other way in the - line, ccoouunntt times. - - The ,, command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. - - Line: Unchanged. - Column: Set to the searched-for character. - Options: None. - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--2277 - - -[[ccoouunntt]] -- - Move to first nonblank of the previous line, ccoouunntt - times. - - This is an error if the movement is past the beginning - of the file. - - The -- command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is line oriented. - - Line: Set to the current line minus ccoouunntt. - Column: Set to the first nonblank character in the - line. - Options: None. - -[[ccoouunntt]] .. - Repeat the last vvii command that modified text. The - repeated command may be a command and motion component - combination. If ccoouunntt is specified, it replaces _b_o_t_h - the count specified for the repeated command, and, if - applicable, for the repeated motion component. If - ccoouunntt is not specified, the counts originally specified - to the command being repeated are used again. - - As a special case, if the .. command is executed imme- - diately after the uu command, the change log is rolled - forward or backward, depending on the action of the uu - command. - - Line: Set as described for the repeated command. - Column: Set as described for the repeated command. - Options: None. - -//RREE<> -//RREE// [[ooffffsseett]]<> -??RREE<> -??RREE?? [[ooffffsseett]]<> -NN -nn - Search forward or backward for a regular expression. - The commands beginning with a slash ("//") character are - forward searches, the commands beginning with a ques- - tion mark ("??") are backward searches. VVii prompts - with the leading character on the last line of the - screen for a string. It then searches forward or back- - ward in the file for the next occurrence of the string, - which is interpreted as a Basic Regular Expression. - - The // and ?? commands are absolute movements. They may - be used as the motion components of other vvii commands, - in which case any text copied into a buffer is charac- - ter oriented, unless the search started and ended on - - - - - - - - - - -UUSSDD::1133--2288 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - the first column of a line, in which case it is line - oriented. In addition, forward searches ending at the - first character of a line, and backward searches begin- - ning at the first character in the line, are corrected - to begin or end at the last character of the previous - line. (Note, forward and backward searches can occur - for both // and ?? commands, if the wwrraappssccaann option is - set.) - - If an offset from the matched line is specified (i.e. a - trailing "//" or "??" character is followed by a signed - offset), the buffer will always be line oriented (e.g. - "//ssttrriinngg//++00" will always guarantee a line orientation). - - The nn command repeats the previous search. - - The NN command repeats the previous search, but in the - reverse direction. - - Missing RE's (e.g. "////<>", "//<>", "????<>", or "??<>" search for the last search RE, in the indi- - cated direction. - - Searches may be interrupted using the <> char- - acter. - - Line: Set to the line in which the match occurred. - Column: Set to the first character of the matched - string. - Options: Affected by the eeddccoommppaattiibbllee, eexxtteennddeedd, - iiggnnoorreeccaassee, mmaaggiicc, and wwrraappssccaann options. - -00 - Move to the first character in the current line. It is - not an error to use the 00 command when the cursor is on - the first character in the line, - - The 00 command may be used as the motion component of - other vvii commands, in which case it is an error if the - cursor is on the first character in the line. - - Line: Unchanged. - Column: Set to the first character in the line. - Options: None. - -:: - Execute an ex command. VVii prompts for an eexx command on - the last line of the screen, using a colon ("::") char- - acter. The command is terminated by a <>, <> or <> character; all of these - characters may be escaped by using a <> - character. The command is then executed. - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--2299 - - - If the eexx command writes to the screen, vvii will prompt - the user for a <> before continuing when - the eexx command finishes. Large amounts of output from - the eexx command will be paged for the user, and the user - prompted for a <> or <> key to con- - tinue. In some cases, a quit (normally a "q" charac- - ter) or <> may be entered to interrupt the eexx - command. - - When the eexx command finishes, and the user is prompted - to resume visual mode, it is also possible to enter - another "::" character followed by another eexx command. - - Line: The current line is set as described for the - eexx command. - Column: The current column is set as described for the - eexx command. - Options: None. - -[[ccoouunntt]] ;; - Repeat the last character find ccoouunntt times. The last - character find is one of the FF, ff, TT or tt commands. - - The ;; command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. - - Line: Unchanged. - Column: Set to the searched-for character. - Options: None. - -[[ccoouunntt]] << mmoottiioonn -[[ccoouunntt]] >> mmoottiioonn - Shift lines left or right. Shift the number of lines - in the region specified by the motion component, times - ccoouunntt, left (for the << command) or right (for the >> - command) by the number of columns specified by the - sshhiiffttwwiiddtthh option. Only whitespace characters are - deleted when shifting left; once the first character in - the line contains a nonblank character, the sshhiifftt will - succeed, but the line will not be modified. - - Line: Unchanged. - Column: Set to the first nonblank character in the - line. - Options: Affected by the sshhiiffttwwiiddtthh option. - -@@ bbuuffffeerr - Execute a named buffer. Execute the named buffer as vvii - commands. The buffer may include eexx commands, too, but - they must be expressed as a :: command. If the buffer - is line oriented, <> characters are logically - appended to each line of the buffer. If the buffer is - - - - - - - - - - -UUSSDD::1133--3300 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - character oriented, <> characters are logically - appended to all but the last line in the buffer. - - If the buffer name is "@@", or "**", then the last buffer - executed shall be used. It is an error to specify "@@@@" - or "****" if there were no buffer previous executions. - The text of a macro may contain an @@ command, and it is - possible to create infinite loops in this manner. (The - <> character may be used to interrupt the - loop.) - - Line: The current line is set as described for the - command(s). - Column: The current column is set as described for the - command(s). - Options: None. - -[[ccoouunntt]] AA - Enter input mode, appending the text after the end of - the line. If ccoouunntt is specified, the text is repeat- - edly input ccoouunntt -- 11 more times after input mode is - exited. - - Line: Set to the last line upon which characters - were entered. - Column: Set to the last character entered. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, bbeeaauu-- - ttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraappmmaarrggiinn - options. - -[[ccoouunntt]] BB - Move backward ccoouunntt bigwords. Move the cursor backward - to the beginning of a bigword by repeating the follow- - ing algorithm: if the current position is at the begin- - ning of a bigword or the character at the current posi- - tion cannot be part of a bigword, move to the first - character of the preceding bigword. Otherwise, move to - the first character of the bigword at the current posi- - tion. If no preceding bigword exists on the current - line, move to the first character of the last bigword - on the first preceding line that contains a bigword. - - The BB command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. - - Line: Set to the line containing the word selected. - Column: Set to the first character of the word - selected. - Options: None. - -[[bbuuffffeerr]] [[ccoouunntt]] CC - Change text from the current position to the end-of- - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--3311 - - - line. If ccoouunntt is specified, the input text replaces - from the current position to the end-of-line, plus - ccoouunntt -- 11 subsequent lines. - - Line: Set to the last line upon which characters - were entered. - Column: Set to the last character entered. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, bbeeaauu-- - ttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraappmmaarrggiinn - options. - -[[bbuuffffeerr]] DD - Delete text from the current position to the end-of- - line. - - It is not an error to execute the DD command on an empty - line. - - Line: Unchanged. - Column: Set to the character before the current char- - acter, or, column 1 if the cursor was on col- - umn 1. - Options: None. - -[[ccoouunntt]] EE - Move forward ccoouunntt end-of-bigwords. Move the cursor - forward to the end of a bigword by repeating the fol- - lowing algorithm: if the current position is the end of - a bigword or the character at that position cannot be - part of a bigword, move to the last character of the - following bigword. Otherwise, move to the last charac- - ter of the bigword at the current position. If no suc- - ceeding bigword exists on the current line, move to the - last character of the first bigword on the next follow- - ing line that contains a bigword. - - The EE command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. - - Line: Set to the line containing the word selected. - Column: Set to the last character of the word - selected. - Options: None. - -[[ccoouunntt]] FF <> - Search ccoouunntt times backward through the current line - for <>. - - The FF command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. - - - - - - - - - - - -UUSSDD::1133--3322 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - Line: Unchanged. - Column: Set to the searched-for character. - Options: None. - -[[ccoouunntt]] GG - Move to line ccoouunntt, or the last line of the file if - ccoouunntt not specified. - - The GG command is an absolute movement. The GG command - may be used as the motion component of other vvii com- - mands, in which case any text copied into a buffer is - line oriented. - - Line: Set to ccoouunntt, if specified, otherwise, the - last line. - Column: Set to the first nonblank character in the - line. - Options: None. - -[[ccoouunntt]] HH - Move to the screen line ccoouunntt -- 11 lines below the top - of the screen. - - The HH command is an absolute movement. The HH command - may be used as the motion component of other vvii com- - mands, in which case any text copied into a buffer is - line oriented. - - Line: Set to the line ccoouunntt -- 11 lines below the top - of the screen. - Column: Set to the first nonblank character of the - _s_c_r_e_e_n line. - Options: None. - -[[ccoouunntt]] II - Enter input mode, inserting the text at the beginning - of the line. If ccoouunntt is specified, the text input is - repeatedly input ccoouunntt -- 11 more times. - - Line: Set to the last line upon which characters - were entered. - Column: Set to the last character entered. - Options: None. - -[[ccoouunntt]] JJ - Join lines. If ccoouunntt is specified, ccoouunntt lines are - joined; a minimum of two lines are always joined, - regardless of the value of ccoouunntt. - - If the current line ends with a whitespace character, - all whitespace is stripped from the next line. Other- - wise, if the next line starts with a open parenthesis - ("((") do nothing. Otherwise, if the current line ends - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--3333 - - - with a question mark ("??"), period ("..") or exclama- - tion point ("!!"), insert two spaces. Otherwise, insert - a single space. - - It is not an error to join lines past the end of the - file, i.e. lines that do not exist. - - Line: Unchanged. - Column: Set to the character after the last character - of the next-to-last joined line. - Options: None. - -[[ccoouunntt]] LL - Move to the screen line ccoouunntt -- 11 lines above the bot- - tom of the screen. - - The LL command is an absolute movement. The LL command - may be used as the motion component of other vvii com- - mands, in which case any text copied into a buffer is - line oriented. - - Line: Set to the line ccoouunntt -- 11 lines above the bot- - tom of the screen. - Column: Set to the first nonblank character of the - _s_c_r_e_e_n line. - Options: None. - - MM - Move to the screen line in the middle of the screen. - - The MM command is an absolute movement. The MM command - may be used as the motion component of other vvii com- - mands, in which case any text copied into a buffer is - line oriented. - - Historically, any ccoouunntt specified to the MM command was - ignored. - - Line: Set to the line in the middle of the screen. - Column: Set to the first nonblank character of the - _s_c_r_e_e_n line. - Options: None. - -[[ccoouunntt]] OO - Enter input mode, appending text in a new line above - the current line. If ccoouunntt is specified, the text - input is repeatedly input ccoouunntt -- 11 more times. - - Historically, any ccoouunntt specified to the OO command was - ignored. - - Line: Set to the last line upon which characters - were entered. - - - - - - - - - - -UUSSDD::1133--3344 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - Column: Set to the last character entered. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, bbeeaauu-- - ttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraappmmaarrggiinn - options. - -[[bbuuffffeerr]] PP - Insert text from a buffer. Text from the buffer (the - unnamed buffer by default) is inserted before the cur- - rent column or, if the buffer is line oriented, before - the current line. - - Line: Set to the lowest numbered line insert, if the - buffer is line oriented, otherwise unchanged. - Column: Set to the first nonblank character of the - appended text, if the buffer is line oriented, - otherwise, the last character of the appended - text. - Options: None. - -QQ - Exit vvii (or visual) mode and switch to eexx mode. - - Line: Unchanged. - Column: No longer relevant. - Options: None. - -[[ccoouunntt]] RR - Enter input mode, replacing the characters in the cur- - rent line. If ccoouunntt is specified, the text input is - repeatedly input ccoouunntt -- 11 more times. - - If the end of the current line is reached, no more - characters are replaced and any further characters - input are appended to the line. - - Line: Set to the last line upon which characters - were entered. - Column: Set to the last character entered. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, bbeeaauu-- - ttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraappmmaarrggiinn - options. - -[[bbuuffffeerr]] [[ccoouunntt]] SS - Substitute ccoouunntt lines. - - Line: Set to the last line upon which characters - were entered. - Column: Set to the last character entered. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, bbeeaauu-- - ttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraappmmaarrggiinn - options. - - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--3355 - - -[[ccoouunntt]] TT <> - Search backward, ccoouunntt times, through the current line - for the character _a_f_t_e_r the specified <>. - - The TT command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. - - Line: Unchanged. - Column: Set to the character _a_f_t_e_r the searched-for - character. - Options: None. - -UU - Restore the current line to its state before the cursor - last moved to it. - - Line: Unchanged. - Column: The first character in the line. - Options: None. - -[[ccoouunntt]] WW - Move forward ccoouunntt bigwords. Move the cursor forward - to the beginning of a bigword by repeating the follow- - ing algorithm: if the current position is within a big- - word or the character at that position cannot be part - of a bigword, move to the first character of the next - bigword. If no subsequent bigword exists on the cur- - rent line, move to the first character of the first - bigword on the first following line that contains a - bigword. - - The WW command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. - - Line: The line containing the word selected. - Column: The first character of the word selected. - Options: None. - -[[bbuuffffeerr]] [[ccoouunntt]] XX - Delete ccoouunntt characters before the cursor. If the num- - ber of characters to be deleted is greater than or - equal to the number of characters to the beginning of - the line, all of the characters before the current cur- - sor position, to the beginning of the line, are - deleted. - - Line: Unchanged. - Column: Set to the current character minus ccoouunntt, or - the first character if count is greater than - the number of characters in the line before - the cursor. - - - - - - - - - - -UUSSDD::1133--3366 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - Options: None. - -[[bbuuffffeerr]] [[ccoouunntt]] YY - Copy (or "yank") ccoouunntt lines into the specified buffer. - - Line: Unchanged. - Column: Unchanged. - Options: None. - -ZZZZ - Write the file and exit vvii. The file is only written - if it has been modified since the last complete write - of the file to any file. - - The ZZZZ command will exit the editor after writing the - file, if there are no further files to edit. Entering - two "quit" commands (i.e. wwqq, qquuiitt, xxiitt or ZZZZ) in a - row will override this check and the editor will exit, - ignoring any files that have not yet been edited. - - Line: Unchanged. - Column: Unchanged. - Options: None. - -[[ccoouunntt]] [[[[ - Back up ccoouunntt section boundaries. - - The [[[[ command is an absolute movement. The [[[[ command - may be used as the motion component of other vvii com- - mands, in which case any text copied into a buffer is - character oriented, unless the starting position is - column 0, in which case it is line oriented. - - This is an error if the movement is past the beginning - of the file. - - Line: Set to the previous line that is ccoouunntt section - boundaries back, or the first line of the file - if no more section boundaries exist preceding - the current line. - Column: Set to the first nonblank character in the - line. - Options: Affected by the sseeccttiioonnss option. - -[[ccoouunntt]] ]]]] - Move forward ccoouunntt section boundaries. - - The ]]]] command is an absolute movement. The ]]]] command - may be used as the motion component of other vvii com- - mands, in which case any text copied into a buffer is - character oriented, unless the starting position is - column 0, in which case it is line oriented. - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--3377 - - - This is an error if the movement is past the end of the - file. - - Line: Set to the line that is ccoouunntt section bound- - aries forward, or to the last line of the file - if no more section boundaries exist following - the current line. - Column: Set to the first nonblank character in the - line. - Options: Affected by the sseeccttiioonnss option. - -^^ - Move to first nonblank character on the current line. - - The ^^ command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. - - Line: Unchanged. - Column: Set to the first nonblank character of the - current line. - Options: None. - -[[ccoouunntt]] __ - Move down ccoouunntt -- 11 lines, to the first nonblank char- - acter. The __ command may be used as the motion compo- - nent of other vvii commands, in which case any text - copied into a buffer is line oriented. - - It is not an error to execute the __ command when the - cursor is on the first character in the line. - - Line: The current line plus ccoouunntt -- 11. - Column: The first nonblank character in the line. - Options: None. - -[[ccoouunntt]] aa - Enter input mode, appending the text after the cursor. - If ccoouunntt is specified, the text input is repeatedly - input ccoouunntt -- 11 more times. - - Line: Set to the last line upon which characters - were entered. - Column: Set to the last character entered. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, bbeeaauu-- - ttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraappmmaarrggiinn - options. - -[[ccoouunntt]] bb - Move backward ccoouunntt words. Move the cursor backward to - the beginning of a word by repeating the following - algorithm: if the current position is at the beginning - of a word, move to the first character of the preceding - - - - - - - - - - -UUSSDD::1133--3388 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - word. Otherwise, the current position moves to the - first character of the word at the current position. - If no preceding word exists on the current line, move - to the first character of the last word on the first - preceding line that contains a word. - - The bb command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. - - Line: Set to the line containing the word selected. - Column: Set to the first character of the word - selected. - Options: None. - -[[bbuuffffeerr]] [[ccoouunntt]] cc mmoottiioonn - Change a region of text. If only part of a single line - is affected, then the last character being changed is - marked with a "$$". Otherwise, the region of text is - deleted, and input mode is entered. - - If ccoouunntt is specified, it is applied to the mmoottiioonn. - - Line: Set to the last line upon which characters - were entered. - Column: Set to the last character entered. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, bbeeaauu-- - ttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraappmmaarrggiinn - options. - -[[bbuuffffeerr]] [[ccoouunntt]] dd mmoottiioonn - Delete a region of text. If ccoouunntt is specified, it is - applied to the mmoottiioonn. - - Line: Set to the line where the region starts. - Column: Set to the first character in the line after - the last character in the region. If no such - character exists, set to the last character - before the region. - Options: None. - -[[ccoouunntt]] ee - Move forward ccoouunntt end-of-words. Move the cursor for- - ward to the end of a word by repeating the following - algorithm: if the current position is the end of a - word, move to the last character of the following word. - Otherwise, move to the last character of the word at - the current position. If no succeeding word exists on - the current line, move to the last character of the - first word on the next following line that contains a - word. - - The ee command may be used as the motion component of - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--3399 - - - other vvii commands, in which case any text copied into a - buffer is character oriented. - - Line: Set to the line containing the word selected. - Column: Set to the last character of the word - selected. - Options: None. - -[[ccoouunntt]] ff <> - Search forward, ccoouunntt times, through the rest of the - current line for <>. - - The ff command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. - - Line: Unchanged. - Column: Set to the searched-for character. - Options: None. - -[[ccoouunntt]] ii - Enter input mode, inserting the text before the cursor. - If ccoouunntt is specified, the text input is repeatedly - input ccoouunntt -- 11 more times. - - Line: Set to the last line upon which characters - were entered. - Column: Set to the last character entered. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, bbeeaauu-- - ttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraappmmaarrggiinn - options. - -mm <> - Save the current context (line and column) as <>. The exact position is referred to by "``<>". The line is referred to by "''<>". - - Historically, <> was restricted to lower-case - letters only, nnvvii permits the use of any character. - - Line: Unchanged. - Column: Unchanged. - Options: None. - -[[ccoouunntt]] oo - Enter input mode, appending text in a new line under - the current line. If ccoouunntt is specified, the text - input is repeatedly input ccoouunntt -- 11 more times. - - Historically, any ccoouunntt specified to the oo command was - ignored. - - - - - - - - - - - - -UUSSDD::1133--4400 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - Line: Set to the last line upon which characters - were entered. - Column: Set to the last character entered. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, bbeeaauu-- - ttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraappmmaarrggiinn - options. - -[[bbuuffffeerr]] pp - Append text from a buffer. Text from the buffer (the - unnamed buffer by default) is appended after the cur- - rent column or, if the buffer is line oriented, after - the current line. - - Line: Set to the first line appended, if the buffer - is line oriented, otherwise unchanged. - Column: Set to the first nonblank character of the - appended text if the buffer is line oriented, - otherwise, the last character of the appended - text. - Options: None. - -[[ccoouunntt]] rr <> - Replace characters. The next ccoouunntt characters in the - line are replaced with <>. Replacing charac- - ters with <> characters results in creating new, - empty lines into the file. - - If <> is <>, the command is cancelled. - - Line: Unchanged unless the replacement character is - a <>, in which case it is set to the - current line plus ccoouunntt -- 11. - Column: Set to the last character replaced, unless the - replacement character is a <>, in which - case the cursor is in column 1 of the last - line inserted. - Options: None. - -[[bbuuffffeerr]] [[ccoouunntt]] ss - Substitute ccoouunntt characters in the current line start- - ing with the current character. - - Line: Set to the last line upon which characters - were entered. - Column: Set to the last character entered. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, bbeeaauu-- - ttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraappmmaarrggiinn - options. - -[[ccoouunntt]] tt <> - Search forward, ccoouunntt times, through the current line - for the character immediately _b_e_f_o_r_e <>. - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--4411 - - - The tt command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. - - Line: Unchanged. - Column: Set to the character _b_e_f_o_r_e the searched-for - character. - Options: None. - -uu - Undo the last change made to the file. If repeated, - the uu command alternates between these two states, and - is its own inverse. When used after an insert that - inserted text on more than one line, the lines are - saved in the numeric buffers. - - The .. command, when used immediately after the uu com- - mand, causes the change log to be rolled forward or - backward, depending on the action of the uu command. - - Line: Set to the position of the first line changed, - if the reversal affects only one line or rep- - resents an addition or change; otherwise, the - line preceding the deleted text. - Column: Set to the cursor position before the change - was made. - Options: None. - -[[ccoouunntt]] ww - Move forward ccoouunntt words. Move the cursor forward to - the beginning of a word by repeating the following - algorithm: if the current position is at the beginning - of a word, move to the first character of the next - word. If no subsequent word exists on the current - line, move to the first character of the first word on - the first following line that contains a word. - - The ww command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. - - Line: Set to the line containing the word selected. - Column: Set to the first character of the word - selected. - Options: None. - -[[bbuuffffeerr]] [[ccoouunntt]] xx - Delete ccoouunntt characters. The deletion is at the cur- - rent character position. If the number of characters - to be deleted is greater than or equal to the number of - characters to the end of the line, all of the charac- - ters from the current cursor position to the end of the - line are deleted. - - - - - - - - - - -UUSSDD::1133--4422 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - Line: Unchanged. - Column: Unchanged unless the last character in the - line is deleted and the cursor is not already - on the first character in the line, in which - case it is set to the previous character. - Options: None. - -[[bbuuffffeerr]] [[ccoouunntt]] yy mmoottiioonn - Copy (or "yank") a text region specified by the ccoouunntt - and motion into a buffer. If ccoouunntt is specified, it is - applied to the mmoottiioonn. - - Line: Unchanged, unless the region covers more than - a single line, in which case it is set to the - line where the region starts. - Column: Unchanged, unless the region covers more than - a single line, in which case it is set to the - character were the region starts. - Options: None. - -[[ccoouunntt11]] zz [[ccoouunntt22]] ttyyppee - Redraw the screen with a window ccoouunntt22 lines long, with - line ccoouunntt11 placed as specified by the ttyyppee character. - If ccoouunntt11 is not specified, it defaults to the current - line. If ccoouunntt22 is not specified, it defaults to the - current window size. - - The following ttyyppee characters may be used: - - + If ccoouunntt11 is specified, place the line ccoouunntt11 - at the top of the screen. Otherwise, display - the screen after the current screen, similarly - to the <> command. - - Place the line ccoouunntt11 at the top of the - screen. - . Place the line ccoouunntt11 in the center of the - screen. - - Place the line ccoouunntt11 at the bottom of the - screen. - ^ If ccoouunntt11 is specified, place the line that is - at the top of the screen when ccoouunntt11 is at the - bottom of the screen, at the bottom of the - screen, i.e. display the screen before the - screen before ccoouunntt11. Otherwise, display the - screen before the current screen, similarly to - the <> command. - - Line: Set to ccoouunntt11 unless ccoouunntt11 is not specified - and the ttyyppee character was either "^^" or "++", - in which case it is set to the line before the - first line on the previous screen or the line - after the last line on the previous screen, - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--4433 - - - respectively. - Column: Set to the first nonblank character in the - line. - Options: None. - -[[ccoouunntt]] {{ - Move backward ccoouunntt paragraphs. - - The {{ command is an absolute movement. The {{ command - may be used as the motion component of other vvii com- - mands, in which case any text copied into a buffer is - character oriented, unless the starting character is - the first character on its line, in which case it is - line oriented. - - Line: Set to the line containing the beginning of - the previous paragraph. - Column: Set to the first nonblank character in the - line. - Options: Affected by the ppaarraaggrraapphh option. - -[[ccoouunntt]] || - Move to a specific _c_o_l_u_m_n position on the current line. - - The || command may be used as the motion component of - other vvii commands, in which case any text copied into a - buffer is character oriented. It is an error to use - the || command as a motion component and for the cursor - not to move. - - Line: Unchanged. - Column: Set to the character occupying the column - position identified by ccoouunntt, if the position - exists in the line. If the column length of - the current line is less than ccoouunntt, the cur- - sor is moved to the last character in the - line. - Options: None. - -[[ccoouunntt]] }} - Move forward ccoouunntt paragraphs. - - The }} command is an absolute movement. The }} command - may be used as the motion component of other vvii com- - mands, in which case any text copied into a buffer is - character oriented, unless the starting character is at - or before any nonblank characters in its line, in which - case it is line oriented. - - Line: Set to the line containing the beginning of - the next paragraph. - Column: Set to the first nonblank character in the - line. - - - - - - - - - - -UUSSDD::1133--4444 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - Options: Affected by the ppaarraaggrraapphh option. - -[[ccoouunntt]] ~~ - Reverse the case of the next ccoouunntt character(s). This - is the historic semantic for the ~~ command and it is - only in effect if the ttiillddeeoopp option is not set. - - Lowercase alphabetic characters are changed to upper- - case, and uppercase characters are changed to lower- - case. No other characters are affected. - - Historically, the ~~ command did not take an associated - count, nor did it move past the end of the current - line. As it had no associated motion it was difficult - to change the case of large blocks of text. In nnvvii, if - the cursor is on the last character of a line, and - there are more lines in the file, the cursor moves to - the next line. - - It is not an error to specify a count larger than the - number of characters between the cursor and the end of - the file. - - Line: Set to the line of the character after ccoouunntt - characters, or, end of file. - Column: Set to the character after ccoouunntt characters, - or, end-of-file. - Options: Affected by the ttiillddeeoopp option. - -[[ccoouunntt]] ~~ mmoottiioonn - Reverse the case of the characters in a text region - specified by the ccoouunntt and mmoottiioonn. Only in effect if - the ttiillddeeoopp option is set. - - Lowercase characters are changed to uppercase, and - uppercase characters are changed to lowercase. No - other characters are affected. - - Line: Set to the line of the character after the - last character in the region. - Column: Set to the character after the last character - in the region. - Options: Affected by the ttiillddeeoopp option. - -<> - Interrupt the current operation. Many of the poten- - tially long-running vvii commands may be interrupted - using the terminal interrupt character. These opera- - tions include searches, file reading and writing, fil- - ter operations and map character expansion. Interrupts - are also enabled when running commands outside of vvii. - - If the <> character is used to interrupt while - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--4455 - - - entering an eexx command, the command is aborted, the - cursor returns to its previous position, and vvii remains - in command mode. - - Generally, if the <> character is used to - interrupt any operation, any changes made before the - interrupt are left in place. - - Line: Dependent on the operation being interrupted. - Column: Dependent on the operation being interrupted. - Options: None. - - 1111.. VVii TTeexxtt IInnppuutt CCoommmmaannddss - - The following section describes the commands - available in the text input mode of the vvii editor. - - Historically, vvii implementations only permitted - the characters inserted on the current line to be - erased. In addition, only the <> erase char- - acter and the "00<>" and "^^<>" erase - strings could erase autoindent characters. This imple- - mentation permits erasure to continue past the begin- - ning of the current line, and back to where text input - mode was entered. In addition, autoindent characters - may be erased using the standard erase characters. For - the line and word erase characters, reaching the - autoindent characters forms a "soft" boundary, denoting - the end of the current word or line erase. Repeating - the word or line erase key will erase the autoindent - characters. - - Historically, vvii always used <> and <> as character and word erase characters, respec- - tively, regardless of the current terminal settings. - This implementation accepts, in addition to these two - characters, the current terminal characters for those - operations. - - <> - If the first character of the input is a <>, - the previous input is replayed, as if just - entered. - - <> - If the previous character on the line was an - autoindent character, erase it. Otherwise, if the - user is entering the first character in the line, - <> is ignored. Otherwise, a literal - <> character is entered. - - ^^<> - If the previous character on the line was an - - - - - - - - - - -UUSSDD::1133--4466 NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) - - - autoindent character, erase all of the autoindent - characters on the line. In addition, the autoin- - dent level is reset to 0. - - 00<> - If the previous character on the line was an - autoindent character, erase all of the autoindent - characters on the line. - - <> - Insert sufficient <> and <> characters to - move the cursor forward to a column immediately - after the next column which is an even multiple of - the sshhiiffttwwiiddtthh option. - - Historically, vvii did not permit the <> - command to be used unless the cursor was at the - first column of a new line or it was preceded only - by autoindent characters. NNvvii permits it to be - used at any time during insert mode. - - <> - <> - Erase the last character. - - <> - Quote the next character. The next character will - not be mapped (see the mmaapp command for more infor- - mation) or interpreted specially. A carat ("^^") - character will be displayed immediately as a - placeholder, but will be replaced by the next - character. - - <> - Resolve all text input into the file, and return - to command mode. - - <> - Erase the current line. - - <> - <> - Erase the last word. The definition of word is - dependent on the aallttwweerraassee and ttttyywweerraassee options. - - <>[[00--99AA--FFaa--ff]]** - Insert a character with the specified hexadecimal - value into the text. - - <> - Interrupt text input mode, returning to command - mode. If the <> character is used to - interrupt inserting text into the file, it is as - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((VVii CCoommmmaannddss)) UUSSDD::1133--4477 - - - if the <> character was used; all text input - up to the interruption is resolved into the file. - - 1122.. EExx AAddddrreessssiinngg - - Addressing in eexx (and when eexx commands are exe- - cuted from vvii) relates to the current line. In gen- - eral, the current line is the last line affected by a - command. The exact effect on the current line is dis- - cussed under the description of each command. When the - file contains no lines, the current line is zero. - - Addresses are constructed by one or more of the - following methods: - - (1) The address ".." refers to the current line. - - (2) The address "$$" refers to the last line of the - file. - - (3) The address "NN", where NN is a positive number, - refers to the N-th line of the file. - - (4) The address "''<>" or "``<>" - refers to the line marked with the name <>. (See the kk or mm commands for more infor- - mation on how to mark lines.) - - (5) A regular expression (RE) enclosed by slashes - ("//") is an address, and it refers to the first - line found by searching forward from the line - _a_f_t_e_r the current line toward the end of the - file, and stopping at the first line containing - a string matching the RE. (The trailing slash - can be omitted at the end of the command line.) - - If no RE is specified, i.e. the pattern is "////", - the last RE used in any command is used in the - search. - - If the eexxtteennddeedd option is set, the RE is handled - as an extended RE, not a basic RE. If the wwrraapp-- - ssccaann option is set, the search wraps around to - the beginning of the file and continues up to - and including the current line, so that the - entire file is searched. - - The form "\\//" is accepted for historic reasons, - and is identical to "////". - - (6) An RE enclosed in question marks ("??") - addresses the first line found by searching - backward from the line _p_r_e_c_e_d_i_n_g the current - - - - - - - - - - -UUSSDD::1133--4488 NNvvii//NNeexx RReeffeerreennccee - - - line, toward the beginning of the file and stop- - ping at the first line containing a string - matching the RE. (The trailing question mark - can be omitted at the end of a command line.) - - If no RE is specified, i.e. the pattern is "????", - the last RE used in any command is used in the - search. - - If the eexxtteennddeedd option is set, the RE is handled - as an extended RE, not a basic RE. If the wwrraapp-- - ssccaann option is set, the search wraps around - from the beginning of the file to the end of the - file and continues up to and including the cur- - rent line, so that the entire file is searched. - - The form "\\??" is accepted for historic reasons, - and is identical to "????". - - (7) An address followed by a plus sign ("++") or a - minus sign ("--") followed by a number is an off- - set address and refers to the address plus (or - minus) the indicated number of lines. If the - address is omitted, the addition or subtraction - is done with respect to the current line. - - (8) An address of "++" or "--" followed by a number is - an offset from the current line. For example, - "--55" is the same as "..--55". - - (9) An address ending with "++" or "--" has 1 added to - or subtracted from the address, respectively. - As a consequence of this rule and of the previ- - ous rule, the address "--" refers to the line - preceding the current line. Moreover, trailing - "++" and "--" characters have a cumulative effect. - For example, "++++--++++" refers to the current line - plus 3. - - (10) A percent sign ("%%") is equivalent to the - address range "11,,$$". - - EExx commands require zero, one, or two addresses. - It is an error to specify an address to a command which - requires zero addresses. - - If the user provides more than the expected number - of addresses to any eexx command, the first addresses - specified are discarded. For example, "11,,22,,33,,55"print - prints lines 3 through 5, because the pprriinntt command - only takes two addresses. - - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--4499 - - - The addresses in a range are separated from each - other by a comma (",,") or a semicolon (";;"). In the - latter case, the current line ("..") is set to the - first address, and only then is the second address cal- - culated. This feature can be used to determine the - starting line for forward and backward searches (see - rules (5) and (6) above). The second address of any - two-address sequence corresponds to a line that fol- - lows, in the file, the line corresponding to the first - address. The first address must be less than or equal - to the second address. The first address must be - greater than or equal to the first line of the file, - and the last address must be less than or equal to the - last line of the file. - - 1133.. EExx DDeessccrriippttiioonn - - The following words have special meanings for eexx - commands. - - <> - The end-of-file character is used to scroll the - screen in the eexx editor. This character is nor- - mally <>, however, whatever character is - set for the current terminal is used. - - lliinnee - A single-line address, given in any of the forms - described in the section entitled "EExx AAddddrreessssiinngg". - The default for lliinnee is the current line. - - rraannggee - A line, or a pair of line addresses, separated by - a comma or semicolon. (See the section entitled - "EExx AAddddrreessssiinngg" for more information.) The - default for range is the current line _o_n_l_y, i.e. - "..,,..". A percent sign ("%%") stands for the range - "11,,$$". The starting address must be less than, or - equal to, the ending address. - - ccoouunntt - A positive integer, specifying the number of lines - to be affected by the command; the default is 1. - Generally, a count past the end-of-file may be - specified, e.g. the command "pp 33000000" in a 10 line - file is acceptable, and will print from the cur- - rent line through the last line in the file. - - ffllaaggss - One or more of the characters "#", "p", and "l". - When a command that accepts these flags completes, - the addressed line(s) are written out as if by the - corresponding ##, ll or pp commands. In addition, - - - - - - - - - - -UUSSDD::1133--5500 NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) - - - any number of "++" or "--" characters can be speci- - fied before, after, or during the flags, in which - case the line written is not necessarily the one - affected by the command, but rather the line - addressed by the offset address specified. The - default for ffllaaggss is none. - - ffiillee - A pattern used to derive a pathname; the default - is the current file. File names are subjected to - normal _s_h(1) word expansions. - - Anywhere a file name is specified, it is also pos- - sible to use the special string "//ttmmpp". This will be - replaced with a temporary file name which can be used - for temporary work, e.g. "::ee //ttmmpp" creates and edits a - new file. - - If both a count and a range are specified for com- - mands that use either, the starting line for the com- - mand is the _l_a_s_t line addressed by the range, and - ccoouunntt- subsequent lines are affected by the command, - e.g. the command "22,,33pp44" prints out lines 3, 4, 5 and - 6. - - When only a line or range is specified, with no - command, the implied command is either a lliisstt, nnuummbbeerr - or pprriinntt command. The command used is the most recent - of the three commands to have been used (including any - use as a flag). If none of these commands have been - used before, the pprriinntt command is the implied command. - When no range or count is specified and the command - line is a blank line, the current line is incremented - by 1 and then the current line is displayed. - - Zero or more whitespace characters may precede or - follow the addresses, count, flags, or command name. - Any object following a command name (such as buffer, - file, etc.), that begins with an alphabetic character, - should be separated from the command name by at least - one whitespace character. - - Any character, including <>, "%%" - and "##" retain their literal value when preceded by a - backslash. - - 1144.. EExx CCoommmmaannddss - - The following section describes the commands - available in the eexx editor. In each entry below, the - tag line is a usage synopsis for the command. - - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) UUSSDD::1133--5511 - - - Each command can be entered as the abbreviation - (those characters in the synopsis command word preced- - ing the "[" character), the full command (all charac- - ters shown for the command word, omitting the "[" and - "]" characters), or any leading subset of the full com- - mand down to the abbreviation. For example, the args - command (shown as "aarr[[ggss]]" in the synopsis) can be - entered as "aarr", "aarrgg" or "aarrggss". - - Each eexx command described below notes the new cur- - rent line after it is executed, as well as any options - that affect the command. - - "" - A comment. Command lines beginning with the dou- - ble-quote character ("""") are ignored. This per- - mits comments in editor scripts and startup files. - - <> - Scroll the screen. Write the next N lines, where - N is the value of the ssccrroollll option. The command - is the end-of-file terminal character, which may - be different on different terminals. Tradition- - ally, it is the <> key. - - Historically, the eeooff command ignored any preced- - ing count, and the <> character was - ignored unless it was entered as the first charac- - ter of the command. This implementation treats it - as a command _o_n_l_y if entered as the first charac- - ter of the command line, and otherwise treats it - as any other character. - - Line: Set to the last line written. - Options: None. - - !! aarrgguummeenntt((ss)) - [[rraannggee]]!! aarrgguummeenntt((ss)) - Execute a shell command, or filter lines through a - shell command. In the first synopsis, the remain- - der of the line after the "!!" character is passed - to the program named by the sshheellll option, as a - single argument. - - Within the rest of the line, "%%" and "##" are - expanded into the current and alternate pathnames, - respectively. The character "!!" is expanded with - the command text of the previous !! command. - (Therefore, the command !!!! repeats the previous !! - command.) The special meanings of "%%", "##", and - "!!" can be overridden by escaping them with a - backslash. If no !! or ::!! command has yet been - executed, it is an error to use an unescaped "!!" - - - - - - - - - - -UUSSDD::1133--5522 NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) - - - character. The !! command does _n_o_t do shell - expansion on the strings provided as arguments. - If any of the above expansions change the command - the user entered, the command is redisplayed at - the bottom of the screen. - - EExx then executes the program named by the sshheellll - option, with a --cc flag followed by the arguments - (which are bundled into a single argument). - - The !! command is permitted in an empty file. - - If the file has been modified since it was last - completely written, the command will warn you. - - A single "!!" character is displayed when the com- - mand completes. - - In the second form of the !! command, the remain- - der of the line after the "!!" is passed to the - program named by the sshheellll option, as described - above. The specified lines are passed to the pro- - gram as standard input, and the standard and stan- - dard error output of the program replace the orig- - inal lines. - - Line: Unchanged if no range was specified, oth- - erwise set to the first line of the - range. - Options: Affected by the aauuttoowwrriittee and wwrriitteeaannyy - options. - - [[rraannggee]] nnuu[[mmbbeerr]] [[ccoouunntt]] [[ffllaaggss]] - [[rraannggee]] ## [[ccoouunntt]] [[ffllaaggss]] - Display the selected lines, each preceded with its - line number. - - The line number format is "%6d", followed by two - spaces. - - Line: Set to the last line displayed. - Options: None. - - @@ bbuuffffeerr - ** bbuuffffeerr - Execute a buffer. Each line in the named buffer - is executed as an eexx command. If no buffer is - specified, or if the specified buffer is "@@" or - "**", the last buffer executed is used. - - [[rraannggee]] <<[[<< ......]] [[ccoouunntt]] [[ffllaaggss]] - Shift lines left or right. The specified lines - are shifted to the left (for the << command) or - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) UUSSDD::1133--5533 - - - right (for the >> command), by the number of - columns specified by the sshhiiffttwwiiddtthh option. Only - leading whitespace characters are deleted when - shifting left; once the first column of the line - contains a nonblank character, the sshhiifftt command - will succeed, but the line will not be modified. - - If the command character << or >> is repeated more - than once, the command is repeated once for each - additional command character. - - Line: If the current line is set to one of the - lines that are affected by the command, - it is unchanged. Otherwise, it is set to - the first nonblank character of the low- - est numbered line shifted. - Options: Affected by the sshhiiffttwwiiddtthh option. - - [[lliinnee]] == [[ffllaaggss]] - Display the line number. Display the line number - of lliinnee (which defaults to the last line in the - file). - - Line: Unchanged. - Options: None. - - [[rraannggee]] >>[[>> ......]] [[ccoouunntt]] [[ffllaaggss]] - Shift right. The specified lines are shifted to - the right by the number of columns specified by - the sshhiiffttwwiiddtthh option, by inserting tab and space - characters. Empty lines are not changed. - - If the command character ">>" is repeated more than - once, the command is repeated once for each addi- - tional command character. - - Line: Set to the last line modified by the com- - mand. - Options: None. - - aabb[[bbrreevv]] llhhss rrhhss - Add an abbreviation to the current abbreviation - list. In vvii, if llhhss is entered such that it is - preceded and followed by characters that cannot be - part of a word, it is replaced by the string rrhhss. - - Line: Unchanged. - Options: None. - - [[lliinnee]] aa[[ppppeenndd]][[!!]] - The input text is appended to the specified line. - If line 0 is specified, the text is inserted at - the beginning of the file. Set to the last line - - - - - - - - - - -UUSSDD::1133--5544 NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) - - - input. If no lines are input, then set to lliinnee, - or to the first line of the file if a lliinnee of 0 - was specified. Following the command name with a - "!!" character causes the aauuttooiinnddeenntt option to be - toggled for the duration of the command. - - Line: Unchanged. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, - bbeeaauuttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraapp-- - mmaarrggiinn options. - - aarr[[ggss]] - Display the argument list. The current argument - is displayed inside of "[[" and "]]" characters. - The argument list is the list of operands speci- - fied on startup, which can be replaced using the - nneexxtt command. - - Line: Unchanged. - Options: None. - - bbgg - VVii mode only. Background the current screen. - - Line: Set to the current line when the screen - was last edited. - Options: None. - - [[rraannggee]] cc[[hhaannggee]][[!!]] [[ccoouunntt]] - Replace the lines with input text. Following the - command name with a "!!" character causes the - aauuttooiinnddeenntt option to be toggled for the duration - of the command. - - Line: Set to the last line input, or, if no - lines were input, set to the line before - the target line, or to the first line of - the file if there are no lines preceding - the target line. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, - bbeeaauuttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraapp-- - mmaarrggiinn options. - - cchhdd[[iirr]][[!!]] [[ddiirreeccttoorryy]] - ccdd[[!!]] [[ddiirreeccttoorryy]] - Change the current working directory. The ddiirreecc-- - ttoorryy argument is subjected to _s_h(1) word expan- - sions. When invoked with no directory argument - and the HHOOMMEE environment variable is set, the - directory named by the HHOOMMEE environment variable - becomes the new current directory. Otherwise, the - new current directory becomes the directory - returned by the _g_e_t_p_w_e_n_t(3) routine. - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) UUSSDD::1133--5555 - - - The cchhddiirr command will fail if the file has been - modified since the last complete write of the - file. You can override this check by appending a - "!!" character to the command. - - Line: Unchanged. - Options: Affected by the ccddppaatthh option. - - [[rraannggee]] ccoo[[ppyy]] lliinnee [[ffllaaggss]] - [[rraannggee]] tt lliinnee [[ffllaaggss]] - Copy the specified lines (range) after the desti- - nation line. Line 0 may be specified to insert - the lines at the beginning of the file. - - Line: Unchanged. - Options: None. - - [[rraannggee]] dd[[eelleettee]] [[bbuuffffeerr]] [[ccoouunntt]] [[ffllaaggss]] - Delete the lines from the file. The deleted text - is saved in the specified buffer, or, if no buffer - is specified, in the unnamed buffer. If the com- - mand name is followed by a letter that could be - interpreted as either a buffer name or a flag - value (because neither a ccoouunntt or ffllaaggss values - were given), eexx treats the letter as a ffllaaggss value - if the letter immediately follows the command - name, without any whitespace separation. If the - letter is preceded by whitespace characters, it - treats it as a buffer name. - - Line: Set to the line following the deleted - lines, or to the last line if the deleted - lines were at the end. - Options: None. - - ddii[[ssppllaayy]] bb[[uuffffeerrss]] || ss[[ccrreeeennss]] || tt[[aaggss]] - Display buffers, screens or tags. The ddiissppllaayy - command takes one of three additional arguments, - which are as follows: - - b[uffers] - Display all buffers (including named, - unnamed, and numeric) that contain text. - s[creens] - Display the file names of all background - screens. - t[ags] Display the tags stack. - - Line: Unchanged. - Options: None. - - ee[[ddiitt]][[!!]] [[++ccmmdd]] [[ffiillee]] - - - - - - - - - - - -UUSSDD::1133--5566 NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) - - - eexx[[!!]] [[++ccmmdd]] [[ffiillee]] - Edit a different file. If the current buffer has - been modified since the last complete write, the - command will fail. You can override this by - appending a "!!" character to the command name. - - If the "++ccmmdd" option is specified, that eexx command - will be executed in the new file. Any eexx command - may be used, although the most common use of this - feature is to specify a line number or search pat- - tern to set the initial location in the new file. - - Line: If you have previously edited the file, - the current line will be set to your last - position in the file. If that position - does not exist, or you have not previ- - ously edited the file, the current line - will be set to the first line of the file - if you are in vvii mode, and the last line - of the file if you are in eexx. - Options: Affected by the aauuttoowwrriittee and wwrriitteeaannyy - options. - - eexxuu[[ssaaggee]] [[ccoommmmaanndd]] - Display usage for an eexx command. If ccoommmmaanndd is - specified, a usage statement for that command is - displayed. Otherwise, usage statements for all eexx - commands are displayed. - - Line: Unchanged. - Options: None. - - ff[[iillee]] [[ffiillee]] - Display and optionally change the file name. If a - file name is specified, the current pathname is - changed to the specified name. The current path- - name, the number of lines, and the current posi- - tion in the file are displayed. - - Line: Unchanged. - Options: None. - - ffgg [[nnaammee]] - VVii mode only. Foreground the specified screen. - Swap the current screen with the specified back- - grounded screen. If no screen is specified, the - first background screen is foregrounded. - - Line: Set to the current line when the screen - was last edited. - Options: None. - - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) UUSSDD::1133--5577 - - - [[rraannggee]] gg[[lloobbaall]] //ppaatttteerrnn// [[ccoommmmaannddss]] - [[rraannggee]] vv //ppaatttteerrnn// [[ccoommmmaannddss]] - Apply commands to lines matching (or not matching) - a pattern. The lines within the given range that - match ("gg[[lloobbaall]]"), or do not match ("vv") the - given pattern are selected. Then, the specified - eexx command(s) are executed with the current line - ("..") set to each selected line. If no range is - specified, the entire file is searched for match- - ing, or not matching, lines. - - Multiple commands can be specified, one per line, - by escaping each <> character with a back- - slash, or by separating commands with a "||" char- - acter. If no commands are specified, the command - defaults to the pprriinntt command. - - For the aappppeenndd, cchhaannggee and iinnsseerrtt commands, the - input text must be part of the global command - line. In this case, the terminating period can be - omitted if it ends the commands. - - The vviissuuaall command may also be specified as one of - the eexx commands. In this mode, input is taken - from the terminal. Entering a QQ command in vvii - mode causes the next line matching the pattern to - be selected and vvii to be reentered, until the list - is exhausted. - - The gglloobbaall, vv and uunnddoo commands cannot be used as - part of these commands. - - The editor options aauuttoopprriinntt, aauuttooiinnddeenntt, and - rreeppoorrtt are turned off for the duration of the - gglloobbaall and vv commands. - - Line: The last line modified. - Options: None. - - hhee[[llpp]] - Display a help message. - - Line: Unchanged. - Options: None. - - [[lliinnee]] ii[[nnsseerrtt]][[!!]] - The input text is inserted before the specified - line. Following the command name with a "!!" - character causes the aauuttooiinnddeenntt option setting to - be toggled for the duration of this command. - - Line: Set to the last line input; if no lines - were input, set to the line before the - - - - - - - - - - -UUSSDD::1133--5588 NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) - - - target line, or to the first line of the - file if there are no lines preceding the - target line. - Options: Affected by the aallttwweerraassee, aauuttooiinnddeenntt, - bbeeaauuttiiffyy, sshhoowwmmaattcchh, ttttyywweerraassee and wwrraapp-- - mmaarrggiinn options. - - [[rraannggee]] jj[[ooiinn]][[!!]] [[ccoouunntt]] [[ffllaaggss]] - Join lines of text together. - - A ccoouunntt specified to the command specifies that - the last line of the rraannggee plus ccoouunntt subsequent - lines will be joined. (Note, this differs by one - from the general rule where only ccoouunntt- subsequent - lines are affected.) - - If the current line ends with a whitespace charac- - ter, all whitespace is stripped from the next - line. Otherwise, if the next line starts with a - open parenthesis ("(("), do nothing. Otherwise, if - the current line ends with a question mark ("??"), - period ("..") or exclamation point ("!!"), insert - two spaces. Otherwise, insert a single space. - - Appending a "!!" character to the command name - causes a simpler join with no white-space process- - ing. - - Line: Unchanged. - Options: None. - - [[rraannggee]] ll[[iisstt]] [[ccoouunntt]] [[ffllaaggss]] - Display the lines unambiguously. Tabs are dis- - played as "^^II", and the end of the line is marked - with a "$$" character. - - Line: Set to the last line displayed. - Options: None. - - mmaapp[[!!]] [[llhhss rrhhss]] - Define or display maps (for vvii only). - - If "llhhss" and "rrhhss" are not specified, the current - set of command mode maps are displayed. If a "!!" - character is appended to to the command, the text - input mode maps are displayed. - - Otherwise, when the "llhhss" character sequence is - entered in vvii, the action is as if the correspond- - ing "rrhhss" had been entered. If a "!!" character - is appended to the command name, the mapping is - effective during text input mode, otherwise, it is - effective during command mode. This allows "llhhss" - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) UUSSDD::1133--5599 - - - to have two different macro definitions at the - same time: one for command mode and one for input - mode. - - Whitespace characters require escaping with a - < character to be entered in the llhhss - string in visual mode. - - Normally, keys in the rrhhss string are remapped (see - the rreemmaapp option), and it is possible to create - infinite loops. However, keys which map to them- - selves are not further remapped, regardless of the - setting of the rreemmaapp option. For example, the - command "::mmaapp nn nnzz.." maps the "nn" key to the nn - and zz commands. - - To exit an infinitely looping map, use the termi- - nal <> character. - - Line: Unchanged. - Options: None. - - [[lliinnee]] mmaa[[rrkk]] <> - [[lliinnee]] kk <> - Mark the line with the mark <>. The - expressions "''<>" and "``<>" can - then be used as an address in any command that - uses one. - - Line: Unchanged. - Options: None. - - [[rraannggee]] mm[[oovvee]] lliinnee - Move the specified lines after the target line. A - target line of 0 places the lines at the beginning - of the file. - - Line: Set to the first of the moved lines. - Options: None. - - mmkk[[eexxrrcc]][[!!]] ffiillee - Write the abbreviations, editor options and maps - to the specified file. Information is written in - a form which can later be read back in using the - eexx ssoouurrccee command. If ffiillee already exists, the - mmkkeexxrrcc command will fail. This check can be over- - ridden by appending a "!!" character to the com- - mand. - - Line: Unchanged. - Options: None. - - - - - - - - - - - - -UUSSDD::1133--6600 NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) - - - nn[[eexxtt]][[!!]] [[ffiillee ......]] - Edit the next file from the argument list. The - nneexxtt command will fail if the file has been modi- - fied since the last complete write. This check - can be overridden by appending the "!!" character - to the command name. The argument list can - optionally be replaced by specifying a new one as - arguments to this command. In this case, editing - starts with the first file on the new list. - - Line: Set as described for the eeddiitt command. - Options: Affected by the options aauuttoowwrriittee and - wwrriitteeaannyy. - - [[lliinnee]] oo[[ppeenn]] //ppaatttteerrnn// [[ffllaaggss]] - Enter open mode. Open mode is the same as being - in vvii, but with a one-line window. All the stan- - dard vvii commands are available. If a match is - found for the optional RE argument, the cursor is - set to the start of the matching pattern. - - _T_h_i_s _c_o_m_m_a_n_d _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_. - - Line: Unchanged, unless the optional RE is - specified, in which case it is set to the - line where the matching pattern is found. - Options: Affected by the ooppeenn option. - - pprree[[sseerrvvee]] - Save the file in a form that can later be recov- - ered using the eexx --rr option. When the file is - preserved, an email message is sent to the user. - - Line: Unchanged. - Options: None. - - pprreevv[[iioouuss]][[!!]] - Edit the previous file from the argument list. - The pprreevviioouuss command will fail if the file has - been modified since the last complete write. This - check can be overridden by appending the "!!" - character to the command name. - - Line: Set as described for the eeddiitt command. - Options: Affected by the options aauuttoowwrriittee and - wwrriitteeaannyy. None. - - [[rraannggee]] pp[[rriinntt]] [[ccoouunntt]] [[ffllaaggss]] - Display the specified lines. - - Line: Set to the last line displayed. - Options: None. - - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) UUSSDD::1133--6611 - - - [[lliinnee]] ppuu[[tt]] [[bbuuffffeerr]] - Append buffer contents to the current line. If a - buffer is specified, its contents are appended to - the line, otherwise, the contents of the unnamed - buffer are used. - - Line: Set to the line after the current line. - Options: None. - - qq[[uuiitt]][[!!]] - End the editing session. If the file has been - modified since the last complete write, the qquuiitt - command will fail. This check may be overridden - by appending a "!!" character to the command. - - If there are more files to edit, the qquuiitt command - will fail. Appending a "!!" character to the com- - mand name or entering two qquuiitt commands (i.e. wwqq, - qquuiitt, xxiitt or ZZZZ) in a row) will override this - check and the editor will exit. - - Line: Unchanged. - Options: None. - - [[lliinnee]] rr[[eeaadd]][[!!]] [[ffiillee]] - Read a file. A copy of the specified file is - appended to the line. If lliinnee is 0, the copy is - inserted at the beginning of the file. If no file - is specified, the current file is read; if there - is no current file, then ffiillee becomes the current - file. If there is no current file and no ffiillee is - specified, then the rreeaadd command will fail. - - If ffiillee is preceded by a "!!" character, ffiillee is - treated as if it were a shell command, and passed - to the program named by the SSHHEELLLL environment - variable. The standard and standard error outputs - of that command are read into the file after the - specified line. The special meaning of the "!!" - character can be overridden by escaping it with a - backslash ("\\") character. - - Line: When executed from eexx, the current line - is set to the last line read. When exe- - cuted from vvii, the current line is set to - the first line read. - Options: None. - - rreecc[[oovveerr]] ffiillee - Recover ffiillee if it was previously saved. If no - saved file by that name exists, the rreeccoovveerr com- - mand behaves similarly to the eeddiitt command. - - - - - - - - - - - -UUSSDD::1133--6622 NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) - - - Line: Set as described for the eeddiitt command. - Options: None. - - rreess[[iizzee]] [[++||--]]ssiizzee - VVii mode only. Grow or shrink the current screen. - If ssiizzee is a positive, signed number, the current - screen is grown by that many lines. If ssiizzee is a - negative, signed number, the current screen is - shrunk by that many lines. If ssiizzee is not signed, - the current screen is set to the specified ssiizzee. - Applicable only to split screens. - - Line: Unchanged. - Options: None. - - rreeww[[iinndd]][[!!]] - Rewind the argument list. If the current file has - been modified since the last complete write, the - rreewwiinndd command will fail. This check may be over- - ridden by appending the "!!" character to the com- - mand. - - Otherwise, the current file is set to the first - file in the argument list. - - Line: Set as described for the eeddiitt command. - Options: Affected by the aauuttoowwrriittee and wwrriitteeaannyy - options. - - ssee[[tt]] [[ooppttiioonn[[==[[vvaalluuee]]]] ......]] [[nnooooppttiioonn ......]] [[ooppttiioonn?? - ......]] [[aallll]] - Display or set editor options. When no arguments - are specified, the editor option tteerrmm, and any - editor options whose values have been changed from - the default settings are displayed. If the argu- - ment aallll is specified, the values of all of editor - options are displayed. - - Specifying an option name followed by the charac- - ter "??" causes the current value of that option - to be displayed. The "??" can be separated from - the option name by whitespace characters. The "??" - is necessary only for Boolean valued options. - Boolean options can be given values by the form - "sseett ooppttiioonn" to turn them on, or "sseett nnooooppttiioonn" to - turn them off. String and numeric options can be - assigned by the form "sseett ooppttiioonn==vvaalluuee". Any - whitespace characters in strings can be included - literally by preceding each with a backslash. - More than one option can be set or listed by a - single set command, by specifying multiple argu- - ments, each separated from the next by whitespace - characters. - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) UUSSDD::1133--6633 - - - Line: Unchanged. - Options: None. - - sshh[[eellll]] - Run a shell program. The program named by the - sshheellll option is run with a --ii (for interactive) - flag. Editing is resumed when that program exits. - - Line: Unchanged. - Options: None. - - ssoo[[uurrccee]] ffiillee - Read and execute eexx commands from a file. SSoouurrccee - commands may be nested. - - Line: Unchanged. - Options: None. - - sspp[[lliitt]] [[ffiillee ......]] - VVii mode only. Split the screen. The current - screen is split into two screens, of approximately - equal size. If the cursor is in the lower half of - the screen, the screen will split up, i.e. the new - screen will be above the old one. If the cursor - is in the upper half of the screen, the new screen - will be below the old one. - - If ffiillee is specified, the new screen is editing - that file, otherwise, both screens are editing the - same file, and changes in each will be be - reflected in the other. The argument list for the - new screen consists of the list of files specified - as arguments to this command, or, the current - pathname if no files are specified. - - Line: If ffiillee is specified, set as for the eeddiitt - command, otherwise unchanged. - Options: None. - - [[rraannggee]] ss[[uubbssttiittuuttee]] [[//ppaatttteerrnn//rreeppllaaccee//]] [[ooppttiioonnss]] - [[ccoouunntt]] [[ffllaaggss]] - [[rraannggee]] && [[ooppttiioonnss]] [[ccoouunntt]] [[ffllaaggss]] - [[rraannggee]] ~~ [[ooppttiioonnss]] [[ccoouunntt]] [[ffllaaggss]] - Make substitutions. Replace the first instance of - ppaatttteerrnn with the string rreeppllaaccee on the specified - line(s). If the "//ppaatttteerrnn//rreeppll//" argument is not - specified, the "//ppaatttteerrnn//rreeppll//" from the previous - ssuubbssttiittuuttee command is used. - - If ooppttiioonnss includes the letter "cc" (confirm), you - will be prompted for confirmation before each - replacement is done. An affirmative response (in - English, a "yy" character) causes the replacement - - - - - - - - - - -UUSSDD::1133--6644 NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) - - - to be made. A quit response (in English, a "qq" - character) causes the ssuubbssttiittuuttee command to be - terminated. Any other response causes the - replacement not to be made, and the ssuubbssttiittuuttee - command continues. If ooppttiioonnss includes the letter - "gg" (global), all nonoverlapping instances of ppaatt-- - tteerrnn in the line are replaced. - - The && version of the command is the same as not - specifying a pattern or replacement string to the - ssuubbssttiittuuttee command, and the "&&" is replaced by the - pattern and replacement information from the pre- - vious substitute command. - - The ~~ version of the command is the same as && and - ss, except that the search pattern used is the last - RE used in _a_n_y command, not necessarily the one - used in the last ssuubbssttiittuuttee command. - - For example, in the sequence - - ss//rreedd//bblluuee// - //ggrreeeenn - ~~ - - the "~~" is equivalent to "ss//ggrreeeenn//bblluuee//". - - The ssuubbssttiittuuttee command may be interrupted, using - the terminal interrupt character. All substitu- - tions completed before the interrupt are retained. - - Line: Set to the last line upon which a substi- - tution was made. - Options: None. - - ssuu[[ssppeenndd]][[!!]] - sstt[[oopp]][[!!]] - <> - Suspend the edit session. Appending a "!!" char- - acter to these commands turns off the aauuttoowwrriittee - option for the command. - - Line: Unchanged. - Options: Affected by the aauuttoowwrriittee option. - - ttaa[[gg]][[!!]] ttaaggssttrriinngg - Edit the file containing the specified tag. - Search for the tagstring, which can be in a dif- - ferent file. If the tag is in a different file, - then the new file is edited. If the current file - has been modified since the last complete write, - the ttaagg command will fail. This check can be - overridden by appending the "!!" character to the - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) UUSSDD::1133--6655 - - - command name. - - The ttaagg command searches for ttaaggssttrriinngg in the tags - file(s) specified by the option. (See _c_t_a_g_s(1) - for more information on tags files.) - - Line: Set to the line indicated by the tag. - Options: Affected by the aauuttoowwrriittee, ttaagglleennggtthh, - ttaaggss and wwrriitteeaannyy options. - - ttaaggpp[[oopp]][[!!]] [[ffiillee || nnuummbbeerr]] - Pop to the specified tag in the tags stack. If - neither ffiillee or nnuummbbeerr is specified, the ttaaggppoopp - command pops to the most recent entry on the tags - stack. If ffiillee or nnuummbbeerr is specified, the ttaaggppoopp - command pops to the most recent entry in the tags - stack for that file, or numbered entry in the tags - stack, respectively. (See the ddiissppllaayy command for - information on displaying the tags stack.) - - If the file has been modified since the last com- - plete write, the ttaaggppoopp command will fail. This - check may be overridden by appending a "!!" char- - acter to the command name. - - Line: Set to the line indicated by the tag. - Options: Affected by the aauuttoowwrriittee, and wwrriitteeaannyy - options. - - ttaaggtt[[oopp]][[!!]] - Pop to the least recent tag on the tags stack, - clearing the tags stack. - - If the file has been modified since the last com- - plete write, the ttaaggppoopp command will fail. This - check may be overridden by appending a "!!" char- - acter to the command name. - - Line: Set to the line indicated by the tag. - Options: Affected by the aauuttoowwrriittee, and wwrriitteeaannyy - options. - - uunnaa[[bbbbrreevv]] llhhss - Delete an abbreviation. Delete llhhss from the cur- - rent list of abbreviations. - - Line: Unchanged. - Options: None. - - uu[[nnddoo]] - Undo the last change made to the file. Changes - made by gglloobbaall, vv, vviissuuaall and map sequences are - considered a single command. If repeated, the uu - - - - - - - - - - -UUSSDD::1133--6666 NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) - - - command alternates between these two states, and - is its own inverse. - - Line: Set to the last line modified by the com- - mand. - Options: None. - - uunnmm[[aapp]][[!!]] llhhss - Unmap a mapped string. Delete the command mode - map definition for llhhss. If a "!!" character is - appended to the command name, delete the text - input mode map definition instead. - - Line: Unchanged. - Options: None. - - vvee[[rrssiioonn]] - Display the version of the eexx//vvii editor. - - [[lliinnee]] vvii[[ssuuaall]] [[ttyyppee]] [[ccoouunntt]] [[ffllaaggss]] - EExx mode only. Enter vvii. The ttyyppee is optional, - and can be "--", "++" or "^^", as in the eexx zz com- - mand, to specify the the position of the specified - line in the screen window. (The default is to - place the line at the top of the screen window.) - A ccoouunntt specifies the number of lines that will - initially be displayed. (The default is the value - of the wwiinnddooww editor option.) - - Line: Unchanged unless lliinnee is specified, in - which case it is set to that line. - Options: None. - - vvii[[ssuuaall]][[!!]] [[++ccmmdd]] [[ffiillee]] - VVii mode only. Edit a new file. Identical to the - "eeddiitt[[!!]] [[++ccmmdd]] [[ffiillee]]" command. - - vviiuu[[ssaaggee]] [[ccoommmmaanndd]] - Display usage for a vvii command. If ccoommmmaanndd is - specified, a usage statement for that command is - displayed. Otherwise, usage statements for all vvii - commands are displayed. - - Line: Unchanged. - Options: None. - - [[rraannggee]] ww[[rriittee]][[!!]] [[>>>>]] [[ffiillee]] - [[rraannggee]] ww[[rriittee]] [[!!]] [[ffiillee]] - [[rraannggee]] wwnn[[!!]] [[>>>>]] [[ffiillee]] - [[rraannggee]] wwqq[[!!]] [[>>>>]] [[ffiillee]] - Write the file. The specified lines (the entire - file, if no range is given) is written to ffiillee. - If ffiillee is not specified, the current pathname is - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) UUSSDD::1133--6677 - - - used. If ffiillee is specified, and it exists, or if - the current pathname was set using the ffiillee com- - mand, and the file already exists, these commands - will fail. Appending a "!!" character to the com- - mand name will override this check and the write - will be attempted, regardless. - - Specifying the optional ">>>>" string will cause the - write to be appended to the file, in which case no - tests are made for the file already existing. - - If the file is preceded by a "!!" character, the - program named in the SHELL environment variable is - invoked with file as its second argument, and the - specified lines are passed as standard input to - that command. The "!!" in this usage must be sep- - arated from command name by at least one whites- - pace character. The special meaning of the "!!" - may be overridden by escaping it with a backslash - ("\\") character. - - The wwqq version of the write command will exit the - editor after writing the file, if there are no - further files to edit. Appending a "!!" character - to the command name or entering two "quit" com- - mands (i.e. wwqq, qquuiitt, xxiitt or ZZZZ) in a row) will - override this check and the editor will exit, - ignoring any files that have not yet been edited. - - The wwnn version of the write command will move to - the next file after writing the file, unless the - write fails. - - Line: Unchanged. - Options: Affected by the rreeaaddoonnllyy and wwrriitteeaannyy - options. - - [[rraannggee]] xx[[iitt]][[!!]] [[ffiillee]] - Write the file if it has been modified. The spec- - ified lines are written to ffiillee, if the file has - been modified since the last complete write to any - file. If no rraannggee is specified, the entire file - is written. - - The xxiitt command will exit the editor after writing - the file, if there are no further files to edit. - Appending a "!!" character to the command name or - entering two "quit" commands (i.e. wwqq, qquuiitt, xxiitt - or ZZZZ) in a row) will override this check and the - editor will exit, ignoring any files that have not - yet been edited. - - - - - - - - - - - - -UUSSDD::1133--6688 NNvvii//NNeexx RReeffeerreennccee ((EExx CCoommmmaannddss)) - - - Line: Unchanged. - Options: Affected by the rreeaaddoonnllyy and wwrriitteeaannyy - options. - - [[rraannggee]] yyaa[[nnkk]] [[bbuuffffeerr]] [[ccoouunntt]] - Copy the specified lines to a buffer. If no - buffer is specified, the unnamed buffer is used. - - Line: Unchanged. - Options: None. - - [[lliinnee]] zz [[ttyyppee]] [[ccoouunntt]] [[ffllaaggss]] - Adjust the window. If no ttyyppee is specified, then - ccoouunntt lines following the specified line are dis- - played. The default ccoouunntt is the value of the - wwiinnddooww option. The ttyyppee argument changes the - position at which lliinnee is displayed on the screen - by changing the number of lines displayed before - and after lliinnee. The following ttyyppee characters may - be used: - - - Place the line at the bottom of the - screen. - + Place the line at the top of the screen. - . Place the line in the middle of the - screen. - ^ Write out count lines starting ccoouunntt ** 22 - lines before lliinnee; the net effect of this - is that a "zz^^" command following a zz com- - mand writes the previous page. - = Center lliinnee on the screen with a line of - hyphens displayed immediately before and - after it. The number of preceding and - following lines of text displayed are - reduced to account for those lines. - - Line: Set to the last line displayed, with the - exception of the ttyyppee, where the current - line is set to the line specified by the - command. - Options: Affected by the option. - - 1155.. SSeett OOppttiioonnss - - There are a large number of options that may be - set (or unset) to change the editor's behavior. This - section describes the options, their abbreviations and - their default values. - - In each entry below, the first part of the tag - line is the full name of the option, followed by any - equivalent abbreviations. (Regardless of the abbrevia- - tions, it is only necessary to use the minimum number - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--6699 - - - of characters necessary to distinguish an abbreviation - from all other commands for it to be accepted, in - nneexx/nnvvii. Historically, only the full name and the - official abbreviations were accepted by eexx/vvii. Using - full names in your startup files and environmental - variables will probably make them more portable.) The - part in square brackets is the default value of the - option. Most of the options are boolean, i.e. they are - either on or off, and do not have an associated value. - - Options apply to both eexx and vvii modes, unless oth- - erwise specified. - - For information on modifying the options or to - display the options and their current values, see the - "set" command in the section entitled "EExx CCoommmmaannddss". - - aallttwweerraassee [[ooffff]] - VVii only. Change how vvii does word erase during - text input. When this option is set, text is bro- - ken up into three classes: alphabetic, numeric and - underscore characters, other nonblank characters, - and blank characters. Changing from one class to - another marks the end of a word. In addition, the - class of the first character erased is ignored - (which is exactly what you want when erasing path- - name components). - - aauuttooiinnddeenntt,, aaii [[ooffff]] - If this option is set, whenever you create a new - line (using the vvii AA, aa, CC, cc, II, ii, OO, oo, RR, rr, - SS, and ss commands, or the eexx aappppeenndd, cchhaannggee, and - iinnsseerrtt commands) the new line is automatically - indented to align the cursor with the first non- - blank character of the line from which you created - it. Lines are indented using tab characters to - the extent possible (based on the value of the - ttaabbssttoopp option) and then using space characters as - necessary. For commands inserting text into the - middle of a line, any blank characters to the - right of the cursor are discarded, and the first - nonblank character to the right of the cursor is - aligned as described above. - - The indent characters are themselves somewhat spe- - cial. If you do not enter more characters on the - new line before moving to another line, or enter- - ing <>, the indent character will be deleted - and the line will be empty. For example, if you - enter <> twice in succession, the - line created by the first <> will - not have any characters in it, regardless of the - indentation of the previous or subsequent line. - - - - - - - - - - -UUSSDD::1133--7700 NNvvii//NNeexx RReeffeerreennccee - - - Indent characters also require that you enter - additional erase characters to delete them. For - example, if you have an indented line, containing - only blanks, the first <> character you - enter will erase up to end of the indent charac- - ters, and the second will erase back to the begin- - ning of the line. (Historically, only the <> key would erase the indent characters. - Both the <> key and the usual erase keys - work in nnvvii.) In addition, if the cursor is posi- - tioned at the end of the indent characters, the - keys "00<>" will erase all of the indent - characters for the current line, resetting the - indentation level to 0. Similarly, the keys - "^^<>" will erase all of the indent char- - acters for the current line, leaving the indenta- - tion level for future created lines unaffected. - - Finally, if the aauuttooiinnddeenntt option is set, the SS - and cccc commands change from the first nonblank of - the line to the end of the line, instead of from - the beginning of the line to the end of the line. - - aauuttoopprriinntt,, aapp [[ooffff]] - EExx only. Cause the current line to be automati- - cally displayed after the eexx commands <<, >>, ccooppyy, - ddeelleettee, jjooiinn, mmoovvee, ppuutt, tt, UUnnddoo, and uunnddoo. This - automatic display is suppressed during gglloobbaall and - vvgglloobbaall commands, and for any command where - optional flags are used to explicitly display the - line. - - aauuttoowwrriittee,, aaww [[ooffff]] - If this option is set, the vvii !!, ^^^^, ^^]] and <> commands, and the eexx eeddiitt, nneexxtt, rreewwiinndd, - ssttoopp, ssuussppeenndd, ttaagg, ttaaggppoopp, and ttaaggttoopp commands - automatically write the current file back to the - current file name if it has been modified since it - was last written. If the write fails, the command - fails and goes no further. - - Appending the optional force flag character "!!" - to the eexx commands nneexxtt, rreewwiinndd, ssttoopp, ssuussppeenndd, - ttaagg, ttaaggppoopp, and ttaaggttoopp stops the automatic write - from being attempted. - - (Historically, the nneexxtt command ignored the - optional force flag.) Note, the eexx commands eeddiitt, - qquuiitt, sshheellll, and xxiitt are _n_o_t affected by the - aauuttoowwrriittee option. - - bbeeaauuttiiffyy,, bbff [[ooffff]] - If this option is set, all control characters that - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--7711 - - - are not currently being specially interpreted, - other than <>, <>, and <>, are - discarded from commands read in by eexx from command - files, and from input text entered to vvii (either - into the file or to the colon command line). Text - files read by eexx/vvii are _n_o_t affected by the bbeeaauu-- - ttiiffyy option. - - ccddppaatthh [[eennvviirroonnmmeenntt vvaarriiaabbllee CCDDPPAATTHH,, oorr ccuurrrreenntt ddiirreecc-- - ttoorryy]] - This option is used to specify a colon separated - list of directories which are used as path pre- - fixes for any relative path names used as argu- - ments for the ccdd command. The value of this - option defaults to the value of the environmental - variable CCDDPPAATTHH if it is set, otherwise to the - current directory. For compatibility with the - POSIX 1003.2 shell, the ccdd command does _n_o_t check - the current directory as a path prefix for rela- - tive path names unless it is explicitly specified. - It may be so specified by entering an empty string - or a ".." character into the CCDDPPAATTHH variable or - the option value. - - ccoolluummnnss,, ccoo [[8800]] - The number of columns in the screen. Setting this - option causes eexx/vvii to set (or reset) the environ- - mental variable CCOOLLUUMMNNSS. See the section entitled - "SSiizziinngg tthhee SSccrreeeenn" more information. - - ccoommmmeenntt [[ooffff]] - VVii only. If the first non-empty line of the file - begins with the string "//**", this option causes vvii - to skip to the end of that C-language comment - (probably a terribly boring legal notice) before - displaying the file. - - ddiirreeccttoorryy,, ddiirr [[eennvviirroonnmmeenntt vvaarriiaabbllee TTMMPPDDIIRR,, oorr //ttmmpp]] - The directory where temporary files are created. - The environmental variable TTMMPPDDIIRR is used as the - default value if it exists, otherwise //ttmmpp is - used. - - eeddccoommppaattiibbllee,, eedd [[ooffff]] - Remember the values of the "c" and "g" suffices to - the ssuubbssttiittuuttee commands, instead of initializing - them as unset for each new command. Specifying - pattern and replacement strings to the ssuubbssttiittuuttee - command unsets the "c" and "g" suffices as well. - - eerrrroorrbbeellllss,, eebb [[ooffff]] - EExx only. EExx error messages are normally presented - in inverse video. If that is not possible for the - - - - - - - - - - -UUSSDD::1133--7722 NNvvii//NNeexx RReeffeerreennccee - - - terminal, setting this option causes error mes- - sages to be announced by ringing the terminal - bell. - - eexxrrcc,, eexx [[ooffff]] - If this option is turned off in the system or - $HOME startup files, the local startup files are - never read (unless they are the same as the system - or $HOME startup files). Turning it on has no - effect, i.e. the normal checks for local startup - files are performed, regardless. See the section - entitled "SSttaarrttuupp IInnffoorrmmaattiioonn" for more informa- - tion. - - eexxtteennddeedd [[ooffff]] - This option causes all regular expressions to be - treated as POSIX 1003.2 Extended Regular Expres- - sions (which are similar to historic _e_g_r_e_p(1) - style expressions). - - ffllaasshh [[oonn]] - This option causes the screen to flash instead of - beeping the keyboard, on error, if the terminal - has the capability. - - hhaarrddttaabbss,, hhtt [[88]] - This option defines the spacing between hardware - tab settings, i.e. the tab expansion done by the - operating system and/or the terminal itself. As - nneexx/nnvvii never writes <> characters to the ter- - minal, unlike historic versions of eexx/vvii, this - option does not currently have any affect. - - iiggnnoorreeccaassee,, iicc [[ooffff]] - This option causes regular expressions, both in eexx - commands and in searches, to be evaluated in a - case-insensitive manner. - - kkeeyyttiimmee [[66]] - The 10th's of a second eexx/vvii waits for a subse- - quent key to complete a key mapping. - - lleeffttrriigghhtt [[ooffff]] - VVii only. This option causes the screen to be - scrolled left-right to view lines longer than the - screen, instead of the traditional vvii screen - interface which folds long lines at the right-hand - margin of the terminal. - - lliinneess,, llii [[2244]] - VVii only. The number of lines in the screen. Set- - ting this option causes eexx/vvii to set (or reset) - the environmental variable LLIINNEESS. See the section - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--7733 - - - entitled "SSiizziinngg tthhee SSccrreeeenn" for more information. - - lliisspp [[ooffff]] - VVii only. This option changes the behavior of the - vvii ((, )), {{, }}, [[[[ and ]]]] commands to match the - Lisp language. Also, the aauuttooiinnddeenntt option's - behavior is changed to be appropriate for Lisp. - - _T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_. - - lliisstt [[ooffff]] - This option causes lines to be displayed in an - unambiguous fashion. Specifically, tabs are dis- - played as control characters, i.e. "^^II", and the - ends of lines are marked with a "$$" character. - - mmaaggiicc [[oonn]] - This option is on by default. Turning the mmaaggiicc - option off causes all regular expression charac- - ters except for "^^" and "$$", to be treated as - ordinary characters. To re-enable characters - individually, when the mmaaggiicc option is off, pre- - cede them with a backslash "\\" character. See the - section entitled "RReegguullaarr EExxpprreessssiioonnss aanndd RReeppllaaccee-- - mmeenntt SSttrriinnggss" for more information. - - mmaattcchhttiimmee [[77]] - VVii only. The 10th's of a second eexx/vvii pauses on - the matching character when the sshhoowwmmaattcchh option - is set. - - mmeessgg [[oonn]] - This option allows other users to contact you - using the _t_a_l_k(1) and _w_r_i_t_e(1) utilities, while - you are editing. EExx/vvii does not turn message on, - i.e. if messages were turned off when the editor - was invoked, they will stay turned off. This - option only permits you to disallow messages for - the edit session. See the _m_e_s_g(1) utility for - more information. - - mmooddeelliinneess,, mmooddeelliinnee [[ooffff]] - If the mmooddeelliinneess option is set, eexx/vvii has histori- - cally scanned the first and last five lines of - each file as it is read for editing, looking for - any eexx commands that have been placed in those - lines. After the startup information has been - processed, and before the user starts editing the - file, any commands embedded in the file are exe- - cuted. - - Commands were recognized by the letters "e" or "v" - followed by "x" or "i", at the beginning of a line - - - - - - - - - - -UUSSDD::1133--7744 NNvvii//NNeexx RReeffeerreennccee - - - or following a tab or space character, and fol- - lowed by a ":", an eexx command, and another ":". - - This option is a security problem of immense pro- - portions, and should not be used under any circum- - stances. - - _T_h_i_s _o_p_t_i_o_n _w_i_l_l _n_e_v_e_r _b_e _i_m_p_l_e_m_e_n_t_e_d_. - - nnuummbbeerr,, nnuu [[ooffff]] - Precede each line displayed with its current line - number. - - ooccttaall [[ooffff]] - Display unknown characters as octal numbers, - instead of the default hexadecimal. - - ooppeenn [[oonn]] - EExx only. If this option is not set, the ooppeenn and - vviissuuaall commands are disallowed. - - ooppttiimmiizzee,, oopptt [[oonn]] - VVii only. Throughput of text is expedited by set- - ting the terminal not to do automatic carriage - returns when printing more than one (logical) line - of output, greatly speeding output on terminals - without addressable cursors when text with leading - white space is printed. - - _T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_. - - ppaarraaggrraapphhss,, ppaarraa [[IIPPLLPPPPPPQQPPPP LLIIppppllppiippbbpp]] - VVii only. Define additional paragraph boundaries - for the {{ and }} commands. The value of this - option must be a character string consisting of - zero or more character pairs. - - In the text to be edited, the character string - <>..<>, (where <> is one - of the character pairs in the option's value) - defines a paragraph boundary. For example, if the - option were set to LLaaAA<>####, then all of the - following additional paragraph boundaries would be - recognized: - - - .La - .A - .## - - - pprroommpptt [[oonn]] - EExx only. This option causes eexx to prompt for - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--7755 - - - command input with a "::" character; when it is not - set, no prompt is displayed. - - rreeaaddoonnllyy,, rroo [[ooffff]] - This option causes a force flag to be required to - attempt to write the file back to the original - file name. Setting this option is equivalent to - using the --RR command line option, or editing a - file which lacks write permission. - - rreeccddiirr [[//vvaarr//ttmmpp//vvii..rreeccoovveerr]] - The directory where recovery files are stored. - - If you change the value of rreeccddiirr, be careful to - choose a directory whose contents are not regu- - larly deleted. Bad choices include directories in - memory based filesystems, or //ttmmpp, on most sys- - tems, as their contents are removed when the - machine is rebooted. - - Public directories like //uussrr//ttmmpp and //vvaarr//ttmmpp are - usually safe, although some sites periodically - prune old files from them. There is no require- - ment that you use a public directory, e.g. a sub- - directory of your home directory will work fine. - - Finally, if you change the value of rreeccddiirr, you - must modify the recovery script to operate in your - chosen recovery area. - - See the section entitled "RReeccoovveerryy" for further - information. - - rreeddrraaww,, rree [[ooffff]] - VVii only. The editor simulates (using great - amounts of output), an intelligent terminal on a - dumb terminal (e.g. during insertions in vvii the - characters to the right of the cursor are - refreshed as each input character is typed). - - _T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_. - - rreemmaapp [[oonn]] - If this option is set, it is possible to define - macros in terms of other macros. Otherwise, each - key is only remapped up to one time. For example, - if "AA" is mapped to "BB", and "BB" is mapped to "CC", - The keystroke "AA" will be mapped to "CC" if the - rreemmaapp option is set, and to "BB" if it is not set. - - rreeppoorrtt [[55]] - Set the threshold of the number of lines that need - to be changed or yanked before a message will be - - - - - - - - - - -UUSSDD::1133--7766 NNvvii//NNeexx RReeffeerreennccee - - - displayed to the user. For everything but the - yank command, the value is the largest value about - which the editor is silent, i.e. by default, 6 - lines must be deleted before the user is notified. - However, if the number of lines yanked is greater - than _o_r _e_q_u_a_l _t_o the set value, it is reported to - the user. - - rruulleerr [[ooffff]] - VVii only. Display a row/column ruler on the colon - command line. - - ssccrroollll,, ssccrr [[wwiinnddooww // 22]] - Set the number of lines scrolled by the vvii <> and <> commands. - - Historically, the eexx zz command, when specified - without a count, used two times the size of the - scroll value; the POSIX 1003.2 standard specified - the window size, which is a better choice. - - sseeccttiioonnss,, sseecctt [[NNHHSSHHHH HHUUnnhhsshh]] - VVii only. Define additional section boundaries for - the [[[[ and ]]]] commands. The sseeccttiioonnss option - should be set to a character string consisting of - zero or more character pairs. In the text to be - edited, the character string <>..<>, (where <> is one of the character - pairs in the option's value), defines a section - boundary in the same manner that ppaarraaggrraapphh option - boundaries are defined. - - sshheellll,, sshh [[eennvviirroonnmmeenntt vvaarriiaabbllee SSHHEELLLL,, oorr //bbiinn//sshh]] - Select the shell used by the editor. The speci- - fied path is the pathname of the shell invoked by - the vvii !! shell escape command and by the eexx sshheellll - command. This program is also used to resolve any - shell meta-characters in eexx commands. - - sshhiiffttwwiiddtthh,, ssww [[88]] - Set the autoindent and shift command indentation - width. This width is used by the aauuttooiinnddeenntt - option and by the <<, >>, and sshhiifftt commands. - - sshhoowwddiirrttyy [[ooffff]] - VVii only. Display an asterisk on the colon command - line if the file has been modified. - - sshhoowwmmaattcchh,, ssmm [[ooffff]] - VVii only. This option causes vvii, when a "}}" or "))" - is entered, to briefly move the cursor the match- - ing "{{" or "((". See the mmaattcchhttiimmee option for more - information. - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--7777 - - - sshhoowwmmooddee [[ooffff]] - VVii only. This option causes vvii to display a - string identifying the current editor mode on the - colon command line. - - ssiiddeessccrroollll [[1166]] - VVii only. Sets the number of columns that are - shifted to the left or right, when vvii is doing - left-right scrolling and the left or right margin - is crossed. See the lleeffttrriigghhtt option for more - information. - - sslloowwooppeenn,, ssllooww [[ooffff]] - This option affects the display algorithm used by - vvii, holding off display updating during input of - new text to improve throughput when the terminal - in use is slow and unintelligent. - - _T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_. - - ssoouurrcceeaannyy [[ooffff]] - If this option is turned on, vvii historically read - startup files that were owned by someone other - than the editor user. See the section entitled - "SSttaarrttuupp IInnffoorrmmaattiioonn" for more information. This - option is a security problem of immense propor- - tions, and should not be used under any circum- - stances. - - _T_h_i_s _o_p_t_i_o_n _w_i_l_l _n_e_v_e_r _b_e _i_m_p_l_e_m_e_n_t_e_d_. - - ttaabbssttoopp,, ttss [[88]] - This option sets tab widths for the editor dis- - play. - - ttaagglleennggtthh,, ttll [[00]] - This option sets the maximum number of characters - that are considered significant in a tag name. - Setting the value to 0 makes all of the characters - in the tag name significant. - - ttaaggss,, ttaagg [[ttaaggss //vvaarr//ddbb//lliibbcc..ttaaggss //ssyyss//kkeerrnn//ttaaggss]] - Sets the list of tags files, in search order, - which are used when the editor searches for a tag. - - tteerrmm,, ttttyyttyyppee,, ttttyy [[eennvviirroonnmmeenntt vvaarriiaabbllee TTEERRMM]] - Set the terminal type. Setting this option causes - eexx/vvii to set (or reset) the environmental variable - TTEERRMM. - - tteerrssee [[ooffff]] - This option has historically made editor messages - less verbose. It has no effect in this - - - - - - - - - - -UUSSDD::1133--7788 NNvvii//NNeexx RReeffeerreennccee - - - implementation. See the vveerrbboossee option for more - information. - - ttiillddeeoopp - Modify the ~~ command to take an associated motion. - - ttiimmeeoouutt,, ttoo [[oonn]] - If this option is set, eexx/vvii waits for a specific - period for a subsequent key to complete a key map- - ping (see the kkeeyyttiimmee option). If the option is - not set, the editor waits until enough keys are - entered to resolve the ambiguity, regardless of - how long it takes. - - ttttyywweerraassee [[ooffff]] - VVii only. This option changes how vvii does word - erase during text input. If this option is set, - text is broken up into two classes, blank charac- - ters and nonblank characters. Changing from one - class to another marks the end of a word. - - vveerrbboossee [[ooffff]] - VVii only. VVii historically bells the terminal for - many obvious mistakes, e.g. trying to move past - the left-hand margin, or past the end of the file. - If this option is set, an error message is dis- - played for all errors. - - ww330000 [[nnoo ddeeffaauulltt]] - VVii only. Set the window size if the baud rate is - less than 1200 baud. See the wwiinnddooww option for - more information. - - ww11220000 [[nnoo ddeeffaauulltt]] - VVii only. Set the window size if the baud rate is - equal to 1200 baud. See the wwiinnddooww option for - more information. - - ww99660000 [[nnoo ddeeffaauulltt]] - VVii only. Set the window size if the baud rate is - greater than 1200 baud. See the wwiinnddooww option for - more information. - - wwaarrnn [[oonn]] - EExx only. This option causes a warning message to - the terminal if the file has been modified, since - it was last written, before a !! command. - - wwiinnddooww,, ww,, wwii [[eennvviirroonnmmeenntt vvaarriiaabbllee LLIINNEESS]] - This option determines the default number of lines - in a screenful, as written by the zz command. It - also determines the number of lines scrolled by - the vvii commands <> and <>. The - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--7799 - - - value of window can be unrelated to the real - screen size, although it starts out as the number - of lines on the screen (see the section entitled - "SSiizziinngg tthhee SSccrreeeenn" for more information). Set- - ting the value of the wwiinnddooww option is the same as - using the --ww command line option. - - If the value of the wwiinnddooww option (as set by the - wwiinnddooww, ww330000, ww11220000 or ww99660000 options) is smaller - than the actual size of the screen, large screen - movements will result in displaying only that - smaller number of lines on the screen. (Further - movements in that same area will result in the - screen being filled.) This can provide a perfor- - mance improvement when viewing different places in - one or more files over a slow link. - - wwrraappmmaarrggiinn,, wwmm [[00]] - VVii only. If the value of the wwrraappmmaarrggiinn option is - non-zero, vvii will split lines so that they end at - least that number of characters before the right- - hand margin of the screen. (Note, the value of - wwrraappmmaarrggiinn is _n_o_t a text length. In a screen that - is 80 columns wide, the command "::sseett wwrraappmmaarr-- - ggiinn==88" attempts to keep the lines less than or - equal to 72 columns wide.) - - Lines are split at the previous whitespace charac- - ter closest to the number. Any trailing whites- - pace characters before that character are deleted. - If the line is split because of an inserted - <> or <> character, and you then enter - another <> character, it is discarded. - - If wrapmargin is set to 0, or if there is no blank - character upon which to split the line, the line - is not broken. - - wwrraappssccaann,, wwss [[oonn]] - This option causes searches to wrap around the end - or the beginning of the file, and back to the - starting point. Otherwise, the end or beginning - of the file terminates the search. - - wwrriitteeaannyy,, wwaa [[ooffff]] - If this option is set, file-overwriting checks - that would usually be made before the wwrriittee and - xxiitt commands, or before an automatic write (see - the aauuttoowwrriittee option), are not made. This allows - a write to any file, provided the file permissions - allow it. - - - - - - - - - - - - -UUSSDD::1133--8800 NNvvii//NNeexx RReeffeerreennccee - - - 1166.. AAddddiittiioonnaall FFeeaattuurreess iinn NNeexx//NNvvii - - There are a few features in nneexx/nnvvii that are not - found in historic versions of eexx/vvii. Some of the more - interesting of those features are as follows: - - 88--bbiitt cclleeaann ddaattaa,, llaarrggee lliinneess,, ffiilleess - NNeexx/nnvvii will edit any format file. Line lengths - are limited by available memory, and file sizes - are limited by available disk space. The vvii text - input mode command <> can insert any pos- - sible character value into the text. - - SSpplliitt ssccrreeeennss - The sspplliitt command divides the screen into multiple - editing regions. The <> command rotates - between the foreground screens. The rreessiizzee com- - mand can be used to grow or shrink a particular - screen. - - BBaacckkggrroouunndd aanndd ffoorreeggrroouunndd ssccrreeeennss - The bbgg command backgrounds the current screen, and - the ffgg command foregrounds backgrounded screens. - The ddiissppllaayy command can be used to list the back- - ground screens. - - TTaagg ssttaacckkss - Tags are now maintained in a stack. The <> command returns to the previous tag location. - The ttaaggppoopp command returns to the most recent tag - location by default, or, optionally to a specific - tag number in the tag stack, or the most recent - tag from a specified file. The ddiissppllaayy command - can be used to list the tags stack. The ttaaggttoopp - command returns to the top of the tag stack. - - NNeeww ddiissppllaayyss - The ddiissppllaayy command can be used to display the - current buffers, the backgrounded screens, and the - tags stack. - - IInnffiinniittee uunnddoo - Changes made during an edit session may be rolled - backward and forward. A .. command immediately - after a uu command continues either forward or - backward depending on whether the uu command was an - undo or a redo. - - UUssaaggee iinnffoorrmmaattiioonn - The eexxuussaaggee and vviiuussaaggee commands provide usage - information for all of the eexx and vvii commands by - default, or, optionally, for a specific command or - key. - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--8811 - - - EExxtteennddeedd RReegguullaarr EExxpprreessssiioonnss - The eexxtteennddeedd option causes Regular Expressions to - be interpreted as as Extended Regular Expressions, - (i.e. _e_g_r_e_p(1) style Regular Expressions). - - WWoorrdd sseeaarrcchh - The <> command searches for the word ref- - erenced by the cursor. - - NNuummbbeerr iinnccrreemmeenntt - The ## command increments or decrements the number - referenced by the cursor. - - PPrreevviioouuss ffiillee - The pprreevviioouuss command edits the previous file from - the argument list. - - LLeefftt--rriigghhtt ssccrroolllliinngg - The lleeffttrriigghhtt option causes nnvvii to do left-right - screen scrolling, instead of the traditional vvii - line wrapping. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -UUSSDD::1133--8822 NNvvii//NNeexx RReeffeerreennccee - - - 1177.. IInnddeexx - - ! 15, 34 @ 20, 35 columns 47 - "" 34 A 20 comment 47 - # 16, 35 B 20 copy 36 - $ 16 C 21 count 10, 33 - % 16 D 21 current pathname 8 - & 17, 42 E 21 d 26 - ( 17 F 21 delete 37 - ) 17 G 21 directory 47 - * 35 H 21 display 37 - + 13 I 22 e 26 - , 18 J 22 edcompatible47 - /RE/ 18 L 22 edit 37 - 0 19 M 22 errorbells 47 - 031 N 18 exrc 47 - : 19 O 22 extended 48 - ; 19 P 23 exusage 37 - < 20, 35 Q 23 f 26 - 11 R 23 fg 37 - 11 S 23 file 33, 37 - , 31 T 23 flags 33 - 12 U 23 flash 48 - 12 W 24 global 38 - 12 X 24 hardtabs 48 - , 31 Y 24 help 38 - 13 ZZ 24 i 26 - 13 [[ 24 ignorecase 48 - 13 - 18 insert 38 - 13 ]] 25 j 13 - 13 ^ 25 join 38 - 13 ^31 k 13, 39 - , 31 _ 25 keytime 48 - 14 `17 l 15 - , 31 a 25 leftright 48 - 31 abbrev 35 line 33 - 14 alternate pathname 8 lines 48 - , 43 altwerase 46 lisp 48 - 15 append 36 list 39, 48 - 15 args 36 m 27 - 34 autoindent 46 magic 48 - 33 autoprint 46 map 39 - 31 autowrite 47 mark 39 - 14, 31 b 25 matchtime 48 - , 31 beautify 47 mesg 48 - 31 bg 36 mkexrc 39 - 7, 31 bigword 10 modelines 49 - 30 buffer 8 motion 10 - 15 c 26 move 39 - 31 cd 36 n 18 - = 35 cdpath 47 next 40 - > 20, 35 change 36 number 35, 49 - ?RE? 18 chdir 36 o 27 - - - - - - - - - - -NNvvii//NNeexx RReeffeerreennccee UUSSDD::1133--8833 - - - octal 49 tildeop 51 - open 40, 49 timeout 51 - optimize 49 ttywerase 52 - p 27 u 28 - paragraph 11 unabbrev 44 - paragraphs 49 undo 44 - preserve 40 unmap 44 - previous 40 unnamed buffer 8 - previous context 9 v 38 - print 40 verbose 52 - prompt 49 version 44 - put 40 visual 44 - quit 41 viusage 44 - r 27 w 28 - range 33 w1200 52 - read 41 w300 52 - readonly 49 w9600 52 - recdir 49 warn 52 - recover 41 window 52 - redraw 50 wn 44 - remap 50 word 10 - report 50 wq 44 - resize 41 wrapmargin 52 - rewind 41 wrapscan 52 - ruler 50 write 44 - s 27 writeany 53 - scroll 50 x 28 - section 11 xit 45 - sections 50 y 28 - sentence 11 yank 45 - set 41 z 28, 45 - shell 42, 50 { 29 - shiftwidth 50 | 29 - showdirty 51 } 29 - showmatch 51 ~ 29, 30, 42 - showmode 51 - sidescroll 51 - slowopen 51 - source 42 - sourceany 51 - split 42 - stop 43 - substitute 42 - suspend 43 - t 27, 36 - tabstop 51 - tag 43 - taglength 51 - tagpop 43 - tags 51 - tagtop 43 - term 51 - terse 51 - - - - - - - - - - -UUSSDD::1133--22 NNvvii//NNeexx RReeffeerreennccee - - - TTaabbllee ooff CCoonntteennttss - - Description ...................................... 3 - Startup Information .............................. 3 - Recovery ......................................... 4 - Sizing the Screen ................................ 7 - Character Display ................................ 7 - Multiple Screens ................................. 8 - Regular Expressions and Replacement Strings ...... 9 - General Editor Description ....................... 10 - Vi Description ................................... 12 - Vi Commands ...................................... 17 - Vi Text Input Commands ........................... 45 - Ex Addressing .................................... 47 - Ex Description ................................... 49 - Ex Commands ...................................... 50 - Set Options ...................................... 68 - Additional Features in Nex/Nvi ................... 79 - Index ............................................ 82 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/usr.bin/whatis/Makefile b/usr.bin/whatis/Makefile deleted file mode 100644 index 8655a7c..0000000 --- a/usr.bin/whatis/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 - -PROG= whatis -SRCS= whatis.c config.c -.PATH: ${.CURDIR}/../man - -.include diff --git a/usr.bin/whatis/whatis.1 b/usr.bin/whatis/whatis.1 deleted file mode 100644 index 0f1b0a1..0000000 --- a/usr.bin/whatis/whatis.1 +++ /dev/null @@ -1,105 +0,0 @@ -.\" Copyright (c) 1989, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)whatis.1 8.1 (Berkeley) 6/6/93 -.\" -.Dd June 6, 1993 -.Dt WHATIS 1 -.Os BSD 4 -.Sh NAME -.Nm whatis -.Nd describe what a command is -.Sh SYNOPSIS -.Nm whatis -.Op Fl M Ar path -.Op Fl m Ar path -.Ar command Ar ... -.Sh DESCRIPTION -.Nm Whatis -looks up a given command and gives the header line from the manual page. -You can then use the -.Xr man 1 -command to get more information. -.Pp -The options are as follows: -.Bl -tag -width Fl -.It Fl M Ar path -Override the list of standard directories -.Nm whatis -searches for its database named -.Dq Pa whatis.db . -The supplied -.Ar path -must be a colon -.Dq \&: -separated list of directories. -This search path may also be set using the environment variable -.Ev MANPATH . -.It Fl m Ar path -Augment the list of standard directories -.Nm whatis -searches for its database named -.Dq Pa whatis.db . -The supplied -.Ar path -must be a colon -.Dq \&: -separated list of directories. -These directories will be searched before the standard directories -or the directories supplied with the -.Fl M -option or the -.Ev MANPATH -environment variable are searched. -.El -.Sh ENVIRONMENT -.Bl -tag -width MANPATH -.It Ev MANPATH -The standard search path used by -.Xr man 1 -may be overridden by specifying a path in the -.Ev MANPATH -environment variable. -.El -.Sh FILES -.Bl -tag -width whatis.db -.It Pa whatis.db -name of the whatis database -.El -.Sh SEE ALSO -.Xr apropos 1 , -.Xr man 1 , -.Xr whereis 1 -.Sh HISTORY -The -.Nm -command appeared in -.Bx 3.0 . diff --git a/usr.bin/whatis/whatis.c b/usr.bin/whatis/whatis.c deleted file mode 100644 index 904f0e4..0000000 --- a/usr.bin/whatis/whatis.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1987, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)whatis.c 8.5 (Berkeley) 1/2/94"; -#endif /* not lint */ - -#include -#include - -#include -#include -#include -#include -#include - -#include "../man/config.h" -#include "../man/pathnames.h" - -#define MAXLINELEN 256 /* max line handled */ - -static int *found, foundman; - -int -main(argc, argv) - int argc; - char *argv[]; -{ - extern char *optarg; - extern int optind; - ENTRY *ep; - TAG *tp; - int ch, rv; - char *beg, *conffile, **p, *p_augment, *p_path; - - conffile = NULL; - p_augment = p_path = NULL; - while ((ch = getopt(argc, argv, "C:M:m:P:")) != EOF) - switch (ch) { - case 'C': - conffile = optarg; - break; - case 'M': - case 'P': /* backward compatible */ - p_path = optarg; - break; - case 'm': - p_augment = optarg; - break; - case '?': - default: - usage(); - } - argv += optind; - argc -= optind; - - if (argc < 1) - usage(); - - if ((found = malloc((u_int)argc * sizeof(int))) == NULL) - err(1, NULL); - memset(found, 0, argc * sizeof(int)); - - for (p = argv; *p; ++p) /* trim full paths */ - if (beg = rindex(*p, '/')) - *p = beg + 1; - - if (p_augment) - whatis(argv, p_augment, 1); - if (p_path || (p_path = getenv("MANPATH"))) - whatis(argv, p_path, 1); - else { - config(conffile); - ep = (tp = getlist("_whatdb")) == NULL ? - NULL : tp->list.tqh_first; - for (; ep != NULL; ep = ep->q.tqe_next) - whatis(argv, ep->s, 0); - } - - if (!foundman) { - fprintf(stderr, "whatis: no %s file found.\n", _PATH_WHATIS); - exit(1); - } - rv = 1; - for (p = argv; *p; ++p) - if (found[p - argv]) - rv = 0; - else - printf("%s: not found\n", *p); - exit(rv); -} - -whatis(argv, path, buildpath) - char **argv, *path; - int buildpath; -{ - register char *end, *name, **p; - char buf[MAXLINELEN + 1], wbuf[MAXLINELEN + 1]; - - for (name = path; name; name = end) { /* through name list */ - if (end = index(name, ':')) - *end++ = '\0'; - - if (buildpath) { - char hold[MAXPATHLEN + 1]; - - (void)sprintf(hold, "%s/%s", name, _PATH_WHATIS); - name = hold; - } - - if (!freopen(name, "r", stdin)) - continue; - - foundman = 1; - - /* for each file found */ - while (fgets(buf, sizeof(buf), stdin)) { - dashtrunc(buf, wbuf); - for (p = argv; *p; ++p) - if (match(wbuf, *p)) { - printf("%s", buf); - found[p - argv] = 1; - - /* only print line once */ - while (*++p) - if (match(wbuf, *p)) - found[p - argv] = 1; - break; - } - } - } -} - -/* - * match -- - * match a full word - */ -match(bp, str) - register char *bp, *str; -{ - register int len; - register char *start; - - if (!*str || !*bp) - return(0); - for (len = strlen(str);;) { - for (; *bp && !isdigit(*bp) && !isalpha(*bp); ++bp); - if (!*bp) - break; - for (start = bp++; - *bp && (*bp == '_' || isdigit(*bp) || isalpha(*bp)); ++bp); - if (bp - start == len && !strncasecmp(start, str, len)) - return(1); - } - return(0); -} - -/* - * dashtrunc -- - * truncate a string at " - " - */ -dashtrunc(from, to) - register char *from, *to; -{ - register int ch; - - for (; (ch = *from) && ch != '\n' && - (ch != ' ' || from[1] != '-' || from[2] != ' '); ++from) - *to++ = ch; - *to = '\0'; -} - -/* - * usage -- - * print usage message and die - */ -usage() -{ - (void)fprintf(stderr, - "usage: whatis [-C file] [-M path] [-m path] command ...\n"); - exit(1); -} diff --git a/usr.bin/which/which.sh b/usr.bin/which/which.sh deleted file mode 100755 index 7167140..0000000 --- a/usr.bin/which/which.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/csh -# -# -# Copyright (C) 1994, Joerg Wunsch -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# [whew!] -# -# $Id$ - -foreach i ($argv) - echo -n "${i}: " - - set a = `alias $i` - - if ("$a" != "") then # test for alias - echo "aliased to $a" - else if ("$i" =~ /*) then # absolute path name - if (! -x "$i") then - echo "not found" - else - echo "$i" - endif - else # search $path - set found = 0 - foreach p ($path) - - if (-x "$p/$i") then - echo "$p/$i" - set found = 1 - break - endif - end - if ($found == 0) echo "not found" - endif -end -- cgit v1.1