Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/ksh PR/52210: David H. Gutteridge: revert var pattern ha...



details:   https://anonhg.NetBSD.org/src/rev/ce0540aea6fd
branches:  trunk
changeset: 353384:ce0540aea6fd
user:      christos <christos%NetBSD.org@localhost>
date:      Wed May 03 00:41:34 2017 +0000

description:
PR/52210: David H. Gutteridge: revert var pattern handling.

diffstat:

 bin/ksh/misc.c |  27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diffs (88 lines):

diff -r 0eb103fd86c8 -r ce0540aea6fd bin/ksh/misc.c
--- a/bin/ksh/misc.c    Wed May 03 00:39:40 2017 +0000
+++ b/bin/ksh/misc.c    Wed May 03 00:41:34 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: misc.c,v 1.16 2017/04/30 17:34:29 christos Exp $       */
+/*     $NetBSD: misc.c,v 1.17 2017/05/03 00:41:34 christos Exp $       */
 
 /*
  * Miscellaneous functions
@@ -6,7 +6,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: misc.c,v 1.16 2017/04/30 17:34:29 christos Exp $");
+__RCSID("$NetBSD: misc.c,v 1.17 2017/05/03 00:41:34 christos Exp $");
 #endif
 
 
@@ -683,12 +683,11 @@
                  case 0x80|'+': /* matches one or more times */
                  case 0x80|'*': /* matches zero or more times */
                        if (!(prest = pat_scan(++p, pe, 0)))
-                               break;
-                       s--;
+                               return 0;
                        /* take care of zero matches */
                        if (p[-1] == (0x80 | '*')
                            && do_gmatch(s, se, prest, pe, isfile))
-                               continue;
+                               return 1;
                        for (psub = p; ; psub = pnext) {
                                pnext = pat_scan(psub, pe, 1);
                                for (srest = s; srest <= se; srest++) {
@@ -704,18 +703,17 @@
                                if (pnext == prest)
                                        break;
                        }
-                       break;
+                       return 0;
 
                  case 0x80|'?': /* matches zero or once */
                  case 0x80|'@': /* matches one of the patterns */
                  case 0x80|' ': /* simile for @ */
                        if (!(prest = pat_scan(++p, pe, 0)))
-                               break;
-                       s--;
+                               return 0;
                        /* Take care of zero matches */
                        if (p[-1] == (0x80 | '?')
                            && do_gmatch(s, se, prest, pe, isfile))
-                               continue;
+                               return 1;
                        for (psub = p; ; psub = pnext) {
                                pnext = pat_scan(psub, pe, 1);
                                srest = prest == pe ? se : s;
@@ -724,17 +722,16 @@
                                                      psub, pnext - 2, isfile)
                                            && do_gmatch(srest, se,
                                                         prest, pe, isfile))
-                                               continue;
+                                               return 1;
                                }
                                if (pnext == prest)
                                        break;
                        }
-                       break;
+                       return 0;
 
                  case 0x80|'!': /* matches none of the patterns */
                        if (!(prest = pat_scan(++p, pe, 0)))
-                               break;
-                       s--;
+                               return 0;
                        for (srest = s; srest <= se; srest++) {
                                int matched = 0;
 
@@ -751,9 +748,9 @@
                                }
                                if (!matched && do_gmatch(srest, se,
                                                          prest, pe, isfile))
-                                       continue;
+                                       return 1;
                        }
-                       break;
+                       return 0;
 
                  default:
                        if (sc != pc)



Home | Main Index | Thread Index | Old Index