diff options
author | Andy Wingo <wingo@pobox.com> | 2010-11-19 17:08:36 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-11-19 17:08:36 +0100 |
commit | 9fe717e23c50680b77860dcb3e30b00184caba4f (patch) | |
tree | 4b14802460ae0239e66efe3d8dfe7ad1b0b0d2ab /libguile/srfi-13.c | |
parent | 402c35ac8115a48ee1fe300eb87b3ed43518be94 (diff) | |
download | guile-9fe717e23c50680b77860dcb3e30b00184caba4f.tar.gz |
fix string-filter and string-delete argument order
* libguile/srfi-13.h:
* libguile/srfi-13.c (scm_string_filter, scm_string_delete): Swap
char_pred and s argument order, to comply with SRFI-13. There is a
back-compat shim that will detect programs that used the old,
erroneous interface, while giving a warning.
* doc/ref/api-data.texi: Update docs.
Diffstat (limited to 'libguile/srfi-13.c')
-rw-r--r-- | libguile/srfi-13.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/libguile/srfi-13.c b/libguile/srfi-13.c index e9bf94e9f..afeb80476 100644 --- a/libguile/srfi-13.c +++ b/libguile/srfi-13.c @@ -29,6 +29,7 @@ #include "libguile.h" +#include <libguile/deprecation.h> #include "libguile/srfi-13.h" #include "libguile/srfi-14.h" @@ -3033,7 +3034,7 @@ SCM_DEFINE (scm_string_split, "string-split", 2, 0, 0, SCM_DEFINE (scm_string_filter, "string-filter", 2, 2, 0, - (SCM s, SCM char_pred, SCM start, SCM end), + (SCM char_pred, SCM s, SCM start, SCM end), "Filter the string @var{s}, retaining only those characters\n" "which satisfy @var{char_pred}.\n" "\n" @@ -3047,7 +3048,21 @@ SCM_DEFINE (scm_string_filter, "string-filter", 2, 2, 0, SCM result; size_t idx; - MY_VALIDATE_SUBSTRING_SPEC (1, s, + if (scm_is_string (char_pred)) + { + SCM tmp; + + scm_c_issue_deprecation_warning + ("Guile used to use the wrong argument order for string-filter.\n" + "This call to string-filter had the arguments in the wrong order.\n" + "See SRFI-13 for more details. At some point we will remove this hack."); + + tmp = char_pred; + char_pred = s; + s = tmp; + } + + MY_VALIDATE_SUBSTRING_SPEC (2, s, 3, start, cstart, 4, end, cend); @@ -3130,7 +3145,7 @@ SCM_DEFINE (scm_string_filter, "string-filter", 2, 2, 0, SCM ls = SCM_EOL; SCM_ASSERT (scm_is_true (scm_procedure_p (char_pred)), - char_pred, SCM_ARG2, FUNC_NAME); + char_pred, SCM_ARG1, FUNC_NAME); idx = cstart; while (idx < cend) { @@ -3151,7 +3166,7 @@ SCM_DEFINE (scm_string_filter, "string-filter", 2, 2, 0, SCM_DEFINE (scm_string_delete, "string-delete", 2, 2, 0, - (SCM s, SCM char_pred, SCM start, SCM end), + (SCM char_pred, SCM s, SCM start, SCM end), "Delete characters satisfying @var{char_pred} from @var{s}.\n" "\n" "If @var{char_pred} is a procedure, it is applied to each\n" @@ -3164,7 +3179,21 @@ SCM_DEFINE (scm_string_delete, "string-delete", 2, 2, 0, SCM result; size_t idx; - MY_VALIDATE_SUBSTRING_SPEC (1, s, + if (scm_is_string (char_pred)) + { + SCM tmp; + + scm_c_issue_deprecation_warning + ("Guile used to use the wrong argument order for string-delete.\n" + "This call to string-filter had the arguments in the wrong order.\n" + "See SRFI-13 for more details. At some point we will remove this hack."); + + tmp = char_pred; + char_pred = s; + s = tmp; + } + + MY_VALIDATE_SUBSTRING_SPEC (2, s, 3, start, cstart, 4, end, cend); @@ -3265,7 +3294,7 @@ SCM_DEFINE (scm_string_delete, "string-delete", 2, 2, 0, { SCM ls = SCM_EOL; SCM_ASSERT (scm_is_true (scm_procedure_p (char_pred)), - char_pred, SCM_ARG2, FUNC_NAME); + char_pred, SCM_ARG1, FUNC_NAME); idx = cstart; while (idx < cend) |