mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 14:50:19 +02:00
(scm_char_upcase, scm_char_downcase, scm_c_upcase,
scm_c_downcase): Use ctype.h toupper and tolower. This will be useful in 8-bit locales, and ensures consistency with char-upper-case? and char-lower-case? which already use ctype.h. (scm_c_upcase_table, scm_c_downcase_table, scm_lowers, scm_uppers): Remove. (scm_tables_prehistory): Remove.
This commit is contained in:
parent
4d81111ebd
commit
465380de00
1 changed files with 8 additions and 26 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 1995,1996,1998, 2000, 2001 Free Software Foundation, Inc.
|
/* Copyright (C) 1995,1996,1998, 2000, 2001, 2004 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <limits.h>
|
||||||
#include "libguile/_scm.h"
|
#include "libguile/_scm.h"
|
||||||
#include "libguile/validate.h"
|
#include "libguile/validate.h"
|
||||||
|
|
||||||
|
@ -260,7 +261,7 @@ SCM_DEFINE (scm_char_upcase, "char-upcase", 1, 0, 0,
|
||||||
#define FUNC_NAME s_scm_char_upcase
|
#define FUNC_NAME s_scm_char_upcase
|
||||||
{
|
{
|
||||||
SCM_VALIDATE_CHAR (1, chr);
|
SCM_VALIDATE_CHAR (1, chr);
|
||||||
return SCM_MAKE_CHAR(scm_c_upcase (SCM_CHAR(chr)));
|
return SCM_MAKE_CHAR (toupper (SCM_CHAR (chr)));
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
@ -271,7 +272,7 @@ SCM_DEFINE (scm_char_downcase, "char-downcase", 1, 0, 0,
|
||||||
#define FUNC_NAME s_scm_char_downcase
|
#define FUNC_NAME s_scm_char_downcase
|
||||||
{
|
{
|
||||||
SCM_VALIDATE_CHAR (1, chr);
|
SCM_VALIDATE_CHAR (1, chr);
|
||||||
return SCM_MAKE_CHAR(scm_c_downcase (SCM_CHAR(chr)));
|
return SCM_MAKE_CHAR (tolower (SCM_CHAR(chr)));
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
@ -279,25 +280,6 @@ SCM_DEFINE (scm_char_downcase, "char-downcase", 1, 0, 0,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned char scm_c_upcase_table[SCM_CHAR_CODE_LIMIT];
|
|
||||||
static unsigned char scm_c_downcase_table[SCM_CHAR_CODE_LIMIT];
|
|
||||||
static const unsigned char scm_lowers[] = "abcdefghijklmnopqrstuvwxyz";
|
|
||||||
static const unsigned char scm_uppers[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
scm_tables_prehistory ()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < SCM_CHAR_CODE_LIMIT; i++)
|
|
||||||
scm_c_upcase_table[i] = scm_c_downcase_table[i] = i;
|
|
||||||
for (i = 0; i < (int) (sizeof scm_lowers / sizeof (scm_lowers[0])); i++)
|
|
||||||
{
|
|
||||||
scm_c_upcase_table[scm_lowers[i]] = scm_uppers[i];
|
|
||||||
scm_c_downcase_table[scm_uppers[i]] = scm_lowers[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: change name to scm_i_.. ? --hwn
|
TODO: change name to scm_i_.. ? --hwn
|
||||||
*/
|
*/
|
||||||
|
@ -306,8 +288,8 @@ TODO: change name to scm_i_.. ? --hwn
|
||||||
int
|
int
|
||||||
scm_c_upcase (unsigned int c)
|
scm_c_upcase (unsigned int c)
|
||||||
{
|
{
|
||||||
if (c < sizeof (scm_c_upcase_table))
|
if (c <= UCHAR_MAX)
|
||||||
return scm_c_upcase_table[c];
|
return toupper (c);
|
||||||
else
|
else
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -316,8 +298,8 @@ scm_c_upcase (unsigned int c)
|
||||||
int
|
int
|
||||||
scm_c_downcase (unsigned int c)
|
scm_c_downcase (unsigned int c)
|
||||||
{
|
{
|
||||||
if (c < sizeof (scm_c_downcase_table))
|
if (c <= UCHAR_MAX)
|
||||||
return scm_c_downcase_table[c];
|
return tolower (c);
|
||||||
else
|
else
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue