Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
66333b5b
Commit
66333b5b
authored
Sep 08, 2021
by
rl-d
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix warnings
parent
fda36378
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
115 additions
and
113 deletions
+115
-113
ccan/graphql/_info
ccan/graphql/_info
+2
-4
ccan/graphql/graphql.c
ccan/graphql/graphql.c
+37
-34
ccan/graphql/graphql.h
ccan/graphql/graphql.h
+1
-0
ccan/graphql/test/run.c
ccan/graphql/test/run.c
+75
-75
No files found.
ccan/graphql/_info
View file @
66333b5b
...
...
@@ -13,10 +13,8 @@
* <https://github.com/rl-d/ccan>
*
* Example:
* #include <stdio.h>
* #include "ccan/graphql/graphql.h"
*
* int main(int argc, char *argv[])
* int main(int argc, char *argv[])
{
*
* const char *input_string = "{ fieldName }";
* struct list_head *output_tokens;
...
...
@@ -56,7 +54,7 @@ int main(int argc, char *argv[])
if (strcmp(argv[1], "depends") == 0) {
printf("ccan/list\n");
printf("ccan/
take
\n");
printf("ccan/
str
\n");
printf("ccan/tal\n");
printf("ccan/tal/str\n");
printf("ccan/utf8\n");
...
...
ccan/graphql/graphql.c
View file @
66333b5b
/* MIT (BSD) license - see LICENSE file for details */
#include "graphql.h"
#include "ccan/tal/str/str.h"
...
...
@@ -22,6 +22,8 @@
#define NAME_START(c) (((c) >= 0x61 && (c) <= 0x7A) || ((c) >= 0x41 && (c) <= 0x5A) || (c) == 0x5F)
#define NAME_CONTINUE(c) (NAME_START(c) || DIGIT(c))
// Safe copy helper
#define cpystr(d,s) { char *cpystr_p; char *cpystr_q; for(cpystr_p = (s), cpystr_q = (d); *cpystr_p;) *cpystr_q++ = *cpystr_p++; *cpystr_q++ = *cpystr_p++; }
// Parser shorthands
...
...
@@ -33,12 +35,14 @@
struct graphql_##type *obj = tal(tokens, struct graphql_##type); memset(obj, 0, sizeof(struct graphql_##type)); \
#define EXIT \
goto exit_label; \
exit_label: \
rollback_top = rollback_top; \
if (*err) obj = tal_free(obj); \
return obj; \
#define CONSUME_ONE { list_add(used, list_pop(tokens, struct graphql_token, list)); }
#define RESTORE_ONE { list_add(tokens, list_pop(used, struct graphql_token, list)); }
#define CONSUME_ONE { list_add(used,
(struct list_node *)
list_pop(tokens, struct graphql_token, list)); }
#define RESTORE_ONE { list_add(tokens,
(struct list_node *)
list_pop(used, struct graphql_token, list)); }
#define ROLLBACK(args) { while (list_top(tokens, struct graphql_token, list) != rollback_top) { RESTORE_ONE; } }
#define OR if (!*err) goto exit_label; *err = NULL;
#define REQ if (*err) { ROLLBACK(args); goto exit_label; }
...
...
@@ -152,7 +156,6 @@ const char *graphql_parse(struct list_head *tokens, struct graphql_executable_do
struct
list_head
used
=
LIST_HEAD_INIT
(
used
);
const
char
*
err
=
NULL
;
*
doc
=
parse_executable_document
(
tokens
,
&
used
,
&
err
);
if
(
err
)
return
err
;
}
...
...
@@ -545,12 +548,12 @@ RET parse_directive(PARAMS) {
RET
parse_keyword
(
PARAMS
,
const
char
*
keyword
,
const
char
*
errmsg
)
{
struct
graphql_token
*
tok
=
list_top
(
tokens
,
struct
graphql_token
,
list
);
if
(
!
tok
||
tok
->
token_type
!=
'a'
)
{
*
err
=
errmsg
;
return
;
*
err
=
errmsg
;
return
NULL
;
}
if
(
!
streq
(
tok
->
token_string
,
keyword
))
{
*
err
=
errmsg
;
return
;
*
err
=
errmsg
;
return
NULL
;
}
CONSUME_ONE
(
ARGS
)
;
CONSUME_ONE
;
return
tok
;
}
...
...
@@ -563,45 +566,45 @@ RET parse_punct(PARAMS, int punct) {
sprintf
(
punctbuf
,
"expected: '...'"
);
else
sprintf
(
punctbuf
,
"expected: '%c'"
,
punct
);
*
err
=
punctbuf
;
return
;
*
err
=
punctbuf
;
return
NULL
;
}
CONSUME_ONE
(
ARGS
)
;
CONSUME_ONE
;
return
tok
;
}
RET
parse_name
(
PARAMS
)
{
struct
graphql_token
*
tok
=
list_top
(
tokens
,
struct
graphql_token
,
list
);
if
(
!
tok
||
tok
->
token_type
!=
'a'
)
{
*
err
=
"name expected"
;
return
0
;
*
err
=
"name expected"
;
return
NULL
;
}
CONSUME_ONE
(
ARGS
)
;
CONSUME_ONE
;
return
tok
;
}
RET
parse_int
(
PARAMS
)
{
struct
graphql_token
*
tok
=
list_top
(
tokens
,
struct
graphql_token
,
list
);
if
(
!
tok
||
tok
->
token_type
!=
'i'
)
{
*
err
=
"integer expected"
;
return
;
*
err
=
"integer expected"
;
return
NULL
;
}
CONSUME_ONE
(
ARGS
)
;
CONSUME_ONE
;
return
tok
;
}
RET
parse_float
(
PARAMS
)
{
struct
graphql_token
*
tok
=
list_top
(
tokens
,
struct
graphql_token
,
list
);
if
(
!
tok
||
tok
->
token_type
!=
'f'
)
{
*
err
=
"float expected"
;
return
;
*
err
=
"float expected"
;
return
NULL
;
}
CONSUME_ONE
(
ARGS
)
;
CONSUME_ONE
;
return
tok
;
}
RET
parse_string
(
PARAMS
)
{
struct
graphql_token
*
tok
=
list_top
(
tokens
,
struct
graphql_token
,
list
);
if
(
!
tok
||
tok
->
token_type
!=
's'
)
{
*
err
=
"string expected"
;
return
;
*
err
=
"string expected"
;
return
NULL
;
}
CONSUME_ONE
(
ARGS
)
;
CONSUME_ONE
;
return
tok
;
}
...
...
@@ -673,7 +676,7 @@ newchar:
}
tok
=
tal
(
tok_list
,
struct
graphql_token
);
list_add_tail
(
tok_list
,
tok
);
list_add_tail
(
tok_list
,
&
tok
->
list
);
tok
->
token_type
=
c
;
tok
->
token_specific
=
c
;
tok
->
token_string
=
NULL
;
...
...
@@ -685,7 +688,7 @@ newchar:
// Name/identifier tokens.
tok
=
tal
(
tok_list
,
struct
graphql_token
);
list_add_tail
(
tok_list
,
tok
);
list_add_tail
(
tok_list
,
&
tok
->
list
);
tok
->
token_type
=
'a'
;
tok
->
token_specific
=
'a'
;
// tok->token_string updated below.
...
...
@@ -763,7 +766,7 @@ newchar:
int
num_len
=
num_end
-
num_start
;
tok
=
tal
(
tok_list
,
struct
graphql_token
);
list_add_tail
(
tok_list
,
tok
);
list_add_tail
(
tok_list
,
&
tok
->
list
);
tok
->
token_type
=
type
;
tok
->
token_string
=
tal_strndup
(
tok
,
num_start
,
num_len
);
tok
->
source_line
=
line_num
;
...
...
@@ -845,7 +848,7 @@ newchar:
int
str_len
=
str_end
-
str_begin
;
tok
=
tal
(
tok_list
,
struct
graphql_token
);
list_add_tail
(
tok_list
,
tok
);
list_add_tail
(
tok_list
,
&
tok
->
list
);
tok
->
token_type
=
's'
;
tok
->
token_specific
=
's'
;
tok
->
token_string
=
tal_strndup
(
tok
,
str_begin
,
str_len
);
...
...
@@ -858,13 +861,13 @@ newchar:
char
*
q
=
tok
->
token_string
;
char
*
rewrite_dest
;
int
quotes
=
0
;
while
(
d
=
*
q
++
)
{
while
(
(
d
=
*
q
++
)
)
{
if
(
str_block
)
{
if
(
d
==
'\"'
)
quotes
++
;
else
quotes
=
0
;
if
(
quotes
==
3
&&
*
(
q
-
4
)
==
'\\'
)
{
quotes
=
0
;
rewrite_dest
=
q
-
4
;
strcpy
(
rewrite_dest
,
q
-
3
);
cpystr
(
rewrite_dest
,
q
-
3
);
}
}
else
{
if
(
d
==
'\\'
)
{
...
...
@@ -873,27 +876,27 @@ newchar:
switch
(
d
)
{
case
'\"'
:
*
rewrite_dest
++
=
'\"'
;
strcpy
(
rewrite_dest
,
q
--
);
cpystr
(
rewrite_dest
,
q
--
);
break
;
case
'b'
:
*
rewrite_dest
++
=
'\b'
;
strcpy
(
rewrite_dest
,
q
--
);
cpystr
(
rewrite_dest
,
q
--
);
break
;
case
'f'
:
*
rewrite_dest
++
=
'\f'
;
strcpy
(
rewrite_dest
,
q
--
);
cpystr
(
rewrite_dest
,
q
--
);
break
;
case
'n'
:
*
rewrite_dest
++
=
'\n'
;
strcpy
(
rewrite_dest
,
q
--
);
cpystr
(
rewrite_dest
,
q
--
);
break
;
case
'r'
:
*
rewrite_dest
++
=
'\r'
;
strcpy
(
rewrite_dest
,
q
--
);
cpystr
(
rewrite_dest
,
q
--
);
break
;
case
't'
:
*
rewrite_dest
++
=
'\t'
;
strcpy
(
rewrite_dest
,
q
--
);
cpystr
(
rewrite_dest
,
q
--
);
break
;
case
'u'
:
{
// Insert escaped character using UTF-8 multi-byte encoding.
...
...
@@ -901,11 +904,11 @@ newchar:
int
code_point
=
strtol
(
buf
,
0
,
16
);
int
bytes
=
utf8_encode
(
code_point
,
rewrite_dest
);
rewrite_dest
+=
bytes
;
strcpy
(
rewrite_dest
,
q
--
);
cpystr
(
rewrite_dest
,
q
--
);
}
break
;
default:
strcpy
(
rewrite_dest
,
--
q
);
cpystr
(
rewrite_dest
,
--
q
);
}
}
}
...
...
@@ -920,7 +923,7 @@ newchar:
if
(
LINE_TERMINATOR
(
d
))
{
while
(
LINE_TERMINATOR
(
d
))
d
=
*
q
++
;
strcpy
(
tok
->
token_string
,
q
-
1
);
cpystr
(
tok
->
token_string
,
q
-
1
);
q
=
tok
->
token_string
;
}
else
break
;
...
...
@@ -1001,7 +1004,7 @@ newchar:
d
=
*
q
++
;
--
q
;
strcpy
(
this_indent_start
,
this_indent_start
+
common_indent_len
);
cpystr
(
this_indent_start
,
this_indent_start
+
common_indent_len
);
q
-=
common_indent_len
;
d
=
*
q
++
;
...
...
ccan/graphql/graphql.h
View file @
66333b5b
/* MIT (BSD) license - see LICENSE file for details */
#ifndef __GRAPHQL_H__
#define __GRAPHQL_H__ 1
...
...
ccan/graphql/test/run.c
View file @
66333b5b
#include "ccan/graphql/graphql.h"
/* Include the C files directly. */
#include "ccan/graphql/graphql.c"
#include "ccan/str/str.h"
/* TEST POINT MACROS
...
...
@@ -32,6 +33,7 @@ int pass = 0, fail = 0;
bool
mute
=
1
;
// Helper function.
int
listlen
(
struct
list_head
*
tokens
);
int
listlen
(
struct
list_head
*
tokens
)
{
struct
graphql_token
*
tok
;
int
n
=
0
;
...
...
@@ -41,15 +43,47 @@ int listlen(struct list_head *tokens) {
return
n
;
}
/* Test case function prototypes */
void
check_example_3
(
const
char
*
source
);
void
check_example_5
(
char
*
source
);
void
check_example_6
(
char
*
source
);
void
check_example_7
(
char
*
source
);
void
check_example_8
(
char
*
source
);
void
check_example_9
(
char
*
source
);
void
check_example_10
(
char
*
source
);
void
check_example_11
(
char
*
source
);
void
check_example_12_and_13
(
const
char
*
source
);
void
check_example_14
(
char
*
source
);
void
check_example_16
(
char
*
source
);
void
check_example_18
(
char
*
source
);
void
check_example_19
(
char
*
source
);
void
check_example_20
(
char
*
source
);
void
check_example_21
(
char
*
source
);
void
check_example_23
(
char
*
source
);
void
check_example_24
(
char
*
source
);
void
check_int_value
(
char
*
source
,
int
int_value
);
void
check_invalid_int_values
(
char
*
source
);
void
check_float_value
(
char
*
source
,
float
float_value
,
const
char
*
format
);
void
check_valid_float_values
(
char
*
source
);
void
check_invalid_float_values
(
char
*
source
);
void
check_boolean_values
(
char
*
source
);
void
check_string_value
(
char
*
source
,
const
char
*
test_value
,
const
char
*
expected_result
);
void
check_example_25_and_26
(
const
char
*
source
);
void
check_example_29
(
char
*
source
);
void
check_example_30_and_31
(
const
char
*
source
);
void
check_example_32
(
char
*
source
);
void
check_example_34
(
char
*
source
);
void
check_example_35
(
char
*
source
);
/* Test case functions begin here, called by main().
* Note: Memory should be freed correctly in the success case, but if there
* are errors, all bets are off.
*/
int
check_example_3
(
const
char
*
source
)
{
void
check_example_3
(
const
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 3
\n
"
);
...
...
@@ -170,10 +204,9 @@ int check_example_3(const char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_5
(
char
*
source
)
{
void
check_example_5
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 5
\n
"
);
...
...
@@ -308,10 +341,9 @@ mutation {\n\
tokens
=
tal_free
(
tokens
);
}
int
check_example_6
(
char
*
source
)
{
void
check_example_6
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 6
\n
"
);
...
...
@@ -367,10 +399,9 @@ int check_example_6(char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_7
(
char
*
source
)
{
void
check_example_7
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 7
\n
"
);
...
...
@@ -462,10 +493,9 @@ int check_example_7(char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_8
(
char
*
source
)
{
void
check_example_8
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 8
\n
"
);
...
...
@@ -632,10 +662,9 @@ int check_example_8(char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_9
(
char
*
source
)
{
void
check_example_9
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 9
\n
"
);
...
...
@@ -770,10 +799,9 @@ int check_example_9(char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_10
(
char
*
source
)
{
void
check_example_10
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 10
\n
"
);
...
...
@@ -902,10 +930,9 @@ int check_example_10(char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_11
(
char
*
source
)
{
void
check_example_11
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 11
\n
"
);
...
...
@@ -1048,10 +1075,9 @@ int check_example_11(char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_12_and_13
(
const
char
*
source
)
{
void
check_example_12_and_13
(
const
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example Nos. 12 and 13
\n
"
);
...
...
@@ -1133,10 +1159,9 @@ int check_example_12_and_13(const char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_14
(
char
*
source
)
{
void
check_example_14
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 14
\n
"
);
...
...
@@ -1308,10 +1333,9 @@ int check_example_14(char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_16
(
char
*
source
)
{
void
check_example_16
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 16
\n
"
);
...
...
@@ -1415,10 +1439,8 @@ int check_example_16(char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_18
(
char
*
source
)
{
void
check_example_18
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 18
\n
"
);
...
...
@@ -1474,10 +1496,9 @@ query noFragments {\n\
tokens
=
tal_free
(
tokens
);
}
int
check_example_19
(
char
*
source
)
{
void
check_example_19
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 19
\n
"
);
...
...
@@ -1581,10 +1602,9 @@ fragment friendFields on User {\n\
tokens
=
tal_free
(
tokens
);
}
int
check_example_20
(
char
*
source
)
{
void
check_example_20
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 20
\n
"
);
...
...
@@ -1717,10 +1737,9 @@ fragment standardProfilePic on User {\n\
tokens
=
tal_free
(
tokens
);
}
int
check_example_21
(
char
*
source
)
{
void
check_example_21
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 21
\n
"
);
...
...
@@ -1846,10 +1865,9 @@ fragment pageFragment on Page {\n\
tokens
=
tal_free
(
tokens
);
}
int
check_example_23
(
char
*
source
)
{
void
check_example_23
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 23
\n
"
);
...
...
@@ -1950,10 +1968,9 @@ query inlineFragmentTyping {\n\
tokens
=
tal_free
(
tokens
);
}
int
check_example_24
(
char
*
source
)
{
void
check_example_24
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 24
\n
"
);
...
...
@@ -2090,10 +2107,9 @@ query inlineFragmentNoType($expandedInfo: Boolean) {\n\
tokens
=
tal_free
(
tokens
);
}
int
check_int_value
(
char
*
source
,
int
int_value
)
{
void
check_int_value
(
char
*
source
,
int
int_value
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Int Value Range Check on %d
\n
"
,
int_value
);
...
...
@@ -2160,14 +2176,12 @@ int check_int_value(char *source, int int_value) {
tokens
=
tal_free
(
tokens
);
}
int
check_invalid_int_values
(
char
*
source
)
{
void
check_invalid_int_values
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Invalid Int Values
\n
"
);
char
*
bad_values
[]
=
{
"00"
,
"-00"
,
"+1"
,
"1."
,
"1a"
,
"1e"
,
"0x123"
,
"123L"
,
0
};
c
onst
c
har
*
bad_values
[]
=
{
"00"
,
"-00"
,
"+1"
,
"1."
,
"1a"
,
"1e"
,
"0x123"
,
"123L"
,
0
};
for
(
int
i
=
0
;
bad_values
[
i
];
i
++
)
{
sprintf
(
source
,
"\
...
...
@@ -2187,10 +2201,9 @@ int check_invalid_int_values(char *source) {
}
}
int
check_float_value
(
char
*
source
,
float
float_value
,
const
char
*
format
)
{
void
check_float_value
(
char
*
source
,
float
float_value
,
const
char
*
format
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Float Value Range Check on %f
\n
"
,
float_value
);
...
...
@@ -2257,14 +2270,13 @@ int check_float_value(char *source, float float_value, const char *format) {
tokens
=
tal_free
(
tokens
);
}
int
check_valid_float_values
(
char
*
source
)
{
void
check_valid_float_values
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Valid Float Values
\n
"
);
char
*
good_values
[]
=
{
"1.0"
,
"1e50"
,
"6.0221413e23"
,
"1.23"
,
0
};
c
onst
c
har
*
good_values
[]
=
{
"1.0"
,
"1e50"
,
"6.0221413e23"
,
"1.23"
,
0
};
for
(
int
i
=
0
;
good_values
[
i
];
i
++
)
{
sprintf
(
source
,
"\
...
...
@@ -2328,14 +2340,12 @@ int check_valid_float_values(char *source) {
}
}
int
check_invalid_float_values
(
char
*
source
)
{
void
check_invalid_float_values
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Invalid Float Values
\n
"
);
char
*
bad_values
[]
=
{
"00.0"
,
"-00.0"
,
"00e1"
,
"1.23.4"
,
"0x1.2p3"
,
0
};
c
onst
c
har
*
bad_values
[]
=
{
"00.0"
,
"-00.0"
,
"00e1"
,
"1.23.4"
,
"0x1.2p3"
,
0
};
for
(
int
i
=
0
;
bad_values
[
i
];
i
++
)
{
sprintf
(
source
,
"\
...
...
@@ -2355,14 +2365,12 @@ int check_invalid_float_values(char *source) {
}
}
int
check_boolean_values
(
char
*
source
)
{
void
check_boolean_values
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Boolean Values
\n
"
);
char
*
good_values
[]
=
{
"true"
,
"false"
,
0
};
c
onst
c
har
*
good_values
[]
=
{
"true"
,
"false"
,
0
};
for
(
int
i
=
0
;
good_values
[
i
];
i
++
)
{
sprintf
(
source
,
"\
...
...
@@ -2406,7 +2414,7 @@ int check_boolean_values(char *source) {
tokens
=
tal_free
(
tokens
);
}
char
*
bad_values
[]
=
{
"True"
,
"False"
,
"TRUE"
,
"FALSE"
,
0
};
c
onst
c
har
*
bad_values
[]
=
{
"True"
,
"False"
,
"TRUE"
,
"FALSE"
,
0
};
for
(
int
i
=
0
;
bad_values
[
i
];
i
++
)
{
sprintf
(
source
,
"\
...
...
@@ -2459,10 +2467,9 @@ int check_boolean_values(char *source) {
}
}
int
check_string_value
(
char
*
source
,
const
char
*
test_value
,
const
char
*
expected_result
)
{
void
check_string_value
(
char
*
source
,
const
char
*
test_value
,
const
char
*
expected_result
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// String Value Test: %s
\n
"
,
test_value
);
...
...
@@ -2539,10 +2546,9 @@ int check_string_value(char *source, const char *test_value, const char *expecte
}
}
int
check_example_25_and_26
(
const
char
*
source
)
{
void
check_example_25_and_26
(
const
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 25 and 26
\n
"
);
...
...
@@ -2562,10 +2568,9 @@ int check_example_25_and_26(const char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_29
(
char
*
source
)
{
void
check_example_29
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 29
\n
"
);
...
...
@@ -2647,10 +2652,9 @@ int check_example_29(char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_30_and_31
(
const
char
*
source
)
{
void
check_example_30_and_31
(
const
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 30 and 31
\n
"
);
...
...
@@ -2678,7 +2682,6 @@ int check_example_30_and_31(const char *source) {
tokens
=
tal_free
(
tokens
);
// Test the parser.
struct
graphql_argument
*
arg
;
struct
graphql_executable_document
*
doc
;
const
char
*
e
;
TEST_CONT
(
graphql_lex
(
source
,
NULL
,
&
tokens
)
==
NULL
);
...
...
@@ -2739,10 +2742,9 @@ int check_example_30_and_31(const char *source) {
tokens
=
tal_free
(
tokens
);
}
int
check_example_32
(
char
*
source
)
{
void
check_example_32
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 32
\n
"
);
...
...
@@ -2892,10 +2894,9 @@ query getZuckProfile($devicePicSize: Int) {\n\
tokens
=
tal_free
(
tokens
);
}
int
check_example_34
(
char
*
source
)
{
void
check_example_34
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 34
\n
"
);
...
...
@@ -2944,10 +2945,9 @@ type Person\n\
tokens
=
tal_free
(
tokens
);
}
int
check_example_35
(
char
*
source
)
{
void
check_example_35
(
char
*
source
)
{
struct
list_head
*
tokens
;
struct
graphql_token
*
tok
;
const
char
*
err
;
if
(
!
mute
)
printf
(
"// Example No. 35
\n
"
);
...
...
@@ -3007,10 +3007,10 @@ int main(void)
int
prev_fail
;
// Used by RUNx macros.
// Check the lexer with all valid line terminators.
char
*
new_line
=
"
\n
"
;
char
*
carriage_return
=
"
\r
"
;
char
*
carriage_return_new_line
=
"
\r\n
"
;
char
*
line_terminators
[]
=
{
new_line
,
carriage_return
,
carriage_return_new_line
};
c
onst
c
har
*
new_line
=
"
\n
"
;
c
onst
c
har
*
carriage_return
=
"
\r
"
;
c
onst
c
har
*
carriage_return_new_line
=
"
\r\n
"
;
c
onst
c
har
*
line_terminators
[]
=
{
new_line
,
carriage_return
,
carriage_return_new_line
};
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
sprintf
(
source
,
"\
{%s\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment