1 /* Copyright (C) 1995, 1996, 1999, 2000, 2004 Free Software Foundation, Inc.
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.
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.
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
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "libguile/_scm.h"
21 #include "libguile/chars.h"
22 #include "libguile/strings.h"
23 #include "libguile/symbols.h"
25 #include "libguile/validate.h"
26 #include "libguile/strorder.h"
27 #include "libguile/srfi-13.h"
30 SCM_C_INLINE_KEYWORD
static SCM
31 srfi13_cmp (SCM s1
, SCM s2
, SCM (*cmp
) (SCM
, SCM
, SCM
, SCM
, SCM
, SCM
))
33 if (scm_is_true (cmp (s1
, s2
,
34 SCM_UNDEFINED
, SCM_UNDEFINED
,
35 SCM_UNDEFINED
, SCM_UNDEFINED
)))
41 SCM_DEFINE1 (scm_string_equal_p
, "string=?", scm_tc7_rpsubr
,
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"
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"
51 #define FUNC_NAME s_scm_string_equal_p
53 return srfi13_cmp (s1
, s2
, scm_string_eq
);
57 SCM_DEFINE1 (scm_string_ci_equal_p
, "string-ci=?", scm_tc7_rpsubr
,
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"
63 #define FUNC_NAME s_scm_string_ci_equal_p
65 return srfi13_cmp (s1
, s2
, scm_string_ci_eq
);
69 SCM_DEFINE1 (scm_string_less_p
, "string<?", scm_tc7_rpsubr
,
71 "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n"
72 "is lexicographically less than @var{s2}.")
73 #define FUNC_NAME s_scm_string_less_p
75 return srfi13_cmp (s1
, s2
, scm_string_lt
);
79 SCM_DEFINE1 (scm_string_leq_p
, "string<=?", scm_tc7_rpsubr
,
81 "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n"
82 "is lexicographically less than or equal to @var{s2}.")
83 #define FUNC_NAME s_scm_string_leq_p
85 return srfi13_cmp (s1
, s2
, scm_string_le
);
89 SCM_DEFINE1 (scm_string_gr_p
, "string>?", scm_tc7_rpsubr
,
91 "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n"
92 "is lexicographically greater than @var{s2}.")
93 #define FUNC_NAME s_scm_string_gr_p
95 return srfi13_cmp (s1
, s2
, scm_string_gt
);
99 SCM_DEFINE1 (scm_string_geq_p
, "string>=?", scm_tc7_rpsubr
,
101 "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n"
102 "is lexicographically greater than or equal to @var{s2}.")
103 #define FUNC_NAME s_scm_string_geq_p
105 return srfi13_cmp (s1
, s2
, scm_string_ge
);
109 SCM_DEFINE1 (scm_string_ci_less_p
, "string-ci<?", scm_tc7_rpsubr
,
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.")
114 #define FUNC_NAME s_scm_string_ci_less_p
116 return srfi13_cmp (s1
, s2
, scm_string_ci_lt
);
120 SCM_DEFINE1 (scm_string_ci_leq_p
, "string-ci<=?", scm_tc7_rpsubr
,
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.")
125 #define FUNC_NAME s_scm_string_ci_leq_p
127 return srfi13_cmp (s1
, s2
, scm_string_ci_le
);
131 SCM_DEFINE1 (scm_string_ci_gr_p
, "string-ci>?", scm_tc7_rpsubr
,
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.")
136 #define FUNC_NAME s_scm_string_ci_gr_p
138 return srfi13_cmp (s1
, s2
, scm_string_ci_gt
);
142 SCM_DEFINE1 (scm_string_ci_geq_p
, "string-ci>=?", scm_tc7_rpsubr
,
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.")
147 #define FUNC_NAME s_scm_string_ci_geq_p
149 return srfi13_cmp (s1
, s2
, scm_string_ci_ge
);
158 #include "libguile/strorder.x"