diff -up texlive-2007/texk/lacheck/lacheck.lex.lacheck texlive-2007/texk/lacheck/lacheck.lex --- texlive-2007/texk/lacheck/lacheck.lex.lacheck 2006-01-17 22:41:51.000000000 +0100 +++ texlive-2007/texk/lacheck/lacheck.lex 2008-08-27 13:20:52.000000000 +0200 @@ -1042,11 +1042,12 @@ char *name; void g_checkend(n) int n; { - if ( check_top_level_end(yytext,n) == 1 ) + if ( check_top_level_end(yytext,n) == 1 ) { if ( CG_TYPE != n ) print_bad_match(yytext,n); else pop(); + } } void e_checkend(n, name) @@ -1075,6 +1075,7 @@ char *name; { print_bad_match(name,3); pop(); + if (gstackp <= 0) return; } pop(); @@ -1090,11 +1091,13 @@ int type; line_count, eg_command( end_command , type) ) ; - printf("\"%s\", line %d: -> unmatched \"%s\"\n", - CG_FILE, - CG_LINE, - bg_command( CG_NAME ) ) ; - warn_count += 2; + if (gstackp > 0) { + printf("\"%s\", line %d: -> unmatched \"%s\"\n", + CG_FILE, + CG_LINE, + bg_command( CG_NAME ) ) ; + warn_count += 2; + } } int check_top_level_end(end_command,type)