Permalink
Browse files

whitespace cleanup

  • Loading branch information...
lloyd committed Mar 17, 2014
1 parent ca5ca36 commit fcfff36b3bacec948ca5292f5191bcbcd52a5266
Showing with 62 additions and 61 deletions.
  1. +1 −0 src/api/yajl_tree.h
  2. +52 −52 src/yajl_lex.c
  3. +9 −9 src/yajl_lex.h
View
@@ -121,6 +121,7 @@ struct yajl_val_s
YAJL_API yajl_val yajl_tree_parse (const char *input,
char *error_buffer, size_t error_buffer_size);
+
/**
* Free a parse tree returned by "yajl_tree_parse".
*
View
@@ -24,7 +24,7 @@
#ifdef YAJL_LEXER_DEBUG
static const char *
-tokToStr(yajl_tok tok)
+tokToStr(yajl_tok tok)
{
switch (tok) {
case yajl_tok_bool: return "bool";
@@ -53,13 +53,13 @@ tokToStr(yajl_tok tok)
* the network or disk). This makes the lexer more complex. The
* responsibility of the lexer is to handle transparently the case where
* a chunk boundary falls in the middle of a token. This is
- * accomplished is via a buffer and a character reading abstraction.
+ * accomplished is via a buffer and a character reading abstraction.
*
* Overview of implementation
*
* When we lex to end of input string before end of token is hit, we
* copy all of the input text composing the token into our lexBuf.
- *
+ *
* Every time we read a character, we do so through the readChar function.
* readChar's responsibility is to handle pulling all chars from the buffer
* before pulling chars from input text
@@ -74,7 +74,7 @@ struct yajl_lexer_t {
yajl_lex_error error;
/* a input buffer to handle the case where a token is spread over
- * multiple chunks */
+ * multiple chunks */
yajl_buf buf;
/* in the case where we have data in the lexBuf, bufOff holds
@@ -186,7 +186,7 @@ static const char charLookupTable[256] =
* yajl_tok_eof - if end of input was hit before validation could
* complete
* yajl_tok_error - if invalid utf8 was encountered
- *
+ *
* NOTE: on error the offset will point to the first char of the
* invalid utf8 */
#define UTF8_CHECK_EOF if (*offset >= jsonTextLen) { return yajl_tok_eof; }
@@ -200,7 +200,7 @@ yajl_lex_utf8_char(yajl_lexer lexer, const unsigned char * jsonText,
/* single byte */
return yajl_tok_string;
} else if ((curChar >> 5) == 0x6) {
- /* two byte */
+ /* two byte */
UTF8_CHECK_EOF;
curChar = readChar(lexer, jsonText, offset);
if ((curChar >> 6) == 0x2) return yajl_tok_string;
@@ -226,7 +226,7 @@ yajl_lex_utf8_char(yajl_lexer lexer, const unsigned char * jsonText,
if ((curChar >> 6) == 0x2) return yajl_tok_string;
}
}
- }
+ }
return yajl_tok_error;
}
@@ -279,16 +279,16 @@ yajl_lex_string(yajl_lexer lexer, const unsigned char * jsonText,
{
const unsigned char * p;
size_t len;
-
+
if ((lexer->bufInUse && yajl_buf_len(lexer->buf) &&
lexer->bufOff < yajl_buf_len(lexer->buf)))
{
p = ((const unsigned char *) yajl_buf_data(lexer->buf) +
(lexer->bufOff));
len = yajl_buf_len(lexer->buf) - lexer->bufOff;
lexer->bufOff += yajl_string_scan(p, len, lexer->validateUTF8);
- }
- else if (*offset < jsonTextLen)
+ }
+ else if (*offset < jsonTextLen)
{
p = jsonText + *offset;
len = jsonTextLen - *offset;
@@ -316,8 +316,8 @@ yajl_lex_string(yajl_lexer lexer, const unsigned char * jsonText,
unsigned int i = 0;
for (i=0;i<4;i++) {
- STR_CHECK_EOF;
- curChar = readChar(lexer, jsonText, offset);
+ STR_CHECK_EOF;
+ curChar = readChar(lexer, jsonText, offset);
if (!(charLookupTable[curChar] & VHC)) {
/* back up to offending char */
unreadChar(lexer, offset);
@@ -329,38 +329,38 @@ yajl_lex_string(yajl_lexer lexer, const unsigned char * jsonText,
/* back up to offending char */
unreadChar(lexer, offset);
lexer->error = yajl_lex_string_invalid_escaped_char;
- goto finish_string_lex;
- }
+ goto finish_string_lex;
+ }
}
/* when not validating UTF8 it's a simple table lookup to determine
* if the present character is invalid */
else if(charLookupTable[curChar] & IJC) {
/* back up to offending char */
unreadChar(lexer, offset);
lexer->error = yajl_lex_string_invalid_json_char;
- goto finish_string_lex;
+ goto finish_string_lex;
}
/* when in validate UTF8 mode we need to do some extra work */
else if (lexer->validateUTF8) {
yajl_tok t = yajl_lex_utf8_char(lexer, jsonText, jsonTextLen,
offset, curChar);
-
+
if (t == yajl_tok_eof) {
tok = yajl_tok_eof;
goto finish_string_lex;
} else if (t == yajl_tok_error) {
lexer->error = yajl_lex_string_invalid_utf8;
goto finish_string_lex;
- }
+ }
}
- /* accept it, and move on */
+ /* accept it, and move on */
}
finish_string_lex:
/* tell our buddy, the parser, wether he needs to process this string
* again */
if (hasEscapes && tok == yajl_tok_string) {
tok = yajl_tok_string_with_escapes;
- }
+ }
return tok;
}
@@ -379,23 +379,23 @@ yajl_lex_number(yajl_lexer lexer, const unsigned char * jsonText,
yajl_tok tok = yajl_tok_integer;
- RETURN_IF_EOF;
+ RETURN_IF_EOF;
c = readChar(lexer, jsonText, offset);
/* optional leading minus */
if (c == '-') {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
+ RETURN_IF_EOF;
+ c = readChar(lexer, jsonText, offset);
}
/* a single zero, or a series of integers */
if (c == '0') {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
+ RETURN_IF_EOF;
+ c = readChar(lexer, jsonText, offset);
} else if (c >= '1' && c <= '9') {
do {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
+ RETURN_IF_EOF;
+ c = readChar(lexer, jsonText, offset);
} while (c >= '0' && c <= '9');
} else {
unreadChar(lexer, offset);
@@ -406,15 +406,15 @@ yajl_lex_number(yajl_lexer lexer, const unsigned char * jsonText,
/* optional fraction (indicates this is floating point) */
if (c == '.') {
int numRd = 0;
-
+
RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
+ c = readChar(lexer, jsonText, offset);
while (c >= '0' && c <= '9') {
numRd++;
RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
- }
+ c = readChar(lexer, jsonText, offset);
+ }
if (!numRd) {
unreadChar(lexer, offset);
@@ -427,18 +427,18 @@ yajl_lex_number(yajl_lexer lexer, const unsigned char * jsonText,
/* optional exponent (indicates this is floating point) */
if (c == 'e' || c == 'E') {
RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
+ c = readChar(lexer, jsonText, offset);
/* optional sign */
if (c == '+' || c == '-') {
RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
+ c = readChar(lexer, jsonText, offset);
}
if (c >= '0' && c <= '9') {
do {
RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
+ c = readChar(lexer, jsonText, offset);
} while (c >= '0' && c <= '9');
} else {
unreadChar(lexer, offset);
@@ -447,10 +447,10 @@ yajl_lex_number(yajl_lexer lexer, const unsigned char * jsonText,
}
tok = yajl_tok_double;
}
-
+
/* we always go "one too far" */
unreadChar(lexer, offset);
-
+
return tok;
}
@@ -462,24 +462,24 @@ yajl_lex_comment(yajl_lexer lexer, const unsigned char * jsonText,
yajl_tok tok = yajl_tok_comment;
- RETURN_IF_EOF;
+ RETURN_IF_EOF;
c = readChar(lexer, jsonText, offset);
/* either slash or star expected */
if (c == '/') {
/* now we throw away until end of line */
do {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
+ RETURN_IF_EOF;
+ c = readChar(lexer, jsonText, offset);
} while (c != '\n');
} else if (c == '*') {
- /* now we throw away until end of comment */
+ /* now we throw away until end of comment */
for (;;) {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
+ RETURN_IF_EOF;
+ c = readChar(lexer, jsonText, offset);
if (c == '*') {
- RETURN_IF_EOF;
- c = readChar(lexer, jsonText, offset);
+ RETURN_IF_EOF;
+ c = readChar(lexer, jsonText, offset);
if (c == '/') {
break;
} else {
@@ -491,7 +491,7 @@ yajl_lex_comment(yajl_lexer lexer, const unsigned char * jsonText,
lexer->error = yajl_lex_invalid_char;
tok = yajl_tok_error;
}
-
+
return tok;
}
@@ -599,7 +599,7 @@ yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
goto lexed;
}
case '-':
- case '0': case '1': case '2': case '3': case '4':
+ case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9': {
/* integer parsing wants to start from the beginning */
unreadChar(lexer, offset);
@@ -626,11 +626,11 @@ yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
jsonTextLen, offset);
if (tok == yajl_tok_comment) {
/* "error" is silly, but that's the initial
- * state of tok. guilty until proven innocent. */
+ * state of tok. guilty until proven innocent. */
tok = yajl_tok_error;
yajl_buf_clear(lexer->buf);
lexer->bufInUse = 0;
- startOffset = *offset;
+ startOffset = *offset;
break;
}
/* hit error or eof, bail */
@@ -651,7 +651,7 @@ yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
lexer->bufInUse = 1;
yajl_buf_append(lexer->buf, jsonText + startOffset, *offset - startOffset);
lexer->bufOff = 0;
-
+
if (tok != yajl_tok_eof) {
*outBuf = yajl_buf_data(lexer->buf);
*outLen = yajl_buf_len(lexer->buf);
@@ -667,7 +667,7 @@ yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
{
assert(*outLen >= 2);
(*outBuf)++;
- *outLen -= 2;
+ *outLen -= 2;
}
@@ -698,7 +698,7 @@ yajl_lex_error_to_string(yajl_lex_error error)
case yajl_lex_string_invalid_escaped_char:
return "inside a string, '\\' occurs before a character "
"which it may not.";
- case yajl_lex_string_invalid_json_char:
+ case yajl_lex_string_invalid_json_char:
return "invalid character inside string.";
case yajl_lex_string_invalid_hex_char:
return "invalid (non-hex) character occurs after '\\u' inside "
@@ -751,13 +751,13 @@ yajl_tok yajl_lex_peek(yajl_lexer lexer, const unsigned char * jsonText,
size_t bufOff = lexer->bufOff;
unsigned int bufInUse = lexer->bufInUse;
yajl_tok tok;
-
+
tok = yajl_lex_lex(lexer, jsonText, jsonTextLen, &offset,
&outBuf, &outLen);
lexer->bufOff = bufOff;
lexer->bufInUse = bufInUse;
yajl_buf_truncate(lexer->buf, bufLen);
-
+
return tok;
}
View
@@ -20,21 +20,21 @@
#include "api/yajl_common.h"
typedef enum {
- yajl_tok_bool,
+ yajl_tok_bool,
yajl_tok_colon,
- yajl_tok_comma,
+ yajl_tok_comma,
yajl_tok_eof,
yajl_tok_error,
- yajl_tok_left_brace,
+ yajl_tok_left_brace,
yajl_tok_left_bracket,
- yajl_tok_null,
- yajl_tok_right_brace,
+ yajl_tok_null,
+ yajl_tok_right_brace,
yajl_tok_right_bracket,
/* we differentiate between integers and doubles to allow the
* parser to interpret the number without re-scanning */
- yajl_tok_integer,
- yajl_tok_double,
+ yajl_tok_integer,
+ yajl_tok_double,
/* we differentiate between strings which require further processing,
* and strings that do not */
@@ -61,11 +61,11 @@ void yajl_lex_free(yajl_lexer lexer);
*
* the client may be interested in the value of offset when an error is
* returned from the lexer. This allows the client to render useful
-n * error messages.
+ * error messages.
*
* When you pass the next chunk of data, context should be reinitialized
* to zero.
- *
+ *
* Finally, the output buffer is usually just a pointer into the jsonText,
* however in cases where the entity being lexed spans multiple chunks,
* the lexer will buffer the entity and the data returned will be

0 comments on commit fcfff36

Please sign in to comment.