[GHC] #14145: I expect `hp2ps -cd` to work as `hp2ps -c -d` does.

#14145: I expect `hp2ps -cd` to work as `hp2ps -c -d` does. -------------------------------------+------------------------------------- Reporter: qbolec | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: Profiling | Version: 7.10.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- It's a common convention among command-line programs that if the documentation describes short options, such as `-c` and `-d` then it should also accept their combination like `-cd`, unless otherwise stated. Alternatively, if this is not supported, then at least a warning abound unknown option "cd" should be displayed. Instead the process silently accepts `-cd`, and produces a colorful chart (-c) but does not sort by variance (ignores d). I'm not sure what version of hp2ps I use, because it seems to ignore `--version` and `-v` and `--help` does not produce version string anywhere. However: $ ghc --version The Glorious Glasgow Haskell Compilation System, version 7.10.2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14145 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14145: I expect `hp2ps -cd` to work as `hp2ps -c -d` does. -------------------------------------+------------------------------------- Reporter: qbolec | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Profiling | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): I agree; it would be nice if this were the case. Perhaps you could offer a patch? `hp2ps` is a C program and can be found in the GHC tree in `utils/hp2ps`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14145#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14145: I expect `hp2ps -cd` to work as `hp2ps -c -d` does. -------------------------------------+------------------------------------- Reporter: qbolec | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Profiling | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by qbolec): I'll devote two hours to that and describe the results if it's not enough time to dive it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14145#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14145: I expect `hp2ps -cd` to work as `hp2ps -c -d` does. -------------------------------------+------------------------------------- Reporter: qbolec | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Profiling | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by qbolec): I've run out of time, so I didn't figure out how to configure all the tools to make the pull request, and where and how to add tests for this file. But here is the minimal change I believe fixes the problem: {{{ diff --git a/utils/hp2ps/Main.c b/utils/hp2ps/Main.c index a44e41c862..30dbc2992b 100644 --- a/utils/hp2ps/Main.c +++ b/utils/hp2ps/Main.c @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) goto nextarg; case 'd': dflag++; - goto nextarg; + break; case 'i': switch( *(*argv + 1) ) { case '-': @@ -94,16 +94,16 @@ int main(int argc, char *argv[]) goto nextarg; case 'g': gflag++; - goto nextarg; + break; case 'y': yflag++; - goto nextarg; + break; case 'b': bflag++; - goto nextarg; + break; case 's': sflag++; - goto nextarg; + break; case 'm': mflag++; TWENTY = atoi(*argv + 1); @@ -122,7 +122,7 @@ int main(int argc, char *argv[]) goto nextarg; case 'c': cflag++; - goto nextarg; + break; case '?': default: Usage(*argv-1); }}} In particular it seems that the intent of the {{{ while (argc && argv[0][0] == '-') { while (*++*argv) switch(**argv) { }}} loop was to loop through all characters within a single word, and in did this is how it works for "-p" option, but for all the others `goto nextarg;` is used instead `break;` which skips all the other letters. A better solution in my opinion would be to use [https://stackoverflow.com/questions/9642732/parsing-command-line- arguments some library] to parse the options because the current code (and code style) seems quite complicated to me. I had no time to investigate which of these libraries we could use in order to support MSYS2 etc. Nor the time to actually rewrite the code to use such a library. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14145#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14145: I expect `hp2ps -cd` to work as `hp2ps -c -d` does. -------------------------------------+------------------------------------- Reporter: qbolec | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Profiling | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Thanks for giving it a shot! I'll try to finish up your patch when I get a chance. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14145#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC