Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Jun 2004 22:09:09 -0700 (PDT)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 54006 for review
Message-ID:  <200406020509.i52599fi027938@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=54006

Change 54006 by marcel@marcel_nfs on 2004/06/01 22:08:53

	IFC @54001

Affected files ...

.. //depot/projects/gdb/bin/ps/ps.c#11 integrate
.. //depot/projects/gdb/contrib/libpcap/pcap-bpf.c#3 integrate
.. //depot/projects/gdb/etc/mtree/BSD.local.dist#6 integrate
.. //depot/projects/gdb/etc/mtree/BSD.x11-4.dist#2 integrate
.. //depot/projects/gdb/games/fortune/datfiles/fortunes#8 integrate
.. //depot/projects/gdb/games/fortune/datfiles/fortunes2#6 integrate
.. //depot/projects/gdb/games/fortune/datfiles/murphy#2 integrate
.. //depot/projects/gdb/include/wctype.h#2 integrate
.. //depot/projects/gdb/lib/libc/gen/ftok.c#2 integrate
.. //depot/projects/gdb/lib/libc/net/eui64.3#2 integrate
.. //depot/projects/gdb/lib/libc/net/eui64.c#2 integrate
.. //depot/projects/gdb/lib/libc/net/getaddrinfo.c#3 integrate
.. //depot/projects/gdb/lib/libmilter/Makefile#2 integrate
.. //depot/projects/gdb/lib/libncp/ncpl_subr.c#2 integrate
.. //depot/projects/gdb/lib/libsm/Makefile#2 integrate
.. //depot/projects/gdb/lib/msun/src/e_pow.c#2 integrate
.. //depot/projects/gdb/lib/msun/src/e_powf.c#2 integrate
.. //depot/projects/gdb/release/doc/en_US.ISO8859-1/relnotes/common/new.sgml#20 integrate
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/Makefile#2 integrate
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/Makefile#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/Makefile.inc#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/alpha/Makefile#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/alpha/article.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/amd64/Makefile#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/amd64/article.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/amd64/proc-amd64.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/common/artheader.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/common/dev.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/common/hw.ent#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/common/intro.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/i386/Makefile#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/i386/article.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/i386/proc-i386.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/ia64/Makefile#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/ia64/article.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/ia64/proc-ia64.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/pc98/Makefile#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/pc98/article.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/pc98/proc-pc98.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/sparc64/Makefile#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/sparc64/article.sgml#1 branch
.. //depot/projects/gdb/release/doc/ru_RU.KOI8-R/hardware/sparc64/proc-sparc64.sgml#1 branch
.. //depot/projects/gdb/sbin/sunlabel/sunlabel.8#3 integrate
.. //depot/projects/gdb/sbin/sunlabel/sunlabel.c#3 integrate
.. //depot/projects/gdb/sys/alpha/alpha/promcons.c#3 integrate
.. //depot/projects/gdb/sys/alpha/tlsb/zs_tlsb.c#5 integrate
.. //depot/projects/gdb/sys/compat/ndis/kern_ndis.c#13 integrate
.. //depot/projects/gdb/sys/conf/NOTES#21 integrate
.. //depot/projects/gdb/sys/conf/files#26 integrate
.. //depot/projects/gdb/sys/contrib/pf/net/if_pflog.c#5 integrate
.. //depot/projects/gdb/sys/contrib/pf/net/if_pfsync.c#5 integrate
.. //depot/projects/gdb/sys/contrib/pf/net/pf_ioctl.c#6 integrate
.. //depot/projects/gdb/sys/dev/aac/aac.c#5 integrate
.. //depot/projects/gdb/sys/dev/ata/ata-lowlevel.c#10 integrate
.. //depot/projects/gdb/sys/dev/ata/ata-queue.c#7 integrate
.. //depot/projects/gdb/sys/dev/ata/atapi-cd.c#4 integrate
.. //depot/projects/gdb/sys/dev/cy/cy.c#4 integrate
.. //depot/projects/gdb/sys/dev/dcons/dcons.c#7 integrate
.. //depot/projects/gdb/sys/dev/digi/digi.c#4 integrate
.. //depot/projects/gdb/sys/dev/if_ndis/if_ndis_pccard.c#5 integrate
.. //depot/projects/gdb/sys/dev/if_ndis/if_ndis_pci.c#5 integrate
.. //depot/projects/gdb/sys/dev/nmdm/nmdm.c#6 integrate
.. //depot/projects/gdb/sys/dev/ofw/ofw_console.c#4 integrate
.. //depot/projects/gdb/sys/dev/pcf/pcf.c#2 integrate
.. //depot/projects/gdb/sys/dev/pcf/pcf_isa.c#2 integrate
.. //depot/projects/gdb/sys/dev/rc/rc.c#5 integrate
.. //depot/projects/gdb/sys/dev/rp/rp.c#3 integrate
.. //depot/projects/gdb/sys/dev/si/si.c#3 integrate
.. //depot/projects/gdb/sys/dev/sio/sio.c#11 integrate
.. //depot/projects/gdb/sys/dev/sound/isa/emu8000.c#3 delete
.. //depot/projects/gdb/sys/dev/sound/isa/gusmidi.c#3 delete
.. //depot/projects/gdb/sys/dev/sound/isa/mpu.c#4 delete
.. //depot/projects/gdb/sys/dev/sound/isa/opl.c#3 delete
.. //depot/projects/gdb/sys/dev/sound/isa/uartsio.c#4 delete
.. //depot/projects/gdb/sys/dev/sound/midi/midi.c#3 delete
.. //depot/projects/gdb/sys/dev/sound/midi/midi.h#3 delete
.. //depot/projects/gdb/sys/dev/sound/midi/midibuf.c#2 delete
.. //depot/projects/gdb/sys/dev/sound/midi/midibuf.h#2 delete
.. //depot/projects/gdb/sys/dev/sound/midi/midisynth.c#2 delete
.. //depot/projects/gdb/sys/dev/sound/midi/midisynth.h#2 delete
.. //depot/projects/gdb/sys/dev/sound/midi/miditypes.h#2 delete
.. //depot/projects/gdb/sys/dev/sound/midi/sequencer.c#3 delete
.. //depot/projects/gdb/sys/dev/sound/midi/sequencer.h#2 delete
.. //depot/projects/gdb/sys/dev/sound/midi/timer.c#2 delete
.. //depot/projects/gdb/sys/dev/sound/midi/timer.h#2 delete
.. //depot/projects/gdb/sys/dev/sound/pci/csamidi.c#4 delete
.. //depot/projects/gdb/sys/dev/sound/usb/uaudio_pcm.c#2 integrate
.. //depot/projects/gdb/sys/dev/sx/sx.c#2 integrate
.. //depot/projects/gdb/sys/dev/syscons/syscons.c#8 integrate
.. //depot/projects/gdb/sys/dev/syscons/sysmouse.c#3 integrate
.. //depot/projects/gdb/sys/dev/usb/ubser.c#3 integrate
.. //depot/projects/gdb/sys/dev/usb/ucom.c#4 integrate
.. //depot/projects/gdb/sys/fs/fifofs/fifo_vnops.c#5 integrate
.. //depot/projects/gdb/sys/geom/geom_sunlabel_enc.c#2 integrate
.. //depot/projects/gdb/sys/i386/acpica/madt.c#6 integrate
.. //depot/projects/gdb/sys/i386/i386/io_apic.c#4 integrate
.. //depot/projects/gdb/sys/i386/i386/legacy.c#4 integrate
.. //depot/projects/gdb/sys/i386/i386/nexus.c#3 integrate
.. //depot/projects/gdb/sys/i386/i386/vm_machdep.c#11 integrate
.. //depot/projects/gdb/sys/i386/isa/pcvt/pcvt_drv.c#4 integrate
.. //depot/projects/gdb/sys/i386/pci/pci_bus.c#5 integrate
.. //depot/projects/gdb/sys/ia64/ia64/ssc.c#3 integrate
.. //depot/projects/gdb/sys/kern/kern_conf.c#5 integrate
.. //depot/projects/gdb/sys/kern/kern_descrip.c#6 integrate
.. //depot/projects/gdb/sys/kern/kern_event.c#4 integrate
.. //depot/projects/gdb/sys/kern/kern_malloc.c#5 integrate
.. //depot/projects/gdb/sys/kern/kern_mbuf.c#1 branch
.. //depot/projects/gdb/sys/kern/subr_mbuf.c#4 delete
.. //depot/projects/gdb/sys/kern/tty.c#5 integrate
.. //depot/projects/gdb/sys/kern/tty_pty.c#5 integrate
.. //depot/projects/gdb/sys/kern/uipc_accf.c#3 integrate
.. //depot/projects/gdb/sys/kern/uipc_mbuf.c#5 integrate
.. //depot/projects/gdb/sys/kern/uipc_mbuf2.c#4 integrate
.. //depot/projects/gdb/sys/kern/uipc_socket.c#7 integrate
.. //depot/projects/gdb/sys/kern/uipc_socket2.c#7 integrate
.. //depot/projects/gdb/sys/kern/uipc_syscalls.c#11 integrate
.. //depot/projects/gdb/sys/kern/vfs_subr.c#8 integrate
.. //depot/projects/gdb/sys/kern/vfs_vnops.c#6 integrate
.. //depot/projects/gdb/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c#5 integrate
.. //depot/projects/gdb/sys/netgraph/ng_ksocket.c#4 integrate
.. //depot/projects/gdb/sys/netgraph/ng_tee.c#5 integrate
.. //depot/projects/gdb/sys/nfsserver/nfs_serv.c#7 integrate
.. //depot/projects/gdb/sys/nfsserver/nfs_srvsubs.c#6 integrate
.. //depot/projects/gdb/sys/nfsserver/nfs_syscalls.c#7 integrate
.. //depot/projects/gdb/sys/pc98/pc98/sio.c#9 integrate
.. //depot/projects/gdb/sys/sparc64/sparc64/vm_machdep.c#8 integrate
.. //depot/projects/gdb/sys/sys/conf.h#5 integrate
.. //depot/projects/gdb/sys/sys/mbuf.h#10 integrate
.. //depot/projects/gdb/sys/sys/socket.h#6 integrate
.. //depot/projects/gdb/sys/sys/socketvar.h#4 integrate
.. //depot/projects/gdb/sys/sys/sun_disklabel.h#3 integrate
.. //depot/projects/gdb/sys/sys/tty.h#3 integrate
.. //depot/projects/gdb/sys/ufs/ffs/fs.h#4 integrate
.. //depot/projects/gdb/sys/vm/uma.h#2 integrate
.. //depot/projects/gdb/sys/vm/uma_core.c#6 integrate
.. //depot/projects/gdb/sys/vm/uma_dbg.c#2 integrate
.. //depot/projects/gdb/sys/vm/uma_int.h#3 integrate
.. //depot/projects/gdb/sys/vm/vm_kern.c#5 integrate
.. //depot/projects/gdb/usr.bin/calendar/calendars/calendar.birthday#3 integrate
.. //depot/projects/gdb/usr.bin/netstat/main.c#4 integrate
.. //depot/projects/gdb/usr.bin/netstat/mbuf.c#3 integrate
.. //depot/projects/gdb/usr.bin/netstat/netstat.1#4 integrate
.. //depot/projects/gdb/usr.bin/netstat/netstat.h#3 integrate
.. //depot/projects/gdb/usr.bin/systat/mbufs.c#2 integrate
.. //depot/projects/gdb/usr.bin/tar/bsdtar.1#6 integrate
.. //depot/projects/gdb/usr.bin/tar/bsdtar.c#14 integrate
.. //depot/projects/gdb/usr.sbin/Makefile#9 integrate
.. //depot/projects/gdb/usr.sbin/arlconfig/Makefile#2 delete
.. //depot/projects/gdb/usr.sbin/arlconfig/arlconfig.8#3 delete
.. //depot/projects/gdb/usr.sbin/arlconfig/arlconfig.c#3 delete
.. //depot/projects/gdb/usr.sbin/arlcontrol/Makefile#1 branch
.. //depot/projects/gdb/usr.sbin/arlcontrol/arlcontrol.8#2 integrate
.. //depot/projects/gdb/usr.sbin/jail/jail.8#6 integrate
.. //depot/projects/gdb/usr.sbin/kldxref/kldxref.8#3 integrate
.. //depot/projects/gdb/usr.sbin/kldxref/kldxref.c#4 integrate
.. //depot/projects/gdb/usr.sbin/newsyslog/newsyslog.c#3 integrate
.. //depot/projects/gdb/usr.sbin/sendmail/Makefile#2 integrate
.. //depot/projects/gdb/usr.sbin/sysinstall/menus.c#5 integrate

Differences ...

==== //depot/projects/gdb/bin/ps/ps.c#11 (text+ko) ====

@@ -47,7 +47,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/ps/ps.c,v 1.91 2004/05/23 21:35:35 gad Exp $");
+__FBSDID("$FreeBSD: src/bin/ps/ps.c,v 1.98 2004/06/01 23:27:11 gad Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -84,6 +84,12 @@
 #define	OPT_LAZY_f		/* I.e., the `-f' option is not added. */
 #endif
 
+/*
+ * isdigit takes an `int', but expects values in the range of unsigned char.
+ * This wrapper ensures that values from a 'char' end up in the correct range.
+ */
+#define	isdigitch(Anychar) isdigit((u_char)(Anychar))
+
 int	 cflag;			/* -c */
 int	 eval;			/* Exit value */
 time_t	 now;			/* Current time(3) value */
@@ -134,7 +140,7 @@
 		    KINFO *, char *, int);
 static void	 free_list(struct listinfo *);
 static void	 init_list(struct listinfo *, addelem_rtn, int, const char *);
-static char	*kludge_oldps_options(char *);
+static char	*kludge_oldps_options(const char *, char *, const char *);
 static int	 pscomp(const void *, const void *);
 static void	 saveuser(KINFO *);
 static void	 scanvars(void);
@@ -162,10 +168,10 @@
 	struct kinfo_proc *kp;
 	struct varent *vent;
 	struct winsize ws;
-	const char *cp, *nlistf, *memf;
+	const char *nlistf, *memf;
 	char *cols;
 	int all, ch, dropgid, elem, flag, _fmt, i, lineno;
-	int nentries, nocludge, nkept, nselectors;
+	int nentries, nkept, nselectors;
 	int prtheader, showthreads, wflag, what, xkeep, xkeep_implied;
 	char errbuf[_POSIX2_LINE_MAX];
 
@@ -183,24 +189,11 @@
 		termwidth = ws.ws_col - 1;
 
 	/*
-	 * Don't apply a kludge if the first argument is an option taking an
-	 * argument
+	 * Hide a number of option-processing kludges in a separate routine,
+	 * to support some historical BSD behaviors, such as `ps axu'.
 	 */
-	if (argc > 1) {
-		nocludge = 0;
-		if (argv[1][0] == '-') {
-			for (cp = PS_ARGS; *cp != '\0'; cp++) {
-				if (*cp != ':')
-					continue;
-				if (*(cp - 1) == argv[1][1]) {
-					nocludge = 1;
-					break;
-				}
-			}
-		}
-		if (nocludge == 0)
-			argv[1] = kludge_oldps_options(argv[1]);
-	}
+	if (argc > 1)
+		argv[1] = kludge_oldps_options(PS_ARGS, argv[1], argv[2]);
 
 	all = dropgid = _fmt = nselectors = optfatal = 0;
 	prtheader = showthreads = wflag = xkeep_implied = 0;
@@ -214,7 +207,7 @@
 	init_list(&uidlist, addelem_uid, sizeof(uid_t), "user");
 	memf = nlistf = _PATH_DEVNULL;
 	while ((ch = getopt(argc, argv, PS_ARGS)) != -1)
-		switch((char)ch) {
+		switch ((char)ch) {
 		case 'A':
 			/*
 			 * Exactly the same as `-ax'.   This has been
@@ -408,27 +401,34 @@
 		}
 	argc -= optind;
 	argv += optind;
+
+	/*
+	 * If there arguments after processing all the options, attempt
+	 * to treat them as a list of process ids.
+	 */
+	while (*argv) {
+		if (!isdigitch(**argv))
+			break;
+		add_list(&pidlist, *argv);
+		argv++;
+	}
+	if (*argv) {
+		fprintf(stderr, "%s: illegal argument: %s\n",
+		    getprogname(), *argv);
+		usage();
+	}
 	if (optfatal)
 		exit(1);		/* Error messages already printed. */
 	if (xkeep < 0)			/* Neither -X nor -x was specified. */
 		xkeep = xkeep_implied;
 
-#define	BACKWARD_COMPATIBILITY
-#ifdef	BACKWARD_COMPATIBILITY
-	if (*argv) {
-		nlistf = *argv;
-		if (*++argv)
-			memf = *argv;
-	}
-#endif
+
 	/*
 	 * Discard setgid privileges if not the running kernel so that bad
 	 * guys can't print interesting stuff from kernel memory.
 	 */
-	if (dropgid) {
+	if (dropgid)
 		setgid(getgid());
-		setuid(getuid());
-	}
 
 	kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
 	if (kd == 0)
@@ -656,9 +656,8 @@
 	if (grp == NULL) {
 		warnx("No %s %s '%s'", inf->lname, nameorID, elem);
 		optfatal = 1;
-		return (0);		/* Do not add this value. */
+		return (0);
 	}
-
 	if (inf->count >= inf->maxcount)
 		expand_list(inf);
 	inf->l.gids[(inf->count)++] = grp->gr_gid;
@@ -672,24 +671,25 @@
 	char *endp;
 	long tempid;
 
-	if (*elem == '\0')
-		tempid = 0L;
-	else {
-		errno = 0;
-		tempid = strtol(elem, &endp, 10);
-		if (*endp != '\0' || tempid < 0 || elem == endp) {
-			warnx("Invalid %s: %s", inf->lname, elem);
-			errno = ERANGE;
-		} else if (errno != 0 || tempid > BSD_PID_MAX) {
-			warnx("%s too large: %s", inf->lname, elem);
-			errno = ERANGE;
-		}
-		if (errno == ERANGE) {
-			optfatal = 1;
-			return (0);	/* Do not add this value. */
-		}
+	if (*elem == '\0') {
+		warnx("Invalid (zero-length) process id");
+		optfatal = 1;
+		return (0);		/* Do not add this value. */
 	}
 
+	errno = 0;
+	tempid = strtol(elem, &endp, 10);
+	if (*endp != '\0' || tempid < 0 || elem == endp) {
+		warnx("Invalid %s: %s", inf->lname, elem);
+		errno = ERANGE;
+	} else if (errno != 0 || tempid > BSD_PID_MAX) {
+		warnx("%s too large: %s", inf->lname, elem);
+		errno = ERANGE;
+	}
+	if (errno == ERANGE) {
+		optfatal = 1;
+		return (0);
+	}
 	if (inf->count >= inf->maxcount)
 		expand_list(inf);
 	inf->l.pids[(inf->count)++] = tempid;
@@ -717,14 +717,13 @@
 	if (stat(ttypath, &sb) == -1) {
 		warn("%s", ttypath);
 		optfatal = 1;
-		return (0);		/* Do not add this value. */
+		return (0);
 	}
 	if (!S_ISCHR(sb.st_mode)) {
 		warn("%s: Not a terminal", ttypath);
 		optfatal = 1;
-		return (0);		/* Do not add this value. */
+		return (0);
 	}
-
 	if (inf->count >= inf->maxcount)
 		expand_list(inf);
 	inf->l.ttys[(inf->count)++] = sb.st_rdev;
@@ -768,9 +767,8 @@
 		 * errors (and the command will be aborted).
 		 */
 		optfatal = 1;
-		return (0);		/* Do not add this value. */
+		return (0);
 	}
-
 	if (inf->count >= inf->maxcount)
 		expand_list(inf);
 	inf->l.uids[(inf->count)++] = pwd->pw_uid;
@@ -785,6 +783,8 @@
 	int toolong;
 	char elemcopy[PATH_MAX];
 
+	if (*argp == 0)
+		inf->addelem(inf, elemcopy);
 	while (*argp != '\0') {
 		while (*argp != '\0' && strchr(W_SEP, *argp) != NULL)
 			argp++;
@@ -801,35 +801,10 @@
 		}
 		if (!toolong) {
 			*cp = '\0';
-#ifndef ADD_PS_LISTRESET
 			/*
-			 * This is how the standard expects lists to
-			 * be handled.
+			 * Add this single element to the given list.
 			 */
 			inf->addelem(inf, elemcopy);
-#else
-			/*-
-			 * This would add a simple non-standard-but-convienent
-			 * feature.
-			 *
-			 * XXX - The first time I tried to add this check,
-			 *	it increased the total size of `ps' by 3940
-			 *	bytes on i386!  That's 12% of the entire
-			 *	program!  The `ps.o' file grew by only about
-			 *	40 bytes, but the final (stripped) executable
-			 *	in /bin/ps grew by 12%.  I have not had time
-			 *	to investigate, so skip the feature for now.
-			 */
-			/*
-			 * We now have a single element.  Add it to the
-			 * list, unless the element is ":".  In that case,
-			 * reset the list so previous entries are ignored.
-			 */
-			if (strcmp(elemcopy, ":") == 0)
-				inf->count = 0;
-			else
-				inf->addelem(inf, elemcopy);
-#endif
 		} else {
 			/*
 			 * The string is too long to copy.  Find the end
@@ -868,8 +843,7 @@
 	newlist = realloc(inf->l.ptr, newmax * inf->elemsize);
 	if (newlist == NULL) {
 		free(inf->l.ptr);
-		errx(1, "realloc to %d %ss failed", newmax,
-		    inf->lname);
+		errx(1, "realloc to %d %ss failed", newmax, inf->lname);
 	}
 	inf->maxcount = newmax;
 	inf->l.ptr = newlist;
@@ -1075,31 +1049,29 @@
  * feature is available with the option 'T', which takes no argument.
  */
 static char *
-kludge_oldps_options(char *s)
+kludge_oldps_options(const char *optlist, char *origval, const char *nextarg)
 {
-	int have_fmt;
 	size_t len;
-	char *newopts, *ns, *cp;
+	char *argp, *cp, *newopts, *ns, *optp, *pidp;
 
 	/*
-	 * If we have an 'o' option, then note it, since we don't want to do
-	 * some types of munging.
+	 * See if the original value includes any option which takes an
+	 * argument (and will thus use up the remainder of the string).
 	 */
-	have_fmt = index(s, 'o') != NULL;
+	argp = NULL;
+	if (optlist != NULL) {
+		for (cp = origval; *cp != '\0'; cp++) {
+			optp = strchr(optlist, *cp);
+			if ((optp != NULL) && *(optp + 1) == ':') {
+				argp = cp;
+				break;
+			}
+		}
+	}
+	if (argp != NULL && *origval == '-')
+		return (origval);
 
-	len = strlen(s);
-	if ((newopts = ns = malloc(len + 2)) == NULL)
-		errx(1, "malloc failed");
-	/*
-	 * options begin with '-'
-	 */
-	if (*s != '-')
-		*ns++ = '-';	/* add option flag */
 	/*
-	 * gaze to end of argv[1]
-	 */
-	cp = s + len - 1;
-	/*
 	 * if last letter is a 't' flag with no argument (in the context
 	 * of the oldps options -- option string NOT starting with a '-' --
 	 * then convert to 'T' (meaning *this* terminal, i.e. ttyname(0)).
@@ -1107,30 +1079,60 @@
 	 * However, if a flag accepting a string argument is found earlier
 	 * in the option string (including a possible `t' flag), then the
 	 * remainder of the string must be the argument to that flag; so
-	 * do not modify that argument.
+	 * do not modify that argument.  Note that a trailing `t' would
+	 * cause argp to be set, if argp was not already set by some
+	 * earlier option.
 	 */
-	if (*cp == 't' && *s != '-' && strcspn(s, "MNOoUt") == len - 1)
-		*cp = 'T';
-	else {
+	len = strlen(origval);
+	cp = origval + len - 1;
+	pidp = NULL;
+	if (*cp == 't' && *origval != '-' && cp == argp) {
+		if (nextarg == NULL || *nextarg == '-' || isdigitch(*nextarg))
+			*cp = 'T';
+	} else if (argp == NULL) {
 		/*
-		 * otherwise check for trailing number, which *may* be a
-		 * pid.
+		 * The original value did not include any option which takes
+		 * an argument (and that would include `p' and `t'), so check
+		 * the value for trailing number, or comma-separated list of
+		 * numbers, which we will treat as a pid request.
 		 */
-		while (cp >= s && isdigit(*cp))
-			--cp;
+		if (isdigitch(*cp)) {
+			while (cp >= origval && (*cp == ',' || isdigitch(*cp)))
+				--cp;
+			pidp = cp + 1;
+		}
 	}
-	cp++;
-	memmove(ns, s, (size_t)(cp - s));	/* copy up to trailing number */
-	ns += cp - s;
+
+	/*
+	 * If nothing needs to be added to the string, then return
+	 * the "original" (although possibly modified) value.
+	 */
+	if (*origval == '-' && pidp == NULL)
+		return (origval);
+
 	/*
-	 * if there's a trailing number, and not a preceding 'p' (pid) or
-	 * 't' (tty) flag, then assume it's a pid and insert a 'p' flag.
+	 * Create a copy of the string to add '-' and/or 'p' to the
+	 * original value.
 	 */
-	if (isdigit(*cp) &&
-	    (cp == s || (cp[-1] != 't' && cp[-1] != 'p')) &&
-	    (cp - 1 == s || cp[-2] != 't') && !have_fmt)
+	if ((newopts = ns = malloc(len + 3)) == NULL)
+		errx(1, "malloc failed");
+
+	if (*origval != '-')
+		*ns++ = '-';	/* add option flag */
+
+	if (pidp == NULL)
+		strcpy(ns, origval);
+	else {
+		/*
+		 * Copy everything before the pid string, add the `p',
+		 * and then copy the pid string.
+		 */
+		len = pidp - origval;
+		memcpy(ns, origval, len);
+		ns += len;
 		*ns++ = 'p';
-	(void)strcpy(ns, cp);		/* and append the number */
+		strcpy(ns, pidp);
+	}
 
 	return (newopts);
 }

==== //depot/projects/gdb/contrib/libpcap/pcap-bpf.c#3 (text+ko) ====

@@ -17,6 +17,8 @@
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/contrib/libpcap/pcap-bpf.c,v 1.2 2004/05/31 21:29:30 dwmalone Exp $
  */
 #ifndef lint
 static const char rcsid[] _U_ =
@@ -467,7 +469,7 @@
 	 */
 	do {
 		(void)snprintf(device, sizeof(device), "/dev/bpf%d", n++);
-		fd = open(device, O_RDONLY);
+		fd = open(device, O_RDWR);
 	} while (fd < 0 && errno == EBUSY);
 
 	/*

==== //depot/projects/gdb/etc/mtree/BSD.local.dist#6 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/etc/mtree/BSD.local.dist,v 1.111 2004/04/21 15:28:21 tjr Exp $
+# $FreeBSD: src/etc/mtree/BSD.local.dist,v 1.112 2004/05/31 07:34:40 kris Exp $
 #
 # Please see the file src/etc/mtree/README before making changes to this file.
 #
@@ -268,6 +268,56 @@
             classes
             ..
         ..
+        locale
+            bg
+            ..
+            da
+            ..
+            de
+            ..
+            en
+            ..
+            en_GB
+            ..
+            eo
+            ..
+            es
+            ..
+            et
+            ..
+            fr
+            ..
+            he
+            ..
+            hr
+            ..
+            hu
+            ..
+            id
+            ..
+            it
+            ..
+            ja
+            ..
+            lt
+            ..
+            ms
+            ..
+            nb
+            ..
+            nl
+            ..
+            pt_BR
+            ..
+            ru
+            ..
+            sv
+            ..
+            tr
+            ..
+            zh_TW.Big5
+            ..
+        ..
         misc
         ..
         nls
@@ -579,4 +629,6 @@
         xml
         ..
     ..
+    www
+    ..
 ..

==== //depot/projects/gdb/etc/mtree/BSD.x11-4.dist#2 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/etc/mtree/BSD.x11-4.dist,v 1.23 2003/05/14 07:23:54 anholt Exp $
+# $FreeBSD: src/etc/mtree/BSD.x11-4.dist,v 1.24 2004/05/31 07:34:40 kris Exp $
 #
 # Please see the file src/etc/mtree/README before making changes to this file.
 #
@@ -456,5 +456,129 @@
         ..
         examples
         ..
+        locale
+            af
+            ..
+            am
+            ..
+            az
+            ..
+            be
+            ..
+            bg
+            ..
+            bs
+            ..
+            ca
+            ..
+            cs
+            ..
+            cy
+            ..
+            da
+            ..
+            de
+            ..
+            el
+            ..
+            en
+            ..
+            en_CA
+            ..
+            en_GB
+            ..
+            eo
+            ..
+            es
+            ..
+            es_ES
+            ..
+            es_MX
+            ..
+            et
+            ..
+            fa
+            ..
+            fi
+            ..
+            fr
+            ..
+            ga
+            ..
+            gl
+            ..
+            he
+            ..
+            hr
+            ..
+            hu
+            ..
+            id
+            ..
+            it
+            ..
+            ja
+            ..
+            kn
+            ..
+            ko
+            ..
+            lt
+            ..
+            lv
+            ..
+            mk
+            ..
+            ml
+            ..
+            ms
+            ..
+            nl
+            ..
+            nn
+            ..
+            no
+            ..
+            pl
+            ..
+            pt
+            ..
+            pt_BR
+            ..
+            pt_PT
+            ..
+            ro
+            ..
+            ru
+            ..
+            sk
+            ..
+            sl
+            ..
+            sq
+            ..
+            sr
+            ..
+            sr@Latn
+            ..
+            sv
+            ..
+            ta
+            ..
+            th
+            ..
+            tr
+            ..
+            uk
+            ..
+            vi
+            ..
+            zh_CN
+            ..
+            zh_TW
+            ..
+            zh_TW.Big5
+            ..
+        ..
     ..
 ..

==== //depot/projects/gdb/games/fortune/datfiles/fortunes#8 (text+ko) ====

@@ -1,5 +1,5 @@
 This fortune brought to you by:
-$FreeBSD: src/games/fortune/datfiles/fortunes,v 1.135 2004/05/25 19:15:02 wollman Exp $
+$FreeBSD: src/games/fortune/datfiles/fortunes,v 1.137 2004/06/01 09:45:16 des Exp $
 
 %
 			-- Gifts for Children --
@@ -678,7 +678,7 @@
 	"Well, gee, doesn't Louise count?"
 	"Only to ten, Mudhead."
 
-			-- Firesign Theater
+		-- Firesign Theater
 %
 	GREAT MOMENTS IN AMERICAN HISTORY #21 -- July 30, 1917
 
@@ -1780,7 +1780,7 @@
 A conclusion is simply the place where someone got tired of thinking.
 %
 A CONS is an object which cares.
-		-- Bernie Greenberg.
+		-- Bernie Greenberg
 %
 A consultant is a person who borrows your watch, tells you what time it
 is, pockets the watch, and sends you a bill for it.
@@ -4475,7 +4475,7 @@
 whether it is based upon deliberation or governed by passion,
 prejudice, and impulse, without restraint or regard to consequences.
 Result is demagogism, license, agitation, discontent, anarchy.
-		-- U. S. Army Training Manual No. 2000-25 (1928-1932),
+		-- U.S. Army Training Manual No. 2000-25 (1928-1932),
 		   since withdrawn.
 %
 Demographic polls show that you have lost credibility across the
@@ -5431,7 +5431,7 @@
 I'd not read Eliot, Auden or MacNiece.
 But now I think a thought that brings me hope:
 Neither had Chaucer, Shakespeare, Milton, Pope.
-		-- Justin Richardson.
+		-- Justin Richardson
 %
 For your penance, say five Hail Marys and one loud BLAH!
 %
@@ -5720,7 +5720,7 @@
 	set off the flash bulb on your camera once.
 
 		-- Peter Doms, manager of the Deep Space Network
-		               systems program at JPL.
+		   systems program at JPL
 %
 From the Pro 350 Pocket Service Guide, p. 49, Step 5 of the
 instructions on removing an I/O board from the card cage, comes a new
@@ -5770,7 +5770,7 @@
 %
 Gauls!  We have nothing to fear; except perhaps that the sky may fall
 on our heads tomorrow.  But as we all know, tomorrow never comes!!
-		-- Adventures of Asterix.
+		-- Adventures of Asterix
 %
 Gay shlafen: Yiddish for "go to sleep".
 
@@ -6801,7 +6801,7 @@
 "I can remember when a good politician had to be 75 percent ability and
 25 percent actor, but I can well see the day when the reverse could be
 true."
-		-- Harry Truman
+		-- Harry S. Truman
 %
 "I can resist anything but temptation."
 %
@@ -7013,7 +7013,7 @@
 beefsteak and perhaps a supporter below.  Westbrook Pegler, a
 guttersnipe, is a gentleman compared to you.  You can take that as more
 of an insult than as a reflection on your ancestry."
-		-- President Harry S Truman
+		-- Harry S. Truman
 %
 I have learned
 To spell hors d'oeuvres
@@ -7796,7 +7796,7 @@
 If you can survive death, you can probably survive anything.
 %
 If you cannot convince them, confuse them.
-		-- Harry S Truman
+		-- Harry S. Truman
 %
 If you can't be good, be careful.  If you can't be careful, give me a
 call.
@@ -8456,7 +8456,7 @@
 applauded.  He repeated his warning, they shouted even louder.  So I
 think the world will come to an end amid general applause from all the
 wits, who believe that it is a joke.
-			-- S. A. Kierkegaard (1813-1855)
+		-- S. A. Kierkegaard (1813-1855)
 %
 It has been observed that one's nose is never so happy as when it is
 thrust into the affairs of another, from which some physiologists have
@@ -12839,7 +12839,7 @@
 The assertion that "all men are created equal" was of no practical use
 in effecting our separation from Great Britain and it was placed in the
 Declaration not for that, but for future use.
-		--  Abraham Lincoln
+		-- Abraham Lincoln
 %
 The average income of the modern teenager is about 2 a.m.
 %
@@ -13497,7 +13497,7 @@
 %
 "The National Association of Theater Concessionaires reported that in
 1986, 60% of all candy sold in movie theaters was sold to Roger Ebert."
-		-- D. Letterman
+		-- David Letterman
 %
 The National Short-Sleeved Shirt Association says:
 	Support your right to bare arms!
@@ -13764,7 +13764,7 @@
 %
 The reason we come up with new versions is not to fix bugs.  It's
 absolutely not.
-			-- Bill Gates
+		-- Bill Gates
 %
 The reasonable man adapts himself to the world; the unreasonable one
 persists in trying to adapt the world to himself.  Therefore all
@@ -13988,7 +13988,7 @@
 %
 The United States also has its native Fascists who say that they are
 "100 percent American"...
-		-- U. S. Army (1945)
+		-- U.S. Army (1945)
 %
 The United States is like the guy at the party who gives cocaine to
 everybody and still nobody likes him.
@@ -14098,7 +14098,7 @@
 marginally competent physicist would immediately use this to run a heat
 engine and make some other part of hell comfortably cool.  This is
 obviously impossible.
-				-- Richard Davisson
+		-- Richard Davisson
 %
 There are people so addicted to exaggeration that they can't tell the
 truth without lying.
@@ -15291,12 +15291,12 @@
 %
 Welcome thy neighbor into thy fallout shelter.  He'll come in handy if
 you run out of food.
-		-- Dean McLaughlin.
+		-- Dean McLaughlin
 %
 "Well," Brahma said, "even after ten thousand explanations, a fool is
 no wiser, but an intelligent man requires only two thousand five
 hundred."
-		-- The Mahabharata.
+		-- The Mahabharata
 %
 "We'll cross out that bridge when we come back to it later."
 %
@@ -15733,7 +15733,7 @@
 When you don't know what you are doing, do it neatly.
 %
 When you have an efficient government, you have a dictatorship.
-		-- Harry Truman
+		-- Harry S. Truman
 %
 "When you have to kill a man it costs nothing to be polite."
 		-- Winston Churchill, On formal declarations of war
@@ -15762,7 +15762,7 @@
 %
 Whenever I hear anyone arguing for slavery, I feel a strong impulse to
 see it tried on him personally.
-		-- A. Lincoln
+		-- Abraham Lincoln
 %
 Whenever people agree with me I always feel I must be wrong.
 		-- Oscar Wilde
@@ -16439,7 +16439,7 @@
 %
 You probably wouldn't worry about what people think of you if you could
 know how seldom they do.
-		-- Olin Miller.
+		-- Olin Miller
 %
 You should emulate your heros, but don't carry it too far.  Especially
 if they are dead.

==== //depot/projects/gdb/games/fortune/datfiles/fortunes2#6 (text+ko) ====

@@ -1,5 +1,5 @@
 This fortune brought to you by:
-$FreeBSD: src/games/fortune/datfiles/fortunes2,v 1.70 2004/05/20 08:15:58 schweikh Exp $
+$FreeBSD: src/games/fortune/datfiles/fortunes2,v 1.74 2004/06/01 09:45:16 des Exp $
 %
 =======================================================================
 ||								     ||
@@ -429,7 +429,7 @@
 I found a thesis topic:
 	How to keep people from hanging out in front of the Dover.
 		-- Sister Mary Elephant,
-		"Student Statement for Black Friday"
+		   "Student Statement for Black Friday"
 %
 	      1/2
 	 /\(3)
@@ -1671,7 +1671,7 @@

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406020509.i52599fi027938>