1 /* Copyright (C) 1995, 1996, 1999, 2000, 2004, 2006, 2008 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
23 #include "libguile/_scm.h"
24 #include "libguile/chars.h"
25 #include "libguile/strings.h"
26 #include "libguile/symbols.h"
28 #include "libguile/validate.h"
29 #include "libguile/strorder.h"
30 #include "libguile/srfi-13.h"
33 SCM_C_INLINE_KEYWORD
static SCM
34 srfi13_cmp (SCM s1
, SCM s2
, SCM (*cmp
) (SCM
, SCM
, SCM
, SCM
, SCM
, SCM
))
36 if (scm_is_true (cmp (s1
, s2
,
37 SCM_UNDEFINED
, SCM_UNDEFINED
,
38 SCM_UNDEFINED
, SCM_UNDEFINED
)))
44 SCM_DEFINE1 (scm_string_equal_p
, "string=?", scm_tc7_rpsubr
,
46 "Lexicographic equality predicate; return @code{#t} if the two\n"
47 "strings are the same length and contain the same characters in\n"
48 "the same positions, otherwise return @code{#f}.\n"
50 "The procedure @code{string-ci=?} treats upper and lower case\n"
51 "letters as though they were the same character, but\n"
52 "@code{string=?} treats upper and lower case as distinct\n"
54 #define FUNC_NAME s_scm_string_equal_p
56 return srfi13_cmp (s1
, s2
, scm_string_eq
);
60 SCM_DEFINE1 (scm_string_ci_equal_p
, "string-ci=?", scm_tc7_rpsubr
,
62 "Case-insensitive string equality predicate; return @code{#t} if\n"
63 "the two strings are the same length and their component\n"
64 "characters match (ignoring case) at each position; otherwise\n"
66 #define FUNC_NAME s_scm_string_ci_equal_p
68 return srfi13_cmp (s1
, s2
, scm_string_ci_eq
);
72 SCM_DEFINE1 (scm_string_less_p
, "string<?", scm_tc7_rpsubr
,
74 "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n"
75 "is lexicographically less than @var{s2}.")
76 #define FUNC_NAME s_scm_string_less_p
78 return srfi13_cmp (s1
, s2
, scm_string_lt
);
82 SCM_DEFINE1 (scm_string_leq_p
, "string<=?", scm_tc7_rpsubr
,
84 "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n"
85 "is lexicographically less than or equal to @var{s2}.")
86 #define FUNC_NAME s_scm_string_leq_p
88 return srfi13_cmp (s1
, s2
, scm_string_le
);
92 SCM_DEFINE1 (scm_string_gr_p
, "string>?", scm_tc7_rpsubr
,
94 "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n"
95 "is lexicographically greater than @var{s2}.")
96 #define FUNC_NAME s_scm_string_gr_p
98 return srfi13_cmp (s1
, s2
, scm_string_gt
);
102 SCM_DEFINE1 (scm_string_geq_p
, "string>=?", scm_tc7_rpsubr
,
104 "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n"
105 "is lexicographically greater than or equal to @var{s2}.")
106 #define FUNC_NAME s_scm_string_geq_p
108 return srfi13_cmp (s1
, s2
, scm_string_ge
);
112 SCM_DEFINE1 (scm_string_ci_less_p
, "string-ci<?", scm_tc7_rpsubr
,
114 "Case insensitive lexicographic ordering predicate; return\n"
115 "@code{#t} if @var{s1} is lexicographically less than @var{s2}\n"
116 "regardless of case.")
117 #define FUNC_NAME s_scm_string_ci_less_p
119 return srfi13_cmp (s1
, s2
, scm_string_ci_lt
);
123 SCM_DEFINE1 (scm_string_ci_leq_p
, "string-ci<=?", scm_tc7_rpsubr
,
125 "Case insensitive lexicographic ordering predicate; return\n"
126 "@code{#t} if @var{s1} is lexicographically less than or equal\n"
127 "to @var{s2} regardless of case.")
128 #define FUNC_NAME s_scm_string_ci_leq_p
130 return srfi13_cmp (s1
, s2
, scm_string_ci_le
);
134 SCM_DEFINE1 (scm_string_ci_gr_p
, "string-ci>?", scm_tc7_rpsubr
,
136 "Case insensitive lexicographic ordering predicate; return\n"
137 "@code{#t} if @var{s1} is lexicographically greater than\n"
138 "@var{s2} regardless of case.")
139 #define FUNC_NAME s_scm_string_ci_gr_p
141 return srfi13_cmp (s1
, s2
, scm_string_ci_gt
);
145 SCM_DEFINE1 (scm_string_ci_geq_p
, "string-ci>=?", scm_tc7_rpsubr
,
147 "Case insensitive lexicographic ordering predicate; return\n"
148 "@code{#t} if @var{s1} is lexicographically greater than or\n"
149 "equal to @var{s2} regardless of case.")
150 #define FUNC_NAME s_scm_string_ci_geq_p
152 return srfi13_cmp (s1
, s2
, scm_string_ci_ge
);
161 #include "libguile/strorder.x"