[ast-developers] Re: foo is not an element of x, if I try to extend a compound in a type

2012-08-17 Thread ольга крыжановская
David, as clarification:
The poll(1) builtin is acting up for types. I think Roland's design
anticipates that it can not create new variables in a compound
variable which is embedded in a type. However ksh even acts up if some
one wants to *read* a compound variable member which does not exist.

For example:
ksh -c 'typeset -T y_t=( compound ex=(i=1)) ; y_t v ; print ${v.ex.nono}'
./arch/linux.i386-64/bin/ksh: ex.nono: is not an element of v

In poll(1) I get the same warning, despite the use of
NV_NOFAIL|NV_NOADD flags in the nv_open() call. I think the nv_open()
call should just fail silently, right?

Olga

On Sat, Aug 18, 2012 at 2:31 AM, ольга крыжановская
olga.kryzhanov...@gmail.com wrote:
 David, why do I get a 'x.sh: line 8: extensions.i: is not an element
 of x' for the script below?

 typeset -T y_t=(
 compound extensions
 )
 y_t x;
 x.extensions=( integer i=1 )
 print $x

 This is rather a *big* problem since I assumed that compound variables
 are always extensible, and if I add an array of compound variables I
 can both add array elements and a variable number of data in these
 compound variables in the array.

 Olga
 --
   ,   __   ,
  { \/`o;-Olga Kryzhanovska   -;o`\/ }
 .'-/`-/ olga.kryzhanov...@gmail.com   \-`\-'.
  `'-..-| /   http://twitter.com/fleyta \ |-..-'`
   /\/\ Solaris/BSD//C/C++ programmer   /\/\
   `--`  `--`



-- 
  ,   __   ,
 { \/`o;-Olga Kryzhanovska   -;o`\/ }
.'-/`-/ olga.kryzhanov...@gmail.com   \-`\-'.
 `'-..-| /   http://twitter.com/fleyta \ |-..-'`
  /\/\ Solaris/BSD//C/C++ programmer   /\/\
  `--`  `--`

___
ast-developers mailing list
ast-developers@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-developers


[ast-developers] Re: foo is not an element of x, if I try to extend a compound in a type

2012-08-17 Thread ольга крыжановская
Analysis:
gdb --args ./arch/linux.i386-64/bin/ksh -c 'builtin poll ; typeset -T
p_t=( integer fd ; compound events revents ) ; function x { p_t -a
xx.p=( [0]=( fd=0 events=( pollin=true ) revents=() ) ) ; poll -R -t10
xx.p ; print -v xx ; } ; compound xx ; x'
Reading symbols from
/home/test001/work/ast_ksh_20120813/build_poll/arch/linux.i386-64/bin/ksh...done.
(gdb) break write
Breakpoint 1 at 0x40caa8
(gdb) run
Starting program:
/home/test001/work/ast_ksh_20120813/build_poll/arch/linux.i386-64/bin/ksh
-c builtin\ poll\ \;\ typeset\ -T\ p_t=\(\ integer\ fd\ \;\ compound\
events\ revents\ \)\ \;\ function\ x\ \{\ p_t\ -a\ xx.p=\(\ \[0\]=\(\
fd=0\ events=\(\ pollin=true\ \)\ revents=\(\)\ \)\ \)\ \;\ poll\ -R\
-t10\ xx.p\ \;\ print\ -v\ xx\ \;\ \}\ \;\ compound\ xx\ \;\ x

Breakpoint 1, 0x774bb1c0 in write () from /lib64/libc.so.6
(gdb) where
#0  0x774bb1c0 in write () from /lib64/libc.so.6
#1  0x0050829d in sfwr (f=0x7d9fe0, buf=0x77fa8070, n=131,
disc=0x0) at 
/home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/sfio/sfwr.c:209
#2  0x004f29f6 in _sfflsbuf (f=0x7d9fe0, c=-1) at
/home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/sfio/sfflsbuf.c:97
#3  0x004fcdf3 in sfsync (f=0x7d9fe0) at
/home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/sfio/sfsync.c:133
#4  0x004bcc09 in errorv (id=0x0, level=3, ap=0x7fff8b08)
at 
/home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/misc/error.c:576
#5  0x004bd083 in errormsg (dictionary=0x55598e libshell,
level=3) at 
/home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/misc/errormsg.c:38
#6  0x004145e5 in create_type (np=0x77fbcc80,
name=0x77facac8 events.pollin, flag=1441792, fp=0x77fbd050)
at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/nvtype.c:541
#7  0x00457de0 in create_tree (np=0x77fbcc80,
name=0x77facac8 events.pollin, flag=1441792, dp=0x77fbc210)
at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/nvtree.c:79
#8  0x004510d5 in nv_create (name=0x77facac0
xx.p[0].events.pollin, root=0x77fe2f80, flags=1441792,
dp=0x7fff8db0)
at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/name.c:1192
#9  0x00451ca8 in nv_open (name=0x7fff8ec0
xx.p[0].events.pollin, root=0x77fbc8c0, flags=1441792)
at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/name.c:1404
#10 0x0048f966 in nv_open_fmt (dict=0x77fbc8c0,
flags=1441792, namefmt=0x56fc6f %s[%s].events.%s)
at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/bltins/poll.c:235
#11 0x0049037e in b_poll (argc=1, argv=0x77fbb738,
context=0x7dc8b8) at
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/bltins/poll.c:538
#12 0x00474e59 in sh_exec (shp=0x7dc3a0, t=0x77fbb660,
flags=4) at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:1332
#13 0x00477cef in sh_exec (shp=0x7dc3a0, t=0x77fbb890,
flags=7) at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:2151
#14 0x0047d8cf in sh_funscope_20120720 (shp=0x7dc3a0, argn=1,
argv=0x77fac700, fun=0, arg=0x7fffcfe0, execflg=5)
at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:3953
#15 0x0047bab8 in sh_funct (shp=0x7dc3a0, np=0x77fbc010,
argn=1, argv=0x77fac700, envlist=0x0, execflg=5)
at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:3282
#16 0x0047599b in sh_exec (shp=0x7dc3a0, t=0x77fac6a0,
flags=5) at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:1513
#17 0x00477d2a in sh_exec (shp=0x7dc3a0, t=0x77fac6a0,
flags=5) at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:2155
#18 0x0040e93a in exfile (shp=0x7dc3a0, iop=0x77fb8d60,
fno=-1) at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/main.c:581
#19 0x0040db2b in sh_main (ac=3, av=0x7fffe108,
userinit=0) at 
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/main.c:353
#20 0x0040cd79 in main (argc=3, argv=0x7fffe108) at
/home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/pmain.c:45

create_type() fails, but in the wrong way: It uses
'errormsg(SH_DICT,ERROR_exit(1),e_notelem,n,name,nv_name(np));'
instead of looking at flags and test for NV_NOFAIL and return NULL.

I tried to fix the problem with this patch:
diff -u5 src/cmd/ksh93/sh/nvtype.c src/cmd/ksh93/sh/nvtype.c
--- src/cmd/ksh93/sh/nvtype.c 2012-08-07 23:13:31.0 +0200
+++ src/cmd/ksh93/sh/nvtype.c   2012-08-18 03:13:19.479515490 +0200
@@ -536,10 +536,12 @@
if(name[n]!='=') for(i=0; i  dp-ndisc; i++)
{
if((memcmp(name,dp-names[i],n)==0) 
dp-names[i][n]==0)
return(nq);
  

[ast-developers] Re: foo is not an element of x, if I try to extend a compound in a type

2012-08-17 Thread ольга крыжановская
Simple test case:

/arch/linux.i386-64/bin/ksh -c 'typeset -T y_t=( compound ex=(i=1)) ;
y_t v ; [[ -v v.ex.l ]]'
./arch/linux.i386-64/bin/ksh: ex.l: is not an element of v

and

./arch/linux.i386-64/bin/ksh +nounset -c 'typeset -T y_t=( compound
ex=(i=1)) ; y_t v ; print ${v.ex.l}'
./arch/linux.i386-64/bin/ksh: ex.l: is not an element of v

Both should not trigger an error message unless set -o nounset is set.
From C api level these messages, whether set -o nounset is enabled or
not, should be suppressed with NV_NOADD|NV_NOFAIL, which does not
happen in ast-ksh 20120813 either.

Please have a look quickly at the problem. I am stuck.
Please.

Olga

On Sat, Aug 18, 2012 at 5:02 AM, ольга крыжановская
olga.kryzhanov...@gmail.com wrote:
 Analysis:
 gdb --args ./arch/linux.i386-64/bin/ksh -c 'builtin poll ; typeset -T
 p_t=( integer fd ; compound events revents ) ; function x { p_t -a
 xx.p=( [0]=( fd=0 events=( pollin=true ) revents=() ) ) ; poll -R -t10
 xx.p ; print -v xx ; } ; compound xx ; x'
 Reading symbols from
 /home/test001/work/ast_ksh_20120813/build_poll/arch/linux.i386-64/bin/ksh...done.
 (gdb) break write
 Breakpoint 1 at 0x40caa8
 (gdb) run
 Starting program:
 /home/test001/work/ast_ksh_20120813/build_poll/arch/linux.i386-64/bin/ksh
 -c builtin\ poll\ \;\ typeset\ -T\ p_t=\(\ integer\ fd\ \;\ compound\
 events\ revents\ \)\ \;\ function\ x\ \{\ p_t\ -a\ xx.p=\(\ \[0\]=\(\
 fd=0\ events=\(\ pollin=true\ \)\ revents=\(\)\ \)\ \)\ \;\ poll\ -R\
 -t10\ xx.p\ \;\ print\ -v\ xx\ \;\ \}\ \;\ compound\ xx\ \;\ x

 Breakpoint 1, 0x774bb1c0 in write () from /lib64/libc.so.6
 (gdb) where
 #0  0x774bb1c0 in write () from /lib64/libc.so.6
 #1  0x0050829d in sfwr (f=0x7d9fe0, buf=0x77fa8070, n=131,
 disc=0x0) at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/sfio/sfwr.c:209
 #2  0x004f29f6 in _sfflsbuf (f=0x7d9fe0, c=-1) at
 /home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/sfio/sfflsbuf.c:97
 #3  0x004fcdf3 in sfsync (f=0x7d9fe0) at
 /home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/sfio/sfsync.c:133
 #4  0x004bcc09 in errorv (id=0x0, level=3, ap=0x7fff8b08)
 at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/misc/error.c:576
 #5  0x004bd083 in errormsg (dictionary=0x55598e libshell,
 level=3) at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/misc/errormsg.c:38
 #6  0x004145e5 in create_type (np=0x77fbcc80,
 name=0x77facac8 events.pollin, flag=1441792, fp=0x77fbd050)
 at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/nvtype.c:541
 #7  0x00457de0 in create_tree (np=0x77fbcc80,
 name=0x77facac8 events.pollin, flag=1441792, dp=0x77fbc210)
 at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/nvtree.c:79
 #8  0x004510d5 in nv_create (name=0x77facac0
 xx.p[0].events.pollin, root=0x77fe2f80, flags=1441792,
 dp=0x7fff8db0)
 at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/name.c:1192
 #9  0x00451ca8 in nv_open (name=0x7fff8ec0
 xx.p[0].events.pollin, root=0x77fbc8c0, flags=1441792)
 at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/name.c:1404
 #10 0x0048f966 in nv_open_fmt (dict=0x77fbc8c0,
 flags=1441792, namefmt=0x56fc6f %s[%s].events.%s)
 at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/bltins/poll.c:235
 #11 0x0049037e in b_poll (argc=1, argv=0x77fbb738,
 context=0x7dc8b8) at
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/bltins/poll.c:538
 #12 0x00474e59 in sh_exec (shp=0x7dc3a0, t=0x77fbb660,
 flags=4) at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:1332
 #13 0x00477cef in sh_exec (shp=0x7dc3a0, t=0x77fbb890,
 flags=7) at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:2151
 #14 0x0047d8cf in sh_funscope_20120720 (shp=0x7dc3a0, argn=1,
 argv=0x77fac700, fun=0, arg=0x7fffcfe0, execflg=5)
 at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:3953
 #15 0x0047bab8 in sh_funct (shp=0x7dc3a0, np=0x77fbc010,
 argn=1, argv=0x77fac700, envlist=0x0, execflg=5)
 at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:3282
 #16 0x0047599b in sh_exec (shp=0x7dc3a0, t=0x77fac6a0,
 flags=5) at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:1513
 #17 0x00477d2a in sh_exec (shp=0x7dc3a0, t=0x77fac6a0,
 flags=5) at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:2155
 #18 0x0040e93a in exfile (shp=0x7dc3a0, iop=0x77fb8d60,
 fno=-1) at 
 /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/main.c:581
 #19 0x0040db2b in sh_main (ac=3, av=0x7fffe108,
 userinit=0) at