From 1fbc93bdf97dde6b07b67abb29a71d779f533dd8 Mon Sep 17 00:00:00 2001 From: Jonathan Tang Date: Wed, 28 Aug 2013 14:03:46 -0700 Subject: [PATCH] Gumbo: Integrate from GitHub. This syncs up to https://github.com/google/gumbo-parser/commit/17d5f7b6789b89506f78ce2d6126eac75204aaab Commits included in this CL: * Change naming convention for struct tags from _Gumbo to GumboInternal so it doesn't violate C reserved word conventions. https://github.com/google/gumbo-parser/commit/1e892b1a1d98c4c85237010f0cf44e441aefa0ee Also added the .gitmodules, CONTRIBUTING.md, autogen.sh, and gumbo_parser.gyp files, which have been contributed by outside authors but didn't make it into the last integration. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=51549719 --- CONTRIBUTING.md | 2 +- autogen.sh | 0 src/char_ref.c | 2 +- src/char_ref.h | 4 ++-- src/tokenizer.h | 2 +- src/utf8.h | 6 +++--- src/util.h | 3 ++- src/vector.c | 6 ++++-- src/vector.h | 9 ++++++--- 9 files changed, 20 insertions(+), 14 deletions(-) mode change 100755 => 100644 autogen.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f47f0dcf..b99612a5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,6 +7,6 @@ Patches and pull requests are also welcome, but before accepting patches, I need https://developers.google.com/open-source/cla/individual https://developers.google.com/open-source/cla/corporate -(Electronic signatures are fine or individual contributors.) +(Electronic signatures are fine for individual contributors.) If you're unwilling to do this, it would be most helpful if you could file bug reports that include detailed prose about where in the code the error is and how to fix it, but leave out exact source code. diff --git a/autogen.sh b/autogen.sh old mode 100755 new mode 100644 diff --git a/src/char_ref.c b/src/char_ref.c index 8f196714..73160c9b 100644 --- a/src/char_ref.c +++ b/src/char_ref.c @@ -2530,7 +2530,7 @@ static bool consume_named_ref( } bool consume_char_ref( - struct GumboInternalParser* parser, struct _Utf8Iterator* input, + struct GumboInternalParser* parser, struct GumboInternalUtf8Iterator* input, int additional_allowed_char, bool is_in_attribute, OneOrTwoCodepoints* output) { utf8iterator_mark(input); diff --git a/src/char_ref.h b/src/char_ref.h index 42478cb7..07afd02a 100644 --- a/src/char_ref.h +++ b/src/char_ref.h @@ -28,7 +28,7 @@ extern "C" { #endif struct GumboInternalParser; -struct _Utf8Iterator; +struct GumboInternalUtf8Iterator; // Value that indicates no character was produced. extern const int kGumboNoChar; @@ -50,7 +50,7 @@ typedef struct { // space for the "additional allowed char" when the spec says "with no // additional allowed char". Returns false on parse error, true otherwise. bool consume_char_ref( - struct GumboInternalParser* parser, struct _Utf8Iterator* input, + struct GumboInternalParser* parser, struct GumboInternalUtf8Iterator* input, int additional_allowed_char, bool is_in_attribute, OneOrTwoCodepoints* output); diff --git a/src/tokenizer.h b/src/tokenizer.h index 432e6899..aacb72cc 100644 --- a/src/tokenizer.h +++ b/src/tokenizer.h @@ -108,7 +108,7 @@ bool gumbo_lex(struct GumboInternalParser* parser, GumboToken* output); // Frees the internally-allocated pointers within an GumboToken. Note that this // doesn't free the token itself, since oftentimes it will be allocated on the -// stack. A simple call to free() (or struct GumboInternalParser->deallocator, if +// stack. A simple call to free() (or GumboParser->deallocator, if // appropriate) can handle that. // // Note that if you are handing over ownership of the internal strings to some diff --git a/src/utf8.h b/src/utf8.h index c37e0e30..3efc77d4 100644 --- a/src/utf8.h +++ b/src/utf8.h @@ -47,7 +47,7 @@ struct GumboInternalParser; // Unicode replacement char. extern const int kUtf8ReplacementChar; -typedef struct _Utf8Iterator { +typedef struct GumboInternalUtf8Iterator { // Points at the start of the code point most recently read into 'current'. const char* _start; @@ -82,8 +82,8 @@ bool utf8_is_invalid_code_point(int c); // Initializes a new Utf8Iterator from the given byte buffer. The source does // not have to be NUL-terminated, but the length must be passed in explicitly. void utf8iterator_init( - struct GumboInternalParser* parser, const char* source, size_t source_length, - Utf8Iterator* iter); + struct GumboInternalParser* parser, const char* source, + size_t source_length, Utf8Iterator* iter); // Advances the current position by one code point. void utf8iterator_next(Utf8Iterator* iter); diff --git a/src/util.h b/src/util.h index a6a37bc5..a772ad75 100644 --- a/src/util.h +++ b/src/util.h @@ -40,7 +40,8 @@ char* gumbo_copy_stringz(struct GumboInternalParser* parser, const char* str); // Allocate a chunk of memory, using the allocator specified in the Parser's // config options. -void* gumbo_parser_allocate(struct GumboInternalParser* parser, size_t num_bytes); +void* gumbo_parser_allocate( + struct GumboInternalParser* parser, size_t num_bytes); // Deallocate a chunk of memory, using the deallocator specified in the Parser's // config options. diff --git a/src/vector.c b/src/vector.c index 16ac7a04..f6b7d88d 100644 --- a/src/vector.c +++ b/src/vector.c @@ -73,7 +73,8 @@ void gumbo_vector_add( vector->data[vector->length++] = element; } -void* gumbo_vector_pop(struct GumboInternalParser* parser, GumboVector* vector) { +void* gumbo_vector_pop( + struct GumboInternalParser* parser, GumboVector* vector) { if (vector->length == 0) { return NULL; } @@ -90,7 +91,8 @@ int gumbo_vector_index_of(GumboVector* vector, void* element) { } void gumbo_vector_insert_at( - struct GumboInternalParser* parser, void* element, int index, GumboVector* vector) { + struct GumboInternalParser* parser, void* element, int index, + GumboVector* vector) { assert(index >= 0); assert(index <= vector->length); enlarge_vector_if_full(parser, vector); diff --git a/src/vector.h b/src/vector.h index b411f604..a78f20de 100644 --- a/src/vector.h +++ b/src/vector.h @@ -29,11 +29,13 @@ struct GumboInternalParser; // Initializes a new GumboVector with the specified initial capacity. void gumbo_vector_init( - struct GumboInternalParser* parser, size_t initial_capacity, GumboVector* vector); + struct GumboInternalParser* parser, size_t initial_capacity, + GumboVector* vector); // Frees the memory used by an GumboVector. Does not free the contained // pointers. -void gumbo_vector_destroy(struct GumboInternalParser* parser, GumboVector* vector); +void gumbo_vector_destroy( + struct GumboInternalParser* parser, GumboVector* vector); // Adds a new element to an GumboVector. void gumbo_vector_add( @@ -47,7 +49,8 @@ void* gumbo_vector_pop(struct GumboInternalParser* parser, GumboVector* vector); // Inserts an element at a specific index. This is potentially O(N) time, but // is necessary for some of the spec's behavior. void gumbo_vector_insert_at( - struct GumboInternalParser* parser, void* element, int index, GumboVector* vector); + struct GumboInternalParser* parser, void* element, int index, + GumboVector* vector); // Removes an element from the vector, or does nothing if the element is not in // the vector.