Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/vgrind first attempt at toolification.
details: https://anonhg.NetBSD.org/src/rev/4d2edf03ca92
branches: trunk
changeset: 330596:4d2edf03ca92
user: christos <christos%NetBSD.org@localhost>
date: Tue Jul 15 13:17:15 2014 +0000
description:
first attempt at toolification.
diffstat:
usr.bin/vgrind/Makefile | 10 +-
usr.bin/vgrind/extern.h | 9 +-
usr.bin/vgrind/pathnames.h | 4 +-
usr.bin/vgrind/regexp.c | 150 ++++++++++---------
usr.bin/vgrind/vfontedpr.c | 176 +++++++++++-----------
usr.bin/vgrind/vgrindefs.c | 337 ---------------------------------------------
6 files changed, 180 insertions(+), 506 deletions(-)
diffs (truncated from 1218 to 300 lines):
diff -r 332eb383288d -r 4d2edf03ca92 usr.bin/vgrind/Makefile
--- a/usr.bin/vgrind/Makefile Tue Jul 15 11:43:54 2014 +0000
+++ b/usr.bin/vgrind/Makefile Tue Jul 15 13:17:15 2014 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.21 2009/04/14 22:15:28 lukem Exp $
+# $NetBSD: Makefile,v 1.22 2014/07/15 13:17:15 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/9/93
+WARNS=6
.include <bsd.own.mk>
PROG= vfontedpr
@@ -13,8 +14,8 @@
FILES= tmac.vgrind vgrindefs.src vgrindefs.src.db
FILESNAME_vgrindefs.src= vgrindefs
FILESNAME_vgrindefs.src.db= vgrindefs.db
-FILESDIR= /usr/share/misc
-FILESDIR_tmac.vgrind= /usr/share/tmac
+FILESDIR?= /usr/share/misc
+FILESDIR_tmac.vgrind?= /usr/share/tmac
FILESNAME_tmac.vgrind= vgrind.tmac
.endif
@@ -35,8 +36,7 @@
.if ${MKSHARE} != "no"
vgrindefs.src.db: vgrindefs.src
${_MKTARGET_CREATE}
- ${TOOL_CAP_MKDB} ${CAP_MKDB_ENDIAN} -f vgrindefs.src \
- ${.CURDIR}/vgrindefs.src
+ ${TOOL_CAP_MKDB} ${CAP_MKDB_ENDIAN} -f vgrindefs.src ${.ALLSRC}
.else
vgrindefs.src.db:
.endif
diff -r 332eb383288d -r 4d2edf03ca92 usr.bin/vgrind/extern.h
--- a/usr.bin/vgrind/extern.h Tue Jul 15 11:43:54 2014 +0000
+++ b/usr.bin/vgrind/extern.h Tue Jul 15 13:17:15 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.5 2004/04/23 22:14:57 christos Exp $ */
+/* $NetBSD: extern.h,v 1.6 2014/07/15 13:17:15 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -32,9 +32,8 @@
* @(#)extern.h 8.1 (Berkeley) 6/6/93
*/
-typedef int boolean;
-extern boolean x_escaped; /* if last character was an escape */
+extern bool x_escaped; /* if last character was an escape */
extern char *x_start; /* start of the current string */
extern char *l_acmbeg; /* string introducing a comment */
extern char *l_acmend; /* string ending a comment */
@@ -46,11 +45,11 @@
extern char *l_comend; /* string ending a comment */
extern char l_escape; /* character used to escape characters */
extern char *l_keywds[]; /* keyword table address */
-extern boolean l_onecase; /* upper and lower case are equivalent */
+extern bool l_onecase; /* upper and lower case are equivalent */
extern char *l_prcbeg; /* regular expr for procedure begin */
extern char *l_strbeg; /* delimiter for string constant */
extern char *l_strend; /* delimiter for string constant */
-extern boolean l_toplex; /* procedures only defined at top lex level */
+extern bool l_toplex; /* procedures only defined at top lex level */
extern const char *language; /* the language indicator */
#include <sys/cdefs.h>
diff -r 332eb383288d -r 4d2edf03ca92 usr.bin/vgrind/pathnames.h
--- a/usr.bin/vgrind/pathnames.h Tue Jul 15 11:43:54 2014 +0000
+++ b/usr.bin/vgrind/pathnames.h Tue Jul 15 13:17:15 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pathnames.h,v 1.4 2003/08/07 11:17:00 agc Exp $ */
+/* $NetBSD: pathnames.h,v 1.5 2014/07/15 13:17:15 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -31,4 +31,6 @@
* @(#)pathnames.h 8.1 (Berkeley) 6/6/93
*/
+#ifndef _PATH_VGRINDEFS
#define _PATH_VGRINDEFS "/usr/share/misc/vgrindefs"
+#endif
diff -r 332eb383288d -r 4d2edf03ca92 usr.bin/vgrind/regexp.c
--- a/usr.bin/vgrind/regexp.c Tue Jul 15 11:43:54 2014 +0000
+++ b/usr.bin/vgrind/regexp.c Tue Jul 15 13:17:15 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: regexp.c,v 1.12 2012/03/20 20:34:59 matt Exp $ */
+/* $NetBSD: regexp.c,v 1.13 2014/07/15 13:17:15 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -30,6 +30,10 @@
* SUCH DAMAGE.
*/
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1980, 1993\
@@ -40,27 +44,31 @@
#if 0
static char sccsid[] = "@(#)regexp.c 8.1 (Berkeley) 6/6/93";
#endif
-__RCSID("$NetBSD: regexp.c,v 1.12 2012/03/20 20:34:59 matt Exp $");
+__RCSID("$NetBSD: regexp.c,v 1.13 2014/07/15 13:17:15 christos Exp $");
#endif /* not lint */
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include "extern.h"
-#define FALSE 0
-#define TRUE !(FALSE)
-#define NIL 0
+static void expconv (void);
-static void expconv __P((void));
-
-boolean x_escaped; /* true if we are currently x_escaped */
+bool x_escaped; /* true if we are currently x_escaped */
char *x_start; /* start of string */
-boolean l_onecase; /* true if upper and lower equivalent */
+bool l_onecase; /* true if upper and lower equivalent */
#define makelower(c) (isupper((unsigned char)(c)) ? tolower((unsigned char)(c)) : (c))
+static char
+tocc(ptrdiff_t x) {
+ if (x & ~0xff)
+ abort();
+ return (char)x;
+}
+
/* STRNCMP - like strncmp except that we convert the
* first string to lower case before comparing
* if l_onecase is set.
@@ -72,7 +80,7 @@
if (l_onecase) {
do
if (*s2 - makelower(*s1))
- return (*s2 - makelower(*s1));
+ return *s2 - makelower(*s1);
else {
s2++;
s1++;
@@ -81,7 +89,7 @@
} else {
do
if (*s2 - *s1)
- return (*s2 - *s1);
+ return *s2 - *s1;
else {
s2++;
s1++;
@@ -152,10 +160,10 @@
char *cre; /* pointer to converted regular expression */
/* allocate room for the converted expression */
- if (re == NIL)
- return (NIL);
+ if (re == NULL)
+ return NULL;
if (*re == '\0')
- return (NIL);
+ return NULL;
cre = malloc(4 * strlen(re) + 3);
ccre = cre;
ure = re;
@@ -168,7 +176,7 @@
/* start the conversion (its recursive) */
expconv();
*ccre = 0;
- return (cre);
+ return cre;
}
static void
@@ -180,9 +188,9 @@
int temp;
/* let the conversion begin */
- acs = NIL;
- cs = NIL;
- while (*ure != NIL) {
+ acs = NULL;
+ cs = NULL;
+ while (*ure) {
switch (c = *ure++) {
case '\\':
@@ -190,7 +198,7 @@
/* escaped characters are just characters */
default:
- if (cs == NIL || (*cs & STR) == 0) {
+ if (cs == NULL || (*cs & STR) == 0) {
cs = ccre;
*cs = STR;
SCNT(cs) = 1;
@@ -205,13 +213,13 @@
case 'd':
case 'e':
case 'p':
- if (acs != NIL && acs != cs) {
+ if (acs != NULL && acs != cs) {
do {
temp = OCNT(acs);
- OCNT(acs) = ccre - acs;
+ OCNT(acs) = tocc(ccre - acs);
acs -= temp;
} while (temp != 0);
- acs = NIL;
+ acs = NULL;
}
cs = ccre;
*cs = META;
@@ -224,13 +232,13 @@
/* just put the symbol in */
case '^':
case '$':
- if (acs != NIL && acs != cs) {
+ if (acs != NULL && acs != cs) {
do {
temp = OCNT(acs);
- OCNT(acs) = ccre - acs;
+ OCNT(acs) = tocc(ccre - acs);
acs -= temp;
} while (temp != 0);
- acs = NIL;
+ acs = NULL;
}
cs = ccre;
*cs = META;
@@ -246,31 +254,31 @@
/* recurse and define a subexpression */
case '(':
- if (acs != NIL && acs != cs) {
+ if (acs != NULL && acs != cs) {
do {
temp = OCNT(acs);
- OCNT(acs) = ccre - acs;
+ OCNT(acs) = tocc(ccre - acs);
acs -= temp;
} while (temp != 0);
- acs = NIL;
+ acs = NULL;
}
cs = ccre;
*cs = OPER;
OSYM(cs) = '(';
ccre = ONEXT(cs);
expconv();
- OCNT(cs) = ccre - cs; /* offset to next symbol */
+ OCNT(cs) = tocc(ccre - cs); /* offset to next symbol */
break;
/* reurn from a recursion */
case ')':
- if (acs != NIL) {
+ if (acs != NULL) {
do {
temp = OCNT(acs);
- OCNT(acs) = ccre - acs;
+ OCNT(acs) = tocc(ccre - acs);
acs -= temp;
} while (temp != 0);
- acs = NIL;
+ acs = NULL;
}
cs = ccre;
*cs = META;
@@ -282,8 +290,8 @@
/* the third byte will contain an offset to jump over the */
/* alternate match in case the first did not fail */
case '|':
- if (acs != NIL && acs != cs)
- OCNT(ccre) = ccre - acs; /* make a back pointer */
+ if (acs != NULL && acs != cs)
+ OCNT(ccre) = tocc(ccre - acs); /* make a back pointer */
else
OCNT(ccre) = 0;
assert(cs != NULL);
@@ -297,7 +305,7 @@
/* if its not a metasymbol just build a scharacter string */
default:
- if (cs == NIL || (*cs & STR) == 0) {
+ if (cs == NULL || (*cs & STR) == 0) {
cs = ccre;
*cs = STR;
SCNT(cs) = 1;
@@ -308,13 +316,13 @@
Home |
Main Index |
Thread Index |
Old Index