[201] in NetBSD-Development

home help back first fref pref prev next nref lref last post

here is the relevant code from zwgc/regexp.c

daemon@ATHENA.MIT.EDU (jtkohl@MIT.EDU)
Wed Nov 16 08:39:55 1994

From: jtkohl@MIT.EDU
Date: Wed, 16 Nov 1994 08:39:22 -0500
To: netbsd-dev@MIT.EDU

*** 1.4	1991/06/20 09:20:45
--- regexp.c	1994/07/17 20:49:56
***************
*** 5,11 ****
   *      Created by:     Marc Horowitz <marc@athena.mit.edu>
   *
   *      $Source: /mit/netbsd/athena/zephyr/zwgc/RCS/regexp.c,v $
!  *      $Author: jfc $
   *
   *      Copyright (c) 1989 by the Massachusetts Institute of Technology.
   *      For copying and distribution information, see the file
--- 5,11 ----
   *      Created by:     Marc Horowitz <marc@athena.mit.edu>
   *
   *      $Source: /mit/netbsd/athena/zephyr/zwgc/RCS/regexp.c,v $
!  *      $Author: jtkohl $
   *
   *      Copyright (c) 1989 by the Massachusetts Institute of Technology.
   *      For copying and distribution information, see the file
***************
*** 13,24 ****
   */
  
  #if (!defined(lint) && !defined(SABER))
! static char rcsid_regexp_c[] = "$Id: regexp.c,v 1.4 1991/06/20 09:20:45 jfc Exp $";
  #endif
  
  #include <stdio.h>
  #include "regexp.h"
  
  extern char *re_comp();
  extern int re_exec();
  
--- 13,53 ----
   */
  
  #if (!defined(lint) && !defined(SABER))
! static char rcsid_regexp_c[] = "$Id: regexp.c,v 1.5 1994/07/17 20:49:55 jtkohl Exp $";
  #endif
  
  #include <stdio.h>
  #include "regexp.h"
  
+ #ifdef POSIX_REGEXP
+ #include <sys/types.h>
+ #include <regex.h>
+ 
+ int ed_regexp_match_p(test_string, pattern)
+      string test_string;
+      string pattern;
+ {
+     regex_t RE;
+     int retval;
+     char errbuf[512];
+ 
+     if (retval = regcomp(&RE, pattern, REG_EXTENDED|REG_NOSUB)) {
+ 	regerror(retval, &RE, errbuf, sizeof(errbuf));
+ 	fprintf(stderr,"%s in regcomp %s\n",errbuf,pattern);
+ 	return(0);
+     }
+     retval = regexec(&RE, test_string, 0, NULL, 0);
+     if (retval  && retval != REG_NOMATCH) {
+ 	regerror(retval, &RE, errbuf, sizeof(errbuf));
+ 	fprintf(stderr,"%s in regexec %s\n",errbuf,pattern);
+ 	regfree(&RE);
+ 	return(0);
+     }
+     regfree(&RE);
+     return(retval == 0 ? 1 : 0);
+ }
+ 
+ #else
  extern char *re_comp();
  extern int re_exec();
  
***************
*** 40,45 ****
--- 69,75 ----
  
      return(exec_retval);
  }
+ #endif
  
  
  /*

home help back first fref pref prev next nref lref last post