Module Name:    src
Committed By:   matt
Date:           Wed Apr 21 05:15:28 UTC 2010

Modified Files:
        src/bin/df [matt-nb5-mips64]: df.c
        src/bin/kill [matt-nb5-mips64]: kill.c
        src/bin/ksh [matt-nb5-mips64]: var.c
        src/bin/pax [matt-nb5-mips64]: Makefile options.c tar.1
        src/bin/sh [matt-nb5-mips64]: cd.c sh.1

Log Message:
sync to netbsd-5


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.83.8.1 src/bin/df/df.c
cvs rdiff -u -r1.25 -r1.25.10.1 src/bin/kill/kill.c
cvs rdiff -u -r1.14 -r1.14.32.1 src/bin/ksh/var.c
cvs rdiff -u -r1.37.12.2 -r1.37.12.3 src/bin/pax/Makefile
cvs rdiff -u -r1.101.12.2 -r1.101.12.2.4.1 src/bin/pax/options.c
cvs rdiff -u -r1.26.12.1 -r1.26.12.1.4.1 src/bin/pax/tar.1
cvs rdiff -u -r1.39 -r1.39.32.1 src/bin/sh/cd.c
cvs rdiff -u -r1.87.18.1 -r1.87.18.1.4.1 src/bin/sh/sh.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/df/df.c
diff -u src/bin/df/df.c:1.83 src/bin/df/df.c:1.83.8.1
--- src/bin/df/df.c:1.83	Sun Jul 20 00:52:39 2008
+++ src/bin/df/df.c	Wed Apr 21 05:15:27 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: df.c,v 1.83 2008/07/20 00:52:39 lukem Exp $ */
+/*	$NetBSD: df.c,v 1.83.8.1 2010/04/21 05:15:27 matt Exp $ */
 
 /*
  * Copyright (c) 1980, 1990, 1993, 1994
@@ -45,7 +45,7 @@
 #if 0
 static char sccsid[] = "@(#)df.c	8.7 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: df.c,v 1.83 2008/07/20 00:52:39 lukem Exp $");
+__RCSID("$NetBSD: df.c,v 1.83.8.1 2010/04/21 05:15:27 matt Exp $");
 #endif
 #endif /* not lint */
 
@@ -473,9 +473,9 @@
 		 */
 		(void)printf("%s %" PRId64 " %" PRId64 " %" PRId64 " %s %s\n",
 		    sfsp->f_mntfromname,
-		    fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize),
-		    fsbtoblk(used, sfsp->f_bsize, blocksize),
-		    fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize),
+		    fsbtoblk(sfsp->f_blocks, sfsp->f_frsize, blocksize),
+		    fsbtoblk(used, sfsp->f_frsize, blocksize),
+		    fsbtoblk(bavail, sfsp->f_frsize, blocksize),
 		    availblks == 0 ? full : strpct64((uint64_t) used,
 		    (uint64_t) availblks, 0), sfsp->f_mntonname);
 		/*

Index: src/bin/kill/kill.c
diff -u src/bin/kill/kill.c:1.25 src/bin/kill/kill.c:1.25.10.1
--- src/bin/kill/kill.c:1.25	Sun Jul 20 00:52:40 2008
+++ src/bin/kill/kill.c	Wed Apr 21 05:15:28 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: kill.c,v 1.25 2008/07/20 00:52:40 lukem Exp $ */
+/* $NetBSD: kill.c,v 1.25.10.1 2010/04/21 05:15:28 matt Exp $ */
 
 /*
  * Copyright (c) 1988, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)kill.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: kill.c,v 1.25 2008/07/20 00:52:40 lukem Exp $");
+__RCSID("$NetBSD: kill.c,v 1.25.10.1 2010/04/21 05:15:28 matt Exp $");
 #endif
 #endif /* not lint */
 
@@ -49,6 +49,8 @@
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <limits.h>
+#include <inttypes.h>
 #include <string.h>
 #include <termios.h>
 #include <unistd.h>
@@ -69,7 +71,8 @@
 int
 main(int argc, char *argv[])
 {
-	int errors, numsig, pid;
+	int errors;
+	intmax_t numsig, pid;
 	char *ep;
 
 	setprogname(argv[0]);
@@ -87,17 +90,19 @@
 		if (argc == 1) {
 			if (isdigit((unsigned char)**argv) == 0)
 				usage();
-			numsig = strtol(*argv, &ep, 10);
-			if (*ep != '\0') {
+			numsig = strtoimax(*argv, &ep, 10);
+			/* check for correctly parsed number */
+			if (*ep != '\0' || numsig == INTMAX_MIN || numsig == INTMAX_MAX) {
 				errx(EXIT_FAILURE, "illegal signal number: %s",
 						*argv);
 				/* NOTREACHED */
 			}
 			if (numsig >= 128)
 				numsig -= 128;
+			/* and whether it fits into signals range */
 			if (numsig <= 0 || numsig >= NSIG)
 				nosig(*argv);
-			printf("%s\n", sys_signame[numsig]);
+			printf("%s\n", sys_signame[(int) numsig]);
 			exit(0);
 		}
 		printsignals(stdout);
@@ -122,12 +127,14 @@
 			if ((numsig = signame_to_signum(sn)) < 0)
 				nosig(sn);
 		} else if (isdigit((unsigned char)*sn)) {
-			numsig = strtol(sn, &ep, 10);
-			if (*ep) {
+			numsig = strtoimax(sn, &ep, 10);
+			/* check for correctly parsed number */
+			if (*ep || numsig == INTMAX_MIN || numsig == INTMAX_MAX ) {
 				errx(EXIT_FAILURE, "illegal signal number: %s",
 						sn);
 				/* NOTREACHED */
 			}
+			/* and whether it fits into signals range */
 			if (numsig < 0 || numsig >= NSIG)
 				nosig(sn);
 		} else
@@ -151,14 +158,17 @@
 		} else 
 #endif
 		{
-			pid = strtol(*argv, &ep, 10);
-			if (!**argv || *ep) {
+			pid = strtoimax(*argv, &ep, 10);
+			/* make sure the pid is a number and fits into pid_t */
+			if (!**argv || *ep || pid == INTMAX_MIN ||
+				pid == INTMAX_MAX || pid != (pid_t) pid) {
+
 				warnx("illegal process id: %s", *argv);
 				errors = 1;
 				continue;
 			}
 		}
-		if (kill(pid, numsig) == -1) {
+		if (kill((pid_t) pid, (int) numsig) == -1) {
 			warn("%s", *argv);
 			errors = 1;
 		}
@@ -166,7 +176,7 @@
 		/* Wakeup the process if it was suspended, so it can
 		   exit without an explicit 'fg'. */
 		if (numsig == SIGTERM || numsig == SIGHUP)
-			kill(pid, SIGCONT);
+			kill((pid_t) pid, SIGCONT);
 #endif
 	}
 

Index: src/bin/ksh/var.c
diff -u src/bin/ksh/var.c:1.14 src/bin/ksh/var.c:1.14.32.1
--- src/bin/ksh/var.c:1.14	Wed Mar 29 15:51:00 2006
+++ src/bin/ksh/var.c	Wed Apr 21 05:15:28 2010
@@ -1,9 +1,9 @@
-/*	$NetBSD: var.c,v 1.14 2006/03/29 15:51:00 christos Exp $	*/
+/*	$NetBSD: var.c,v 1.14.32.1 2010/04/21 05:15:28 matt Exp $	*/
 
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: var.c,v 1.14 2006/03/29 15:51:00 christos Exp $");
+__RCSID("$NetBSD: var.c,v 1.14.32.1 2010/04/21 05:15:28 matt Exp $");
 #endif
 
 
@@ -458,10 +458,17 @@
 	base = 10;
 	num = 0;
 	neg = 0;
+	if (*s == '-') {
+		neg = 1;
+		s++;
+	}
+	if (s[0] == '0' && s[1] == 'x') {
+		base = 16;
+		have_base = 1;
+		s += 2;
+	}
 	for (c = (unsigned char)*s++; c ; c = (unsigned char)*s++) {
-		if (c == '-') {
-			neg++;
-		} else if (c == '#') {
+		if (c == '#') {
 			base = (int) num;
 			if (have_base || base < 2 || base > 36)
 				return -1;

Index: src/bin/pax/Makefile
diff -u src/bin/pax/Makefile:1.37.12.2 src/bin/pax/Makefile:1.37.12.3
--- src/bin/pax/Makefile:1.37.12.2	Fri Dec 18 06:12:25 2009
+++ src/bin/pax/Makefile	Wed Apr 21 05:15:28 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.37.12.2 2009/12/18 06:12:25 matt Exp $
+#	$NetBSD: Makefile,v 1.37.12.3 2010/04/21 05:15:28 matt Exp $
 #       @(#)Makefile	8.1 (Berkeley) 5/31/93
 
 .include <bsd.own.mk>
@@ -28,6 +28,7 @@
 .if defined(HOSTPROG)
 CPPFLAGS+=	-DHOSTPROG
 .else	# {	! HOSTPROG
+
 # XXX: Interix does not have it; we need a conditional for it.
 CPPFLAGS+=	-DHAVE_SYS_MTIO_H
 

Index: src/bin/pax/options.c
diff -u src/bin/pax/options.c:1.101.12.2 src/bin/pax/options.c:1.101.12.2.4.1
--- src/bin/pax/options.c:1.101.12.2	Mon Apr 13 20:42:59 2009
+++ src/bin/pax/options.c	Wed Apr 21 05:15:28 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: options.c,v 1.101.12.2 2009/04/13 20:42:59 snj Exp $	*/
+/*	$NetBSD: options.c,v 1.101.12.2.4.1 2010/04/21 05:15:28 matt Exp $	*/
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)options.c	8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: options.c,v 1.101.12.2 2009/04/13 20:42:59 snj Exp $");
+__RCSID("$NetBSD: options.c,v 1.101.12.2.4.1 2010/04/21 05:15:28 matt Exp $");
 #endif
 #endif /* not lint */
 
@@ -85,7 +85,7 @@
 static void printflg(unsigned int);
 static int c_frmt(const void *, const void *);
 static off_t str_offt(char *);
-static char *getline(FILE *fp);
+static char *get_line(FILE *fp);
 static void pax_options(int, char **);
 static void pax_usage(void);
 static void tar_options(int, char **);
@@ -95,10 +95,10 @@
 static void cpio_usage(void);
 #endif
 
-/* errors from getline */
+/* errors from get_line */
 #define GETLINE_FILE_CORRUPT 1
 #define GETLINE_OUT_OF_MEM 2
-static int getline_error;
+static int get_line_error;
 
 #define BZIP2_CMD	"bzip2"		/* command to run as bzip2 */
 #define GZIP_CMD	"gzip"		/* command to run as gzip */
@@ -692,7 +692,7 @@
 	case LIST:
 	case EXTRACT:
 		for (; optind < argc; optind++)
-			if (pat_add(argv[optind], NULL, NOGLOB_MTCH) < 0)
+			if (pat_add(argv[optind], NULL, 0) < 0)
 				pax_usage();
 		break;
 	case COPY:
@@ -1210,7 +1210,7 @@
 						tty_warn(1, "Unable to open file '%s' for read", file);
 						tar_usage();
 					}
-					while ((str = getline(fp)) != NULL) {
+					while ((str = get_line(fp)) != NULL) {
 						if (dirisnext) {
 							if (dir && mustfreedir)
 								free(dir);
@@ -1245,7 +1245,7 @@
 						free(dir);
 					if (strcmp(file, "-") != 0)
 						fclose(fp);
-					if (getline_error) {
+					if (get_line_error) {
 						tty_warn(1, "Problem with file '%s'", file);
 						tar_usage();
 					}
@@ -1315,7 +1315,7 @@
 					tty_warn(1, "Unable to open file '%s' for read", file);
 					tar_usage();
 				}
-				while ((str = getline(fp)) != NULL) {
+				while ((str = get_line(fp)) != NULL) {
 					if (dirisnext) {
 						if (ftree_add(str, 1) < 0)
 							tar_usage();
@@ -1339,7 +1339,7 @@
 					tar_usage();
 				if (strcmp(file, "-") != 0)
 					fclose(fp);
-				if (getline_error) {
+				if (get_line_error) {
 					tty_warn(1, "Problem with file '%s'",
 					    file);
 					tar_usage();
@@ -1640,11 +1640,11 @@
 				    optarg);
 				cpio_usage();
 			}
-			while ((str = getline(fp)) != NULL) {
+			while ((str = get_line(fp)) != NULL) {
 				pat_add(str, NULL, 0);
 			}
 			fclose(fp);
-			if (getline_error) {
+			if (get_line_error) {
 				tty_warn(1, "Problem with file '%s'", optarg);
 				cpio_usage();
 			}
@@ -1803,10 +1803,10 @@
 		 * no read errors allowed on updates/append operation!
 		 */
 		maxflt = 0;
-		while ((str = getline(stdin)) != NULL) {
+		while ((str = get_line(stdin)) != NULL) {
 			ftree_add(str, 0);
 		}
-		if (getline_error) {
+		if (get_line_error) {
 			tty_warn(1, "Problem while reading stdin");
 			cpio_usage();
 		}
@@ -2034,21 +2034,21 @@
 }
 
 char *
-getline(FILE *f)
+get_line(FILE *f)
 {
 	char *name, *temp;
 	size_t len;
 
 	name = fgetln(f, &len);
 	if (!name) {
-		getline_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0;
+		get_line_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0;
 		return 0;
 	}
 	if (name[len-1] != '\n')
 		len++;
 	temp = malloc(len);
 	if (!temp) {
-		getline_error = GETLINE_OUT_OF_MEM;
+		get_line_error = GETLINE_OUT_OF_MEM;
 		return 0;
 	}
 	memcpy(temp, name, len-1);

Index: src/bin/pax/tar.1
diff -u src/bin/pax/tar.1:1.26.12.1 src/bin/pax/tar.1:1.26.12.1.4.1
--- src/bin/pax/tar.1:1.26.12.1	Sun Nov 23 21:25:01 2008
+++ src/bin/pax/tar.1	Wed Apr 21 05:15:28 2010
@@ -1,4 +1,4 @@
-.\" $NetBSD: tar.1,v 1.26.12.1 2008/11/23 21:25:01 riz Exp $
+.\" $NetBSD: tar.1,v 1.26.12.1.4.1 2010/04/21 05:15:28 matt Exp $
 .\"
 .\" Copyright (c) 1996 SigmaSoft, Th. Lockert
 .\" All rights reserved.
@@ -25,7 +25,7 @@
 .\"
 .\"	OpenBSD: tar.1,v 1.28 2000/11/09 23:58:56 aaron Exp
 .\"
-.Dd May 4, 2007
+.Dd March 23, 2010
 .Dt TAR 1
 .Os
 .Sh NAME
@@ -249,7 +249,7 @@
 A line may also specify the positional argument
 .Dq Fl C Ar directory .
 .It Fl X Ar file , Fl -exclude-from Ar file
-Exclude files listed in the given file.
+Exclude files matching the shell glob patterns listed in the given file.
 .\" exclude should be '-E' and '-X' should be one-file-system
 .Pp
 Note that it would be more standard to use this option to mean ``do not

Index: src/bin/sh/cd.c
diff -u src/bin/sh/cd.c:1.39 src/bin/sh/cd.c:1.39.32.1
--- src/bin/sh/cd.c:1.39	Thu May  4 11:16:53 2006
+++ src/bin/sh/cd.c	Wed Apr 21 05:15:28 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd.c,v 1.39 2006/05/04 11:16:53 simonb Exp $	*/
+/*	$NetBSD: cd.c,v 1.39.32.1 2010/04/21 05:15:28 matt Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)cd.c	8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: cd.c,v 1.39 2006/05/04 11:16:53 simonb Exp $");
+__RCSID("$NetBSD: cd.c,v 1.39.32.1 2010/04/21 05:15:28 matt Exp $");
 #endif
 #endif /* not lint */
 
@@ -84,7 +84,8 @@
 	struct stat statb;
 	int print = cdprint;	/* set -cdprint to enable */
 
-	nextopt(nullstr);
+	while (nextopt("P") != '\0')
+		;
 
 	/*
 	 * Try (quite hard) to have 'curdir' defined, nothing has set

Index: src/bin/sh/sh.1
diff -u src/bin/sh/sh.1:1.87.18.1 src/bin/sh/sh.1:1.87.18.1.4.1
--- src/bin/sh/sh.1:1.87.18.1	Wed Apr  1 00:25:21 2009
+++ src/bin/sh/sh.1	Wed Apr 21 05:15:28 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sh.1,v 1.87.18.1 2009/04/01 00:25:21 snj Exp $
+.\"	$NetBSD: sh.1,v 1.87.18.1.4.1 2010/04/21 05:15:28 matt Exp $
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -31,7 +31,7 @@
 .\"
 .\"	@(#)sh.1	8.6 (Berkeley) 5/4/95
 .\"
-.Dd June 24, 2007
+.Dd January 1, 2010
 .Os
 .Dt SH 1
 .Sh NAME
@@ -1225,7 +1225,7 @@
 search for the command and print the absolute pathname
 of utilities, the name for built-ins or the expansion of aliases.
 .El
-.It cd Op Ar directory Op Ar replace
+.It cd Oo Fl P Oc Op Ar directory Op Ar replace
 Switch to the specified directory (default
 .Ev $HOME ) .
 If
@@ -1251,6 +1251,21 @@
 is the same as that of
 .Ev PATH .
 .Pp
+The
+.Fl P
+option instructs the shell to update
+.Ev PWD
+with the specified directory and change to that directory.
+This is the default.
+.Pp
+Some shells also support a
+.Fl L
+option, which instructs the shell to update
+.Ev PWD
+with incorrect information and to change the current directory
+accordingly.
+This is not supported.
+.Pp
 In an interactive shell, the
 .Ic cd
 command will print out the name of the
@@ -1538,11 +1553,9 @@
 .Fl L ,
 but note that the built-in
 .Ic cd
-command doesn't currently support
+command doesn't currently support the
 .Fl L
-or
-.Fl P
-and will cache (almost) the absolute path.
+option and will cache (almost) the absolute path.
 If
 .Ic cd
 is changed,

Reply via email to