2006-04-17 00:05:42 +00:00
|
|
|
|
/* Copyright (C) 1995,1996,1998, 2000, 2001, 2004, 2006 Free Software Foundation, Inc.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2005-05-23 19:57:22 +00:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <ctype.h>
|
2004-04-24 22:03:28 +00:00
|
|
|
|
#include <limits.h>
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
|
|
|
|
|
#include "libguile/validate.h"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/chars.h"
|
2004-08-24 22:12:59 +00:00
|
|
|
|
#include "libguile/srfi-14.h"
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_char_p, "char?", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is a character, else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (SCM_CHARP(x));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-06 19:51:45 +00:00
|
|
|
|
SCM_DEFINE1 (scm_char_eq_p, "char=?", scm_tc7_rpsubr,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM y),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is the same character as @var{y}, else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_eq_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-12-04 17:19:35 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, x);
|
|
|
|
|
|
SCM_VALIDATE_CHAR (2, y);
|
2004-07-27 15:41:49 +00:00
|
|
|
|
return scm_from_bool (scm_is_eq (x, y));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-06 19:51:45 +00:00
|
|
|
|
SCM_DEFINE1 (scm_char_less_p, "char<?", scm_tc7_rpsubr,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM y),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is less than @var{y} in the ASCII sequence,\n"
|
|
|
|
|
|
"else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_less_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, x);
|
|
|
|
|
|
SCM_VALIDATE_CHAR (2, y);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (SCM_CHAR(x) < SCM_CHAR(y));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-06 19:51:45 +00:00
|
|
|
|
SCM_DEFINE1 (scm_char_leq_p, "char<=?", scm_tc7_rpsubr,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM y),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is less than or equal to @var{y} in the\n"
|
|
|
|
|
|
"ASCII sequence, else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_leq_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, x);
|
|
|
|
|
|
SCM_VALIDATE_CHAR (2, y);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (SCM_CHAR(x) <= SCM_CHAR(y));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-06 19:51:45 +00:00
|
|
|
|
SCM_DEFINE1 (scm_char_gr_p, "char>?", scm_tc7_rpsubr,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM y),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII\n"
|
|
|
|
|
|
"sequence, else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_gr_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, x);
|
|
|
|
|
|
SCM_VALIDATE_CHAR (2, y);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (SCM_CHAR(x) > SCM_CHAR(y));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-06 19:51:45 +00:00
|
|
|
|
SCM_DEFINE1 (scm_char_geq_p, "char>=?", scm_tc7_rpsubr,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM y),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the\n"
|
|
|
|
|
|
"ASCII sequence, else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_geq_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, x);
|
|
|
|
|
|
SCM_VALIDATE_CHAR (2, y);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (SCM_CHAR(x) >= SCM_CHAR(y));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-06 19:51:45 +00:00
|
|
|
|
SCM_DEFINE1 (scm_char_ci_eq_p, "char-ci=?", scm_tc7_rpsubr,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM y),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is the same character as @var{y} ignoring\n"
|
|
|
|
|
|
"case, else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_ci_eq_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, x);
|
|
|
|
|
|
SCM_VALIDATE_CHAR (2, y);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (scm_c_upcase(SCM_CHAR(x))==scm_c_upcase(SCM_CHAR(y)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-06 19:51:45 +00:00
|
|
|
|
SCM_DEFINE1 (scm_char_ci_less_p, "char-ci<?", scm_tc7_rpsubr,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM y),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is less than @var{y} in the ASCII sequence\n"
|
|
|
|
|
|
"ignoring case, else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_ci_less_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, x);
|
|
|
|
|
|
SCM_VALIDATE_CHAR (2, y);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool ((scm_c_upcase(SCM_CHAR(x))) < scm_c_upcase(SCM_CHAR(y)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-06 19:51:45 +00:00
|
|
|
|
SCM_DEFINE1 (scm_char_ci_leq_p, "char-ci<=?", scm_tc7_rpsubr,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM y),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is less than or equal to @var{y} in the\n"
|
|
|
|
|
|
"ASCII sequence ignoring case, else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_ci_leq_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, x);
|
|
|
|
|
|
SCM_VALIDATE_CHAR (2, y);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (scm_c_upcase(SCM_CHAR(x)) <= scm_c_upcase(SCM_CHAR(y)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-06 19:51:45 +00:00
|
|
|
|
SCM_DEFINE1 (scm_char_ci_gr_p, "char-ci>?", scm_tc7_rpsubr,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM y),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is greater than @var{y} in the ASCII\n"
|
|
|
|
|
|
"sequence ignoring case, else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_ci_gr_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, x);
|
|
|
|
|
|
SCM_VALIDATE_CHAR (2, y);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (scm_c_upcase(SCM_CHAR(x)) > scm_c_upcase(SCM_CHAR(y)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-06 19:51:45 +00:00
|
|
|
|
SCM_DEFINE1 (scm_char_ci_geq_p, "char-ci>=?", scm_tc7_rpsubr,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM y),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is greater than or equal to @var{y} in the\n"
|
|
|
|
|
|
"ASCII sequence ignoring case, else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_ci_geq_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, x);
|
|
|
|
|
|
SCM_VALIDATE_CHAR (2, y);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (scm_c_upcase(SCM_CHAR(x)) >= scm_c_upcase(SCM_CHAR(y)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_char_alphabetic_p, "char-alphabetic?", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM chr),
|
2004-08-24 22:12:59 +00:00
|
|
|
|
"Return @code{#t} iff @var{chr} is alphabetic, else @code{#f}.\n")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_alphabetic_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2004-08-24 22:12:59 +00:00
|
|
|
|
return scm_char_set_contains_p (scm_char_set_letter, chr);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_char_numeric_p, "char-numeric?", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM chr),
|
2004-08-24 22:12:59 +00:00
|
|
|
|
"Return @code{#t} iff @var{chr} is numeric, else @code{#f}.\n")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_numeric_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2004-08-24 22:12:59 +00:00
|
|
|
|
return scm_char_set_contains_p (scm_char_set_digit, chr);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_char_whitespace_p, "char-whitespace?", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM chr),
|
2004-08-24 22:12:59 +00:00
|
|
|
|
"Return @code{#t} iff @var{chr} is whitespace, else @code{#f}.\n")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_whitespace_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2004-08-24 22:12:59 +00:00
|
|
|
|
return scm_char_set_contains_p (scm_char_set_whitespace, chr);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_char_upper_case_p, "char-upper-case?", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM chr),
|
2004-08-24 22:12:59 +00:00
|
|
|
|
"Return @code{#t} iff @var{chr} is uppercase, else @code{#f}.\n")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_upper_case_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2004-08-24 22:12:59 +00:00
|
|
|
|
return scm_char_set_contains_p (scm_char_set_upper_case, chr);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_char_lower_case_p, "char-lower-case?", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM chr),
|
2004-08-24 22:12:59 +00:00
|
|
|
|
"Return @code{#t} iff @var{chr} is lowercase, else @code{#f}.\n")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_lower_case_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2004-08-24 22:12:59 +00:00
|
|
|
|
return scm_char_set_contains_p (scm_char_set_lower_case, chr);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_char_is_both_p, "char-is-both?", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM chr),
|
2004-08-24 22:12:59 +00:00
|
|
|
|
"Return @code{#t} iff @var{chr} is either uppercase or lowercase, else @code{#f}.\n")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_is_both_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2004-08-24 22:12:59 +00:00
|
|
|
|
if (scm_is_true (scm_char_set_contains_p (scm_char_set_lower_case, chr)))
|
|
|
|
|
|
return SCM_BOOL_T;
|
|
|
|
|
|
return scm_char_set_contains_p (scm_char_set_upper_case, chr);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_char_to_integer, "char->integer", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM chr),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return the number corresponding to ordinal position of @var{chr} in the\n"
|
|
|
|
|
|
"ASCII sequence.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_to_integer
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, chr);
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
return scm_from_ulong (SCM_CHAR(chr));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_integer_to_char, "integer->char", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM n),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return the character at position @var{n} in the ASCII sequence.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_integer_to_char
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
return SCM_MAKE_CHAR (scm_to_uchar (n));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_char_upcase, "char-upcase", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM chr),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return the uppercase character version of @var{chr}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_upcase
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, chr);
|
2004-04-24 22:03:28 +00:00
|
|
|
|
return SCM_MAKE_CHAR (toupper (SCM_CHAR (chr)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_char_downcase, "char-downcase", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM chr),
|
2000-08-18 09:30:54 +00:00
|
|
|
|
"Return the lowercase character version of @var{chr}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_char_downcase
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_CHAR (1, chr);
|
2004-04-24 22:03:28 +00:00
|
|
|
|
return SCM_MAKE_CHAR (tolower (SCM_CHAR(chr)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-04-06 21:48:02 +00:00
|
|
|
|
/*
|
|
|
|
|
|
TODO: change name to scm_i_.. ? --hwn
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
int
|
2004-04-06 21:48:02 +00:00
|
|
|
|
scm_c_upcase (unsigned int c)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2004-04-24 22:03:28 +00:00
|
|
|
|
if (c <= UCHAR_MAX)
|
|
|
|
|
|
return toupper (c);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
else
|
|
|
|
|
|
return c;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
int
|
2004-04-06 21:48:02 +00:00
|
|
|
|
scm_c_downcase (unsigned int c)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2004-04-24 22:03:28 +00:00
|
|
|
|
if (c <= UCHAR_MAX)
|
|
|
|
|
|
return tolower (c);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
else
|
|
|
|
|
|
return c;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _DCC
|
|
|
|
|
|
# define ASCII
|
|
|
|
|
|
#else
|
|
|
|
|
|
# if (('\n'=='\025') && (' '=='\100') && ('a'=='\201') && ('A'=='\301'))
|
|
|
|
|
|
# define EBCDIC
|
|
|
|
|
|
# endif /* (('\n'=='\025') && (' '=='\100') && ('a'=='\201') && ('A'=='\301')) */
|
|
|
|
|
|
# if (('\n'=='\012') && (' '=='\040') && ('a'=='\141') && ('A'=='\101'))
|
|
|
|
|
|
# define ASCII
|
|
|
|
|
|
# endif /* (('\n'=='\012') && (' '=='\040') && ('a'=='\141') && ('A'=='\101')) */
|
|
|
|
|
|
#endif /* def _DCC */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef EBCDIC
|
* chars.c (scm_lowers, scm_uppers, scm_charnames, scm_charnums),
eval.c (s_expression, s_test, s_body, s_bindings, s_variable,
s_clauses, s_formals): Variables now const.
1999-02-06 12:28:45 +00:00
|
|
|
|
char *const scm_charnames[] =
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
"nul", "soh", "stx", "etx", "pf", "ht", "lc", "del",
|
|
|
|
|
|
0 , 0 , "smm", "vt", "ff", "cr", "so", "si",
|
|
|
|
|
|
"dle", "dc1", "dc2", "dc3", "res", "nl", "bs", "il",
|
|
|
|
|
|
"can", "em", "cc", 0 , "ifs", "igs", "irs", "ius",
|
|
|
|
|
|
"ds", "sos", "fs", 0 , "byp", "lf", "eob", "pre",
|
|
|
|
|
|
0 , 0 , "sm", 0 , 0 , "enq", "ack", "bel",
|
|
|
|
|
|
0 , 0 , "syn", 0 , "pn", "rs", "uc", "eot",
|
|
|
|
|
|
0 , 0 , 0 , 0 , "dc4", "nak", 0 , "sub",
|
1996-07-25 22:56:11 +00:00
|
|
|
|
"space", scm_s_newline, "tab", "backspace", "return", "page", "null"};
|
|
|
|
|
|
|
* chars.c (scm_lowers, scm_uppers, scm_charnames, scm_charnums),
eval.c (s_expression, s_test, s_body, s_bindings, s_variable,
s_clauses, s_formals): Variables now const.
1999-02-06 12:28:45 +00:00
|
|
|
|
const char scm_charnums[] =
|
1996-07-25 22:56:11 +00:00
|
|
|
|
"\000\001\002\003\004\005\006\007\
|
|
|
|
|
|
\010\011\012\013\014\015\016\017\
|
|
|
|
|
|
\020\021\022\023\024\025\026\027\
|
|
|
|
|
|
\030\031\032\033\034\035\036\037\
|
|
|
|
|
|
\040\041\042\043\044\045\046\047\
|
|
|
|
|
|
\050\051\052\053\054\055\056\057\
|
|
|
|
|
|
\060\061\062\063\064\065\066\067\
|
|
|
|
|
|
\070\071\072\073\074\075\076\077\
|
|
|
|
|
|
\n\t\b\r\f\0";
|
|
|
|
|
|
#endif /* def EBCDIC */
|
|
|
|
|
|
#ifdef ASCII
|
* chars.c (scm_lowers, scm_uppers, scm_charnames, scm_charnums),
eval.c (s_expression, s_test, s_body, s_bindings, s_variable,
s_clauses, s_formals): Variables now const.
1999-02-06 12:28:45 +00:00
|
|
|
|
char *const scm_charnames[] =
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
"nul","soh","stx","etx","eot","enq","ack","bel",
|
1998-10-18 19:55:39 +00:00
|
|
|
|
"bs", "ht", "newline", "vt", "np", "cr", "so", "si",
|
1996-07-25 22:56:11 +00:00
|
|
|
|
"dle","dc1","dc2","dc3","dc4","nak","syn","etb",
|
|
|
|
|
|
"can", "em","sub","esc", "fs", "gs", "rs", "us",
|
2004-11-04 17:08:26 +00:00
|
|
|
|
"space", "sp", "nl", "tab", "backspace", "return", "page", "null", "del"};
|
* chars.c (scm_lowers, scm_uppers, scm_charnames, scm_charnums),
eval.c (s_expression, s_test, s_body, s_bindings, s_variable,
s_clauses, s_formals): Variables now const.
1999-02-06 12:28:45 +00:00
|
|
|
|
const char scm_charnums[] =
|
1996-07-25 22:56:11 +00:00
|
|
|
|
"\000\001\002\003\004\005\006\007\
|
|
|
|
|
|
\010\011\012\013\014\015\016\017\
|
|
|
|
|
|
\020\021\022\023\024\025\026\027\
|
|
|
|
|
|
\030\031\032\033\034\035\036\037\
|
2004-11-04 17:08:26 +00:00
|
|
|
|
\n\t\b\r\f\0\177";
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#endif /* def ASCII */
|
|
|
|
|
|
|
|
|
|
|
|
int scm_n_charnames = sizeof (scm_charnames) / sizeof (char *);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_init_chars ()
|
|
|
|
|
|
{
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/chars.x"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|