Skip to content

Commit

Permalink
separate usage texts from regular messages
Browse files Browse the repository at this point in the history
usage texts are generated from options.gml definition
  • Loading branch information
jmalak committed Sep 7, 2020
1 parent 2e568ff commit e957b91
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 45 deletions.
2 changes: 1 addition & 1 deletion bld/as/c/asmsg.c
Expand Up @@ -80,7 +80,7 @@ bool AsMsgInit( void )
hInstance.status = 0;
if( _cmdname( name ) != NULL && OpenResFile( &hInstance, name ) ) {
msgShift = _WResLanguage() * MSG_LANG_SPACING;
if( AsMsgGet( USAGE_1, AsResBuffer ) ) {
if( AsMsgGet( MSG_AS_BASE, AsResBuffer ) ) {
return( true );
}
}
Expand Down
9 changes: 8 additions & 1 deletion bld/as/c/asutils.c
Expand Up @@ -92,12 +92,19 @@ void Banner( void )
printed = true;
}

enum {
MSG_USAGE_COUNT = 0
#define pick(c,e,j) + 1
#include "usage.gh"
#undef pick
};

void Usage( void )
//****************
{
int ctr;

for( ctr = USAGE_1; ctr <= USAGE_LAST; ++ctr ) {
for( ctr = MSG_USAGE_BASE; ctr < MSG_USAGE_BASE + MSG_USAGE_COUNT; ++ctr ) {
AsMsgGet( ctr, AsResBuffer );
puts( AsResBuffer );
}
Expand Down
41 changes: 0 additions & 41 deletions bld/as/h/as.msg
Expand Up @@ -121,44 +121,3 @@ pick( OFFSET_OUT_OF_RANGE, "offset out of range",
pick( ABS_REF_NOT_ALLOWED, "absolute reference to '%s' not allowed",
"(J)absolute reference to '%s' not allowed" )
#endif

#ifdef _STANDALONE_
/**** Usage messages - MUST GO LAST!!! ****/
#if defined( AS_ALPHA )
pick( USAGE_1, "Usage: wasaxp {options} {asm_files}",
"(J)Usage: wasaxp {options} {asm_files}" )
#elif defined( AS_PPC )
pick( USAGE_1, "Usage: wasppc {options} {asm_files}",
"(J)Usage: wasppc {options} {asm_files}" )
#elif defined( AS_MIPS )
pick( USAGE_1, "Usage: wasmips {options} {asm_files}",
"(J)Usage: wasmips {options} {asm_files}" )
#else
#error unknown AS_CPU
#endif
pick( USAGE_2, "Options: (/option is also supported)",
"(J)Options: (/option is also supported)" )
pick( USAGE_3, "-d<name>[=text] define text macro",
"(J)-d<name>[=text] define text macro" )
pick( USAGE_4, "-e<number> set error limit number",
"(J)-e<number> set error limit number" )
pick( USAGE_5, "-fo=<filename> set output filename (applies to the first asm_file)",
"(J)-fo=<filename> set output filename (applies to the first asm_file)" )
pick( USAGE_6, "-h or -? print this message",
"(J)-h or -? print this message" )
pick( USAGE_7, "-i=<path> set include path",
"(J)-i=<path> set include path" )
pick( USAGE_8, "-o{e,c} object file format (ELF,COFF)",
"(J)-o{e,c} object file format (ELF,COFF)" )
pick( USAGE_9, "-q or -zq operate quietly",
"(J)-q or -zq operate quietly" )
pick( USAGE_10, "-we treat all warnings as errors",
"(J)-we treat all warnings as errors" )
#ifdef AS_DEBUG_DUMP
pick( USAGE_11, "DEBUG options:",
"DEBUG options:" )
pick( USAGE_12, "-v{i,l,p,s,t} view (instruction,lex buffer,parse,symbols,ins table)",
"-v{i,l,p,s,t} view (instruction,lex buffer,parse,symbols,ins table)" )
#endif
pick( USAGE_LAST, ".", "." )
#endif // _STANDALONE_
2 changes: 2 additions & 0 deletions bld/as/h/as.rc
Expand Up @@ -6,12 +6,14 @@ BEGIN
#define pick(c,e,j) (c + RLE_ENGLISH * MSG_LANG_SPACING), [ e ]

#include "as.msg"
#include "usage.gh"

#undef pick

#define pick(c,e,j) (c + RLE_JAPANESE * MSG_LANG_SPACING), [ j ]

#include "as.msg"
#include "usagej.gh"

#undef pick
END
1 change: 1 addition & 0 deletions bld/as/h/msg.rh
Expand Up @@ -34,6 +34,7 @@
#define MSG_LANG_SPACING 13000

#define MSG_AS_BASE 1
#define MSG_USAGE_BASE 100

#if defined( _STANDALONE_ )
#include "msg.gh"
Expand Down
26 changes: 24 additions & 2 deletions bld/as/master.mif
Expand Up @@ -163,7 +163,7 @@ all : $(all_as) .symbolic
#
# EXE
#
exetarg_prebuild_objs = $(subdir_stand) msg.gh
exetarg_prebuild_objs = $(subdir_stand) msg.gh usage.gh usagej.gh
exetarg_objs = $(as_objs)
exetarg_libs = $(owl_lib) $(wres_lib)
exetarg_res_version_nt_386 = exever.res
Expand All @@ -185,7 +185,7 @@ libtarg_name = asinline
verrc_exe = $(exetarg_name)
!include verrc.mif

wresui.res : $(as_dir)/h/as.rc msg.gh $(__MAKEFILES__)
wresui.res : $(as_dir)/h/as.rc msg.gh usage.gh usagej.gh $(__MAKEFILES__)
@%make echo_rc
$(rcui) $(cppflags) -D_STANDALONE_

Expand Down Expand Up @@ -242,6 +242,28 @@ $(asi_lex_out).c : $(asi_lex_in).re $(__MAKEFILES__)
@%make echo_re2c
$(re2c) $(lex_flags) $[@ > $@

!ifdef exetarg_qnx_res
optencod_opt_qnx = -u $(exetarg_qnx_res)
!endif
!ifeq release 0
optencod_targ_dbg = dbg
!endif

usage.gh $(exetarg_$(host_os)_res) : ../../h/options.gml $(__MAKEFILES__)
@%make echo_optencod
$(noecho)optencod -q $(optencod_opt_$(host_os)) -utf8 $[@ . . $^&.tmp $(host_os) $(target_cpu) $(optencod_targ_dbg)
$(wsplice) -t8 -f "pick((MSG_USAGE_BASE+%$#%+), %s, \"\")" $^&.tmp $@

usagej.gh : ../../h/options.gml $(__MAKEFILES__)
@%make echo_optencod
$(noecho)optencod -l 1 -q -utf8 $[@ . . $^&.tmp $(host_os) $(target_cpu) $(optencod_targ_dbg)
$(wsplice) -t8 -f "pick((MSG_USAGE_BASE+%$#%+), \"\", %s)" $^&.tmp $@

echo_optencod : .PROCEDURE .EXPLICIT
!ifeq verbose 0
@echo optencod $@
!endif

# implicit rules
#################

Expand Down

0 comments on commit e957b91

Please sign in to comment.