diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-06-12 20:00:20 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-06-12 20:00:20 -0700 |
commit | 9afe98ddd7506561f70b4356fbde69731e339042 (patch) | |
tree | 20cf813f0330826ae03f32e381638aab05274521 /txr.1 | |
parent | 2f9728db321c67ee6c41372914a4a56a5809356d (diff) | |
download | txr-9afe98ddd7506561f70b4356fbde69731e339042.tar.gz txr-9afe98ddd7506561f70b4356fbde69731e339042.tar.bz2 txr-9afe98ddd7506561f70b4356fbde69731e339042.zip |
int-str: allow radix to be #\c for C conventions.
* lib.c (int_str): Support #\c base, recognizing
0x as hex and leading 0 as octal. We don't rely on
the wcstol function's ability to do this conversion,
but scan it ourselves.
* txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -33489,8 +33489,13 @@ ignored. The .code int-str function converts a string of digits in the specified -radix to an integer value. If the radix isn't specified, it defaults to 10. -Otherwise it must be an integer in the range 2 to 36. +.meta radix +to an integer value. If +.meta radix +isn't specified, it defaults to 10. +Otherwise it must be an integer in the range 2 to 36, or else the character +.codn #\c . + For radices above 10, letters of the alphabet are used for digits: .code A @@ -33499,11 +33504,30 @@ represent a digit whose value is 10, represents 11 and so forth until .codn Z . -For values of radix above 36, the returned value is -unspecified. Upper and lower case letters are recognized. +Upper and lower case letters are recognized. Any character which is not a digit of the specified radix is regarded as the start of trailing junk at which the extraction of the digits stops. +When +.meta radix +is specified as the character object +.codn #\c , +this indicates that a C-language-style integer constant should be +recognized. If, after any optional sign, the remainder of +.meta string +begins with the character pair +.code 0x +then that pair is considered removed from the string, and it is treated +as base 16 (hexadecimal). If, after any optional sign, the remainder of +.meta string +begins with a leading zero not followed by +.codn x , +then the radix is taken to be 8 (octal). In scanning these formats, +.code int-str +function is not otherwise constrained by C language representational +limitations. Specifically, the input values are taken to be the printed +representation of arbitrary-precision integers and treated accordingly. + The .code flo-str function converts a floating-point decimal notation to a nearby |