PERFORCE change 40232 for review

Robert Watson rwatson at FreeBSD.org
Thu Oct 23 02:15:06 GMT 2003


http://perforce.freebsd.org/chv.cgi?CH=40232

Change 40232 by rwatson at rwatson_paprika on 2003/10/22 19:14:30

	Integrate trustedbsd_sebsd bin tree forward to 39070, the last
	major integration of the trustedbsd_mac branch, which brings in
	many of the major changes in the last four months to the main
	FreeBSD tree.  This includes substantial lock pushdown, threading
	bug fixes, compiler upgrades, et al.  The bin directory includes
	only relatively few changes, such as sh grammer improvements.

Affected files ...

.. //depot/projects/trustedbsd/sebsd/bin/Makefile.inc#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/df/df.c#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/ls/ls.1#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/ls/util.c#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/ps/extern.h#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/ps/keyword.c#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/ps/print.c#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/ps/ps.1#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/setfacl/setfacl.1#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/setfacl/setfacl.c#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/sh/arith.h#2 integrate
.. //depot/projects/trustedbsd/sebsd/bin/sh/arith.y#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/sh/arith_lex.l#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/sh/mkbuiltins#2 integrate
.. //depot/projects/trustedbsd/sebsd/bin/sh/sh.1#4 integrate
.. //depot/projects/trustedbsd/sebsd/bin/sh/shell.h#2 integrate
.. //depot/projects/trustedbsd/sebsd/bin/test/Makefile#2 integrate

Differences ...

==== //depot/projects/trustedbsd/sebsd/bin/Makefile.inc#4 (text+ko) ====

@@ -1,6 +1,9 @@
 #	@(#)Makefile.inc	8.1 (Berkeley) 5/31/93
-# $FreeBSD: src/bin/Makefile.inc,v 1.16 2003/06/13 07:04:01 markm Exp $
+# $FreeBSD: src/bin/Makefile.inc,v 1.17 2003/08/17 08:37:47 gordon Exp $
 
 BINDIR?=	/bin
+WARNS?=		6
+
+.if !defined (WITH_DYNAMICROOT)
 NOSHARED?=	YES
-WARNS?=		6
+.endif

==== //depot/projects/trustedbsd/sebsd/bin/df/df.c#4 (text+ko) ====

@@ -48,7 +48,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/df/df.c,v 1.50 2003/06/03 11:54:42 bde Exp $");
+__FBSDID("$FreeBSD: src/bin/df/df.c,v 1.51 2003/09/13 20:46:58 obrien Exp $");
 
 #include <sys/param.h>
 #include <sys/stat.h>
@@ -122,10 +122,10 @@
 static char	 *getmntpt(const char *);
 static size_t	  longwidth(long);
 static char	 *makenetvfslist(void);
-static void	  prthuman(const struct statfs *, long);
+static void	  prthuman(const struct statfs *, size_t);
 static void	  prthumanval(double);
 static void	  prtstat(struct statfs *, struct maxwidths *);
-static long	  regetmntinfo(struct statfs **, long, const char **);
+static size_t	  regetmntinfo(struct statfs **, long, const char **);
 static unit_t	  unit_adjust(double *);
 static void	  update_maxwidths(struct maxwidths *, const struct statfs *);
 static void	  usage(void);
@@ -148,8 +148,8 @@
 	const char *fstype;
 	char *mntpath, *mntpt;
 	const char **vfslist;
-	long mntsize;
-	int ch, i, rv;
+	size_t i, mntsize;
+	int ch, rv;
 
 	fstype = "ufs";
 
@@ -305,7 +305,7 @@
 static char *
 getmntpt(const char *name)
 {
-	long mntsize, i;
+	size_t mntsize, i;
 	struct statfs *mntbuf;
 
 	mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
@@ -321,7 +321,7 @@
  * file system types not in vfslist and possibly re-stating to get
  * current (not cached) info.  Returns the new count of valid statfs bufs.
  */
-static long
+static size_t
 regetmntinfo(struct statfs **mntbufp, long mntsize, const char **vfslist)
 {
 	int i, j;
@@ -371,7 +371,7 @@
 }
 
 static void
-prthuman(const struct statfs *sfsp, long used)
+prthuman(const struct statfs *sfsp, size_t used)
 {
 
 	prthumanval((double)sfsp->f_blocks * (double)sfsp->f_bsize);
@@ -411,7 +411,7 @@
 	static long blocksize;
 	static int headerlen, timesthrough = 0;
 	static const char *header;
-	long used, availblks, inodes;
+	size_t used, availblks, inodes;
 
 	if (++timesthrough == 1) {
 		mwp->mntfrom = max(mwp->mntfrom, strlen("Filesystem"));
@@ -456,8 +456,8 @@
 	if (iflag) {
 		inodes = sfsp->f_files;
 		used = inodes - sfsp->f_ffree;
-		(void)printf(" %*ld %*ld %4.0f%% ",
-		    (u_int)mwp->iused, used,
+		(void)printf(" %*lu %*lu %4.0f%% ",
+		    (u_int)mwp->iused, (u_long)used,
 		    (u_int)mwp->ifree, sfsp->f_ffree,
 		    inodes == 0 ? 100.0 : (double)used / (double)inodes * 100.0);
 	} else

==== //depot/projects/trustedbsd/sebsd/bin/ls/ls.1#4 (text+ko) ====

@@ -33,7 +33,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)ls.1	8.7 (Berkeley) 7/29/94
-.\" $FreeBSD: src/bin/ls/ls.1,v 1.75 2003/07/10 20:53:56 brueffer Exp $
+.\" $FreeBSD: src/bin/ls/ls.1,v 1.76 2003/08/08 17:04:17 schweikh Exp $
 .\"
 .Dd May 19, 2002
 .Dt LS 1
@@ -645,7 +645,12 @@
 .Xr getfmac 8 ,
 .Xr sticky 8
 .Sh STANDARDS
-The
+With the exception of options
+.Fl g ,
+.Fl n
+and
+.Fl o ,
+the
 .Nm
 utility conforms to
 .St -p1003.1-2001 .

==== //depot/projects/trustedbsd/sebsd/bin/ls/util.c#4 (text+ko) ====

@@ -40,7 +40,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/ls/util.c,v 1.31 2003/05/03 16:39:33 markm Exp $");
+__FBSDID("$FreeBSD: src/bin/ls/util.c,v 1.32 2003/09/09 12:02:52 tjr Exp $");
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -156,9 +156,9 @@
 {
 	(void)fprintf(stderr,
 #ifdef COLORLS
-	"usage: ls [-ABCFGHLPRTWZabcdfghiklnoqrstu1]"
+	"usage: ls [-ABCFGHLPRTWZabcdfghiklmnoqrstuwx1]"
 #else
-	"usage: ls [-ABCFHLPRTWZabcdfghiklnoqrstu1]"
+	"usage: ls [-ABCFHLPRTWZabcdfghiklmnoqrstuwx1]"
 #endif
 		      " [file ...]\n");
 	exit(1);

==== //depot/projects/trustedbsd/sebsd/bin/ps/extern.h#4 (text+ko) ====

@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)extern.h	8.3 (Berkeley) 4/2/94
- * $FreeBSD: src/bin/ps/extern.h,v 1.30 2003/01/19 00:22:34 jmallett Exp $
+ * $FreeBSD: src/bin/ps/extern.h,v 1.31 2003/08/13 07:35:07 harti Exp $
  */
 
 struct kinfo;
@@ -63,6 +63,7 @@
 void	 maxrss(KINFO *, VARENT *);
 void	 lockname(KINFO *, VARENT *);
 void	 mwchan(KINFO *, VARENT *);
+void	 nwchan(KINFO *, VARENT *);
 void	 pagein(KINFO *, VARENT *);
 void	 parsefmt(const char *, int);
 void	 pcpu(KINFO *, VARENT *);

==== //depot/projects/trustedbsd/sebsd/bin/ps/keyword.c#4 (text+ko) ====

@@ -37,7 +37,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/ps/keyword.c,v 1.63 2003/04/12 10:39:56 tjr Exp $");
+__FBSDID("$FreeBSD: src/bin/ps/keyword.c,v 1.64 2003/08/13 07:35:07 harti Exp $");
 
 #include <sys/param.h>
 #include <sys/time.h>
@@ -127,6 +127,7 @@
 		LONG, "ld", 0},
 	{"nvcsw", "NVCSW", NULL, USER, rvar, NULL, 5, ROFF(ru_nvcsw),
 		LONG, "ld", 0},
+	{"nwchan", "NWCHAN", NULL, LJUST, nwchan, NULL, 8, 0, CHAR, NULL, 0},
 	{"oublk", "OUBLK", NULL, USER, rvar, NULL, 4, ROFF(ru_oublock),
 		LONG, "ld", 0},
 	{"oublock", "", "oublk", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},

==== //depot/projects/trustedbsd/sebsd/bin/ps/print.c#4 (text+ko) ====

@@ -38,7 +38,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/ps/print.c,v 1.82 2003/04/15 18:49:20 charnier Exp $");
+__FBSDID("$FreeBSD: src/bin/ps/print.c,v 1.83 2003/08/13 07:35:07 harti Exp $");
 
 #include <sys/param.h>
 #include <sys/time.h>
@@ -457,6 +457,19 @@
 }
 
 void
+nwchan(KINFO *k, VARENT *ve)
+{
+	VAR *v;
+
+	v = ve->var;
+	if (k->ki_p->ki_wchan) {
+		(void)printf("%0*lx", v->width,
+		    (long)k->ki_p->ki_wchan);
+	} else
+		(void)printf("%-*s", v->width, "-");
+}
+
+void
 mwchan(KINFO *k, VARENT *ve)
 {
 	VAR *v;

==== //depot/projects/trustedbsd/sebsd/bin/ps/ps.1#4 (text+ko) ====

@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)ps.1	8.3 (Berkeley) 4/18/94
-.\" $FreeBSD: src/bin/ps/ps.1,v 1.64 2003/08/05 10:31:28 brueffer Exp $
+.\" $FreeBSD: src/bin/ps/ps.1,v 1.65 2003/09/08 19:57:13 ru Exp $
 .\"
 .Dd April 18, 1994
 .Dt PS 1
@@ -210,7 +210,7 @@
 .It flags
 The flags associated with the process as in
 the include file
-.Aq Pa sys/proc.h :
+.In sys/proc.h :
 .Bl -column P_NOCLDSTOP P_NOCLDSTOP
 .It Dv "P_ADVLOCK" Ta No "0x00001	Process may hold a POSIX advisory lock"
 .It Dv "P_CONTROLT" Ta No "0x00002	Has a controlling terminal"

==== //depot/projects/trustedbsd/sebsd/bin/setfacl/setfacl.1#4 (text+ko) ====

@@ -23,7 +23,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/bin/setfacl/setfacl.1,v 1.8 2002/12/30 15:36:29 rwatson Exp $
+.\" $FreeBSD: src/bin/setfacl/setfacl.1,v 1.9 2003/08/07 14:52:17 rwatson Exp $
 .\"
 .Dd January 7, 2001
 .Dt SETFACL 1
@@ -185,6 +185,24 @@
 .Dq Li group
 ACL entries in the resulting ACL.
 .Pp
+Traditional POSIX interfaces acting on file system object modes have
+modified semantics in the presence of POSIX.1e extended ACLs.
+When a mask entry is present on the access ACL of an object, the mask
+entry is substituted for the group bits; this occurs in programs such
+as
+.Xr stat 1
+or
+.Xr ls 1 .
+When the mode is modified on an object that has a mask entry, the
+changes applied to the group bits will actually be applied to the
+mask entry.
+These semantics provide for greater application compatibility:
+applications modifying the mode instead of the ACL will see
+conservative behavior, limiting the effective rights granted by all
+of the additional user and group entries; this occurs in programs
+such as
+.Xr chmod 1 .
+.Pp
 ACL entries applied from a file using the
 .Fl M
 or

==== //depot/projects/trustedbsd/sebsd/bin/setfacl/setfacl.c#4 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/setfacl/setfacl.c,v 1.8 2003/07/18 16:00:26 rwatson Exp $");
+__FBSDID("$FreeBSD: src/bin/setfacl/setfacl.c,v 1.9 2003/08/07 14:43:43 rwatson Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -96,7 +96,7 @@
 usage(void)
 {
 
-	fprintf(stderr, "usage: setfacl [-bdhknv] [-m entries] [-M file1] "
+	fprintf(stderr, "usage: setfacl [-bdhkn] [-m entries] [-M file1] "
 	    "[-x entries] [-X file2] [file ...]\n");
 	exit(1);
 }

==== //depot/projects/trustedbsd/sebsd/bin/sh/arith.h#2 (text+ko) ====

@@ -31,8 +31,9 @@
  * SUCH DAMAGE.
  *
  *	@(#)arith.h	1.1 (Berkeley) 5/4/95
- * $FreeBSD: src/bin/sh/arith.h,v 1.6 2002/02/02 06:50:45 imp Exp $
+ * $FreeBSD: src/bin/sh/arith.h,v 1.8 2003/09/04 18:28:42 schweikh Exp $
  */
 
 int arith(char *);
-int expcmd(int , char **);
+int arith_assign(char *, arith_t);
+int expcmd(int, char **);

==== //depot/projects/trustedbsd/sebsd/bin/sh/arith.y#4 (text+ko) ====

@@ -1,58 +1,4 @@
-%token ARITH_NUM ARITH_LPAREN ARITH_RPAREN
-
-%left ARITH_OR
-%left ARITH_AND
-%left ARITH_BOR
-%left ARITH_BXOR
-%left ARITH_BAND
-%left ARITH_EQ ARITH_NE
-%left ARITH_LT ARITH_GT ARITH_GE ARITH_LE
-%left ARITH_LSHIFT ARITH_RSHIFT
-%left ARITH_ADD ARITH_SUB
-%left ARITH_MUL ARITH_DIV ARITH_REM
-%left ARITH_UNARYMINUS ARITH_UNARYPLUS ARITH_NOT ARITH_BNOT
-%%
-
-exp:	expr = {
-			return ($1);
-		}
-	;
-
-
-expr:	ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; }
-	| expr ARITH_OR expr	= { $$ = $1 ? $1 : $3 ? $3 : 0; }
-	| expr ARITH_AND expr	= { $$ = $1 ? ( $3 ? $3 : 0 ) : 0; }
-	| expr ARITH_BOR expr	= { $$ = $1 | $3; }
-	| expr ARITH_BXOR expr	= { $$ = $1 ^ $3; }
-	| expr ARITH_BAND expr	= { $$ = $1 & $3; }
-	| expr ARITH_EQ expr	= { $$ = $1 == $3; }
-	| expr ARITH_GT expr	= { $$ = $1 > $3; }
-	| expr ARITH_GE expr	= { $$ = $1 >= $3; }
-	| expr ARITH_LT expr	= { $$ = $1 < $3; }
-	| expr ARITH_LE expr	= { $$ = $1 <= $3; }
-	| expr ARITH_NE expr	= { $$ = $1 != $3; }
-	| expr ARITH_LSHIFT expr = { $$ = $1 << $3; }
-	| expr ARITH_RSHIFT expr = { $$ = $1 >> $3; }
-	| expr ARITH_ADD expr	= { $$ = $1 + $3; }
-	| expr ARITH_SUB expr	= { $$ = $1 - $3; }
-	| expr ARITH_MUL expr	= { $$ = $1 * $3; }
-	| expr ARITH_DIV expr	= {
-			if ($3 == 0)
-				yyerror("division by zero");
-			$$ = $1 / $3;
-			}
-	| expr ARITH_REM expr   = {
-			if ($3 == 0)
-				yyerror("division by zero");
-			$$ = $1 % $3;
-			}
-	| ARITH_NOT expr	= { $$ = !($2); }
-	| ARITH_BNOT expr	= { $$ = ~($2); }
-	| ARITH_SUB expr %prec ARITH_UNARYMINUS = { $$ = -($2); }
-	| ARITH_ADD expr %prec ARITH_UNARYPLUS = { $$ = $2; }
-	| ARITH_NUM
-	;
-%%
+%{
 /*-
  * Copyright (c) 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -89,19 +35,233 @@
  * SUCH DAMAGE.
  */
 
+#if 0
 #ifndef lint
-#if 0
 static char sccsid[] = "@(#)arith.y	8.3 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
+
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/sh/arith.y,v 1.14 2003/05/01 16:58:56 obrien Exp $");
+__FBSDID("$FreeBSD: src/bin/sh/arith.y,v 1.17 2003/09/07 10:14:56 schweikh Exp $");
 
+#include <limits.h>
 #include "shell.h"
+#include "var.h"
+%}
+%union {
+	arith_t l_value;
+	char* s_value;
+}
+%token <l_value> ARITH_NUM ARITH_LPAREN ARITH_RPAREN
+%token <s_value> ARITH_VAR
+
+%type <l_value>	expr
+%right ARITH_ASSIGN
+%right ARITH_ADDASSIGN ARITH_SUBASSIGN
+%right ARITH_MULASSIGN ARITH_DIVASSIGN ARITH_REMASSIGN
+%right ARITH_RSHASSIGN ARITH_LSHASSIGN
+%right ARITH_BANDASSIGN ARITH_BXORASSIGN ARITH_BORASSIGN
+%left ARITH_OR
+%left ARITH_AND
+%left ARITH_BOR
+%left ARITH_BXOR
+%left ARITH_BAND
+%left ARITH_EQ ARITH_NE
+%left ARITH_LT ARITH_GT ARITH_GE ARITH_LE
+%left ARITH_LSHIFT ARITH_RSHIFT
+%left ARITH_ADD ARITH_SUB
+%left ARITH_MUL ARITH_DIV ARITH_REM
+%left ARITH_UNARYMINUS ARITH_UNARYPLUS ARITH_NOT ARITH_BNOT
+%%
+
+exp:
+	expr
+		{ return ($1); }
+	;
+
+expr:
+	ARITH_LPAREN expr ARITH_RPAREN
+		{ $$ = $2; } |
+	expr ARITH_OR expr
+		{ $$ = $1 ? $1 : $3 ? $3 : 0; } |
+	expr ARITH_AND expr
+		{ $$ = $1 ? ( $3 ? $3 : 0 ) : 0; } |
+	expr ARITH_BOR expr
+		{ $$ = $1 | $3; } |
+	expr ARITH_BXOR expr
+		{ $$ = $1 ^ $3; } |
+	expr ARITH_BAND expr
+		{ $$ = $1 & $3; } |
+	expr ARITH_EQ expr
+		{ $$ = $1 == $3; } |
+	expr ARITH_GT expr
+		{ $$ = $1 > $3; } |
+	expr ARITH_GE expr
+		{ $$ = $1 >= $3; } |
+	expr ARITH_LT expr
+		{ $$ = $1 < $3; } |
+	expr ARITH_LE expr
+		{ $$ = $1 <= $3; } |
+	expr ARITH_NE expr
+		{ $$ = $1 != $3; } |
+	expr ARITH_LSHIFT expr
+		{ $$ = $1 << $3; } |
+	expr ARITH_RSHIFT expr
+		{ $$ = $1 >> $3; } |
+	expr ARITH_ADD expr
+		{ $$ = $1 + $3; } |
+	expr ARITH_SUB expr
+		{ $$ = $1 - $3; } |
+	expr ARITH_MUL expr
+		{ $$ = $1 * $3; } |
+	expr ARITH_DIV expr
+		{
+		if ($3 == 0)
+			yyerror("division by zero");
+		$$ = $1 / $3;
+		} |
+	expr ARITH_REM expr
+		{
+		if ($3 == 0)
+			yyerror("division by zero");
+		$$ = $1 % $3;
+		} |
+	ARITH_NOT expr
+		{ $$ = !($2); } |
+	ARITH_BNOT expr
+		{ $$ = ~($2); } |
+	ARITH_SUB expr %prec ARITH_UNARYMINUS
+		{ $$ = -($2); } |
+	ARITH_ADD expr %prec ARITH_UNARYPLUS
+		{ $$ = $2; } |
+	ARITH_NUM |
+	ARITH_VAR
+		{
+		char *p;
+		arith_t arith_val;
+		char *str_val;
+
+		if (lookupvar($1) == NULL)
+			setvarsafe($1, "0", 0);
+		str_val = lookupvar($1);
+		arith_val = strtoarith_t(str_val, &p, 0);
+		/*
+		 * Conversion is successful only in case
+		 * we've converted _all_ characters.
+		 */
+		if (*p != '\0')
+			yyerror("variable conversion error");
+		$$ = arith_val;
+		} |
+	ARITH_VAR ARITH_ASSIGN expr
+		{
+		if (arith_assign($1, $3) != 0)
+			yyerror("variable assignment error");
+		$$ = $3;
+		} |
+	ARITH_VAR ARITH_ADDASSIGN expr
+		{
+		arith_t value;
+
+		value = atoarith_t(lookupvar($1)) + $3;
+		if (arith_assign($1, value) != 0)
+			yyerror("variable assignment error");
+		$$ = value;
+		} |
+	ARITH_VAR ARITH_SUBASSIGN expr
+		{
+		arith_t value;
+
+		value = atoarith_t(lookupvar($1)) - $3;
+		if (arith_assign($1, value) != 0)
+			yyerror("variable assignment error");
+		$$ = value;
+		} |
+	ARITH_VAR ARITH_MULASSIGN expr
+		{
+		arith_t value;
+
+		value = atoarith_t(lookupvar($1)) * $3;
+		if (arith_assign($1, value) != 0)
+			yyerror("variable assignment error");
+		$$ = value;
+		} |
+	ARITH_VAR ARITH_DIVASSIGN expr
+		{
+		arith_t value;
+
+		if ($3 == 0)
+			yyerror("division by zero");
+
+		value = atoarith_t(lookupvar($1)) / $3;
+		if (arith_assign($1, value) != 0)
+			yyerror("variable assignment error");
+		$$ = value;
+		} |
+	ARITH_VAR ARITH_REMASSIGN expr
+		{
+		arith_t value;
+
+		if ($3 == 0)
+			yyerror("division by zero");
+
+		value = atoarith_t(lookupvar($1)) % $3;
+		if (arith_assign($1, value) != 0)
+			yyerror("variable assignment error");
+		$$ = value;
+		} |
+	ARITH_VAR ARITH_RSHASSIGN expr
+		{
+		arith_t value;
+
+		value = atoarith_t(lookupvar($1)) >> $3;
+		if (arith_assign($1, value) != 0)
+			yyerror("variable assignment error");
+		$$ = value;
+		} |
+	ARITH_VAR ARITH_LSHASSIGN expr
+		{
+		arith_t value;
+
+		value = atoarith_t(lookupvar($1)) << $3;
+		if (arith_assign($1, value) != 0)
+			yyerror("variable assignment error");
+		$$ = value;
+		} |
+	ARITH_VAR ARITH_BANDASSIGN expr
+		{
+		arith_t value;
+
+		value = atoarith_t(lookupvar($1)) & $3;
+		if (arith_assign($1, value) != 0)
+			yyerror("variable assignment error");
+		$$ = value;
+		} |
+	ARITH_VAR ARITH_BXORASSIGN expr
+		{
+		arith_t value;
+
+		value = atoarith_t(lookupvar($1)) ^ $3;
+		if (arith_assign($1, value) != 0)
+			yyerror("variable assignment error");
+		$$ = value;
+		} |
+	ARITH_VAR ARITH_BORASSIGN expr
+		{
+		arith_t value;
+
+		value = atoarith_t(lookupvar($1)) | $3;
+		if (arith_assign($1, value) != 0)
+			yyerror("variable assignment error");
+		$$ = value;
+		} ;
+%%
 #include "error.h"
 #include "output.h"
 #include "memalloc.h"
 
+#define lstrlen(var) (3 + (2 + CHAR_BIT * sizeof((var))) / 3)
+
 char *arith_buf, *arith_startbuf;
 extern void arith_lex_reset();
 
@@ -109,6 +269,19 @@
 int yyparse(void);
 
 int
+arith_assign(char *name, arith_t value)
+{
+	char *str;
+	int ret;
+
+	str = (char *)ckmalloc(lstrlen(value));
+	sprintf(str, ARITH_FORMAT_STR, value);
+	ret = setvarsafe(name, str, 0);
+	free(str);
+	return ret;
+}
+
+int
 arith(char *s)
 {
 	long result;
@@ -117,10 +290,10 @@
 
 	INTOFF;
 	result = yyparse();
-	arith_lex_reset();	/* reprime lex */
+	arith_lex_reset();	/* Reprime lex. */
 	INTON;
 
-	return (result);
+	return result;
 }
 
 void
@@ -129,7 +302,7 @@
 
 	yyerrok;
 	yyclearin;
-	arith_lex_reset();	/* reprime lex */
+	arith_lex_reset();	/* Reprime lex. */
 	error("arithmetic expression: %s: \"%s\"", s, arith_startbuf);
 }
 
@@ -148,7 +321,7 @@
 		p = argv[1];
 		if (argc > 2) {
 			/*
-			 * concatenate arguments
+			 * Concatenate arguments.
 			 */
 			STARTSTACKSTR(concat);
 			ap = argv + 2;
@@ -168,7 +341,7 @@
 	i = arith(p);
 
 	out1fmt("%ld\n", i);
-	return (! i);
+	return !i;
 }
 
 /*************************/

==== //depot/projects/trustedbsd/sebsd/bin/sh/arith_lex.l#4 (text+ko) ====

@@ -35,18 +35,23 @@
  * SUCH DAMAGE.
  */
 
+#if 0
 #ifndef lint
-#if 0
 static char sccsid[] = "@(#)arith_lex.l	8.3 (Berkeley) 5/4/95";
 #endif
 #endif /* not lint */
+
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/sh/arith_lex.l,v 1.18 2003/05/01 16:58:56 obrien Exp $");
+__FBSDID("$FreeBSD: src/bin/sh/arith_lex.l,v 1.21 2003/09/06 16:33:55 tjr Exp $");
+
+#include <string.h>
 
+#include "shell.h"
 #include "y.tab.h"
 #include "error.h"
+#include "memalloc.h"
+#include "var.h"
 
-extern int yylval;
 extern char *arith_buf, *arith_startbuf;
 #undef YY_INPUT
 #define YY_INPUT(buf,result,max) \
@@ -56,34 +61,76 @@
 
 %%
 [ \t\n]	{ ; }
-[0-9]+	{ yylval = atol(yytext); return(ARITH_NUM); }
-"("	{ return(ARITH_LPAREN); }
-")"	{ return(ARITH_RPAREN); }
-"||"	{ return(ARITH_OR); }
-"&&"	{ return(ARITH_AND); }
-"|"	{ return(ARITH_BOR); }
-"^"	{ return(ARITH_BXOR); }
-"&"	{ return(ARITH_BAND); }
-"=="	{ return(ARITH_EQ); }
-"!="	{ return(ARITH_NE); }
-">"	{ return(ARITH_GT); }
-">="	{ return(ARITH_GE); }
-"<"	{ return(ARITH_LT); }
-"<="	{ return(ARITH_LE); }
-"<<"	{ return(ARITH_LSHIFT); }
-">>"	{ return(ARITH_RSHIFT); }
-"*"	{ return(ARITH_MUL); }
-"/"	{ return(ARITH_DIV); }
-"%"	{ return(ARITH_REM); }
-"+"	{ return(ARITH_ADD); }
-"-"	{ return(ARITH_SUB); }
-"~"	{ return(ARITH_BNOT); }
-"!"	{ return(ARITH_NOT); }
-.	{ error("arith: syntax error: \"%s\"\n", arith_startbuf); }
+
+0x[a-fA-F0-9]+	{
+			yylval.l_value = strtoarith_t(yytext, NULL, 16);
+			return ARITH_NUM;
+		}
+
+0[0-7]+		{
+			yylval.l_value = strtoarith_t(yytext, NULL, 8);
+			return ARITH_NUM;
+		}
+
+[0-9]+		{
+			yylval.l_value = strtoarith_t(yytext, NULL, 10);
+			return ARITH_NUM;
+		}
+
+[A-Za-z][A-Za-z0-9_]*	{
+			/*
+			 * If variable doesn't exist, we should initialize
+			 * it to zero.
+			 */
+			char *temp;
+			if (lookupvar(yytext) == NULL)
+				setvarsafe(yytext, "0", 0);
+			temp = (char *)ckmalloc(strlen(yytext) + 1);
+			yylval.s_value = strcpy(temp, yytext);
+
+			return ARITH_VAR;
+		}
+
+"("		{	return ARITH_LPAREN;	}
+")"		{	return ARITH_RPAREN;	}
+"||"		{	return ARITH_OR;	}
+"&&"		{	return ARITH_AND;	}
+"|"		{	return ARITH_BOR;	}
+"^"		{	return ARITH_BXOR;	}
+"&"		{	return ARITH_BAND;	}
+"=="		{	return ARITH_EQ;	}
+"!="		{	return ARITH_NE;	}
+">"		{	return ARITH_GT;	}
+">="		{	return ARITH_GE;	}
+"<"		{	return ARITH_LT;	}
+"<="		{	return ARITH_LE;	}
+"<<"		{	return ARITH_LSHIFT;	}
+">>"		{	return ARITH_RSHIFT;	}
+"*"		{	return ARITH_MUL;	}
+"/"		{	return ARITH_DIV;	}
+"%"		{	return ARITH_REM;	}
+"+"		{	return ARITH_ADD;	}
+"-"		{	return ARITH_SUB;	}
+"~"		{	return ARITH_BNOT;	}
+"!"		{	return ARITH_NOT;	}
+"="		{	return ARITH_ASSIGN;	}
+"+="		{	return ARITH_ADDASSIGN;	}
+"-="		{	return ARITH_SUBASSIGN;	}
+"*="		{	return ARITH_MULASSIGN;	}
+"/="		{	return ARITH_DIVASSIGN;	}
+"%="		{	return ARITH_REMASSIGN;	}
+">>="		{	return ARITH_RSHASSIGN;	}
+"<<="		{	return ARITH_LSHASSIGN;	}
+"&="		{	return ARITH_BANDASSIGN; }
+"^="		{	return ARITH_BXORASSIGN; }
+"|="		{	return ARITH_BORASSIGN;	}
+.		{
+			error("arith: syntax error: \"%s\"\n", arith_startbuf);
+		}
 %%
 
 void
-arith_lex_reset()
+arith_lex_reset(void)
 {
 	YY_NEW_FILE;
 }

==== //depot/projects/trustedbsd/sebsd/bin/sh/mkbuiltins#2 (text+ko) ====

@@ -35,11 +35,11 @@
 # SUCH DAMAGE.
 #
 #	@(#)mkbuiltins	8.2 (Berkeley) 5/4/95
-# $FreeBSD: src/bin/sh/mkbuiltins,v 1.11 2002/10/18 10:33:32 tjr Exp $
+# $FreeBSD: src/bin/sh/mkbuiltins,v 1.12 2003/09/13 06:59:22 schweikh Exp $
 
 temp=`/usr/bin/mktemp -t ka`
 havejobs=0
-if grep '^#define JOBS[	 ]*1' shell.h > /dev/null
+if grep '^#define[	 ]*JOBS[	 ]*1' shell.h > /dev/null
 then	havejobs=1
 fi
 havehist=1

==== //depot/projects/trustedbsd/sebsd/bin/sh/sh.1#4 (text+ko) ====

@@ -33,7 +33,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	from: @(#)sh.1	8.6 (Berkeley) 5/4/95
-.\" $FreeBSD: src/bin/sh/sh.1,v 1.87 2003/05/16 21:19:32 ru Exp $
+.\" $FreeBSD: src/bin/sh/sh.1,v 1.88 2003/09/08 19:57:13 ru Exp $
 .\"
 .Dd April 12, 2003
 .Dt SH 1
@@ -583,7 +583,7 @@
 .Pp
 If a command is terminated by a signal, its exit status is 128 plus
 the signal number.  Signal numbers are defined in the header file
-.Aq Pa sys/signal.h .
+.In sys/signal.h .
 .Ss Complex Commands
 Complex commands are combinations of simple commands
 with control operators or reserved words, together creating a larger complex

==== //depot/projects/trustedbsd/sebsd/bin/sh/shell.h#2 (text+ko) ====

@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)shell.h	8.2 (Berkeley) 5/4/95
- * $FreeBSD: src/bin/sh/shell.h,v 1.14 2002/07/19 08:09:04 tjr Exp $
+ * $FreeBSD: src/bin/sh/shell.h,v 1.16 2003/09/04 18:28:42 schweikh Exp $
  */
 
 /*
@@ -48,20 +48,27 @@
  */
 
 
-#define JOBS 1
+#define	JOBS 1
 /* #define DEBUG 1 */
 
+/*
+ * Type of used arithmetics. SUSv3 requires us to have at least signed long.
+ */
+typedef long arith_t;
+#define	ARITH_FORMAT_STR  "%ld"
+#define	atoarith_t(arg)  strtol(arg, NULL, 0)
+#define	strtoarith_t(nptr, endptr, base)  strtol(nptr, endptr, base)
+
 typedef void *pointer;
 #define STATIC  static
-#define MKINIT	/* empty */
+#define MKINIT  /* empty */
 
 #include <sys/cdefs.h>
 
 extern char nullstr[1];		/* null string */
 
-
 #ifdef DEBUG
-#define TRACE(param)	sh_trace param
+#define TRACE(param)  sh_trace param
 #else
 #define TRACE(param)
 #endif

==== //depot/projects/trustedbsd/sebsd/bin/test/Makefile#2 (text+ko) ====

@@ -1,8 +1,8 @@
 #        @(#)Makefile	8.1 (Berkeley) 5/31/93
-# $FreeBSD: src/bin/test/Makefile,v 1.9 2001/12/04 01:57:47 obrien Exp $
+# $FreeBSD: src/bin/test/Makefile,v 1.10 2003/09/07 12:52:17 ru Exp $
 
 PROG=	test
 LINKS=	${BINDIR}/test ${BINDIR}/[
-MLINKS=	test.1 '[.1'
+MLINKS=	test.1 [.1
 
 .include <bsd.prog.mk>
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list