From ff8a9aa82f1ea1b18bb859bc053b753f6d6ad238 Mon Sep 17 00:00:00 2001 From: zlg Date: Wed, 6 Feb 2013 02:47:55 -0600 Subject: Fix style issue and correct 1-24 Escape sequences were being compared with the 'or' operator instead of the 'and' operator. If I had left it alone, every escape sequence would've borked it. --- 1-24_syntax-checker.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to '1-24_syntax-checker.c') diff --git a/1-24_syntax-checker.c b/1-24_syntax-checker.c index 239999f..019b9bc 100644 --- a/1-24_syntax-checker.c +++ b/1-24_syntax-checker.c @@ -46,7 +46,7 @@ int main() { escapes++; c = getchar(); // This does not detect all sequences; just the ones covered in Chapter 1. - if (c != '\\' || c != 't' || c != '\'' || c != '"' || c != 'n' || c != 'b' || c != '0') { + if (c != '\\' && c != 't' && c != '\'' && c != '"' && c != 'n' && c != 'b' && c != '0') { break; } else { escapes--; @@ -57,11 +57,11 @@ int main() { if (singqs > 0 || dubqs > 0) { break; } - linenr += 1; + linenr++; } // Parentheses if (c == '(') { - parens += 1; + parens++; } if (c == ')') { parens -= 1; @@ -71,7 +71,7 @@ int main() { } // Brackets if (c == '[') { - brackets += 1; + brackets++; } if (c == ']') { brackets--; -- cgit v1.2.3-54-g00ecf