home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / ed.zip / ed.doc < prev    next >
Text File  |  1989-12-05  |  3KB  |  121 lines

  1. Here is a version of the unix "ed" editor.
  2. For its history, please see the manual page.
  3.  
  4. This source uses a very slightly hacked version of Henry Spencer's
  5. Regexp package. The only difference from Henry's original is that regsub
  6. now returns a value, so it should be compatible with other uses of this
  7. package.
  8.  
  9. I'm sure that Henry's package is in an archive server somewhere, but I
  10. just mailed him (for his address, look in /usr/spool/news/.... :-)
  11. and was sent them by return. Don't you all do the same, though!
  12.  
  13. Here are the diffs from Henry's original:
  14.  
  15. *** regexp.h.orig    Fri Sep 29 11:23:29 1989
  16. --- regexp.h    Wed Nov 22 12:31:41 1989
  17. ***************
  18. *** 15,21 ****
  19.       char program[1];    /* Unwarranted chumminess with compiler. */
  20.   } regexp;
  21.  
  22.   extern regexp *regcomp();
  23.   extern int regexec();
  24. ! extern void regsub();
  25.   extern void regerror();
  26. --- 15,29 ----
  27.       char program[1];    /* Unwarranted chumminess with compiler. */
  28.   } regexp;
  29.  
  30. + #ifdef __STDC__
  31. + extern regexp *regcomp( char * );
  32. + extern int regexec( regexp*, char* );
  33. + extern char *regsub( regexp*, char*, char* );
  34. + extern void regerror( char* );
  35. + #else
  36.   extern regexp *regcomp();
  37.   extern int regexec();
  38. ! extern char *regsub();
  39.   extern void regerror();
  40. + #endif
  41. *** regsub.c.orig    Fri Sep 29 11:23:33 1989
  42. --- regsub.c    Wed Nov 22 12:18:52 1989
  43. ***************
  44. *** 18,23 ****
  45. --- 18,27 ----
  46.    *
  47.    *    3. Altered versions must be plainly marked as such, and must not
  48.    *        be misrepresented as being the original software.
  49. +  *
  50. +  * This version modified by Ian Phillipps to return pointer to terminating
  51. +  * NUL on substitution string. [ Temp mail address ex-igp@camcon.co.uk ]
  52. +  *
  53.    */
  54.   #include <stdio.h>
  55.   #include <regexp.h>
  56. ***************
  57. *** 32,38 ****
  58.   /*
  59.    - regsub - perform substitutions after a regexp match
  60.    */
  61. ! void
  62.   regsub(prog, source, dest)
  63.   regexp *prog;
  64.   char *source;
  65. --- 36,43 ----
  66.   /*
  67.    - regsub - perform substitutions after a regexp match
  68.    */
  69. ! char *
  70.   regsub(prog, source, dest)
  71.   regexp *prog;
  72.   char *source;
  73. ***************
  74. *** 47,57 ****
  75.  
  76.       if (prog == NULL || source == NULL || dest == NULL) {
  77.           regerror("NULL parm to regsub");
  78. !         return;
  79.       }
  80.       if (UCHARAT(prog->program) != MAGIC) {
  81.           regerror("damaged regexp fed to regsub");
  82. !         return;
  83.       }
  84.  
  85.       src = source;
  86. --- 52,62 ----
  87.  
  88.       if (prog == NULL || source == NULL || dest == NULL) {
  89.           regerror("NULL parm to regsub");
  90. !         return NULL;
  91.       }
  92.       if (UCHARAT(prog->program) != MAGIC) {
  93.           regerror("damaged regexp fed to regsub");
  94. !         return NULL;
  95.       }
  96.  
  97.       src = source;
  98. ***************
  99. *** 74,82 ****
  100.               dst += len;
  101.               if (len != 0 && *(dst-1) == '\0') {    /* strncpy hit NUL. */
  102.                   regerror("damaged match string");
  103. !                 return;
  104.               }
  105.           }
  106.       }
  107. !     *dst++ = '\0';
  108.   }
  109. --- 79,89 ----
  110.               dst += len;
  111.               if (len != 0 && *(dst-1) == '\0') {    /* strncpy hit NUL. */
  112.                   regerror("damaged match string");
  113. !                 return NULL;
  114.               }
  115.           }
  116.       }
  117. !     *dst = '\0';
  118. !     return dst;
  119.   }
  120. *************** end of diffs *****************
  121.