Skip to content

Commit

Permalink
Merge pull request #4793 from cyrusimap/unicode-casemap-len
Browse files Browse the repository at this point in the history
charset.c: Add 'len' argument to unicode_casemap()
  • Loading branch information
ksmurchison committed Jan 19, 2024
2 parents 4ab4389 + d578282 commit 5887e70
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cunit/charset.testc
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ static void test_unicode_casemap(void)
char *s; \
static const char _in[] = (in); \
static const char _want[] = (want); \
s = unicode_casemap(_in); \
s = unicode_casemap(_in, -1); \
CU_ASSERT_PTR_NOT_NULL(s); \
CU_ASSERT_STRING_EQUAL(s, _want); \
free(s); \
Expand Down
4 changes: 2 additions & 2 deletions lib/charset.c
Original file line number Diff line number Diff line change
Expand Up @@ -4519,9 +4519,9 @@ EXPORTED void charset_write_mime_param(struct buf *buf, int extended, size_t cur
free(xvalue);
}

EXPORTED char *unicode_casemap(const char *s)
EXPORTED char *unicode_casemap(const char *s, ssize_t slen)
{
int32_t slen = strlen(s), ulen, tlen, nlen, olen;
int32_t ulen, tlen, nlen, olen;
UChar *uni = NULL, *title = NULL, *nfkd = NULL;
const UNormalizer2 *norm = NULL;
UErrorCode err = U_ZERO_ERROR;
Expand Down
7 changes: 5 additions & 2 deletions lib/charset.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,14 @@ extern struct char_counts charset_count_validutf8(const char *data, size_t datal
extern void charset_write_mime_param(struct buf *buf, int extended, size_t cur_len,
const char *name, const char *value);

/* Transform the UTF-8 string 's' into a titlecased canonicalized UTF-8 string
/* Transform the UTF-8 string 's' of length 'len' into
* a titlecased, canonicalized, NULL-terminated UTF-8 string
* per the i;unicode-casemap collation.
*
* If 'len' is -1, then 's' MUST be NULL-terminated.
*
* https://www.rfc-editor.org/rfc/rfc5051.html
*/
extern char *unicode_casemap(const char *s);
extern char *unicode_casemap(const char *s, ssize_t len);

#endif /* INCLUDED_CHARSET_H */

0 comments on commit 5887e70

Please sign in to comment.