Description: quick fix for flex. Hoping flex's buffering is smart enough, Otherwise this shit should be rewritten, or illumos lex should be used. See http://flex.sourceforge.net/manual/Lex-and-Posix.html Index: smf-tools/usr/src/cmd/svc/svccfg/svccfg.l =================================================================== --- smf-tools.orig/usr/src/cmd/svc/svccfg/svccfg.l 2012-10-08 00:25:33.000000000 +0000 +++ smf-tools/usr/src/cmd/svc/svccfg/svccfg.l 2012-11-10 14:04:22.782011167 +0000 @@ -36,26 +36,14 @@ #include "svccfg.h" #include "svccfg_grammar.h" -/* - * We need to undefine lex's input, unput, and output macros so that references - * to these call the functions we provide at the end of this source file, - * instead of the default versions based on libc's stdio. - */ -#ifdef input -#undef input -#endif - -#ifdef unput -#undef unput -#endif - -#ifdef output -#undef output -#endif - -static int input(void); -static void unput(int); -static void output(int); +#define YY_INPUT(buf, result, max_size) \ +{ \ + int c = my_input(); \ + result = (c == 0) ? YY_NULL : (buf[0] = c, 1); \ +} + + +static int my_input(void); int parens = 0; @@ -70,11 +58,6 @@ */ %Start WORD -/* - * The default value of lex for transitions is 2000 and it seems we reached it. - * So we are bumping it up! - */ -%a 3000 %% @@ -202,7 +185,7 @@ } static int -input(void) +my_input(void) { static int saw_eof = 0; @@ -210,8 +193,10 @@ /* * To ensure input is terminated, slip in a newline on EOF. + * FIXME: there is no EOF for command line invocation, thus + * "svccfg " does nothing. Catch end-of-line (0) as well. */ - if (c == EOF) { + if (c == EOF || c == 0) { if (saw_eof) return (0); @@ -226,18 +211,3 @@ return (c); } -static void -unput(int c) -{ - if (c == '\n') - yylineno--; - - (void) engine_cmd_ungetc(est, c == 0 ? EOF : c); -} - -static void -output(int c) -{ - char ch = c; - engine_cmd_nputs(est, &ch, sizeof (ch)); -} Index: smf-tools/usr/src/cmd/svc/svccfg/svccfg.h =================================================================== --- smf-tools.orig/usr/src/cmd/svc/svccfg/svccfg.h 2012-11-10 13:58:21.787048655 +0000 +++ smf-tools/usr/src/cmd/svc/svccfg/svccfg.h 2012-11-10 13:58:23.127397069 +0000 @@ -495,8 +495,6 @@ void help(int); int engine_cmd_getc(engine_state_t *); -int engine_cmd_ungetc(engine_state_t *, char); -void engine_cmd_nputs(engine_state_t *, char *, size_t); void tmpl_errors_destroy(tmpl_errors_t *); void tmpl_errors_print(FILE *, tmpl_errors_t *, const char *); Index: smf-tools/usr/src/cmd/svc/svccfg/svccfg_engine.c =================================================================== --- smf-tools.orig/usr/src/cmd/svc/svccfg/svccfg_engine.c 2012-10-08 00:25:33.000000000 +0000 +++ smf-tools/usr/src/cmd/svc/svccfg/svccfg_engine.c 2012-11-10 13:58:23.129941346 +0000 @@ -117,26 +117,6 @@ } int -engine_cmd_ungetc(engine_state_t *E, char c) -{ - if (E->sc_cmd_file != NULL) - return (ungetc(c, E->sc_cmd_file)); - - if (E->sc_cmd_buf != NULL) - *(E->sc_cmd_buf + --E->sc_cmd_bufoff) = c; - - return (c); -} - -/*ARGSUSED*/ -void -engine_cmd_nputs(engine_state_t *E, char *c, size_t n) -{ - /* our lexer shouldn't need this state */ - exit(11); -} - -int engine_exec(char *cmd) { est->sc_cmd_buf = cmd;