diff lwasm/main.c @ 390:1ebb5a0b2874

Add option to specify tab width in listing There is much insistence that generating the asm listing should absolutely not ever in the entire expanse of space and time expand tabs. lwasm, however, does so, and it does so for a reason. That reason is that there are enough users that have enough trouble even understanding what a tab is that it was simpler to just expand them. That said, having a means to actually specify the tab width is pretty much required if you're going to do that, and having a way to disable such expansion is also a good idea. Thanks to Erik G <erik@6809.org> for the base patch to handle this.
author William Astle <lost@l-w.ca>
date Mon, 13 Jul 2015 21:52:43 -0600
parents 71f507f404f1
children 4411a6123716
line wrap: on
line diff
--- a/lwasm/main.c	Mon Jul 13 21:37:49 2015 -0600
+++ b/lwasm/main.c	Mon Jul 13 21:52:43 2015 -0600
@@ -48,6 +48,7 @@
 	{ "list",		'l',	"FILE",		lw_cmdline_opt_optional,	"Generate list [to FILE]"},
 	{ "symbols",	's',	0,			lw_cmdline_opt_optional,	"Generate symbol list in listing, no effect without --list"},
 	{ "symbols-nolocals", 0x103,	0,	lw_cmdline_opt_optional,	"Same as --symbols but with local labels ignored"},
+	{ "tabs",		't',	"WIDTH",	0,							"Set tab spacing in listing (0=don't expand tabs)" },
 	{ "map",		'm',	"FILE",		lw_cmdline_opt_optional,	"Generate map [to FILE]"},
 	{ "decb",		'b',	0,			0,							"Generate DECB .bin format output, equivalent of --format=decb"},
 	{ "raw",		'r',	0,			0,							"Generate raw binary format output, equivalent of --format=raw"},
@@ -58,7 +59,7 @@
 	{ "6809",		'9',	0,			0,							"Set assembler to 6809 only mode" },
 	{ "6309",		'3',	0,			0,							"Set assembler to 6309 mode (default)" },
 	{ "includedir",	'I',	"PATH",		0,							"Add entry to include path" },
-	{ "define", 'D', "SYM[=VAL]", 0, "Automatically define SYM to be VAL (or 1)"},
+	{ "define",		'D',	"SYM[=VAL]",0,							"Automatically define SYM to be VAL (or 1)"},
 	{ "preprocess",	'P',	0,			0,							"Preprocess macros and conditionals and output revised source to stdout" },
 	{ "unicorns",	0x142,	0,			0,							"Add sooper sekrit sauce"},
 	{ "6800compat",	0x200,	0,			0,							"Enable 6800 compatibility instructions, equivalent to --pragma=6800compat" },
@@ -114,6 +115,11 @@
 #endif
 		break;
 
+	case 't':
+		if (arg)
+			as -> tabwidth = atoi(arg);
+		break;
+
 	case 'l':
 		if (as -> list_file)
 			lw_free(as -> list_file);
@@ -293,6 +299,7 @@
 	asmstate.input_files = lw_stringlist_create();
 	asmstate.nextcontext = 1;
 	asmstate.exprwidth = 16;
+	asmstate.tabwidth = 8;
 	
 	/* parse command line arguments */	
 	lw_cmdline_parse(&cmdline_parser, argc, argv, 0, 0, &asmstate);