diff options
author | Shawn Landden <shawn@churchofgit.com> | 2015-10-31 20:39:15 -0700 |
---|---|---|
committer | Shawn Landden <shawn@churchofgit.com> | 2015-10-31 21:00:57 -0700 |
commit | 025b4c410577a10692c608e7dbad712655abb858 (patch) | |
tree | 3de2fe13c9a9d9fd778abdcfb1abbb97c202e834 /src/basic/escape.c | |
parent | 534e8f89d6367cd0e9e17fff67880fb430071d01 (diff) | |
download | systemd-025b4c410577a10692c608e7dbad712655abb858.tar.gz systemd-025b4c410577a10692c608e7dbad712655abb858.tar.bz2 systemd-025b4c410577a10692c608e7dbad712655abb858.zip |
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.
Diffstat (limited to 'src/basic/escape.c')
-rw-r--r-- | src/basic/escape.c | 12 |
1 files changed, 6 insertions, 6 deletions
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; |