Commit | Line | Data |
---|---|---|
2b829bbb | 1 | /* Copyright (C) 1995, 1996, 1999, 2000, 2004, 2006 Free Software Foundation, Inc. |
0f2d19dd | 2 | * |
73be1d9e MV |
3 | * This library is free software; you can redistribute it and/or |
4 | * modify it under the terms of the GNU Lesser General Public | |
5 | * License as published by the Free Software Foundation; either | |
6 | * version 2.1 of the License, or (at your option) any later version. | |
0f2d19dd | 7 | * |
73be1d9e MV |
8 | * This library is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
11 | * Lesser General Public License for more details. | |
0f2d19dd | 12 | * |
73be1d9e MV |
13 | * You should have received a copy of the GNU Lesser General Public |
14 | * License along with this library; if not, write to the Free Software | |
92205699 | 15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
73be1d9e | 16 | */ |
6e8d25a6 | 17 | |
0f2d19dd JB |
18 | \f |
19 | ||
a0599745 MD |
20 | #include "libguile/_scm.h" |
21 | #include "libguile/chars.h" | |
a002f1a2 DH |
22 | #include "libguile/strings.h" |
23 | #include "libguile/symbols.h" | |
0f2d19dd | 24 | |
a0599745 MD |
25 | #include "libguile/validate.h" |
26 | #include "libguile/strorder.h" | |
2c0b7c1f | 27 | #include "libguile/srfi-13.h" |
0f2d19dd JB |
28 | \f |
29 | ||
2c0b7c1f MV |
30 | SCM_C_INLINE_KEYWORD static SCM |
31 | srfi13_cmp (SCM s1, SCM s2, SCM (*cmp) (SCM, SCM, SCM, SCM, SCM, SCM)) | |
32 | { | |
33 | if (scm_is_true (cmp (s1, s2, | |
34 | SCM_UNDEFINED, SCM_UNDEFINED, | |
35 | SCM_UNDEFINED, SCM_UNDEFINED))) | |
36 | return SCM_BOOL_T; | |
37 | else | |
38 | return SCM_BOOL_F; | |
39 | } | |
40 | ||
c3ee7520 | 41 | SCM_DEFINE1 (scm_string_equal_p, "string=?", scm_tc7_rpsubr, |
6e8d25a6 | 42 | (SCM s1, SCM s2), |
1e6808ea MG |
43 | "Lexicographic equality predicate; return @code{#t} if the two\n" |
44 | "strings are the same length and contain the same characters in\n" | |
45 | "the same positions, otherwise return @code{#f}.\n" | |
46 | "\n" | |
47 | "The procedure @code{string-ci=?} treats upper and lower case\n" | |
48 | "letters as though they were the same character, but\n" | |
49 | "@code{string=?} treats upper and lower case as distinct\n" | |
50 | "characters.") | |
6e8d25a6 | 51 | #define FUNC_NAME s_scm_string_equal_p |
0f2d19dd | 52 | { |
2c0b7c1f | 53 | return srfi13_cmp (s1, s2, scm_string_eq); |
0f2d19dd | 54 | } |
6e8d25a6 | 55 | #undef FUNC_NAME |
0f2d19dd | 56 | |
c3ee7520 | 57 | SCM_DEFINE1 (scm_string_ci_equal_p, "string-ci=?", scm_tc7_rpsubr, |
6e8d25a6 | 58 | (SCM s1, SCM s2), |
1e6808ea MG |
59 | "Case-insensitive string equality predicate; return @code{#t} if\n" |
60 | "the two strings are the same length and their component\n" | |
61 | "characters match (ignoring case) at each position; otherwise\n" | |
62 | "return @code{#f}.") | |
6e8d25a6 | 63 | #define FUNC_NAME s_scm_string_ci_equal_p |
0f2d19dd | 64 | { |
2c0b7c1f | 65 | return srfi13_cmp (s1, s2, scm_string_ci_eq); |
0f2d19dd | 66 | } |
6e8d25a6 | 67 | #undef FUNC_NAME |
0f2d19dd | 68 | |
3ba5a6c2 DH |
69 | SCM_DEFINE1 (scm_string_less_p, "string<?", scm_tc7_rpsubr, |
70 | (SCM s1, SCM s2), | |
1e6808ea MG |
71 | "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n" |
72 | "is lexicographically less than @var{s2}.") | |
3ba5a6c2 DH |
73 | #define FUNC_NAME s_scm_string_less_p |
74 | { | |
2c0b7c1f | 75 | return srfi13_cmp (s1, s2, scm_string_lt); |
3ba5a6c2 | 76 | } |
6e8d25a6 | 77 | #undef FUNC_NAME |
0f2d19dd | 78 | |
c3ee7520 | 79 | SCM_DEFINE1 (scm_string_leq_p, "string<=?", scm_tc7_rpsubr, |
6e8d25a6 | 80 | (SCM s1, SCM s2), |
1e6808ea MG |
81 | "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n" |
82 | "is lexicographically less than or equal to @var{s2}.") | |
6e8d25a6 | 83 | #define FUNC_NAME s_scm_string_leq_p |
0f2d19dd | 84 | { |
2c0b7c1f | 85 | return srfi13_cmp (s1, s2, scm_string_le); |
0f2d19dd | 86 | } |
6e8d25a6 | 87 | #undef FUNC_NAME |
0f2d19dd | 88 | |
c3ee7520 | 89 | SCM_DEFINE1 (scm_string_gr_p, "string>?", scm_tc7_rpsubr, |
6e8d25a6 | 90 | (SCM s1, SCM s2), |
1e6808ea MG |
91 | "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n" |
92 | "is lexicographically greater than @var{s2}.") | |
6e8d25a6 | 93 | #define FUNC_NAME s_scm_string_gr_p |
0f2d19dd | 94 | { |
2c0b7c1f | 95 | return srfi13_cmp (s1, s2, scm_string_gt); |
0f2d19dd | 96 | } |
6e8d25a6 | 97 | #undef FUNC_NAME |
0f2d19dd | 98 | |
c3ee7520 | 99 | SCM_DEFINE1 (scm_string_geq_p, "string>=?", scm_tc7_rpsubr, |
6e8d25a6 | 100 | (SCM s1, SCM s2), |
1e6808ea MG |
101 | "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n" |
102 | "is lexicographically greater than or equal to @var{s2}.") | |
6e8d25a6 | 103 | #define FUNC_NAME s_scm_string_geq_p |
0f2d19dd | 104 | { |
2c0b7c1f | 105 | return srfi13_cmp (s1, s2, scm_string_ge); |
0f2d19dd | 106 | } |
6e8d25a6 | 107 | #undef FUNC_NAME |
0f2d19dd | 108 | |
3ba5a6c2 DH |
109 | SCM_DEFINE1 (scm_string_ci_less_p, "string-ci<?", scm_tc7_rpsubr, |
110 | (SCM s1, SCM s2), | |
1e6808ea MG |
111 | "Case insensitive lexicographic ordering predicate; return\n" |
112 | "@code{#t} if @var{s1} is lexicographically less than @var{s2}\n" | |
113 | "regardless of case.") | |
3ba5a6c2 DH |
114 | #define FUNC_NAME s_scm_string_ci_less_p |
115 | { | |
2c0b7c1f | 116 | return srfi13_cmp (s1, s2, scm_string_ci_lt); |
3ba5a6c2 | 117 | } |
6e8d25a6 | 118 | #undef FUNC_NAME |
0f2d19dd | 119 | |
c3ee7520 | 120 | SCM_DEFINE1 (scm_string_ci_leq_p, "string-ci<=?", scm_tc7_rpsubr, |
6e8d25a6 | 121 | (SCM s1, SCM s2), |
1e6808ea MG |
122 | "Case insensitive lexicographic ordering predicate; return\n" |
123 | "@code{#t} if @var{s1} is lexicographically less than or equal\n" | |
124 | "to @var{s2} regardless of case.") | |
6e8d25a6 | 125 | #define FUNC_NAME s_scm_string_ci_leq_p |
0f2d19dd | 126 | { |
2c0b7c1f | 127 | return srfi13_cmp (s1, s2, scm_string_ci_le); |
0f2d19dd | 128 | } |
6e8d25a6 | 129 | #undef FUNC_NAME |
0f2d19dd | 130 | |
c3ee7520 | 131 | SCM_DEFINE1 (scm_string_ci_gr_p, "string-ci>?", scm_tc7_rpsubr, |
6e8d25a6 | 132 | (SCM s1, SCM s2), |
1e6808ea MG |
133 | "Case insensitive lexicographic ordering predicate; return\n" |
134 | "@code{#t} if @var{s1} is lexicographically greater than\n" | |
135 | "@var{s2} regardless of case.") | |
6e8d25a6 | 136 | #define FUNC_NAME s_scm_string_ci_gr_p |
0f2d19dd | 137 | { |
2c0b7c1f | 138 | return srfi13_cmp (s1, s2, scm_string_ci_gt); |
0f2d19dd | 139 | } |
6e8d25a6 | 140 | #undef FUNC_NAME |
0f2d19dd | 141 | |
c3ee7520 | 142 | SCM_DEFINE1 (scm_string_ci_geq_p, "string-ci>=?", scm_tc7_rpsubr, |
6e8d25a6 | 143 | (SCM s1, SCM s2), |
1e6808ea MG |
144 | "Case insensitive lexicographic ordering predicate; return\n" |
145 | "@code{#t} if @var{s1} is lexicographically greater than or\n" | |
146 | "equal to @var{s2} regardless of case.") | |
6e8d25a6 | 147 | #define FUNC_NAME s_scm_string_ci_geq_p |
0f2d19dd | 148 | { |
2c0b7c1f | 149 | return srfi13_cmp (s1, s2, scm_string_ci_ge); |
0f2d19dd | 150 | } |
6e8d25a6 | 151 | #undef FUNC_NAME |
0f2d19dd JB |
152 | |
153 | \f | |
1cc91f1b | 154 | |
0f2d19dd JB |
155 | void |
156 | scm_init_strorder () | |
0f2d19dd | 157 | { |
a0599745 | 158 | #include "libguile/strorder.x" |
0f2d19dd JB |
159 | } |
160 | ||
89e00824 ML |
161 | |
162 | /* | |
163 | Local Variables: | |
164 | c-file-style: "gnu" | |
165 | End: | |
166 | */ |