Browse Source

FromStringAndSize instead of FromString.

tags/v0.2
Ben Kurtovic 12 years ago
parent
commit
467aef3651
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      mwparserfromhell/parser/tokenizer.c

+ 5
- 5
mwparserfromhell/parser/tokenizer.c View File

@@ -421,7 +421,7 @@ Tokenizer_parse_template_or_argument(Tokenizer* self)
RESET_ROUTE(); RESET_ROUTE();
char bracestr[braces]; char bracestr[braces];
for (i = 0; i < braces; i++) bracestr[i] = *"{"; for (i = 0; i < braces; i++) bracestr[i] = *"{";
PyObject* text = PyUnicode_FromString(bracestr);
PyObject* text = PyUnicode_FromStringAndSize(bracestr, braces);


if (Tokenizer_write_text_then_stack(self, text)) { if (Tokenizer_write_text_then_stack(self, text)) {
Py_XDECREF(text); Py_XDECREF(text);
@@ -977,7 +977,7 @@ Tokenizer_parse_heading(Tokenizer* self)
self->head = reset + best - 1; self->head = reset + best - 1;
char blocks[best]; char blocks[best];
for (i = 0; i < best; i++) blocks[i] = *"="; for (i = 0; i < best; i++) blocks[i] = *"=";
text = PyUnicode_FromString(blocks);
text = PyUnicode_FromStringAndSize(blocks, best);
if (!text) return -1; if (!text) return -1;


if (Tokenizer_write_text_then_stack(self, text)) { if (Tokenizer_write_text_then_stack(self, text)) {
@@ -1035,7 +1035,7 @@ Tokenizer_parse_heading(Tokenizer* self)
Py_ssize_t diff = best - heading->level; Py_ssize_t diff = best - heading->level;
char diffblocks[diff]; char diffblocks[diff];
for (i = 0; i < diff; i++) diffblocks[i] = *"="; for (i = 0; i < diff; i++) diffblocks[i] = *"=";
PyObject* text = PyUnicode_FromString(diffblocks);
PyObject* text = PyUnicode_FromStringAndSize(diffblocks, diff);
if (!text) { if (!text) {
Py_DECREF(heading->title); Py_DECREF(heading->title);
free(heading); free(heading);
@@ -1104,7 +1104,7 @@ Tokenizer_handle_heading_end(Tokenizer* self)
Py_ssize_t diff = best - level; Py_ssize_t diff = best - level;
char diffblocks[diff]; char diffblocks[diff];
for (i = 0; i < diff; i++) diffblocks[i] = *"="; for (i = 0; i < diff; i++) diffblocks[i] = *"=";
text = PyUnicode_FromString(diffblocks);
text = PyUnicode_FromStringAndSize(diffblocks, diff);
if (!text) return NULL; if (!text) return NULL;


if (Tokenizer_write_text_then_stack(self, text)) { if (Tokenizer_write_text_then_stack(self, text)) {
@@ -1120,7 +1120,7 @@ Tokenizer_handle_heading_end(Tokenizer* self)
else { else {
char blocks[best]; char blocks[best];
for (i = 0; i < best; i++) blocks[i] = *"="; for (i = 0; i < best; i++) blocks[i] = *"=";
text = PyUnicode_FromString(blocks);
text = PyUnicode_FromStringAndSize(blocks, best);
if (!text) { if (!text) {
Py_DECREF(after->title); Py_DECREF(after->title);
free(after); free(after);


Loading…
Cancel
Save