summaryrefslogtreecommitdiff
path: root/src/basic/escape.c
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2015-11-02 10:57:38 +0100
committerDaniel Mack <github@zonque.org>2015-11-02 10:57:38 +0100
commit86b4428a58739a3899f0d2cee5bf78ba861d16b7 (patch)
tree62b24c733d65866a8302114cc3440d4ee3ca2097 /src/basic/escape.c
parent8fa7cf70764319982e6617413cd0e287f6e35447 (diff)
parent025b4c410577a10692c608e7dbad712655abb858 (diff)
Merge pull request #1740 from shawnl/master
utf8.[ch]: use char32_t and char16_t instead of int, int32_t, int16_t
Diffstat (limited to 'src/basic/escape.c')
-rw-r--r--src/basic/escape.c12
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;