diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cba7efc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +a.out diff --git a/pike.c b/pike.c index 6900e9d..7eba58f 100644 --- a/pike.c +++ b/pike.c @@ -1,6 +1,5 @@ // Copyright 2007-2009 Russ Cox. All Rights Reserved. // Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. #include #include @@ -201,7 +200,7 @@ void re_dumpcode(rcode *prog) printf("any\n"); break; case CLASS: - case CLASSNOT: { + case CLASSNOT:; int num = code[pc]; printf("class%s %d", (code[pc - 1] == CLASSNOT ? "not" : ""), num); pc++; @@ -211,7 +210,6 @@ void re_dumpcode(rcode *prog) } printf("\n"); break; - } case NAMEDCLASS: printf("namedclass %c\n", code[pc++]); break; @@ -632,6 +630,10 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp) int main(int argc, char *argv[]) { + if (argc < 2) { + printf("usage: ...\n"); + return 0; + } int sz = re_sizecode(argv[1]) * sizeof(int); printf("Precalculated size: %d\n", sz); char code[sizeof(rcode)+sz]; diff --git a/test.sh b/test.sh index 9954700..161b860 100755 --- a/test.sh +++ b/test.sh @@ -1,3 +1,4 @@ +#!/bin/sh regex="\ abc @@ -38,7 +39,6 @@ a{5} (abc+){5}|[0-9]{1,} b[^c]* " - input="\ abcdef abcdef @@ -78,7 +78,6 @@ abcabcabcabcabcabchsdfhsdh 62374623 djfjgjsdfjbshdhfhshd " - expect="\ (0,3) (2,5) @@ -119,7 +118,6 @@ expect="\ (10,20) (0,0) " - c=1 echo "$regex" | tr '\n' | while read re; do inp=$(echo "$input" | awk -v c=$c 'BEGIN{ RS = "" ; FS = "\n" }{print $c}')