fill and return the given buffer with the long nethack version string */
| 32 | |
| 33 | /* fill and return the given buffer with the long nethack version string */ |
| 34 | char * |
| 35 | getversionstring(char *buf, size_t bufsz) |
| 36 | { |
| 37 | Strcpy(buf, nomakedefs.version_id); |
| 38 | |
| 39 | { |
| 40 | int c = 0; |
| 41 | #if defined(RUNTIME_PORT_ID) |
| 42 | char tmpbuf[BUFSZ], *tmp; |
| 43 | #endif |
| 44 | char *p = eos(buf); |
| 45 | boolean dotoff = (p > buf && p[-1] == '.'); |
| 46 | |
| 47 | if (dotoff) |
| 48 | --p; |
| 49 | Strcpy(p, " ("); |
| 50 | #if defined(RUNTIME_PORT_ID) |
| 51 | tmp = get_port_id(tmpbuf); |
| 52 | if (tmp) |
| 53 | Snprintf(eos(buf), (bufsz - strlen(buf)) - 1, |
| 54 | "%s%s", c++ ? "," : "", tmp); |
| 55 | #endif |
| 56 | if (nomakedefs.git_sha) |
| 57 | Snprintf(eos(buf), (bufsz - strlen(buf)) - 1, |
| 58 | "%s%s", c++ ? "," : "", nomakedefs.git_sha); |
| 59 | #if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) |
| 60 | if (nomakedefs.git_branch) |
| 61 | Snprintf(eos(buf), (bufsz - strlen(buf)) - 1, |
| 62 | "%sbranch:%s", |
| 63 | c++ ? "," : "", nomakedefs.git_branch); |
| 64 | #endif |
| 65 | if (nomakedefs.git_prefix) |
| 66 | Snprintf(eos(buf), (bufsz - strlen(buf)) - 1, |
| 67 | "%sprefix:%s", |
| 68 | c++ ? "," : "", nomakedefs.git_prefix); |
| 69 | if (c) |
| 70 | Snprintf(eos(buf), (bufsz - strlen(buf)) - 1, |
| 71 | "%s", ")"); |
| 72 | else /* if nothing has been added, strip " (" back off */ |
| 73 | *p = '\0'; |
| 74 | if (dotoff) |
| 75 | Snprintf(eos(buf), (bufsz - strlen(buf)) - 1, |
| 76 | "%s", "."); |
| 77 | } |
| 78 | return buf; |
| 79 | } |
| 80 | |
| 81 | /* version info that could be displayed on status lines; |
| 82 | "<game name> <git branch name> <x.y.z version number>"; |
no test coverage detected