Skip to content

Commit

Permalink
fix: Make XMLVER always print version message
Browse files Browse the repository at this point in the history
The current RPG code calls writeIFS to write directly to file descriptor
1 (stdout), but this descriptor is not guaranteed to be set up and most
certainly is *not* when the program is called from a CL command line
instead of from QSH.

Instead, of calling write() we can call printf(), which ensures that this
descriptor gets set up and a temporary terminal output window is shown when
XMLVER is called from a CL prompt and the output is shown like normal when
called from QSH.

In addition, print a trailing newline so as to not mess up the prompt when
called from a shell.
  • Loading branch information
kadler committed Jan 27, 2020
1 parent 9b9fa7d commit e9cfced
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 56 deletions.
2 changes: 2 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ serialize =

[bumpversion:file:src/plugconf_h.rpgle]

[bumpversion:file:src/xmlver.c]

[bumpversion:file:docs/conf.py]

[bumpversion:part:release]
Expand Down
7 changes: 7 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ xmlstoredp.srvpgm: qsrvsrc.srcpf $(XMLSTOREDP_MODULES)
if [ -e $*.failed ]; then rm $*.failed; exit 1; fi
touch $@

%.module: src/%.c
system "CRTCMOD MODULE($(LIBRARY)/$*) SRCSTMF('$<') DBGVIEW($(DBGVIEW)) REPLACE(*YES) TGTCCSID(37)" > $*.log 2> $*.msg && rm $*.log $*.msg || touch $*.failed
test ! -e $*.msg || cat $*.msg
test ! -e $*.log || cat $*.log
if [ -e $*.failed ]; then rm $*.failed; exit 1; fi
touch $@

%.lib:
(system -q 'CHKOBJ $* *LIB' || system -q 'CRTLIB $*') && touch $@

Expand Down
10 changes: 10 additions & 0 deletions src/xmlver.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <stdio.h>

const char* version = "XML Toolkit 2.0.2-dev";

int main()
{
printf("%s\n", version);
return 0;
}

56 changes: 0 additions & 56 deletions src/xmlver.rpgle

This file was deleted.

0 comments on commit e9cfced

Please sign in to comment.