Xref: utzoo comp.bugs.4bsd:1757 comp.unix.wizards:24187 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!magnus.ircc.ohio-state.edu!csn!news From: cdash@mumm.colorado.edu (Charles Shub) Newsgroups: comp.bugs.4bsd,comp.unix.wizards Subject: I think i'm having a problem with re_cmp and re_exec Message-ID: <1991Feb20.051351.970@csn.org> Date: 20 Feb 91 05:13:51 GMT Sender: news@csn.org (news) Organization: University of Colorado at Colorado Springs Lines: 83 Nntp-Posting-Host: mumm.colorado.edu Have I found a bug in re_cmp and re_exec? If so, is there a fix?? if not, what am I doing wrong please respond by mail as I do not subscribe to this group. The problem seems to be in matching files with an input of * I get a random match in this case. charlie shub cdash@boulder.Colorado.EDU -or- ..!{ucar|nbires}!boulder!cdash or even cdash@colospgs (BITNET) -or- (719) 593-3492 Execution output ------------------------------ bug m* enter a string >u* 'u*' 'u.*' 'moutgoing' found 1 ------------------------------ ^ ^ ^ | | ------- file matched by re_exec | -------------- string fed to re_comp ------------------- input string The directory has 42 entries including the following: bulgren csu moutgoing upe Source code below (culled from huge program, recompiled, and run) it is running on a microvax with 4.3 + nfs ------------------------------ #include #include #include #include main() { DIR *dirp; struct direct *dp; char com[256], lstr[256]; char *re_comp(), *ap, *lp; int found = 0; printf("enter a string >"); gets(com); ap = com; lp = lstr; while (*ap) { if(*ap == '*') { *lp++ = '.'; *lp++ = *ap++; } else { *lp++ = *ap++; } } *lp = '\0'; printf("'%s' '%s' ",com, lstr); if(ap = re_comp(lstr)) { printf("'%s' error %s",lp,ap); } else { int zz; dirp = opendir("."); while ((dp = readdir(dirp)) != NULL && !found) { if((zz = re_exec(dp->d_name)) < 0) { printf("re_exec error"); break; } else if (zz) { found = 1; printf(" '%s' ",dp->d_name); } } closedir(dirp); } printf(" found %d\n",found); } ------------------------------ -- charlie shub cdash@boulder.Colorado.EDU -or- ..!{ucar|nbires}!boulder!cdash or even cdash@colospgs (BITNET) -or- (719) 593-3492