From 6502ed39197d6047afd309fb015cb3f3d739765c Mon Sep 17 00:00:00 2001 From: Eldred Habert Date: Mon, 26 Sep 2022 09:42:30 +0200 Subject: [PATCH] Add `-I` as an alias for `-i` in rgbasm (#1056) Co-authored-by: Rangi <35663410+Rangi42@users.noreply.github.com> --- contrib/bash_compl/_rgbasm.bash | 2 +- contrib/zsh_compl/_rgbasm | 2 +- man/rgbasm.1 | 4 ++-- src/asm/main.c | 10 +++++++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/contrib/bash_compl/_rgbasm.bash b/contrib/bash_compl/_rgbasm.bash index 10127abc..9da15c95 100755 --- a/contrib/bash_compl/_rgbasm.bash +++ b/contrib/bash_compl/_rgbasm.bash @@ -35,7 +35,7 @@ _rgbasm_completions() { [b]="binary-digits:unk" [D]="define:unk" [g]="gfx-chars:unk" - [i]="include:dir" + [I]="include:dir" [M]="dependfile:glob-*.mk *.d" [o]="output:glob-*.o" [P]="preinclude:glob-*.asm *.inc" diff --git a/contrib/zsh_compl/_rgbasm b/contrib/zsh_compl/_rgbasm index 4a7588bc..cb30f3f5 100644 --- a/contrib/zsh_compl/_rgbasm +++ b/contrib/zsh_compl/_rgbasm @@ -48,7 +48,7 @@ local args=( '(-b --binary-digits)'{-b,--binary-digits}'+[Change chars for binary constants]:digit spec:' '*'{-D,--define}'+[Define a string symbol]:name + value (default 1):' '(-g --gfx-chars)'{-g,--gfx-chars}'+[Change chars for gfx constants]:chars spec:' - '(-i --include)'{-i,--include}'+[Add an include directory]:include path:_files -/' + '(-I --include)'{-I,--include}'+[Add an include directory]:include path:_files -/' '(-M --dependfile)'{-M,--dependfile}"+[List deps in make format]:output file:_files -g '*.{d,mk}'" -MG'[Assume missing files should be generated]' -MP'[Add phony targets to all deps]' diff --git a/man/rgbasm.1 b/man/rgbasm.1 index f0face69..65149efd 100644 --- a/man/rgbasm.1 +++ b/man/rgbasm.1 @@ -17,7 +17,7 @@ .Op Fl b Ar chars .Op Fl D Ar name Ns Op = Ns Ar value .Op Fl g Ar chars -.Op Fl i Ar path +.Op Fl I Ar path .Op Fl M Ar depend_file .Op Fl MG .Op Fl MP @@ -86,7 +86,7 @@ Disables inserting a instruction immediately after any .Ic halt instruction. -.It Fl i Ar path , Fl Fl include Ar path +.It Fl I Ar path , Fl Fl include Ar path Add a new .Dq include path ; Ar path must point to a directory. diff --git a/src/asm/main.c b/src/asm/main.c index a57f37b7..a119b7a9 100644 --- a/src/asm/main.c +++ b/src/asm/main.c @@ -87,7 +87,7 @@ static char *make_escape(char const *str) } // Short options -static const char *optstring = "b:D:Eg:Hhi:LlM:o:P:p:Q:r:VvW:w"; +static const char *optstring = "b:D:Eg:Hhi:I:LlM:o:P:p:Q:r:VvW:w"; // Variables for the long-only options static int depType; // Variants of `-M` @@ -107,7 +107,7 @@ static struct option const longopts[] = { { "gfx-chars", required_argument, NULL, 'g' }, { "nop-after-halt", no_argument, NULL, 'H' }, { "halt-without-nop", no_argument, NULL, 'h' }, - { "include", required_argument, NULL, 'i' }, + { "include", required_argument, NULL, 'I' }, { "preserve-ld", no_argument, NULL, 'L' }, { "auto-ldh", no_argument, NULL, 'l' }, { "dependfile", required_argument, NULL, 'M' }, @@ -129,7 +129,7 @@ static struct option const longopts[] = { static void print_usage(void) { fputs( -"Usage: rgbasm [-EHhLlVvw] [-b chars] [-D name[=value]] [-g chars] [-i path]\n" +"Usage: rgbasm [-EHhLlVvw] [-b chars] [-D name[=value]] [-g chars] [-I path]\n" " [-M depend_file] [-MG] [-MP] [-MT target_file] [-MQ target_file]\n" " [-o out_file] [-P include_file] [-p pad_value] [-Q precision]\n" " [-r depth] [-W warning] \n" @@ -220,6 +220,10 @@ int main(int argc, char *argv[]) haltnop = false; break; + // `-i` was the only short option for `--include` until `-I` was + // introduced to better match the `-I dir` option of gcc and clang. + // `-i` is now undocumented but still supported for now. + case 'I': case 'i': fstk_AddIncludePath(musl_optarg); break;