~mcf/cproc

driver: Discard unused inputs before complaining about having too many v2 PROPOSED

Lassi Pulkkinen: 2
 driver: Discard unused inputs before complaining about having too many
 driver: Ignore -pedantic-errors

 3 files changed, 13 insertions(+), 6 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~mcf/cproc/patches/52353/mbox | git am -3
Learn more about email & git

[PATCH v2 1/2] driver: Discard unused inputs before complaining about having too many Export this patch

Fixes e.g. cproc -lm -S a.c -o a.
---
v2: Dumb mistake in the commit message - the bug needs an explicit
output.

 driver.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/driver.c b/driver.c
index 2ead711..255903a 100644
--- a/driver.c
+++ b/driver.c
@@ -564,6 +564,16 @@ main(int argc, char *argv[])
		stages[i].cmdbase = stages[i].cmd.len;
	if (inputs.len == 0)
		usage(NULL);
	i = 0;
	arrayforeach (&inputs, input) {
		/* discard the input if it doesn't participate in the last stage */
		if (!(input->stages & 1 << last))
			continue;
		/* only run up through the last stage */
		input->stages &= (1 << last + 1) - 1;
		((struct input *)inputs.val)[i++] = *input;
	}
	inputs.len = i * sizeof(*input);
	if (output) {
		if (strcmp(output, "-") == 0) {
			if (last >= ASSEMBLE)
@@ -573,11 +583,6 @@ main(int argc, char *argv[])
		}
	}
	arrayforeach (&inputs, input) {
		/* ignore the input if it doesn't participate in the last stage */
		if (!(input->stages & 1 << last))
			continue;
		/* only run up through the last stage */
		input->stages &= (1 << last + 1) - 1;
		buildobj(input, output);
	}
	if (last == LINK) {
-- 
2.45.0

[PATCH v2 2/2] driver: Ignore -pedantic-errors Export this patch

---
 cproc.1  | 2 +-
 driver.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/cproc.1 b/cproc.1
index 83e9fec..f3618c7 100644
--- a/cproc.1
+++ b/cproc.1
@@ -115,7 +115,7 @@ Do not search default compiler include paths when compiling.
.It Fl pthread
This is a short hand of
.Fl lpthread .
.It Fl g , Fl O , Fl pipe , Fl pedantic
.It Fl g , Fl O , Fl pipe , Fl pedantic , Fl pedantic-errors
These options are available for compatibility with most common compilers but
are currently ineffective.
.El
diff --git a/driver.c b/driver.c
index 255903a..853c20e 100644
--- a/driver.c
+++ b/driver.c
@@ -445,6 +445,8 @@ main(int argc, char *argv[])
			arrayaddptr(&stages[PREPROCESS].cmd, arg);
		} else if (strcmp(arg, "-pedantic") == 0) {
			/* ignore */
		} else if (strcmp(arg, "-pedantic-errors") == 0) {
			/* ignore */
		} else if (strcmp(arg, "-pthread") == 0) {
			arrayaddptr(&stages[LINK].cmd, "-l");
			arrayaddptr(&stages[LINK].cmd, "pthread");
-- 
2.45.0