Skip to content

Commit fc28b8f

Browse files
committed
main: provide the way to hide version number from interactive output
1 parent 318e691 commit fc28b8f

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

Tmain/sandbox-version.d/run.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
# Copyright: 2022 Masatake YAMATO
4+
# License: GPL-2
5+
6+
CTAGS=$1
7+
8+
. ../utils.sh
9+
is_feature_available $CTAGS sandbox
10+
is_feature_available ${CTAGS} interactive
11+
is_feature_available ${CTAGS} '!' gcov
12+
13+
echo | $CTAGS --quiet --options=NONE --_interactive=sandbox \
14+
--pseudo-tags=+TAG_PROGRAM_NAME \
15+
--pseudo-tags=+TAG_PROGRAM_VERSION &&
16+
echo | $CTAGS --quiet --options=NONE --_interactive=sandbox \
17+
--pseudo-tags=-TAG_PROGRAM_NAME \
18+
--pseudo-tags=+TAG_PROGRAM_VERSION &&
19+
echo | $CTAGS --quiet --options=NONE --_interactive=sandbox \
20+
--pseudo-tags=+TAG_PROGRAM_NAME \
21+
--pseudo-tags=-TAG_PROGRAM_VERSION
22+
exit $?

Tmain/sandbox-version.d/stderr-expected.txt

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{"_type": "program", "name": "Universal Ctags", "version": "5.9.0"}
2+
{"_type": "program", "version": "5.9.0"}
3+
{"_type": "program", "name": "Universal Ctags"}

main/main.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include "options_p.h"
6060
#include "optscript.h"
6161
#include "parse_p.h"
62+
#include "ptag_p.h"
6263
#include "read_p.h"
6364
#include "routines_p.h"
6465
#include "stats_p.h"
@@ -415,7 +416,16 @@ void interactiveLoop (cookedArgs *args CTAGS_ATTR_UNUSED, void *user)
415416
char buffer[1024];
416417
json_t *request;
417418

418-
fputs ("{\"_type\": \"program\", \"name\": \"" PROGRAM_NAME "\", \"version\": \"" PROGRAM_VERSION "\"}\n", stdout);
419+
if (isPtagEnabled(PTAG_PROGRAM_NAME))
420+
{
421+
if (isPtagEnabled(PTAG_PROGRAM_VERSION))
422+
fputs ("{\"_type\": \"program\", \"name\": \"" PROGRAM_NAME "\", \"version\": \"" PROGRAM_VERSION "\"}\n", stdout);
423+
else
424+
fputs ("{\"_type\": \"program\", \"name\": \"" PROGRAM_NAME "\"}\n", stdout);
425+
}
426+
else if (isPtagEnabled(PTAG_PROGRAM_VERSION))
427+
fputs ("{\"_type\": \"program\", \"version\": \"" PROGRAM_VERSION "\"}\n", stdout);
428+
419429
fflush (stdout);
420430

421431
while (fgets (buffer, sizeof(buffer), stdin))

0 commit comments

Comments
 (0)