Commit 92418c9b authored by Erick's avatar Erick

Recognize UTF-8 strings in regexps

parent 686b9eeb
......@@ -6279,6 +6279,7 @@ then
PCRE_FLAGS="-Dregexec=PCRE_regexec -Dregcomp=PCRE_regcomp \
-Dregerror=PCRE_regerror -Dregfree=PCRE_regfree"
(cd pcre; CC=${CC} CFLAGS="${CFLAGS} $PCRE_FLAGS" ./configure \
--enable-utf8 \
--prefix=$prefix --disable-shared --disable-cpp) || \
{ echo "Cannot configure PCRE"; exit; }
PCRE=pcre
......
......@@ -2,7 +2,7 @@
###
### Author: Erick Gallesio [eg@unice.fr]
### Creation date: 28-Dec-1999 21:19 (eg)
### Last file update: 27-Jul-2011 23:01 (eg)
### Last file update: 21-Aug-2011 12:56 (eg)
AC_PREREQ(2.64)
AC_INIT([stklos], [1.10])
......@@ -62,7 +62,7 @@ fi
eval `CC=$CC /bin/sh ./utils/shlib-options`
case $OS_NAME_VERSION in
SUNOS*)
SUNOS*)
CFLAGS="$CFLAGS -DSOLARIS";
LIBS="$LIBS -lsocket -lrt -lnsl -lpthread"
;;
......@@ -76,7 +76,7 @@ case $OS_NAME_VERSION in
echo "**** Please modify the script \"utils/shlib-options\" to add"
echo "**** support for your system (it's easy) and restart installation process."
echo "**** Thanks for sending your modifications to <bugs _at_ stklos.net>"
exit 1
exit 1
;;
esac
......@@ -90,8 +90,8 @@ PREFIX=$prefix
BUILD_OS=$os-$version
BUILD_ARCH=`uname -m`
OS_NAME=$OS
case $OS in
LINUX)
case $OS in
LINUX)
v=`echo $version | sed -e 's/\([[0-9]]*\)\.\([[0-9\]]*\).*/\1_\2/'`
OS_NAME_VERSION=LINUX_$v
;;
......@@ -102,7 +102,7 @@ case $OS in
*) OS_NAME_VERSION=DARWIN_OLD;;
esac
;;
*)
*)
v=`echo $version | sed -e 's/[[^0-9]]/_/g'`
OS_NAME_VERSION=$OS\_$v;
esac
......@@ -144,7 +144,7 @@ case "$THREADS" in
;;
posix | pthreads)
### Check for pthreads
AC_CHECK_LIB(pthread, pthread_create, LIBS="-lpthread $LIBS",
AC_CHECK_LIB(pthread, pthread_create, LIBS="-lpthread $LIBS",
[AC_MSG_ERROR([Missing PThread library])])
THREADS=pthreads
AC_DEFINE(THREADS_PTHREADS, [], [PThread support])
......@@ -172,16 +172,16 @@ AM_CONDITIONAL(PTHREADS, test "$THREADS" = pthreads)
AM_CONDITIONAL(NO_THREAD, test "$THREADS" = none)
# ----------------------------------------------------------------------
# GC support
# GC support
# ----------------------------------------------------------------------
echo "*****"
echo "***** GC support"
echo "*****"
# Try to determine if libgc is installed
if ${PKGCONFIG} --exists bdw-gc ;then
if ${PKGCONFIG} --exists bdw-gc ;then
HAVE_GC="yes"
else
else
AC_CHECK_LIB(gc, GC_malloc, HAVE_GC="yes", HAVE_GC="no", $LIBS)
fi
......@@ -191,11 +191,11 @@ AC_ARG_WITH(provided-gc,
PROV_GC="$withval", PROV_GC="no")
if test "$HAVE_GC" = "no" -o "$PROV_GC" = "yes"
then
then
echo "... Configuring libgc"
case $OS_NAME_VERSION in
DARWIN_10)
DARWIN_10)
cflags="${CFLAGS} -D_XOPEN_SOURCE";;
*)
cflags="${CFLAGS}";;
......@@ -223,7 +223,7 @@ fi
# ----------------------------------------------------------------------
# GMP support
# GMP support
# ----------------------------------------------------------------------
echo "*****"
echo "***** GMP support"
......@@ -240,7 +240,7 @@ if test "$HAVE_GMP" = "no" ;then
AC_CHECK_LIB(gmp, __gmpz_init_set, HAVE_GMP="yes", HAVE_GMP="no")
fi
# Test if the user want to force with our GMP lib
# Test if the user want to force with our GMP lib
# (2 names available for that --with-provided-bignum or (legacy) --with-gmp-light
AC_ARG_WITH(provided-bignum,
[ --with-provided-bignum use the provided Bignum (GMPlite) library],
......@@ -253,7 +253,7 @@ if test "$PROV_GMP" = "no" ;then
fi
if test "$HAVE_GMP" = "no" -o "$PROV_GMP" = "yes"
then
then
echo "... Configuring libgmp"
(cd gmp; CC=${CC} CFLAGS="${cflags} -I../src -DFOR_STKLOS=1" ./configure \
--prefix=$prefix) || { echo "Cannot configure the GMP"; exit; }
......@@ -272,17 +272,17 @@ fi
# ----------------------------------------------------------------------
# PCRE support
# PCRE support
# ----------------------------------------------------------------------
echo "*****"
echo "***** Regexp support"
echo "*****"
# Try to determine if libpcre is installed
if ${PKGCONFIG} --exists libpcre ;then
if ${PKGCONFIG} --exists libpcre ;then
HAVE_PCRE="yes"
PCREPKG="present"
else
else
AC_CHECK_LIB(pcre, pcre_fullinfo, HAVE_PCRE="yes", HAVE_PCRE="no", $LIBS)
fi
......@@ -292,11 +292,12 @@ AC_ARG_WITH(provided-regexp,
PROV_PCRE="$withval", PROV_PCRE="no")
if test "$HAVE_PCRE" = "no" -o "$PROV_PCRE" = "yes"
then
then
echo "... Configuring libpcre"
PCRE_FLAGS="-Dregexec=PCRE_regexec -Dregcomp=PCRE_regcomp \
-Dregerror=PCRE_regerror -Dregfree=PCRE_regfree"
(cd pcre; CC=${CC} CFLAGS="${CFLAGS} $PCRE_FLAGS" ./configure \
--enable-utf8 \
--prefix=$prefix --disable-shared --disable-cpp) || \
{ echo "Cannot configure PCRE"; exit; }
PCRE=pcre
......@@ -310,26 +311,26 @@ else
if $PKGCONFIG --exists libpcre ;then
PCREINC="$($PKGCONFIG --cflags libpcre)"
PCRELIB="$($PKGCONFIG --libs libpcre) -lpcreposix"
else
else
PCREINC=""
PCRELIB="-lpcre -lpcreposix"
fi
fi
AC_DEFINE(HAVE_PCRE, 1 , [We use our version of pcre])
SYST_LIBS="libpcre $SYST_LIBS"
fi
# ----------------------------------------------------------------------
# FFI support
# FFI support
# ----------------------------------------------------------------------
echo "*****"
echo "***** FFI support"
echo "*****"
# Try to determine if libffi is installed
if ${PKGCONFIG} --exists libffi ;then
if ${PKGCONFIG} --exists libffi ;then
HAVE_FFI="yes"
else
else
AC_CHECK_LIB(ffi, ffi_prep_cif, HAVE_FFI="yes", HAVE_FFI="no", $LIBS)
fi
......@@ -339,7 +340,7 @@ AC_ARG_WITH(provided-ffi,
PROV_FFI="$withval", PROV_FFI="no")
if test "$HAVE_FFI" = "no" -o "$PROV_FFI" = "yes"
then
then
echo "... Configuring libffi"
(cd ffi; CC=${CC} CFLAGS=${CFLAGS} ./configure \
--disable-structs --disable-raw-api --disable-shared \
......@@ -348,7 +349,7 @@ then
FFIINC="-I../ffi/include"
FFILIB="../ffi/.libs/libffi.a"
COMP_LIBS="libffi $COMP_LIBS"
else
else
echo "... Using system libffi library"
FFI=""
if $PKGCONFIG --exists libffi ;then
......@@ -361,7 +362,7 @@ else
SYST_LIBS="libffi $SYST_LIBS"
fi
# We always want FFI. Should be modifiable in the future
AC_DEFINE(HAVE_FFI, 1, [System provides FFI])
AC_DEFINE(HAVE_FFI, 1, [System provides FFI])
###
### See in what direction the stack grows (code stolen from Sawfish)
......@@ -379,7 +380,7 @@ AC_TRY_RUN([ void inner (char *foo) { char bar; exit (!(foo >= &bar)); }
LIB_SUMMARY="(:system ($SYST_LIBS) :compiled ($COMP_LIBS))"
### Output files
### Output files
AC_SUBST(STKCFLAGS)
AC_SUBST(VERSION)
AC_SUBST(HAVE_DLOPEN)
......@@ -424,11 +425,11 @@ AC_SUBST(THREADS)
AC_SUBST(LIB_SUMMARY)
AC_CONFIG_FILES([Makefile src/Makefile src/extraconf.h doc/Makefile
lib/Makefile utils/Makefile utils/stklos-config
utils/stklos-script examples/Makefile
lib/Match.d/Makefile lib/SILex.d/Makefile lib/Lalr.d/Makefile
lib/ScmPkg.d/Makefile tests/Makefile
doc/stklos.1 doc/stklos-config.1 doc/stklos-compile.1
lib/Makefile utils/Makefile utils/stklos-config
utils/stklos-script examples/Makefile
lib/Match.d/Makefile lib/SILex.d/Makefile lib/Lalr.d/Makefile
lib/ScmPkg.d/Makefile tests/Makefile
doc/stklos.1 doc/stklos-config.1 doc/stklos-compile.1
doc/stklos-genlex.1 doc/stklos-pkg.1 doc/skb/stklos-version.stk
pkgman/Makefile])
AC_OUTPUT
......@@ -445,12 +446,12 @@ echo " OS type: " $OS_FLAVOUR
echo " Install prefix : " $prefix
echo " C compiler: " $CC
echo " Compilation flags: " $CFLAGS
echo " Thread support: " $THREADS
echo " Thread support: " $THREADS
echo "System libraries used: " $SYST_LIBS
echo " Compiled libraries: " $COMP_LIBS
echo " "
echo "If this is correct, you can just type 'make' now at your shell prompt."
echo "Otherwise, re-run 'configure' with correct options."
echo "Otherwise, re-run 'configure' with correct options."
echo " "
......@@ -21,7 +21,7 @@
*
* Author: Erick Gallesio [eg@essi.fr]
* Creation date: 1-Jul-2003 11:38 (eg)
* Last file update: 27-May-2011 22:34 (eg)
* Last file update: 19-Aug-2011 18:00 (eg)
*/
......@@ -250,7 +250,7 @@ DEFINE_PRIMITIVE("%parameter-dynenv-pop!", parameter_dynenv_pop, subr1, (SCM par
*
\*===========================================================================*/
struct extended_type_descr xtype_parameter = { "parameter", NULL };
static struct extended_type_descr xtype_parameter = { "parameter", NULL };
int STk_init_parameter(void)
{
......
/*
* promise.c -- Implementation of promises
*
* Copyright © 2000-2005 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
*
*
*
* Copyright © 2000-2011 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program 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 General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
*
* Author: Erick Gallesio [eg@unice.fr]
* Author: Erick Gallesio [eg@kaolin.unice.fr]
* Creation date: 2-Jun-1993 12:27 (eg)
* Last file update: 24-Apr-2005 21:55 (eg)
* Last file update: 19-Aug-2011 18:01 (eg)
*/
#include <stklos.h>
......@@ -57,19 +57,19 @@ DEFINE_PRIMITIVE("%make-promise", make_promise, subr1, (SCM expr))
* returned. The value of the promise is cached (or "memoized") so
* that if it is forced a second time, the previously computed value
* is returned.
*
*
* @lisp
* (force (delay (+ 1 2))) => 3
* (let ((p (delay (+ 1 2))))
* (list (force p) (force p))) => (3 3)
*
*
* (define a-stream
* (letrec ((next (lambda (n)
* (cons n (delay (next (+ n 1)))))))
* (next 0)))
* (define head car)
* (define tail (lambda (stream) (force (cdr stream))))
*
*
* (head (tail (tail a-stream))) => 2
* @end lisp
*
......@@ -91,8 +91,8 @@ DEFINE_PRIMITIVE("%make-promise", make_promise, subr1, (SCM expr))
* (begin (set! x 10)
* (force p)) => 6
* @end lisp
* ,(bold "Note:") See R5RS for details on a posssible way to implement
* |force| and |delay|.
* ,(bold "Note:") See R5RS for details on a posssible way to implement
* |force| and |delay|.
doc>
*/
DEFINE_PRIMITIVE("force", force, subr1, (SCM promise))
......@@ -102,7 +102,7 @@ DEFINE_PRIMITIVE("force", force, subr1, (SCM promise))
if (!PROMISEP(promise)) return promise;
if (RESULT_READYP(promise))
/* promise was already evaluated. It's expr field contains the result */
/* promise was already evaluated. It's expr field contains the result */
return PROMISE_EXPR(promise);
z = STk_C_apply(PROMISE_EXPR(promise), 0);
......@@ -146,7 +146,7 @@ static void print_promise(SCM promise, SCM port, int mode)
}
struct extended_type_descr xtype_promise = {
static struct extended_type_descr xtype_promise = {
"promise",
print_promise
};
......
/*
* regexp.c -- STklos Regexps
*
* Copyright © 2000-2010 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
*
*
*
* Copyright © 2000-2011 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program 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 General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
*
* Author: Erick Gallesio [eg@unice.fr]
* Creation date: 24-Nov-2000 10:35 (eg)
* Last file update: 4-Apr-2010 12:22 (eg)
* Last file update: 21-Aug-2011 13:33 (eg)
*/
#include "stklos.h"
/*
/*
* All the complexity comes from MAC OS. I don't remember why I had to do
* this, but I remember the culprit !!!
*/
......@@ -36,7 +36,7 @@
# define PCRE_regcomp regcomp
# define PCRE_regerror regerror
# define PCRE_regfree regfree
#else
#else
# define regexec PCRE_regexec
# define regcomp PCRE_regcomp
# define regerror PCRE_regerror
......@@ -46,29 +46,38 @@
/* ---------------------------------------------------------------------- */
#ifdef PCRE_PKG_CONFIG
# include <pcreposix.h>
#else
/* Here again Mac Os problems.
#else
/* Here again Mac Os problems.
* Here, we used to have a #include <pcreposix.h>
* However, on a fresh 10.6 install, there is a pcre lib which is
* installed, but the "pcreposix.h" file isn't.
*
*
* So what we do here is potentially FALSE. However, it is unlikely
* that the code include in STklos is not compatible with the one
* used to compile the installed library (this file seems to have
* been always "semantically" compatible). The only point wehr we
* can have difference shoul be the definition of regmatch_t type
* that the code include in STklos is not compatible with the one
* used to compile the installed library (this file seems to have
* been always "semantically" compatible). The only point where we
* can have difference should be the definition of regmatch_t type
*/
# include "../pcre/pcreposix.h"
#endif
#ifdef REG_UTF8
# define PCRE_COMP_FLAG REG_UTF8
#else
# define PCRE_COMP_FLAG 0
#endif
/* ---------------------------------------------------------------------- */
struct regexp_obj {
stk_header header;
SCM src;
regex_t buffer;
};
#define REGEXPP(p) (BOXED_TYPE_EQ((p), tc_regexp))
#define REGEXP_SRC(p) (((struct regexp_obj *) (p))->src)
#define REGEXP_BUFFER(p) (((struct regexp_obj *) (p))->buffer)
#define REGEXP_DEPTH(p) ((((struct regexp_obj *) (p))->buffer).re_nsub)
......@@ -99,7 +108,14 @@ static void regexp_finalizer(SCM re)
PCRE_regfree(&REGEXP_BUFFER(re));
}
static void print_regexp(SCM obj, SCM port, int mode)
{
STk_fprintf(port,
"#[regexp '%s' @ %lx]",
STRING_CHARS(REGEXP_SRC(obj)),
(unsigned long) obj);
}
/*
<doc EXT string->regexp
* (string->regexp string)
......@@ -110,8 +126,8 @@ static void regexp_finalizer(SCM re)
* the matching pattern. If a regular expression string is used
* multiple times, it is faster to compile the string once to a regexp
* value and use it for repeated matches instead of using the string
* each time.
doc>
* each time.
doc>
*/
DEFINE_PRIMITIVE("string->regexp", str2regexp, subr1, (SCM re))
{
......@@ -119,10 +135,12 @@ DEFINE_PRIMITIVE("string->regexp", str2regexp, subr1, (SCM re))
int ret;
if (!STRINGP(re)) error_bad_string(re);
NEWCELL_ATOMIC(z, regexp, sizeof(struct regexp_obj) );
ret = PCRE_regcomp(&REGEXP_BUFFER(z), STRING_CHARS(re), 0);
NEWCELL(z, regexp);
ret = PCRE_regcomp(&REGEXP_BUFFER(z),
STRING_CHARS(re),
STk_use_utf8? PCRE_COMP_FLAG: 0);
REGEXP_SRC(z) = re;
if (ret) signal_regexp_error(ret, &REGEXP_BUFFER(z));
STk_register_finalizer(z, regexp_finalizer);
......@@ -131,9 +149,9 @@ DEFINE_PRIMITIVE("string->regexp", str2regexp, subr1, (SCM re))
/*
<doc EXT regexp?
* (regexp? obj)
* (regexp? obj)
*
* |Regexp| returns |#t| if |obj| is a regexp value created by the |regexp|,
* |Regexp| returns |#t| if |obj| is a regexp value created by the |regexp|,
* otherwise |regexp| returns |#f|.
doc>
*/
......@@ -148,17 +166,17 @@ DEFINE_PRIMITIVE("regexp?", regexpp, subr1, (SCM obj))
* (regexp-match pattern str)
* (regexp-match-positions pattern str)
*
* These functions attempt to match |pattern| (a string or a regexp value)
* to |str|. If the match fails, |#f| is returned. If the match succeeds,
* a list (containing strings for |regexp-match| and positions for
* These functions attempt to match |pattern| (a string or a regexp value)
* to |str|. If the match fails, |#f| is returned. If the match succeeds,
* a list (containing strings for |regexp-match| and positions for
* |regexp-match-positions| is returned. The first string (or positions) in
* this list is the portion of string that matched pattern. If two portions
* this list is the portion of string that matched pattern. If two portions
* of string can match pattern, then the earliest and longest match is found,
* by default.
*
* by default.
*
* Additional strings or positions are returned in the list if pattern contains
* parenthesized sub-expressions; matches for the sub-expressions are provided
* in the order of the opening parentheses in pattern.
* in the order of the opening parentheses in pattern.
* @lisp
* (regexp-match-positions "ca" "abracadabra")
* => ((4 6))
......@@ -172,9 +190,9 @@ DEFINE_PRIMITIVE("regexp?", regexpp, subr1, (SCM obj))
* => ((0 3) (0 1) (1 2) (2 3))
* (regexp-match-positions "(a*)(b*)(c*)" "c")
* => ((0 1) (0 0) (0 0) (0 1))
* (regexp-match-positions "(?<=\\\\d{3})(?<!999)foo"
* (regexp-match-positions "(?<=\\\\d{3})(?<!999)foo"
* "999foo and 123foo")
* => ((14 17))
* => ((14 17))
* @end lisp
doc>
*/
......@@ -186,6 +204,7 @@ static SCM regexec_helper(SCM re, SCM str, int pos_only)
int i, ret, depth, max;
SCM result;
STk_debug("regexec helper ~S ~S", re, str);
/* RE can be a string or a already compiled regexp */
if (STRINGP(re)) re = STk_str2regexp(re);
else if (!REGEXPP(re)) STk_error("bad compiled regexp ~S", re);
......@@ -202,7 +221,7 @@ static SCM regexec_helper(SCM re, SCM str, int pos_only)
result = STk_nil;
depth = REGEXP_DEPTH(re);
max = (depth < MAX_PMATCH) ? (depth + 1) : MAX_PMATCH;
for(i=0; i < max; i++) {
int from = pmatch[i].rm_so;
int to = pmatch[i].rm_eo;
......@@ -212,12 +231,13 @@ static SCM regexec_helper(SCM re, SCM str, int pos_only)
LIST2(MAKE_INT(0), MAKE_INT(0)) :
STk_false,
result);
else
result = STk_cons((pos_only)?
else
result = STk_cons((pos_only)?
LIST2(STk_long2integer(from), STk_long2integer(to)) :
STk_makestring(to-from, STRING_CHARS(str)+from),
result);
}
STk_debug("regexec helper ~S ~S => ", re, str, STk_reverse(result));
return STk_dreverse(result);
}
......@@ -245,7 +265,7 @@ DEFINE_PRIMITIVE("regexp-match-positions", regmatch_pos, subr2, (SCM re, SCM str
* (regexp-quote "list?") => "list\\\\?"
* @end lisp
* |regexp-quote| is useful when building a composite regexp from
* a mix of regexp strings and verbatim strings.
* a mix of regexp strings and verbatim strings.
doc>
*/
#define REGEXP_SPECIALS "\\.?*+|[]{}()"
......@@ -262,12 +282,12 @@ DEFINE_PRIMITIVE("regexp-quote", regexp_quote, subr1, (SCM str))
/* compute length of new string */
for (s = STRING_CHARS(str), len=0; s < end; s++, len++)
if (strchr(REGEXP_SPECIALS, *s)) len++;
if (len > STRING_SIZE(str)) {
/* make new string */
z = STk_makestring(len, NULL);
for (s = STRING_CHARS(str), t = STRING_CHARS(z);
s < end;
s < end;
s++, t++) {
if (strchr(REGEXP_SPECIALS, *s)) *t++ = '\\';
*t = *s;
......@@ -280,15 +300,15 @@ DEFINE_PRIMITIVE("regexp-quote", regexp_quote, subr1, (SCM str))
}
/*===========================================================================*\
*
*
* Initialization
*
*
\*===========================================================================*/
/* The stucture which describes the regexp type */
static struct extended_type_descr xtype_regexp = {
"regexp", /* name */
NULL /* print function */
print_regexp /* print function */
};
......
......@@ -21,7 +21,7 @@
*
* Author: Erick Gallesio [eg@unice.fr]
* Creation date: 30-Apr-2011 19:46 (eg)
* Last file update: 16-Aug-2011 18:03 (eg)
* Last file update: 19-Aug-2011 18:05 (eg)
*/
#include "stklos.h"
......@@ -92,16 +92,12 @@ int STk_utf8_read_char(SCM port)
}
int STk_char2utf8(int ch, char *str) /* result = length of the UTF-8 repr. */
{
uint8_t *buff = (uint8_t *)str;
int n = 0;
if (VALID_UTF8_VALUE(ch))
if (VALID_UTF8_VALUE(ch)) {
if (ch < 0x80) {
*buff++ = ch;
n = 1;
......@@ -121,6 +117,7 @@ int STk_char2utf8(int ch, char *str) /* result = length of the UTF-8 repr. */
*buff++ = (ch & 0x3f) | 0x80;
n = 4;
}
}
/* *buff = '\0'; */
return n;
}
......@@ -198,7 +195,8 @@ DEFINE_PRIMITIVE("%char-utf8-encoding", char_utf8_encoding, subr1, (SCM c))
DEFINE_PRIMITIVE("%dump-string", dump_string, subr12, (SCM str, SCM index))
{
int i, c=0;
int i;
uint32_t c = 0;
STk_debug("String ~S. space=%d, size=%d, len =%d", str,
STRING_SPACE(str), STRING_SIZE(str), STRING_LENGTH(str));
......@@ -213,8 +211,7 @@ DEFINE_PRIMITIVE("%dump-string", dump_string, subr12, (SCM str, SCM index))
printf("------\nChar starting at index %d\n", i);
STk_debug(" length of char = %d",
STk_utf8_sequence_length(&(STRING_CHARS(str)[i])));
STk_utf8_grab_char(
STRING_CHARS(str)+i, &c);
STk_utf8_grab_char(STRING_CHARS(str)+i, &c);
STk_debug(" character is %d ~S", (unsigned) c, MAKE_CHARACTER(c));
}
......
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