From 025b4c410577a10692c608e7dbad712655abb858 Mon Sep 17 00:00:00 2001 From: Shawn Landden Date: Sat, 31 Oct 2015 20:39:15 -0700 Subject: utf8.[ch]: use char32_t and char16_t instead of int, int32_t, int16_t rework C11 utf8.[ch] to use char32_t instead of uint32_t when referring to unicode chars, to make things more expressive. --- src/basic/escape.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/basic/escape.c') diff --git a/src/basic/escape.c b/src/basic/escape.c index add0d7795b..5cb8287b61 100644 --- a/src/basic/escape.c +++ b/src/basic/escape.c @@ -226,7 +226,7 @@ int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode int a[8]; unsigned i; - uint32_t c; + char32_t c; if (length != (size_t) -1 && length < 9) return -EINVAL; @@ -237,8 +237,8 @@ int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode return a[i]; } - c = ((uint32_t) a[0] << 28U) | ((uint32_t) a[1] << 24U) | ((uint32_t) a[2] << 20U) | ((uint32_t) a[3] << 16U) | - ((uint32_t) a[4] << 12U) | ((uint32_t) a[5] << 8U) | ((uint32_t) a[6] << 4U) | (uint32_t) a[7]; + c = (a[0] << 28U) | (a[1] << 24U) | (a[2] << 20U) | (a[3] << 16U) | + (a[4] << 12U) | (a[5] << 8U) | (a[6] << 4U) | (a[7] << 0U); /* Don't allow 0 chars */ if (c == 0) @@ -272,7 +272,7 @@ int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode case '7': { /* octal encoding */ int a, b, c; - uint32_t m; + char32_t m; if (length != (size_t) -1 && length < 3) return -EINVAL; @@ -294,7 +294,7 @@ int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode return -EINVAL; /* Don't allow bytes above 255 */ - m = ((uint32_t) a << 6U) | ((uint32_t) b << 3U) | (uint32_t) c; + m = (a << 6U) | (b << 3U) | (char32_t) c; if (m > 255) return -EINVAL; @@ -331,7 +331,7 @@ int cunescape_length_with_prefix(const char *s, size_t length, const char *prefi for (f = s, t = r + pl; f < s + length; f++) { size_t remaining; - uint32_t u; + char32_t u; char c; int k; -- cgit v1.2.3-54-g00ecf