tidy things up

This commit is contained in:
Kyryl Melekhin
2021-07-13 21:07:53 +00:00
parent 6ea4f0f7ed
commit a7ee926770
3 changed files with 7 additions and 6 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
a.out

8
pike.c
View File

@@ -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 <stdio.h>
#include <stdlib.h>
@@ -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: <regex> <str...> <str...> ...\n");
return 0;
}
int sz = re_sizecode(argv[1]) * sizeof(int);
printf("Precalculated size: %d\n", sz);
char code[sizeof(rcode)+sz];

View File

@@ -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}')