提交 b8e3673d 编写于 作者: M Max Bruckner

refactor cJSONUtils_PointerEncodedstrlen

上级 b16bcc3c
...@@ -107,18 +107,20 @@ static int cJSONUtils_Pstrcasecmp(const unsigned char *name, const unsigned char ...@@ -107,18 +107,20 @@ static int cJSONUtils_Pstrcasecmp(const unsigned char *name, const unsigned char
return 0; return 0;
} }
static size_t cJSONUtils_PointerEncodedstrlen(const unsigned char *s) /* calculate the length of a string if encoded as JSON pointer with ~0 and ~1 escape sequences */
static size_t cJSONUtils_PointerEncodedstrlen(const unsigned char *string)
{ {
size_t l = 0; size_t length;
for (; *s; (void)s++, l++) for (length = 0; *string != '\0'; (void)string++, length++)
{ {
if ((*s == '~') || (*s == '/')) /* character needs to be escaped? */
if ((*string == '~') || (*string == '/'))
{ {
l++; length++;
} }
} }
return l; return length;
} }
static void cJSONUtils_PointerEncodedstrcpy(unsigned char *d, const unsigned char *s) static void cJSONUtils_PointerEncodedstrcpy(unsigned char *d, const unsigned char *s)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册