[ast-users] C ode example how to enumerate fields of a compound variable?
I'm looking for a C code example how to enumerate the fields in a compound variable. Like: compound ex=( field0=aaa field1=bbb field710=AUA context=0xff0a ) Now I need a C loop which returns these values: key='field0' value='aaa' key='field1' value='bbb' key='field710' value='AUA' key='context' value='0xff0a' Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.m...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
Re: [ast-users] nan payload support in next ksh93/libast tarball?
Lionel, Glenn, do you have updates? Tina On 12 September 2014 18:54, Tina Harriott tina.harriott.m...@gmail.com wrote: On 9 September 2014 23:11, Lionel Cons lionelcons1...@gmail.com wrote: On 3 September 2014 15:30, Lionel Cons lionelcons1...@gmail.com wrote: What is the status of the nan payload support in ksh? Can the support be integrated into the next ksh and libast tarball? Lionel Glenn? I think this is mostly your department since Roland's patch mostly touched libast. I'd like to have that feature too Lionel ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.m...@gmail.com -- Tina Harriott - Women in Mathematics Contact: tina.harriott.m...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
Re: [ast-users] Unit of least precision (ULP)/spacing between floating point number problems
On 23 October 2013 03:59, Tina Harriott tina.harriott.m...@gmail.com wrote: On 11 August 2013 10:43, Tina Harriott tina.harriott.m...@gmail.com wrote: On Wed, Jul 24, 2013 at 7:28 PM, Glenn Fowler g...@research.att.com wrote: On Wed, 24 Jul 2013 19:02:39 +0200 Tina Harriott wrote: Here's one of my little tough problems which I am unable to solve myself, even after looking at the source code of ast-ksh. The problem below requires a good understanding how floating point numbers are implemented in computers. I'm trying to prototype code and like to iterate over a small, linear area by using the C library function nextafter() to step forward the smallest possible distance between each step, and print the number of iterations needed to cover the distance between 4 and 4.0001: ksh -c 'float v ; integer iter ; for ((iter=0,v=4 ; v 4.0001 iter 1000; v=nextafter(v,4.0001))) ; do ((iter++));done;print $iter ' 2305843 The result 2305843 is correct. However, if I use typeset -E (or just typeset) to declare the variable v the loop runs forever, or in this case until it hits iter 1000 which I added as safeguard later: ksh -c 'typeset -E v ; integer iter ; for ((iter=0,v=4 ; v 4.0001 iter 1000; v=nextafter(v,4.0001))) ; do ((iter++));done;print $iter ' 1000 Can anyone explain this? float is an alias this shows the alias definition type float which is typeset -lE this documents -l typeset --?l so for your example typeset -E gave you a double v and typeset -lE would give you a long double v But why does nextafter() misbehave if I want to use a datatype smaller than long double? Accuracy is a good thing, but in this case we iterate too fine-grained, meaning the code should iterate over the smallest possible steps of a double, but not over the smallest possible steps of a long double. Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.m...@gmail.com I am still running into this bug in ksh 20131010. Does it still take long to have it fixed? Is this going to be fixed in the next alpha? Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.m...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
Re: [ast-users] [ast-developers] Temporary project work at Google Code?
On 31 October 2013 01:43, Irek Szczesniak iszczesn...@gmail.com wrote: On Tue, Oct 29, 2013 at 3:35 PM, Glenn Fowler glenn.s.fow...@gmail.com wrote: thanks for the suggestion, its added to the list of possibilities today dgk and I may finally be in a place to start building again its amazing how systems (in this case gsfdgk home systems), left to their own designs, become harder to replicate as time passes in my particular case I have forgotten all of the little personalization tweaks that make a stock system my system although forgetting may not matter that much because those tweaks are the least stable part of linux distros Can you say how long it all take until AST resumes operations? I'd be interested in updates, too. Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.m...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
[ast-users] for loop in arithmetic expressions proposal?
I think I once saw a proposal to allow for loops within arithmetic expressions. Does anyone have a link to it? What happened to the proposal? Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.m...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
Re: [ast-users] Unsigned long int has a MAX of -1
On 19 September 2013 17:30, Tina Harriott tina.harriott.m...@gmail.com wrote: I found a small bug in i.MAX for unsigned long integers: ksh -c 'typeset -u -l -i i ; print -- $((i.MAX))' -1 This bug is still present in the latest language version: ksh --version version sh (ATT Research) 93v- 2013-09-23 Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.m...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
[ast-users] [[ -v x.MAX ]] returns 0 if x is an integer variable
The -v test operand does not work for i.MAX if i is a constant of an integer type: ksh -c 'integer i; [[ -v i.MAX ]] echo var is there' Language version is the latest: ksh --version version sh (ATT Research) 93v- 2013-09-23 Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.m...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
Re: [ast-users] [ast-developers] Unit of least precision (ULP)/spacing between floating point number problems
On 13 August 2013 04:16, David Korn d...@research.att.com wrote: cc: ast-users@lists.research.att.com ast-develop...@research.att.com Subject: Re: Re: [ast-developers] [ast-users] Unit of least precision (ULP)/spacing between floating point number problems David send Roland a comment that nextafter(x+1.1,5) does not figure the data type of x+1.1 correctly and always uses the data type of the right value. IMO the rules of ISO C (C1X) should apply. The difficult part is that I do not know how to do that with the arithmetic engine in ksh, some how the value of node.isfloat (which is now a kind of enum describing which kind of floating point data type is used - float, double, long double) must be recalculated based on the left hand lhand_node.isfloat and right hand rhand_node.isfloat value of such operations. Olga I hope to be able to do this correctly in a future release. There are four types, integer, float, double, and long double. How long will it take until ksh -c 'typeset -s -E x=4 ; print $(( x=nextafter(x,5) ))' uses nextafterf()? Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.m...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
[ast-users] Unset method for multidimensional array crashes ksh
The example below crashes any ksh version I could find, even the latest sh (ATT Research) 93v- 2013-08-27 function f { typeset -a a ; a.unset() { print unset ; } ; a[3][6][11][20]=7 ; } ; f Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.m...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
[ast-users] Compound variable declarations do not work in namespace
Compound variable declarations do not work within a namespace. If I declare a compound variable container and wish to print its contents as plain text outside the namespace it doesn't work: ksh -c 'namespace com.foo { compound container; compound -a container.a; integer container.i=0; }; print -v .com.foo.container' ( ) Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.m...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
[ast-users] Passing a file descriptor to a child process?
ksh93 uses O_CLOEXEC to avoid passing all its file descriptors to a child process. That is IMO a good thing (clean!). However, is there a way to pass a file descriptor to a child process? Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.mathemat...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
Re: [ast-users] Nested namespaces for function/type libraries (e.g. com.att.research...) ... / was: Re: ksh -c 'namespace a.c.b { integer i=5 ; } ; ' = a.c.b: is not an identifier?
On 29 July 2013 03:17, Wendy Lin wendlin1...@gmail.com wrote: On 28 July 2013 06:17, Roland Mainz roland.ma...@nrubsig.org wrote: On Fri, Jul 12, 2013 at 4:42 AM, Wendy Lin wendlin1...@gmail.com wrote: On 12 July 2013 04:35, David Korn d...@research.att.com wrote: cc: wendlin1...@gmail.com Subject: Re: [ast-users] ksh -c 'namespace a.c.b { integer i=5 ; } ; ' = a.c.b: is not an identifier? How do I create a nested namespace? I tried this but it fails: ksh -c 'namespace a.c.b { integer i=5 ; } ; ' /home/wlin/bin/ksh: a.c.b: is not an identifier Wendy namespace a { namespace c { namespace b { integer i=5 } } } I still get an error for this: ksh -c 'namespace a { namespace b { integer i=5 ; } ; } ; printf %d\n .a.b.i' /home/wlin/bin/ksh: printf: .a.b.i: no parent I don't think this is the right way (semantically) because you can't switch from namespace a.b.c to namespace b.g.y on the fly. The following test patch fixes the problem: -- snip -- diff -r -u original/src/cmd/ksh93/sh/xec.c build_i386_64bit_debug/src/cmd/ksh93/sh/xec.c --- src/cmd/ksh93/sh/xec.c 2013-07-25 02:37:26.0 +0200 +++ src/cmd/ksh93/sh/xec.c 2013-07-28 05:36:31.827214685 +0200 @@ -2710,8 +2710,10 @@ Namval_t *oldnspace = shp-namespace; int offset = stktell(stkp); int flag=NV_NOASSIGN|NV_NOARRAY|NV_VARNAME; +#if 0 if(cp) errormsg(SH_DICT,ERROR_exit(1),e_ident,fname); +#endif sfputc(stkp,'.'); sfputr(stkp,fname,0); np = nv_open(stkptr(stkp,offset),shp-var_tree,flag); -- snip -- If this gets applied then the following sample code finally works: -- snip -- # the next three lines are placeholders for the parent namespaces namespace com { true ; } namespace com.att { true ; } namespace com.att.research { true ; } # test namespace for ATT Research namespace com.att.research.hello { function print_hello { print 'Hello World' } } # do somthing .com.att.research.hello.print_hello -- snip -- IMO this would finally a major step forward towards a common function/type library where each party has it's own namespace which is organised like DNA (see java why this is a good idea) * Notes: - At some point namerefs to functions, e.g. typeset -f -n would be usefull... e.g. nameref -f hello=.com.att.research.hello.print_hello # would map the function .com.att.research.hello.print_hello to the short name hello without requiring a wrapper function (saving execution name) - Known bugs: $ ksh -c 'namespace a { true ; } ; namespace a.sp1 { integer i=5 ; function inc { let i++ ; } ; } ; print ${.a.sp1.i} ; .a.sp1.inc ; print ${.a.sp1.i} ' # print $'5\n5' but should print $'5\n6' Comments/feedback/rants/etc. wecome... I like it. It improves a lot over perl module madness. One rfe: mkdir has option -p to create missing parent dirs. Could you add namespace -p to add missing namespaces, i.e. create empty namespaces if they are not set yet? Aside from namespace -p the idea of adding namespaces like a DNS tree is GREAT!! Not that this is a beauty contest, but I like the concept of com.att.research.hello or ca.uwaterloo.math.statistics1.util, too. It would be very very useful if you can get it working. I'd imagine it would just work like wrapping your favourite functions into a statement like namespace ca.uwaterloo.math.statistics1.util {} and you can share them without risk, right? Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.mathemat...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
Re: [ast-users] Edit 10GB file with fixed size records
On 24 July 2013 22:57, Janis Papanagnou janis_papanag...@hotmail.com wrote: Does ksh have an API to edit a file at a specific position pos1, read n1 bytes, and write n1 bytes at that position without truncating the file? I need this to do edit a file in place without reading and writing it completely each time. Yes, ksh has seek redirection operators. Here's an ad hoc example (not sure whether the features are applied proficiently, but it seems to work :-) f=somefile cat EOT $f Hello world! My good friend. How are you? EOT function fun ## palindrome (just for example) { arg=$1 x= (( len=${#arg} )) for ((i=0; ilen; i++)) do res=${arg:i:1}$res done printf %s $res } pos1=18 n1=8 read -N $n1 content 0$f #((pos1)) printf %s $(fun $content) 1$f #((pos1)) Outputs: Hello world! My goneirf dod. How are you? Hope it's of some use to you. How would this example look like if I opened a file descriptor with the number 19? ksh seems to use file descriptors 0-9 for manual usage, but descriptors opened with exec {filed}name.rec use numbers 10. Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.mathemat...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
Re: [ast-users] ACL lists not preserved when copying files with ksh cp
On 23 July 2013 20:43, Glenn Fowler g...@research.att.com wrote: On Tue, 23 Jul 2013 19:16:43 +0200 Tina Harriott wrote: I hope this is the right place to report to. On Suse Linux nfs4 ACL lists are not preserved if I copy files with ksh's builtin cp command. To demonstrate: 1. touch aaa 2. nfs4_setfacl -a A::testuser@localdomain:RX aaa 3. nfs4_getfacl aaa D::OWNER@:x A::OWNER@:rwatTcCy A::1000:rxtcy - new ACL entry A::GROUP@:rtcy A::EVERYONE@:rtcy 4. ksh -c 'builtin cp; cp aaa aaa_copy' 5. nfs4_getfacl aaa_copy D::OWNER@:x A::OWNER@:rwatTcCy A::GROUP@:rxtcy A::EVERYONE@:rtcy The new ACL entry is missing in the copy. cp options -a and -p have no effect. Is this functionality missing or just broken. ACL support is IMO a mandatory enterprise system feature and needs to be supported. missing on the todo list How long will it take to implement it? Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.mathemat...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
[ast-users] Demo code and contrib packages?
Does ast-ksh have extension packages like demo and contrib like bash and zsh do? Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.mathemat...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
[ast-users] Unit of least precision (ULP)/spacing between floating point number problems
Here's one of my little tough problems which I am unable to solve myself, even after looking at the source code of ast-ksh. The problem below requires a good understanding how floating point numbers are implemented in computers. I'm trying to prototype code and like to iterate over a small, linear area by using the C library function nextafter() to step forward the smallest possible distance between each step, and print the number of iterations needed to cover the distance between 4 and 4.0001: ksh -c 'float v ; integer iter ; for ((iter=0,v=4 ; v 4.0001 iter 1000; v=nextafter(v,4.0001))) ; do ((iter++));done;print $iter ' 2305843 The result 2305843 is correct. However, if I use typeset -E (or just typeset) to declare the variable v the loop runs forever, or in this case until it hits iter 1000 which I added as safeguard later: ksh -c 'typeset -E v ; integer iter ; for ((iter=0,v=4 ; v 4.0001 iter 1000; v=nextafter(v,4.0001))) ; do ((iter++));done;print $iter ' 1000 Can anyone explain this? Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.mathemat...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
Re: [ast-users] Demo code and contrib packages?
On 24 July 2013 19:32, Glenn Fowler g...@research.att.com wrote: On Wed, 24 Jul 2013 18:52:14 +0200 Tina Harriott wrote: Does ast-ksh have extension packages like demo and contrib like bash and zsh do? in ksh user extension are called builtins and have an main(argc,argv,context) api its described in the nav bar at http://www.research.att.com/sw/download/ AST = ksh = builtins ksh has some builtins implemented directly in its source there and many other ast builtins implemented in src/lib/libcmd I think you misunderstood the question. For example, bash provides demo and contrib packages. Demo contains demo scripts to show the various features of a shell, and contrib contains extra functionality written by people who are not in the core development team but are otherwise thought to be useful. Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.mathemat...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users
[ast-users] ACL lists not preserved when copying files with ksh cp
I hope this is the right place to report to. On Suse Linux nfs4 ACL lists are not preserved if I copy files with ksh's builtin cp command. To demonstrate: 1. touch aaa 2. nfs4_setfacl -a A::testuser@localdomain:RX aaa 3. nfs4_getfacl aaa D::OWNER@:x A::OWNER@:rwatTcCy A::1000:rxtcy - new ACL entry A::GROUP@:rtcy A::EVERYONE@:rtcy 4. ksh -c 'builtin cp; cp aaa aaa_copy' 5. nfs4_getfacl aaa_copy D::OWNER@:x A::OWNER@:rwatTcCy A::GROUP@:rxtcy A::EVERYONE@:rtcy The new ACL entry is missing in the copy. cp options -a and -p have no effect. Is this functionality missing or just broken. ACL support is IMO a mandatory enterprise system feature and needs to be supported. Tina -- Tina Harriott - Women in Mathematics Contact: tina.harriott.mathemat...@gmail.com ___ ast-users mailing list ast-users@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-users