Date: Sun, 15 May 2005 00:49:24 GMT From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 76992 for review Message-ID: <200505150049.j4F0nOB2049026@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=76992 Change 76992 by marcel@marcel_nfs on 2005/05/15 00:48:45 IFC @76990 Affected files ... .. //depot/projects/tty/bin/chflags/chflags.1#8 integrate .. //depot/projects/tty/bin/chflags/chflags.c#5 integrate .. //depot/projects/tty/contrib/tcp_wrappers/hosts_access.c#2 integrate .. //depot/projects/tty/contrib/tcp_wrappers/socket.c#3 integrate .. //depot/projects/tty/etc/mtree/BSD.local.dist#10 integrate .. //depot/projects/tty/games/fortune/datfiles/fortunes#13 integrate .. //depot/projects/tty/gnu/usr.bin/grep/FREEBSD-upgrade#1 branch .. //depot/projects/tty/gnu/usr.bin/grep/dfa.c#4 integrate .. //depot/projects/tty/gnu/usr.bin/grep/dfa.h#3 integrate .. //depot/projects/tty/gnu/usr.bin/grep/grep.c#5 integrate .. //depot/projects/tty/gnu/usr.bin/grep/grep.h#3 integrate .. //depot/projects/tty/gnu/usr.bin/grep/mbcache.h#2 delete .. //depot/projects/tty/gnu/usr.bin/grep/search.c#4 integrate .. //depot/projects/tty/include/unistd.h#7 integrate .. //depot/projects/tty/lib/libc/gen/ttyname.3#3 integrate .. //depot/projects/tty/lib/libc/gen/ttyname.c#5 integrate .. //depot/projects/tty/lib/libc/net/getaddrinfo.c#12 integrate .. //depot/projects/tty/lib/libc/net/name6.c#12 integrate .. //depot/projects/tty/lib/libc/net/rcmd.c#5 integrate .. //depot/projects/tty/lib/libc/net/res_send.c#4 integrate .. //depot/projects/tty/lib/libc/stdio/glue.h#2 integrate .. //depot/projects/tty/lib/libc_r/uthread/pthread_private.h#7 integrate .. //depot/projects/tty/lib/libpam/modules/pam_unix/pam_unix.c#6 integrate .. //depot/projects/tty/lib/libutil/logwtmp.c#3 integrate .. //depot/projects/tty/lib/libutil/realhostname.c#4 integrate .. //depot/projects/tty/libexec/rlogind/rlogind.c#5 integrate .. //depot/projects/tty/libexec/tftpd/tftpd.c#7 integrate .. //depot/projects/tty/release/picobsd/tinyware/login/pico-login.c#2 integrate .. //depot/projects/tty/sbin/ifconfig/af_inet6.c#2 integrate .. //depot/projects/tty/sbin/route/route.c#7 integrate .. //depot/projects/tty/sys/alpha/alpha/clock.c#8 integrate .. //depot/projects/tty/sys/alpha/alpha/timerreg.h#4 delete .. //depot/projects/tty/sys/alpha/include/ppireg.h#1 branch .. //depot/projects/tty/sys/alpha/include/timerreg.h#1 branch .. //depot/projects/tty/sys/alpha/isa/isa_dma.c#6 integrate .. //depot/projects/tty/sys/amd64/amd64/prof_machdep.c#4 integrate .. //depot/projects/tty/sys/amd64/include/ppireg.h#1 branch .. //depot/projects/tty/sys/amd64/include/timerreg.h#1 branch .. //depot/projects/tty/sys/amd64/isa/clock.c#8 integrate .. //depot/projects/tty/sys/amd64/isa/isa.h#5 integrate .. //depot/projects/tty/sys/amd64/isa/isa_dma.c#7 integrate .. //depot/projects/tty/sys/amd64/isa/timerreg.h#4 delete .. //depot/projects/tty/sys/dev/acpi_support/acpi_panasonic.c#2 integrate .. //depot/projects/tty/sys/dev/ata/ata-all.c#19 integrate .. //depot/projects/tty/sys/dev/ata/ata-chipset.c#18 integrate .. //depot/projects/tty/sys/dev/ata/ata-lowlevel.c#12 integrate .. //depot/projects/tty/sys/dev/ata/ata-pci.c#15 integrate .. //depot/projects/tty/sys/dev/ata/ata-pci.h#15 integrate .. //depot/projects/tty/sys/dev/ata/ata-raid.c#17 integrate .. //depot/projects/tty/sys/dev/ic/i8237.h#3 integrate .. //depot/projects/tty/sys/dev/ic/i8253reg.h#1 branch .. //depot/projects/tty/sys/i386/include/ppireg.h#1 branch .. //depot/projects/tty/sys/i386/include/timerreg.h#1 branch .. //depot/projects/tty/sys/i386/isa/clock.c#11 integrate .. //depot/projects/tty/sys/i386/isa/isa.h#7 integrate .. //depot/projects/tty/sys/i386/isa/isa_dma.c#7 integrate .. //depot/projects/tty/sys/i386/isa/prof_machdep.c#6 integrate .. //depot/projects/tty/sys/i386/isa/spkr.c#10 integrate .. //depot/projects/tty/sys/i386/isa/timerreg.h#3 delete .. //depot/projects/tty/sys/ia64/isa/isa_dma.c#6 integrate .. //depot/projects/tty/sys/isa/isa_dmareg.h#1 branch .. //depot/projects/tty/sys/isa/isareg.h#6 integrate .. //depot/projects/tty/sys/isa/syscons_isa.c#6 integrate .. //depot/projects/tty/sys/kern/vfs_cluster.c#15 integrate .. //depot/projects/tty/sys/netgraph/netgraph.h#7 integrate .. //depot/projects/tty/sys/netgraph/ng_base.c#10 integrate .. //depot/projects/tty/sys/netgraph/ng_ksocket.c#8 integrate .. //depot/projects/tty/sys/netinet/ip_divert.c#12 integrate .. //depot/projects/tty/sys/netinet/tcp_sack.c#5 integrate .. //depot/projects/tty/sys/netsmb/smb_conn.c#7 integrate .. //depot/projects/tty/sys/pc98/cbus/cbus.h#3 integrate .. //depot/projects/tty/sys/pc98/cbus/cbus_dma.c#2 integrate .. //depot/projects/tty/sys/pc98/cbus/cbus_dmareg.h#1 branch .. //depot/projects/tty/sys/pc98/cbus/clock.c#2 integrate .. //depot/projects/tty/sys/pc98/cbus/fdc_cbus.c#2 integrate .. //depot/projects/tty/sys/pc98/cbus/olptreg.h#2 integrate .. //depot/projects/tty/sys/pc98/cbus/sio_cbus.c#2 integrate .. //depot/projects/tty/sys/pc98/cbus/syscons_cbus.c#2 integrate .. //depot/projects/tty/sys/pc98/include/ppireg.h#1 branch .. //depot/projects/tty/sys/pc98/include/timerreg.h#1 branch .. //depot/projects/tty/sys/pc98/pc98/machdep.c#2 integrate .. //depot/projects/tty/sys/powerpc/powermac/ata_kauai.c#6 integrate .. //depot/projects/tty/sys/sys/param.h#18 integrate .. //depot/projects/tty/usr.bin/make/GNode.h#3 integrate .. //depot/projects/tty/usr.bin/make/arch.h#2 integrate .. //depot/projects/tty/usr.bin/make/buf.c#4 integrate .. //depot/projects/tty/usr.bin/make/buf.h#4 integrate .. //depot/projects/tty/usr.bin/make/cond.c#8 integrate .. //depot/projects/tty/usr.bin/make/for.h#2 integrate .. //depot/projects/tty/usr.bin/make/globals.h#5 integrate .. //depot/projects/tty/usr.bin/make/hash.c#4 integrate .. //depot/projects/tty/usr.bin/make/hash.h#4 integrate .. //depot/projects/tty/usr.bin/make/job.c#8 integrate .. //depot/projects/tty/usr.bin/make/job.h#7 integrate .. //depot/projects/tty/usr.bin/make/lst.h#4 integrate .. //depot/projects/tty/usr.bin/make/make.h#7 integrate .. //depot/projects/tty/usr.bin/make/parse.h#3 integrate .. //depot/projects/tty/usr.bin/make/sprite.h#3 delete .. //depot/projects/tty/usr.bin/make/str.h#2 integrate .. //depot/projects/tty/usr.bin/make/suff.c#7 integrate .. //depot/projects/tty/usr.bin/make/targ.c#5 integrate .. //depot/projects/tty/usr.bin/make/util.c#4 integrate .. //depot/projects/tty/usr.bin/make/util.h#2 integrate .. //depot/projects/tty/usr.bin/netstat/route.c#8 integrate .. //depot/projects/tty/usr.sbin/burncd/burncd.c#7 integrate .. //depot/projects/tty/usr.sbin/inetd/inetd.c#10 integrate .. //depot/projects/tty/usr.sbin/jail/jail.8#12 integrate .. //depot/projects/tty/usr.sbin/lpr/common_source/net.c#3 integrate .. //depot/projects/tty/usr.sbin/lpr/lpd/lpd.c#3 integrate .. //depot/projects/tty/usr.sbin/mountd/mountd.c#9 integrate .. //depot/projects/tty/usr.sbin/ppp/ncpaddr.c#6 integrate .. //depot/projects/tty/usr.sbin/rip6query/rip6query.c#2 integrate .. //depot/projects/tty/usr.sbin/syslogd/syslogd.c#11 integrate Differences ... ==== //depot/projects/tty/bin/chflags/chflags.1#8 (text+ko) ==== @@ -30,9 +30,9 @@ .\" SUCH DAMAGE. .\" .\" @(#)chflags.1 8.4 (Berkeley) 5/2/95 -.\" $FreeBSD: src/bin/chflags/chflags.1,v 1.23 2005/02/25 00:40:46 trhodes Exp $ +.\" $FreeBSD: src/bin/chflags/chflags.1,v 1.24 2005/05/14 23:23:10 dd Exp $ .\" -.Dd February 24, 2005 +.Dd May 14, 2005 .Dt CHFLAGS 1 .Os .Sh NAME @@ -40,6 +40,7 @@ .Nd change file flags .Sh SYNOPSIS .Nm +.Op Fl h .Oo .Fl R .Op Fl H | Fl L | Fl P @@ -61,6 +62,11 @@ .Fl R option is specified, symbolic links on the command line are followed. (Symbolic links encountered in the tree traversal are not followed.) +.It Fl h +If the +.Ar file +is a symbolic link, +change the mode of the link itself rather than the file to which it points. .It Fl L If the .Fl R @@ -114,11 +120,12 @@ clear the nodump flag (owner or super-user only) .El .Pp -Symbolic links do not have flags, so unless the -.Fl H +Unless the +.Fl H , +.Fl L , or -.Fl L -option is set, +.Fl h +options are given, .Nm on a symbolic link always succeeds and has no effect. The ==== //depot/projects/tty/bin/chflags/chflags.c#5 (text+ko) ==== @@ -40,7 +40,7 @@ #endif #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/bin/chflags/chflags.c,v 1.22 2005/01/10 08:39:20 imp Exp $"); +__FBSDID("$FreeBSD: src/bin/chflags/chflags.c,v 1.23 2005/05/14 23:23:10 dd Exp $"); #include <sys/types.h> #include <sys/stat.h> @@ -62,11 +62,12 @@ FTSENT *p; u_long clear, set; long val; - int Hflag, Lflag, Rflag, ch, fts_options, oct, rval; + int Hflag, Lflag, Rflag, hflag, ch, fts_options, oct, rval; char *flags, *ep; + int (*change_flags)(const char *, unsigned long); - Hflag = Lflag = Rflag = 0; - while ((ch = getopt(argc, argv, "HLPR")) != -1) + Hflag = Lflag = Rflag = hflag = 0; + while ((ch = getopt(argc, argv, "HLPRh")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -82,6 +83,9 @@ case 'R': Rflag = 1; break; + case 'h': + hflag = 1; + break; case '?': default: usage(); @@ -94,6 +98,9 @@ if (Rflag) { fts_options = FTS_PHYSICAL; + if (hflag) + errx(1, "the -R and -h options " + "may not be specified together"); if (Hflag) fts_options |= FTS_COMFOLLOW; if (Lflag) { @@ -103,6 +110,12 @@ } else fts_options = FTS_LOGICAL; + /* XXX: Why don't chflags and lchflags have compatible prototypes? */ + if (hflag) + change_flags = (int (*)(const char *, unsigned long))lchflags; + else + change_flags = chflags; + flags = *argv; if (*flags >= '0' && *flags <= '7') { errno = 0; @@ -147,17 +160,20 @@ * don't point to anything and ones that we found * doing a physical walk. */ - continue; + if (!hflag) + continue; + /* FALLTHROUGH */ default: break; } if (oct) { - if (!chflags(p->fts_accpath, set)) + if (!(*change_flags)(p->fts_accpath, set)) continue; } else { p->fts_statp->st_flags |= set; p->fts_statp->st_flags &= clear; - if (!chflags(p->fts_accpath, (u_long)p->fts_statp->st_flags)) + if (!(*change_flags)(p->fts_accpath, + (u_long)p->fts_statp->st_flags)) continue; } warn("%s", p->fts_path); @@ -172,6 +188,6 @@ usage(void) { (void)fprintf(stderr, - "usage: chflags [-R [-H | -L | -P]] flags file ...\n"); + "usage: chflags [-h] [-R [-H | -L | -P]] flags file ...\n"); exit(1); } ==== //depot/projects/tty/contrib/tcp_wrappers/hosts_access.c#2 (text+ko) ==== @@ -16,7 +16,7 @@ * * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. * - * $FreeBSD: src/contrib/tcp_wrappers/hosts_access.c,v 1.4 2000/07/14 17:15:33 ume Exp $ + * $FreeBSD: src/contrib/tcp_wrappers/hosts_access.c,v 1.5 2005/05/13 16:31:08 ume Exp $ */ #ifndef lint @@ -366,11 +366,9 @@ return NO; memcpy(&addr, res->ai_addr, sizeof(addr)); freeaddrinfo(res); -#ifdef NI_WITHSCOPEID if (pat.sin6_scope_id != 0 && addr.sin6_scope_id != pat.sin6_scope_id) return NO; -#endif return (!memcmp(&pat.sin6_addr, &addr.sin6_addr, sizeof(struct in6_addr))); return (ret); @@ -472,10 +470,8 @@ if ((mask_len = atoi(mask_tok)) < 0 || mask_len > 128) return NO; -#ifdef NI_WITHSCOPEID if (net.sin6_scope_id != 0 && addr.sin6_scope_id != net.sin6_scope_id) return NO; -#endif while (mask_len > 0) { if (mask_len < 32) { mask = htonl(~(0xffffffff >> mask_len)); ==== //depot/projects/tty/contrib/tcp_wrappers/socket.c#3 (text+ko) ==== @@ -14,7 +14,7 @@ * * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. * - * $FreeBSD: src/contrib/tcp_wrappers/socket.c,v 1.7 2003/12/27 14:58:00 ceri Exp $ + * $FreeBSD: src/contrib/tcp_wrappers/socket.c,v 1.8 2005/05/13 16:31:08 ume Exp $ */ #ifndef lint @@ -32,11 +32,7 @@ #include <syslog.h> #include <string.h> -#ifdef INET6 -#ifndef NI_WITHSCOPEID -#define NI_WITHSCOPEID 0 -#endif -#else +#ifndef INET6 extern char *inet_ntoa(); #endif @@ -159,7 +155,7 @@ : sizeof(struct sockaddr_in6); #endif getnameinfo(sin, salen, host->addr, sizeof(host->addr), - NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID); + NULL, 0, NI_NUMERICHOST); #else struct sockaddr_in *sin = host->sin; @@ -211,7 +207,7 @@ } if (ap) err = getnameinfo(sin, salen, hname, sizeof(hname), - NULL, 0, NI_WITHSCOPEID | NI_NAMEREQD); + NULL, 0, NI_NAMEREQD); } if (!err) { @@ -316,7 +312,7 @@ */ getnameinfo(sin, salen, hname, sizeof(hname), - NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID); + NULL, 0, NI_NUMERICHOST); tcpd_warn("host name/address mismatch: %s != %.*s", hname, STRING_LENGTH, (res0->ai_canonname == NULL) ? "" : res0->ai_canonname); ==== //depot/projects/tty/etc/mtree/BSD.local.dist#10 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/etc/mtree/BSD.local.dist,v 1.114 2005/03/22 18:29:41 krion Exp $ +# $FreeBSD: src/etc/mtree/BSD.local.dist,v 1.115 2005/05/13 04:06:04 marcus Exp $ # # Please see the file src/etc/mtree/README before making changes to this file. # @@ -20,6 +20,8 @@ lib .. libdata + pkgconfig + .. .. libexec .. ==== //depot/projects/tty/games/fortune/datfiles/fortunes#13 (text+ko) ==== @@ -1,5 +1,5 @@ This fortune brought to you by: -$FreeBSD: src/games/fortune/datfiles/fortunes,v 1.175 2005/04/13 06:11:49 phk Exp $ +$FreeBSD: src/games/fortune/datfiles/fortunes,v 1.176 2005/05/13 15:51:56 phk Exp $ % ======================================================================= @@ -26330,9 +26330,6 @@ some means abridged, it will soon fall into disuse. -- Philip Hale, Boston music critic, 1837 % -If builders built buildings the way programmers wrote programs, -then the first woodpecker to come along would destroy civilization. -% If built in great numbers, motels will be used for nothing but illegal purposes. -- J. Edgar Hoover @@ -55237,6 +55234,7 @@ Weinberg's Second Law: If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization. + -- Gerald Weinberg % Weiner's Law of Libraries: There are no answers, only cross references. ==== //depot/projects/tty/gnu/usr.bin/grep/dfa.c#4 (text+ko) ==== @@ -18,7 +18,7 @@ /* Written June, 1988 by Mike Haertel Modified July, 1988 by Arthur David Olson to assist BMG speedups */ -/* $FreeBSD: src/gnu/usr.bin/grep/dfa.c,v 1.19 2004/07/04 16:25:41 tjr Exp $ */ +/* $FreeBSD: src/gnu/usr.bin/grep/dfa.c,v 1.21 2005/05/14 03:18:20 tjr Exp $ */ #ifdef HAVE_CONFIG_H #include <config.h> @@ -2552,6 +2552,8 @@ } /* match with a character? */ + if (case_fold) + wc = towlower (wc); for (i = 0; i<work_mbc->nchars; i++) { if (wc == work_mbc->chars[i]) @@ -2747,8 +2749,7 @@ match needs to be verified by a backtracking matcher. Otherwise we store a 0 in *backref. */ size_t -dfaexec (struct dfa *d, char const *begin, size_t size, int *backref, - struct mb_cache *mb_cache) +dfaexec (struct dfa *d, char const *begin, size_t size, int *backref) { register int s; /* Current state. */ register unsigned char const *p; /* Current input character. */ @@ -2780,79 +2781,43 @@ #ifdef MBS_SUPPORT if (MB_CUR_MAX > 1) { + int remain_bytes, i; buf_begin = begin; buf_end = end; - if (mb_cache && mb_cache->mblen_buf && mb_cache->wcs_buf && - begin > mb_cache->orig_buf && - (begin + size) <= (mb_cache->orig_buf + mb_cache->len)) + + /* initialize mblen_buf, and inputwcs. */ + MALLOC(mblen_buf, unsigned char, end - (unsigned char const *)begin + 2); + MALLOC(inputwcs, wchar_t, end - (unsigned char const *)begin + 2); + memset(&mbs, 0, sizeof(mbstate_t)); + remain_bytes = 0; + for (i = 0; i < end - (unsigned char const *)begin + 1; i++) { - /* The cache can help us. */ - MALLOC(mblen_buf, unsigned char, size + 2); - MALLOC(inputwcs, wchar_t, size + 2); - memcpy (mblen_buf, - mb_cache->mblen_buf + (begin - mb_cache->orig_buf), - (size + 2) * sizeof (unsigned char)); - memcpy (inputwcs, - mb_cache->wcs_buf + (begin - mb_cache->orig_buf), - (size + 2) * sizeof (wchar_t)); - mblen_buf[size + 1] = 0; - inputwcs[size + 1] = 0; - } - else - { - int remain_bytes, i; - - /* initialize mblen_buf, and inputwcs. */ - MALLOC(mblen_buf, unsigned char, end - (unsigned char const *)begin + 2); - MALLOC(inputwcs, wchar_t, end - (unsigned char const *)begin + 2); - memset(&mbs, 0, sizeof(mbstate_t)); - remain_bytes = 0; - for (i = 0; i < end - (unsigned char const *)begin + 1; i++) + if (remain_bytes == 0) { - if (remain_bytes == 0) + remain_bytes + = mbrtowc(inputwcs + i, begin + i, + end - (unsigned char const *)begin - i + 1, &mbs); + if (remain_bytes <= 1) { - remain_bytes - = mbrtowc(inputwcs + i, begin + i, - end - (unsigned char const *)begin - i + 1, &mbs); - if (remain_bytes <= 1) - { - remain_bytes = 0; - inputwcs[i] = (wchar_t)begin[i]; - mblen_buf[i] = 0; - } - else - { - mblen_buf[i] = remain_bytes; - remain_bytes--; - } + remain_bytes = 0; + inputwcs[i] = (wchar_t)begin[i]; + mblen_buf[i] = 0; } else { mblen_buf[i] = remain_bytes; - inputwcs[i] = 0; remain_bytes--; } } - mblen_buf[i] = 0; - inputwcs[i] = 0; /* sentinel */ - - if (mb_cache) + else { - /* Populate the cache. */ - mb_cache->len = size; - mb_cache->orig_buf = begin; - if (mb_cache->mblen_buf) - free (mb_cache->mblen_buf); - if (mb_cache->wcs_buf) - free (mb_cache->wcs_buf); - MALLOC(mb_cache->mblen_buf, unsigned char, size + 2); - MALLOC(mb_cache->wcs_buf, wchar_t, size + 2); - memcpy (mb_cache->mblen_buf, mblen_buf, - (size + 2) * sizeof (unsigned char)); - memcpy (mb_cache->wcs_buf, inputwcs, - (size + 2) * sizeof (wchar_t)); + mblen_buf[i] = remain_bytes; + inputwcs[i] = 0; + remain_bytes--; } } + mblen_buf[i] = 0; + inputwcs[i] = 0; /* sentinel */ } #endif /* MBS_SUPPORT */ ==== //depot/projects/tty/gnu/usr.bin/grep/dfa.h#3 (text+ko) ==== @@ -17,15 +17,13 @@ /* Written June, 1988 by Mike Haertel */ -/* $FreeBSD: src/gnu/usr.bin/grep/dfa.h,v 1.8 2004/07/04 16:16:59 tjr Exp $ */ +/* $FreeBSD: src/gnu/usr.bin/grep/dfa.h,v 1.9 2005/05/14 03:02:22 tjr Exp $ */ /* FIXME: 2. We should not export so much of the DFA internals. In addition to clobbering modularity, we eat up valuable name space. */ -#include "mbcache.h" - #ifdef __STDC__ # ifndef _PTR_T # define _PTR_T @@ -407,8 +405,7 @@ order to verify backreferencing; otherwise the flag will be cleared. Returns (size_t) -1 if no match is found, or the offset of the first character after the first & shortest matching string in the buffer. */ -extern size_t dfaexec PARAMS ((struct dfa *, char const *, size_t, int *, - struct mb_cache *)); +extern size_t dfaexec PARAMS ((struct dfa *, char const *, size_t, int *)); /* Free the storage held by the components of a struct dfa. */ extern void dfafree PARAMS ((struct dfa *)); ==== //depot/projects/tty/gnu/usr.bin/grep/grep.c#5 (text+ko) ==== @@ -19,7 +19,7 @@ /* Written July 1992 by Mike Haertel. */ /* Builtin decompression 1997 by Wolfram Schneider <wosch@FreeBSD.org>. */ -/* $FreeBSD: src/gnu/usr.bin/grep/grep.c,v 1.28 2005/02/13 23:07:30 obrien Exp $ */ +/* $FreeBSD: src/gnu/usr.bin/grep/grep.c,v 1.31 2005/05/14 05:35:04 tjr Exp $ */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -198,8 +198,7 @@ /* Functions we'll use to search. */ static void (*compile) PARAMS ((char const *, size_t)); -static size_t (*execute) PARAMS ((char const *, size_t, struct mb_cache *, - size_t *, int)); +static size_t (*execute) PARAMS ((char const *, size_t, size_t *, int)); /* Like error, but suppress the diagnostic if requested. */ static void @@ -584,7 +583,7 @@ } static void -prline (char const *beg, char const *lim, int sep, struct mb_cache *mb_cache) +prline (char const *beg, char const *lim, int sep) { if (out_file) printf ("%s%c", filename, sep & filename_mask); @@ -607,8 +606,7 @@ { size_t match_size; size_t match_offset; - while ((match_offset = (*execute) (beg, lim - beg, mb_cache, - &match_size, 1)) + while ((match_offset = (*execute) (beg, lim - beg, &match_size, 1)) != (size_t) -1) { char const *b = beg + match_offset; @@ -633,36 +631,7 @@ { size_t match_size; size_t match_offset; - if(match_icase) - { - /* Yuck, this is tricky */ - char *buf = (char*) xmalloc (lim - beg); - char *ibeg = buf; - char *ilim = ibeg + (lim - beg); - int i; - for (i = 0; i < lim - beg; i++) - ibeg[i] = tolower (beg[i]); - while ((match_offset = (*execute) (ibeg, ilim-ibeg, mb_cache, - &match_size, 1)) - != (size_t) -1) - { - char const *b = beg + match_offset; - if (b == lim) - break; - fwrite (beg, sizeof (char), match_offset, stdout); - printf ("\33[%sm", grep_color); - fwrite (b, sizeof (char), match_size, stdout); - fputs ("\33[00m", stdout); - beg = b + match_size; - ibeg = ibeg + match_offset + match_size; - } - fwrite (beg, 1, lim - beg, stdout); - free (buf); - lastout = lim; - return; - } - while (lim-beg && (match_offset = (*execute) (beg, lim - beg, mb_cache, - &match_size, 1)) + while (lim-beg && (match_offset = (*execute) (beg, lim - beg, &match_size, 1)) != (size_t) -1) { char const *b = beg + match_offset; @@ -678,6 +647,7 @@ fputs ("\33[00m", stdout); beg = b + match_size; } + fputs ("\33[K", stdout); } fwrite (beg, 1, lim - beg, stdout); if (ferror (stdout)) @@ -690,7 +660,7 @@ /* Print pending lines of trailing context prior to LIM. Trailing context ends at the next matching line when OUTLEFT is 0. */ static void -prpending (char const *lim, struct mb_cache *mb_cache) +prpending (char const *lim) { if (!lastout) lastout = bufbeg; @@ -700,10 +670,9 @@ size_t match_size; --pending; if (outleft - || (((*execute) (lastout, nl - lastout, mb_cache, - &match_size, 0) == (size_t) -1) + || (((*execute) (lastout, nl - lastout, &match_size, 0) == (size_t) -1) == !out_invert)) - prline (lastout, nl + 1, '-', mb_cache); + prline (lastout, nl + 1, '-'); else pending = 0; } @@ -712,8 +681,7 @@ /* Print the lines between BEG and LIM. Deal with context crap. If NLINESP is non-null, store a count of lines between BEG and LIM. */ static void -prtext (char const *beg, char const *lim, int *nlinesp, - struct mb_cache *mb_cache) +prtext (char const *beg, char const *lim, int *nlinesp) { static int used; /* avoid printing "--" before any output */ char const *bp, *p; @@ -721,7 +689,7 @@ int i, n; if (!out_quiet && pending > 0) - prpending (beg, mb_cache); + prpending (beg); p = beg; @@ -745,7 +713,7 @@ { char const *nl = memchr (p, eol, beg - p); nl++; - prline (p, nl, '-', mb_cache); + prline (p, nl, '-'); p = nl; } } @@ -758,7 +726,7 @@ char const *nl = memchr (p, eol, lim - p); nl++; if (!out_quiet) - prline (p, nl, ':', mb_cache); + prline (p, nl, ':'); p = nl; } *nlinesp = n; @@ -768,7 +736,7 @@ } else if (!out_quiet) - prline (beg, lim, ':', mb_cache); + prline (beg, lim, ':'); pending = out_quiet ? 0 : out_after; used = 1; @@ -778,7 +746,7 @@ between matching lines if OUT_INVERT is true). Return a count of lines printed. */ static int -grepbuf (char const *beg, char const *lim, struct mb_cache *mb_cache) +grepbuf (char const *beg, char const *lim) { int nlines, n; register char const *p; @@ -787,8 +755,7 @@ nlines = 0; p = beg; - while ((match_offset = (*execute) (p, lim - p, mb_cache, - &match_size, 0)) != (size_t) -1) + while ((match_offset = (*execute) (p, lim - p, &match_size, 0)) != (size_t) -1) { char const *b = p + match_offset; char const *endp = b + match_size; @@ -797,7 +764,7 @@ break; if (!out_invert) { - prtext (b, endp, (int *) 0, mb_cache); + prtext (b, endp, (int *) 0); nlines++; outleft--; if (!outleft || done_on_match) @@ -810,7 +777,7 @@ } else if (p < b) { - prtext (p, b, &n, mb_cache); + prtext (p, b, &n); nlines += n; outleft -= n; if (!outleft) @@ -820,7 +787,7 @@ } if (out_invert && p < lim) { - prtext (p, lim, &n, mb_cache); + prtext (p, lim, &n); nlines += n; outleft -= n; } @@ -840,9 +807,7 @@ char *beg; char *lim; char eol = eolbyte; - struct mb_cache mb_cache; - memset (&mb_cache, 0, sizeof (mb_cache)); if (!reset (fd, file, stats)) return 0; @@ -917,9 +882,9 @@ if (beg < lim) { if (outleft) - nlines += grepbuf (beg, lim, &mb_cache); + nlines += grepbuf (beg, lim); if (pending) - prpending (lim, &mb_cache); + prpending (lim); if((!outleft && !pending) || (nlines && done_on_match && !out_invert)) goto finish_grep; } @@ -947,11 +912,6 @@ totalcc = add_count (totalcc, buflim - bufbeg - save); if (out_line) nlscan (beg); - if (mb_cache.wcs_buf) - free (mb_cache.wcs_buf); - if (mb_cache.mblen_buf) - free (mb_cache.mblen_buf); - memset (&mb_cache, 0, sizeof (mb_cache)); if (! fillbuf (save, stats)) { if (! is_EISDIR (errno, file)) @@ -963,9 +923,9 @@ { *buflim++ = eol; if (outleft) - nlines += grepbuf (bufbeg + save - residue, buflim, &mb_cache); + nlines += grepbuf (bufbeg + save - residue, buflim); if (pending) - prpending (buflim, &mb_cache); + prpending (buflim); } finish_grep: @@ -973,11 +933,6 @@ out_quiet -= not_text; if ((not_text & ~out_quiet) && nlines != 0) printf (_("Binary file %s matches\n"), filename); - - if (mb_cache.wcs_buf) - free (mb_cache.wcs_buf); - if (mb_cache.mblen_buf) - free (mb_cache.mblen_buf); return nlines; } ==== //depot/projects/tty/gnu/usr.bin/grep/grep.h#3 (text+ko) ==== @@ -16,14 +16,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $FreeBSD: src/gnu/usr.bin/grep/grep.h,v 1.7 2004/07/04 16:16:59 tjr Exp $ */ +/* $FreeBSD: src/gnu/usr.bin/grep/grep.h,v 1.8 2005/05/14 03:02:22 tjr Exp $ */ #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) || __STRICT_ANSI__ # define __attribute__(x) #endif -#include "mbcache.h" - /* Grep.c expects the matchers vector to be terminated by an entry with a NULL compile, and to contain at least an entry named "default". */ @@ -32,8 +30,7 @@ { char name[8]; void (*compile) PARAMS ((char const *, size_t)); - size_t (*execute) PARAMS ((char const *, size_t, struct mb_cache *, - size_t *, int)); + size_t (*execute) PARAMS ((char const *, size_t, size_t *, int)); } const matchers[]; /* Exported from fgrepmat.c, egrepmat.c, grepmat.c. */ ==== //depot/projects/tty/gnu/usr.bin/grep/search.c#4 (text+ko) ==== @@ -18,11 +18,15 @@ /* Written August 1992 by Mike Haertel. */ -/* $FreeBSD: src/gnu/usr.bin/grep/search.c,v 1.17 2004/07/04 16:16:59 tjr Exp $ */ +/* $FreeBSD: src/gnu/usr.bin/grep/search.c,v 1.22 2005/05/14 06:13:23 tjr Exp $ */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif #ifdef HAVE_CONFIG_H # include <config.h> #endif +#include <assert.h> #include <sys/types.h> #if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC /* We can handle multibyte string. */ @@ -41,6 +45,9 @@ #ifdef HAVE_LIBPCRE # include <pcre.h> #endif +#ifdef HAVE_LANGINFO_CODESET +# include <langinfo.h> +#endif #define NCHAR (UCHAR_MAX + 1) @@ -72,23 +79,28 @@ call the regexp matcher at all. */ static int kwset_exact_matches; -#if defined(MBS_SUPPORT) -static char* check_multibyte_string PARAMS ((char const *buf, size_t size, - struct mb_cache *, - char const *orig_buf)); -#endif +/* UTF-8 encoding allows some optimizations that we can't otherwise + assume in a multibyte encoding. */ +static int using_utf8; + static void kwsinit PARAMS ((void)); static void kwsmusts PARAMS ((void)); static void Gcompile PARAMS ((char const *, size_t)); static void Ecompile PARAMS ((char const *, size_t)); -static size_t EGexecute PARAMS ((char const *, size_t, struct mb_cache *, - size_t *, int )); +static size_t EGexecute PARAMS ((char const *, size_t, size_t *, int )); static void Fcompile PARAMS ((char const *, size_t)); -static size_t Fexecute PARAMS ((char const *, size_t, struct mb_cache *, - size_t *, int)); +static size_t Fexecute PARAMS ((char const *, size_t, size_t *, int)); static void Pcompile PARAMS ((char const *, size_t )); -static size_t Pexecute PARAMS ((char const *, size_t, struct mb_cache *, - size_t *, int)); +static size_t Pexecute PARAMS ((char const *, size_t, size_t *, int)); + +void +check_utf8 (void) +{ +#ifdef HAVE_LANGINFO_CODESET + if (strcmp (nl_langinfo (CODESET), "UTF-8") == 0) + using_utf8 = 1; +#endif +} void dfaerror (char const *mesg) @@ -148,78 +160,6 @@ } } -#ifdef MBS_SUPPORT -/* This function allocate the array which correspond to "buf". - Then this check multibyte string and mark on the positions which - are not singlebyte character nor the first byte of a multibyte - character. Caller must free the array. */ -static char* -check_multibyte_string(char const *buf, size_t size, struct mb_cache *mb_cache, - char const *orig_buf) -{ - char *mb_properties = xmalloc(size); - mbstate_t cur_state; - wchar_t wc; - int i; - memset(&cur_state, 0, sizeof(mbstate_t)); - - if (mb_cache && mb_cache->mblen_buf && - orig_buf > mb_cache->orig_buf && - (orig_buf + size) <= (mb_cache->orig_buf + mb_cache->len)) - { - /* The cache can help us. */ - memcpy (mb_properties, - mb_cache->mblen_buf + (orig_buf - mb_cache->orig_buf), - size); - - } - else - { - memset(mb_properties, 0, sizeof(char)*size); - for (i = 0; i < size ;) - { - size_t mbclen; - mbclen = mbrtowc(&wc, buf + i, size - i, &cur_state); - - if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0) - { - /* An invalid sequence, or a truncated multibyte character. - We treat it as a singlebyte character. */ - mbclen = 1; - } - else if (match_icase) - { - if (iswupper((wint_t)wc)) - { - wc = towlower((wint_t)wc); - wcrtomb(buf + i, wc, &cur_state); - } - } - mb_properties[i] = mbclen; - i += mbclen; - } - - /* Now populate the cache. */ - if (mb_cache) - { - if (mb_cache->wcs_buf) - { - free (mb_cache->wcs_buf); - mb_cache->wcs_buf = NULL; - } - if (mb_cache->mblen_buf) - free (mb_cache->mblen_buf); - mb_cache->len = size; - mb_cache->orig_buf = orig_buf; - mb_cache->mblen_buf = xmalloc (size); - memcpy (mb_cache->mblen_buf, mb_properties, size); - } - } - - return mb_properties; -} -#endif - static void Gcompile (char const *pattern, size_t size) { @@ -228,6 +168,7 @@ >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200505150049.j4F0nOB2049026>