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 License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * 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
24 #include "libguile/_scm.h"
25 #include "libguile/chars.h"
26 #include "libguile/strings.h"
27 #include "libguile/symbols.h"
29 #include "libguile/validate.h"
30 #include "libguile/strorder.h"
31 #include "libguile/srfi-13.h"
34 SCM_C_INLINE_KEYWORD
static SCM
35 srfi13_cmp (SCM s1
, SCM s2
, SCM (*cmp
) (SCM
, SCM
, SCM
, SCM
, SCM
, SCM
))
37 if (scm_is_true (cmp (s1
, s2
,
38 SCM_UNDEFINED
, SCM_UNDEFINED
,
39 SCM_UNDEFINED
, SCM_UNDEFINED
)))
45 SCM_DEFINE1 (scm_string_equal_p
, "string=?", scm_tc7_rpsubr
,
47 "Lexicographic equality predicate; return @code{#t} if the two\n"
48 "strings are the same length and contain the same characters in\n"
49 "the same positions, otherwise return @code{#f}.\n"
51 "The procedure @code{string-ci=?} treats upper and lower case\n"
52 "letters as though they were the same character, but\n"
53 "@code{string=?} treats upper and lower case as distinct\n"
55 #define FUNC_NAME s_scm_string_equal_p
57 return srfi13_cmp (s1
, s2
, scm_string_eq
);
61 SCM_DEFINE1 (scm_string_ci_equal_p
, "string-ci=?", scm_tc7_rpsubr
,
63 "Case-insensitive string equality predicate; return @code{#t} if\n"
64 "the two strings are the same length and their component\n"
65 "characters match (ignoring case) at each position; otherwise\n"
67 #define FUNC_NAME s_scm_string_ci_equal_p
69 return srfi13_cmp (s1
, s2
, scm_string_ci_eq
);
73 SCM_DEFINE1 (scm_string_less_p
, "string<?", scm_tc7_rpsubr
,
75 "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n"
76 "is lexicographically less than @var{s2}.")
77 #define FUNC_NAME s_scm_string_less_p
79 return srfi13_cmp (s1
, s2
, scm_string_lt
);
83 SCM_DEFINE1 (scm_string_leq_p
, "string<=?", scm_tc7_rpsubr
,
85 "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n"
86 "is lexicographically less than or equal to @var{s2}.")
87 #define FUNC_NAME s_scm_string_leq_p
89 return srfi13_cmp (s1
, s2
, scm_string_le
);
93 SCM_DEFINE1 (scm_string_gr_p
, "string>?", scm_tc7_rpsubr
,
95 "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n"
96 "is lexicographically greater than @var{s2}.")
97 #define FUNC_NAME s_scm_string_gr_p
99 return srfi13_cmp (s1
, s2
, scm_string_gt
);
103 SCM_DEFINE1 (scm_string_geq_p
, "string>=?", scm_tc7_rpsubr
,
105 "Lexicographic ordering predicate; return @code{#t} if @var{s1}\n"
106 "is lexicographically greater than or equal to @var{s2}.")
107 #define FUNC_NAME s_scm_string_geq_p
109 return srfi13_cmp (s1
, s2
, scm_string_ge
);
113 SCM_DEFINE1 (scm_string_ci_less_p
, "string-ci<?", scm_tc7_rpsubr
,
115 "Case insensitive lexicographic ordering predicate; return\n"
116 "@code{#t} if @var{s1} is lexicographically less than @var{s2}\n"
117 "regardless of case.")
118 #define FUNC_NAME s_scm_string_ci_less_p
120 return srfi13_cmp (s1
, s2
, scm_string_ci_lt
);
124 SCM_DEFINE1 (scm_string_ci_leq_p
, "string-ci<=?", scm_tc7_rpsubr
,
126 "Case insensitive lexicographic ordering predicate; return\n"
127 "@code{#t} if @var{s1} is lexicographically less than or equal\n"
128 "to @var{s2} regardless of case.")
129 #define FUNC_NAME s_scm_string_ci_leq_p
131 return srfi13_cmp (s1
, s2
, scm_string_ci_le
);
135 SCM_DEFINE1 (scm_string_ci_gr_p
, "string-ci>?", scm_tc7_rpsubr
,
137 "Case insensitive lexicographic ordering predicate; return\n"
138 "@code{#t} if @var{s1} is lexicographically greater than\n"
139 "@var{s2} regardless of case.")
140 #define FUNC_NAME s_scm_string_ci_gr_p
142 return srfi13_cmp (s1
, s2
, scm_string_ci_gt
);
146 SCM_DEFINE1 (scm_string_ci_geq_p
, "string-ci>=?", scm_tc7_rpsubr
,
148 "Case insensitive lexicographic ordering predicate; return\n"
149 "@code{#t} if @var{s1} is lexicographically greater than or\n"
150 "equal to @var{s2} regardless of case.")
151 #define FUNC_NAME s_scm_string_ci_geq_p
153 return srfi13_cmp (s1
, s2
, scm_string_ci_ge
);
162 #include "libguile/strorder.x"