summaryrefslogtreecommitdiffstats
path: root/1
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-11-23 23:21:22 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-11-23 23:21:22 +0800
commita8e49d4b25c75c4392e0ad6e38a543d403567d0a (patch)
treefc91bdc957c84adfc9ab3187a8d849a22ae1dbd7 /1
parenta1c7577c6f9fc87aa8a0322431de447d7df0f24d (diff)
downloadk&r-exercises-a8e49d4b25c75c4392e0ad6e38a543d403567d0a.tar.gz
1.24
Diffstat (limited to '1')
-rw-r--r--1/24.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/1/24.c b/1/24.c
index 0e8e53f..7091896 100644
--- a/1/24.c
+++ b/1/24.c
@@ -16,16 +16,15 @@ int main(int argc, char *argv[]) {
parens = bracks = braces = 0;
for (i = 0; i < MAXLEN - 1 && (c = getchar()) != EOF; i++) {
- if (!comment && !quote && (c == '/' || c == '*') && p == '/') {
- comment = c == '/' ? INLINE : MULTILINE;
- } else if (!comment && !quote && c == '"') {
- quote = TRUE;
- } else if (comment == INLINE && c == '\n') {
+ if (!comment && !quote) {
+ if ((c == '/' || c == '*') && p == '/')
+ comment = c == '/' ? INLINE : MULTILINE;
+ else if (c == '"')
+ quote = TRUE;
+ } else if ((comment == INLINE && c == '\n') ||
+ (comment == MULTILINE && c == '/' && p == '*')) {
comment = FALSE;
- } else if (comment == MULTILINE && c == '/' && p == '*') {
- comment = FALSE;
- }
- if (!comment && quote && c == '"' && p != '\\') {
+ } else if (!comment && quote && c == '"' && p != '\\') {
quote = FALSE;
} else if (!comment && !quote) {
if (c == '{')