|
|
1.1 ! root 1: # include "hangman.h" ! 2: ! 3: # if pdp11 ! 4: # define RN (((off_t) rand() << 16) | (off_t) rand()) ! 5: # else ! 6: # define RN rand() ! 7: # endif ! 8: ! 9: /* ! 10: * getword: ! 11: * Get a valid word out of the dictionary file ! 12: */ ! 13: getword() ! 14: { ! 15: register FILE *inf; ! 16: register char *wp, *gp; ! 17: ! 18: inf = Dict; ! 19: for (;;) { ! 20: fseek(inf, abs(RN % Dict_size), 0); ! 21: if (fgets(Word, BUFSIZ, inf) == NULL) ! 22: continue; ! 23: if (fgets(Word, BUFSIZ, inf) == NULL) ! 24: continue; ! 25: Word[strlen(Word) - 1] = '\0'; ! 26: if (strlen(Word) < MINLEN) ! 27: continue; ! 28: for (wp = Word; *wp; wp++) ! 29: if (!islower(*wp)) ! 30: goto cont; ! 31: break; ! 32: cont: ; ! 33: } ! 34: gp = Known; ! 35: wp = Word; ! 36: while (*wp) { ! 37: *gp++ = '-'; ! 38: wp++; ! 39: } ! 40: *gp = '\0'; ! 41: } ! 42: ! 43: /* ! 44: * abs: ! 45: * Return the absolute value of an integer ! 46: */ ! 47: off_t ! 48: abs(i) ! 49: off_t i; ! 50: { ! 51: if (i < 0) ! 52: return -(off_t) i; ! 53: else ! 54: return (off_t) i; ! 55: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.