=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/bc/bc.y,v retrieving revision 1.48 retrieving revision 1.49 diff -c -r1.48 -r1.49 *** src/usr.bin/bc/bc.y 2015/10/10 19:28:54 1.48 --- src/usr.bin/bc/bc.y 2015/11/23 09:58:55 1.49 *************** *** 1,5 **** %{ ! /* $OpenBSD: bc.y,v 1.48 2015/10/10 19:28:54 deraadt Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek --- 1,5 ---- %{ ! /* $OpenBSD: bc.y,v 1.49 2015/11/23 09:58:55 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek *************** *** 72,78 **** static ssize_t cs(const char *); static ssize_t as(const char *); static ssize_t node(ssize_t, ...); ! static void emit(ssize_t); static void emit_macro(int, ssize_t); static void free_tree(void); static ssize_t numnode(int); --- 72,78 ---- static ssize_t cs(const char *); static ssize_t as(const char *); static ssize_t node(ssize_t, ...); ! static void emit(ssize_t, int); static void emit_macro(int, ssize_t); static void free_tree(void); static ssize_t numnode(int); *************** *** 175,181 **** input_item : semicolon_list NEWLINE { ! emit($1); macro_char = reset_macro_char; putchar('\n'); free_tree(); --- 175,181 ---- input_item : semicolon_list NEWLINE { ! emit($1, 0); macro_char = reset_macro_char; putchar('\n'); free_tree(); *************** *** 803,814 **** } static void ! emit(ssize_t i) { ! if (instructions[i].index >= 0) ! while (instructions[i].index != END_NODE) ! emit(instructions[i++].index); ! else fputs(instructions[i].u.cstr, stdout); } --- 803,819 ---- } static void ! emit(ssize_t i, int level) { ! if (level > 1000) ! errx(1, "internal error: tree level > 1000"); ! if (instructions[i].index >= 0) { ! while (instructions[i].index != END_NODE && ! instructions[i].index != i) { ! emit(instructions[i].index, level + 1); ! i++; ! } ! } else if (instructions[i].index != END_NODE) fputs(instructions[i].u.cstr, stdout); } *************** *** 816,822 **** emit_macro(int node, ssize_t code) { putchar('['); ! emit(code); printf("]s%s\n", instructions[node].u.cstr); nesting--; } --- 821,827 ---- emit_macro(int node, ssize_t code) { putchar('['); ! emit(code, 0); printf("]s%s\n", instructions[node].u.cstr); nesting--; } *************** *** 951,957 **** !isprint((unsigned char)yytext[0])) n = asprintf(&str, "%s: %s:%d: %s: ascii char 0x%02x unexpected", ! __progname, filename, lineno, s, yytext[0]); else n = asprintf(&str, "%s: %s:%d: %s: %s unexpected", __progname, filename, lineno, s, yytext); --- 956,962 ---- !isprint((unsigned char)yytext[0])) n = asprintf(&str, "%s: %s:%d: %s: ascii char 0x%02x unexpected", ! __progname, filename, lineno, s, yytext[0] & 0xff); else n = asprintf(&str, "%s: %s:%d: %s: %s unexpected", __progname, filename, lineno, s, yytext);