Skip to content

Commit 4751c28

Browse files
author
sthsieh
committed
修正include資料夾、修正enum大小寫
1 parent b0e58a7 commit 4751c28

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

.ycm_extra_conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
'c',
5353
'-isystem',
5454
'lib',
55+
'-isystem',
56+
'libjson',
5557
'-I',
5658
'.',
5759
]

lib/parser.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ static const char *const string_of_errors[] = {
2222

2323
static int _json_parser_callback(void *const restrict userdata, const int type, const char *const restrict data, const uint32_t length) {
2424
struct _Parser *parser = userdata;
25-
// TODO: no mem detect
25+
// TODO: detect oom
2626
switch (parser->status) {
2727
case lyric_parser_status_start: {
2828
if (type == JSON_ARRAY_BEGIN) {
29+
// set of objects
2930
} else if (type == JSON_OBJECT_BEGIN) {
3031
if (parser->lyrics == NULL) {
3132
parser->lyrics = lyric_lyric_new();

lib/time.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
#include "time.h"
22

33
enum {
4-
TIME_PARSER_FLEXIBLE_LENGTH_BLOCK,
5-
TIME_PARSER_FIXED_LENGTH_BLOCK,
6-
TIME_PARSER_MINISECOND,
4+
lyric_time_status_flexible_length_block,
5+
lyric_time_status_fixed_length_block,
6+
lyric_time_status_minisecond,
77
};
88

99
bool lyric_time_create_from_string(Time *const restrict time, const char *const restrict string, const size_t length) {
1010
if (unlikely(time == NULL)) {
1111
return false;
1212
}
1313
time->second = time->minisecond = 0;
14-
size_t status = TIME_PARSER_FLEXIBLE_LENGTH_BLOCK;
14+
size_t status = lyric_time_status_flexible_length_block;
1515
size_t counter = 0;
1616
for (size_t i = 0; i < length; ++i) {
1717
switch (status) {
18-
case TIME_PARSER_FLEXIBLE_LENGTH_BLOCK: {
18+
case lyric_time_status_flexible_length_block: {
1919
if (isdigit(string[i])) {
2020
time->second = time->second * 10 + (string[i] - '0');
2121
} else if (string[i] == ':') {
2222
time->second *= 60;
23-
status = TIME_PARSER_FIXED_LENGTH_BLOCK;
23+
status = lyric_time_status_fixed_length_block;
2424
} else {
2525
return false;
2626
}
2727
} break;
28-
case TIME_PARSER_FIXED_LENGTH_BLOCK: {
28+
case lyric_time_status_fixed_length_block: {
2929
if (isdigit(string[i])) {
3030
if (counter == 2) {
3131
return false;
@@ -36,20 +36,20 @@ bool lyric_time_create_from_string(Time *const restrict time, const char *const
3636
return false;
3737
}
3838
time->second *= 60;
39-
status = TIME_PARSER_FIXED_LENGTH_BLOCK;
39+
status = lyric_time_status_fixed_length_block;
4040
counter = 0;
4141
} else if (string[i] == '.') {
4242
if (counter != 2) {
4343
return false;
4444
}
45-
status = TIME_PARSER_MINISECOND;
45+
status = lyric_time_status_minisecond;
4646
counter = 0;
4747
} else {
4848
return false;
4949
}
5050
++counter;
5151
} break;
52-
case TIME_PARSER_MINISECOND: {
52+
case lyric_time_status_minisecond: {
5353
if (isdigit(string[i])) {
5454
if (counter == 4) {
5555
return false;
@@ -62,7 +62,7 @@ bool lyric_time_create_from_string(Time *const restrict time, const char *const
6262
} break;
6363
}
6464
}
65-
if (status == TIME_PARSER_MINISECOND) {
65+
if (status == lyric_time_status_minisecond) {
6666
while (counter < 3) {
6767
time->minisecond *= 10;
6868
++counter;

0 commit comments

Comments
 (0)