home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume22 / thought / patch02 < prev    next >
Encoding:
Text File  |  1991-08-31  |  31.6 KB  |  1,027 lines

  1. Newsgroups: comp.sources.misc
  2. From: David F. Skoll <dfs@doe.carleton.ca>
  3. Subject:  v22i082:  thought - A replacement for 'fortune', Patch02
  4. Message-ID: <1991Aug30.214945.7856@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: c1c0a05e504c8c382331edb56ed6a686
  6. Date: Fri, 30 Aug 1991 21:49:45 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: David F. Skoll <dfs@doe.carleton.ca>
  10. Posting-number: Volume 22, Issue 82
  11. Archive-name: thought/patch02
  12. Environment: UNIX
  13. Patch-To: thought: Volume 21, Issue 23-24
  14.  
  15. This is Official Patch #2 for Thought.  You should previously have
  16. applied Patch#1 so that your current version is 1.0 (PL 1).  To see
  17. the current version, type "thought -v".
  18.  
  19. To apply the patch, change the the Thought source directory and unshar
  20. this file.  Type "patch < Patch02", and re-make and re-install Thought.
  21.  
  22. What this shar does:
  23.  
  24. o    Includes a new control file (rap.rc) for generating rap songs.
  25.  
  26. o    Causes Thought not to "re-use" words in a given sentence.
  27.  
  28. o    Allows you to give words identifiers so they WILL be re-used if
  29.     you so desire.  This allows you to create long passages which
  30.     consistently use previous words.  For example:
  31.  
  32.     {defsent Don't touch the {n:a}!  {N:a;plural} are bad!}
  33.  
  34.     could result in:
  35.  
  36.     "Don't touch the dog!  Dogs are bad!"
  37.     "Don't touch the tooth!  Teeth are bad!"  (etc)
  38.  
  39. o     Certain spelling errors and bugs in thought.rc are fixed.  Also
  40.     adds past tense of verbs, and a couple of new sentence definitions.
  41.  
  42. o    The thoughtfile.man man page is updated.
  43.  
  44. --
  45. David F. Skoll
  46.  
  47. -------------- Cut Here ---------- Cut Here ---------- Cut Here -------------
  48. #!/bin/sh
  49. # This is Thought 1.0 Patch 2, a shell archive (shar 3.32)
  50. # made 08/29/1991 14:51 UTC by dfs@wesley
  51. # Source directory /enterprise/transporter/dfs/work/.thought/v1.0.2
  52. #
  53. # existing files will NOT be overwritten
  54. #
  55. # This shar contains:
  56. # length  mode       name
  57. # ------ ---------- ------------------------------------------
  58. #  27303 -rw------- Patch02
  59. #   1226 -rw------- rap.rc
  60. #
  61. if touch 2>&1 | fgrep 'amc' > /dev/null
  62.  then TOUCH=touch
  63.  else TOUCH=true
  64. fi
  65. # ============= Patch02 ==============
  66. if test X"$1" != X"-c" -a -f 'Patch02'; then
  67.     echo "File already exists: skipping 'Patch02'"
  68. else
  69. echo "x - extracting Patch02 (Text)"
  70. sed 's/^X//' << 'SHAR_EOF' > Patch02 &&
  71. X#
  72. X# Add the rap.rc file to Makefile's MANIFEST variable
  73. X#
  74. X*** ../v1.0.1/Makefile    Mon Aug 26 10:31:50 1991
  75. X--- ./Makefile    Thu Aug 29 10:10:21 1991
  76. X***************
  77. X*** 59,67 ****
  78. X  #--------------- SHOULDN'T CHANGE STUFF BELOW HERE ---------------
  79. X  
  80. X  #Version of THOUGHT
  81. X! VERSION= 1.0.1
  82. X  
  83. X! MANIFEST= Makefile README examples protos.h st.rc thought.c thought.man thought.rc thoughtfile.man version.h insult.rc new-user.rc buzzword.rc
  84. X  
  85. X  all: thought.c protos.h version.h
  86. X      $(CC) $(HAVE_RANDOM) $(NO_STRDUP) $(NO_STRICMP) -DLIBPATH=\"$(LIBDIR)\" -DFILE_DEFAULT=\"$(GRAMFILE)\" -o thought thought.c
  87. X--- 59,67 ----
  88. X  #--------------- SHOULDN'T CHANGE STUFF BELOW HERE ---------------
  89. X  
  90. X  #Version of THOUGHT
  91. X! VERSION= 1.0.2
  92. X  
  93. X! MANIFEST= Makefile README examples protos.h st.rc thought.c thought.man thought.rc thoughtfile.man version.h insult.rc new-user.rc buzzword.rc rap.rc
  94. X  
  95. X  all: thought.c protos.h version.h
  96. X      $(CC) $(HAVE_RANDOM) $(NO_STRDUP) $(NO_STRICMP) -DLIBPATH=\"$(LIBDIR)\" -DFILE_DEFAULT=\"$(GRAMFILE)\" -o thought thought.c
  97. X#
  98. X# Update README
  99. X#
  100. X*** ../v1.0.1/README    Mon Aug 26 10:43:49 1991
  101. X--- ./README    Thu Aug 29 10:42:19 1991
  102. X***************
  103. X*** 20,26 ****
  104. X  And you're on your way!  To create your own grammar files, read the
  105. X  man page for "thoughtfile".
  106. X  
  107. X! I have supplied five grammar files:
  108. X  
  109. X      'thought.rc' produces generally demented sayings.
  110. X  
  111. X--- 20,26 ----
  112. X  And you're on your way!  To create your own grammar files, read the
  113. X  man page for "thoughtfile".
  114. X  
  115. X! I have supplied a few grammar files:
  116. X  
  117. X      'thought.rc' produces generally demented sayings.
  118. X  
  119. X***************
  120. X*** 31,37 ****
  121. X  
  122. X      'insult.rc' generates childish insults
  123. X  
  124. X!     'new-user' generates messages designed to panic new Unix users.
  125. X  
  126. X  --
  127. X  David F. Skoll (dfs@doe.carleton.ca)
  128. X--- 31,40 ----
  129. X  
  130. X      'insult.rc' generates childish insults
  131. X  
  132. X!     'new-user.rc' generates messages designed to panic new Unix users.
  133. X! 
  134. X!     'rap.rc' creates dumb rap songs.  (But probably no dumber than the
  135. X!         commercial ones.)
  136. X  
  137. X  --
  138. X  David F. Skoll (dfs@doe.carleton.ca)
  139. X#
  140. X# Update protos.h - change the structure of a tag to make it possible
  141. X# not to "re-use" words.  Also add a structure for holding words which
  142. X# have identifiers so we can find them again.  Add the prototype declaration
  143. X# for InitializeTags
  144. X#
  145. X*** ../v1.0.1/protos.h    Mon Aug 26 10:39:34 1991
  146. X--- ./protos.h    Mon Aug 26 15:03:48 1991
  147. X***************
  148. X*** 28,35 ****
  149. X  {
  150. X    struct tag *next;
  151. X    char *def;
  152. X!   Word *wordlist;
  153. X!   int numwords;  /* Number of words with this tag definition */
  154. X  } Tag;
  155. X  
  156. X  /* Define the structure of a sentence */
  157. X--- 28,37 ----
  158. X  {
  159. X    struct tag *next;
  160. X    char *def;
  161. X!   Word *wordlist; /* List of words for this tag */
  162. X!   Word *realword; /* Real start of list */
  163. X!   int numwords;   /* Number of words unpicked with this tag definition */
  164. X!   int realnum;    /* Total number of words with this definition */
  165. X  } Tag;
  166. X  
  167. X  /* Define the structure of a sentence */
  168. X***************
  169. X*** 40,45 ****
  170. X--- 42,55 ----
  171. X    char *def;
  172. X  } Sentence;
  173. X  
  174. X+ /* Define the structure of "identified" words */
  175. X+ typedef struct ident
  176. X+ {
  177. X+    struct ident *next;
  178. X+    char *def;
  179. X+    Word *w;
  180. X+ } Ident;
  181. X+ 
  182. X  /* ARGH!  Our stupid header files don't give prototype for getenv! */
  183. X  #ifdef __STDC__
  184. X  char * getenv(char *);
  185. X***************
  186. X*** 71,76 ****
  187. X--- 81,87 ----
  188. X  #ifdef NO_STRICMP
  189. X  int    stricmp(const char *s1, const char *s2);
  190. X  #endif
  191. X+ void   InitializeTags(void);
  192. X  #else
  193. X  Tag *  FindTag();
  194. X  char * FindModifier();
  195. X***************
  196. X*** 95,98 ****
  197. X--- 106,110 ----
  198. X  #ifdef NO_STRICMP
  199. X  int    stricmp();
  200. X  #endif
  201. X+ void   InitializeTags();
  202. X  #endif
  203. X#
  204. X# Add a third set of "token separators" so we don't barf if parsing a colon
  205. X# within a word definition.  Increase the sizes of various system buffers.
  206. X# Add the {reuse} command.  Add code for identifiers and non-reusing of words.
  207. X# Add code to handle "\n" escape sequence in sentence definitions.
  208. X#
  209. X*** ../v1.0.1/thought.c    Mon Aug 26 11:15:09 1991
  210. X--- ./thought.c    Thu Aug 29 10:16:13 1991
  211. X***************
  212. X*** 64,72 ****
  213. X  
  214. X  #define UPPER(c) ( ((c) >= 'a' && (c) <= 'z') ? (c) - ('a' - 'A') : (c) )
  215. X  
  216. X! char *SEP1="{}=;,";
  217. X! char *SEP2="{}=;, \n\t";
  218. X  
  219. X  /* The global data structures - a singly-linked list of tags
  220. X     and a singly-linked list of sentence definitions. */
  221. X  
  222. X--- 64,76 ----
  223. X  
  224. X  #define UPPER(c) ( ((c) >= 'a' && (c) <= 'z') ? (c) - ('a' - 'A') : (c) )
  225. X  
  226. X! #define iseow(c) (isspace(c) || (c) == '\\')
  227. X  
  228. X+ char *SEP1="{}=:;,";
  229. X+ char *SEP2="{}=:;, \n\t";
  230. X+ char *SEP3="{}=;,";
  231. X+ 
  232. X+ 
  233. X  /* The global data structures - a singly-linked list of tags
  234. X     and a singly-linked list of sentence definitions. */
  235. X  
  236. X***************
  237. X*** 73,85 ****
  238. X  Tag *TagList = NULL;
  239. X  int NumTags = 0;
  240. X  
  241. X  Sentence *SentenceList = NULL;
  242. X  int NumSentences = 0;
  243. X  
  244. X! char Buffer[1024];  /* Temp buffer - big for sentence definitions */
  245. X! char Mod[32];       /* Temp buffer to hold current modifier */
  246. X! char Token[200];    /* Another temp. buffer for various stuff */
  247. X! char FileName[256]; /* Resolved filename */
  248. X  /***************************************************************/
  249. X  /*                                                             */
  250. X  /*  ReadChar                                                   */
  251. X--- 77,92 ----
  252. X  Tag *TagList = NULL;
  253. X  int NumTags = 0;
  254. X  
  255. X+ char ReUse = 0;  /* Should we re-use words? */
  256. X+ 
  257. X  Sentence *SentenceList = NULL;
  258. X  int NumSentences = 0;
  259. X  
  260. X! char Buffer[8192];   /* Temp buffer - big for sentence definitions */
  261. X! char Mod[32];        /* Temp buffer to hold current modifier       */
  262. X! char Identifier[96]; /* Temp buffer to hold current identifier     */
  263. X! char Token[200];     /* Another temp. buffer for various stuff     */
  264. X! char FileName[256];  /* Resolved filename                          */
  265. X  /***************************************************************/
  266. X  /*                                                             */
  267. X  /*  ReadChar                                                   */
  268. X***************
  269. X*** 241,248 ****
  270. X              exit(1);
  271. X           }
  272. X           new->next = TagList;
  273. X!          new->wordlist = (Word *) NULL;
  274. X           new->numwords = 0;
  275. X           TagList = new;
  276. X           NumTags++;
  277. X       new->def = strdup(Buffer);
  278. X--- 248,256 ----
  279. X              exit(1);
  280. X           }
  281. X           new->next = TagList;
  282. X!          new->realword = (Word *) NULL;
  283. X           new->numwords = 0;
  284. X+      new->realnum = 0;
  285. X           TagList = new;
  286. X           NumTags++;
  287. X       new->def = strdup(Buffer);
  288. X***************
  289. X*** 334,369 ****
  290. X     char *s;
  291. X     Word *new;
  292. X  
  293. X!    s = ReadToken(SEP1, fp, NULL);
  294. X  
  295. X     while(1) {
  296. X!       if (strchr(SEP1, *s)) {
  297. X           fprintf(stderr, "Illegal word definition: %s\n", s);
  298. X       exit(1);
  299. X        }
  300. X        strcpy(Buffer, s);
  301. X!       s = ReadToken(SEP1, fp, NULL);
  302. X        while (*s == ';') {   /* Collect modifiers */
  303. X           strcat(Buffer, s);
  304. X!          s = ReadToken(SEP1, fp, NULL);  /* Modifier name */
  305. X           strcat(Buffer, s);
  306. X!          if (strchr(SEP1, *s)) {
  307. X              fprintf(stderr, "Illegal word definition: %s\n", s);
  308. X              exit(1);
  309. X           }
  310. X!      s = ReadToken(SEP1, fp, NULL); /* equals sign */
  311. X       strcat(Buffer, s);
  312. X       if (*s != '=') {
  313. X              fprintf(stderr, "Illegal word definition: %s\n", s);
  314. X              exit(1);
  315. X           }
  316. X!      s = ReadToken(SEP1, fp, NULL); /* Definition */
  317. X       strcat(Buffer, s);
  318. X!          if (strchr(SEP1, *s)) {
  319. X              fprintf(stderr, "Illegal word definition: %s\n", s);
  320. X              exit(1);
  321. X           }
  322. X!          s = ReadToken(SEP1, fp, NULL);
  323. X        }
  324. X        if (*s != ',' && *s != CRIGHT) {
  325. X           fprintf(stderr, "Illegal word definition: %s%s\n", Buffer, s);
  326. X--- 342,377 ----
  327. X     char *s;
  328. X     Word *new;
  329. X  
  330. X!    s = ReadToken(SEP3, fp, NULL);
  331. X  
  332. X     while(1) {
  333. X!       if (strchr(SEP3, *s)) {
  334. X           fprintf(stderr, "Illegal word definition: %s\n", s);
  335. X       exit(1);
  336. X        }
  337. X        strcpy(Buffer, s);
  338. X!       s = ReadToken(SEP3, fp, NULL);
  339. X        while (*s == ';') {   /* Collect modifiers */
  340. X           strcat(Buffer, s);
  341. X!          s = ReadToken(SEP3, fp, NULL);  /* Modifier name */
  342. X           strcat(Buffer, s);
  343. X!          if (strchr(SEP3, *s)) {
  344. X              fprintf(stderr, "Illegal word definition: %s\n", s);
  345. X              exit(1);
  346. X           }
  347. X!      s = ReadToken(SEP3, fp, NULL); /* equals sign */
  348. X       strcat(Buffer, s);
  349. X       if (*s != '=') {
  350. X              fprintf(stderr, "Illegal word definition: %s\n", s);
  351. X              exit(1);
  352. X           }
  353. X!      s = ReadToken(SEP3, fp, NULL); /* Definition */
  354. X       strcat(Buffer, s);
  355. X!          if (strchr(SEP3, *s)) {
  356. X              fprintf(stderr, "Illegal word definition: %s\n", s);
  357. X              exit(1);
  358. X           }
  359. X!          s = ReadToken(SEP3, fp, NULL);
  360. X        }
  361. X        if (*s != ',' && *s != CRIGHT) {
  362. X           fprintf(stderr, "Illegal word definition: %s%s\n", Buffer, s);
  363. X***************
  364. X*** 379,389 ****
  365. X           fprintf(stderr, "Memory allocation error for word: %s\n", Buffer);
  366. X       exit(1);
  367. X        }
  368. X!       new->next = tag->wordlist;
  369. X!       tag->wordlist = new;
  370. X!       tag->numwords++;
  371. X        if (*s == CRIGHT) return 0;
  372. X!       s = ReadToken(SEP1, fp, NULL);
  373. X     }
  374. X  }
  375. X  
  376. X--- 387,397 ----
  377. X           fprintf(stderr, "Memory allocation error for word: %s\n", Buffer);
  378. X       exit(1);
  379. X        }
  380. X!       new->next = tag->realword;
  381. X!       tag->realword = new;
  382. X!       tag->realnum++;
  383. X        if (*s == CRIGHT) return 0;
  384. X!       s = ReadToken(SEP3, fp, NULL);
  385. X     }
  386. X  }
  387. X  
  388. X***************
  389. X*** 485,490 ****
  390. X--- 493,507 ----
  391. X        }
  392. X        s = ReadToken(SEP2, fp, NULL);
  393. X        if (! stricmp(s, "deftag")) DefTag(fp);
  394. X+       else if (! stricmp(s, "reuse")) {
  395. X+          ReUse = 1;
  396. X+      s = ReadToken(SEP2, fp, NULL);
  397. X+      if (*s != CRIGHT) {
  398. X+             fprintf(stderr, "Expecting %c, found %s\n", CRIGHT, s);
  399. X+         fclose(fp);
  400. X+         exit(1);
  401. X+      }
  402. X+       }
  403. X        else if (! stricmp(s, "defsent")) DefSent(fp);
  404. X        else {
  405. X           t = FindTag(s);
  406. X***************
  407. X*** 518,527 ****
  408. X     char *mod;
  409. X     char ch;
  410. X     Tag *tag;
  411. X!    Word *w;
  412. X     int i;
  413. X     char upper;
  414. X  
  415. X     out = Buffer;
  416. X     *out = 0;
  417. X  
  418. X--- 535,547 ----
  419. X     char *mod;
  420. X     char ch;
  421. X     Tag *tag;
  422. X!    Word *w, *prevw;
  423. X     int i;
  424. X     char upper;
  425. X+    Ident *identifiers = NULL;
  426. X+    Ident *id;
  427. X  
  428. X+    InitializeTags(); /* Initialize all the tags, etc. */
  429. X     out = Buffer;
  430. X     *out = 0;
  431. X  
  432. X***************
  433. X*** 534,539 ****
  434. X--- 554,562 ----
  435. X        }
  436. X        tok = ReadToken(SEP1, NULL, &sd);
  437. X        if (*tok >= 'A' && *tok <='Z') upper = 1; else upper = 0;
  438. X+ 
  439. X+ /* Save the token name in case it needs an identifier */
  440. X+       strcpy(Identifier, tok);
  441. X        tag = FindTag(tok);
  442. X        if (!tag) {
  443. X           fprintf(stderr, "Unknown tag %s in sentence definition\n%s\n", tok, sen->def);
  444. X***************
  445. X*** 540,549 ****
  446. X       exit(1);
  447. X        }
  448. X        tok = ReadToken(SEP1, NULL, &sd);
  449. X!       if (*tok != ';' && *tok != CRIGHT) {
  450. X           fprintf(stderr, "Illegal tag usage in %s\n", sen->def);
  451. X       exit(1);
  452. X        }
  453. X        if (*tok == ';') {
  454. X           tok = ReadToken(SEP1, NULL, &sd);
  455. X       strcpy(Mod, tok);
  456. X--- 563,584 ----
  457. X       exit(1);
  458. X        }
  459. X        tok = ReadToken(SEP1, NULL, &sd);
  460. X!       if (*tok != ';' && *tok != CRIGHT && *tok != ':') {
  461. X           fprintf(stderr, "Illegal tag usage in %s\n", sen->def);
  462. X       exit(1);
  463. X        }
  464. X+ /* If it's a colon, then this is a word that should be given an identifier */
  465. X+       if (*tok == ':') {
  466. X+          strcat(Identifier, tok);
  467. X+      tok = ReadToken(SEP1, NULL, &sd);
  468. X+      strcat(Identifier, tok);
  469. X+      tok = ReadToken(SEP1, NULL, &sd);
  470. X+      if (*tok != ';' && *tok != CRIGHT) {
  471. X+         fprintf(stderr, "Illegal tag usage in %s\n", sen->def);
  472. X+         exit(1);
  473. X+          }
  474. X+       } else *Identifier = 0;  /* No identifier needed! */
  475. X+ 
  476. X        if (*tok == ';') {
  477. X           tok = ReadToken(SEP1, NULL, &sd);
  478. X       strcpy(Mod, tok);
  479. X***************
  480. X*** 555,582 ****
  481. X           }
  482. X        } else mod = (char *) NULL;
  483. X  
  484. X! /* We've got the tag and the modifier - now pick a random word */
  485. X!       if (!tag->numwords) {
  486. X!          fprintf(stderr, "Tag %s has no words defined.\n", tag->def);
  487. X!      exit(1);
  488. X!       }
  489. X!       i = (RAND() >> 4) % tag->numwords;
  490. X  
  491. X  /* Find the actual word - this is HIGHLY INEFFICIENT!! */
  492. X!       w = tag->wordlist;
  493. X!       while (i && w) {
  494. X!          w = w->next;
  495. X!      i--;
  496. X!       }
  497. X  
  498. X!       if (!w) {
  499. X!          fprintf(stderr, "Internal error!  numwords for tag %s is too high!!!\n", tag->def);
  500. X!      exit(1);
  501. X        }
  502. X  
  503. X! /* We've got a word - emit it */
  504. X        WriteWord(tag, w, mod, &out, upper);
  505. X     }
  506. X  }
  507. X  /***************************************************************/
  508. X  /*                                                             */
  509. X--- 590,675 ----
  510. X           }
  511. X        } else mod = (char *) NULL;
  512. X  
  513. X! /* We've got the tag and the modifier and possibly an identifier.
  514. X!    If we have an identifier, search the previously-used-words list for it.
  515. X!    If found, use that word.  Otherwise, pick a new word and if necessary
  516. X!    add it to the previously-used-words list. */
  517. X!       if (*Identifier) {
  518. X!          id = identifiers;
  519. X!      while (id) {
  520. X!         if (!stricmp(id->def, Identifier)) break;
  521. X!         id = id->next;
  522. X!          }
  523. X!       } else id = NULL;
  524. X  
  525. X+       if (id) w = id->w;
  526. X+ 
  527. X+ /* If no identifier supplied, OR identifier not found, pick a random word */
  528. X+       if (!*Identifier || !id) {
  529. X+          if (!tag->numwords) {
  530. X+             fprintf(stderr, "Tag %s has no remaining words defined.\n", tag->def);
  531. X+             exit(1);
  532. X+          }
  533. X+          i = (RAND() >> 4) % tag->numwords;
  534. X+ 
  535. X  /* Find the actual word - this is HIGHLY INEFFICIENT!! */
  536. X!          w = tag->wordlist;
  537. X!          prevw = (Word *) NULL;
  538. X!          while (i && w) {
  539. X!             prevw = w;
  540. X!             w = w->next;
  541. X!             i--;
  542. X!          }
  543. X  
  544. X!          if (!w) {
  545. X!             fprintf(stderr, "Internal error!  numwords for tag %s is too high!!!\n", tag->def);
  546. X!             exit(1);
  547. X!          }
  548. X! 
  549. X! /* Move the word to the beginning of the list */
  550. X!          if (!ReUse) {
  551. X!             if (prevw) {
  552. X!                prevw->next = w->next;
  553. X!            w->next = tag->realword;
  554. X!            tag->realword = w;
  555. X!             } else {
  556. X!                tag->wordlist = w->next;
  557. X!             }
  558. X! 
  559. X! /* Decrement the number of words remaining to be picked */
  560. X!             tag->numwords--;
  561. X!          }
  562. X        }
  563. X  
  564. X! /* If an identifier was supplied, and we picked a random word, add to the
  565. X!    list of previously-identified words */
  566. X!       if (*Identifier && !id) {
  567. X!          id = (Ident *) malloc(sizeof(Ident));
  568. X!      if (!id) {
  569. X!             fprintf(stderr, "Memory allocation error for identifier: %s\n", Identifier);
  570. X!         exit(1);
  571. X!      }
  572. X!      id->next = identifiers;
  573. X!      identifiers = id;
  574. X!      id->def = strdup(Identifier);
  575. X!      id->w = w;
  576. X!      if (!id->def) {
  577. X!             fprintf(stderr, "Memory allocation error for identifier: %s\n", Identifier);
  578. X!         exit(1);
  579. X!      }
  580. X!       }
  581. X! /* Emit the word */
  582. X        WriteWord(tag, w, mod, &out, upper);
  583. X     }
  584. X+ 
  585. X+ /* De-allocate memory used for identifiers */
  586. X+    id = identifiers;
  587. X+    while (identifiers) {
  588. X+       id = id->next;
  589. X+       free(identifiers->def);
  590. X+       free(identifiers);
  591. X+       identifiers = id;
  592. X+    }
  593. X  }
  594. X  /***************************************************************/
  595. X  /*                                                             */
  596. X***************
  597. X*** 685,690 ****
  598. X--- 778,788 ----
  599. X     pos = 0;
  600. X     while (*s) {
  601. X        wd = NextWord(&s);  /* With leading spaces, not with trailing spaces */
  602. X+       if (*wd == '\n') {
  603. X+          putchar('\n');
  604. X+      pos = 0;
  605. X+      continue;
  606. X+       }
  607. X        len = strlen(wd);
  608. X        if (pos + len > width-2) {
  609. X           putchar('\n');
  610. X***************
  611. X*** 717,732 ****
  612. X     char *t;
  613. X     while (isspace(**s)) *dest++ = *(*s)++;  /* Copy leading spaces */
  614. X  
  615. X     realword = dest;  /* Start of the real word */
  616. X     if (**s == '-' || **s == '+') (*s)++;  /* Skip any "a/an" thing */
  617. X!    while (**s && !isspace(**s)) *dest++ = *(*s)++; /* Copy word */
  618. X     *dest = 0;
  619. X  
  620. X     if (stricmp(realword, "a")) return Token; /* Exit if not "a" */
  621. X  
  622. X!    /* Look for start of next word */
  623. X     t = *s;
  624. X!    while (isspace(*t)) t++;
  625. X     if (strchr("aeiouAEIOU+", *t)) {
  626. X        *dest++ = 'n';
  627. X        *dest = 0;
  628. X--- 815,844 ----
  629. X     char *t;
  630. X     while (isspace(**s)) *dest++ = *(*s)++;  /* Copy leading spaces */
  631. X  
  632. X+    /* If it's a '\n', */
  633. X+    if (**s == '\\' && *(*s+1) == 'n') {
  634. X+       *Token = '\n';
  635. X+       *(Token+1) = 0;
  636. X+       (*s)+=2;
  637. X+    /* Chew up following whitespace */
  638. X+       while(isspace(**s)) (*s)++;
  639. X+       return Token;
  640. X+    }       
  641. X+ 
  642. X     realword = dest;  /* Start of the real word */
  643. X     if (**s == '-' || **s == '+') (*s)++;  /* Skip any "a/an" thing */
  644. X!    while (**s && !iseow(**s)) *dest++ = *(*s)++; /* Copy word */
  645. X     *dest = 0;
  646. X  
  647. X     if (stricmp(realword, "a")) return Token; /* Exit if not "a" */
  648. X  
  649. X!    /* Look for start of next valid word */
  650. X     t = *s;
  651. X!    while(1) {
  652. X!       while (isspace(*t)) t++;
  653. X!       if (*t != '\\') break;
  654. X!       if (*(t+1) == 'n') t += 2; else break;
  655. X!    }
  656. X     if (strchr("aeiouAEIOU+", *t)) {
  657. X        *dest++ = 'n';
  658. X        *dest = 0;
  659. X***************
  660. X*** 993,995 ****
  661. X--- 1105,1127 ----
  662. X     return strcpy(ret, s);
  663. X  }
  664. X  #endif
  665. X+ 
  666. X+ /***************************************************************/
  667. X+ /*                                                             */
  668. X+ /*  InitializeTags - set up the numwords and wordlist fields   */
  669. X+ /*  to their initial values.                                   */
  670. X+ /*                                                             */
  671. X+ /***************************************************************/
  672. X+ #ifdef __STDC__
  673. X+ void InitializeTags(void)
  674. X+ #else
  675. X+ void InitializeTags()
  676. X+ #endif
  677. X+ {
  678. X+    Tag *cur = TagList;
  679. X+    while(cur) {
  680. X+       cur->numwords = cur->realnum;
  681. X+       cur->wordlist = cur->realword;
  682. X+       cur = cur->next;
  683. X+    }
  684. X+ }
  685. X#
  686. X# Fix various spelling errors and bugs in thought.rc.  Also add past forms
  687. X# of verbs, and participles.  Add a couple more sentence definitions.
  688. X#
  689. X*** ../v1.0.1/thought.rc    Fri Aug 23 10:58:47 1991
  690. X--- ./thought.rc    Tue Aug 27 10:56:08 1991
  691. X***************
  692. X*** 7,25 ****
  693. X  {deftag art}        # Articles - "the", "a", and so on
  694. X  {deftag adj}        # Adjectives
  695. X  {deftag adv}        # Adverbs
  696. X! {deftag vi;3s=!s}    # Intransitive verbs with mod for 3rd person singular
  697. X! {deftag vt;3s=!s}    # Transitive verbs with mod for 3rd person singular
  698. X  {deftag n;p=!s}        # Nouns with mod for plural
  699. X  {deftag mname}        # Male's name
  700. X  {deftag fname}        # Female's name
  701. X  {deftag name}        # Name (either gender)
  702. X  
  703. X- 
  704. X  #--------------------------------------------------------------------------#
  705. X  
  706. X  # Now let's define a bunch of sentences
  707. X  
  708. X  {defsent
  709. X  {Art} {adj} {n} {vi;3s} {adv}.
  710. X  }
  711. X  
  712. X--- 7,38 ----
  713. X  {deftag art}        # Articles - "the", "a", and so on
  714. X  {deftag adj}        # Adjectives
  715. X  {deftag adv}        # Adverbs
  716. X! {deftag vi;3s=!s;ing=!ing;pa=!ed} # Intr. verbs with mods
  717. X! {deftag vt;3s=!s;ing=!ing;pa=!ed} # Transitive verbs with mods
  718. X  {deftag n;p=!s}        # Nouns with mod for plural
  719. X  {deftag mname}        # Male's name
  720. X  {deftag fname}        # Female's name
  721. X  {deftag name}        # Name (either gender)
  722. X+ {deftag bodypart;p=!s}
  723. X  
  724. X  #--------------------------------------------------------------------------#
  725. X  
  726. X  # Now let's define a bunch of sentences
  727. X  
  728. X  {defsent
  729. X+ {Mname:1} thought that {Fname:1} had stolen his {n:1}.  He loved that
  730. X+ {adj} {n:1}.  {Fname:1} denied taking the {n:1} and said that
  731. X+ {Fname:2} had it.  {Mname:1} was {adj} beyond belief to see {Fname:2}
  732. X+ {adv} {vt:1;ing} the {n:1}, {vi;ing} {adv} as she {vt:1;pa}
  733. X+ it.}
  734. X+ 
  735. X+ {defsent
  736. X+ When I was but a {adj} lad, I went down to the {n} to watch the {n:1;p}
  737. X+ {vi;ing}.  One day, a {n:1} landed on my {bodypart}, and {vt;pa} its
  738. X+ {bodypart:1}.  I felt {adj}!  What a {adj} sight!  I'll never forget
  739. X+ that {n:1} or its {bodypart:1}.}
  740. X+ 
  741. X+ {defsent
  742. X  {Art} {adj} {n} {vi;3s} {adv}.
  743. X  }
  744. X  
  745. X***************
  746. X*** 145,151 ****
  747. X  {defsent Rm {vt;3s} one or more {n;p}.  If a {n} was the {adj} {n}
  748. X  to it, its {n;p} are {adj}.}
  749. X  
  750. X! {defsent To {vt} a {n}, you must have {n} permission in its {n}.}
  751. X  
  752. X  {defsent It is forbidden to {vt} the {n} "{name}" to avoid the {adj}
  753. X  consequences.}
  754. X--- 158,164 ----
  755. X  {defsent Rm {vt;3s} one or more {n;p}.  If a {n} was the {adj} {n}
  756. X  to it, its {n;p} are {adj}.}
  757. X  
  758. X! {defsent To {vt} a {n:1}, you must have {n} permission in the {n:1}'s {n}.}
  759. X  
  760. X  {defsent It is forbidden to {vt} the {n} "{name}" to avoid the {adj}
  761. X  consequences.}
  762. X***************
  763. X*** 370,376 ****
  764. X  angrily, anomalously, antagonistically, anxiously, apathetically,
  765. X  apologetically, ardently, arrogantly, atrociously, attractively,
  766. X  awkwardly, belligerently, benevolently, blasphemously, blatantly,
  767. X! bluntly, boisterously, calamitously, callously, calmy, carelessly,
  768. X  cataclysmically, caustically, ceremoniously, cheaply, chivalrously,
  769. X  circuitously, cogently, coherently, comically, complacently,
  770. X  consciously, conspicuously, conspiratorially, constantly,
  771. X--- 383,389 ----
  772. X  angrily, anomalously, antagonistically, anxiously, apathetically,
  773. X  apologetically, ardently, arrogantly, atrociously, attractively,
  774. X  awkwardly, belligerently, benevolently, blasphemously, blatantly,
  775. X! bluntly, boisterously, calamitously, callously, calmly, carelessly,
  776. X  cataclysmically, caustically, ceremoniously, cheaply, chivalrously,
  777. X  circuitously, cogently, coherently, comically, complacently,
  778. X  consciously, conspicuously, conspiratorially, constantly,
  779. X***************
  780. X*** 425,445 ****
  781. X  }
  782. X  
  783. X  {vi
  784. X!  fly;3s=flies, whoosh;3s=!es, burp, explode, whimper, moan, growl,
  785. X!  eat, die, kiss;3s=!es, scream, weep, bleed, exhale, sleep, flip,
  786. X!  triumph, blow, flop, shiver, sink, breathe, choke, gasp, expire, fart,
  787. X!  giggle, concentrate, fib, meditate, contemplate, regurgitate,
  788. X!  exaggerate, wobble, dance, sing, swim, skate, float, collapse,
  789. X!  mutate
  790. X  }
  791. X  
  792. X  {vt
  793. X!  kiss;3s=!es, lift, kill, beat, eat, whack, caress;3s=!es, hug, bore,
  794. X!  hack, chop, nibble, lick, reason with;3s=reasons with, thrill, flatten,
  795. X!  worry;3s=worries, berate, anger, throw, destroy, maim, heal,
  796. X!  improve, help, mystify;3s=mystifies, split, stab, create, feel,
  797. X!  enrage, please, whip, fry;3s=fries, mangle, absorb, enjoy,
  798. X!  berate, console, injure, belittle
  799. X  }
  800. X  
  801. X  {n
  802. X--- 438,473 ----
  803. X  }
  804. X  
  805. X  {vi
  806. X! fly;3s=flies;pa=flew, whoosh;3s=!es, burp,
  807. X! explode;ing=exploding;pa=!d, whimper, moan, growl, eat;pa=ate,
  808. X! die;ing=dying;pa=!d, kiss;3s=!es, scream, weep;pa=wept, bleed;pa=bled,
  809. X! exhale;ing=exhaling;pa=!d, sleep;pa=slept, flip;ing=!ping;pa=!ped,
  810. X! triumph, blow;pa=blew, flop;ing=!ping;pa=!ped, shiver, sink;pa=sank,
  811. X! breathe;ing=breathing;pa=!d, choke;ing=choking;pa=!d, gasp,
  812. X! expire;ing=expiring;pa=!d, fart, giggle;ing=giggling;pa=!d,
  813. X! concentrate;ing=concentrating;pa=!d, fib;ing=!bing;pa=!bed,
  814. X! meditate;ing=meditating;pa=!d, contemplate;ing=contemplating;pa=!d,
  815. X! regurgitate;ing=regurgitating;pa=!d,
  816. X! exaggerate;ing=exaggerating;pa=!d, wobble;ing=wobbling;pa=!d,
  817. X! dance;ing=dancing;pa=!d, sing;pa=sang, swim;ing=!ming;pa=swam,
  818. X! skate;ing=skating;pa=!d, float, collapse;ing=collapsing;pa=!d,
  819. X! mutate;ing=mutating;pa=!d
  820. X  }
  821. X  
  822. X  {vt
  823. X! kiss;3s=!es, lift, kill, beat;pa=!, eat;pa=ate, whack,
  824. X! caress;3s=!es, hug;ing=!ging;pa=!ged, bore;ing=boring;pa=!d,
  825. X! hack, chop;ing=!ping;pa=!ped, nibble;ing=nibbling;pa=!d, lick,
  826. X! reason with;3s=reasons with;ing=reasoning with;pa=reasoned with, thrill,
  827. X! flatten, worry;3s=worries;pa=worried, berate;ing=berating;pa=!d,
  828. X! anger, throw;pa=threw, destroy, maim, heal,
  829. X! improve;ing=improving;pa=!d, help, mystify;3s=mystifies;pa=mystified,
  830. X! split;ing=!ting;pa=!, stab;ing=!bing;pa=!bed,
  831. X! create;ing=creating;pa=!d, feel;pa=felt, enrage;ing=enraging;pa=!d,
  832. X! please;ing=pleasing;pa=!d, whip;ing=!ping;pa=!ped,
  833. X! fry;3s=fries;pa=fried, mangle;ing=mangling;pa=!d, absorb, enjoy,
  834. X! console;ing=consoling;pa=!d, injure;ing=injuring;pa=!d,
  835. X! belittle;ing=belittling;pa=!d
  836. X  }
  837. X  
  838. X  {n
  839. X***************
  840. X*** 496,498 ****
  841. X--- 524,530 ----
  842. X   Cindy, Alice, Debbie, Kathy, Linda, Mandy, Nancy, Patricia,
  843. X   Sandy, Veronica, Barabara, Lori, Jenny, Sandra, Sally, Anne
  844. X  }
  845. X+ 
  846. X+ {bodypart
  847. X+ leg, wing, breast, head, buttock, foot;p=feet, eye, ear, nose,
  848. X+ throat, thigh, hip, nostril}
  849. X#
  850. X# Update the man page for thoughtfile to reflect new features.
  851. X#
  852. X*** ../v1.0.1/thoughtfile.man    Thu Jul  4 14:13:36 1991
  853. X--- ./thoughtfile.man    Wed Aug 28 17:15:20 1991
  854. X***************
  855. X*** 129,135 ****
  856. X--- 129,181 ----
  857. X  \fBThought\fP operates by reading an entire grammar file, picking a
  858. X  sentence definition at random, substituting random words for each
  859. X  tag reference, and displaying the result.
  860. X+ .SH IDENTIFIERS
  861. X+ Normally, \fBthought\fP will not "re-use" a particular word in a given
  862. X+ sentence.  Thus, if your sentence definition is something like:
  863. X+ .PP
  864. X+ .nf
  865. X+     {defsent I prefer a {n} to {n;p}.}
  866. X+ .fi
  867. X+ .PP
  868. X+ possible results are:
  869. X+ .PP
  870. X+ .nf
  871. X+     I prefer a dog to cats.
  872. X+     I prefer an elephant to mice.
  873. X+ .fi
  874. X+ .PP
  875. X+ You'll never get "bad" sentences like:
  876. X+ .PP
  877. X+ .nf
  878. X+     I prefer a tree to trees.
  879. X+ .fi
  880. X+ .PP
  881. X+ However, sometimes it is desirable to "re-use" words to give sentences
  882. X+ more meanings.  In this case, when you define a sentence, you add an
  883. X+ \fIidentifier\fP immediately after the tag name and prior to any modifier.
  884. X+ An identifier is simply a colon followed by an alphanumeric string, and
  885. X+ is case-insensitive.  This ensures that appropriate words are re-used.  For
  886. X+ example, consider the definition:
  887. X+ .PP
  888. X+ .nf
  889. X+     {defsent I tried a {n:1} once, but it was {adj:1}.  {Adj:1}
  890. X+              {n:1;p} don't agree with me.}
  891. X+ .fi
  892. X+ .PP
  893. X+ In this case, the identifiers are simply numbers - you can use anything.
  894. X+ Possible results are:
  895. X+ .PP
  896. X+ .nf
  897. X+     I tried a dog once, but it was evil.  Evil dogs don't agree
  898. X+     with me.
  899. X+     I tried an igloo once, but it was putrid.  Putrid igloos don't
  900. X+     agree with me.
  901. X+     -- etc --
  902. X+ .fi
  903. X  .SH ODDS AND ENDS
  904. X+ You can place a carriage return inside sentence definitions with the
  905. X+ sequence "\n".
  906. X+ .PP
  907. X  If you want a substituted word to be capitalized, simply use a capital
  908. X  letter as the first character of the tag reference.  For example:
  909. X  .PP
  910. X***************
  911. X*** 155,160 ****
  912. X--- 201,218 ----
  913. X  .nf
  914. X      {noun +hour, -unicorn}
  915. X  .fi
  916. X+ .PP
  917. X+ As stated previously, \fBthought\fP will not re-use a word unless it is
  918. X+ given an identifier.  This behaviour is a change from version 1.0.1 and
  919. X+ may not be desirable.  If you wish to maintain the old behaviour, place
  920. X+ the command:
  921. X+ .PP
  922. X+ .nf
  923. X+     {reuse}
  924. X+ .fi
  925. X+ .PP
  926. X+ in the control file.  (For an example of why this is useful, see the file
  927. X+ "rap.rc" supplied with \fBthought\fP.)
  928. X  .SH HINTS
  929. X  A judicious choice of literal text and word substitutions usually gives
  930. X  good results.  A sentence which consists mostly of word substitutions
  931. X#
  932. X# Update version.h
  933. X#
  934. X*** ../v1.0.1/version.h    Thu Jul 25 15:44:43 1991
  935. X--- ./version.h    Mon Aug 26 14:15:58 1991
  936. X***************
  937. X*** 15,18 ****
  938. X  /***************************************************************/
  939. X  
  940. X  #define VERSION "1.0"
  941. X! #define PATCHLEVEL "1"
  942. X--- 15,18 ----
  943. X  /***************************************************************/
  944. X  
  945. X  #define VERSION "1.0"
  946. X! #define PATCHLEVEL "2"
  947. SHAR_EOF
  948. $TOUCH -am 0829104991 Patch02 &&
  949. chmod 0600 Patch02 ||
  950. echo "restore of Patch02 failed"
  951. set `wc -c Patch02`;Wc_c=$1
  952. if test "$Wc_c" != "27303"; then
  953.     echo original size 27303, current size $Wc_c
  954. fi
  955. fi
  956. # ============= rap.rc ==============
  957. if test X"$1" != X"-c" -a -f 'rap.rc'; then
  958.     echo "File already exists: skipping 'rap.rc'"
  959. else
  960. echo "x - extracting rap.rc (Text)"
  961. sed 's/^X//' << 'SHAR_EOF' > rap.rc &&
  962. X{reuse}
  963. X{deftag lyric1}
  964. X{deftag lyric2}
  965. X{deftag lyric3}
  966. X{deftag bandname}
  967. X
  968. X{lyric1
  969. XMove it, Get up, Pump it up, Get down, Shake it, Pump the jam
  970. X}
  971. X
  972. X{lyric2
  973. Xto triple beat, get body heat, feel the beat, get around,
  974. Xthe joint is jumpin', feet are stompin'
  975. X}
  976. X
  977. X{lyric3
  978. Xin the city streets, you'll be humpin', till the night is over,
  979. Xshake your meat, I'm bustin' loose, with disco heat
  980. X}
  981. X
  982. X{bandname
  983. XThe Mixmastermeatbeaters,
  984. XSharp Al and the Dead Citizens,
  985. XThe Ghetto Blaster,
  986. XDr. Cool,
  987. XRapsody in Black
  988. X}
  989. X
  990. X{defsent
  991. X"{Lyric1:a}" by {Bandname}\n\n
  992. X{Lyric1} {lyric2} {lyric3}\n
  993. X{Lyric1} {lyric2} {lyric3}\n
  994. X{Lyric1} {lyric2} {lyric3}\n
  995. X{Lyric1} {lyric2} {lyric3}\n
  996. X\n(chorus)\n
  997. X{Lyric1:a} {lyric2:a} {lyric3:a}\n
  998. X{Lyric1:b} {lyric2:b} {lyric3:b}\n\n
  999. X{Lyric1} {lyric2} {lyric3}\n
  1000. X{Lyric1} {lyric2} {lyric3}\n
  1001. X{Lyric1} {lyric2} {lyric3}\n
  1002. X{Lyric1} {lyric2} {lyric3}\n
  1003. X\n(chorus)\n
  1004. X{Lyric1:a} {lyric2:a} {lyric3:a}\n
  1005. X{Lyric1:b} {lyric2:b} {lyric3:b}\n\n
  1006. X{Lyric1:b} {lyric2:b} {lyric3:b}\n
  1007. X{Lyric1:b} {lyric2:b} {lyric3:b}\n
  1008. X{Lyric1:b} {lyric2:b} {lyric3:b}\n
  1009. X{Lyric1:b} {lyric2:b} {lyric3:b}\n
  1010. X{Lyric1:b} {lyric2:b} {lyric3:b}\n
  1011. X{Lyric1:b} {lyric2:b} {lyric3:b}\n
  1012. X{Lyric1:b} {lyric2:b} {lyric3:b}\n
  1013. X{Lyric1:b} {lyric2:b} {lyric3:b}\n
  1014. X}
  1015. SHAR_EOF
  1016. $TOUCH -am 0828170791 rap.rc &&
  1017. chmod 0600 rap.rc ||
  1018. echo "restore of rap.rc failed"
  1019. set `wc -c rap.rc`;Wc_c=$1
  1020. if test "$Wc_c" != "1226"; then
  1021.     echo original size 1226, current size $Wc_c
  1022. fi
  1023. fi
  1024. exit 0
  1025.  
  1026. exit 0 # Just in case...
  1027.