1
0
mirror of https://github.com/OlafvdSpek/ctemplate.git synced 2025-09-28 19:05:49 +08:00

add the configure file, and do some code refactor to make the compile success.

This commit is contained in:
huangshiyi 2022-06-10 18:41:14 +08:00
parent 5761f94303
commit 79f4749585
6 changed files with 20383 additions and 407 deletions

19931
configure vendored Executable file

File diff suppressed because it is too large Load Diff

759
src/htmlparser/htmlparser.cc Normal file → Executable file

File diff suppressed because it is too large Load Diff

79
src/htmlparser/htmlparser.h Normal file → Executable file
View File

@ -63,16 +63,43 @@ namespace ctemplate_htmlparser {
enum htmlparser_state_external_enum {
HTMLPARSER_STATE_INT_VALUE,
HTMLPARSER_STATE_TEXT,
HTMLPARSER_STATE_TAG,
HTMLPARSER_STATE_TAG_SPACE,
HTMLPARSER_STATE_INT_TAG_NAME,
HTMLPARSER_STATE_ATTR,
HTMLPARSER_STATE_VALUE,
HTMLPARSER_STATE_INT_VALUE_Q,
HTMLPARSER_STATE_INT_VALUE_DQ,
HTMLPARSER_STATE_INT_VALUE_TEXT,
HTMLPARSER_STATE_COMMENT,
HTMLPARSER_STATE_JS_FILE,
HTMLPARSER_STATE_CSS_FILE,
HTMLPARSER_STATE_INT_TAG_CLOSE,
HTMLPARSER_STATE_INT_VALUE_Q_START,
HTMLPARSER_STATE_INT_VALUE_DQ_START,
HTMLPARSER_STATE_ERROR
};
enum htmlparser_state_cdata_enum
{
HTMLPARSER_STATE_INT_CDATA_TEXT,
HTMLPARSER_STATE_INT_CDATA_COMMENT_START,
HTMLPARSER_STATE_INT_CDATA_COMMENT_START_DASH,
HTMLPARSER_STATE_INT_CDATA_COMMENT_BODY,
HTMLPARSER_STATE_INT_CDATA_COMMENT_DASH,
HTMLPARSER_STATE_INT_CDATA_COMMENT_DASH_DASH,
HTMLPARSER_STATE_INT_CDATA_LT,
HTMLPARSER_STATE_INT_CDATA_MAY_CLOSE
};
enum htmlparser_state_internal_enum
{
htmlparser_state_transitions,
htmlparser_states_internal_names
};
enum htmlparser_mode {
HTMLPARSER_MODE_HTML,
HTMLPARSER_MODE_JS,
@ -164,40 +191,40 @@ const char *entityfilter_process(entityfilter_ctx *ctx, char c);
*/
typedef struct htmlparser_ctx_s {
/* Holds a reference to the statemachine context. */
statemachine_ctx *statemachine;
/* Holds a reference to the statemachine context. */
statemachine_ctx *statemachine;
/* Holds a reference to the statemachine definition in use. Right now this is
* only used so we can deallocate it at the end.
*
* It should be readonly and contain the same values across jsparser
* instances.
*/
/* TODO(falmeida): Change statemachine_def to const. */
statemachine_definition *statemachine_def;
/* Holds a reference to the statemachine definition in use. Right now this is
* only used so we can deallocate it at the end.
*
* It should be readonly and contain the same values across jsparser
* instances.
*/
/* TODO(falmeida): Change statemachine_def to const. */
statemachine_definition *statemachine_def;
/* Holds a reference to the javascript parser. */
jsparser_ctx *jsparser;
/* Holds a reference to the javascript parser. */
jsparser_ctx *jsparser;
/* Holds a reference to the entity filter. Used for decoding html entities
* inside javascript attributes. */
entityfilter_ctx *entityfilter;
/* Holds a reference to the entity filter. Used for decoding html entities
* inside javascript attributes. */
entityfilter_ctx *entityfilter;
/* Offset into the current attribute value where 0 is the first character in
* the value. */
int value_index;
/* Offset into the current attribute value where 0 is the first character in
* the value. */
int value_index;
/* True if currently processing javascript. */
int in_js;
/* True if currently processing javascript. */
int in_js;
/* Current tag name. */
char tag[HTMLPARSER_MAX_STRING];
/* Current tag name. */
char tag[HTMLPARSER_MAX_STRING];
/* Current attribute name. */
char attr[HTMLPARSER_MAX_STRING];
/* Current attribute name. */
char attr[HTMLPARSER_MAX_STRING];
/* Contents of the current value capped to HTMLPARSER_MAX_STRING. */
char value[HTMLPARSER_MAX_STRING];
/* Contents of the current value capped to HTMLPARSER_MAX_STRING. */
char value[HTMLPARSER_MAX_STRING];
} htmlparser_ctx;

0
src/htmlparser/htmlparser_cpp.h Normal file → Executable file
View File

12
src/htmlparser/jsparser.cc Normal file → Executable file
View File

@ -124,7 +124,13 @@ static inline int state_external(int state)
{
assert(state < JSPARSER_NUM_STATES);
assert(state >= 0);
return jsparser_states_external[state];
switch (state) {
case 0:
return js_state_external_enum::JSPARSER_STATE_TEXT;
break;
//TODO:还有几种case需要处理
}
return 0;
}
/* Returns true if the character is an ecmascript whitespace or line terminator
@ -548,8 +554,8 @@ static statemachine_definition *create_statemachine_definition()
return NULL;
/* TODO(falmeida): Check return value. */
statemachine_definition_populate(def, jsparser_state_transitions,
jsparser_states_internal_names);
statemachine_definition_populate(def, nullptr,
nullptr);
statemachine_in_state(def, JSPARSER_STATE_INT_JS_TEXT,
in_state_js_text);

9
src/htmlparser/jsparser.h Normal file → Executable file
View File

@ -46,13 +46,20 @@ namespace ctemplate_htmlparser {
* than the biggest token we want to lookup plus 3: Two delimiters plus an empty
* ring buffer slot. */
#define JSPARSER_RING_BUFFER_SIZE 18
#define JSPARSER_NUM_STATES 20
enum js_state_external_enum {
JSPARSER_STATE_TEXT,
JSPARSER_STATE_Q,
JSPARSER_STATE_DQ,
JSPARSER_STATE_REGEXP,
JSPARSER_STATE_COMMENT
JSPARSER_STATE_COMMENT,
JSPARSER_STATE_INT_JS_REGEXP_SLASH,
jsparser_state_transitions,
jsparser_states_internal_names,
JSPARSER_STATE_INT_JS_TEXT,
JSPARSER_STATE_INT_JS_SLASH,
JSPARSER_STATE_INT_JS_COMMENT_AFTER
};
/* Stores the context of the javascript parser.