summaryrefslogtreecommitdiff
path: root/libguile/srfi-13.c
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2019-05-07 02:28:26 -0400
committerAndy Wingo <wingo@pobox.com>2019-05-23 17:48:46 +0200
commitd5c420a88880caf1e364af7339b66932411b5234 (patch)
treec1eaffa1c50752bd96c5a40b9cf4e53fdf2e549e /libguile/srfi-13.c
parent7e208c8f256ac4d7ef670655aa42711433fdd781 (diff)
downloadguile-d5c420a88880caf1e364af7339b66932411b5234.tar.gz
Add 'scm_c_make_char' and use it where appropriate.
This reverts the change to SCM_MAKE_CHAR made in the previous commit 63818453ad226cd3c2d1fd8ade12e3d7c1d43c05, which used an arithmetic trick to avoid evaluating its argument more than once. Here, we restore the previous implementation of SCM_MAKE_CHAR, which evaluates its argument twice. Instead, we introduce a new inlinable function 'scm_c_make_char' and replace uses of SCM_MAKE_CHAR with calls to 'scm_c_make_char' where appropriate. * libguile/chars.h (scm_c_make_char): New inline function. * libguile/inline.c: Include chars.h. * libguile/srfi-13.c (REF_IN_CHARSET, scm_string_any, scm_string_every) (scm_string_trim, scm_string_trim_right, scm_string_trim_both) (scm_string_index, scm_string_index_right, scm_string_skip) (scm_string_skip_right, scm_string_count, string_titlecase_x) (string_reverse_x, scm_string_fold, scm_string_fold_right) (scm_string_for_each, scm_string_filter, scm_string_delete): Use 'scm_c_make_char' instead of 'SCM_MAKE_CHAR' in cases where the argument calls a function. * libguile/chars.c (scm_char_upcase, scm_char_downcase, scm_char_titlecase), libguile/ports.c (scm_port_decode_char), libguile/print.c (scm_simple_format), libguile/read.c (scm_read_character), libguile/strings.c (scm_string_ref, scm_c_string_ref),
Diffstat (limited to 'libguile/srfi-13.c')
-rw-r--r--libguile/srfi-13.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/libguile/srfi-13.c b/libguile/srfi-13.c
index 3de8b5d3e..97c372674 100644
--- a/libguile/srfi-13.c
+++ b/libguile/srfi-13.c
@@ -60,7 +60,7 @@
} while (0)
#define REF_IN_CHARSET(s, i, cs) \
- (scm_is_true (scm_char_set_contains_p ((cs), SCM_MAKE_CHAR (scm_i_string_ref (s, i)))))
+ (scm_is_true (scm_char_set_contains_p ((cs), scm_c_make_char (scm_i_string_ref (s, i)))))
SCM_DEFINE (scm_string_null_p, "string-null?", 1, 0, 0,
(SCM str),
@@ -140,7 +140,7 @@ SCM_DEFINE (scm_string_any, "string-any-c-code", 2, 2, 0,
while (cstart < cend)
{
res = scm_call_1 (char_pred,
- SCM_MAKE_CHAR (scm_i_string_ref (s, cstart)));
+ scm_c_make_char (scm_i_string_ref (s, cstart)));
if (scm_is_true (res))
break;
cstart++;
@@ -207,7 +207,7 @@ SCM_DEFINE (scm_string_every, "string-every-c-code", 2, 2, 0,
while (cstart < cend)
{
res = scm_call_1 (char_pred,
- SCM_MAKE_CHAR (scm_i_string_ref (s, cstart)));
+ scm_c_make_char (scm_i_string_ref (s, cstart)));
if (scm_is_false (res))
break;
cstart++;
@@ -765,7 +765,7 @@ SCM_DEFINE (scm_string_trim, "string-trim", 1, 3, 0,
{
SCM res;
- res = scm_call_1 (char_pred, SCM_MAKE_CHAR (scm_i_string_ref (s, cstart)));
+ res = scm_call_1 (char_pred, scm_c_make_char (scm_i_string_ref (s, cstart)));
if (scm_is_false (res))
break;
cstart++;
@@ -841,7 +841,7 @@ SCM_DEFINE (scm_string_trim_right, "string-trim-right", 1, 3, 0,
{
SCM res;
- res = scm_call_1 (char_pred, SCM_MAKE_CHAR (scm_i_string_ref (s, cend - 1)));
+ res = scm_call_1 (char_pred, scm_c_make_char (scm_i_string_ref (s, cend - 1)));
if (scm_is_false (res))
break;
cend--;
@@ -935,7 +935,7 @@ SCM_DEFINE (scm_string_trim_both, "string-trim-both", 1, 3, 0,
{
SCM res;
- res = scm_call_1 (char_pred, SCM_MAKE_CHAR (scm_i_string_ref (s, cstart)));
+ res = scm_call_1 (char_pred, scm_c_make_char (scm_i_string_ref (s, cstart)));
if (scm_is_false (res))
break;
cstart++;
@@ -944,7 +944,7 @@ SCM_DEFINE (scm_string_trim_both, "string-trim-both", 1, 3, 0,
{
SCM res;
- res = scm_call_1 (char_pred, SCM_MAKE_CHAR (scm_i_string_ref (s, cend - 1)));
+ res = scm_call_1 (char_pred, scm_c_make_char (scm_i_string_ref (s, cend - 1)));
if (scm_is_false (res))
break;
cend--;
@@ -1705,7 +1705,7 @@ SCM_DEFINE (scm_string_index, "string-index", 2, 2, 0,
while (cstart < cend)
{
SCM res;
- res = scm_call_1 (char_pred, SCM_MAKE_CHAR (scm_i_string_ref (s, cstart)));
+ res = scm_call_1 (char_pred, scm_c_make_char (scm_i_string_ref (s, cstart)));
if (scm_is_true (res))
goto found;
cstart++;
@@ -1771,7 +1771,7 @@ SCM_DEFINE (scm_string_index_right, "string-index-right", 2, 2, 0,
{
SCM res;
cend--;
- res = scm_call_1 (char_pred, SCM_MAKE_CHAR (scm_i_string_ref (s, cend)));
+ res = scm_call_1 (char_pred, scm_c_make_char (scm_i_string_ref (s, cend)));
if (scm_is_true (res))
goto found;
}
@@ -1857,7 +1857,7 @@ SCM_DEFINE (scm_string_skip, "string-skip", 2, 2, 0,
while (cstart < cend)
{
SCM res;
- res = scm_call_1 (char_pred, SCM_MAKE_CHAR (scm_i_string_ref (s, cstart)));
+ res = scm_call_1 (char_pred, scm_c_make_char (scm_i_string_ref (s, cstart)));
if (scm_is_false (res))
goto found;
cstart++;
@@ -1924,7 +1924,7 @@ SCM_DEFINE (scm_string_skip_right, "string-skip-right", 2, 2, 0,
{
SCM res;
cend--;
- res = scm_call_1 (char_pred, SCM_MAKE_CHAR (scm_i_string_ref (s, cend)));
+ res = scm_call_1 (char_pred, scm_c_make_char (scm_i_string_ref (s, cend)));
if (scm_is_false (res))
goto found;
}
@@ -1990,7 +1990,7 @@ SCM_DEFINE (scm_string_count, "string-count", 2, 2, 0,
while (cstart < cend)
{
SCM res;
- res = scm_call_1 (char_pred, SCM_MAKE_CHAR (scm_i_string_ref (s, cstart)));
+ res = scm_call_1 (char_pred, scm_c_make_char (scm_i_string_ref (s, cstart)));
if (scm_is_true (res))
count++;
cstart++;
@@ -2247,7 +2247,7 @@ string_titlecase_x (SCM str, size_t start, size_t end)
str = scm_i_string_start_writing (str);
for(i = start; i < end; i++)
{
- ch = SCM_MAKE_CHAR (scm_i_string_ref (str, i));
+ ch = scm_c_make_char (scm_i_string_ref (str, i));
if (scm_is_true (scm_char_alphabetic_p (ch)))
{
if (!in_word)
@@ -2345,7 +2345,7 @@ string_reverse_x (SCM str, size_t cstart, size_t cend)
cend--;
while (cstart < cend)
{
- tmp = SCM_MAKE_CHAR (scm_i_string_ref (str, cstart));
+ tmp = scm_c_make_char (scm_i_string_ref (str, cstart));
scm_i_string_set_x (str, cstart, scm_i_string_ref (str, cend));
scm_i_string_set_x (str, cend, SCM_CHAR (tmp));
cstart++;
@@ -2582,7 +2582,7 @@ SCM_DEFINE (scm_string_fold, "string-fold", 3, 2, 0,
result = knil;
while (cstart < cend)
{
- result = scm_call_2 (kons, SCM_MAKE_CHAR (scm_i_string_ref (s, cstart)), result);
+ result = scm_call_2 (kons, scm_c_make_char (scm_i_string_ref (s, cstart)), result);
cstart++;
}
@@ -2610,7 +2610,7 @@ SCM_DEFINE (scm_string_fold_right, "string-fold-right", 3, 2, 0,
result = knil;
while (cstart < cend)
{
- result = scm_call_2 (kons, SCM_MAKE_CHAR (scm_i_string_ref (s, cend-1)), result);
+ result = scm_call_2 (kons, scm_c_make_char (scm_i_string_ref (s, cend-1)), result);
cend--;
}
@@ -2767,7 +2767,7 @@ SCM_DEFINE (scm_string_for_each, "string-for-each", 2, 2, 0,
4, end, cend);
while (cstart < cend)
{
- scm_call_1 (proc, SCM_MAKE_CHAR (scm_i_string_ref (s, cstart)));
+ scm_call_1 (proc, scm_c_make_char (scm_i_string_ref (s, cstart)));
cstart++;
}
@@ -3208,7 +3208,7 @@ SCM_DEFINE (scm_string_filter, "string-filter", 2, 2, 0,
while (idx < cend)
{
SCM res, ch;
- ch = SCM_MAKE_CHAR (scm_i_string_ref (s, idx));
+ ch = scm_c_make_char (scm_i_string_ref (s, idx));
res = scm_call_1 (char_pred, ch);
if (scm_is_true (res))
ls = scm_cons (ch, ls);
@@ -3343,7 +3343,7 @@ SCM_DEFINE (scm_string_delete, "string-delete", 2, 2, 0,
idx = cstart;
while (idx < cend)
{
- SCM res, ch = SCM_MAKE_CHAR (scm_i_string_ref (s, idx));
+ SCM res, ch = scm_c_make_char (scm_i_string_ref (s, idx));
res = scm_call_1 (char_pred, ch);
if (scm_is_false (res))
ls = scm_cons (ch, ls);