mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix floating point numerics having precision of 0 with assignments (#149)
Issuing typeset floating point numerics having a precision of 0 failed as the precision/size was being overwritten with the string length of the value, e.g. 'typeset -F0 x=5.67' would result in 'typeset -F 4 x=5.6700' as len('5.67') is 4. src/cmd/ksh93/include/nval.h: - Created a symbolic name of NV_FLTSIZEZERO to respresent a float having a precision/size of 0. NV_FLTSIZEZERO needs to be a negative value. src/cmd/ksh93/bltins/typeset.c: - In b_typeset(), added code to set tdata.argnum to NV_FLTSIZEZERO for E, F, X options. - In setall(), adjusted code to allow for tp->argnum to be negative. src/cmd/ksh93/sh/name.c: nv_newattr(): - Adjusted option value only change code to handle NV_FLTSIZEZERO as well as changed to directly setting np->nvsize instead of using nv_setsize(np,size) as nv_setsize might contain conflicting and/or redundant code. - Added missing conditional check of '!(newatts&NV_INTEGER)' to constrain the size==0 code block to justified strings as NV_LJUST, NV_RJUST, or NV_ZFILL are only valid for strings if NV_INTEGER is not set. This code block was mistakenly setting the precision/size value to the length of the value of an assignment for floats whereas it should only be performing auto assignment length for justified strings.
This commit is contained in:
parent
95fe07d869
commit
88a6baa1a7
6 changed files with 27 additions and 5 deletions
|
@ -165,6 +165,7 @@ struct Namval
|
|||
#define NV_DOUBLE (NV_INTEGER|NV_ZFILL) /* for floating point */
|
||||
#define NV_EXPNOTE (NV_LJUST) /* for scientific notation */
|
||||
#define NV_HEXFLOAT (NV_LTOU) /* for C99 base16 float notation */
|
||||
#define NV_FLTSIZEZERO -1 /* a float with size of 0 being <0 */
|
||||
|
||||
/* options for nv_open */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue