diff options
-rw-r--r-- | srfi/ChangeLog | 5 | ||||
-rw-r--r-- | srfi/srfi-13.c | 12 | ||||
-rw-r--r-- | test-suite/ChangeLog | 5 | ||||
-rw-r--r-- | test-suite/tests/srfi-13.test | 13 |
4 files changed, 28 insertions, 7 deletions
diff --git a/srfi/ChangeLog b/srfi/ChangeLog index d2e94bbe5..e2286b8b7 100644 --- a/srfi/ChangeLog +++ b/srfi/ChangeLog @@ -1,3 +1,8 @@ +2001-08-22 Mikael Djurfeldt <mdj@linnaeus.mit.edu> + + * srfi-13.c (string-map): Swapped order of string and proc args to + conform with the srfi. (Thanks to Alex Shinn.) + 2001-08-05 Gary Houston <ghouston@arglist.com> * srfi-1.scm (check-arg-type, non-negative-integer?): a couple of new diff --git a/srfi/srfi-13.c b/srfi/srfi-13.c index acd043b9c..a54dfbc1a 100644 --- a/srfi/srfi-13.c +++ b/srfi/srfi-13.c @@ -2400,7 +2400,7 @@ SCM_DEFINE (scm_string_concatenate_reverse_shared, "string-concatenate-reverse/s SCM_DEFINE (scm_string_map, "string-map", 2, 2, 0, - (SCM s, SCM proc, SCM start, SCM end), + (SCM proc, SCM s, SCM start, SCM end), "@var{proc} is a char->char procedure, it is mapped over\n" "@var{s}. The order in which the procedure is applied to the\n" "string elements is not specified.") @@ -2410,10 +2410,10 @@ SCM_DEFINE (scm_string_map, "string-map", 2, 2, 0, int cstart, cend; SCM result; - SCM_VALIDATE_SUBSTRING_SPEC_COPY (1, s, cstr, + SCM_VALIDATE_PROC (1, proc); + SCM_VALIDATE_SUBSTRING_SPEC_COPY (2, s, cstr, 3, start, cstart, 4, end, cend); - SCM_VALIDATE_PROC (2, proc); result = scm_allocate_string (cend - cstart); p = SCM_STRING_CHARS (result); while (cstart < cend) @@ -2430,7 +2430,7 @@ SCM_DEFINE (scm_string_map, "string-map", 2, 2, 0, SCM_DEFINE (scm_string_map_x, "string-map!", 2, 2, 0, - (SCM s, SCM proc, SCM start, SCM end), + (SCM proc, SCM s, SCM start, SCM end), "@var{proc} is a char->char procedure, it is mapped over\n" "@var{s}. The order in which the procedure is applied to the\n" "string elements is not specified. The string @var{s} is\n" @@ -2440,10 +2440,10 @@ SCM_DEFINE (scm_string_map_x, "string-map!", 2, 2, 0, char * cstr, *p; int cstart, cend; - SCM_VALIDATE_SUBSTRING_SPEC_COPY (1, s, cstr, + SCM_VALIDATE_PROC (1, proc); + SCM_VALIDATE_SUBSTRING_SPEC_COPY (2, s, cstr, 3, start, cstart, 4, end, cend); - SCM_VALIDATE_PROC (2, proc); p = SCM_STRING_CHARS (s) + cstart; while (cstart < cend) { diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index e0d6c6716..d12e6fdc1 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,8 @@ +2001-08-22 Mikael Djurfeldt <mdj@linnaeus.mit.edu> + + * tests/srfi-13.test (string-map): Swapped order of string and + proc args to conform with the srfi. (Thanks to Alex Shinn.) + 2001-08-12 Thien-Thi Nguyen <ttn@revel.glug.org> * tests/getopt-long.test (exception:no-such-option, diff --git a/test-suite/tests/srfi-13.test b/test-suite/tests/srfi-13.test index b55472b75..37ecfa5af 100644 --- a/test-suite/tests/srfi-13.test +++ b/test-suite/tests/srfi-13.test @@ -18,7 +18,7 @@ ;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;;; Boston, MA 02111-1307 USA -(use-modules (srfi srfi-13) (srfi srfi-14)) +(use-modules (srfi srfi-13) (srfi srfi-14) (test-suite lib)) ;;; This kludge is needed, because SRFI-13 redefines some bindings in ;;; the core. @@ -1010,3 +1010,14 @@ (pass-if "pred, start and end index" (string=? "" (string-delete ".foo.bar." char-alphabetic? 2 4)))) + +(with-test-prefix "string-map" + + (pass-if "constant" + (string=? "xxx" (string-map (lambda (c) #\x) "foo"))) + + (pass-if "identity" + (string=? "foo" (string-map identity "foo"))) + + (pass-if "upcase" + (string=? "FOO" (string-map char-upcase "foo")))) |