From 8517a196f4110376ce769611594cd8692f72dc7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 23 Jun 2022 04:21:16 +0200 Subject: Remove ->str and ->quoted-string. ->str as an alias of ->string is removed. ->string is however left. ->quoted-string was always weird, and was only used once. --- doc/ref/guile/util.texi | 8 +------- module/hnh/util.scm | 9 ++------- module/sxml/transformations.scm | 2 +- module/web/uri-query.scm | 3 +-- tests/test/util.scm | 4 ---- 5 files changed, 5 insertions(+), 21 deletions(-) diff --git a/doc/ref/guile/util.texi b/doc/ref/guile/util.texi index d7ed0785..f7a0f77e 100644 --- a/doc/ref/guile/util.texi +++ b/doc/ref/guile/util.texi @@ -310,16 +310,10 @@ non-unique keys, returning all mathing records (instead of just the first). Returns the last element of @var{v}. @end defun -@defun ->str any -@defunx ->string any +@defun ->string any Converts @var{any} to a string, as per @var{display}. @end defun -@defun ->quoted-string any -Converts @var{any} to a string, as per @var{write}. -@end defun - - @defmac let-env bindings body ... Similar to @var{let}, but sets environment variables for the code in diff --git a/module/hnh/util.scm b/module/hnh/util.scm index b0e6b81a..46557e38 100644 --- a/module/hnh/util.scm +++ b/module/hnh/util.scm @@ -58,7 +58,7 @@ vector-last - ->str ->string ->quoted-string + ->string catch* ) @@ -530,14 +530,9 @@ (define (vector-last v) (vector-ref v (1- (vector-length v)))) -(define (->str any) +(define (->string any) (with-output-to-string (lambda () (display any)))) -(define ->string ->str) - -(define (->quoted-string any) - (with-output-to-string (lambda () (write any)))) - (define-syntax catch* diff --git a/module/sxml/transformations.scm b/module/sxml/transformations.scm index 61de42aa..09b26ad4 100644 --- a/module/sxml/transformations.scm +++ b/module/sxml/transformations.scm @@ -31,7 +31,7 @@ (attribute-transformer tree `((href . ,(lambda (_ . content) - `(href ,@(transformer (string-concatenate (map ->str content)))) + `(href ,@(transformer (string-concatenate (map ->string content)))) ))))) (define (href-prefixer tree prefix) diff --git a/module/web/uri-query.scm b/module/web/uri-query.scm index adf99803..e7cc627c 100644 --- a/module/web/uri-query.scm +++ b/module/web/uri-query.scm @@ -1,5 +1,4 @@ (define-module (web uri-query) - :use-module ((hnh util) :select (->quoted-string)) :use-module ((web uri) :select (uri-encode)) :export (encode-query-parameters) ) @@ -14,7 +13,7 @@ (map (lambda (p) (format #f "~a=~a" (car p) - (uri-encode (->quoted-string (cdr p))))) + (uri-encode (with-output-to-string (lambda () (write (cdr p))))))) parameters) "&")) diff --git a/tests/test/util.scm b/tests/test/util.scm index e6b0c214..1de96a37 100644 --- a/tests/test/util.scm +++ b/tests/test/util.scm @@ -226,10 +226,6 @@ (test-equal "5" (->string "5")) -(test-equal "5" (->quoted-string 5)) - -(test-equal "\"5\"" (->quoted-string "5")) - (test-equal "no slashes" "home/user" -- cgit v1.2.3