Article View: gnu.utils.bug
Article #1021glob.c patch.
From: Hod Greeley
Date: Wed, 04 Nov 1992 18:31
Date: Wed, 04 Nov 1992 18:31
68 lines
2546 bytes
2546 bytes
Hi,
spoke a little too quickly. The closedir should done within the else
statement following the opendir. Here's a corrected patch.
*** /reef/hod/src/make-3.62/glob/glob.c Sat Oct 19 16:39:23 1991
--- glob.c Wed Nov 4 23:24:49 1992
***************
*** 456,482 ****
return GLOB_ABEND;
}
else
! while ((d = readdir(stream)) != NULL)
! if (REAL_DIR_ENTRY(d) &&
! fnmatch(pattern, d->d_name,
! (!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) |
! ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)) == 0)
! {
! struct globlink *new = (struct globlink *)
! __alloca(sizeof(struct globlink));
! size_t len = D_NAMLEN(d);
! new->name = (char *) malloc(len +
! ((flags & GLOB_MARK) ? 1 : 0) + 1);
! if (new->name == NULL)
! goto memory_error;
! memcpy((char *) new->name, d->d_name, len);
! if (flags & GLOB_MARK)
! new->name[len++] = '/';
! new->name[len] = '\0';
! new->next = names;
! names = new;
! ++nfound;
! }
}
if (nfound == 0 && (flags & GLOB_NOCHECK))
--- 456,485 ----
return GLOB_ABEND;
}
else
! {
! while ((d = readdir(stream)) != NULL)
! if (REAL_DIR_ENTRY(d) &&
! fnmatch(pattern, d->d_name,
! (!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) |
! ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)) == 0)
! {
! struct globlink *new = (struct globlink *)
! __alloca(sizeof(struct globlink));
! size_t len = D_NAMLEN(d);
! new->name = (char *) malloc(len +
! ((flags & GLOB_MARK) ? 1 : 0) + 1);
! if (new->name == NULL)
! goto memory_error;
! memcpy((char *) new->name, d->d_name, len);
! if (flags & GLOB_MARK)
! new->name[len++] = '/';
! new->name[len] = '\0';
! new->next = names;
! names = new;
! ++nfound;
! }
! closedir(stream);
! }
}
if (nfound == 0 && (flags & GLOB_NOCHECK))
Hod Greeley
hod@cucbs.chem.columbia.edu
Technical Details
Message-ID:
<199211050431.AA20937@cucbs.chem.columbia.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sun-barr!ames!saimiri.primate.wisc.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cucbs.chem.columbia.edu!hodShow Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sun-barr!ames!saimiri.primate.wisc.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cucbs.chem.columbia.edu!hod From: hod@cucbs.chem.columbia.edu (Hod Greeley) Subject: glob.c patch. Message-ID: <199211050431.AA20937@cucbs.chem.columbia.edu> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Wed, 4 Nov 1992 18:31:34 GMT Approved: bug-gnu-utils@prep.ai.mit.edu Lines: 69