From 132e4b48bbd1d8f7f04d57b9a342b9f779a4cd8e Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Fri, 3 Jul 2015 14:38:37 +0000 Subject: [PATCH] aded STIX_SYNERR_INCLUDE --- stix/lib/comp.c | 6 +++++- stix/lib/main.c | 5 ++++- stix/lib/stix-prv.h | 3 ++- stix/lib/stix.h | 2 +- stix/lib/utf8.c | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/stix/lib/comp.c b/stix/lib/comp.c index 1fdeb84..9a1389e 100644 --- a/stix/lib/comp.c +++ b/stix/lib/comp.c @@ -1383,7 +1383,11 @@ static int begin_include (stix_t* stix) arg->colm = 1; arg->includer = stix->c->curinp; - if (stix->c->impl (stix, STIX_IO_OPEN, arg) <= -1) goto oops; + if (stix->c->impl (stix, STIX_IO_OPEN, arg) <= -1) + { + set_syntax_error (stix, STIX_SYNERR_INCLUDE, &stix->c->tok.loc, &stix->c->tok.name); + goto oops; + } stix->c->curinp = arg; /* stix->c->depth.incl++; */ diff --git a/stix/lib/main.c b/stix/lib/main.c index 9eb3869..68d0cd1 100644 --- a/stix/lib/main.c +++ b/stix/lib/main.c @@ -80,6 +80,8 @@ static STIX_INLINE stix_ssize_t open_input (stix_t* stix, stix_ioarg_t* arg) return -1; } +/* TODO: make bcs relative to the includer */ + #if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) arg->handle = fopen (bcs, "rb"); #else @@ -211,7 +213,8 @@ static char* syntax_error_msg[] = "too many block temporaries", "too many block arguments", "too large block", - "wrong primitive number" + "wrong primitive number", + "#include error" }; stix_uch_t str_stix[] = { 'S', 't', 'i', 'x' }; diff --git a/stix/lib/stix-prv.h b/stix/lib/stix-prv.h index e6c6fc3..681031a 100644 --- a/stix/lib/stix-prv.h +++ b/stix/lib/stix-prv.h @@ -326,7 +326,8 @@ enum stix_synerrnum_t STIX_SYNERR_BLKTMPRFLOOD, /* too many block temporaries */ STIX_SYNERR_BLKARGFLOOD, /* too many block arguments */ STIX_SYNERR_BLKFLOOD, /* too large block */ - STIX_SYNERR_PRIMNO /* wrong primitive number */ + STIX_SYNERR_PRIMNO, /* wrong primitive number */ + STIX_SYNERR_INCLUDE /* #include error */ }; typedef enum stix_synerrnum_t stix_synerrnum_t; diff --git a/stix/lib/stix.h b/stix/lib/stix.h index 75ef9a3..2ec64a5 100644 --- a/stix/lib/stix.h +++ b/stix/lib/stix.h @@ -376,7 +376,7 @@ enum stix_obj_type_t STIX_OBJ_TYPE_OOP, STIX_OBJ_TYPE_CHAR, STIX_OBJ_TYPE_BYTE, - STIX_OBJ_TYPE_WORD, + STIX_OBJ_TYPE_WORD /* STIX_OBJ_TYPE_UINT8, diff --git a/stix/lib/utf8.c b/stix/lib/utf8.c index 300a2ae..8b19f44 100644 --- a/stix/lib/utf8.c +++ b/stix/lib/utf8.c @@ -310,7 +310,7 @@ static STIX_INLINE int bcs_to_ucs_with_cmgr ( stix_size_t mlen, wlen; int n; - for (bp = bcs; *bp != '\0'; bp++); + for (bp = bcs; *bp != '\0'; bp++) /* nothing */ ; mlen = bp - bcs; wlen = *ucslen; n = bcsn_to_ucsn_with_cmgr (bcs, &mlen, ucs, &wlen, cmgr, all);