Commit 0b1b8180 authored by Erick's avatar Erick

Added comparison functions for UTF-8 strings

parent 40f3abbe
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.67 for stklos 1.01.
# Generated by GNU Autoconf 2.67 for stklos 1.10.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
......@@ -549,8 +549,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='stklos'
PACKAGE_TARNAME='stklos'
PACKAGE_VERSION='1.01'
PACKAGE_STRING='stklos 1.01'
PACKAGE_VERSION='1.10'
PACKAGE_STRING='stklos 1.10'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
......@@ -1288,7 +1288,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures stklos 1.01 to adapt to many kinds of systems.
\`configure' configures stklos 1.10 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1354,7 +1354,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of stklos 1.01:";;
short | recursive ) echo "Configuration of stklos 1.10:";;
esac
cat <<\_ACEOF
......@@ -1451,7 +1451,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
stklos configure 1.01
stklos configure 1.10
generated by GNU Autoconf 2.67
Copyright (C) 2010 Free Software Foundation, Inc.
......@@ -1870,7 +1870,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by stklos $as_me 1.01, which was
It was created by stklos $as_me 1.10, which was
generated by GNU Autoconf 2.67. Invocation command line was
$ $0 $@
......@@ -2688,7 +2688,7 @@ fi
# Define the identity of the package.
PACKAGE='stklos'
VERSION='1.01'
VERSION='1.10'
cat >>confdefs.h <<_ACEOF
......@@ -6999,7 +6999,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by stklos $as_me 1.01, which was
This file was extended by stklos $as_me 1.10, which was
generated by GNU Autoconf 2.67. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -7065,7 +7065,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
stklos config.status 1.01
stklos config.status 1.10
configured by $0, generated by GNU Autoconf 2.67,
with options \\"\$ac_cs_config\\"
......
......@@ -2,10 +2,10 @@
###
### Author: Erick Gallesio [eg@unice.fr]
### Creation date: 28-Dec-1999 21:19 (eg)
### Last file update: 23-Apr-2011 21:49 (eg)
### Last file update: 27-Jul-2011 23:01 (eg)
AC_PREREQ(2.64)
AC_INIT([stklos], [1.01])
AC_INIT([stklos], [1.10])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR(src/stklos.c)
AC_CONFIG_HEADERS(src/stklosconf.h)
......
......@@ -22,7 +22,7 @@
*
* Author: Erick Gallesio [eg@unice.fr]
* Creation date: ??????
* Last file update: 27-Jul-2011 17:02 (eg)
* Last file update: 27-Jul-2011 23:27 (eg)
*/
#include <ctype.h>
......@@ -59,42 +59,90 @@ static void error_index_out_of_bound(SCM str, SCM index)
STk_error("index ~S out of bound in string ~S", index, str);
}
static void error_bad_sequence(SCM str)
{
STk_error("bad UTF-8 sequence in ~S", str);
}
static int stringcomp(SCM s1, SCM s2)
{
register int l1, l2;
register char *str1, *str2;
if (!STRINGP(s1)) error_bad_string(s1);
if (!STRINGP(s2)) error_bad_string(s2);
for (l1=STRING_SIZE(s1), str1=STRING_CHARS(s1),
if (STk_use_utf8 && (!STRING_MONOBYTE(s1) || !STRING_MONOBYTE(s2))) {
/* At least one string is multi-bytes */
uint32_t ch1, ch2;
char *end1, *end2;
str1 = STRING_CHARS(s1); end1 = str1 + STRING_SIZE(s1);
str2 = STRING_CHARS(s2); end2 = str2 + STRING_SIZE(s2);
while ((str1 < end1) && (str2 < end2)) {
if ((str1 = STk_utf8_grab_char(str1, &ch1)) == NULL) error_bad_sequence(s1);
if ((str2 = STk_utf8_grab_char(str2, &ch2)) == NULL) error_bad_sequence(s2);
if (ch1 != ch2) return ch1 - ch2;
}
/* str1 < end1 || str2 < end2 */
return (str1 < end1) ? +1 : ((str2 < end2) ? -1 : 0);
} else {
/* fast-path for mono-byte strings */
register int l1, l2;
for (l1=STRING_SIZE(s1), str1=STRING_CHARS(s1),
l2=STRING_SIZE(s2),str2=STRING_CHARS(s2);
l1 && l2;
l1--, str1++, l2--, str2++)
if (*str1 != *str2) return ((unsigned char) *str1 - (unsigned char) *str2);
l1 && l2;
l1--, str1++, l2--, str2++)
if (*str1 != *str2) return ((unsigned char) *str1 - (unsigned char) *str2);
/* l1 == 0 || l2 == 0 */
return l1 ? +1 : (l2 ? -1 : 0);
/* l1 == 0 || l2 == 0 */
return l1 ? +1 : (l2 ? -1 : 0);
}
}
static int stringcompi(SCM s1, SCM s2)
{
register int l1, l2;
register char *str1, *str2;
if (!STRINGP(s1)) error_bad_string(s1);
if (!STRINGP(s2)) error_bad_string(s2);
for (l1=STRING_SIZE(s1), str1=STRING_CHARS(s1),
l2=STRING_SIZE(s2), str2=STRING_CHARS(s2);
l1 && l2;
l1--, str1++, l2--, str2++)
if (tolower(*str1) != tolower(*str2))
if (STk_use_utf8 && (!STRING_MONOBYTE(s1) || !STRING_MONOBYTE(s2))) {
/* At least one string is multi-bytes */
uint32_t ch1, ch2;
char *end1, *end2;
str1 = STRING_CHARS(s1); end1 = str1 + STRING_SIZE(s1);
str2 = STRING_CHARS(s2); end2 = str2 + STRING_SIZE(s2);
while ((str1 < end1) && (str2 < end2)) {
if ((str1 = STk_utf8_grab_char(str1, &ch1)) == NULL) error_bad_sequence(s1);
if ((str2 = STk_utf8_grab_char(str2, &ch2)) == NULL) error_bad_sequence(s2);
if (towlower(ch1) != towlower(ch2)) return towlower(ch1) - towlower(ch2);
}
/* str1 < end1 || str2 < end2 */
return (str1 < end1) ? +1 : ((str2 < end2) ? -1 : 0);
} else {
/* fast-path for mono-byte strings */
register int l1, l2;
for (l1=STRING_SIZE(s1), str1=STRING_CHARS(s1),
l2=STRING_SIZE(s2),str2=STRING_CHARS(s2);
l1 && l2;
l1--, str1++, l2--, str2++)
if (tolower(*str1) != tolower(*str2))
return (tolower(*str1) - tolower(*str2));
/* l1 == 0 || l2 == 0 */
return l1 ? +1 : (l2 ? -1 : 0);
/* l1 == 0 || l2 == 0 */
return l1 ? +1 : (l2 ? -1 : 0);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment