summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-06-12 20:07:54 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-06-12 20:07:54 -0700
commit3514a727b3807b19f150922f376b4eeb7a9f5dba (patch)
tree4f686ce8af49ba2f59eddd5604b75cdcb22bd7f4
parentc26dba28db8ee168ae02a62b453107309f737269 (diff)
downloadtxr-3514a727b3807b19f150922f376b4eeb7a9f5dba.tar.gz
txr-3514a727b3807b19f150922f376b4eeb7a9f5dba.tar.bz2
txr-3514a727b3807b19f150922f376b4eeb7a9f5dba.zip
awk macro: new fconv conversions c and cz.
* share/txr/stdlib/conv.tl (sys:conv-let): New local functions c and cz, using the new #\c radix conversion. * txr.1: Documented new extension under the fconv awk macro. Also fixed a typo here; the b conversion was exemplified as (c str).
-rw-r--r--share/txr/stdlib/conv.tl4
-rw-r--r--txr.121
2 files changed, 22 insertions, 3 deletions
diff --git a/share/txr/stdlib/conv.tl b/share/txr/stdlib/conv.tl
index 88a8fb95..e373e3dc 100644
--- a/share/txr/stdlib/conv.tl
+++ b/share/txr/stdlib/conv.tl
@@ -33,6 +33,8 @@
(toint arg 16))
(b (arg)
(toint arg 2))
+ (c (arg)
+ (toint arg #\c))
(r (arg)
(tofloat arg))
(iz (arg : radix)
@@ -43,6 +45,8 @@
(tointz arg 16))
(bz (arg)
(tointz arg 2))
+ (cz (arg)
+ (tointz arg #\c))
(rz (arg)
(tofloatz arg)))
,*body))
diff --git a/txr.1 b/txr.1
index e46d52a0..7c1ec319 100644
--- a/txr.1
+++ b/txr.1
@@ -45805,21 +45805,36 @@ is equivalent to
.coIP b
Converts a string value holding a binary (base two) representation
to the integer which it denotes. The expression
-.code "(c str)"
+.code "(b str)"
is equivalent to
.codn "(toint str 2)" .
+.coIP c
+Converts a string value holding a C-language-style representation
+to the integer which it denotes, meaning that the
+.code 0x
+prefix denotes a hexadecimal value, a leading zero octal, otherwise
+decimal. These prefixes follow the
+.code +
+or
+.code -
+sign, if present.
+The expression
+.code "(c str)"
+is equivalent to
+.codn "(toint str #\ec)" .
.coIP r
Converts a string holding a floating-point representation to
the floating-point value which it denotes. The expression
.code "(r str)"
is equivalent to
.codn "(tofloat str)" .
-.ccIP @, iz @, oz @, xz @ bz and @ rz
+.ccIP @, iz @, oz @, xz @, bz @ cz and @ rz
Conversion similar to
.codn i ,
.codn o ,
.codn x ,
-.code b
+.codn b ,
+.code c
and
.codn r ,
but using