Skip to content

Commit

Permalink
main: use colprint in --list-features implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Jun 20, 2017
1 parent 406a938 commit f9dca6f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Tmain/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ is_feature_available()
fi

if [ "${neg}" = 1 ]; then
if ${ctags} $o --list-features | grep -q "$feat"; then
if ${ctags} $o --list-features --with-list-header=no | grep -q "$feat"; then
skip "feature \"$feat\" is available in $ctags"
fi
else
if ! ${ctags} $o --list-features | grep -q "$feat"; then
if ! ${ctags} $o --list-features --with-list-header=no | grep -q "$feat"; then
skip "feature \"$feat\" is not available in $ctags"
fi
fi
Expand Down
2 changes: 2 additions & 0 deletions dictfiles/english.list
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ readonly
splitter
whitespace
whitespaces
wildcards

2 changes: 2 additions & 0 deletions dictfiles/libc.list
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ isupper
isxdigit
printf
putc
putchar
puts
qsort
scandir
stdarg
strcat
strchr
Expand Down
1 change: 1 addition & 0 deletions dictfiles/misc.list
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ travis
typedefs
uctags
unix
utils
vg
vs2013
www
Expand Down
2 changes: 1 addition & 1 deletion docs/optlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ NOTE: This feature requires ``scandir`` library function. This feature may
be disabled on which platform scandir is not available. Check ``option-directory``
in the supported features::

$ ./ctags --list-features
$ ./ctags --list-features --with-list-header=no
wildcards
regex
option-directory
Expand Down
19 changes: 18 additions & 1 deletion main/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -1385,14 +1385,31 @@ static void printFeatureList (void)
}


static int featureCompare (struct colprintLine *a, struct colprintLine *b)
{
return strcmp (colprintLineGetColumn (a, 0),
colprintLineGetColumn (b, 0));
}

static void processListFeaturesOption(const char *const option CTAGS_ATTR_UNUSED,
const char *const parameter CTAGS_ATTR_UNUSED)
{
int i;

struct colprintTable *table = colprintTableNew ("L:NAME", NULL);

for (i = 0 ; Features [i] != NULL ; ++i)
{
struct colprintLine * line = colprintTableGetNewLine (table);
if (strcmp (Features [i], "regex") != 0 || checkRegex ())
printf ("%s\n", Features [i]);
colprintLineAppendColumnCString (line, Features [i]);

}

colprintTableSort (table, featureCompare);
colprintTablePrint (table, 0, Option.withListHeader, Option.machinable, stdout);
colprintTableDelete (table);

if (i == 0)
putchar ('\n');
exit (0);
Expand Down
2 changes: 1 addition & 1 deletion misc/units
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ check_features()
for expected in $([ -f "$ffile" ] && cat "$ffile") ${feature}; do
found=no
found_unexpectedly=no
for f in $( ${CTAGS} --quiet --options=NONE --list-features 2> /dev/null | "${_LINE_SPLITTER}" ) ; do
for f in $( ${CTAGS} --quiet --options=NONE --list-features --with-list-header=no 2> /dev/null | "${_LINE_SPLITTER}" ) ; do
[ "$expected" = "$f" ] && found=yes
[ "$expected" = '!'"$f" ] && found_unexpectedly=yes
done
Expand Down

0 comments on commit f9dca6f

Please sign in to comment.