Index: class.c ================================================================== --- class.c +++ class.c @@ -1155,15 +1155,16 @@ cl->codes[ptr++]=0; depth++; break; case OP_ELSE: if(!depth) ParseError("Premature end of subpattern\n"); - cl->codes[nest[depth-1]+1]=ptr; + cl->codes[nest[depth-1]+1]=ptr+1; cl->codes[ptr++]=OP_ELSE; cl->codes[ptr++]=cl->codes[nest[depth-1]]; cl->codes[nest[depth-1]]=OP_IF; cl->codes[ptr++]=0; + nest[depth-1]=ptr-2; break; case OP_THEN: if(!depth) ParseError("Premature end of subpattern\n"); cl->codes[nest[--depth]+1]=ptr; cl->codes[ptr++]=OP_THEN; Index: exec.c ================================================================== --- exec.c +++ exec.c @@ -1864,11 +1864,13 @@ if(main_options['t']) { printf("ptr=%d cpi=%d x=%d y=%d dir=%d obj=%lu ",ptr,cpi,x,y,d,(long)n); printf("[ptr=%d x=%d y=%d dir=%d]\n",cp[cpi].ptr,cp[cpi].x,cp[cpi].y,cp[cpi].dir); } break; - default: Throw("Unimplemented opcode in pattern"); + default: + fprintf(stderr,"Unrecognized opcode 0x%04X at 0x%04X in pattern\n",code[ptr-1],ptr-1); + Throw("Internal error: Unimplemented opcode in pattern"); } goto again; fail: if(!all) { if(vstackptrdepth) Throw("Stack underflow in pattern matching");