Skip to content

Commit

Permalink
sjio: extended --fullpath
Browse files Browse the repository at this point in the history
added: CLI option parsing, test, docs
  • Loading branch information
ped7g committed Jan 27, 2025
1 parent b42668f commit e207d99
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/documentation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
- include paths which can't be opened before assembling are now reported in error message
- include paths which start with literal tilde '~' are reported in error message
- include options <link linkend="s_cli">`-i, -I, --inc`</link> can take path from next CLI argument (new recommended syntax)
- option <link linkend="s_cli">`--fullpath`</link> has now three states including full absolute paths
- added Amstrad CPC device <link linkend="po_device">AMSTRADCPCPLUS</link> - by Laurent Carlier
- added Amstrad CPC+ <link linkend="po_savecpr">`SAVECPR`</link> to save CPR cartridge - by Laurent Carlier
- ZX Next CSpect emulator v2.19.9.1: `break` opcode changed to `FD 00`
Expand Down Expand Up @@ -497,9 +498,8 @@
Note: "lst" or "lstlab" will turn STDERR into listing file (this will clash with
`--lst`, use only one of the options) and some diagnostic messages of "all"
are omitted, as they are not part of listing files. "lstlab" does sort symbols.
--fullpath Show full path to file in errors
Note: the "fullpath" starts from current working directory, not from file system
root (the MS_VS build was fixed to behave this way since v1.15.0)
--fullpath[=on|rel|off] Input file paths: full | CWD relative | name only (*)
Note: --fullpath without value is "rel" (relative to current working directory)
--color=[on|off|auto] Enable or disable ANSI coloring of warnings/errors
Note: auto detection checks for existence of environment variable TERM, and its
content is scanned for sub-string "color" (like "xterm-256color")
Expand Down
12 changes: 10 additions & 2 deletions sjasm/sjasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static void PrintHelpMain() {
_COUT " --nologo Do not show startup message" _ENDL;
_COUT " --msg=[all|war|err|none|lst|lstlab]" _ENDL;
_COUT " Stderr messages verbosity (\"all\" is default)" _ENDL;
_COUT " --fullpath Show full path to file in errors" _ENDL;
_COUT " --fullpath[=on|rel|off] Input file paths: full | CWD relative | name only" _ENDL;
_COUT " --color=[on|off|auto] Enable or disable ANSI coloring of warnings/errors" _ENDL;
_COUT " Other:" _ENDL;
_COUT " -D<NAME>[=<value>] or --define <NAME>[=<value>]" _ENDL;
Expand Down Expand Up @@ -539,7 +539,15 @@ namespace Options {
CheckAssignmentOption("raw", RAWFName) ) {
// was proccessed inside CheckAssignmentOption function
} else if (!strcmp(opt, "fullpath")) {
FileVerbosity = FNAME_LAUNCH_REL;
if (!strcmp("on", val)) {
FileVerbosity = FNAME_ABSOLUTE;
} else if (!val[0] || !strcmp("rel", val)) {
FileVerbosity = FNAME_LAUNCH_REL;
} else if (!strcmp("off", val)) {
FileVerbosity = FNAME_BASE;
} else {
Error("invalid --fullpath setting (use: on|rel|off)", val, ALL);
}
} else if (!strcmp(opt, "color")) {
if (!strcmp("on", val)) {
SetTerminalColors(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
; test --fullpath results in listing file
INCLUDE "optionFullpath/optionFullpath.i.asm"
ASSERT 0 ; for error reporting file pos
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## run sjasmplus with all --fulpath posssible options "--fullpath=off|rel|on" and uknown value
LANG=C $MEMCHECK "$EXE" --nologo --msg=lstlab "${options[@]}" 2> "${dst_base}.1a.lst" "$file_asm"
LANG=C $MEMCHECK "$EXE" --nologo --msg=lstlab --fullpath=off "${options[@]}" 2> "${dst_base}.1b.lst" "$file_asm"
LANG=C $MEMCHECK "$EXE" --nologo --msg=lstlab --fullpath=rel "${options[@]}" 2> "${dst_base}.2a.lst" "$file_asm"
LANG=C $MEMCHECK "$EXE" --nologo --msg=lstlab --fullpath "${options[@]}" 2> "${dst_base}.2b.lst" "$file_asm"
LANG=C $MEMCHECK "$EXE" --nologo --msg=lstlab --fullpath=on "${options[@]}" 2> "${dst_base}.3.lst" "$file_asm"
LANG=C $MEMCHECK "$EXE" --nologo --msg=lstlab --fullpath=xxx "${options[@]}" 2> "${dst_base}.4.lst" "$file_asm"
# check that 1a == 1b, 2a == 2b, and 1 != 2 != 3 != 4 (not checking lst content, differences are enough to pass)
diff "${dst_base}.1a.lst" "${dst_base}.1b.lst" && \
diff "${dst_base}.2a.lst" "${dst_base}.2b.lst" && \
! diff -q "${dst_base}.1a.lst" "${dst_base}.2a.lst" > /dev/null && \
! diff -q "${dst_base}.1a.lst" "${dst_base}.3.lst" > /dev/null && \
! diff -q "${dst_base}.1a.lst" "${dst_base}.4.lst" > /dev/null && \
! diff -q "${dst_base}.2a.lst" "${dst_base}.3.lst" > /dev/null && \
! diff -q "${dst_base}.2a.lst" "${dst_base}.4.lst" > /dev/null && \
! diff -q "${dst_base}.3.lst" "${dst_base}.4.lst" > /dev/null
last_result=$?
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ret
ASSERT 0 ; for error reporting file pos

0 comments on commit e207d99

Please sign in to comment.