1 /****************************************************************
3 The author of this software is David M. Gay.
5 Copyright (C) 2000 by Lucent Technologies
8 Permission to use, copy, modify, and distribute this software and
9 its documentation for any purpose and without fee is hereby
10 granted, provided that the above copyright notice appear in all
11 copies and that both that the copyright notice and this
12 permission notice and warranty disclaimer appear in supporting
13 documentation, and that the name of Lucent or any of its entities
14 not be used in advertising or publicity pertaining to
15 distribution of the software without specific, written prior
18 LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
20 IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
21 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
23 IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
27 ****************************************************************/
29 /* Please send bug reports to David M. Gay (dmg at acm dot org,
30 * with " at " changed at "@" and " dot " changed to "."). */
38 L_shift(x
, x1
, i
) ULong
*x
; ULong
*x1
; int i
;
40 L_shift(ULong
*x
, ULong
*x1
, int i
)
57 CONST
char **sp
; FPI
*fpi
; ULong
*x0
;
59 hexnan( CONST
char **sp
, FPI
*fpi
, ULong
*x0
)
62 ULong c
, h
, *x
, *x1
, *xe
;
64 int havedig
, hd0
, i
, nbits
;
69 x
= x0
+ (nbits
>> kshift
);
74 havedig
= hd0
= i
= 0;
77 /* FreeBSD local: Accept (but ignore) the '0x' prefix. */
78 if (s
[1] == '0' && (s
[2] == 'x' || s
[2] == 'X'))
81 while(c
= *(CONST
unsigned char*)++s
) {
82 if (!(h
= hexdig
[c
])) {
99 if (/*(*/ c
== ')' && havedig
) {
113 *x
= (*x
<< 4) | h
& 0xf;
115 if (havedig
&& x
< x1
&& i
< 8)
125 /* truncate high-order word if necessary */
126 if ( (i
= nbits
& (ULbits
-1)) !=0)
127 *xe
&= ((ULong
)0xffffffff) >> (ULbits
- i
);
130 for(x1
= xe
;; --x1
) {
141 * FreeBSD local: Accept all the sequences allowed by C99 and update
142 * the tail pointer correctly. Don't accept any invalid sequences.
144 if (c
== '\0') /* nan() calls this, too; tolerate a missing ')' */
145 return STRTOG_NaNbits
;
147 while(c
= *(CONST
unsigned char*)++s
) {
150 if (!isalnum(c
) && c
!= '_')
151 return STRTOG_NaNbits
;
155 return STRTOG_NaNbits
;