From feca88ede6dec816878832f2129fe85b211770e4 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 22 Oct 2004 15:36:35 +0000 Subject: 20513: fix tests of zero-length patterns trivial optimisation in jobs.c (unposted) --- Src/jobs.c | 4 ++-- Src/pattern.c | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'Src') diff --git a/Src/jobs.c b/Src/jobs.c index 9bb8bbbd7..ed97d2cef 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -565,9 +565,9 @@ printtime(struct timeval *real, child_times_t *ti, char *desc) #ifdef HAVE_GETRUSAGE user_time = ti->ru_utime.tv_sec + ti->ru_utime.tv_usec / 1000000.0; system_time = ti->ru_stime.tv_sec + ti->ru_stime.tv_usec / 1000000.0; - percent = 100.0 * (user_time + system_time) - / (real->tv_sec + real->tv_usec / 1000000.0); total_time = user_time + system_time; + percent = 100.0 * total_time + / (real->tv_sec + real->tv_usec / 1000000.0); #else set_clktck(); user_time = ti->ut / (double) clktck; diff --git a/Src/pattern.c b/Src/pattern.c index 04452187d..528c48d5e 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -399,7 +399,7 @@ patcompile(char *exp, int inflags, char **endexp) patendstr++; patendseglen--; patendstrlen--; - remnulargs(exp); + remnulargs(patparse); patglobflags = 0; } /* @@ -419,10 +419,20 @@ patcompile(char *exp, int inflags, char **endexp) || (!(patglobflags & ~GF_IGNCASE) && (patflags & PAT_FILE)) #endif ) + { + /* + * Waah! I wish I understood this. + * Empty metafied strings have an initial Nularg. + * This never corresponds to a real character in + * a glob pattern or string, so skip it. + */ + if (*exp == Nularg) + exp++; for (strp = exp; *strp && (!(patflags & PAT_FILE) || *strp != '/') && !itok(*strp); strp++) ; + } if (!strp || (*strp && *strp != '/')) { /* No, do normal compilation. */ strp = NULL; @@ -1010,6 +1020,9 @@ patcomppiece(int *flagp) /* Get length of string without metafication. */ nmeta = 0; + /* inherited from domatch, but why, exactly? */ + if (*str0 == Nularg) + str0++; for (ptr = str0; ptr < patparse; ptr++) { if (*ptr == Meta) { nmeta++; -- cgit 1.4.1