summaryrefslogtreecommitdiff
path: root/libguile/strorder.c
diff options
context:
space:
mode:
authorMarius Vollmer <mvo@zagadka.de>2004-08-12 17:45:03 +0000
committerMarius Vollmer <mvo@zagadka.de>2004-08-12 17:45:03 +0000
commit8824ac88f08cffc954a907b85858ccd5b3c9843f (patch)
treec96fa1d142124eaf6f030adbc4ec2eb040b612b0 /libguile/strorder.c
parent70f7ee4188c0a752154d8cc63daf5a99ba89951f (diff)
downloadguile-8824ac88f08cffc954a907b85858ccd5b3c9843f.tar.gz
* socket.c, rw.c, deprecated.h, validate.h
(SCM_VALIDATE_STRING_COPY): Deprecated. Replaced all uses with SCM_VALIDATE_STRING plus SCM_I_STRING_CHARS or scm_to_locale_string, etc. (SCM_VALIDATE_SUBSTRING_SPEC_COPY): Deprecated. Replaced as above, plus scm_i_get_substring_spec. * regex-posix.c, read.c, random.c, ramap.c, print.c, numbers.c, hash.c, gc.c, gc-card.c, convert.i.c, backtrace.c, strop.c, strorder.c, strports.c, struct.c, symbols.c, unif.c, ports.c: Use SCM_I_STRING_CHARS, SCM_I_STRING_UCHARS, and SCM_I_STRING_LENGTH instead of SCM_STRING_CHARS, SCM_STRING_UCHARS, and SCM_STRING_LENGTH, respectively. Also, replaced scm_return_first with more explicit scm_remember_upto_here_1, etc, or introduced them in the first place.
Diffstat (limited to 'libguile/strorder.c')
-rw-r--r--libguile/strorder.c56
1 files changed, 34 insertions, 22 deletions
diff --git a/libguile/strorder.c b/libguile/strorder.c
index ac19d7370..6e8b647d3 100644
--- a/libguile/strorder.c
+++ b/libguile/strorder.c
@@ -43,18 +43,22 @@ SCM_DEFINE1 (scm_string_equal_p, "string=?", scm_tc7_rpsubr,
SCM_VALIDATE_STRING (1, s1);
SCM_VALIDATE_STRING (2, s2);
- length = SCM_STRING_LENGTH (s2);
- if (SCM_STRING_LENGTH (s1) == length)
+ length = SCM_I_STRING_LENGTH (s2);
+ if (SCM_I_STRING_LENGTH (s1) == length)
{
- unsigned char *c1 = SCM_STRING_UCHARS (s1) + length - 1;
- unsigned char *c2 = SCM_STRING_UCHARS (s2) + length - 1;
+ unsigned char *c1 = SCM_I_STRING_UCHARS (s1) + length - 1;
+ unsigned char *c2 = SCM_I_STRING_UCHARS (s2) + length - 1;
size_t i;
/* comparing from back to front typically finds mismatches faster */
for (i = 0; i != length; ++i, --c1, --c2)
if (*c1 != *c2)
- return SCM_BOOL_F;
+ {
+ scm_remember_upto_here_2 (s1, s2);
+ return SCM_BOOL_F;
+ }
+ scm_remember_upto_here_2 (s1, s2);
return SCM_BOOL_T;
}
else
@@ -78,18 +82,22 @@ SCM_DEFINE1 (scm_string_ci_equal_p, "string-ci=?", scm_tc7_rpsubr,
SCM_VALIDATE_STRING (1, s1);
SCM_VALIDATE_STRING (2, s2);
- length = SCM_STRING_LENGTH (s2);
- if (SCM_STRING_LENGTH (s1) == length)
+ length = SCM_I_STRING_LENGTH (s2);
+ if (SCM_I_STRING_LENGTH (s1) == length)
{
- unsigned char *c1 = SCM_STRING_UCHARS (s1) + length - 1;
- unsigned char *c2 = SCM_STRING_UCHARS (s2) + length - 1;
+ unsigned char *c1 = SCM_I_STRING_UCHARS (s1) + length - 1;
+ unsigned char *c2 = SCM_I_STRING_UCHARS (s2) + length - 1;
size_t i;
/* comparing from back to front typically finds mismatches faster */
for (i = 0; i != length; ++i, --c1, --c2)
if (scm_c_upcase (*c1) != scm_c_upcase (*c2))
- return SCM_BOOL_F;
+ {
+ scm_remember_upto_here_2 (s1, s2);
+ return SCM_BOOL_F;
+ }
+ scm_remember_upto_here_2 (s1, s2);
return SCM_BOOL_T;
}
else
@@ -108,16 +116,18 @@ string_less_p (SCM s1, SCM s2)
size_t i, length1, length2, lengthm;
unsigned char *c1, *c2;
- length1 = SCM_STRING_LENGTH (s1);
- length2 = SCM_STRING_LENGTH (s2);
+ length1 = SCM_I_STRING_LENGTH (s1);
+ length2 = SCM_I_STRING_LENGTH (s2);
lengthm = min (length1, length2);
- c1 = SCM_STRING_UCHARS (s1);
- c2 = SCM_STRING_UCHARS (s2);
+ c1 = SCM_I_STRING_UCHARS (s1);
+ c2 = SCM_I_STRING_UCHARS (s2);
for (i = 0; i != lengthm; ++i, ++c1, ++c2) {
int c = *c1 - *c2;
- if (c < 0) return SCM_BOOL_T;
- if (c > 0) return SCM_BOOL_F;
+ if (c == 0)
+ continue;
+ scm_remember_upto_here_2 (s1, s2);
+ return scm_from_bool (c < 0);
}
return scm_from_bool (length1 < length2);
@@ -188,16 +198,18 @@ string_ci_less_p (SCM s1, SCM s2)
size_t i, length1, length2, lengthm;
unsigned char *c1, *c2;
- length1 = SCM_STRING_LENGTH (s1);
- length2 = SCM_STRING_LENGTH (s2);
+ length1 = SCM_I_STRING_LENGTH (s1);
+ length2 = SCM_I_STRING_LENGTH (s2);
lengthm = min (length1, length2);
- c1 = SCM_STRING_UCHARS (s1);
- c2 = SCM_STRING_UCHARS (s2);
+ c1 = SCM_I_STRING_UCHARS (s1);
+ c2 = SCM_I_STRING_UCHARS (s2);
for (i = 0; i != lengthm; ++i, ++c1, ++c2) {
int c = scm_c_upcase (*c1) - scm_c_upcase (*c2);
- if (c < 0) return SCM_BOOL_T;
- if (c > 0) return SCM_BOOL_F;
+ if (c == 0)
+ continue;
+ scm_remember_upto_here_2 (s1, s2);
+ return scm_from_bool (c < 0);
}
return scm_from_bool (length1 < length2);