home *** CD-ROM | disk | FTP | other *** search
/ The UNIX CD Bookshelf / OREILLY_TUCB_UNIX_CD.iso / upt / examples / SOURCES / INDEX / RTR / INDEX. next >
Encoding:
Text File  |  1998-07-24  |  12.2 KB  |  621 lines

  1. *** createdb.c.orig    Wed Nov  4 22:04:20 1992
  2. --- createdb.c    Wed Nov  4 23:56:23 1992
  3. ***************
  4. *** 126,131 ****
  5. --- 126,132 ----
  6.        */
  7.       if ((pid = fork()) < 0) {
  8.           error("%s: cannot fork.\n", pname, 0, 0);
  9. +                 sleep(2);
  10.           exit(1);
  11.       }
  12.   
  13. ***************
  14. *** 133,140 ****
  15.        * Execute the editor.
  16.        */
  17.       if (pid == 0) {
  18. !         execl(editor, editor, fname, 0);
  19.           perror(editor);
  20.           exit(1);
  21.       }
  22.   
  23. --- 134,142 ----
  24.        * Execute the editor.
  25.        */
  26.       if (pid == 0) {
  27. !         execlp(editor, editor, fname, 0);
  28.           perror(editor);
  29. +                 sleep(2);
  30.           exit(1);
  31.       }
  32.   
  33. *** dbio.c.orig    Wed Nov  4 22:04:22 1992
  34. --- dbio.c    Wed Nov  4 23:48:26 1992
  35. ***************
  36. *** 17,22 ****
  37. --- 17,23 ----
  38.    * 
  39.    */
  40.   #include <sys/param.h>
  41. + #include <sys/types.h>
  42.   #include <sys/stat.h>
  43.   #include <curses.h>
  44.   #include <stdio.h>
  45. ***************
  46. *** 258,264 ****
  47.        * Set the file mode to the mode of the original
  48.        * file.  Mark the database as unmodified.
  49.        */
  50. !     fchmod(fileno(fp), st.st_mode & 0777);
  51.       dbmodified = 0;
  52.   
  53.       fclose(fp);
  54. --- 259,265 ----
  55.        * Set the file mode to the mode of the original
  56.        * file.  Mark the database as unmodified.
  57.        */
  58. !     chmod(realfile, st.st_mode & 0777);
  59.       dbmodified = 0;
  60.   
  61.       fclose(fp);
  62. *** defs.h.orig    Wed Nov  4 22:04:22 1992
  63. --- defs.h    Wed Nov  4 23:47:51 1992
  64. ***************
  65. *** 44,53 ****
  66.   #endif
  67.   
  68.   /*
  69. !  * Usually defined in ttychars.h.
  70.    */
  71. ! #ifndef CTRL
  72. ! #define CTRL(c)        ('c' & 037)
  73.   #endif
  74.   
  75.   /*
  76. --- 44,61 ----
  77.   #endif
  78.   
  79.   /*
  80. !  * Usually defined in ttychars.h, but sometimes wrongly defined in others.
  81.    */
  82. ! #undef CTRL
  83. ! #define CTRL(c)        (c & 037)
  84. ! #define bzero(s, n) memset(s, 0, n)
  85. ! #include <limits.h>
  86. ! #ifdef _POSIX_PATH_MAX
  87. ! #undef MAXPATHLEN
  88. ! #define MAXPATHLEN _POSIX_PATH_MAX
  89.   #endif
  90.   
  91.   /*
  92. No differences encountered
  93. *** printdb.c.orig    Wed Nov  4 22:04:25 1992
  94. --- printdb.c    Tue Nov 10 23:16:13 1992
  95. ***************
  96. *** 16,22 ****
  97.    * Initial revision
  98.    * 
  99.    */
  100. ! #include <sys/file.h>
  101.   #include <stdio.h>
  102.   #include "defs.h"
  103.   
  104. --- 16,22 ----
  105.    * Initial revision
  106.    * 
  107.    */
  108. ! #include <unistd.h>
  109.   #include <stdio.h>
  110.   #include "defs.h"
  111.   
  112. *** screen.c.orig    Wed Nov  4 22:05:31 1992
  113. --- screen.c    Tue Nov 10 23:10:34 1992
  114. ***************
  115. *** 66,79 ****
  116.        */
  117.       while ((c = getchar()) != EOF) {
  118.           switch (c) {
  119. !         case CTRL(a):            /* beginning of line    */
  120.               col = col0;
  121.               break;
  122. !         case CTRL(b):            /* back character    */
  123.               if (col > col0)
  124.                   col--;
  125.               break;
  126. !         case CTRL(d):            /* delete character    */
  127.               /*
  128.                * If there's stuff in the string,
  129.                * delete this character.
  130. --- 66,79 ----
  131.        */
  132.       while ((c = getchar()) != EOF) {
  133.           switch (c) {
  134. !         case CTRL('a'):            /* beginning of line    */
  135.               col = col0;
  136.               break;
  137. !         case CTRL('b'):            /* back character    */
  138.               if (col > col0)
  139.                   col--;
  140.               break;
  141. !         case CTRL('d'):            /* delete character    */
  142.               /*
  143.                * If there's stuff in the string,
  144.                * delete this character.
  145. ***************
  146. *** 102,115 ****
  147.               }
  148.   
  149.               break;
  150. !         case CTRL(e):            /* end of line        */
  151.               col = col0 + len;
  152.               break;
  153. !         case CTRL(f):            /* forward character    */
  154.               if ((col - col0) < len)
  155.                   col++;
  156.               break;
  157. !         case CTRL(h):            /* backspace delete    */
  158.           case '\177':
  159.               /*
  160.                * If there's stuff in the string,
  161. --- 102,115 ----
  162.               }
  163.   
  164.               break;
  165. !         case CTRL('e'):            /* end of line        */
  166.               col = col0 + len;
  167.               break;
  168. !         case CTRL('f'):            /* forward character    */
  169.               if ((col - col0) < len)
  170.                   col++;
  171.               break;
  172. !         case CTRL('h'):            /* backspace delete    */
  173.           case '\177':
  174.               /*
  175.                * If there's stuff in the string,
  176. ***************
  177. *** 139,145 ****
  178.                   delch();
  179.               }
  180.               break;
  181. !         case CTRL(k):            /* kill line        */
  182.               /*
  183.                * Clear the string.
  184.                */
  185. --- 139,145 ----
  186.                   delch();
  187.               }
  188.               break;
  189. !         case CTRL('k'):            /* kill line        */
  190.               /*
  191.                * Clear the string.
  192.                */
  193. ***************
  194. *** 152,164 ****
  195.                   clrtoeol();
  196.               }
  197.               break;
  198. !         case CTRL(l):            /* redraw screen    */
  199.               wrefresh(curscr);
  200.               break;
  201.           case '\n':            /* return the string    */
  202.               line[len] = '\0';
  203.               return;
  204.           default:            /* regular character    */
  205.               /*
  206.                * If it's the user's line-kill character,
  207.                * we'll accept that to kill the line too.
  208. --- 152,166 ----
  209.                   clrtoeol();
  210.               }
  211.               break;
  212. !         case CTRL('l'):            /* redraw screen    */
  213.               wrefresh(curscr);
  214.               break;
  215. +         case '\r':            /* return the string    */
  216.           case '\n':            /* return the string    */
  217.               line[len] = '\0';
  218.               return;
  219.           default:            /* regular character    */
  220. + #if 0
  221.               /*
  222.                * If it's the user's line-kill character,
  223.                * we'll accept that to kill the line too.
  224. ***************
  225. *** 171,177 ****
  226.                   *line = '\0';
  227.                   len = 0;
  228.               }
  229. !             else {
  230.                   /*
  231.                    * If it's a printable character,
  232.                    * insert it into the string.
  233. --- 173,181 ----
  234.                   *line = '\0';
  235.                   len = 0;
  236.               }
  237. !             else
  238. ! #endif
  239. !                         {
  240.                   /*
  241.                    * If it's a printable character,
  242.                    * insert it into the string.
  243. ***************
  244. *** 332,338 ****
  245.           case 'x':
  246.               byebye();
  247.               break;
  248. !         case CTRL(l):            /* redraw screen    */
  249.               wrefresh(curscr);
  250.               break;
  251.           }
  252. --- 336,342 ----
  253.           case 'x':
  254.               byebye();
  255.               break;
  256. !         case CTRL('l'):            /* redraw screen    */
  257.               wrefresh(curscr);
  258.               break;
  259.           }
  260. ***************
  261. *** 414,419 ****
  262. --- 418,424 ----
  263.            * Dispatch the command...
  264.            */
  265.           switch (c) {
  266. +         case '\r':            /* go to next entry    */
  267.           case '\n':            /* go to next entry    */
  268.               /*
  269.                * Save this one.
  270. ***************
  271. *** 567,580 ****
  272.           len = &tmp.db_lens[row];
  273.   
  274.           switch (c) {
  275. !         case CTRL(a):            /* beginning of line    */
  276.               col = col0;
  277.               break;
  278. !         case CTRL(b):            /* back character    */
  279.               if (col > col0)
  280.                   col--;
  281.               break;
  282. !         case CTRL(d):            /* delete character    */
  283.               if (*len) {
  284.                   /*
  285.                    * Calculate position of character
  286. --- 572,585 ----
  287.           len = &tmp.db_lens[row];
  288.   
  289.           switch (c) {
  290. !         case CTRL('a'):            /* beginning of line    */
  291.               col = col0;
  292.               break;
  293. !         case CTRL('b'):            /* back character    */
  294.               if (col > col0)
  295.                   col--;
  296.               break;
  297. !         case CTRL('d'):            /* delete character    */
  298.               if (*len) {
  299.                   /*
  300.                    * Calculate position of character
  301. ***************
  302. *** 599,612 ****
  303.               }
  304.   
  305.               break;
  306. !         case CTRL(e):            /* end of line        */
  307.               col = col0 + *len;
  308.               break;
  309. !         case CTRL(f):            /* forward character    */
  310.               if ((col - col0) < *len)
  311.                   col++;
  312.               break;
  313. !         case CTRL(h):            /* backspace delete    */
  314.           case '\177':
  315.               if (*len) {
  316.                   /*
  317. --- 604,617 ----
  318.               }
  319.   
  320.               break;
  321. !         case CTRL('e'):            /* end of line        */
  322.               col = col0 + *len;
  323.               break;
  324. !         case CTRL('f'):            /* forward character    */
  325.               if ((col - col0) < *len)
  326.                   col++;
  327.               break;
  328. !         case CTRL('h'):            /* backspace delete    */
  329.           case '\177':
  330.               if (*len) {
  331.                   /*
  332. ***************
  333. *** 632,638 ****
  334.                   delch();
  335.               }
  336.               break;
  337. !         case CTRL(k):            /* kill line        */
  338.               /*
  339.                * Kill the line.
  340.                */
  341. --- 637,643 ----
  342.                   delch();
  343.               }
  344.               break;
  345. !         case CTRL('k'):            /* kill line        */
  346.               /*
  347.                * Kill the line.
  348.                */
  349. ***************
  350. *** 645,654 ****
  351.                   clrtoeol();
  352.               }
  353.               break;
  354. !         case CTRL(l):            /* redraw screen    */
  355.               wrefresh(curscr);
  356.               break;
  357. !         case CTRL(n):            /* next line        */
  358.               /*
  359.                * Wrap around to the top if necessary.
  360.                */
  361. --- 650,659 ----
  362.                   clrtoeol();
  363.               }
  364.               break;
  365. !         case CTRL('l'):            /* redraw screen    */
  366.               wrefresh(curscr);
  367.               break;
  368. !         case CTRL('n'):            /* next line        */
  369.               /*
  370.                * Wrap around to the top if necessary.
  371.                */
  372. ***************
  373. *** 662,668 ****
  374.               if ((col - col0) > tmp.db_lens[row])
  375.                   col = col0 + tmp.db_lens[row];
  376.               break;
  377. !         case CTRL(p):            /* previous line    */
  378.               /*
  379.                * Wrap around if necessary.
  380.                */
  381. --- 667,673 ----
  382.               if ((col - col0) > tmp.db_lens[row])
  383.                   col = col0 + tmp.db_lens[row];
  384.               break;
  385. !         case CTRL('p'):            /* previous line    */
  386.               /*
  387.                * Wrap around if necessary.
  388.                */
  389. ***************
  390. *** 676,682 ****
  391.               if ((col - col0) > tmp.db_lens[row])
  392.                   col = col0 + tmp.db_lens[row];
  393.               break;
  394. !         case CTRL([):            /* save entry        */
  395.               /*
  396.                * Prompt for whether to save the entry.
  397.                */
  398. --- 681,687 ----
  399.               if ((col - col0) > tmp.db_lens[row])
  400.                   col = col0 + tmp.db_lens[row];
  401.               break;
  402. !         case CTRL('['):            /* save entry        */
  403.               /*
  404.                * Prompt for whether to save the entry.
  405.                */
  406. ***************
  407. *** 687,692 ****
  408. --- 692,698 ----
  409.                * See what they said.
  410.                */
  411.               switch (c) {
  412. +             case '\r':        /* never mind        */
  413.               case '\n':        /* never mind        */
  414.                   move(idx.idx_nlines+2, 0);
  415.                   clrtoeol();
  416. ***************
  417. *** 717,722 ****
  418. --- 723,729 ----
  419.                   return(0);
  420.               }
  421.               break;
  422. +         case '\r':            /* go to next line    */
  423.           case '\n':            /* go to next line    */
  424.               /*
  425.                * Wrap around if necessary.
  426. ***************
  427. *** 726,731 ****
  428. --- 733,739 ----
  429.               col = col0;
  430.               break;
  431.           default:            /* something else    */
  432. + #if 0
  433.               /*
  434.                * If it's the user's kill character, we'll
  435.                * accept that to delete the line too.
  436. ***************
  437. *** 738,744 ****
  438.                   *line = '\0';
  439.                   *len = 0;
  440.               }
  441. !             else {
  442.                   /*
  443.                    * If it's a printable character, insert
  444.                    * it into the string.
  445. --- 746,754 ----
  446.                   *line = '\0';
  447.                   *len = 0;
  448.               }
  449. !             else
  450. ! #endif
  451. !                         {
  452.                   /*
  453.                    * If it's a printable character, insert
  454.                    * it into the string.
  455. *** searchdb.c.orig    Wed Nov  4 22:04:33 1992
  456. --- searchdb.c    Wed Nov  4 23:08:32 1992
  457. ***************
  458. *** 38,44 ****
  459.        * to all lower case.
  460.        */
  461.       if (igncase) {
  462. !         for (p = pattern; *p != NULL; p++) {
  463.               if (isupper(*p))
  464.                   *p = tolower(*p);
  465.           }
  466. --- 38,44 ----
  467.        * to all lower case.
  468.        */
  469.       if (igncase) {
  470. !         for (p = pattern; *p != 0; p++) {
  471.               if (isupper(*p))
  472.                   *p = tolower(*p);
  473.           }
  474. ***************
  475. *** 74,80 ****
  476.                   p = db[i].db_lines[j];
  477.                   q = buf;
  478.   
  479. !                 while (*p != NULL) {
  480.                       *q++ = isupper(*p) ? tolower(*p) : *p;
  481.                       p++;
  482.                   }
  483. --- 74,80 ----
  484.                   p = db[i].db_lines[j];
  485.                   q = buf;
  486.   
  487. !                 while (*p != 0) {
  488.                       *q++ = isupper(*p) ? tolower(*p) : *p;
  489.                       p++;
  490.                   }
  491. ***************
  492. *** 109,111 ****
  493. --- 109,148 ----
  494.       return(code);
  495.   }
  496.   
  497. + #ifdef SYSV
  498. + static char* re;
  499. + char* re_comp(s)
  500. +     char* s;
  501. + {
  502. +     extern char* regcmp();
  503. +     if (s == 0 || !*s)
  504. +         return;
  505. +     if (re)
  506. +         free(re);
  507. +     re = regcmp(s, 0);
  508. +     return (re ? 0 : "Regex compile error");
  509. + }
  510. + re_exec(s)
  511. +     char* s;
  512. + {
  513. +     extern char* regex();
  514. +     char* match;
  515. +     if (!re)
  516. +         return -1;
  517. +     
  518. +     match = regex(re, s);
  519. +     return (match && !*match);
  520. + }
  521. + #endif
  522. *** selectdb.c.orig    Wed Nov  4 22:04:34 1992
  523. --- selectdb.c    Tue Nov 10 22:59:53 1992
  524. ***************
  525. *** 16,23 ****
  526.    * Initial revision
  527.    * 
  528.    */
  529. ! #include <sys/param.h>
  530. ! #include <sys/dir.h>
  531.   #include <curses.h>
  532.   #include <stdio.h>
  533.   #include "defs.h"
  534. --- 16,22 ----
  535.    * Initial revision
  536.    * 
  537.    */
  538. ! #include <dirent.h>
  539.   #include <curses.h>
  540.   #include <stdio.h>
  541.   #include "defs.h"
  542. ***************
  543. *** 62,69 ****
  544.       /*
  545.        * Prompt for the name of a database.
  546.        */
  547. !     while (*dbname == '\0')
  548. !         prompt_str(spread+2, 0, "Select a database: ", dbname);
  549.   
  550.       /*
  551.        * If the database exists, return its name.
  552. --- 61,73 ----
  553.       /*
  554.        * Prompt for the name of a database.
  555.        */
  556. !         prompt_str(spread+2, 0, "Select a database: ", dbname);
  557. !         if (*dbname == '\0')
  558. !         {
  559. !             reset_modes();
  560. !             printf("\nExiting - no database sepecified!\n");
  561. !             exit (1);
  562. !         }
  563.   
  564.       /*
  565.        * If the database exists, return its name.
  566. ***************
  567. *** 88,97 ****
  568.   {
  569.       DIR *dp;
  570.       int ndbs;
  571. !     char *rindex();
  572.       register char *s;
  573.       extern int compare();
  574. !     register struct direct *d;
  575.   
  576.       ndbs = 0;
  577.   
  578. --- 92,101 ----
  579.   {
  580.       DIR *dp;
  581.       int ndbs;
  582. !     char *strrchr();
  583.       register char *s;
  584.       extern int compare();
  585. !     register struct dirent *d;
  586.   
  587.       ndbs = 0;
  588.   
  589. ***************
  590. *** 111,117 ****
  591.            * Search for a "." in the name, which marks
  592.            * the suffix.
  593.            */
  594. !         if ((s = rindex(d->d_name, '.')) == NULL)
  595.               continue;
  596.   
  597.           /*
  598. --- 115,121 ----
  599.            * Search for a "." in the name, which marks
  600.            * the suffix.
  601.            */
  602. !         if ((s = strrchr(d->d_name, '.')) == NULL)
  603.               continue;
  604.   
  605.           /*
  606.