Skip to content

Commit ded489d

Browse files
author
crystalwind
committed
Do tutorial04 exercise
1 parent 19bafe6 commit ded489d

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

tutorial04/leptjson.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,27 +116,25 @@ static const char* lept_parse_hex4(const char* p, unsigned* u) {
116116
return p;
117117
}
118118

119-
#define OutputByte(ch) PUTC(c,ch)
120-
121119
static void lept_encode_utf8(lept_context* c, unsigned u) {
122120
assert(u >= 0x0000 && u <= 0x10FFFF);
123121
if (u >= 0x0000 && u <= 0x007F) {
124-
OutputByte(u);
122+
PUTC(c,u & 0xFF);
125123
}
126124
if (u >= 0x0080 && u <= 0x07FF) {
127-
OutputByte(0xC0 | ((u >> 6) & 0xFF));
128-
OutputByte(0x80 | ( u & 0x3F));
125+
PUTC(c,0xC0 | ((u >> 6) & 0xFF));
126+
PUTC(c,0x80 | ( u & 0x3F));
129127
}
130128
if (u >= 0x0800 && u <= 0xFFFF) {
131-
OutputByte(0xE0 | ((u >> 12) & 0xFF));
132-
OutputByte(0x80 | ((u >> 6) & 0x3F));
133-
OutputByte(0x80 | ( u & 0x3F));
129+
PUTC(c,0xE0 | ((u >> 12) & 0xFF));
130+
PUTC(c,0x80 | ((u >> 6) & 0x3F));
131+
PUTC(c,0x80 | ( u & 0x3F));
134132
}
135133
if (u >= 0x10000 && u <= 0x10FFFF) {
136-
OutputByte(0xF0 | ((u >> 18) & 0xFF));
137-
OutputByte(0x80 | ((u >> 12) & 0x3F));
138-
OutputByte(0x80 | ((u >> 6) & 0x3F));
139-
OutputByte(0x80 | ( u & 0x3F));
134+
PUTC(c,0xF0 | ((u >> 18) & 0xFF));
135+
PUTC(c,0x80 | ((u >> 12) & 0x3F));
136+
PUTC(c,0x80 | ((u >> 6) & 0x3F));
137+
PUTC(c,0x80 | ( u & 0x3F));
140138
}
141139
}
142140

0 commit comments

Comments
 (0)