Changeset: 6f25cf80bc8d for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6f25cf80bc8d Modified Files: sql/backends/monet5/UDF/pyapi/unicode.c sql/backends/monet5/UDF/pyapi/unicode.h Branch: Dec2016 Log Message:
Off-by-one error, plus return a size_t for a string length. diffs (31 lines): diff --git a/sql/backends/monet5/UDF/pyapi/unicode.c b/sql/backends/monet5/UDF/pyapi/unicode.c --- a/sql/backends/monet5/UDF/pyapi/unicode.c +++ b/sql/backends/monet5/UDF/pyapi/unicode.c @@ -29,12 +29,12 @@ int utf8_strlen(const char *utf8_str, bo return utf8_char_count; } -int utf32_strlen(const Py_UNICODE *utf32_str) +size_t utf32_strlen(const Py_UNICODE *utf32_str) { - int i = 0; + size_t i = 0; while(utf32_str[i] != 0) i++; - return (i - 1); + return i; } int utf8_length(unsigned char utf8_char) diff --git a/sql/backends/monet5/UDF/pyapi/unicode.h b/sql/backends/monet5/UDF/pyapi/unicode.h --- a/sql/backends/monet5/UDF/pyapi/unicode.h +++ b/sql/backends/monet5/UDF/pyapi/unicode.h @@ -26,7 +26,7 @@ ascii: a pointer to a boolean, this is set to true if the string is ascii-encoded and to false otherwise */ int utf8_strlen(const char *utf8_str, bool *ascii); -int utf32_strlen(const Py_UNICODE *utf32_str); +size_t utf32_strlen(const Py_UNICODE *utf32_str); //! Returns the length in bytes of a single utf8 character [1,2,3 or 4] based on the signature of the first byte, returns -1 if the character is not a valid utf8 character /* Arguments: _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list