Преглед на файлове

Fix compilation issue on Travis since GCC uses C90 by default there.

tags/v0.5
Ben Kurtovic преди 7 години
родител
ревизия
6ee61789da
променени са 3 файла, в които са добавени 20 реда и са изтрити 4 реда
  1. +17
    -0
      mwparserfromhell/parser/ctokenizer/tok_support.c
  2. +1
    -0
      mwparserfromhell/parser/ctokenizer/tok_support.h
  3. +2
    -4
      mwparserfromhell/parser/ctokenizer/tokenizer.c

+ 17
- 0
mwparserfromhell/parser/ctokenizer/tok_support.c Целия файл

@@ -196,6 +196,23 @@ int Tokenizer_check_route(Tokenizer* self, uint64_t context)
}

/*
Free the tokenizer's bad route cache tree. Intended to be called by the
main tokenizer function after parsing is finished.
*/
void Tokenizer_free_bad_route_tree(Tokenizer *self)
{
struct avl_tree_node *cur = avl_tree_first_in_postorder(self->bad_routes);
struct avl_tree_node *parent;
while (cur) {
route_tree_node *node = avl_tree_entry(cur, route_tree_node, node);
parent = avl_get_parent(cur);
free(node);
cur = avl_tree_next_in_postorder(cur, parent);
}
self->bad_routes = NULL;
}

/*
Write a token to the current token stack.
*/
int Tokenizer_emit_token(Tokenizer* self, PyObject* token, int first)


+ 1
- 0
mwparserfromhell/parser/ctokenizer/tok_support.h Целия файл

@@ -33,6 +33,7 @@ PyObject* Tokenizer_pop(Tokenizer*);
PyObject* Tokenizer_pop_keeping_context(Tokenizer*);
void* Tokenizer_fail_route(Tokenizer*);
int Tokenizer_check_route(Tokenizer*, uint64_t);
void Tokenizer_free_bad_route_tree(Tokenizer*);

int Tokenizer_emit_token(Tokenizer*, PyObject*, int);
int Tokenizer_emit_token_kwargs(Tokenizer*, PyObject*, PyObject*, int);


+ 2
- 4
mwparserfromhell/parser/ctokenizer/tokenizer.c Целия файл

@@ -22,6 +22,7 @@ SOFTWARE.

#include "tokenizer.h"
#include "tok_parse.h"
#include "tok_support.h"
#include "tokens.h"

/* Globals */
@@ -165,10 +166,7 @@ static PyObject* Tokenizer_tokenize(Tokenizer* self, PyObject* args)

tokens = Tokenizer_parse(self, context, 1);

route_tree_node *n;
avl_tree_for_each_in_postorder(n, self->bad_routes, route_tree_node, node)
free(n);
self->bad_routes = NULL;
Tokenizer_free_bad_route_tree(self);

if (!tokens || self->topstack) {
Py_XDECREF(tokens);


Зареждане…
Отказ
Запис