diff options
| author | Sadeep Madurange <smadurange@users.noreply.github.com> | 2021-12-21 18:57:07 +0800 |
|---|---|---|
| committer | Sadeep Madurange <smadurange@users.noreply.github.com> | 2021-12-21 18:57:07 +0800 |
| commit | a62b9cab19886062bf0bc75f05ec79f79e7eb4f2 (patch) | |
| tree | beb362ae3387549a087d71464c91abe3efe15df1 /4 | |
| parent | fa3299b4d7e305cbd5f29e12c69227182fc2f924 (diff) | |
| download | k&r-exercises-a62b9cab19886062bf0bc75f05ec79f79e7eb4f2.tar.gz | |
4.11
Diffstat (limited to '4')
| -rw-r--r-- | 4/11.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -144,7 +144,7 @@ int getop(char s[]) { i = 0; if (isdigit(c) || c == '.' || c == '-') { - while (isdigit((s[++i] = c = getch())) || c == '.') + while (isdigit(s[++i] = c = getch()) || c == '.') ; pc = c; rc = i == 1 && s[0] == '-' ? '-' : NUM; @@ -152,16 +152,18 @@ int getop(char s[]) { while (isalnum(s[++i] = c = getch())) ; s[i] = 0; - pc = c; - if (c == ' ') { + if (i == 1) { if ((c = getch()) == '=') rc = '='; else { pc = c; - rc = strcmp("LOUT", s) == 0 || strlen(s) == 1 ? VAR : FUN; + rc = VAR; } - } else + } + else { + pc = c; rc = strcmp("LOUT", s) == 0 || strlen(s) == 1 ? VAR : FUN; + } } s[i] = 0; |
