clang-format the files

This commit is contained in:
dota17
2020-03-28 10:25:00 +08:00
parent c117d8a8a8
commit 8b162c4b89
54 changed files with 2860 additions and 2713 deletions

View File

@@ -2,24 +2,24 @@
* gcc -o utf8 utf8.c -I/home/y/include -L./.libs -ljson
*/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include "config.h"
#include "json_inttypes.h"
#include "json_object.h"
#include "json_tokener.h"
void print_hex(const char* s)
void print_hex(const char *s)
{
const char *iter = s;
unsigned char ch;
while ((ch = *iter++) != 0)
{
if( ',' != ch)
if (',' != ch)
printf("%x ", ch);
else
printf( ",");
printf(",");
}
putchar('\n');
}
@@ -27,19 +27,22 @@ void print_hex(const char* s)
int main(void)
{
const char *input = "\"\\ud840\\udd26,\\ud840\\udd27,\\ud800\\udd26,\\ud800\\udd27\"";
const char *expected = "\xF0\xA0\x84\xA6,\xF0\xA0\x84\xA7,\xF0\x90\x84\xA6,\xF0\x90\x84\xA7";
const char *expected =
"\xF0\xA0\x84\xA6,\xF0\xA0\x84\xA7,\xF0\x90\x84\xA6,\xF0\x90\x84\xA7";
struct json_object *parse_result = json_tokener_parse(input);
const char *unjson = json_object_get_string(parse_result);
printf("input: %s\n", input);
int strings_match = !strcmp( expected, unjson);
int strings_match = !strcmp(expected, unjson);
int retval = 0;
if (strings_match)
{
printf("JSON parse result is correct: %s\n", unjson);
puts("PASS");
} else {
}
else
{
printf("JSON parse result doesn't match expected string\n");
printf("expected string bytes: ");
print_hex(expected);