PERFORCE change 155574 for review
Gabor Kovesdan
gabor at FreeBSD.org
Fri Jan 2 10:14:55 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=155574
Change 155574 by gabor at gabor_server on 2009/01/02 10:14:14
IFC
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/src/gnu/usr.bin/Makefile#2 integrate
.. //depot/projects/soc2008/gabor_textproc/src/share/mk/bsd.kmod.mk#2 integrate
.. //depot/projects/soc2008/gabor_textproc/src/share/mk/bsd.libnames.mk#2 integrate
.. //depot/projects/soc2008/gabor_textproc/src/share/mk/bsd.own.mk#4 integrate
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_ACCT#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_AMD#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_APM#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_AT#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_BSNMP#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_CTM#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_FLOPPY#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_FREEBSD_UPDATE#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_IPFW#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_JAIL#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_LEGACY_CONSOLE#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_LOCATE#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_MAIL#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_MAKE#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_NDIS#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_NETGRAPH#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_NETGRAPH_SUPPORT#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_NTP#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_PKGTOOLS#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_PMC#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_PORTSNAP#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_PPP#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_QUOTAS#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_ROUTED#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_SLIP#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_SYSINSTALL#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_TELNET#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_TEXTPROC#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_WIRELESS#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/tools/build/options/WITHOUT_WIRELESS_SUPPORT#1 branch
.. //depot/projects/soc2008/gabor_textproc/src/usr.bin/Makefile#3 integrate
.. //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/Makefile#4 integrate
.. //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/fastgrep.c#2 integrate
.. //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/file.c#6 integrate
.. //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/grep.c#4 integrate
.. //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/grep.h#4 integrate
.. //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/queue.c#2 integrate
.. //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/util.c#4 integrate
Differences ...
==== //depot/projects/soc2008/gabor_textproc/src/gnu/usr.bin/Makefile#2 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/gnu/usr.bin/Makefile,v 1.97 2008/06/16 05:48:15 dougb Exp $
+# $FreeBSD: src/gnu/usr.bin/Makefile,v 1.99 2008/09/21 22:02:26 sam Exp $
.include <bsd.own.mk>
@@ -22,7 +22,11 @@
send-pr \
sort \
${_texinfo}
-
+
+.if ${MACHINE_ARCH} == "mips"
+MK_GDB=no # not yet
+.endif
+
.if ${MK_CXX} != "no"
_gperf= gperf
.if ${MK_GROFF} != "no"
@@ -42,12 +46,16 @@
_grep= grep
.endif
+.if ${MK_INFO} != "no"
+_texinfo= texinfo
+.endif
+
.if ${MK_MAN} != "no"
_man= man
.endif
-.if ${MK_INFO} != "no"
-_texinfo= texinfo
+.if ${MK_RCS} != "no"
+_rcs= rcs
.endif
.if ${MK_TOOLCHAIN} != "no"
@@ -57,8 +65,5 @@
_gdb= gdb
.endif
.endif
-.if ${MK_RCS} != "no"
-_rcs= rcs
-.endif
.include <bsd.subdir.mk>
==== //depot/projects/soc2008/gabor_textproc/src/share/mk/bsd.kmod.mk#2 (text+ko) ====
@@ -1,8 +1,8 @@
-# $FreeBSD: src/share/mk/bsd.kmod.mk,v 1.91 2004/06/21 16:12:02 bde Exp $
+# $FreeBSD: src/share/mk/bsd.kmod.mk,v 1.92 2008/10/09 22:01:27 imp Exp $
# Search for kernel source tree in standard places.
.for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. ${.CURDIR}/../../../.. \
- /sys /usr/src/sys
+ ${.CURDIR}/../../../../.. /sys /usr/src/sys
.if !defined(SYSDIR) && exists(${_dir}/kern/) && exists(${_dir}/conf/kmod.mk)
SYSDIR= ${_dir}
.endif
==== //depot/projects/soc2008/gabor_textproc/src/share/mk/bsd.libnames.mk#2 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/share/mk/bsd.libnames.mk,v 1.108 2008/05/22 01:14:43 jb Exp $
+# $FreeBSD: src/share/mk/bsd.libnames.mk,v 1.110 2008/12/31 11:12:24 rwatson Exp $
# The include file <bsd.libnames.mk> define library names.
# Other include files (e.g. bsd.prog.mk, bsd.lib.mk) include this
@@ -14,6 +14,7 @@
LIBARCHIVE?= ${DESTDIR}${LIBDIR}/libarchive.a
LIBASN1?= ${DESTDIR}${LIBDIR}/libasn1.a
LIBATM?= ${DESTDIR}${LIBDIR}/libatm.a
+LIBAUDITD?= ${DESTDIR}${LIBDIR}/libauditd.a
LIBAVL?= ${DESTDIR}${LIBDIR}/libavl.a
LIBBEGEMOT?= ${DESTDIR}${LIBDIR}/libbegemot.a
.if ${MK_BIND_LIBS} != "no"
@@ -148,6 +149,7 @@
LIBUGIDFW?= ${DESTDIR}${LIBDIR}/libugidfw.a
LIBUMEM?= ${DESTDIR}${LIBDIR}/libumem.a
LIBUSBHID?= ${DESTDIR}${LIBDIR}/libusbhid.a
+LIBUSB20?= ${DESTDIR}${LIBDIR}/libusb20.a
LIBUTIL?= ${DESTDIR}${LIBDIR}/libutil.a
LIBUUTIL?= ${DESTDIR}${LIBDIR}/libuutil.a
LIBVGL?= ${DESTDIR}${LIBDIR}/libvgl.a
==== //depot/projects/soc2008/gabor_textproc/src/share/mk/bsd.own.mk#4 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/share/mk/bsd.own.mk,v 1.77 2008/06/16 07:23:12 dougb Exp $
+# $FreeBSD: src/share/mk/bsd.own.mk,v 1.78 2008/09/21 22:02:26 sam Exp $
#
# The include file <bsd.own.mk> set common variables for owner,
# group, mode, and directories. Defaults are in brackets.
@@ -282,8 +282,12 @@
# MK_* options which default to "yes".
#
.for var in \
+ ACCT \
ACPI \
+ AMD \
+ APM \
ASSERT_DEBUG \
+ AT \
ATM \
AUDIT \
AUTHPF \
@@ -298,18 +302,22 @@
BOOT \
BSD_CPIO \
BSD_GREP \
+ BSNMP \
BZIP2 \
CALENDAR \
CDDL \
CPP \
CRYPT \
+ CTM \
CVS \
CXX \
DICT \
DYNAMICROOT \
EXAMPLES \
+ FLOPPY \
FORTH \
FP_LIBC \
+ FREEBSD_UPDATE \
GAMES \
GCOV \
GDB \
@@ -321,40 +329,60 @@
INFO \
INSTALLLIB \
IPFILTER \
+ IPFW \
IPX \
+ JAIL \
KERBEROS \
KVM \
+ LEGACY_CONSOLE \
LIB32 \
LIBPTHREAD \
LIBTHR \
LOCALES \
+ LOCATE \
LPR \
+ MAIL \
MAILWRAPPER \
+ MAKE \
MAN \
NCP \
+ NDIS \
NETCAT \
+ NETGRAPH \
NIS \
NLS \
NLS_CATALOGS \
NS_CACHING \
+ NTP \
OBJC \
OPENSSH \
OPENSSL \
PAM \
PF \
+ PKGTOOLS \
+ PMC \
+ PORTSNAP \
+ PPP \
PROFILE \
+ QUOTAS \
RCMDS \
RCS \
RESCUE \
+ ROUTED \
SENDMAIL \
SETUID_LOGIN \
SHAREDOCS \
+ SLIP \
SSP \
+ SYSINSTALL \
SYMVER \
SYSCONS \
TCSH \
+ TELNET \
+ TEXTPROC \
TOOLCHAIN \
USB \
+ WIRELESS \
WPA_SUPPLICANT_EAPOL \
ZFS \
ZONEINFO
@@ -433,6 +461,11 @@
MK_NCP:= no
.endif
+.if ${MK_MAIL} == "no"
+MK_MAILWRAPPER:= no
+MK_SENDMAIL:= no
+.endif
+
.if ${MK_OPENSSL} == "no"
MK_OPENSSH:= no
MK_KERBEROS:= no
@@ -442,6 +475,10 @@
MK_AUTHPF:= no
.endif
+.if ${MK_TEXTPROC} == "no"
+MK_GROFF:= no
+.endif
+
.if ${MK_TOOLCHAIN} == "no"
MK_GDB:= no
.endif
@@ -461,7 +498,9 @@
IPX \
KERBEROS \
KVM \
- PAM
+ NETGRAPH \
+ PAM \
+ WIRELESS
.if defined(WITH_${var}_SUPPORT) && defined(WITHOUT_${var}_SUPPORT)
.error WITH_${var}_SUPPORT and WITHOUT_${var}_SUPPORT can't both be set.
.endif
==== //depot/projects/soc2008/gabor_textproc/src/usr.bin/Makefile#3 (text+ko) ====
@@ -1,5 +1,5 @@
# From: @(#)Makefile 8.3 (Berkeley) 1/7/94
-# $FreeBSD: src/usr.bin/Makefile,v 1.315 2008/06/16 05:48:15 dougb Exp $
+# $FreeBSD: src/usr.bin/Makefile,v 1.320 2008/09/24 20:41:35 marius Exp $
.include <bsd.own.mk>
@@ -13,12 +13,12 @@
apply \
${_ar} \
asa \
- at \
+ ${_at} \
${_atm} \
awk \
banner \
basename \
- biff \
+ ${_biff} \
${_bluetooth} \
brandelf \
bsdiff \
@@ -30,24 +30,24 @@
cap_mkdb \
${_catman} \
chat \
- checknr \
+ ${_checknr} \
${_chkey} \
chpass \
cksum \
cmp \
col \
- colcrt \
+ ${_colcrt} \
colldef \
colrm \
column \
comm \
- compile_et \
+ ${_compile_et} \
compress \
${_cpio} \
cpuset \
csplit \
${_csup} \
- ctags \
+ ${_ctags} \
cut \
${_dig} \
dirname \
@@ -61,12 +61,12 @@
false \
fetch \
file \
- file2c \
+ ${_file2c} \
find \
finger \
- fmt \
+ ${_fmt} \
fold \
- from \
+ ${_from} \
fstat \
fsync \
ftp \
@@ -83,7 +83,7 @@
hexdump \
${_host} \
id \
- indent \
+ ${_indent} \
ipcrm \
ipcs \
join \
@@ -105,7 +105,7 @@
${_lex} \
limits \
locale \
- locate \
+ ${_locate} \
lock \
lockf \
logger \
@@ -116,8 +116,8 @@
lorder \
lsvfs \
m4 \
- mail \
- make \
+ ${_mail} \
+ ${_make} \
makewhatis \
mesg \
minigzip \
@@ -125,10 +125,10 @@
mkdep \
mkfifo \
mklocale \
- mkstr \
+ ${_mkstr} \
mktemp \
mkuzip \
- msgs \
+ ${_msgs} \
mt \
${_nc} \
ncal \
@@ -150,24 +150,23 @@
passwd \
paste \
pathchk \
- pkill \
pr \
printenv \
printf \
procstat \
- quota \
+ ${_quota} \
renice \
rev \
${_rlogin} \
- rpcgen \
+ ${_rpcgen} \
rpcinfo \
rs \
${_rsh} \
rup \
- ruptime \
+ ${_ruptime} \
rusers \
rwall \
- rwho \
+ ${_rwho} \
script \
sed \
shar \
@@ -184,7 +183,7 @@
tar \
tcopy \
tee \
- telnet \
+ ${_telnet} \
tftp \
time \
tip \
@@ -198,10 +197,10 @@
tset \
tsort \
tty \
- ul \
+ ${_ul} \
uname \
unexpand \
- unifdef \
+ ${_unifdef} \
uniq \
units \
unvis \
@@ -211,7 +210,7 @@
uudecode \
uuencode \
${_vacation} \
- vgrind \
+ ${_vgrind} \
vi \
vis \
vmstat \
@@ -228,17 +227,23 @@
xargs \
xinstall \
${_xlint} \
- xstr \
+ ${_xstr} \
${_yacc} \
yes \
${_ypcat} \
${_ypmatch} \
${_ypwhich}
-.if ${MACHINE_ARCH} != "arm"
+.if ${MACHINE_ARCH} != "arm" && ${MACHINE_ARCH} != "mips"
_truss= truss
.endif
+# NB: keep these sorted by MK_* knobs
+
+.if ${MK_AT} != "no"
+_at= at
+.endif
+
.if ${MK_ATM} != "no"
_atm= atm
.endif
@@ -266,6 +271,10 @@
_calendar= calendar
.endif
+.if ${MK_HESIOD} != "no"
+_hesinfo= hesinfo
+.endif
+
.if ${MK_OPENSSL} != "no"
_chkey= chkey
_newkey= newkey
@@ -275,11 +284,24 @@
.endif
.if ${MK_BSD_GREP} != "no"
-_grep= grep
+_grep= grep
+.endif
+
+.if ${MK_LOCATE} != "no"
+_locate= locate
+.endif
+
+# XXX msgs?
+.if ${MK_MAIL} != "no"
+_biff= biff
+_fmt= fmt
+_from= from
+_mail= mail
+_msgs= msgs
.endif
-.if ${MK_HESIOD} != "no"
-_hesinfo= hesinfo
+.if ${MK_MAKE} != "no"
+_make= make
.endif
.if ${MK_NETCAT} != "no"
@@ -292,22 +314,48 @@
_ypwhich= ypwhich
.endif
+.if ${MK_QUOTAS} != "no"
+_quota= quota
+.endif
+
.if ${MK_RCMDS} != "no"
_rlogin= rlogin
_rsh= rsh
+_ruptime= ruptime
+_rwho= rwho
.endif
.if ${MK_SENDMAIL} != "no"
_vacation= vacation
.endif
+.if ${MK_TELNET} != "no"
+_telnet= telnet
+.endif
+
+.if ${MK_TEXTPROC} != "no"
+_checknr= checknr
+_colcrt= colcrt
+_ul= ul
+.endif
+
.if ${MK_TOOLCHAIN} != "no"
_ar= ar
_c89= c89
_c99= c99
+_compile_et= compile_et
+_ctags= ctags
+_file2c= file2c
_gprof= gprof
+_indent= indent
_lex= lex
+_mkstr= mkstr
+_rpcgen= rpcgen
+_unifdef= unifdef
_xlint= xlint
+_xstr= xstr
+# XXX maybe under textproc?
+_vgrind= vgrind
_yacc= yacc
.endif
==== //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/Makefile#4 (text+ko) ====
@@ -20,13 +20,6 @@
LDADD= -lz -lbz2
DPADD= ${LIBZ} ${LIBBZ2}
-.if defined(WITH_PCRE)
-CFLAGS+= -DWITH_PCRE=yes -I/usr/local/include
-LDFLAGS+= -L/usr/local/lib
-LDADD+= -lpcre
-DPADD+= /usr/local/lib/libpcre.a
-.endif
-
.if !defined(WITHOUT_NLS)
NLS= hu_HU.ISO8859-2
NLS+= pt_BR.ISO8859-1
==== //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/fastgrep.c#2 (text+ko) ====
@@ -40,10 +40,11 @@
__FBSDID("$FreeBSD$");
#endif /* not lint */
-#include <ctype.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
+#include <wchar.h>
+#include <wctype.h>
#include "grep.h"
@@ -61,31 +62,13 @@
fg->eol = 0;
fg->reversed = 0;
- /*
- * Make a copy and upper case it for later if in -i mode,
- * else just copy the pointer.
- */
- if (iflag) {
- fg->pattern = grep_malloc(fg->len + 1);
- for (i = 0; i < fg->len; i++)
- fg->pattern[i] = toupper(pattern[i]);
- fg->pattern[fg->len] = '\0';
- } else
- fg->pattern = (unsigned char *)pattern; /* really const */
+ fg->pattern = (unsigned char *)pattern; /* really const */
/* Preprocess pattern. */
for (i = 0; i <= UCHAR_MAX; i++)
fg->qsBc[i] = fg->len;
- for (i = 1; i < fg->len; i++) {
+ for (i = 1; i < fg->len; i++)
fg->qsBc[fg->pattern[i]] = fg->len - i;
- /*
- * If case is ignored, make the jump apply to both upper and
- * lower cased characters. As the pattern is stored in upper
- * case, apply the same to the lower case equivalents.
- */
- if (iflag)
- fg->qsBc[tolower(fg->pattern[i])] = fg->len - i;
- }
}
/*
@@ -144,14 +127,7 @@
for (i = 0; i < fg->len; i++)
{
/* Can still cheat? */
- if ((isalnum(fg->pattern[i])) || isspace(fg->pattern[i]) ||
- (fg->pattern[i] == '_') || (fg->pattern[i] == ',') ||
- (fg->pattern[i] == '=') || (fg->pattern[i] == '-') ||
- (fg->pattern[i] == ':') || (fg->pattern[i] == '/')) {
- /* As long as it is good, upper case it for later. */
- if (iflag)
- fg->pattern[i] = toupper(fg->pattern[i]);
- } else if (fg->pattern[i] == '.') {
+ if (fg->pattern[i] == '.') {
hasDot = i;
if (i < fg->len / 2) {
if (firstHalfDot < 0)
@@ -211,13 +187,6 @@
fg->qsBc[i] = shiftPatternLen;
for (i = hasDot + 1; i < fg->len; i++) {
fg->qsBc[fg->pattern[i]] = fg->len - i;
- /*
- * If case is ignored, make the jump apply to both upper and
- * lower cased characters. As the pattern is stored in upper
- * case, apply the same to the lower case equivalents.
- */
- if (iflag)
- fg->qsBc[tolower(fg->pattern[i])] = fg->len - i;
}
/*
@@ -313,14 +282,39 @@
grep_cmp(const unsigned char *pattern, const unsigned char *data, size_t len)
{
int i;
+ size_t size;
+ wchar_t *wdata, *wpat;
+
+ if (iflag) {
+ if ((size = mbstowcs(NULL, (const char *)data, 0)) == -1)
+ return (-1);
+
+ wdata = grep_malloc(size * sizeof(wint_t));
- for (i = 0; i < len; i++) {
- if (((pattern[i] == data[i]) || ((grepbehave != GREP_FIXED) && pattern[i] == '.'))
- || (iflag && pattern[i] == toupper(data[i])))
- continue;
- return (i);
+ if (mbstowcs(wdata, (const char *)data, size) == -1)
+ return (-1);
+
+ if ((size = mbstowcs(NULL, (const char *)pattern, 0)) == -1)
+ return (-1);
+
+ wpat = grep_malloc(size * sizeof(wint_t));
+
+ if (mbstowcs(wpat, (const char *)pattern, size) == -1)
+ return (-1);
+ for (i = 0; i < len; i++) {
+ if ((towlower(wpat[i]) == towlower(wdata[i])) || ((grepbehave != GREP_FIXED) && wpat[i] == L'.'))
+ continue;
+ free(wpat);
+ free(wdata);
+ return (i);
+ }
+ } else {
+ for (i = 0; i < len; i++) {
+ if ((pattern[i] == data[i]) || ((grepbehave != GREP_FIXED) && pattern[i] == '.'))
+ continue;
+ return (i);
+ }
}
-
return (-1);
}
==== //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/file.c#6 (text+ko) ====
@@ -36,6 +36,8 @@
#endif /* not lint */
#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <bzlib.h>
#include <err.h>
@@ -52,10 +54,13 @@
static char fname[MAXPATHLEN]; /* file name */
+#define MAXBUFSIZ (16 * 1024)
+#define PREREAD_M 0.2
+
/* Some global variable for the buffering and reading. */
static char *lnbuf;
static size_t lnbuflen;
-static char binbuf[BUFSIZ * 4];
+static char *binbuf;
static int binbufsiz;
char *binbufptr;
static int bzerr;
@@ -118,19 +123,24 @@
grep_fgetln(struct file *f, size_t *len)
{
int i = 0;
- char ch;
+ int ch = 0;
+ struct stat st;
+ size_t bufsiz;
/* Fill in the buffer if it is empty. */
if (binbufptr == NULL) {
+
/* Only pre-read to the buffer if we need the binary check. */
if (binbehave != BINFILE_TEXT) {
- for (; i < sizeof(binbuf) && !grep_feof(f); i++) {
- ch = grep_fgetc(f);
- if (ch != EOF)
- binbuf[i] = ch;
- else
- break;
- }
+ if (stat(fname, &st) != 0)
+ errx(2, NULL);
+
+ bufsiz = (MAXBUFSIZ > (st.st_size * PREREAD_M)) ? (st.st_size / 2) : MAXBUFSIZ;
+
+ binbuf = grep_malloc(sizeof(char) * bufsiz);
+
+ for (; i < bufsiz && !grep_feof(f); i++)
+ binbuf[i] = grep_fgetc(f);
f->binary = memchr(binbuf, (filebehave != FILE_GZIP) ? '\0' : '\200', i - 1) != 0;
}
binbufsiz = i;
@@ -149,11 +159,13 @@
lnbuflen *= 2;
lnbuf = grep_realloc(lnbuf, ++lnbuflen);
}
- if (ch == '\n')
+ if ((ch == '\n') || (ch == EOF)) {
+ lnbuf[i] = '\0';
break;
- lnbuf[i] = ch;
+ } else
+ lnbuf[i] = ch;
}
- if (grep_feof(f) && (i == 0))
+ if (grep_feof(f) && (i == 0) && (ch != '\n'))
return (NULL);
*len = i;
return (lnbuf);
@@ -228,4 +240,9 @@
break;
}
free(f);
+
+ /* Reset read buffer for the file we are closing */
+ binbufptr = NULL;
+ free(binbuf);
+
}
==== //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/grep.c#4 (text+ko) ====
@@ -79,9 +79,6 @@
/*14*/ "unknown -d or --directory option",
/*15*/ "unknown --color option",
/*16*/ "cannot read bzip2 compressed file",
-/*17*/ "PCRE is not enabled in this version of grep. "
- "To enable this feature, please install libpcre and"
- "recompile grep with WITH_PCRE set."
};
/* Flags passed to regcomp() and regexec() */
@@ -96,9 +93,6 @@
char **pattern;
regex_t *r_pattern;
fastgrep_t *fg_pattern;
-#ifdef WITH_PCRE
-pcre **perl_pattern;
-#endif
/* Filename exclusion/inclusion patterns */
int epatterns, epattern_sz;
@@ -209,7 +203,6 @@
{"max-count", required_argument, NULL, 'm'},
{"line-number", no_argument, NULL, 'n'},
{"only-matching", no_argument, NULL, 'o'},
- {"perl-regexp", no_argument, NULL, 'P'},
{"quiet", no_argument, NULL, 'q'},
{"silent", no_argument, NULL, 'q'},
{"recursive", no_argument, NULL, 'r'},
@@ -462,9 +455,6 @@
case 'o':
oflag++;
break;
- case 'P':
- grepbehave = GREP_PERL;
- break;
case 'p':
linkbehave = LINK_SKIP;
break;
@@ -581,53 +571,32 @@
case GREP_EXTENDED:
cflags |= REG_EXTENDED;
break;
- case GREP_PERL:
-#ifndef WITH_PCRE
- errx(2, getstr(17));
-#endif
- break;
default:
/* NOTREACHED */
usage();
}
- if (grepbehave != GREP_PERL) {
- fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern));
- r_pattern = grep_calloc(patterns, sizeof(*r_pattern));
+
+ fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern));
+ r_pattern = grep_calloc(patterns, sizeof(*r_pattern));
/*
* XXX: fgrepcomp() and fastcomp() are workarounds for regexec() performance.
* Optimizations should be done there.
*/
- for (i = 0; i < patterns; ++i) {
- /* Check if cheating is allowed (always is for fgrep). */
- if (grepbehave == GREP_FIXED)
- fgrepcomp(&fg_pattern[i], pattern[i]);
- else {
- if (fastcomp(&fg_pattern[i], pattern[i])) {
- /* Fall back to full regex library */
- c = regcomp(&r_pattern[i], pattern[i], cflags);
- if (c != 0) {
- regerror(c, &r_pattern[i], re_error,
- RE_ERROR_BUF);
- errx(2, "%s", re_error);
- }
+ for (i = 0; i < patterns; ++i) {
+ /* Check if cheating is allowed (always is for fgrep). */
+ if (grepbehave == GREP_FIXED)
+ fgrepcomp(&fg_pattern[i], pattern[i]);
+ else {
+ if (fastcomp(&fg_pattern[i], pattern[i])) {
+ /* Fall back to full regex library */
+ c = regcomp(&r_pattern[i], pattern[i], cflags);
+ if (c != 0) {
+ regerror(c, &r_pattern[i], re_error,
+ RE_ERROR_BUF);
+ errx(2, "%s", re_error);
}
}
}
- } else {
-#ifdef WITH_PCRE
- /* Compile Perl regexes with pcre_compile() */
- perl_pattern = grep_calloc(patterns, sizeof(perl_pattern));
- for (i = 0; i < patterns; ++i) {
- char **err_msg = NULL;
- int erroff;
-
- perl_pattern[i] = pcre_compile(pattern[i], 0, (const char **)err_msg, &erroff, NULL);
- if (perl_pattern[i] != NULL)
- errx(2, "wrong PCRE: %s", err_msg[0]);
- }
-#else
- ;
-#endif
}
if (lbflag)
==== //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/grep.h#4 (text+ko) ====
@@ -32,10 +32,6 @@
#include <stdio.h>
#include <zlib.h>
-#ifdef WITH_PCRE
-#include <pcre.h>
-#endif
-
#ifdef WITHOUT_NLS
#define getstr(n) errstr[n]
#else
@@ -52,7 +48,6 @@
#define GREP_FIXED 0
#define GREP_BASIC 1
#define GREP_EXTENDED 2
-#define GREP_PERL 3
#define BINFILE_BIN 0
#define BINFILE_SKIP 1
@@ -118,11 +113,6 @@
extern regex_t *r_pattern, *er_pattern;
extern fastgrep_t *fg_pattern;
-#ifdef WITH_PCRE
-extern pcre **perl_pattern;
-#endif
-
-
/* For regex errors */
#define RE_ERROR_BUF 512
extern char re_error[RE_ERROR_BUF + 1]; /* Seems big enough */
@@ -136,7 +126,6 @@
void printline(struct str *line, int sep, regmatch_t *matches, int m);
/* queue.c */
-void initqueue(void);
void enqueue(struct str *x);
void printqueue(void);
void clearqueue(void);
==== //depot/projects/soc2008/gabor_textproc/src/usr.bin/grep/queue.c#2 (text+ko) ====
@@ -26,7 +26,7 @@
/*
* A really poor man's queue. It does only what it has to and gets out of
- * Dodge.
+ * Dodge. It is used in place of <sys/queue.h> to get a better performance.
*/
#include <sys/cdefs.h>
@@ -40,92 +40,72 @@
#endif /* not lint */
#include <sys/param.h>
+#include <sys/queue.h>
#include <stdlib.h>
#include <string.h>
#include "grep.h"
-struct queue {
- struct queue *next;
- struct str data;
+struct qentry {
+ STAILQ_ENTRY(qentry) list;
+ struct str data;
};
-static struct queue *q_head, *q_tail;
-static int count;
+static STAILQ_HEAD(, qentry) queue = STAILQ_HEAD_INITIALIZER(queue);
+static int count;
-static struct queue *dequeue(void);
-
-void
-initqueue(void)
-{
- q_head = q_tail = NULL;
-}
-
-static void
-free_item(struct queue *item)
-{
-
- free(item);
-}
+static struct qentry *dequeue(void);
void
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list