From owner-freebsd-standards@FreeBSD.ORG Mon Aug 18 11:02:12 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7B8D037B401 for ; Mon, 18 Aug 2003 11:02:12 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id EC36F43F85 for ; Mon, 18 Aug 2003 11:02:11 -0700 (PDT) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (peter@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h7II2BUp068831 for ; Mon, 18 Aug 2003 11:02:11 -0700 (PDT) (envelope-from owner-bugmaster@freebsd.org) Received: (from peter@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h7II2BD6068816 for freebsd-standards@freebsd.org; Mon, 18 Aug 2003 11:02:11 -0700 (PDT) Date: Mon, 18 Aug 2003 11:02:11 -0700 (PDT) Message-Id: <200308181802.h7II2BD6068816@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: peter set sender to owner-bugmaster@freebsd.org using -f From: FreeBSD bugmaster To: freebsd-standards@FreeBSD.org Subject: Current problem reports assigned to you X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2003 18:02:12 -0000 Current FreeBSD problem reports Critical problems Serious problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2002/02/25] bin/35307 standards standard include files are not standard c o [2003/03/05] bin/48958 standards The type 'bool' has different sizes for C s [2001/01/23] misc/24590 standards timezone function not compatible witn Sin o [2003/04/21] standards/51209standards [PATCH] add a64l()/l64a/l64a_r functions o [2003/06/05] standards/52972standards /bin/sh arithmetic not POSIX compliant o [2003/06/20] standards/53554standards interval timers not cleared in fork() o [2003/07/12] standards/54410standards one-true-awk not POSIX compliant (no exte 7 problems total. Non-critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2001/01/16] bin/24390 standards Replacing old dir-symlinks when using /bi o [2003/06/24] bin/53682 standards [PATCH] add fuser(1) utitity o [2002/07/09] misc/40378 standards stdlib.h gives needless warnings with -an s [2002/03/18] standards/36076standards Implementation of POSIX fuser command o [2002/06/13] standards/39256standards [v]snprintf aren't POSIX-conformant for s p [2002/07/16] standards/40669standards command command does not support `-p' opt o [2001/11/20] standards/32126standards getopt(3) not Unix-98 conformant p [2002/08/12] standards/41576standards POSIX compliance of ln(1) o [2002/10/23] standards/44425standards getcwd() succeeds even if current dir has o [2002/12/09] standards/46119standards Priority problems for SCHED_OTHER using p o [2002/12/23] standards/46504standards Warnings in headers o [2003/04/22] standards/51292standards [PATCH] add ecvt()/fcvt()/gcvt() function o [2003/06/22] standards/53613standards FreeBSD doesn't define EPROTO o [2003/07/24] standards/54809standards pcvt deficits o [2003/07/24] standards/54833standards more pcvt deficits o [2003/07/25] standards/54839standards pcvt deficits o [2003/07/31] standards/55112standards glob.h, glob_t's gl_pathc should be "size 17 problems total. From owner-freebsd-standards@FreeBSD.ORG Mon Aug 18 11:04:45 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 790F937B401 for ; Mon, 18 Aug 2003 11:04:45 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1A61443F75 for ; Mon, 18 Aug 2003 11:04:45 -0700 (PDT) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (peter@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h7II4iUp071376 for ; Mon, 18 Aug 2003 11:04:45 -0700 (PDT) (envelope-from owner-bugmaster@freebsd.org) Received: (from peter@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h7II4iEt071370 for standards@freebsd.org; Mon, 18 Aug 2003 11:04:44 -0700 (PDT) Date: Mon, 18 Aug 2003 11:04:44 -0700 (PDT) Message-Id: <200308181804.h7II4iEt071370@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: peter set sender to owner-bugmaster@freebsd.org using -f From: FreeBSD bugmaster To: standards@FreeBSD.org Subject: Current problem reports assigned to you X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Aug 2003 18:04:45 -0000 Current FreeBSD problem reports Critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2001/08/18] kern/29844 standards [PATCH] setpgrp does not behave as manual 1 problem total. Serious problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2001/03/05] bin/25542 standards /bin/sh: null char in quoted string 1 problem total. Non-critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2000/09/24] bin/21519 standards sys/dir.h should be deprecated some more f [1995/01/11] i386/105 standards Distributed libm (msun) has non-standard o [2000/12/05] kern/23304 standards POSIX clock_gettime, clock_getres return s [2001/06/18] kern/28260 standards UIO_MAXIOV needs to be made public 4 problems total. From owner-freebsd-standards@FreeBSD.ORG Fri Aug 22 15:41:30 2003 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D190216A4FE for ; Fri, 22 Aug 2003 15:41:23 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id CE99143FE0 for ; Fri, 22 Aug 2003 15:40:34 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h7MMeJUp013814 for ; Fri, 22 Aug 2003 15:40:19 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h7MMeJSO013813; Fri, 22 Aug 2003 15:40:19 -0700 (PDT) Date: Fri, 22 Aug 2003 15:40:19 -0700 (PDT) Message-Id: <200308222240.h7MMeJSO013813@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Wartan Hachaturow Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Wartan Hachaturow List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Aug 2003 22:41:32 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: Wartan Hachaturow To: Jens Schweikhardt Cc: GNATS Bug Followup , tjr@FreeBSD.org Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Sat, 23 Aug 2003 02:27:21 +0400 --Kj7319i9nmIyA2yE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This version of patch (hopefully :) fixes the issues tjr pointed to, and adds hexal and octal constants which are required by SUSv3. I've even successfully built 5.1's world with it. -- Regards, Wartan. "Computers are not intelligent. They only think they are." --Kj7319i9nmIyA2yE Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ash.patch" diff -u ./FreeBSD_ASH_HEAD.orig/arith.h ./FreeBSD_ASH_HEAD/arith.h --- ./FreeBSD_ASH_HEAD.orig/arith.h Thu Aug 7 14:17:27 2003 +++ ./FreeBSD_ASH_HEAD/arith.h Thu Aug 7 14:17:43 2003 @@ -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.5.2.1 2002/07/19 04:38:51 tjr Exp $ */ +int arith_assign(char *, arith_t); int arith(char *); int expcmd(int , char **); diff -u ./FreeBSD_ASH_HEAD.orig/arith.y ./FreeBSD_ASH_HEAD/arith.y --- ./FreeBSD_ASH_HEAD.orig/arith.y Thu Aug 7 14:17:27 2003 +++ ./FreeBSD_ASH_HEAD/arith.y Fri Aug 22 16:23:05 2003 @@ -1,5 +1,65 @@ -%token ARITH_NUM ARITH_LPAREN ARITH_RPAREN +%{ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Kenneth Almquist. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef lint +#if 0 +static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD: src/bin/sh/arith.y,v 1.10.2.2 2002/07/19 04:38:51 tjr Exp $"); + +#include +#include "shell.h" +#include "var.h" +%} +%union { + arith_t l_value; + char* s_value; +} +%token ARITH_NUM ARITH_LPAREN ARITH_RPAREN +%token ARITH_VAR + +%type 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 @@ -18,7 +78,6 @@ } ; - 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; } @@ -51,62 +110,139 @@ | 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) != 1) + 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; + } ; %% -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Kenneth Almquist. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95"; -#endif -#endif /* not lint */ -#include -__FBSDID("$FreeBSD: src/bin/sh/arith.y,v 1.14 2003/05/01 16:58:56 obrien Exp $"); - -#include "shell.h" #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(); int yylex(void); 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) diff -u ./FreeBSD_ASH_HEAD.orig/arith_lex.l ./FreeBSD_ASH_HEAD/arith_lex.l --- ./FreeBSD_ASH_HEAD.orig/arith_lex.l Thu Aug 7 14:17:27 2003 +++ ./FreeBSD_ASH_HEAD/arith_lex.l Fri Aug 22 16:30:51 2003 @@ -41,12 +41,14 @@ #endif #endif /* not lint */ #include -__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.14.2.2 2002/07/19 04:38:51 tjr Exp $"); +#include "shell.h" #include "y.tab.h" #include "error.h" +#include "var.h" +#include "memalloc.h" -extern int yylval; extern char *arith_buf, *arith_startbuf; #undef YY_INPUT #define YY_INPUT(buf,result,max) \ @@ -56,7 +58,36 @@ %% [ \t\n] { ; } -[0-9]+ { yylval = atol(yytext); return(ARITH_NUM); } + +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); } @@ -79,6 +110,17 @@ "-" { 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); } %% Common subdirectories: ./FreeBSD_ASH_HEAD.orig/bltin and ./FreeBSD_ASH_HEAD/bltin Common subdirectories: ./FreeBSD_ASH_HEAD.orig/funcs and ./FreeBSD_ASH_HEAD/funcs diff -u ./FreeBSD_ASH_HEAD.orig/shell.h ./FreeBSD_ASH_HEAD/shell.h --- ./FreeBSD_ASH_HEAD.orig/shell.h Thu Aug 7 14:17:27 2003 +++ ./FreeBSD_ASH_HEAD/shell.h Fri Aug 22 16:29:39 2003 @@ -51,6 +51,14 @@ #define JOBS 1 /* #define DEBUG 1 */ +/* + * Type of used arithmetics. SUSv3 requires us to have at least signed long. + */ +typedef long arith_t; +#define strtoarith_t(nptr, endptr, base) strtol(nptr, endptr, base) +#define atoarith_t(arg) strtol(arg, NULL, 0) +#define ARITH_FORMAT_STR "%ld" + typedef void *pointer; #define STATIC static #define MKINIT /* empty */ --Kj7319i9nmIyA2yE--