Skip to content

Commit

Permalink
main: introduce TAGS_OUTPUT_FILESEP pseudo tag
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <[email protected]>
  • Loading branch information
masatake committed Sep 25, 2019
1 parent 576f76c commit e6ee6e6
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions Tmain/input-encoding-option.d/tags-expected.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
!_TAG_FILE_ENCODING UTF-8 //
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
Expand Down
2 changes: 1 addition & 1 deletion Tmain/json-output-format.d/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ if is_feature_available "${CTAGS}" json; then
run_with_format json --languages=+man
run_with_format json --languages=+man --fields="*"
run_with_format json --languages=+man --fields="*" --extras='*'-{subword}
} | grep -v TAG_PROGRAM_VERSION
} | grep -v TAG_PROGRAM_VERSION | grep -v TAG_OUTPUT_FILESEP
fi
1 change: 1 addition & 0 deletions Tmain/list-pseudo-tags.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ TAG_FILE_FORMAT on the version of tags file format
TAG_FILE_SORTED on how tags are sorted
TAG_KIND_DESCRIPTION off the letters, names and descriptions of kinds in a parser
TAG_KIND_SEPARATOR off the separators used in kinds
TAG_OUTPUT_FILESEP on the separator used in file name (slash or backslash)
TAG_OUTPUT_MODE on the output mode: u-ctags or e-ctags
TAG_PROGRAM_AUTHOR on the author of this ctags implementation
TAG_PROGRAM_NAME on the name of this ctags implementation
Expand Down
14 changes: 14 additions & 0 deletions Tmain/option-use-slash-as-filename-separator.d/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,25 @@ $CTAGS --quiet --options=NONE -o - 'src\input.c'
$CTAGS --quiet --options=NONE -o - $OPT 'src\input.c'
$CTAGS --quiet --options=NONE -o - ${OPT}=no 'src\input.c'

echo '#u-ctags ptag output'
{
$CTAGS --quiet --options=NONE --extras=p -o - 'src\input.c'
$CTAGS --quiet --options=NONE --extras=p -o - $OPT 'src\input.c'
$CTAGS --quiet --options=NONE --extras=p -o - ${OPT}=no 'src\input.c'
} | grep TAG_OUTPUT_FILESEP

echo '#e-ctags output'
$CTAGS --quiet --options=NONE --output-format=e-ctags -o - 'src\input.c'
$CTAGS --quiet --options=NONE --output-format=e-ctags -o - $OPT 'src\input.c'
$CTAGS --quiet --options=NONE --output-format=e-ctags -o - ${OPT}=no 'src\input.c'

echo '#e-ctags ptag output'
{
$CTAGS --quiet --options=NONE --extras=p --output-format=e-ctags -o - 'src\input.c'
$CTAGS --quiet --options=NONE --extras=p --output-format=e-ctags -o - $OPT 'src\input.c'
$CTAGS --quiet --options=NONE --extras=p --output-format=e-ctags -o - ${OPT}=no 'src\input.c'
} | grep TAG_OUTPUT_FILESEP

echo '#xref output'
$CTAGS --quiet --options=NONE --output-format=xref -o - 'src\input.c'
$CTAGS --quiet --options=NONE --output-format=xref -o - $OPT 'src\input.c'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
n src/input.c /^int n;$/;" v typeref:typename:int
n src/input.c /^int n;$/;" v typeref:typename:int
n src\\input.c /^int n;$/;" v typeref:typename:int
#u-ctags ptag output
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_FILESEP backslash /slash or backslash/
#e-ctags output
n src\input.c /^int n;$/;" v typeref:typename:int
n src/input.c /^int n;$/;" v typeref:typename:int
n src\input.c /^int n;$/;" v typeref:typename:int
#e-ctags ptag output
!_TAG_OUTPUT_FILESEP backslash /slash or backslash/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_FILESEP backslash /slash or backslash/
#xref output
n variable 1 src\\input.c int n;
n variable 1 src/input.c int n;
Expand Down
1 change: 1 addition & 0 deletions Tmain/output-encoding-option.d/tags-expected.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
!_TAG_FILE_ENCODING cp932 //
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
Expand Down
2 changes: 2 additions & 0 deletions Tmain/ptag-kind-desc.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
!_TAG_KIND_DESCRIPTION!Sh f,function /functions/
!_TAG_KIND_DESCRIPTION!Sh h,heredoc /label for here document/
!_TAG_KIND_DESCRIPTION!Sh s,script /script files/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
Expand All @@ -13,6 +14,7 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_KIND_DESCRIPTION!foo k,kind /kinds/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
Expand Down
1 change: 1 addition & 0 deletions Tmain/tags-pseudo-tags.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
!_TAG_KIND_SEPARATOR!PHP \\ /nn/
!_TAG_KIND_SEPARATOR!PHP \\ /nt/
!_TAG_KIND_SEPARATOR!PHP \\ /nv/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
Expand Down
4 changes: 4 additions & 0 deletions main/ptag.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ static ptagDesc ptagDescs [] = {
"the output mode: u-ctags or e-ctags",
ptagMakeCtagsOutputMode,
true },
{ true, "TAG_OUTPUT_FILESEP",
"the separator used in file name (slash or backslash)",
ptagMakeCtagsOutputFilesep,
true },
};

extern bool makePtagIfEnabled (ptagType type, const void *data)
Expand Down
1 change: 1 addition & 0 deletions main/ptag_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ typedef enum ePtagType { /* pseudo tag content control */
PTAG_KIND_SEPARATOR,
PTAG_KIND_DESCRIPTION,
PTAG_OUTPUT_MODE,
PTAG_OUTPUT_FILESEP,
PTAG_COUNT
} ptagType;

Expand Down
13 changes: 13 additions & 0 deletions main/writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "general.h"
#include "entry_p.h"
#include "options_p.h"
#include "writer_p.h"

extern tagWriter uCtagsWriter;
Expand Down Expand Up @@ -128,3 +129,15 @@ extern enum filenameSepOp getFilenameSeparator (enum filenameSepOp currentSettin
return currentSetting;
}
#endif

extern bool ptagMakeCtagsOutputFilesep (ptagDesc *desc, const void *data CTAGS_ATTR_UNUSED)
{
const char *sep = "slash";
#ifdef WIN32
const optionValues *opt = data;
if (getFilenameSeparator (opt->useSlashAsFilenameSeparator)
!= FILENAME_SEP_USE_SLASH)
sep = "backslash";
#endif
return writePseudoTag (desc, sep, "slash or backslash", NULL);
}
1 change: 1 addition & 0 deletions main/writer_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ extern void abort_if_ferror(MIO *const fp);

extern bool ptagMakeJsonOutputVersion (ptagDesc *desc, const void *data CTAGS_ATTR_UNUSED);
extern bool ptagMakeCtagsOutputMode (ptagDesc *desc, const void *data CTAGS_ATTR_UNUSED);
extern bool ptagMakeCtagsOutputFilesep (ptagDesc *desc, const void *data);

extern bool writerCanPrintPtag (void);
extern bool writerDoesTreatFieldAsFixed (int fieldType);
Expand Down

0 comments on commit e6ee6e6

Please sign in to comment.