shithub: rgbds

Download patch

ref: 6502ed39197d6047afd309fb015cb3f3d739765c
parent: b1a241233e856b630df1a52106ee6cdaa6b68e68
author: Eldred Habert <eldredhabert0@gmail.com>
date: Mon Sep 26 05:42:30 EDT 2022

Add `-I` as an alias for `-i` in rgbasm (#1056)

Co-authored-by: Rangi <35663410+Rangi42@users.noreply.github.com>

--- a/contrib/bash_compl/_rgbasm.bash
+++ b/contrib/bash_compl/_rgbasm.bash
@@ -35,7 +35,7 @@
 		[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"
--- a/contrib/zsh_compl/_rgbasm
+++ b/contrib/zsh_compl/_rgbasm
@@ -48,7 +48,7 @@
 	'(-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]'
--- 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 @@
 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.
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -87,7 +87,7 @@
 }
 
 // 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 @@
 	{ "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 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] <file>\n"
@@ -220,6 +220,10 @@
 			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;