Bug 7617

Summary: spamc cannot be build on Windows
Product: Spamassassin Reporter: Martin Puppe <puppe>
Component: spamc/spamdAssignee: SpamAssassin Developer Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: kmcgrail, puppe
Priority: P2    
Version: 3.4 SVN branch   
Target Milestone: Undefined   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments: Proposed patch

Description Martin Puppe 2018-09-06 11:19:29 UTC
Building spamc currently fails on Windows. This is caused by two issues:

1. There is a subtle bug in spamc/Makefile.win (see also bug #7393).
2. spamc/getopt.c is not POSIX-compliant.

Regarding 1.: The first line of the target for spamc/spamc.exe changes the working directory. However, dmake (installed with Strawberry Perl 5.24) and GNU make (gmake, installed with Strawberry Perl 5.28) spawn a sub-shell for each command [^1][^2]. The change of directory thus only affects the sub-shell and is "forgotten" immediately afterwards.

Regarding 2.: spamc/getopt.c uses function err from err.h, which is not part of the POSIX standard [^3], and thus it is not availabe on Windows, neither natively nor in MinGW.

I have fixes for these issues mostly ready. I will submit a patch, once I have verified that no tests are negatively affected by this.

[^1]: https://www.openoffice.org/tools/dmake/dmake_4.11.html, see section MAKING TARGETS
[^2]: https://www.gnu.org/software/make/manual/html_node/Execution.html#Execution
[^3]: "These functions are nonstandard BSD extensions." https://man.cx/err
Comment 1 Martin Puppe 2018-09-06 12:57:33 UTC
Created attachment 5595 [details]
Proposed patch

Here is the proposed patch. Both fixes are relatively straight-forward. I have tried to replicate the behavior of err. The new implementation is mostly equivalent with one exception. Instead of "the last component of the program name" [^1], my implementation prints argv[0]. Is that acceptable?

[^1]: http://man7.org/linux/man-pages/man3/err.3.html
Comment 2 Kevin A. McGrail 2018-09-17 11:14:54 UTC
I don't have any concern on an error message using argv before an exit.

3.4:
Committed revision 1841065.
trunk:
Committed revision 1841066.