MCPcopy Index your code
hub / github.com/NetHack/NetHack / status_version

Function status_version

src/version.c:88–152  ·  view source on GitHub ↗

version info that could be displayed on status lines; " "; if game name is a prefix of--or same as--branch name, it is omitted " "; after release--or if branch info is unavailable--it will be " "; game name or branch name or both can be requested via fl

Source from the content-addressed store, hash-verified

86 "<game name> <x.y.z version number>";
87 game name or branch name or both can be requested via flags */
88char *
89status_version(char *buf, size_t bufsz, boolean indent)
90{
91 const char *name = NULL, *altname = NULL, *indentation;
92 unsigned vflags = flags.versinfo;
93 boolean shownum = ((vflags & VI_NUMBER) != 0),
94 showname = ((vflags & VI_NAME) != 0),
95 showbranch = ((vflags & VI_BRANCH) != 0);
96
97 /* game's name {variants should use own name, not "NetHack"} */
98 if (showname) {
99#ifdef VERS_GAME_NAME /* can be set to override default (base of filename) */
100 name = VERS_GAME_NAME;
101#else
102 name = nh_basename(gh.hname, FALSE); /* hname is from xxxmain.c */
103#endif
104 if (!name || !*name) /* shouldn't happen */
105 showname = FALSE;
106 }
107 /* git branch name, if available */
108 if (showbranch) {
109#if 1 /*#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)*/
110 altname = nomakedefs.git_branch;
111#endif
112 if (!altname || !*altname)
113 showbranch = FALSE;
114 }
115 if (showname && showbranch) {
116 if (!strncmpi(name, altname, strlen(name)))
117 showname = FALSE;
118#if 0
119 /* note: it's possible for branch name to be a prefix of game name
120 but that's unlikely enough that we won't bother with it; having
121 branch "nethack-5.0" be a superset of game "nethack" seems like
122 including both is redundant, but having branch "net" be a subset
123 of game "nethack" doesn't feel that way; optimizing "net" out
124 seems like it would be a mistake */
125 else if (!strncmpi(altname, name, strlen(altname)))
126 showbranch = FALSE;
127#endif
128 } else if (!showname && !showbranch) {
129 /* flags.versinfo could be set to only 'branch' but it might not
130 be available */
131 shownum = TRUE;
132 }
133
134 *buf = '\0';
135 indentation = indent ? " " : "";
136 if (showname) {
137 Snprintf(eos(buf), bufsz - strlen(buf), "%s%s", indentation, name);
138 indentation = " "; /* forced separator rather than optional indent */
139 }
140 if (showbranch) {
141 Snprintf(eos(buf), bufsz - strlen(buf), "%s%s", indentation, altname);
142 indentation = " ";
143 }
144 if (shownum) {
145 /* x.y.z version number */

Callers 5

updateStatsMethod · 0.85
update_valFunction · 0.85
optfn_versinfoFunction · 0.85
do_statusline2Function · 0.85
botl.cFile · 0.85

Calls 4

nh_basenameFunction · 0.85
eosFunction · 0.85
mdlib_version_stringFunction · 0.85
strncmpiFunction · 0.70

Tested by

no test coverage detected