-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse NaN from object like {"n": NaN} #25
Conversation
This is ready for an initial review. "make check" passes, but there's not yet any test for the new NaN parsing. The next steps are to control this NaN parsing with a compile-time or runtime option, and to add a test for it that expects success or failure depending on whether NaN parsing is enabled. Would you like to do those steps, or tell me how I should do them? |
state->special_flags &= ~JSONSL_SPECIALf_NULL; | ||
} | ||
|
||
if (tolower(CUR_CHAR) != 'a') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it's two "!=" statements, so CUR_CHAR might be neither 'a', 'N', nor 'n', I think we have to check both if statements.
jsonsl.c
Outdated
@@ -1425,11 +1440,13 @@ static unsigned short Special_Table[0x100] = { | |||
/* 0x37 */ JSONSL_SPECIALf_UNSIGNED /* <7> */, /* 0x37 */ | |||
/* 0x38 */ JSONSL_SPECIALf_UNSIGNED /* <8> */, /* 0x38 */ | |||
/* 0x39 */ JSONSL_SPECIALf_UNSIGNED /* <9> */, /* 0x39 */ | |||
/* 0x3a */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x59 */ | |||
/* 0x3a */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |||
/* 0x4e */ JSONSL_SPECIALf_NAN /* <N> */, /* 0x4e */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this table is generated by a Perl script. Better to modify it there.
jsonsl.c
Outdated
/* 0x5a */ 0,0,0,0,0,0,0,0,0,0,0,0, /* 0x65 */ | ||
/* 0x66 */ JSONSL_SPECIALf_FALSE /* <f> */, /* 0x66 */ | ||
/* 0x67 */ 0,0,0,0,0,0,0, /* 0x6d */ | ||
/* 0x6e */ JSONSL_SPECIALf_NULL /* <n> */, /* 0x6e */ | ||
/* 0x6e */ JSONSL_SPECIALf_NULL | JSONSL_SPECIALf_NAN /* <n> */, /* 0x6e */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likewise
Regarding tests - all existing parse tests load from a file. You'd make a new file and simply feed a |
oops. didn't mean to close |
I see the tests didn't work on Travis as they did on my machine, investigating.... |
OK, this pull request is ready for review. |
Can you squash these into a single commit? Also, I'm still a bit uneasy about having the NaN parsing around there as dead code even if it's not being compiled that way. I have another idea. How about making a proxy variable.. e.g. (in the character table for
Then..
You can even go one step further and only define the enum value if This way, the current (pre-nan) code can remain the same, and newer code/branches can be added on only if So basically:
Because |
Parsing is case-insensitive. Closes mnunberg#24.
Done, let me know if I followed your instructions correctly. |
yep! exactly what I had in mind. thanks for the contribution! |
Parsing is case-insensitive. Closes #24.