summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1997-09-18 13:45:34 +0000
committerphk <phk@FreeBSD.org>1997-09-18 13:45:34 +0000
commit2d831c7d21d4e39820d9fe862e7ec818476c083b (patch)
tree8fbe1264a5b4847d971add4433faa0f7cce9b35c
parentbf06d52b9dd8b00f77a1fd5550c0d7ba459c8744 (diff)
downloadFreeBSD-src-2d831c7d21d4e39820d9fe862e7ec818476c083b.zip
FreeBSD-src-2d831c7d21d4e39820d9fe862e7ec818476c083b.tar.gz
Many places in the code NULL is used in integer context, where
plain 0 should be used. This happens to work because we #define NULL to 0, but is stylistically wrong and can cause problems for people trying to port bits of code to other environments. PR: 2752 Submitted by: Arne Henrik Juul <arnej@imf.unit.no>
-rw-r--r--games/cribbage/io.c22
-rw-r--r--games/cribbage/score.c8
-rw-r--r--games/rogue/inventory.c4
3 files changed, 17 insertions, 17 deletions
diff --git a/games/cribbage/io.c b/games/cribbage/io.c
index c38c119..b4c2f15 100644
--- a/games/cribbage/io.c
+++ b/games/cribbage/io.c
@@ -250,10 +250,10 @@ incard(crd)
if (!(line = getline()))
goto gotit;
p = p1 = line;
- while (*p1 != ' ' && *p1 != NULL)
+ while (*p1 != ' ' && *p1 != '\0')
++p1;
- *p1++ = NULL;
- if (*p == NULL)
+ *p1++ = '\0';
+ if (*p == '\0')
goto gotit;
/* IMPORTANT: no real card has 2 char first name */
@@ -289,17 +289,17 @@ incard(crd)
if (rnk == EMPTY)
goto gotit;
p = p1;
- while (*p1 != ' ' && *p1 != NULL)
+ while (*p1 != ' ' && *p1 != '\0')
++p1;
- *p1++ = NULL;
- if (*p == NULL)
+ *p1++ = '\0';
+ if (*p == '\0')
goto gotit;
if (!strcmp("OF", p)) {
p = p1;
- while (*p1 != ' ' && *p1 != NULL)
+ while (*p1 != ' ' && *p1 != '\0')
++p1;
- *p1++ = NULL;
- if (*p == NULL)
+ *p1++ = '\0';
+ if (*p == '\0')
goto gotit;
}
sut = EMPTY;
@@ -348,7 +348,7 @@ number(lo, hi, prompt)
for (sum = 0;;) {
msg(prompt);
- if (!(p = getline()) || *p == NULL) {
+ if (!(p = getline()) || *p == '\0') {
msg(quiet ? "Not a number" :
"That doesn't look like a number");
continue;
@@ -363,7 +363,7 @@ number(lo, hi, prompt)
++p;
}
- if (*p != ' ' && *p != '\t' && *p != NULL)
+ if (*p != ' ' && *p != '\t' && *p != '\0')
sum = lo - 1;
if (sum >= lo && sum <= hi)
break;
diff --git a/games/cribbage/score.c b/games/cribbage/score.c
index 239e26d..ecfed9a 100644
--- a/games/cribbage/score.c
+++ b/games/cribbage/score.c
@@ -115,7 +115,7 @@ scorehand(hand, starter, n, crb, do_explain)
CARD h[(CINHAND + 1)];
char buf[32];
- expl[0] = NULL; /* initialize explanation */
+ expl[0] = '\0'; /* initialize explanation */
score = 0;
flag = TRUE;
k = hand[0].suit;
@@ -131,7 +131,7 @@ scorehand(hand, starter, n, crb, do_explain)
}
if (flag && n >= CINHAND) {
- if (do_explain && expl[0] != NULL)
+ if (do_explain && expl[0] != '\0')
strcat(expl, ", ");
if (starter.suit == k) {
score += 5;
@@ -140,13 +140,13 @@ scorehand(hand, starter, n, crb, do_explain)
} else
if (!crb) {
score += 4;
- if (do_explain && expl[0] != NULL)
+ if (do_explain && expl[0] != '\0')
strcat(expl, ", Four-flush");
else
strcpy(expl, "Four-flush");
}
}
- if (do_explain && expl[0] != NULL)
+ if (do_explain && expl[0] != '\0')
strcat(expl, ", ");
h[n] = starter;
sorthand(h, n + 1); /* sort by rank */
diff --git a/games/rogue/inventory.c b/games/rogue/inventory.c
index 8fa88a8..5dd6f3d 100644
--- a/games/rogue/inventory.c
+++ b/games/rogue/inventory.c
@@ -176,9 +176,9 @@ struct id_com_s com_id_tab[COMS] = {
'b', "b down & left",
'c', "c call object",
'n', "n down & right",
- NULL, "<SHIFT><dir>: run that way",
+ '\0', "<SHIFT><dir>: run that way",
')', ") print current weapon",
- NULL, "<CTRL><dir>: run till adjacent",
+ '\0', "<CTRL><dir>: run till adjacent",
']', "] print current armor",
'f', "f<dir> fight till death or near death",
'=', "= print current rings",
OpenPOWER on IntegriCloud