Re: scripts/makelst: bc -> shell Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Feb 03, 2007 at 12:24:59PM +0100, David Weinehall wrote:
> On Sat, Jan 27, 2007 at 06:38:36AM +0000, Oleg Verych wrote:
> [snip]
> > ,-*- diff snip -*-
> > |-    t4=`echo $t3 | gawk '{ print $1 }'`
> > |-    t5=`echo $t1 | gawk '{ print $1 }'`
> > |+    t4=`pos_param 1 $t3`
> > |+    t5=`pos_param 1 $t1`
> > 5     t6=`echo $t4 - $t5 | tr a-f A-F`
> > 6     t7=`( echo  ibase=16 ; echo $t6 ) | bc`
> > `-*-
> > 
> > I've just noticed, that things on lines 5 and 6 may be optimized.
> > 
> > t7=`printf "%lu" $(( 0x$t4 - 0x$t5 ))`
> 
> %lu does not seem to agree with SuSv3:
> 
> http://www.opengroup.org/onlinepubs/009695399/utilities/printf.html
> http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap05.html

,-*- xbd_chap05.html -*-
|     The EXTENDED DESCRIPTION section almost exactly matches the
|     printf() function in the ISO C standard, although it is described
|     in terms of the file format notation in the Base Definitions volume
|     of IEEE Std 1003.1-2001, Chapter 5, File Format Notation.
`-*-
In other words, it does *not* match it at all. How it can without
the length modifiers?

As for me, "shalls" and "shoulds", "Implementations are encouraged" are
standard terms of The Standards.

Thus, i think, "%ul" is more "implementation wise":

,-*- printf test on bash, dash, busybox -*-
|olecom@flower:~$
|olecom@flower:~$ printf "%u \n" 0xffffffffffffffff
|18446744073709551615
|olecom@flower:~$ printf "%u \n" 0xffffffffffffffffA
|bash: printf: warning: 0xffffffffffffffffA: Numerical result out of range
|18446744073709551615
|olecom@flower:~$
|olecom@flower:~$ echo $BASH_VERSION
|3.1.17(1)-release
|olecom@flower:~$
|olecom@flower:~$ /bin/dash
|flower:-$ printf "%u \n" 0xffffffffffffffff
|18446744073709551615
|flower:-$ printf "%u \n" 0xffffffffffffffffA
|printf: 2: 0xffffffffffffffffA: Numerical result out of range
|18446744073709551615
|flower:-$
|flower:-$ /bin/busybox sh
|
|
|BusyBox v1.1.3 (Debian 1:1.1.3-4) Built-in shell (ash)
|Enter 'help' for a list of built-in commands.
|
|flower:-$
|flower:-$
|flower:-$ printf "%u \n" 0xffffffffffffffff
|4294967295
|flower:-$ printf "%u \n" 0xffffffffffffffffA
|0xffffffffffffffffA4294967295
|flower:-$ printf "%lu \n" 0xffffffffffffffff
|18446744073709551615
|flower:-$ printf "%lu \n" 0xffffffffffffffffA
|0xffffffffffffffffA18446744073709551615
|flower:-$
|flower:-$
`-*-

____
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux