`mpc_sepby1` takes a single fold function but this doesn't apply to the
whole list of entries. Instead it applies the fold twice,
one for `mpc_and` and another for `mpc_many`.
Introduce a new repeat repeat parser type MPC_TYPE_SEPBY1 that combines
the results and applies the fold once for all entries.
Deduplicates the results allocation logic used in MPC_TYPE_MANY
and MPC_TYPE_MANY1 on a `grow_results` function.
This will aid in implementing new repeat parser types. A new one is
neeeded for `sepby1` as discussed on
https://github.com/orangeduck/mpc/pull/165#discussion_r1292878771.
Make is supposed to only compile dependencies when they change but
`make check` always compiles them, making the test suite run slow.
```
$ make check
cc ... build/mpc.o
$ make check
cc ... build/mpc.o
```
The same occurs for other targets like `build/test-dynamic` and
`build/test-static`.
This happens because these targets have the `$(DIST)` directory as a
dependency, and directories always change whenever members are added,
removed or renamed.
Fix this by changing the `$(DIST)` directory dependency to a
`$(DIST)/.dirstamp` file.
Now `make check` compiles dependencies only once.
After running `make install`, pkg-config only finds mpc with sudo:
```
$ sudo pkg-config --list-all | grep mpc
mpc - Library for creating parser combinators
$ pkg-config --list-all | grep mpc
```
This is because the Makefile runs `install -d -m644`, which doesn't
include permission to access the `/usr/local/lib/pkgconfig` directory.
Fix this by changing the created directories mode to 645.
Otherwise, the 'prefix' variable would be left undefined:
$ pkg-config --cflags mpc
Variable 'prefix' not defined in '/gnu/store/...-profile/lib/pkgconfig/mpc.pc'
$ cat /gnu/store/...-profile/lib/pkgconfig/mpc.pc
libdir=${prefix}/lib
includedir=${prefix}/include
[...]
* Makefile (install): Install the templated pkg-config from the build
directory.
(all): Add the libs and $(DIST)/$(PROJ).pc targets.
The mpcf_freefold is documented in the README but currently not declared
in the header file. As such, adding the latter was probably just
forgotten at some point. This change adds the required function
prototype.