summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/jobs.c4
-rw-r--r--Src/pattern.c15
2 files changed, 16 insertions, 3 deletions
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++;