summaryrefslogtreecommitdiffstats
path: root/4
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-12-21 18:57:07 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-12-21 18:57:07 +0800
commita62b9cab19886062bf0bc75f05ec79f79e7eb4f2 (patch)
treebeb362ae3387549a087d71464c91abe3efe15df1 /4
parentfa3299b4d7e305cbd5f29e12c69227182fc2f924 (diff)
downloadk&r-exercises-a62b9cab19886062bf0bc75f05ec79f79e7eb4f2.tar.gz
4.11
Diffstat (limited to '4')
-rw-r--r--4/11.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/4/11.c b/4/11.c
index 160ff66..0173317 100644
--- a/4/11.c
+++ b/4/11.c
@@ -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;