From owner-svn-soc-all@FreeBSD.ORG Wed Aug 17 05:24:03 2011 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 327B7106564A for ; Wed, 17 Aug 2011 05:24:01 +0000 (UTC) (envelope-from zy@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Wed, 17 Aug 2011 05:24:01 +0000 Date: Wed, 17 Aug 2011 05:24:01 +0000 From: zy@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20110817052401.327B7106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r225177 - in soc2011/zy/nvi-iconv/head: contrib/nvi2 contrib/nvi2/cl contrib/nvi2/common contrib/nvi2/docs/man contrib/nvi2/ex contrib/nvi2/regex contrib/nvi2/vi usr.bin/vi X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2011 05:24:03 -0000 Author: zy Date: Wed Aug 17 05:24:00 2011 New Revision: 225177 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=225177 Log: Updates to git:63b3b92. Version 2.0.1 presents. * Correct UTF-16LE support; * Restore XTerm title when 'windowname' is on (xprop); * Use a modified regex lib to support wide characters (nvi-1.8x); * Some bugfixes. Note that this version is WARNS-free with gcc. Added: soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/ soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/COPYRIGHT soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/WHATSNEW soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/cclass.h soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/cname.h soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/engine.c soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/re_format.7 soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/regcomp.c soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/regerror.c soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/regex.3 soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/regex.h soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/regex2.h soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/regexec.c soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/regfree.c soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/utils.h Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/README soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl.h soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_funcs.c soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_main.c soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/extern.h soc2011/zy/nvi-iconv/head/contrib/nvi2/common/conv.c soc2011/zy/nvi-iconv/head/contrib/nvi2/common/cut.h soc2011/zy/nvi-iconv/head/contrib/nvi2/common/encoding.c soc2011/zy/nvi-iconv/head/contrib/nvi2/common/exf.c soc2011/zy/nvi-iconv/head/contrib/nvi2/common/mark.h soc2011/zy/nvi-iconv/head/contrib/nvi2/common/multibyte.h soc2011/zy/nvi-iconv/head/contrib/nvi2/common/options.c soc2011/zy/nvi-iconv/head/contrib/nvi2/common/screen.h soc2011/zy/nvi-iconv/head/contrib/nvi2/docs/man/vi.1 soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex.h soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_version.c soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_write.c soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/version.h soc2011/zy/nvi-iconv/head/contrib/nvi2/vi/vi.c soc2011/zy/nvi-iconv/head/usr.bin/vi/Makefile Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/README ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/README Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/README Wed Aug 17 05:24:00 2011 (r225177) @@ -1,6 +1,6 @@ -# $Id: README,v 8.155 2011/07/15 04:45:07 zy Exp $ (Berkeley) $Date: 2011/07/15 04:45:07 $ +# $Id: README,v 8.156 2011/08/16 13:55:14 zy Exp $ (Berkeley) $Date: 2011/08/16 13:55:14 $ -This is version 2.0.0 (2011-07-11) of nex/nvi, a reimplementation of the ex/vi +This is version 2.0.1 (2011-08-16) of nex/nvi, a reimplementation of the ex/vi text editors originally distributed as part of the Fourth Berkeley Software Distribution (4BSD), by the University of California, Berkeley. @@ -15,6 +15,7 @@ docs .......... Ex/vi documentation, both current and historic. ex ............ Ex source code. include ....... Replacement include files. + regex ......... Modified regex library with wide character support. vi ............ Vi source code. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl.h Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl.h Wed Aug 17 05:24:00 2011 (r225177) @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: cl.h,v 10.33 2011/07/14 15:14:00 zy Exp $ (Berkeley) $Date: 2011/07/14 15:14:00 $ + * $Id: cl.h,v 10.34 2011/08/15 20:07:32 zy Exp $ (Berkeley) $Date: 2011/08/15 20:07:32 $ */ #ifdef USE_SLANG_CURSES @@ -15,6 +15,9 @@ #ifdef HAVE_NCURSESW_NCURSES_H /* { */ #include #else /* } { */ +#if defined(USE_WIDECHAR) && !defined(_XOPEN_SOURCE_EXTENDED) +#define _XOPEN_SOURCE_EXTENDED 1 +#endif #ifdef HAVE_NCURSES_H /* { */ #include #else /* } { */ @@ -42,6 +45,8 @@ char *rmso, *smso; /* Inverse video terminal strings. */ char *smcup, *rmcup; /* Terminal start/stop strings. */ + char *oname; /* Original screen window name. */ + SCR *focus; /* Screen that has the "focus". */ int killersig; /* Killer signal. */ @@ -83,9 +88,6 @@ #define RCNO(sp, cno) (cno) #define RLNO(sp, lno) (lno) -/* X11 xterm escape sequence to rename the icon/window. */ -#define XTERM_RENAME "\033]0;%s\007" - /* * XXX * Some implementations of curses.h don't define these for us. Used for Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_funcs.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_funcs.c Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_funcs.c Wed Aug 17 05:24:00 2011 (r225177) @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: cl_funcs.c,v 10.72 2002/03/02 23:18:33 skimo Exp $ (Berkeley) $Date: 2002/03/02 23:18:33 $"; +static const char sccsid[] = "$Id: cl_funcs.c,v 10.73 2011/08/15 19:55:33 zy Exp $ (Berkeley) $Date: 2011/08/15 19:55:33 $"; #endif /* not lint */ #include @@ -638,34 +638,60 @@ { GS *gp; CL_PRIVATE *clp; - char *ttype; + FILE *pfp; + char buf[256], *s, *e; + char * wid; + char cmd[64]; gp = sp->gp; clp = CLP(sp); - ttype = OG_STR(gp, GO_TERM); - /* * XXX * We can only rename windows for xterm. */ if (on) { clp->focus = sp; - if (F_ISSET(clp, CL_RENAME_OK) && - !strncmp(ttype, "xterm", sizeof("xterm") - 1)) { - F_SET(clp, CL_RENAME); - (void)printf(XTERM_RENAME, name); - (void)fflush(stdout); + if (!F_ISSET(clp, CL_RENAME_OK) || + strcmp(OG_STR(gp, GO_TERM), "xterm")) + return (0); + + if (clp->oname == NULL && (wid = getenv("WINDOWID"))) { + snprintf(cmd, sizeof(cmd), "xprop -id %s WM_NAME", wid); + if ((pfp = popen(cmd, "r")) && fgets(buf, sizeof(buf), pfp) && + (s = strchr(buf, '"')) && (e = strrchr(buf, '"'))) + clp->oname = strndup(s + 1, e - s - 1); } + + cl_setname(gp, name); + + F_SET(clp, CL_RENAME); } else if (F_ISSET(clp, CL_RENAME)) { + cl_setname(gp, clp->oname); + F_CLR(clp, CL_RENAME); - (void)printf(XTERM_RENAME, ttype); - (void)fflush(stdout); } return (0); } +/* + * cl_setname -- + * Set a X11 icon/window name. + * + * PUBLIC: void cl_setname __P((GS *, char *)); + */ +void +cl_setname(GS *gp, char *name) +{ +/* X11 xterm escape sequence to rename the icon/window. */ +#define XTERM_RENAME "\033]0;%s\007" + + (void)printf(XTERM_RENAME, name == NULL ? OG_STR(gp, GO_TERM) : name); + (void)fflush(stdout); +#undef XTERM_RENAME +} + /* * cl_split -- * Split a screen. Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_main.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_main.c Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/cl_main.c Wed Aug 17 05:24:00 2011 (r225177) @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: cl_main.c,v 10.54 2001/07/29 19:07:27 skimo Exp $ (Berkeley) $Date: 2001/07/29 19:07:27 $"; +static const char sccsid[] = "$Id: cl_main.c,v 10.55 2011/08/15 19:52:28 zy Exp $ (Berkeley) $Date: 2011/08/15 19:52:28 $"; #endif /* not lint */ #include @@ -139,10 +139,8 @@ * XXX * Reset the X11 xterm icon/window name. */ - if (F_ISSET(clp, CL_RENAME)) { - (void)printf(XTERM_RENAME, ttype); - (void)fflush(stdout); - } + if (F_ISSET(clp, CL_RENAME)) + cl_setname(gp, clp->oname); /* If a killer signal arrived, pretend we just got it. */ if (clp->killersig) { @@ -153,6 +151,8 @@ /* Free the global and CL private areas. */ #if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY) + if (clp->oname != NULL) + free(clp->oname); free(clp); free(gp); #endif Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/extern.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/extern.h Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/cl/extern.h Wed Aug 17 05:24:00 2011 (r225177) @@ -42,6 +42,7 @@ int cl_move __P((SCR *, size_t, size_t)); int cl_refresh __P((SCR *, int)); int cl_rename __P((SCR *, char *, int)); +void cl_setname __P((GS *, char *)); int cl_split __P((SCR *, SCR *)); int cl_suspend __P((SCR *, int *)); void cl_usage __P((void)); Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/conv.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/conv.c Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/conv.c Wed Aug 17 05:24:00 2011 (r225177) @@ -92,7 +92,7 @@ { /* XXX UTF-16 linesep hack */ if (!strncasecmp(enc, "utf-16", 6) && len % 2) - len -= 1; + str[--len] != '\0' && str++; /* shortern by 1, shift if LE */ int i = 0, j; CHAR_T **tostr = &cw->b_wc1; @@ -206,7 +206,7 @@ for (i = 0; i < len; ++i) (*tostr)[i] = str[i]; - *dst = cw->b_wc1; + *dst = cw->b_c1; return 0; } @@ -339,10 +339,16 @@ sp->conv.input2int = ie_char2int; #endif #ifdef USE_ICONV - o_set(sp, O_FILEENCODING, OS_STRDUP, nl_langinfo(CODESET), 0); o_set(sp, O_INPUTENCODING, OS_STRDUP, nl_langinfo(CODESET), 0); #endif } + /* XXX + * Do not inherit file encoding from the old screen, + * but overwrite the fileencoding option in .exrc + */ +#ifdef USE_ICONV + o_set(sp, O_FILEENCODING, OS_STRDUP, nl_langinfo(CODESET), 0); +#endif } /* Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/cut.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/cut.h Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/cut.h Wed Aug 17 05:24:00 2011 (r225177) @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: cut.h,v 10.10 2011/07/16 18:06:00 zy Exp $ (Berkeley) $Date: 2011/07/16 18:06:00 $ + * $Id: cut.h,v 10.9 2000/07/22 17:31:18 skimo Exp $ (Berkeley) $Date: 2000/07/22 17:31:18 $ */ typedef struct _texth TEXTH; /* TEXT list head structure. */ @@ -16,7 +16,8 @@ struct _cb { LIST_ENTRY(_cb) q; /* Linked list of cut buffers. */ TEXTH textq; /* Linked list of TEXT structures. */ - char name; /* Cut buffer name. */ + /* XXXX Needed ? Can non ascii-chars be cut buffer names ? */ + CHAR_T name; /* Cut buffer name. */ size_t len; /* Total length of cut text. */ #define CB_LMODE 0x01 /* Cut was in line mode. */ Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/encoding.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/encoding.c Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/encoding.c Wed Aug 17 05:24:00 2011 (r225177) @@ -73,17 +73,17 @@ int following; if ((buf[i] & 0x20) == 0) /* 110xxxxx */ - if ((buf[1] & 0x3e)) /* C0, C1 */ + if (buf[i] > '\xc1') /* C0, C1 */ following = 1; else return -1; else if ((buf[i] & 0x10) == 0) /* 1110xxxx */ following = 2; else if ((buf[i] & 0x08) == 0) /* 11110xxx */ - if ((u_char)buf[i] < 0xf5 || 0xf7 < (u_char)buf[i]) + if (buf[i] < '\xf5') following = 3; else return -1; /* F5, F6, F7 */ else - return -1; + return -1; /* F8~FF */ for (n = 0; n < following; n++) { i++; Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/exf.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/exf.c Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/exf.c Wed Aug 17 05:24:00 2011 (r225177) @@ -1246,21 +1246,26 @@ int st = looks_utf16(buf, blen); if (st > 0) { char *np; - size_t nlen; db_rget(sp, 1, &p, &len); - nlen = len-2; - GET_SPACE_GOTOC(sp, np, nlen, nlen); - memcpy(sp->ep->_bom, p, 2); - memcpy(np, p+2, len-2); - db_rset(sp, 1, np, len-2); /* store w/o the BOM */ + if ((np = malloc(len-2))) { + memcpy(sp->ep->_bom, p, 2); + memcpy(np, p+2, len-2); + db_rset(sp, 1, np, len-2); /* store w/o the BOM */ + free(np); + } } - if (st == 1) + if (st == 1) { + DBT key, data; + recno_t lno; + key.data = &lno; + key.size = sizeof(lno); + !sp->ep->db->seq(sp->ep->db, &key, &data, R_LAST) && + *(char*)data.data == '\0' && sp->ep->db->del(sp->ep->db, &key, 0); o_set(sp, O_FILEENCODING, OS_STRDUP, "utf-16le", 0); - else if (st == 2) + } else if (st == 2) o_set(sp, O_FILEENCODING, OS_STRDUP, "utf-16be", 0); } /* Fallback to locale encoding */ -alloc_err:; #endif } Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/mark.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/mark.h Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/mark.h Wed Aug 17 05:24:00 2011 (r225177) @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: mark.h,v 10.7 2011/07/16 18:07:30 zy Exp $ (Berkeley) $Date: 2011/07/16 18:07:30 $ + * $Id: mark.h,v 10.6 2011/07/04 14:41:51 zy Exp $ (Berkeley) $Date: 2011/07/04 14:41:51 $ */ /* @@ -31,7 +31,8 @@ LIST_ENTRY(_lmark) q; /* Linked list of marks. */ recno_t lno; /* Line number. */ size_t cno; /* Column number. */ - char name; /* Mark name. */ + /* XXXX Needed ? Can non ascii-chars be mark names ? */ + CHAR_T name; /* Mark name. */ #define MARK_DELETED 0x01 /* Mark was deleted. */ #define MARK_USERSET 0x02 /* User set this mark. */ Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/multibyte.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/multibyte.h Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/multibyte.h Wed Aug 17 05:24:00 2011 (r225177) @@ -33,6 +33,9 @@ typedef wchar_t CHAR_T; #define MAX_CHAR_T 0x7fffffff typedef u_int UCHAR_T; +typedef wchar_t RCHAR_T; +#define RCHAR_T_MAX ((1 << 24)-1) +#define RCHAR_BIT 24 #define STRLEN wcslen #define STRTOL wcstol @@ -50,10 +53,13 @@ typedef u_char CHAR_T; #define MAX_CHAR_T 0xff typedef u_char UCHAR_T; +typedef char RCHAR_T; +#define RCHAR_T_MAX CHAR_MAX +#define RCHAR_BIT CHAR_BIT #define STRLEN strlen -#define STRTOL strtol -#define STRTOUL strtoul +#define STRTOL(a,b,c) (strtol(a,(char**)b,c)) +#define STRTOUL(a,b,c) (strtoul(a,(char**)b,c)) #define SPRINTF snprintf #define STRCMP strcmp #define STRPBRK strpbrk Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/options.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/options.c Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/options.c Wed Aug 17 05:24:00 2011 (r225177) @@ -358,7 +358,7 @@ (void)SPRINTF(b2, SIZE(b2), L("directory=%s"), (s = getenv("TMPDIR")) == NULL ? _PATH_TMP : s); OI(O_TMPDIR, b2); - OI(O_ESCAPETIME, L("escapetime=1")); + OI(O_ESCAPETIME, L("escapetime=6")); OI(O_KEYTIME, L("keytime=6")); OI(O_MATCHTIME, L("matchtime=7")); (void)SPRINTF(b2, SIZE(b2), L("msgcat=%s"), _PATH_MSGCAT); Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/common/screen.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/common/screen.h Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/common/screen.h Wed Aug 17 05:24:00 2011 (r225177) @@ -107,8 +107,8 @@ #define RE_C_SUBST 0x0008 /* Compile substitute replacement. */ #define RE_C_TAG 0x0010 /* Compile ctag pattern. */ -#define RE_WSTART "[[:<:]]" /* Ex/vi: not-in-word search pattern. */ -#define RE_WSTOP "[[:>:]]" +#define RE_WSTART L("[[:<:]]") /* Ex/vi: not-in-word search pattern. */ +#define RE_WSTOP L("[[:>:]]") #define RE_WSTART_LEN (sizeof(RE_WSTART)/sizeof(CHAR_T)-1) #define RE_WSTOP_LEN (sizeof(RE_WSTOP)/sizeof(CHAR_T)-1) /* Ex/vi: flags to search routines. */ Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/docs/man/vi.1 ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/docs/man/vi.1 Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/docs/man/vi.1 Wed Aug 17 05:24:00 2011 (r225177) @@ -8,9 +8,9 @@ .\" .\" See the LICENSE file for redistribution information. .\" -.\" $Id: vi.1,v 8.54 2011/07/14 00:25:04 zy Exp $ (Berkeley) $Date: 2011/07/14 00:25:04 $ +.\" $Id: vi.1,v 8.55 2011/08/16 12:31:39 zy Exp $ (Berkeley) $Date: 2011/08/16 12:31:39 $ .\" -.TH VI 1 "%Q%" +.TH VI 1 "16 August, 2011" .UC .SH NAME ex, vi, view \- text editors @@ -1380,8 +1380,7 @@ Set the window size for the screen. .TP .B "windowname [off]" -Change the icon/window name to the current file name even if it can't -be restored on editor exit. +Change the icon/window name to the current file name. .TP .B "wraplen, wl [0]" .I \&Vi @@ -1592,14 +1591,7 @@ source for all of these documents is distributed with .I nex/nvi in the -.I nvi/USD.doc -directory of the -.I nex/nvi -source code. -.sp -The files ``autowrite'', ``input'', ``quoting'' and ``structures'' -found in the -.I nvi/docs/internals +.I nvi/docs directory of the .I nex/nvi source code. Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex.h Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex.h Wed Aug 17 05:24:00 2011 (r225177) @@ -133,7 +133,7 @@ #define E_C_PRINT 0x01000 /* p flag. */ u_int16_t iflags; /* User input information. */ -#define __INUSE2 0x000004ff /* Same name space as EXCMDLIST. */ +#define __INUSE2 0x000007ff /* Same name space as EXCMDLIST. */ #define E_BLIGNORE 0x00000800 /* Ignore blank lines. */ #define E_NAMEDISCARD 0x00001000 /* Free/discard the name. */ #define E_NOAUTO 0x00002000 /* Don't do autoprint output. */ Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_version.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_version.c Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_version.c Wed Aug 17 05:24:00 2011 (r225177) @@ -32,6 +32,7 @@ int ex_version(SCR *sp, EXCMD *cmdp) { - msgq(sp, M_INFO, VI_VERSION); + msgq(sp, M_INFO, "Version "VI_VERSION + " The CSRG, University of California, Berkeley."); return (0); } Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_write.c ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_write.c Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/ex_write.c Wed Aug 17 05:24:00 2011 (r225177) @@ -318,7 +318,11 @@ lcnt = 0; msg = "253|Writing..."; +#if defined(USE_WIDECHAR) && defined(USE_ICONV) isutf16 = !strncasecmp(O_STR(sp, O_FILEENCODING), "utf-16", 6); +#else + isutf16 = 0; +#endif if (tline != 0) { if (sp->ep->bom && fwrite(&sp->ep->bom, 2, 1, fp) != 1) @@ -340,9 +344,14 @@ if (fwrite(f, 1, flen, fp) != flen) goto err; ccnt += len; - if (isutf16 && putc('\0', fp) != '\0') - break; /* UTF-16 uses '000a' as EOL */ - if (putc('\n', fp) != '\n') + /* UTF-16 w/o BOM is big-endian */ + if (isutf16 && sp->ep->_bom[0] != '\xff') { /* UTF-16BE */ + if (fwrite("\0\x0a", 1, 2, fp) != 2) + break; + } else if (sp->ep->_bom[0] == '\xff') { /* UTF-16LE */ + if (fwrite("\x0a\0", 1, 2, fp) != 2) + break; + } else if (putc('\n', fp) != '\n') break; ++ccnt; } Modified: soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/version.h ============================================================================== --- soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/version.h Wed Aug 17 03:44:47 2011 (r225176) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/ex/version.h Wed Aug 17 05:24:00 2011 (r225177) @@ -1,2 +1 @@ -#define VI_VERSION \ - "nvi-2.0.0 (2011/07/11) The CSRG, University of California, Berkeley." +#define VI_VERSION "nvi-2.0.1 (2011-08-16)" Added: soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/COPYRIGHT ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/COPYRIGHT Wed Aug 17 05:24:00 2011 (r225177) @@ -0,0 +1,56 @@ +Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved. +This software is not subject to any license of the American Telephone +and Telegraph Company or of the Regents of the University of California. + +Permission is granted to anyone to use this software for any purpose on +any computer system, and to alter it and redistribute it, subject +to the following restrictions: + +1. The author is not responsible for the consequences of use of this + software, no matter how awful, even if they arise from flaws in it. + +2. The origin of this software must not be misrepresented, either by + explicit claim or by omission. Since few users ever read sources, + credits must appear in the documentation. + +3. Altered versions must be plainly marked as such, and must not be + misrepresented as being the original software. Since few users + ever read sources, credits must appear in the documentation. + +4. This notice may not be removed or altered. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +/*- + * Copyright (c) 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. + * + * @(#)COPYRIGHT 8.1 (Berkeley) 3/16/94 + */ Added: soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/WHATSNEW ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/WHATSNEW Wed Aug 17 05:24:00 2011 (r225177) @@ -0,0 +1,94 @@ +# @(#)WHATSNEW 8.3 (Berkeley) 3/18/94 + +New in alpha3.4: The complex bug alluded to below has been fixed (in a +slightly kludgey temporary way that may hurt efficiency a bit; this is +another "get it out the door for 4.4" release). The tests at the end of +the tests file have accordingly been uncommented. The primary sign of +the bug was that something like a?b matching ab matched b rather than ab. +(The bug was essentially specific to this exact situation, else it would +have shown up earlier.) + +New in alpha3.3: The definition of word boundaries has been altered +slightly, to more closely match the usual programming notion that "_" +is an alphabetic. Stuff used for pre-ANSI systems is now in a subdir, +and the makefile no longer alludes to it in mysterious ways. The +makefile has generally been cleaned up some. Fixes have been made +(again!) so that the regression test will run without -DREDEBUG, at +the cost of weaker checking. A workaround for a bug in some folks' + has been added. And some more things have been added to +tests, including a couple right at the end which are commented out +because the code currently flunks them (complex bug; fix coming). +Plus the usual minor cleanup. + +New in alpha3.2: Assorted bits of cleanup and portability improvement +(the development base is now a BSDI system using GCC instead of an ancient +Sun system, and the newer compiler exposed some glitches). Fix for a +serious bug that affected REs using many [] (including REG_ICASE REs +because of the way they are implemented), *sometimes*, depending on +memory-allocation patterns. The header-file prototypes no longer name +the parameters, avoiding possible name conflicts. The possibility that +some clot has defined CHAR_MIN as (say) `-128' instead of `(-128)' is +now handled gracefully. "uchar" is no longer used as an internal type +name (too many people have the same idea). Still the same old lousy +performance, alas. + +New in alpha3.1: Basically nothing, this release is just a bookkeeping +convenience. Stay tuned. + +New in alpha3.0: Performance is no better, alas, but some fixes have been +made and some functionality has been added. (This is basically the "get +it out the door in time for 4.4" release.) One bug fix: regfree() didn't +free the main internal structure (how embarrassing). It is now possible +to put NULs in either the RE or the target string, using (resp.) a new +REG_PEND flag and the old REG_STARTEND flag. The REG_NOSPEC flag to +regcomp() makes all characters ordinary, so you can match a literal +string easily (this will become more useful when performance improves!). +There are now primitives to match beginnings and ends of words, although +the syntax is disgusting and so is the implementation. The REG_ATOI +debugging interface has changed a bit. And there has been considerable +internal cleanup of various kinds. + +New in alpha2.3: Split change list out of README, and moved flags notes +into Makefile. Macro-ized the name of regex(7) in regex(3), since it has +to change for 4.4BSD. Cleanup work in engine.c, and some new regression +tests to catch tricky cases thereof. + +New in alpha2.2: Out-of-date manpages updated. Regerror() acquires two +small extensions -- REG_ITOA and REG_ATOI -- which avoid debugging kludges +in my own test program and might be useful to others for similar purposes. +The regression test will now compile (and run) without REDEBUG. The +BRE \$ bug is fixed. Most uses of "uchar" are gone; it's all chars now. +Char/uchar parameters are now written int/unsigned, to avoid possible +portability problems with unpromoted parameters. Some unsigned casts have +been introduced to minimize portability problems with shifting into sign +bits. + +New in alpha2.1: Lots of little stuff, cleanup and fixes. The one big +thing is that regex.h is now generated, using mkh, rather than being +supplied in the distribution; due to circularities in dependencies, +you have to build regex.h explicitly by "make h". The two known bugs +have been fixed (and the regression test now checks for them), as has a +problem with assertions not being suppressed in the absence of REDEBUG. +No performance work yet. + +New in alpha2: Backslash-anything is an ordinary character, not an +error (except, of course, for the handful of backslashed metacharacters +in BREs), which should reduce script breakage. The regression test +checks *where* null strings are supposed to match, and has generally +been tightened up somewhat. Small bug fixes in parameter passing (not +harmful, but technically errors) and some other areas. Debugging +invoked by defining REDEBUG rather than not defining NDEBUG. + +New in alpha+3: full prototyping for internal routines, using a little +helper program, mkh, which extracts prototypes given in stylized comments. +More minor cleanup. Buglet fix: it's CHAR_BIT, not CHAR_BITS. Simple +pre-screening of input when a literal string is known to be part of the +RE; this does wonders for performance. + +New in alpha+2: minor bits of cleanup. Notably, the number "32" for the +word width isn't hardwired into regexec.c any more, the public header +file prototypes the functions if __STDC__ is defined, and some small typos +in the manpages have been fixed. + +New in alpha+1: improvements to the manual pages, and an important +extension, the REG_STARTEND option to regexec(). Added: soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/cclass.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/cclass.h Wed Aug 17 05:24:00 2011 (r225177) @@ -0,0 +1,83 @@ +/*- + * Copyright (c) 1992, 1993, 1994 Henry Spencer. + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer of the University of Toronto. + * + * 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. + * + * @(#)cclass.h 8.2 (Berkeley) 3/16/94 + */ + +RCHAR_T ALNUM[] = {'a','l','n','u','m',0}; +RCHAR_T ALPHA[] = {'a','l','p','h','a',0}; +RCHAR_T BLANK[] = {'b','l','a','n','k',0}; +RCHAR_T CNTRL[] = {'c','n','t','r','l',0}; +RCHAR_T DIGIT[] = {'d','i','g','i','t',0}; +RCHAR_T GRAPH[] = {'g','r','a','p','h',0}; +RCHAR_T LOWER[] = {'l','o','w','e','r',0}; +RCHAR_T PRINT[] = {'p','r','i','n','t',0}; +RCHAR_T PUNCT[] = {'p','u','n','c','t',0}; +RCHAR_T SPACE[] = {'s','p','a','c','e',0}; +RCHAR_T UPPER[] = {'u','p','p','e','r',0}; +RCHAR_T XDIGIT[] = {'x','d','i','g','i','t',0}; + +/* character-class table */ +static struct cclass { + RCHAR_T *name; + char *chars; + char *multis; +} cclasses[] = { + ALNUM, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ +0123456789", "", + ALPHA, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", + "", + BLANK, " \t", "", + CNTRL, "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\ +\25\26\27\30\31\32\33\34\35\36\37\177", "", + DIGIT, "0123456789", "", + GRAPH, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ +0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", + "", + LOWER, "abcdefghijklmnopqrstuvwxyz", + "", + PRINT, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ +0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", + "", + PUNCT, "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", + "", + SPACE, "\t\n\v\f\r ", "", + UPPER, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", + "", + XDIGIT, "0123456789ABCDEFabcdef", + "", + NULL, 0, "" +}; Added: soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/cname.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/cname.h Wed Aug 17 05:24:00 2011 (r225177) @@ -0,0 +1,141 @@ +/*- + * Copyright (c) 1992, 1993, 1994 Henry Spencer. + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer of the University of Toronto. + * + * 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. + * + * @(#)cname.h 8.2 (Berkeley) 3/16/94 + */ + +/* character-name table */ +static struct cname { + RCHAR_T *name; + char code; +} cnames[] = { + L("NUL"), '\0', + L("SOH"), '\001', + L("STX"), '\002', + L("ETX"), '\003', + L("EOT"), '\004', + L("ENQ"), '\005', + L("ACK"), '\006', + L("BEL"), '\007', + L("alert"), '\007', + L("BS"), '\010', + L("backspace"), '\b', + L("HT"), '\011', + L("tab"), '\t', + L("LF"), '\012', + L("newline"), '\n', + L("VT"), '\013', + L("vertical-tab"), '\v', + L("FF"), '\014', + L("form-feed"), '\f', + L("CR"), '\015', + L("carriage-return"), '\r', + L("SO"), '\016', + L("SI"), '\017', + L("DLE"), '\020', + L("DC1"), '\021', + L("DC2"), '\022', + L("DC3"), '\023', + L("DC4"), '\024', + L("NAK"), '\025', + L("SYN"), '\026', + L("ETB"), '\027', + L("CAN"), '\030', + L("EM"), '\031', + L("SUB"), '\032', + L("ESC"), '\033', + L("IS4"), '\034', + L("FS"), '\034', + L("IS3"), '\035', + L("GS"), '\035', + L("IS2"), '\036', + L("RS"), '\036', + L("IS1"), '\037', + L("US"), '\037', + L("space"), ' ', + L("exclamation-mark"), '!', + L("quotation-mark"), '"', + L("number-sign"), '#', + L("dollar-sign"), '$', + L("percent-sign"), '%', + L("ampersand"), '&', + L("apostrophe"), '\'', + L("left-parenthesis"), '(', + L("right-parenthesis"), ')', + L("asterisk"), '*', + L("plus-sign"), '+', + L("comma"), ',', + L("hyphen"), '-', + L("hyphen-minus"), '-', + L("period"), '.', + L("full-stop"), '.', + L("slash"), '/', + L("solidus"), '/', + L("zero"), '0', + L("one"), '1', + L("two"), '2', + L("three"), '3', + L("four"), '4', + L("five"), '5', + L("six"), '6', + L("seven"), '7', + L("eight"), '8', + L("nine"), '9', + L("colon"), ':', + L("semicolon"), ';', + L("less-than-sign"), '<', + L("equals-sign"), '=', + L("greater-than-sign"), '>', + L("question-mark"), '?', + L("commercial-at"), '@', + L("left-square-bracket"), '[', + L("backslash"), '\\', + L("reverse-solidus"), '\\', + L("right-square-bracket"), ']', + L("circumflex"), '^', + L("circumflex-accent"), '^', + L("underscore"), '_', + L("low-line"), '_', + L("grave-accent"), '`', + L("left-brace"), '{', + L("left-curly-bracket"), '{', + L("vertical-line"), '|', + L("right-brace"), '}', + L("right-curly-bracket"), '}', + L("tilde"), '~', + L("DEL"), '\177', + NULL, 0, +}; Added: soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/engine.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2011/zy/nvi-iconv/head/contrib/nvi2/regex/engine.c Wed Aug 17 05:24:00 2011 (r225177) @@ -0,0 +1,1091 @@ +/*- + * Copyright (c) 1992, 1993, 1994 Henry Spencer. + * Copyright (c) 1992, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer of the University of Toronto. + * + * 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. + * + * @(#)engine.c 8.4 (Berkeley) 3/19/94 + */ + +/* + * The matching engine and friends. This file is #included by regexec.c + * after suitable #defines of a variety of macros used herein, so that + * different state representations can be used without duplicating masses + * of code. + */ + +#ifdef SNAMES +#define matcher smatcher +#define fast sfast +#define slow sslow +#define dissect sdissect +#define backref sbackref +#define step sstep +#define print sprint +#define at sat +#define match smat +#endif +#ifdef LNAMES +#define matcher lmatcher +#define fast lfast +#define slow lslow +#define dissect ldissect +#define backref lbackref +#define step lstep +#define print lprint +#define at lat +#define match lmat +#endif + +/* another structure passed up and down to avoid zillions of parameters */ +struct match { + struct re_guts *g; + int eflags; + regmatch_t *pmatch; /* [nsub+1] (0 element unused) */ + const RCHAR_T *offp; /* offsets work from here */ + const RCHAR_T *beginp; /* start of string -- virtual NUL precedes */ + const RCHAR_T *endp; /* end of string -- virtual NUL here */ + const RCHAR_T *coldp; /* can be no match starting before here */ + const RCHAR_T **lastpos; /* [nplus+1] */ + STATEVARS; + states st; /* current states */ + states fresh; /* states for a fresh start */ + states tmp; /* temporary */ + states empty; /* empty set of states */ +}; + +/* ========= begin header generated by ./mkh ========= */ +#ifdef __cplusplus +extern "C" { +#endif + +/* === engine.c === */ +static int matcher __P((struct re_guts *g, const RCHAR_T *string, size_t nmatch, regmatch_t pmatch[], int eflags)); +static const RCHAR_T *dissect __P((struct match *m, const RCHAR_T *start, const RCHAR_T *stop, sopno startst, sopno stopst)); +static const RCHAR_T *backref __P((struct match *m, const RCHAR_T *start, const RCHAR_T *stop, sopno startst, sopno stopst, sopno lev)); +static const RCHAR_T *fast __P((struct match *m, const RCHAR_T *start, const RCHAR_T *stop, sopno startst, sopno stopst)); +static const RCHAR_T *slow __P((struct match *m, const RCHAR_T *start, const RCHAR_T *stop, sopno startst, sopno stopst)); +static states step __P((struct re_guts *g, sopno start, sopno stop, states bef, int ch, states aft)); +#define BOL (OUT+1) +#define EOL (BOL+1) +#define BOLEOL (BOL+2) +#define NOTHING (BOL+3) +#define BOW (BOL+4) +#define EOW (BOL+5) +#define CODEMAX (BOL+5) /* highest code used */ +#define NONCHAR(c) ((c) > RCHAR_T_MAX) +#define NNONCHAR (CODEMAX-CHAR_MAX) +#ifdef REDEBUG +static void print __P((struct match *m, char *caption, states st, int ch, FILE *d)); +#endif +#ifdef REDEBUG +static void at __P((struct match *m, char *title, char *start, char *stop, sopno startst, sopno stopst)); +#endif +#ifdef REDEBUG +static char *pchar __P((int ch)); +#endif + +#ifdef __cplusplus +} +#endif +/* ========= end header generated by ./mkh ========= */ + +#ifdef REDEBUG +#define SP(t, s, c) print(m, t, s, c, stdout) +#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2) +#define NOTE(str) { if (m->eflags®_TRACE) printf("=%s\n", (str)); } +#else +#define SP(t, s, c) /* nothing */ +#define AT(t, p1, p2, s1, s2) /* nothing */ +#define NOTE(s) /* nothing */ +#endif + +/* + - matcher - the actual matching engine *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***