mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Example code: bugfix of KW scan.
This commit is contained in:
parent
433d2f386a
commit
e0c489f98f
@ -123,6 +123,7 @@
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <climits>
|
||||
#include <unistd.h>
|
||||
|
||||
// We use the BSD primitives throughout as they exist on both BSD and Linux.
|
||||
@ -657,6 +658,10 @@ int main(int argc, char **argv) {
|
||||
break;
|
||||
case 'n':
|
||||
repeatCount = atoi(optarg);
|
||||
if (repeatCount <= 0 || repeatCount > UINT_MAX) {
|
||||
cerr << "Invalid repeatCount." << endl;
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <climits>
|
||||
#include <unistd.h>
|
||||
|
||||
// We use the BSD primitives throughout as they exist on both BSD and Linux.
|
||||
@ -489,6 +490,10 @@ int main(int argc, char **argv) {
|
||||
|
||||
// Streaming mode scans.
|
||||
double secsStreamingScan = 0.0, secsStreamingOpenClose = 0.0;
|
||||
if (repeatCount <= 0 || repeatCount > UINT_MAX) {
|
||||
cerr << "Invalid repeatCount." << endl;
|
||||
exit(-1);
|
||||
}
|
||||
for (unsigned int i = 0; i < repeatCount; i++) {
|
||||
// Open streams.
|
||||
clock.start();
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <hs.h>
|
||||
|
||||
@ -152,6 +153,15 @@ int main(int argc, char *argv[]) {
|
||||
char *pattern = argv[1];
|
||||
char *inputFN = argv[2];
|
||||
|
||||
if (access(inputFN, F_OK) != 0) {
|
||||
fprintf(stderr, "ERROR: file doesn't exist.\n");
|
||||
return -1;
|
||||
}
|
||||
if (access(inputFN, R_OK) != 0) {
|
||||
fprintf(stderr, "ERROR: can't be read.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* First, we attempt to compile the pattern provided on the command line.
|
||||
* We assume 'DOTALL' semantics, meaning that the '.' meta-character will
|
||||
* match newline characters. The compiler will analyse the given pattern and
|
||||
|
Loading…
x
Reference in New Issue
Block a user