mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 11:19:32 -06:00
fix the encoding problem with unicode literals in the Python binding
This commit is contained in:
@@ -148,7 +148,7 @@ typedef enum {
|
|||||||
|
|
||||||
struct PgfExprParser {
|
struct PgfExprParser {
|
||||||
GuExn* err;
|
GuExn* err;
|
||||||
GuReader* rdr;
|
GuIn* in;
|
||||||
GuPool* expr_pool;
|
GuPool* expr_pool;
|
||||||
GuPool* tmp_pool;
|
GuPool* tmp_pool;
|
||||||
PGF_TOKEN_TAG token_tag;
|
PGF_TOKEN_TAG token_tag;
|
||||||
@@ -159,7 +159,7 @@ struct PgfExprParser {
|
|||||||
static void
|
static void
|
||||||
pgf_expr_parser_getc(PgfExprParser* parser)
|
pgf_expr_parser_getc(PgfExprParser* parser)
|
||||||
{
|
{
|
||||||
parser->ch = gu_getc(parser->rdr, parser->err);
|
parser->ch = gu_in_u8(parser->in, parser->err);
|
||||||
if (!gu_ok(parser->err)) {
|
if (!gu_ok(parser->err)) {
|
||||||
gu_exn_clear(parser->err);
|
gu_exn_clear(parser->err);
|
||||||
parser->ch = EOF;
|
parser->ch = EOF;
|
||||||
@@ -353,12 +353,12 @@ pgf_expr_parser_expr(PgfExprParser* parser)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PgfExpr
|
PgfExpr
|
||||||
pgf_read_expr(GuReader* rdr, GuPool* pool, GuExn* err)
|
pgf_read_expr(GuIn* in, GuPool* pool, GuExn* err)
|
||||||
{
|
{
|
||||||
GuPool* tmp_pool = gu_new_pool();
|
GuPool* tmp_pool = gu_new_pool();
|
||||||
PgfExprParser* parser = gu_new(PgfExprParser, tmp_pool);
|
PgfExprParser* parser = gu_new(PgfExprParser, tmp_pool);
|
||||||
parser->err = err;
|
parser->err = err;
|
||||||
parser->rdr = rdr;
|
parser->in = in;
|
||||||
parser->expr_pool = pool;
|
parser->expr_pool = pool;
|
||||||
parser->tmp_pool = NULL;
|
parser->tmp_pool = NULL;
|
||||||
parser->ch = ' ';
|
parser->ch = ' ';
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ pgf_expr_unapply(PgfExpr expr, GuPool* pool);
|
|||||||
|
|
||||||
|
|
||||||
PgfExpr
|
PgfExpr
|
||||||
pgf_read_expr(GuReader* rdr, GuPool* pool, GuExn* err);
|
pgf_read_expr(GuIn* in, GuPool* pool, GuExn* err);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pgf_literal_eq(PgfLiteral lit1, PgfLiteral lit2);
|
pgf_literal_eq(PgfLiteral lit1, PgfLiteral lit2);
|
||||||
|
|||||||
@@ -1663,11 +1663,10 @@ pgf_readExpr(PyObject *self, PyObject *args) {
|
|||||||
|
|
||||||
GuPool* tmp_pool = gu_local_pool();
|
GuPool* tmp_pool = gu_local_pool();
|
||||||
GuIn* in = gu_data_in(buf, len, tmp_pool);
|
GuIn* in = gu_data_in(buf, len, tmp_pool);
|
||||||
GuReader* rdr = gu_new_utf8_reader(in, tmp_pool);
|
|
||||||
GuExn* err = gu_new_exn(NULL, gu_kind(type), tmp_pool);
|
GuExn* err = gu_new_exn(NULL, gu_kind(type), tmp_pool);
|
||||||
|
|
||||||
pyexpr->pool = gu_new_pool();
|
pyexpr->pool = gu_new_pool();
|
||||||
pyexpr->expr = pgf_read_expr(rdr, pyexpr->pool, err);
|
pyexpr->expr = pgf_read_expr(in, pyexpr->pool, err);
|
||||||
pyexpr->master = NULL;
|
pyexpr->master = NULL;
|
||||||
|
|
||||||
if (!gu_ok(err) || gu_variant_is_null(pyexpr->expr)) {
|
if (!gu_ok(err) || gu_variant_is_null(pyexpr->expr)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user