Simplify the standard filter stepper.
authormdw <mdw>
Sat, 5 Mar 2005 16:47:22 +0000 (16:47 +0000)
committermdw <mdw>
Sat, 5 Mar 2005 16:47:22 +0000 (16:47 +0000)
pgen.c

diff --git a/pgen.c b/pgen.c
index e569647..86e31c1 100644 (file)
--- a/pgen.c
+++ b/pgen.c
@@ -49,7 +49,7 @@
 int pgen_filter(int rq, pgen_event *ev, void *p)
 {
   pgen_filterctx *f = p;
-  int rc = PGEN_ABORT;
+  int rc = PGEN_FAIL;
 
   switch (rq) {
     case PGEN_BEGIN:
@@ -58,16 +58,17 @@ int pgen_filter(int rq, pgen_event *ev, void *p)
       break;
     case PGEN_TRY:
       mp_drop(ev->m);
-      if (!((f->step | f->f.m->v[0]) & 1))
-       rc = pfilt_step(&f->f, 1);
-      else
-       rc = pfilt_step(&f->f, f->step);
       break;
     case PGEN_DONE:
       pfilt_destroy(&f->f);
       return (PGEN_DONE);
+    default:
+      rc = PGEN_ABORT;
+      break;
   }
        
+  if (rc == PGEN_FAIL && !((f->step | f->f.m->v[0]) & 1))
+    rc = pfilt_step(&f->f, 1);
   while (rc == PGEN_FAIL)
     rc = pfilt_step(&f->f, f->step);
   ev->m = MP_COPY(f->f.m);