diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-07-27 06:46:04 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-07-27 06:46:04 -0700 |
commit | 50de41b73095374a330284f84f592bf56ad797b7 (patch) | |
tree | d63065e8a84a5da6c9e3a19a7a48281db915c3cd /stdlib | |
parent | 02bbca53efa5c2da8d671bd46e7e410ce533c846 (diff) | |
download | txr-50de41b73095374a330284f84f592bf56ad797b7.tar.gz txr-50de41b73095374a330284f84f592bf56ad797b7.tar.bz2 txr-50de41b73095374a330284f84f592bf56ad797b7.zip |
Take advantage of substring support in regsub.
* txr.c (sysroot_init): Use regsub to look for "\\"
substring instead of regex.
* stdlib/getopts.tl (opt-parsed convert-type):
regsub for "0x" substring rather than #/0x/ regex.
* stdlib/pic.tl (pic-join-oipt): regsub for
"~" substring rather than #/\~/ regex.
* stdlib/socket.tl (in6addr-str): regsub for "::"
substring instead of #/::/ regex in two places.
The double regsub there looks like a mistake; will
address in another commit.
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/getopts.tl | 2 | ||||
-rw-r--r-- | stdlib/pic.tl | 2 | ||||
-rw-r--r-- | stdlib/socket.tl | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/stdlib/getopts.tl b/stdlib/getopts.tl index fb1ee007..dcfd5e21 100644 --- a/stdlib/getopts.tl +++ b/stdlib/getopts.tl @@ -130,7 +130,7 @@ (:cint (set me.arg (cond ((r^$ #/[+\-]?0x[\da-fA-F]+/ me.arg) - (int-str (regsub #/0x/ "" me.arg) 16)) + (int-str (regsub "0x" "" me.arg) 16)) ((r^$ #/[+\-]?0[0-7]+/ me.arg) (int-str me.arg 8)) ((r^$ #/[+\-]?0[\da-fA-F]+/ me.arg) diff --git a/stdlib/pic.tl b/stdlib/pic.tl index 2d05b319..c6c95bdc 100644 --- a/stdlib/pic.tl +++ b/stdlib/pic.tl @@ -114,7 +114,7 @@ ^(fmt ,`~@(if chr chr)@(len fmt)a` ,val)) (defun pic-join-opt (join-form) - (labels ((et (str) (regsub #/\~/ "~~" str))) + (labels ((et (str) (regsub "~" "~~" str))) (match-case join-form ((join @(stringp @s) (fmt `@fmt` . @args) . @rest) (pic-join-opt ^(join (fmt ,`@(et s)@fmt` ,*args) ,*rest))) diff --git a/stdlib/socket.tl b/stdlib/socket.tl index 01c328b5..7aecfc88 100644 --- a/stdlib/socket.tl +++ b/stdlib/socket.tl @@ -252,8 +252,8 @@ (set addr.prefix prefix) addr))) ((r^$ #/[\da-fA-F]*(:[\da-fA-F]*)*/ str) - (upd str (regsub #/::/ "@")) - (let* ((str-splat (regsub #/::/ "@" str)) + (upd str (regsub "::" "@")) + (let* ((str-splat (regsub "::" "@" str)) (maj-pieces (spl #\@ str-splat))) (caseql (len maj-pieces) (1 (mkaddr-full (str-to-pieces (car maj-pieces)))) |