diff --git a/Makefile.in b/Makefile.in index fc7a20e..86fa86e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -354,6 +354,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -584,7 +585,7 @@ distdir: $(DISTFILES) ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir @@ -610,7 +611,7 @@ dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir @@ -628,7 +629,7 @@ dist dist-all: distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ @@ -638,7 +639,7 @@ distcheck: dist *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac diff --git a/configure b/configure index 6f7fa10..32c8c68 100755 --- a/configure +++ b/configure @@ -782,6 +782,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -875,6 +876,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1127,6 +1129,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1264,7 +1275,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1417,6 +1428,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] diff --git a/lib/Makefile.in b/lib/Makefile.in index 9d9f4ff..e61c5c1 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -420,6 +420,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/lib/err.c b/lib/err.c index dc44326..d0a6c4e 100644 --- a/lib/err.c +++ b/lib/err.c @@ -375,6 +375,12 @@ void hcl_getsynerr (hcl_t* hcl, hcl_synerr_t* synerr) if (synerr) *synerr = hcl->c->synerr; } +hcl_synerrnum_t hcl_getsynerrnum (hcl_t* hcl) +{ + HCL_ASSERT (hcl, hcl->c != HCL_NULL); + return hcl->c->synerr.num; +} + void hcl_setsynerrbfmt (hcl_t* hcl, hcl_synerrnum_t num, const hcl_ioloc_t* loc, const hcl_oocs_t* tgt, const hcl_bch_t* msgfmt, ...) { static hcl_bch_t syntax_error[] = "syntax error - "; diff --git a/lib/hcl-prv.h b/lib/hcl-prv.h index c75ba09..a921be2 100644 --- a/lib/hcl-prv.h +++ b/lib/hcl-prv.h @@ -169,6 +169,7 @@ enum hcl_iotok_type_t HCL_IOTOK_LBRACE, /* { */ HCL_IOTOK_RBRACE, /* } */ HCL_IOTOK_VBAR, + HCL_IOTOK_EOL, /* end of line */ HCL_IOTOK_INCLUDE }; diff --git a/lib/hcl-s.c b/lib/hcl-s.c index 4f740f4..94f2fbf 100644 --- a/lib/hcl-s.c +++ b/lib/hcl-s.c @@ -2651,7 +2651,6 @@ int hcl_server_start (hcl_server_t* server, const hcl_bch_t* addrs) free_worker (worker); } } - } } } diff --git a/lib/hcl.h b/lib/hcl.h index 24b4dd4..5e9ab3c 100644 --- a/lib/hcl.h +++ b/lib/hcl.h @@ -187,6 +187,9 @@ enum hcl_trait_t HCL_DEBUG_BIGINT = (1u << 1), #endif + /* command line mode */ + HCL_CLI_MODE = (1u << 7), + /* perform no garbage collection when the heap is full. * you still can use hcl_gc() explicitly. */ HCL_NOGC = (1u << 8), @@ -1754,6 +1757,9 @@ HCL_EXPORT void hcl_getsynerr ( hcl_synerr_t* synerr ); +HCL_EXPORT hcl_synerrnum_t hcl_getsynerrnum ( + hcl_t* hcl +); HCL_EXPORT void hcl_setsynerrbfmt ( hcl_t* hcl, diff --git a/lib/main.c b/lib/main.c index 21b300b..600e21e 100644 --- a/lib/main.c +++ b/lib/main.c @@ -1674,6 +1674,7 @@ int main (int argc, char* argv[]) { ":log", 'l' }, { ":memsize", 'm' }, { "large-pages", '\0' }, + { "cli-mode", '\0' }, #if defined(HCL_BUILD_DEBUG) { ":debug", '\0' }, /* NOTE: there is no short option for --debug */ #endif @@ -1688,6 +1689,7 @@ int main (int argc, char* argv[]) const char* logopt = HCL_NULL; hcl_oow_t memsize = MIN_MEMSIZE; int large_pages = 0; + int cli_mode = 0; #if defined(HCL_BUILD_DEBUG) const char* dbgopt = HCL_NULL; @@ -1722,6 +1724,11 @@ int main (int argc, char* argv[]) large_pages = 1; break; } + else if (hcl_comp_bcstr(opt.lngopt, "cli-mode") == 0) + { + cli_mode = 1; + break; + } #if defined(HCL_BUILD_DEBUG) else if (hcl_comp_bcstr(opt.lngopt, "debug") == 0) { @@ -1788,6 +1795,8 @@ int main (int argc, char* argv[]) /*trait |= HCL_NOGC;*/ trait |= HCL_AWAIT_PROCS; + + if (cli_mode) trait |= HCL_CLI_MODE; hcl_setoption (hcl, HCL_TRAIT, &trait); /* disable GC logs */ @@ -1879,7 +1888,7 @@ count++; else if (hcl->errnum == HCL_ESYNERR) { print_synerr (hcl); - if (xtn->reader_istty) continue; + if (xtn->reader_istty && hcl_getsynerrnum(hcl) != HCL_SYNERR_EOF) continue; } else { diff --git a/lib/read.c b/lib/read.c index 4a90df8..5631151 100644 --- a/lib/read.c +++ b/lib/read.c @@ -58,6 +58,7 @@ static struct voca_t { 7, { '#','\\','s','p','a','c','e' } }, { 5, { '#','\\','t','a','b' } }, { 6, { '#','\\','v','t','a','b' } }, + { 5, { '<','E','O','L','>' } }, { 5, { '<','E','O','F','>' } } }; @@ -75,6 +76,7 @@ enum voca_id_t VOCA_TAB, VOCA_VTAB, + VOCA_EOL, VOCA_EOF }; typedef enum voca_id_t voca_id_t; @@ -1013,7 +1015,17 @@ retry: do { /* skip spaces */ - while (is_spacechar(hcl->c->lxc.c)) GET_CHAR (hcl); + while (is_spacechar(hcl->c->lxc.c)) + { + if ((hcl->option.trait & HCL_CLI_MODE) && hcl->c->lxc.c == '\n') + { + SET_TOKEN_TYPE (hcl, HCL_IOTOK_EOL); + CLEAR_TOKEN_NAME (hcl); + ADD_TOKEN_STR(hcl, vocas[VOCA_EOL].str, vocas[VOCA_EOL].len); + hcl->c->tok.loc = hcl->c->lxc.l; /* set token location */ + } + GET_CHAR (hcl); + } /* the first character after the last space is in hcl->c->lxc */ if ((n = skip_comment(hcl)) <= -1) return -1; } diff --git a/mod/Makefile.in b/mod/Makefile.in index 10bc392..66c44a7 100644 --- a/mod/Makefile.in +++ b/mod/Makefile.in @@ -377,6 +377,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@