From 32f6cb10bcd0dc1a5ac3e1b21b6915eefa155841 Mon Sep 17 00:00:00 2001 From: erg Date: Fri, 8 Jan 2010 21:28:39 +0000 Subject: [PATCH] Tweak getopt to handle -? correctly on various architectures --- cmd/tools/Makefile.am | 8 +++++++- cmd/tools/acyclic.c | 4 ++-- cmd/tools/bcomps.c | 3 ++- cmd/tools/ccomps.c | 3 ++- cmd/tools/cvtgxl.c | 3 ++- cmd/tools/dijkstra.c | 3 ++- cmd/tools/gc.c | 3 ++- cmd/tools/gml2gv.c | 3 ++- cmd/tools/gvcolor.c | 3 ++- cmd/tools/gvgen.c | 3 ++- cmd/tools/gvpack.c | 3 ++- cmd/tools/matrix_market.c | 3 ++- cmd/tools/mm2gv.c | 3 ++- cmd/tools/nop.c | 3 ++- cmd/tools/sccmap.c | 3 ++- cmd/tools/tred.c | 3 ++- cmd/tools/unflatten.c | 4 ++-- 17 files changed, 39 insertions(+), 19 deletions(-) diff --git a/cmd/tools/Makefile.am b/cmd/tools/Makefile.am index e3c55359c..cadcdb18f 100644 --- a/cmd/tools/Makefile.am +++ b/cmd/tools/Makefile.am @@ -19,7 +19,7 @@ pdfdir = $(pkgdatadir)/doc/pdf noinst_HEADERS = colortbl.h convert.h mmio.h matrix_market.h \ graph_generator.h gml2gv.h gmlparse.h bin_PROGRAMS = gc gvcolor gxl2gv acyclic nop ccomps sccmap tred \ - unflatten gvpack dijkstra bcomps mm2gv gvgen gml2gv + unflatten gvpack dijkstra bcomps mm2gv gvgen gml2gv gv2gml man_MANS = gc.1 gvcolor.1 gxl2gv.1 acyclic.1 nop.1 ccomps.1 sccmap.1 \ tred.1 unflatten.1 gvpack.1 dijkstra.1 bcomps.1 mm2gv.1 gvgen.1 gml2gv.1 pdf_DATA = gc.1.pdf gvcolor.1.pdf gxl2gv.1.pdf acyclic.1.pdf \ @@ -180,6 +180,12 @@ gml2gv_LDADD = \ gml2gv.1.pdf: gml2gv.1 - @GROFF@ -Tps -man gml2gv.1 | @PS2PDF@ - - >gml2gv.1.pdf +gv2gml_SOURCES = gv2gml.c + +gv2gml_LDADD = \ + $(top_builddir)/lib/ingraphs/libingraphs_C.la \ + $(top_builddir)/lib/cgraph/libcgraph.la + dijkstra_SOURCES = dijkstra.c dijkstra_LDADD = \ diff --git a/cmd/tools/acyclic.c b/cmd/tools/acyclic.c index 0f1d29dd9..3d3493a14 100644 --- a/cmd/tools/acyclic.c +++ b/cmd/tools/acyclic.c @@ -138,8 +138,8 @@ static void init(int argc, char *argv[]) int c; cmd = argv[0]; - - while ((c = getopt(argc, argv, ":vno:?")) != -1) + opterr = 0; + while ((c = getopt(argc, argv, ":vno:")) != -1) switch (c) { case 'o': outFile = openFile(optarg, "w"); diff --git a/cmd/tools/bcomps.c b/cmd/tools/bcomps.c index e73c5fc57..26e15393a 100644 --- a/cmd/tools/bcomps.c +++ b/cmd/tools/bcomps.c @@ -340,7 +340,8 @@ static void init(int argc, char *argv[]) { int c; - while ((c = getopt(argc, argv, ":o:xstv?")) != -1) { + opterr = 0; + while ((c = getopt(argc, argv, ":o:xstv")) != -1) { switch (c) { case 'o': outfile = optarg; diff --git a/cmd/tools/ccomps.c b/cmd/tools/ccomps.c index 2663d18bd..7910ed1ed 100644 --- a/cmd/tools/ccomps.c +++ b/cmd/tools/ccomps.c @@ -132,7 +132,8 @@ static void init(int argc, char *argv[]) { int c; - while ((c = getopt(argc, argv, ":zo:xCX:nsv?")) != -1) { + opterr = 0; + while ((c = getopt(argc, argv, ":zo:xCX:nsv")) != -1) { switch (c) { case 'o': outfile = optarg; diff --git a/cmd/tools/cvtgxl.c b/cmd/tools/cvtgxl.c index 13bf7fba7..fd62b30a0 100644 --- a/cmd/tools/cvtgxl.c +++ b/cmd/tools/cvtgxl.c @@ -145,7 +145,8 @@ static void initargs(int argc, char **argv) int c; CmdName = cmdName(argv[0]); - while ((c = getopt(argc, argv, ":gdo:?")) != -1) { + opterr = 0; + while ((c = getopt(argc, argv, ":gdo:")) != -1) { switch (c) { case 'd': act = ToGV; diff --git a/cmd/tools/dijkstra.c b/cmd/tools/dijkstra.c index ed681fe93..e87352b84 100644 --- a/cmd/tools/dijkstra.c +++ b/cmd/tools/dijkstra.c @@ -246,7 +246,8 @@ static void init(int argc, char *argv[]) int i, j, c; CmdName = argv[0]; - while ((c = getopt(argc, argv, ":ap?")) != -1) { + opterr = 0; + while ((c = getopt(argc, argv, ":ap")) != -1) { switch (c) { case 'a': setall = 1; diff --git a/cmd/tools/gc.c b/cmd/tools/gc.c index c69e515cd..749035e63 100644 --- a/cmd/tools/gc.c +++ b/cmd/tools/gc.c @@ -94,7 +94,8 @@ static void init(int argc, char *argv[]) { unsigned int c; - while ((c = getopt(argc, argv, ":necCaDUrsv?")) != -1) { + opterr = 0; + while ((c = getopt(argc, argv, ":necCaDUrsv")) != -1) { switch (c) { case 'e': flags |= EDGES; diff --git a/cmd/tools/gml2gv.c b/cmd/tools/gml2gv.c index 813816680..f7466e7e0 100644 --- a/cmd/tools/gml2gv.c +++ b/cmd/tools/gml2gv.c @@ -106,7 +106,8 @@ static void initargs(int argc, char **argv) int c; CmdName = cmdName(argv[0]); - while ((c = getopt(argc, argv, ":gdo:?")) != -1) { + opterr = 0; + while ((c = getopt(argc, argv, ":gdo:")) != -1) { switch (c) { case 'o': outFile = openFile(optarg, "w"); diff --git a/cmd/tools/gvcolor.c b/cmd/tools/gvcolor.c index 1a442aa0a..38f58951e 100644 --- a/cmd/tools/gvcolor.c +++ b/cmd/tools/gvcolor.c @@ -96,7 +96,8 @@ static void init(int argc, char *argv[]) { int c; - while ((c = getopt(argc, argv, ":?")) != -1) { + opterr = 0; + while ((c = getopt(argc, argv, ":")) != -1) { switch (c) { case '?': if (optopt == '?') diff --git a/cmd/tools/gvgen.c b/cmd/tools/gvgen.c index 73b497f9d..0a4bafaa3 100644 --- a/cmd/tools/gvgen.c +++ b/cmd/tools/gvgen.c @@ -175,7 +175,7 @@ static char* setFold(char *s, opts_t* opts) return next; } -static char *optList = ":c:C:dg:G:h:k:b:o:p:s:S:t:T:Vw:?"; +static char *optList = ":c:C:dg:G:h:k:b:o:p:s:S:t:T:Vw:"; static GraphType init(int argc, char *argv[], opts_t* opts) { @@ -183,6 +183,7 @@ static GraphType init(int argc, char *argv[], opts_t* opts) GraphType graphType = unknown; cmd = argv[0]; + opterr = 0; while ((c = getopt(argc, argv, optList)) != -1) { switch (c) { case 'c': diff --git a/cmd/tools/gvpack.c b/cmd/tools/gvpack.c index 0e6b0729f..4c45374df 100644 --- a/cmd/tools/gvpack.c +++ b/cmd/tools/gvpack.c @@ -194,7 +194,8 @@ static void init(int argc, char *argv[], pack_info* pinfo) pinfo->doSplines = TRUE; /* Use edges in packing */ pinfo->fixed = 0; - while ((c = getopt(argc, argv, ":na:gvum:o:G:?")) != -1) { + opterr = 0; + while ((c = getopt(argc, argv, ":na:gvum:o:G:")) != -1) { switch (c) { case 'a': len = strlen(optarg) + 2; diff --git a/cmd/tools/matrix_market.c b/cmd/tools/matrix_market.c index d96dc3804..b9a8f37e2 100644 --- a/cmd/tools/matrix_market.c +++ b/cmd/tools/matrix_market.c @@ -17,7 +17,8 @@ #include "SparseMatrix.h" #include "mmio.h" #include "matrix_market.h" -#include "render.h" +#include "memory.h" +#include "assert.h" #define MALLOC gmalloc #define REALLOC grealloc #define FREE free diff --git a/cmd/tools/mm2gv.c b/cmd/tools/mm2gv.c index 762ac67d6..60d51eb8c 100644 --- a/cmd/tools/mm2gv.c +++ b/cmd/tools/mm2gv.c @@ -385,7 +385,8 @@ static void init(int argc, char **argv, parms_t* p) int c; cmd = argv[0]; - while ((c = getopt(argc, argv, ":o:u?")) != -1) { + opterr = 0; + while ((c = getopt(argc, argv, ":o:u")) != -1) { switch (c) { case 'o': p->outf = openF (optarg, "w"); diff --git a/cmd/tools/nop.c b/cmd/tools/nop.c index 67f62f0ac..66c7433ae 100644 --- a/cmd/tools/nop.c +++ b/cmd/tools/nop.c @@ -50,7 +50,8 @@ static void init(int argc, char *argv[]) { int c; - while ((c = getopt(argc, argv, ":p?")) != -1) { + opterr = 0; + while ((c = getopt(argc, argv, ":p")) != -1) { switch (c) { case 'p': chkOnly = 1; diff --git a/cmd/tools/sccmap.c b/cmd/tools/sccmap.c index 562051450..0980e845c 100644 --- a/cmd/tools/sccmap.c +++ b/cmd/tools/sccmap.c @@ -347,7 +347,8 @@ static void scanArgs(int argc, char **argv) int c; CmdName = argv[0]; - while ((c = getopt(argc, argv, ":o:sdvS?")) != EOF) { + opterr = 0; + while ((c = getopt(argc, argv, ":o:sdvS")) != EOF) { switch (c) { case 's': StatsOnly = 1; diff --git a/cmd/tools/tred.c b/cmd/tools/tred.c index cf1d0140e..5c149debb 100644 --- a/cmd/tools/tred.c +++ b/cmd/tools/tred.c @@ -103,7 +103,8 @@ static void init(int argc, char *argv[]) int c; CmdName = argv[0]; - while ((c = getopt(argc, argv, ":?")) != -1) { + opterr = 0; + while ((c = getopt(argc, argv, ":")) != -1) { switch (c) { case '?': if (optopt == '?') diff --git a/cmd/tools/unflatten.c b/cmd/tools/unflatten.c index a2bdd74fa..ebb535c50 100644 --- a/cmd/tools/unflatten.c +++ b/cmd/tools/unflatten.c @@ -179,8 +179,8 @@ static char **scanargs(int argc, char **argv) int c, ival; cmd = argv[0]; - - while ((c = getopt(argc, argv, ":fl:c:o:?")) != -1) { + opterr = 0; + while ((c = getopt(argc, argv, ":fl:c:o:")) != -1) { switch (c) { case 'f': Do_fans = 1; -- 2.40.0