Regression: many tools does not recognize the -? option on macOS

In !1592 (merged) and !1608 (merged) many tools were adapted to GNU getopt. See e.g. !1592 (2c6420be) or !1608 (81852ca7).

macOS however, does not use GNU getopt, but BSD getopt where the optopt variable behaves slightly differently and the code prior the the changes mentioned above is the correct one. Therefore, the code needs to be different depending on which OS it it running on.

The tools that are currently failing the tools test on macOS are:

  • bcomps
  • ccomps
  • cluster
  • dijkstra
  • edgepaint
  • gc
  • gvcolor
  • gvmap
  • gvpack
  • mm2gv
  • nop
  • sccmap
  • tred

All of them may not have been working on macOS before, but at least some of them did.

This problem should be fixed before the next stable release.

Steps to reproduce

E.g. bcomps -?

Expected Behaviour

Show usage and exit status zero.

Actual Behaviour

Output:

bcomps: option -? unrecognized
Usage: bcomps [-stvx?] [-o<out template>] <files>
  -o - output file template
  -s - don't print components
  -t - emit block-cutpoint tree
  -v - verbose
  -x - external
  -? - print usage
If no files are specified, stdin is used

Exit status 1.

OS Version

macOS Catalina Version 10.15.7

Graphviz Version

dot - graphviz version 2.44.2~dev.20201016.1439 (20201016.1439)

Home-built from aa165722.

Edited by Magnus Jacobsson