From 0aebb03b1f9c3a4a0dd99b715f13dc044540a0bd Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 26 Mar 2009 21:11:12 -0700 Subject: [PATCH] Fix error message for bad characters in syntax files. Before this commit, on systems where "char" is a signed type, formatting a char with %o would sign-extend to the width of "int", so that a typical error message would look like: Bad character in input: `\37777777605'. With this commit, the value gets zero-extended, producing the more sensible error mesage: Bad character in input: `\205'. --- src/language/lexer/lexer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index 16195b0d..26511614 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -384,10 +384,11 @@ lex_get (struct lexer *lexer) } else { - if (c_isgraph ((unsigned char) *lexer->prog)) - msg (SE, _("Bad character in input: `%c'."), *lexer->prog++); + unsigned char c = *lexer->prog++; + if (c_isgraph (c)) + msg (SE, _("Bad character in input: `%c'."), c); else - msg (SE, _("Bad character in input: `\\%o'."), *lexer->prog++); + msg (SE, _("Bad character in input: `\\%o'."), c); continue; } } -- 2.30.2