home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Editors / emacs / Emacs-1.14b1-sources / sources / utility-src / ispell / ispell.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-04  |  28.7 KB  |  967 lines  |  [TEXT/EMAC]

  1. /* Copyright (C) 1990, 1993  Free Software Foundation, Inc.
  2.  
  3.    This file is part of GNU ISPELL.
  4.    
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    GNU General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. /* ISPELL is an interactive spelling corrector generates a list
  20.    of near misses for each misspelled word.  The direct parantage
  21.    of this version seems to have begun in California in the
  22.    early 70's.  A child of that version was known as SPELL on
  23.    the MIT ITS systems, and later ISPELL on MIT TOPS-20 systems.
  24.    I wrote the first C implementation in 1983, and then developed
  25.    this version in 1988.  See the History section of ispell.texinfo
  26.    for more information.
  27.  
  28.    Pace Willisson
  29.    pace@ai.mit.edu  pace@hx.lcs.mit.edu
  30.    (617) 625-3452
  31.  
  32.    See ChangeLog for further author information. */
  33.  
  34. #include "stdio.h"
  35. #include <ctype.h>
  36. #include "signal.h"
  37.  
  38. #ifdef HAVE_MALLOC_H
  39. #include <malloc.h>
  40. #endif
  41.  
  42. #include "getopt.h"
  43.  
  44. #include "ispell.h"
  45. #include "hash.h"
  46. #include "charset.h"
  47.  
  48. static void show_warranty (NOARGS);
  49. static void show_copying (NOARGS);
  50. static void show_signon (NOARGS);
  51.  
  52. char **lexdecode = NULL;
  53.  
  54. /* this array contains letters to use when generating near misses */
  55. char near_miss_letters[256];
  56. int nnear_miss_letters;
  57.  
  58. /* this array has 1 for any character that is in near_miss_letters */
  59. char near_map[256];
  60.  
  61. enum formatter formatter;
  62.  
  63. /* set to 1 if any interaction takes place */
  64. int interaction_flag = 1;
  65.  
  66. int lflag;
  67. int aflag;
  68. int dflag;
  69. int pflag;
  70. int Sflag;
  71. int askflag;
  72. int Dflag;
  73. int Eflag;
  74. int hflag;
  75. int uflag;
  76. int iflag;
  77. char *dname;
  78. char *privname;
  79. int intr_typed;
  80.  
  81. FILE *sortf;
  82.  
  83.  
  84. void
  85. usage ()
  86. {
  87.   (void) fprintf (stderr, "Usage: ispell [-d dict] [-p privdict] file\n");
  88.   (void) fprintf (stderr, "or:    ispell [-a | -l]\n");
  89.   exit (1);
  90. }
  91.  
  92.  
  93. RETSIGTYPE
  94. intr ()
  95. {
  96.   signal (SIGINT, (RETSIGTYPE (*)()) intr);
  97.   intr_typed = 1;
  98. }
  99.  
  100.  
  101. void
  102. done ()
  103. {
  104.   extern char tempfile[];
  105.  
  106.   if (tempfile[0])
  107.     {
  108.       (void) unlink (tempfile);
  109.       tempfile[0] = 0;
  110.     }
  111.   termuninit ();
  112.   exit (0);
  113. }
  114.  
  115. struct cmd
  116. {
  117.   char name[20];
  118. #ifdef __STDC__
  119.   int (*func) (char *);
  120. #else
  121.   int (*func) ();
  122. #endif
  123. };
  124.  
  125. extern struct cmd subcmds[];
  126.  
  127.  
  128. int
  129. main1 (argc, argv)
  130.   int argc;
  131.   char **argv;
  132. {
  133.   int c;
  134.   extern char *optarg;
  135.   extern int optind;
  136.   char *p;
  137.   int i;
  138.  
  139. int cmd_insert(),cmd_accept(),cmd_delete(),cmd_dump(),cmd_reload(),
  140.     cmd_file(),cmd_tex(),cmd_troff(),cmd_generic();
  141. subcmds[0].func = cmd_insert;
  142. subcmds[1].func = cmd_accept;
  143. subcmds[2].func = cmd_delete;
  144. subcmds[3].func = cmd_dump;
  145. subcmds[4].func = cmd_reload;
  146. subcmds[5].func = cmd_file;
  147. subcmds[6].func = cmd_tex;
  148. subcmds[7].func = cmd_troff;
  149. subcmds[8].func = cmd_generic;
  150.  
  151. #if 0
  152. {
  153.     extern char **environ;
  154.     char *_argv[] = { "ispell", "-S", 0L };
  155.     argv = _argv;
  156.     argc = sizeof(_argv) / sizeof(char *) - 1;
  157.     init_unix_io_driver(1,&environ);
  158. }
  159. #endif
  160.  
  161.   for (i = 0; i < 256; i++)
  162.     if (charset[i].word_component)
  163.       (ctbl + 1)[i] |= LEXLETTER;
  164.  
  165.   /* if invoked by the name 'spell', set uflag */
  166.   if ((p = (char *) strrchr (argv[0], '/')))
  167.     p++;
  168.   else
  169.     p = argv[0];
  170.  
  171.   if (strcmp (p, "spell") == 0)
  172.     {
  173.       uflag = 1;
  174.       lflag = 1;
  175.     }
  176.  
  177.   formatter = formatter_generic;
  178.  
  179.   while ((c = getopt (argc, argv, "alp:d:SDEhuvbixtWC")) != EOF)
  180.     {
  181.       switch (c)
  182.     {
  183.     case 'W':
  184.       show_warranty ();
  185.       exit (0);
  186.     case 'C':
  187.       show_copying ();
  188.       exit (0);
  189.     case 't':
  190.       formatter = formatter_tex;
  191.       break;
  192.       /* traditional spell options */
  193.       /* ignore these */
  194.     case 'v':        /* don't trust original suffix stripper */
  195.     case 'b':        /* check british spelling */
  196.       break;
  197.     case 'i':        /* don't follow any .so's or .nx's */
  198.       iflag = 1;
  199.       break;
  200.       /* case 'l': */
  201.       /* follow nroff .so's, and .nx's into /usr/lib */
  202.       /* in ispell, this means make a list.  luckily,
  203.              * if the user wants old style, lflag is turned
  204.              * on anyway
  205.              */
  206.  
  207.     case 'x':        /* print stems with '='s */
  208.       (void) fprintf (stderr, "-x is not supported\n");
  209.       exit (1);
  210.  
  211.       /* end of traditional options */
  212.  
  213.     case 'u':
  214.       uflag = 1;
  215.       lflag = 1;
  216.       break;
  217.     case 'h':
  218.       hflag = 1;
  219.       break;
  220.     default:
  221.       usage ();
  222.     case 'D':
  223.       Dflag = 1;
  224.       break;
  225.     case 'E':
  226.       Eflag = 1;
  227.       break;
  228.     case 'p':
  229.       pflag = 1;
  230.       privname = optarg;
  231.       break;
  232.     case 'd':
  233.       dflag = 1;
  234.       dname = optarg;
  235.       break;
  236.     case 'a':
  237.       aflag = 1;
  238.       break;
  239.     case 'l':
  240.       lflag = 1;
  241.       break;
  242.     case 'S':
  243.       Sflag = 1;
  244.       break;
  245.     }
  246.     }
  247.  
  248.   if (optind < argc && argv[optind][0] == '+')
  249.     {
  250.       /* this is for traditional spell - add words in
  251.          * named file to OK list
  252.          */
  253.       (void) p_load (argv[optind] + 1, 0);
  254.       optind++;
  255.     }
  256.  
  257.   if (dflag == 0)
  258.     {
  259.       dname = (char *) getenv ("ISPELL_DICTIONARY");
  260.       if (dname == NULL)
  261.     {
  262.       dname = (char *) xmalloc ((unsigned) strlen (DICT_LIB) + 30);
  263.       (void) strcpy (dname, DICT_LIB);
  264.       (void) strcat (dname, "/ispell.dict.bin");
  265.     }
  266.     }
  267.  
  268.   if (access (dname, 4) < 0)
  269.     {
  270.       (void) fprintf (stderr, "can't read dictionary %s\n", dname);
  271.       exit (1);
  272.     }
  273.  
  274.   if (!Dflag && !Eflag && !Sflag && !aflag && !lflag)
  275.     show_signon ();
  276.  
  277.   if (hash_init (dname) < 0)
  278.     {
  279.       (void) fprintf (stderr, "hash_init failed\n");
  280.       exit (1);
  281.     }
  282.  
  283.   if (hflag)
  284.     {
  285.       prhashchain ();
  286.       exit (0);
  287.     }
  288.  
  289.   if (Dflag)
  290.     {
  291.       hash_awrite (stdout);
  292.       exit (0);
  293.     }
  294.  
  295.   if (Eflag)
  296.     {
  297.       hash_ewrite (stdout);
  298.       exit (0);
  299.     }
  300.  
  301. if (pflag == 0)
  302. {
  303.     if ((p = (char *) getenv ("HOME")) != NULL)
  304.     {
  305.         privname = (char *) xmalloc ((unsigned) (strlen (p) + 50));
  306.         (void) strcpy (privname, p);
  307.         (void) strcat (privname, "/ispell.words");
  308.  
  309.         // Added MP
  310.         strcpy(privname,"~emacs/ispell.words");
  311.     }
  312. }
  313.  
  314.   if (privname)
  315.     (void) p_load (privname, 1);
  316.  
  317.   if (Sflag)
  318.     {
  319.       submode ();
  320.     }
  321.   else if (aflag)
  322.     {
  323.       askmode (0);
  324.     }
  325.   else if (uflag)
  326.     {
  327.       spellmode (argc, argv, optind);
  328.       exit (0);
  329.     }
  330.   else if (lflag)
  331.     {
  332.       checkfile (stdin, (FILE *) NULL, (long) 0);
  333.       exit (0);
  334.     }
  335.   else
  336.     {
  337.       /* normal interactive mode */
  338.       if (optind == argc)
  339.     {
  340.       askmode (1);
  341.       exit (0);
  342.     }
  343.       signal (SIGINT, (RETSIGTYPE (*)()) intr);
  344.       terminit ();
  345.       while (optind < argc)
  346.     dofile (argv[optind++]);
  347.  
  348.       if (interaction_flag == 0)
  349.     printf ("No errors detected\r\n");
  350.     }
  351.  
  352.   if (privname)
  353.     (void) p_dump (privname);
  354.  
  355.   done ();
  356.   exit (0);
  357. }
  358.  
  359. extern struct sp_corrections corrections;
  360. static char stdoutbuf[BUFSIZ];
  361.  
  362. void
  363. submode (NOARGS)
  364. {
  365.   char buf[BUFSIZ];
  366.   int i;
  367.   int c;
  368.   int len;
  369.  
  370.   signal (SIGINT, SIG_IGN);
  371.   setbuf (stdin, (char *) NULL);
  372.   setbuf (stdout, stdoutbuf);
  373.   (void) printf ("(1 \"%s\")", VERSION_STRING);
  374.  
  375.   while (1)
  376.     {
  377.     again:
  378.       intr_typed = 0;
  379.       putchar ('=');
  380.       fflush (stdout);
  381.  
  382.       if (fgets (buf, sizeof buf, stdin) == NULL)
  383.     break;
  384.       len = strlen (buf);
  385.       if (len && buf[len - 1] == '\n')
  386.     {
  387.       buf[--len] = 0;
  388.     }
  389.       else
  390.     {
  391.       /* line was too long to hold newline -
  392.              * just return an error without otherwise
  393.              * looking at it
  394.              */
  395.       while (1)
  396.         {
  397.           if ((c = getchar ()) == EOF)
  398.         return;
  399.           if (c == '\n')
  400.         {
  401.           (void) printf ("nil\n");
  402.           goto again;
  403.         }
  404.         }
  405.     }
  406.       if (buf[0] == 0)
  407.     continue;
  408.  
  409.       if (buf[0] == ':')
  410.     {
  411.       if (subcmd (buf) < 0)
  412.         (void) printf ("nil\n");
  413.       else
  414.         (void) printf ("t\n");
  415.       continue;
  416.     }
  417.       if (good (buf, strlen (buf), 0))
  418.     {
  419.       (void) printf ("t\n");
  420.     }
  421.       else
  422.     {
  423.       makepossibilities (buf);
  424.       if (corrections.posbuf[0][0])
  425.         {
  426.           (void) printf ("(");
  427.           for (i = 0; i < 10; i++)
  428.         {
  429.           if (corrections.posbuf[i][0] == 0)
  430.             break;
  431.           (void) printf ("\"%s\" ",
  432.                  corrections.posbuf[i]);
  433.         }
  434.           (void) printf (")\n");
  435.         }
  436.       else
  437.         {
  438.           (void) printf ("nil\n");
  439.         }
  440.     }
  441.     }
  442. }
  443.  
  444. int
  445. subcmd (buf)
  446.   char *buf;
  447. {
  448.   char *p;
  449.   struct cmd *cp;
  450.  
  451.   buf++;            /* skip colon */
  452.   for (p = buf; *p && !isspace (*p); p++)
  453.     ;
  454.   if (*p)
  455.     *p++ = 0;
  456.  
  457.   for (cp = subcmds; cp->name[0]; cp++) // Change here
  458.     if (strcmp (cp->name, buf) == 0)
  459.       break;
  460.   if (!cp->name[0])
  461.     return (-1);
  462.  
  463.   return ((*cp->func) (p));
  464. }
  465.  
  466.  
  467. int
  468. cmd_insert (arg)
  469.      char *arg;
  470. {
  471.   return (p_enter (arg, 1, 1));
  472. }
  473.  
  474.  
  475. int
  476. cmd_accept (arg)
  477.   char *arg;
  478. {
  479.   return (p_enter (arg, 1, 0));
  480. }
  481.  
  482.  
  483. int
  484. cmd_delete (arg)
  485.   char *arg;
  486. {
  487.   return (p_delete (arg));
  488. }
  489.  
  490.  
  491. int
  492. cmd_dump (arg)
  493.   char *arg;
  494. {
  495.   if (privname)
  496.     return (p_dump (privname));
  497.   else
  498.     return (-1);
  499. }
  500.  
  501. /* ARGSUSED */
  502. int
  503. cmd_reload (arg)
  504.   char *arg;
  505. {
  506.   return p_reload ();
  507. }
  508.  
  509.  
  510. int
  511. cmd_file (arg)
  512.   char *arg;
  513. {
  514.   FILE *f;
  515.   long start, end;
  516.   char *p;
  517.  
  518.     // This is a Macintosh kludge to allow spaces in pathnames.
  519.     int len = strlen(arg);
  520.     int spaces = 0;
  521.     int i = len-1;
  522.     while (1) {
  523.         if (i < 0) return -1;
  524.         if (isspace(arg[i])) {
  525.             ++spaces;
  526.             if (spaces == 2) break;
  527.         }
  528.         --i;
  529.     }
  530.     arg[i] = '\0';
  531.     p = arg+i+1;
  532. /*
  533.   for (p = arg; *p && !isspace (*p); p++)
  534.     ;
  535.   if (*p)
  536.     *p++ = 0;
  537. */
  538.  
  539.   start = 0;
  540.   end = 0;
  541.  
  542.   sscanf (p, "%ld %ld", &start, &end);
  543.  
  544.   if ((f = fopen (arg, "r")) == NULL)
  545.     return -1;
  546.  
  547.   if (fseek (f, start, 0) < 0)
  548.     {
  549.       (void) fclose (f);
  550.       return (-1);
  551.     }
  552.  
  553.   signal (SIGINT, (RETSIGTYPE (*)()) intr);
  554.   checkfile (f, (FILE *) NULL, end);
  555.   signal (SIGINT, SIG_IGN);
  556.  
  557.   (void) fclose (f);
  558.   if (intr_typed)
  559.     {
  560.       intr_typed = 0;
  561.       return (-1);
  562.     }
  563.   else
  564.     {
  565.       return (0);
  566.     }
  567. }
  568.  
  569. /* ARGSUSED */
  570. int
  571. cmd_tex (arg)
  572.   char *arg;
  573. {
  574.   formatter = formatter_tex;
  575.   return (0);
  576. }
  577.  
  578. /* ARGSUSED */
  579. int
  580. cmd_troff (arg)
  581.   char *arg;
  582. {
  583.   formatter = formatter_troff;
  584.   return (0);
  585. }
  586.  
  587. /* ARGUSED */
  588. int
  589. cmd_generic (arg)
  590.   char *arg;
  591. {
  592.   formatter = formatter_generic;
  593.   return (0);
  594. }
  595.  
  596.  
  597. void
  598. spellmode (ac, av, ind)
  599.   char **av;
  600.   int ac, ind;
  601. {
  602.   FILE *f;
  603.  
  604.   sortf = (FILE *) popen ("sort", "w");
  605.   if (sortf == NULL)
  606.     {
  607.       (void) fprintf (stderr, "can't exec 'sort' program\n");
  608.       exit (1);
  609.     }
  610.   if (ac == ind)
  611.     {
  612.       checkfile (stdin, (FILE *) NULL, (long) 0);
  613.     }
  614.   else
  615.     {
  616.       while (ind < ac)
  617.     {
  618.       f = fopen (av[ind], "r");
  619.       if (f == NULL)
  620.         {
  621.           (void) fprintf (stderr, "can't open %s\n", av[ind]);
  622.         }
  623.       else
  624.         {
  625.           checkfile (f, (FILE *) NULL, (long) 0);
  626.           (void) fclose (f);
  627.         }
  628.       ind++;
  629.     }
  630.     }
  631.   (void) pclose (sortf);    /* needed to wait for sort to finish */
  632. }
  633.  
  634.  
  635. struct cmd subcmds[] =
  636. {
  637.   {"insert", },
  638.   {"accept", },
  639.   {"delete", },
  640.   {"dump", },
  641.   {"reload", },
  642.   {"file", },
  643.   {"tex", },
  644.   {"troff", },
  645.   {"generic", },
  646.   {""}
  647. };
  648.  
  649. /* struct cmd subcmds[] =
  650. {
  651.   {"insert", cmd_insert},
  652.   {"accept", cmd_accept},
  653.   {"delete", cmd_delete},
  654.   {"dump", cmd_dump},
  655.   {"reload", cmd_reload},
  656.   {"file", cmd_file},
  657.   {"tex", cmd_tex},
  658.   {"troff", cmd_troff},
  659.   {"generic", cmd_generic},
  660.   {NULL}
  661. }; */
  662.  
  663. #define p(str) printf("%s\n", str)
  664.  
  665. static void
  666. show_signon ()
  667. {
  668.   printf ("%s.\n", VERSION_STRING);
  669.   p ("Copyright (C) 1990, 1993 Free Software Foundation, Inc.");
  670.   p ("Ispell comes with ABSOLUTELY NO WARRANTY; for details run \"ispell -W\"");
  671.   p ("This is free software, and you are welcome to redistribute it");
  672.   p ("under certain conditions; run \"ispell -C\" for details.");
  673. }
  674.  
  675.  
  676. static void
  677. show_copying ()
  678. {
  679. #if 0
  680.   p ("            GNU GENERAL PUBLIC LICENSE");
  681.   p ("               Version 2, June 1991");
  682.   p ("");
  683.   p (" Copyright (C) 1989, 1991 Free Software Foundation, Inc.");
  684.   p ("                          675 Mass Ave, Cambridge, MA 02139, USA");
  685.   p (" Everyone is permitted to copy and distribute verbatim copies");
  686.   p (" of this license document, but changing it is not allowed.");
  687.   p ("");
  688.   p ("                Preamble");
  689.   p ("");
  690.   p ("  The licenses for most software are designed to take away your");
  691.   p ("freedom to share and change it.  By contrast, the GNU General Public");
  692.   p ("License is intended to guarantee your freedom to share and change free");
  693.   p ("software--to make sure the software is free for all its users.  This");
  694.   p ("General Public License applies to most of the Free Software");
  695.   p ("Foundation's software and to any other program whose authors commit to");
  696.   p ("using it.  (Some other Free Software Foundation software is covered by");
  697.   p ("the GNU Library General Public License instead.)  You can apply it to");
  698.   p ("your programs, too.");
  699.   p ("");
  700.   p ("  When we speak of free software, we are referring to freedom, not");
  701.   p ("price.  Our General Public Licenses are designed to make sure that you");
  702.   p ("have the freedom to distribute copies of free software (and charge for");
  703.   p ("this service if you wish), that you receive source code or can get it");
  704.   p ("if you want it, that you can change the software or use pieces of it");
  705.   p ("in new free programs; and that you know you can do these things.");
  706.   p ("");
  707.   p ("  To protect your rights, we need to make restrictions that forbid");
  708.   p ("anyone to deny you these rights or to ask you to surrender the rights.");
  709.   p ("These restrictions translate to certain responsibilities for you if you");
  710.   p ("distribute copies of the software, or if you modify it.");
  711.   p ("");
  712.   p ("  For example, if you distribute copies of such a program, whether");
  713.   p ("gratis or for a fee, you must give the recipients all the rights that");
  714.   p ("you have.  You must make sure that they, too, receive or can get the");
  715.   p ("source code.  And you must show them these terms so they know their");
  716.   p ("rights.");
  717.   p ("");
  718.   p ("  We protect your rights with two steps: (1) copyright the software, and");
  719.   p ("(2) offer you this license which gives you legal permission to copy,");
  720.   p ("distribute and/or modify the software.");
  721.   p ("");
  722.   p ("  Also, for each author's protection and ours, we want to make certain");
  723.   p ("that everyone understands that there is no warranty for this free");
  724.   p ("software.  If the software is modified by someone else and passed on, we");
  725.   p ("want its recipients to know that what they have is not the original, so");
  726.   p ("that any problems introduced by others will not reflect on the original");
  727.   p ("authors' reputations.");
  728.   p ("");
  729.   p ("  Finally, any free program is threatened constantly by software");
  730.   p ("patents.  We wish to avoid the danger that redistributors of a free");
  731.   p ("program will individually obtain patent licenses, in effect making the");
  732.   p ("program proprietary.  To prevent this, we have made it clear that any");
  733.   p ("patent must be licensed for everyone's free use or not licensed at all.");
  734.   p ("");
  735.   p ("  The precise terms and conditions for copying, distribution and");
  736.   p ("modification follow.");
  737.   p (" ");
  738.   p ("            GNU GENERAL PUBLIC LICENSE");
  739.   p ("   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION");
  740.   p ("");
  741.   p ("  0. This License applies to any program or other work which contains");
  742.   p ("a notice placed by the copyright holder saying it may be distributed");
  743.   p ("under the terms of this General Public License.  The \"Program\", below,");
  744.   p ("refers to any such program or work, and a \"work based on the Program\"");
  745.   p ("means either the Program or any derivative work under copyright law:");
  746.   p ("that is to say, a work containing the Program or a portion of it,");
  747.   p ("either verbatim or with modifications and/or translated into another");
  748.   p ("language.  (Hereinafter, translation is included without limitation in");
  749.   p ("the term \"modification\".)  Each licensee is addressed as \"you\".");
  750.   p ("");
  751.   p ("Activities other than copying, distribution and modification are not");
  752.   p ("covered by this License; they are outside its scope.  The act of");
  753.   p ("running the Program is not restricted, and the output from the Program");
  754.   p ("is covered only if its contents constitute a work based on the");
  755.   p ("Program (independent of having been made by running the Program).");
  756.   p ("Whether that is true depends on what the Program does.");
  757.   p ("");
  758.   p ("  1. You may copy and distribute verbatim copies of the Program's");
  759.   p ("source code as you receive it, in any medium, provided that you");
  760.   p ("conspicuously and appropriately publish on each copy an appropriate");
  761.   p ("copyright notice and disclaimer of warranty; keep intact all the");
  762.   p ("notices that refer to this License and to the absence of any warranty;");
  763.   p ("and give any other recipients of the Program a copy of this License");
  764.   p ("along with the Program.");
  765.   p ("");
  766.   p ("You may charge a fee for the physical act of transferring a copy, and");
  767.   p ("you may at your option offer warranty protection in exchange for a fee.");
  768.   p ("");
  769.   p ("  2. You may modify your copy or copies of the Program or any portion");
  770.   p ("of it, thus forming a work based on the Program, and copy and");
  771.   p ("distribute such modifications or work under the terms of Section 1");
  772.   p ("above, provided that you also meet all of these conditions:");
  773.   p ("");
  774.   p ("    a) You must cause the modified files to carry prominent notices");
  775.   p ("    stating that you changed the files and the date of any change.");
  776.   p ("");
  777.   p ("    b) You must cause any work that you distribute or publish, that in");
  778.   p ("    whole or in part contains or is derived from the Program or any");
  779.   p ("    part thereof, to be licensed as a whole at no charge to all third");
  780.   p ("    parties under the terms of this License.");
  781.   p ("");
  782.   p ("    c) If the modified program normally reads commands interactively");
  783.   p ("    when run, you must cause it, when started running for such");
  784.   p ("    interactive use in the most ordinary way, to print or display an");
  785.   p ("    announcement including an appropriate copyright notice and a");
  786.   p ("    notice that there is no warranty (or else, saying that you provide");
  787.   p ("    a warranty) and that users may redistribute the program under");
  788.   p ("    these conditions, and telling the user how to view a copy of this");
  789.   p ("    License.  (Exception: if the Program itself is interactive but");
  790.   p ("    does not normally print such an announcement, your work based on");
  791.   p ("    the Program is not required to print an announcement.)");
  792.   p (" ");
  793.   p ("These requirements apply to the modified work as a whole.  If");
  794.   p ("identifiable sections of that work are not derived from the Program,");
  795.   p ("and can be reasonably considered independent and separate works in");
  796.   p ("themselves, then this License, and its terms, do not apply to those");
  797.   p ("sections when you distribute them as separate works.  But when you");
  798.   p ("distribute the same sections as part of a whole which is a work based");
  799.   p ("on the Program, the distribution of the whole must be on the terms of");
  800.   p ("this License, whose permissions for other licensees extend to the");
  801.   p ("entire whole, and thus to each and every part regardless of who wrote it.");
  802.   p ("");
  803.   p ("Thus, it is not the intent of this section to claim rights or contest");
  804.   p ("your rights to work written entirely by you; rather, the intent is to");
  805.   p ("exercise the right to control the distribution of derivative or");
  806.   p ("collective works based on the Program.");
  807.   p ("");
  808.   p ("In addition, mere aggregation of another work not based on the Program");
  809.   p ("with the Program (or with a work based on the Program) on a volume of");
  810.   p ("a storage or distribution medium does not bring the other work under");
  811.   p ("the scope of this License.");
  812.   p ("");
  813.   p ("  3. You may copy and distribute the Program (or a work based on it,");
  814.   p ("under Section 2) in object code or executable form under the terms of");
  815.   p ("Sections 1 and 2 above provided that you also do one of the following:");
  816.   p ("");
  817.   p ("    a) Accompany it with the complete corresponding machine-readable");
  818.   p ("    source code, which must be distributed under the terms of Sections");
  819.   p ("    1 and 2 above on a medium customarily used for software interchange; or,");
  820.   p ("");
  821.   p ("    b) Accompany it with a written offer, valid for at least three");
  822.   p ("    years, to give any third party, for a charge no more than your");
  823.   p ("    cost of physically performing source distribution, a complete");
  824.   p ("    machine-readable copy of the corresponding source code, to be");
  825.   p ("    distributed under the terms of Sections 1 and 2 above on a medium");
  826.   p ("    customarily used for software interchange; or,");
  827.   p ("");
  828.   p ("    c) Accompany it with the information you received as to the offer");
  829.   p ("    to distribute corresponding source code.  (This alternative is");
  830.   p ("    allowed only for noncommercial distribution and only if you");
  831.   p ("    received the program in object code or executable form with such");
  832.   p ("    an offer, in accord with Subsection b above.)");
  833.   p ("");
  834.   p ("The source code for a work means the preferred form of the work for");
  835.   p ("making modifications to it.  For an executable work, complete source");
  836.   p ("code means all the source code for all modules it contains, plus any");
  837.   p ("associated interface definition files, plus the scripts used to");
  838.   p ("control compilation and installation of the executable.  However, as a");
  839.   p ("special exception, the source code distributed need not include");
  840.   p ("anything that is normally distributed (in either source or binary");
  841.   p ("form) with the major components (compiler, kernel, and so on) of the");
  842.   p ("operating system on which the executable runs, unless that component");
  843.   p ("itself accompanies the executable.");
  844.   p ("");
  845.   p ("If distribution of executable or object code is made by offering");
  846.   p ("access to copy from a designated place, then offering equivalent");
  847.   p ("access to copy the source code from the same place counts as");
  848.   p ("distribution of the source code, even though third parties are not");
  849.   p ("compelled to copy the source along with the object code.");
  850.   p (" ");
  851.   p ("  4. You may not copy, modify, sublicense, or distribute the Program");
  852.   p ("except as expressly provided under this License.  Any attempt");
  853.   p ("otherwise to copy, modify, sublicense or distribute the Program is");
  854.   p ("void, and will automatically terminate your rights under this License.");
  855.   p ("However, parties who have received copies, or rights, from you under");
  856.   p ("this License will not have their licenses terminated so long as such");
  857.   p ("parties remain in full compliance.");
  858.   p ("");
  859.   p ("  5. You are not required to accept this License, since you have not");
  860.   p ("signed it.  However, nothing else grants you permission to modify or");
  861.   p ("distribute the Program or its derivative works.  These actions are");
  862.   p ("prohibited by law if you do not accept this License.  Therefore, by");
  863.   p ("modifying or distributing the Program (or any work based on the");
  864.   p ("Program), you indicate your acceptance of this License to do so, and");
  865.   p ("all its terms and conditions for copying, distributing or modifying");
  866.   p ("the Program or works based on it.");
  867.   p ("");
  868.   p ("  6. Each time you redistribute the Program (or any work based on the");
  869.   p ("Program), the recipient automatically receives a license from the");
  870.   p ("original licensor to copy, distribute or modify the Program subject to");
  871.   p ("these terms and conditions.  You may not impose any further");
  872.   p ("restrictions on the recipients' exercise of the rights granted herein.");
  873.   p ("You are not responsible for enforcing compliance by third parties to");
  874.   p ("this License.");
  875.   p ("");
  876.   p ("  7. If, as a consequence of a court judgment or allegation of patent");
  877.   p ("infringement or for any other reason (not limited to patent issues),");
  878.   p ("conditions are imposed on you (whether by court order, agreement or");
  879.   p ("otherwise) that contradict the conditions of this License, they do not");
  880.   p ("excuse you from the conditions of this License.  If you cannot");
  881.   p ("distribute so as to satisfy simultaneously your obligations under this");
  882.   p ("License and any other pertinent obligations, then as a consequence you");
  883.   p ("may not distribute the Program at all.  For example, if a patent");
  884.   p ("license would not permit royalty-free redistribution of the Program by");
  885.   p ("all those who receive copies directly or indirectly through you, then");
  886.   p ("the only way you could satisfy both it and this License would be to");
  887.   p ("refrain entirely from distribution of the Program.");
  888.   p ("");
  889.   p ("If any portion of this section is held invalid or unenforceable under");
  890.   p ("any particular circumstance, the balance of the section is intended to");
  891.   p ("apply and the section as a whole is intended to apply in other");
  892.   p ("circumstances.");
  893.   p ("");
  894.   p ("It is not the purpose of this section to induce you to infringe any");
  895.   p ("patents or other property right claims or to contest validity of any");
  896.   p ("such claims; this section has the sole purpose of protecting the");
  897.   p ("integrity of the free software distribution system, which is");
  898.   p ("implemented by public license practices.  Many people have made");
  899.   p ("generous contributions to the wide range of software distributed");
  900.   p ("through that system in reliance on consistent application of that");
  901.   p ("system; it is up to the author/donor to decide if he or she is willing");
  902.   p ("to distribute software through any other system and a licensee cannot");
  903.   p ("impose that choice.");
  904.   p ("");
  905.   p ("This section is intended to make thoroughly clear what is believed to");
  906.   p ("be a consequence of the rest of this License.");
  907.   p (" ");
  908.   p ("  8. If the distribution and/or use of the Program is restricted in");
  909.   p ("certain countries either by patents or by copyrighted interfaces, the");
  910.   p ("original copyright holder who places the Program under this License");
  911.   p ("may add an explicit geographical distribution limitation excluding");
  912.   p ("those countries, so that distribution is permitted only in or among");
  913.   p ("countries not thus excluded.  In such case, this License incorporates");
  914.   p ("the limitation as if written in the body of this License.");
  915.   p ("");
  916.   p ("  9. The Free Software Foundation may publish revised and/or new versions");
  917.   p ("of the General Public License from time to time.  Such new versions will");
  918.   p ("be similar in spirit to the present version, but may differ in detail to");
  919.   p ("address new problems or concerns.");
  920.   p ("");
  921.   p ("Each version is given a distinguishing version number.  If the Program");
  922.   p ("specifies a version number of this License which applies to it and \"any");
  923.   p ("later version\", you have the option of following the terms and conditions");
  924.   p ("either of that version or of any later version published by the Free");
  925.   p ("Software Foundation.  If the Program does not specify a version number of");
  926.   p ("this License, you may choose any version ever published by the Free Software");
  927.   p ("Foundation.");
  928.   p ("");
  929.   p ("  10. If you wish to incorporate parts of the Program into other free");
  930.   p ("programs whose distribution conditions are different, write to the author");
  931.   p ("to ask for permission.  For software which is copyrighted by the Free");
  932.   p ("Software Foundation, write to the Free Software Foundation; we sometimes");
  933.   p ("make exceptions for this.  Our decision will be guided by the two goals");
  934.   p ("of preserving the free status of all derivatives of our free software and");
  935.   p ("of promoting the sharing and reuse of software generally.");
  936.   p ("");
  937. #endif
  938. }
  939.  
  940.  
  941. static void
  942. show_warranty ()
  943. {
  944.   p ("                NO WARRANTY");
  945.   p ("");
  946.   p ("  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY");
  947.   p ("FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN");
  948.   p ("OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES");
  949.   p ("PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED");
  950.   p ("OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF");
  951.   p ("MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS");
  952.   p ("TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE");
  953.   p ("PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,");
  954.   p ("REPAIR OR CORRECTION.");
  955.   p ("");
  956.   p ("  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING");
  957.   p ("WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR");
  958.   p ("REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,");
  959.   p ("INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING");
  960.   p ("OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED");
  961.   p ("TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY");
  962.   p ("YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER");
  963.   p ("PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE");
  964.   p ("POSSIBILITY OF SUCH DAMAGES.");
  965.   p ("");
  966. }
  967.