rpms/cernlib/FC-4 032-use-regcomp-not-re_comp,NONE,1.1
Patrice Dumas (pertusus)
fedora-extras-commits at redhat.com
Fri Nov 18 18:01:15 UTC 2005
Author: pertusus
Update of /cvs/extras/rpms/cernlib/FC-4
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29423
Added Files:
032-use-regcomp-not-re_comp
Log Message:
add the 032-use-regcomp-not-re_comp patch file
--- NEW FILE 032-use-regcomp-not-re_comp ---
--- src/packlib/kuip/code_motif/kmfile.c.old 1996-03-08 10:33:08.000000000 -0500
+++ src/packlib/kuip/code_motif/kmfile.c 2003-08-10 12:24:15.000000000 -0400
@@ -18,6 +18,11 @@
#include "kuip/mkutfu.h"
#include "mkutda.h"
+#ifdef MATCH_REGCOMP
+#include <sys/types.h>
+#include <regex.h> /* for regex_t */
+#endif
+
static char **ftype_list = NULL;
static char **class_list = NULL;
static char **stext_list = NULL;
@@ -92,8 +97,12 @@
DIR *dirp;
struct dirent *dp;
char *pattern;
+#ifdef MATCH_REGCOMP
+ regex_t *re = (regex_t *)malloc( sizeof(regex_t) );
+#else
char *re;
#endif
+#endif
struct stat filestatus;
ndlist = 0;
@@ -221,11 +230,15 @@
}
}
pattern = mstrcat( pattern, "$" );
+#ifdef MATCH_REGCOMP
+ regcomp( re, pattern, REG_NEWLINE );
+#else
#ifdef MATCH_RE_COMP
re = re_comp( pattern );
#else
re = regcmp( pattern, NULL );
#endif
+#endif
free( pattern );
/*
@@ -260,12 +273,16 @@
}
else if( (filestatus.st_mode & S_IFMT) == S_IFREG ) {
/* regular file: match name against regexp */
+#ifdef MATCH_REGCOMP
+ int match = (regexec( re, dp->d_name, 0, NULL, 0 ) == 0);
+#else
#ifdef MATCH_RE_COMP
int match = re_exec( dp->d_name );
#else
int match = (regex( re, dp->d_name ) != NULL);
#endif
+#endif
- if( match == 1 ) {
+ if( match ) {
filelist = (char**)realloc( (char*)filelist,
(nflist+1) * sizeof(char*) );
filelist[nflist] = strdup( dp->d_name );
@@ -276,6 +293,9 @@
closedir( dirp );
}
+#ifdef MATCH_REGCOMP
+ regfree( re );
+#endif
#ifndef MATCH_RE_COMP
free( re );
#endif
More information about the scm-commits
mailing list