Skip to content

Commit

Permalink
Merge pull request #27 from fastly/sv/upstream-main
Browse files Browse the repository at this point in the history
Sync from upstream katef/libfsm main
  • Loading branch information
katef authored Oct 9, 2024
2 parents 3e3950b + 0961848 commit 8b53634
Show file tree
Hide file tree
Showing 317 changed files with 19,028 additions and 7,359 deletions.
68 changes: 34 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:

steps:
- name: Cache checkout
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-checkout
with:
path: ${{ env.wc }}
key: checkout-${{ github.sha }}

- name: Checkout
if: steps.cache-checkout.outputs.cache-hit != 'true'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
path: ${{ env.wc }}
Expand All @@ -49,7 +49,7 @@ jobs:

steps:
- name: Cache PCRE suite
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-pcre
with:
path: pcre-suite/${{ env.pcre2 }}
Expand All @@ -67,15 +67,15 @@ jobs:
chmod -R ug-w pcre-suite
- name: Cache converted PCRE tests
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-cvtpcre
with:
path: ${{ env.cvtpcre }}
key: cvtpcre-bmake-ubuntu-gcc-DEBUG-AUSAN-${{ github.sha }}-${{ env.pcre2 }}

- name: Fetch build
if: steps.cache-cvtpcre.outputs.cache-hit != 'true'
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-build
with:
path: ${{ env.build }}
Expand Down Expand Up @@ -155,14 +155,14 @@ jobs:

steps:
- name: Fetch checkout
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-checkout
with:
path: ${{ env.wc }}
key: checkout-${{ github.sha }}

- name: Cache build
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-build
with:
path: ${{ env.build }}
Expand All @@ -185,7 +185,7 @@ jobs:
- name: Get number of CPU cores
if: steps.cache-build.outputs.cache-hit != 'true'
uses: SimenB/github-actions-cpu-cores@v1
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores

- name: Make
Expand Down Expand Up @@ -233,15 +233,15 @@ jobs:

steps:
- name: Fetch checkout
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-checkout
with:
path: ${{ env.wc }}
key: checkout-${{ github.sha }}

# An arbitary build.
- name: Fetch build
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-build
with:
path: ${{ env.build }}
Expand Down Expand Up @@ -273,7 +273,7 @@ jobs:
${{ matrix.cc }} --version
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores

- name: Make
Expand All @@ -292,7 +292,7 @@ jobs:
# kmkf duplicate install targets, it's not interesting for libfsm's CI,
# so I'm retrying on error here. # github.com/katef/kmkf/issues/14
- name: Install
uses: nick-fields/retry@v2.8.3
uses: nick-fields/retry@v3
with:
timeout_seconds: 10 # required, but not a problem for the kmkf bug
max_attempts: 3
Expand Down Expand Up @@ -322,7 +322,7 @@ jobs:

steps:
- name: Fetch checkout
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-checkout
with:
path: ${{ env.wc }}
Expand All @@ -344,14 +344,14 @@ jobs:
${{ matrix.cc }} --version
- name: Fetch build
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-build
with:
path: ${{ env.build }}
key: build-${{ matrix.make }}-${{ matrix.os }}-${{ matrix.cc }}-${{ matrix.debug }}-${{ matrix.san }}-${{ github.sha }}

- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores

- name: Test
Expand Down Expand Up @@ -381,7 +381,7 @@ jobs:

steps:
- name: Fetch checkout
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-checkout
with:
path: ${{ env.wc }}
Expand All @@ -403,7 +403,7 @@ jobs:
${{ matrix.cc }} --version
- name: Fetch build
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-build
with:
path: ${{ env.build }}
Expand All @@ -418,7 +418,7 @@ jobs:
# still run fuzzing, just from empty, and do not save their seeds.
- name: Restore seeds (mode ${{ matrix.mode }})
if: github.repository == 'katef/libfsm'
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
id: cache-seeds
with:
path: ${{ env.seeds }}-${{ matrix.mode }}
Expand All @@ -429,7 +429,7 @@ jobs:
run: mkdir -p ${{ env.seeds }}-${{ matrix.mode }}

- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores

- name: Fuzz
Expand All @@ -455,15 +455,15 @@ jobs:
# the same seeds for a given bug.
# The explicit cache/restore and cache/save actions are just for that.
- name: Save seeds (mode ${{ matrix.mode }}-${{ matrix.debug }})
uses: actions/cache/save@v3
uses: actions/cache/save@v4
if: always()
with:
path: ${{ env.seeds }}-${{ matrix.mode }}
key: ${{ steps.cache-seeds.outputs.cache-primary-key }}

# nothing to do with the caching, I'm uploading the seeds so a developer can grab them to fuzz locally
- name: Upload seeds (mode ${{ matrix.mode }}-${{ matrix.debug }})
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: seeds-${{ matrix.mode }}-${{ matrix.debug }}
path: ${{ env.seeds }}-${{ matrix.mode }}
Expand All @@ -481,7 +481,7 @@ jobs:
cc: [ clang, gcc ]
make: [ bmake ]
debug: [ DEBUG, RELEASE ] # RELEASE=1 is a no-op
lang: [ "vm -x v1", "vm -x v2", asm, c, rust, vmc, vmops, go, goasm ]
lang: [ "vm -x v1", "vm -x v2", asm, c, rust, vmc, vmops, go, goasm, llvm ]
exclude:
- os: macos
cc: gcc # it's clang anyway
Expand Down Expand Up @@ -513,14 +513,14 @@ jobs:
go version
- name: Fetch build
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-build
with:
path: ${{ env.build }}
key: build-${{ matrix.make }}-${{ matrix.os }}-${{ matrix.cc }}-${{ matrix.debug }}-${{ matrix.san }}-${{ github.sha }}

- name: Fetch converted PCRE tests
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-cvtpcre
with:
path: ${{ env.cvtpcre }}
Expand All @@ -539,7 +539,7 @@ jobs:

steps:
- name: Cache docs
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-docs
with:
path: ${{ env.build }}
Expand All @@ -554,15 +554,15 @@ jobs:
- name: Fetch checkout
if: steps.cache-docs.outputs.cache-hit != 'true'
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-checkout
with:
path: ${{ env.wc }}
key: checkout-${{ github.sha }}

- name: Get number of CPU cores
if: steps.cache-docs.outputs.cache-hit != 'true'
uses: SimenB/github-actions-cpu-cores@v1
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores

- name: Test docs
Expand Down Expand Up @@ -594,7 +594,7 @@ jobs:

steps:
- name: Cache prefix
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-prefix
with:
path: ${{ env.prefix }}
Expand All @@ -608,31 +608,31 @@ jobs:
- name: Fetch checkout
if: steps.cache-prefix.outputs.cache-hit != 'true'
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-checkout
with:
path: ${{ env.wc }}
key: checkout-${{ github.sha }}

- name: Fetch build
if: steps.cache-prefix.outputs.cache-hit != 'true'
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-build
with:
path: ${{ env.build }}
key: build-${{ env.make }}-${{ env.os }}-${{ env.cc }}-${{ env.debug }}-${{ env.san }}-${{ github.sha }}

- name: Fetch docs
if: steps.cache-prefix.outputs.cache-hit != 'true'
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-docs
with:
path: ${{ env.build }}
key: docs-${{ github.sha }}

- name: Get number of CPU cores
if: steps.cache-prefix.outputs.cache-hit != 'true'
uses: SimenB/github-actions-cpu-cores@v1
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores

- name: Install
Expand Down Expand Up @@ -668,7 +668,7 @@ jobs:
fpm -v
- name: Fetch prefix
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-prefix
with:
path: ${{ env.prefix }}
Expand All @@ -691,7 +691,7 @@ jobs:
printf "package_file=%s\n" $(basename pkg/*) >> $GITHUB_ENV
- name: Upload
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.package_file }}
path: pkg/${{ env.package_file }}
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ PKG += libtheft
.if !defined(NODOC)
SUBDIR += man/fsm.1
SUBDIR += man/re.1
SUBDIR += man/rx.1
SUBDIR += man/lx.1
SUBDIR += man/fsm_print.3
SUBDIR += man/libfsm.3
Expand Down Expand Up @@ -101,6 +102,7 @@ SUBDIR += src/libre/print
SUBDIR += src/libre
SUBDIR += src/fsm
SUBDIR += src/re
SUBDIR += src/rx
SUBDIR += src/retest
SUBDIR += src/lx/print
SUBDIR += src/lx
Expand All @@ -114,9 +116,11 @@ SUBDIR += tests/intersect
SUBDIR += tests/eclosure
SUBDIR += tests/equals
SUBDIR += tests/subtract
SUBDIR += tests/detect_required
SUBDIR += tests/determinise
SUBDIR += tests/endids
SUBDIR += tests/epsilons
SUBDIR += tests/fsm
SUBDIR += tests/glob
SUBDIR += tests/like
SUBDIR += tests/literal
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ You get:
* libfsm — library for manipulating FSM (NFA and DFA)
* libre — library for compiling regular expressions to NFA
* fsm(1) — command line interface for FSM
* re(1) — command line interface for executing regular expressions
* re(1) — command line interface for regular expressions
* rx(1) — command line interface for compiling sets of regular expressions
* lx(1) — lexer generator

lx is an attempt to produce a simple, expressive, and unobtrusive
Expand Down
3 changes: 3 additions & 0 deletions examples/bm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ pcre: pcre.c
libfsm: libfsm.c
gcc -o libfsm -O3 -Wall -std=c99 ${BM_CFLAGS} libfsm.c -I ../../include ../../build/lib/libre.a ../../build/lib/libfsm.a

clean:
rm -f pcre libfsm

4 changes: 2 additions & 2 deletions examples/bm/libfsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ main(int argc, char *argv[])
opt.io = FSM_IO_STR;

p = argv[0];
fsm = re_comp(RE_PCRE, fsm_sgetc, &p, &opt, flags, &e);
fsm = re_comp(RE_PCRE, fsm_sgetc, &p, NULL, flags, &e);
if (fsm == NULL) {
re_perror(RE_LITERAL, &e, NULL, s);
return 1;
Expand All @@ -80,7 +80,7 @@ main(int argc, char *argv[])
printf("#include <time.h>\n");
printf("\n");

fsm_print_c(stdout, fsm);
fsm_print(stdout, fsm, &opt, NULL, FSM_PRINT_C);

printf("int\n");
printf("main(void)\n");
Expand Down
4 changes: 2 additions & 2 deletions examples/glob/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ match(const struct fsm *fsm, const char *s)
assert(fsm_all(fsm, fsm_isdfa));
assert(s != NULL);

if (1 != fsm_exec(fsm, fsm_sgetc, &s, &state)) {
if (1 != fsm_exec(fsm, fsm_sgetc, &s, &state, NULL)) {
return 0;
}

Expand Down Expand Up @@ -196,7 +196,7 @@ main(int argc, char *argv[])
}

if (!quiet) {
fsm_print_fsm(stdout, fsm);
fsm_print(stdout, fsm, NULL, NULL, FSM_PRINT_FSM);
}

matched = match(fsm, argv[1]);
Expand Down
Loading

0 comments on commit 8b53634

Please sign in to comment.