projects
/
project
/
libubox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
jshn: refactor _jshn_append to require fewer evals
[project/libubox.git]
/
blobmsg_json.c
diff --git
a/blobmsg_json.c
b/blobmsg_json.c
index
7a4ab7b
..
e4e005f
100644
(file)
--- a/
blobmsg_json.c
+++ b/
blobmsg_json.c
@@
-151,11
+151,12
@@
static void add_separator(struct strbuf *s)
static void blobmsg_format_string(struct strbuf *s, const char *str)
{
static void blobmsg_format_string(struct strbuf *s, const char *str)
{
- const
char *p, *last = str, *end = str + strlen(str)
;
+ const
unsigned char *p, *last, *end
;
char buf[8] = "\\u00";
char buf[8] = "\\u00";
+ end = (unsigned char *) str + strlen(str);
blobmsg_puts(s, "\"", 1);
blobmsg_puts(s, "\"", 1);
- for (p =
str
; *p; p++) {
+ for (p =
(unsigned char *) str, last = p
; *p; p++) {
char escape = '\0';
int len;
char escape = '\0';
int len;
@@
-187,20
+188,20
@@
static void blobmsg_format_string(struct strbuf *s, const char *str)
continue;
if (p > last)
continue;
if (p > last)
- blobmsg_puts(s, last, p - last);
+ blobmsg_puts(s,
(char *)
last, p - last);
last = p + 1;
buf[1] = escape;
if (escape == 'u') {
sprintf(buf + 4, "%02x", (unsigned char) *p);
last = p + 1;
buf[1] = escape;
if (escape == 'u') {
sprintf(buf + 4, "%02x", (unsigned char) *p);
- len =
4
;
+ len =
6
;
} else {
len = 2;
}
blobmsg_puts(s, buf, len);
}
} else {
len = 2;
}
blobmsg_puts(s, buf, len);
}
- blobmsg_puts(s, last, end - last);
+ blobmsg_puts(s,
(char *)
last, end - last);
blobmsg_puts(s, "\"", 1);
}
blobmsg_puts(s, "\"", 1);
}
@@
-246,7
+247,7
@@
static void blobmsg_format_element(struct strbuf *s, struct blob_attr *attr, boo
sprintf(buf, "%d", be16_to_cpu(*(uint16_t *)data));
break;
case BLOBMSG_TYPE_INT32:
sprintf(buf, "%d", be16_to_cpu(*(uint16_t *)data));
break;
case BLOBMSG_TYPE_INT32:
- sprintf(buf, "%d", be32_to_cpu(*(uint32_t *)data));
+ sprintf(buf, "%d",
(int32_t)
be32_to_cpu(*(uint32_t *)data));
break;
case BLOBMSG_TYPE_INT64:
sprintf(buf, "%lld", (long long int) be64_to_cpu(*(uint64_t *)data));
break;
case BLOBMSG_TYPE_INT64:
sprintf(buf, "%lld", (long long int) be64_to_cpu(*(uint64_t *)data));