summaryrefslogtreecommitdiff
path: root/usr/src/lib/libshell/common/sh/streval.c
diff options
context:
space:
mode:
authorRoger A. Faulkner <Roger.Faulkner@Oracle.COM>2010-04-03 09:48:44 -0700
committerRoger A. Faulkner <Roger.Faulkner@Oracle.COM>2010-04-03 09:48:44 -0700
commit3e14f97f673e8a630f076077de35afdd43dc1587 (patch)
tree9828b6b676f58d7b27dd28e00202d3f3461a5cd8 /usr/src/lib/libshell/common/sh/streval.c
parent4f60987df4dcaa54a88b596f861fbf4f3382c65e (diff)
downloadillumos-joyent-3e14f97f673e8a630f076077de35afdd43dc1587.tar.gz
6939349 RFE: Update ksh93 to ast-ksh.2010-03-09
6877392 ksh93 regresses 'uniq -c' performance 6887363 Korn shell 93 sometimes mishandles return value of its child process 6900314 (while true ; do true|true ; done) hang in ioctl() with SIGTTOU 6904557 wc no longer counts number of bytes correctly 6904575 cut -d with multibyte character no longer works 6904597 paste -d no longer works with multibyte characters 6904780 /usr/bin/cksum changed output in snv_128 6904870 uniq -s does not skip multibyte characters correctly 6904878 join -t no longer works with multibyte char separator 6907460 EXIT trap handlers are sometimes executed twice 6909579 libast getopt solaris compatibility broken 6920072 ksh93 tail -f, with unconditional .25s sleep and line parsing, about 37x slower than cat 6932124 mktemp in ksh93 is broken Contributed by Olga Kryzhanovska <olga.kryzhanovska@gmail.com>
Diffstat (limited to 'usr/src/lib/libshell/common/sh/streval.c')
-rw-r--r--usr/src/lib/libshell/common/sh/streval.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/usr/src/lib/libshell/common/sh/streval.c b/usr/src/lib/libshell/common/sh/streval.c
index 92a8256594..7053831da0 100644
--- a/usr/src/lib/libshell/common/sh/streval.c
+++ b/usr/src/lib/libshell/common/sh/streval.c
@@ -1,7 +1,7 @@
/***********************************************************************
* *
* This software is part of the ast package *
-* Copyright (c) 1982-2009 AT&T Intellectual Property *
+* Copyright (c) 1982-2010 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
@@ -34,6 +34,7 @@
#include <error.h>
#include <stak.h>
#include "FEATURE/externs"
+#include "defs.h" /* for sh.decomma */
#ifndef ERROR_dictionary
# define ERROR_dictionary(s) (s)
@@ -162,6 +163,8 @@ Sfdouble_t arith_exec(Arith_t *ep)
node.emode = ep->emode;
node.expr = ep->expr;
node.elen = ep->elen;
+ node.value = 0;
+ node.nosub = 0;
if(level++ >=MAXLEVEL)
{
arith_error(e_recursive,ep->expr,ep->emode);
@@ -195,17 +198,21 @@ Sfdouble_t arith_exec(Arith_t *ep)
type=0;
break;
case A_PLUSPLUS:
+ node.nosub = 1;
(*ep->fun)(&ptr,&node,ASSIGN,num+1);
break;
case A_MINUSMINUS:
+ node.nosub = 1;
(*ep->fun)(&ptr,&node,ASSIGN,num-1);
break;
case A_INCR:
num = num+1;
+ node.nosub = 1;
num = (*ep->fun)(&ptr,&node,ASSIGN,num);
break;
case A_DECR:
num = num-1;
+ node.nosub = 1;
num = (*ep->fun)(&ptr,&node,ASSIGN,num);
break;
case A_SWAP:
@@ -248,6 +255,8 @@ Sfdouble_t arith_exec(Arith_t *ep)
*++tp = type;
c = 0;
break;
+ case A_ASSIGNOP:
+ node.nosub = 1;
case A_STORE:
cp = roundptr(ep,cp,Sfdouble_t*);
dp = *((Sfdouble_t**)cp);
@@ -430,15 +439,21 @@ static int gettok(register struct vars *vp)
case A_EOF:
vp->nextchr--;
break;
- /*FALL THRU*/
- case A_DIG: case A_REG: case A_DOT: case A_LIT:
- if(op==A_DOT)
+ case A_COMMA:
+ if(sh.decomma && (c=peekchr(vp))>='0' && c<='9')
{
- if((c=peekchr(vp))>='0' && c<='9')
- op = A_DIG;
- else
- op = A_REG;
+ op = A_DIG;
+ goto keep;
}
+ break;
+ case A_DOT:
+ if((c=peekchr(vp))>='0' && c<='9')
+ op = A_DIG;
+ else
+ op = A_REG;
+ /*FALL THRU*/
+ case A_DIG: case A_REG: case A_LIT:
+ keep:
ungetchr(vp);
break;
case A_QUEST:
@@ -483,7 +498,7 @@ static int expr(register struct vars *vp,register int precedence)
int invalid,wasop=0;
struct lval lvalue,assignop;
const char *pos;
- Sfdouble_t d;
+ Sfdouble_t d;
lvalue.value = 0;
lvalue.fun = 0;
@@ -603,7 +618,7 @@ again:
}
if(!expr(vp,c))
{
- stakseek(-1);
+ stakseek(staktell()-1);
return(0);
}
lvalue.value = 0;
@@ -784,7 +799,7 @@ again:
vp->stakmaxsize = vp->staksize;
if(assignop.flag<0)
assignop.flag = 0;
- stakputc(A_STORE);
+ stakputc(c&1?A_ASSIGNOP:A_STORE);
stakpush(vp,assignop.value,char*);
stakpush(vp,assignop.flag,short);
}