home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / unix / volume03 / regexp2 < prev    next >
Encoding:
Text File  |  1988-09-11  |  968 b   |  33 lines

  1. Subject: bug in regexp(3), and fix
  2. Newsgroups: mod.sources
  3. Approved: jpn@panda.UUCP
  4.  
  5. Mod.sources:  Volume 3, Issue 105
  6. Submitted by: genrad!decvax!utzoo!henry
  7.  
  8. Drat!  Chris Siebenmann at CSRI just found a bug in my regexp(3) routines.
  9. The problem is that the code for character classes does not check properly
  10. for the possibility that it might be looking at the end of the string.  By
  11. simple bad luck none of my test cases hit this.  To fix it, make the
  12. following two changes to regexp.c:
  13.  
  14. 848c848
  15. <             if (strchr(OPERAND(scan), *reginput) == NULL)
  16. ---
  17. >             if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL)
  18. 853c853
  19. <             if (strchr(OPERAND(scan), *reginput) != NULL)
  20. ---
  21. >             if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL)
  22.  
  23. and recompile.  Also, add the following line to the "tests" file:
  24.  
  25. [k]    ab    n    -    -
  26.  
  27. My thanks to Chris for finding this.
  28.  
  29.                 Henry Spencer @ U of Toronto Zoology
  30.                 {allegra,ihnp4,linus,decvax}!utzoo!henry
  31.  
  32.  
  33.