sexp_string_size and sexp_string_length both return sexp_uint_t.

This commit is contained in:
Alex Shinn 2013-07-21 15:03:22 +09:00
parent 13b540418e
commit 025f03fde6
3 changed files with 5 additions and 5 deletions

View file

@ -690,8 +690,8 @@ the following macros:
\itemlist[
\item{\ccode{char* sexp_string_data(s)} - the raw bytes of the string}
\item{\ccode{unsigned long sexp_string_size(s)} - the number of raw bytes in the string}
\item{\ccode{int sexp_string_length(sexp s)} - the number of characters encoded in \var{s}}
\item{\ccode{sexp_uint_t sexp_string_size(s)} - the number of raw bytes in the string}
\item{\ccode{sexp_uint_t sexp_string_length(sexp s)} - the number of characters encoded in \var{s}}
]
Currently all Scheme strings also happen to be NULL-terminated, but

View file

@ -1403,7 +1403,7 @@ SEXP_API void sexp_init(void);
#if SEXP_USE_UTF8_STRINGS
SEXP_API int sexp_utf8_initial_byte_count (int c);
SEXP_API int sexp_utf8_char_byte_count (int c);
SEXP_API int sexp_string_utf8_length (unsigned char *p, int len);
SEXP_API sexp_uint_t sexp_string_utf8_length (unsigned char *p, long len);
SEXP_API char* sexp_string_utf8_prev (unsigned char *p);
SEXP_API sexp sexp_string_utf8_ref (sexp ctx, sexp str, sexp i);
SEXP_API sexp sexp_string_utf8_index_ref (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp i);

4
sexp.c
View file

@ -923,9 +923,9 @@ int sexp_utf8_char_byte_count (int c) {
return 4;
}
int sexp_string_utf8_length (unsigned char *p, int len) {
sexp_uint_t sexp_string_utf8_length (unsigned char *p, long len) {
unsigned char *q = p+len;
int i;
sexp_uint_t i;
for (i=0; p<q; i++)
p += sexp_utf8_initial_byte_count(*p);
return i;