On Sun, May 19, 2013 at 9:27 PM, David Korn <[email protected]> wrote:
> Subject: Re: [ast-users] Documenting short floating point type,  i.e. typeset 
> -s -E?
> --------
>
>> sh.1 doesn't document the short floating point type, i.e. typeset -s
>> -E or typeset -s -F. Is this an oversight or is this still
>> experimental? The point of using a short float type is to store very
>> large arrays without the memory consumption of long double (i.e.
>> typeset -s -E or the float alias). This comes into play for storing 2D
>> images as ksh 2D array for image processing
>>
>> Wendy
>>
>
> This is an oversite.

Attached (as "astksh20130503_typeset_short_floatingpoint001.diff.txt")
is a cleanup patch which adds+documents typeset -s -E/-F/-X.

* Notes:
- The patch fixes the documentation for typeset -X (C99 hexfloat) to
be in par with -E/-F in typeset(1)
- The patch adds a new CPP symbol |AST_PTR_BITS| as easy wato to
distinguish between 32bit/64bit builds (note that in the not-so-far
future 80bit/96bit/128bit pointers are likely so this macro should be
used with <, <=, >, >= and not == operators). if this OK then all
other places should be cleaned-up, too (the old version of using
sizeof(char*) in an |if()| statement is a bit troublesome for debug
code since the statements are compiled-in but are not removed by the
compiler unless the optimiser gets enabled).
- Minor other cleanup in typeset(1) (watch the TABS in the source code!)
- Add usage of C99 |bool| where usefull

----

Bye,
Roland

P.S.: I hereby curse GoogleMail for not providing a Reply-To: option... ;-((

-- 
  __ .  . __
 (o.\ \/ /.o) [email protected]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
diff -r -u original/src/cmd/ksh93/bltins/typeset.c 
build_i386_64bit_debug/src/cmd/ksh93/bltins/typeset.c
--- original/src/cmd/ksh93/bltins/typeset.c     2013-03-28 14:30:54.000000000 
+0100
+++ build_i386_64bit_debug/src/cmd/ksh93/bltins/typeset.c       2013-05-19 
18:56:14.997387259 +0200
@@ -212,7 +212,7 @@
        const char      *optstring = sh_opttypeset;
        Namdecl_t       *ntp = (Namdecl_t*)context->ptr;
        Dt_t            *troot;
-       int             isfloat=0, shortint=0, sflag=0;
+       bool            isfloat=false, isshort=false, sflag=false;
        NOT_USED(argc);
        memset((void*)&tdata,0,sizeof(tdata));
        tdata.sh = context->shp;
@@ -255,7 +255,7 @@
                        case 'X':
                                if(!opt_info.arg || (tdata.argnum = 
opt_info.num) <0)
                                        tdata.argnum = 
(n=='X'?2*sizeof(Sfdouble_t):10);
-                               isfloat = 1;
+                               isfloat = true;
                                if(n=='E')
                                {
                                        flag &= ~NV_HEXFLOAT;
@@ -329,13 +329,13 @@
                                flag |= NV_RDONLY;
                                break;
                        case 'S':
-                               sflag=1;
+                               sflag=true;
                                break;
                        case 'h':
                                tdata.help = opt_info.arg;
                                break;
                        case 's':
-                               shortint=1;
+                               isshort=true;
                                break;
                        case 't':
                                flag |= NV_TAGGED;
@@ -382,16 +382,18 @@
        if(sflag && troot==tdata.sh->fun_tree)
        {
                /* static function */
-               sflag = 0;
+               sflag = false;
                flag |= NV_STATICF;
        }
        if(error_info.errors)
                errormsg(SH_DICT,ERROR_usage(2),"%s", optusage(NIL(char*)));
-       if(sizeof(char*)<8 && tdata.argnum > SHRT_MAX)
+#if AST_PTR_BITS < 64
+       if(tdata.argnum > SHRT_MAX)
                errormsg(SH_DICT,ERROR_exit(2),"option argument cannot be 
greater than %d",SHRT_MAX);
+#endif
        if(isfloat)
                flag |= NV_DOUBLE;
-       if(shortint)
+       if(isshort)
        {
                flag &= ~NV_LONG;
                flag |= NV_SHORT|NV_INTEGER;
diff -r -u original/src/cmd/ksh93/data/builtins.c 
build_i386_64bit_debug/src/cmd/ksh93/data/builtins.c
--- original/src/cmd/ksh93/data/builtins.c      2013-05-03 22:23:11.000000000 
+0200
+++ build_i386_64bit_debug/src/cmd/ksh93/data/builtins.c        2013-05-19 
18:27:36.211490951 +0200
@@ -1619,7 +1619,7 @@
 ;
 
 const char sh_opttypeset[] =
-"+[-1c?\n@(#)$Id: typeset (AT&T Research) 2010-12-08 $\n]"
+"+[-1c?\n@(#)$Id: typeset (AT&T Research) 2013-05-17 $\n]"
 USAGE_LICENSE
 "[+NAME?\f?\f - declare or display variables with attributes]"
 "[+DESCRIPTION?Without the \b-f\b option, \b\f?\f\b sets, unsets, "
@@ -1657,12 +1657,8 @@
 "[+?\b\f?\f\b is built-in to the shell as a declaration command so that "
        "field splitting and pathname expansion are not performed on "
        "the arguments.  Tilde expansion occurs on \avalue\a.]"
-#if 1
 "[a]:?[type?Indexed array.  This is the default. If \b[\b\atype\a\b]]\b is "
-    "specified, each subscript is interpreted as a value of type \atype\a.]"
-#else
-"[a?Indexed array. this is the default.]"
-#endif
+       "specified, each subscript is interpreted as a value of type \atype\a.]"
 "[b?Each \aname\a may contain binary data.  Its value is the mime "
        "base64 encoding of the data. It can be used with \b-Z\b, "
        "to specify fixed sized fields.]"
@@ -1670,7 +1666,7 @@
 "[i]#?[base:=10?An integer. \abase\a represents the arithmetic base "
        "from 2 to 64.]"
 "[l?Without \b-i\b, sets character mapping to \btolower\b. When used "
-       "with \b-i\b, \b-E\b, or \b-F\b indicates long variant.]"
+       "with \b-i\b, \b-E\b, \b-F\b, or \b-X\b indicates long variant.]"
 "[m?Move.  The value is the name of a variable whose value will be "
        "moved to \aname\a.  The orignal variable will be unset.  Cannot be "
        "used with any other options.]"
@@ -1681,7 +1677,8 @@
        "shell to recreate the attributes for variables.]"
 "[r?Enables readonly.  Once enabled it cannot be disabled.  See "
        "\breadonly\b(1).]"
-"[s?Used with \b-i\b to restrict integer size to short.]"
+"[s?Used with \b-i\b to restrict integer size to short integer or with "
+       "\b-E\b , \b-F\b or \b-X\b to represent a float.]"
 "[t?When used with \b-f\b, enables tracing for each of the specified "
        "functions.  Otherwise, \b-t\b is a user defined attribute and "
        "has no meaning to the shell.]"
diff -r -u original/src/lib/libast/features/common 
build_i386_64bit_debug/src/lib/libast/features/common
--- original/src/lib/libast/features/common     2012-09-25 06:40:06.000000000 
+0200
+++ build_i386_64bit_debug/src/lib/libast/features/common       2013-05-19 
18:51:55.638004312 +0200
@@ -23,6 +23,16 @@
        void* bar() { return foo(); }
 }end
 
+tst    - note{ number of bits in pointer }end output{
+       #include <stdio.h>
+       int
+       main()
+       {
+               printf("#define AST_PTR_BITS\t%d\n", sizeof(char*) * 8);
+               return 0;
+       }
+}end
+
 cat{
        /* disable non-standard linux/gnu inlines */
        #ifdef __GNUC__ 
diff -r -u original/src/lib/libast/features/sfio 
build_i386_64bit_debug/src/lib/libast/features/sfio
--- original/src/lib/libast/features/sfio       2010-05-26 06:45:57.000000000 
+0200
+++ build_i386_64bit_debug/src/lib/libast/features/sfio 2013-05-19 
18:58:06.532881990 +0200
@@ -4,16 +4,6 @@
 lib    qfrexp,qldexp
 key    signed
 
-tst    - note{ number of bits in pointer }end output{
-       #include <stdio.h>
-       int
-       main()
-       {
-               printf("#define _ptr_bits       %d\n", sizeof(char*) * 8);
-               return 0;
-       }
-}end
-
 tst    tmp_rmfail note{ open files cannot be removed }end execute{
        #include <string.h>
        #include <time.h>
diff -r -u original/src/lib/libast/sfio/sfhdr.h 
build_i386_64bit_debug/src/lib/libast/sfio/sfhdr.h
--- original/src/lib/libast/sfio/sfhdr.h        2012-09-24 20:10:31.000000000 
+0200
+++ build_i386_64bit_debug/src/lib/libast/sfio/sfhdr.h  2013-05-19 
18:58:10.630377755 +0200
@@ -843,7 +843,7 @@
                         ((n) >= SF_GRAIN && (ssize_t)(n) >= (f)->size/16 ) )
 
 /* number of pages to memory map at a time */
-#if _ptr_bits >= 64
+#if AST_PTR_BITS >= 64
 #define SF_NMAP                1024
 #else
 #define SF_NMAP                32
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to