xolox/vim-easytags — Issue #25: Sorting issue
Author: jreybert
Created: 2012-01-13 11:08:29+00:00
State: open

I am facing a big issue with sort in tags files... The sort is not the same if I create the file from command line and if I use UpdateTags in easytags. The problem is how underscores are interpreted. I don't know if it is always reproducible, maybe it is because some deep hidden locale definition somewhere. I tried to play with LC_COLLATE, but I don't know if is understood by vim. BTW, here a comment extracted from help of sort command in vim (I know you use sort function, but it is maybe related)

> The details about sorting depend on the library function used. There is no
> guarantee that sorting is "stable" or obeys the current locale. You will have
> to try it out.

I am using:
* Exuberant Ctags 5.8
* Vim 7.3
* bash 4.1

The proble is that vim says to me that some tags files are not well sorted (and I want to keep binary search!)

I can reproduce it with the following:

create a test.c file:

```c
int test_pe_init_params;
int test_pe_try_credits;

void test_pending_credits_init();
void test_pending_try_credits();
```

Now, create a tags file from command line:

ctags --sort=foldcase -R --c++-kinds=+p --c-kinds=+p --fields=+liaS

Copy this first version, then open test.c, :UpdateTags, then check diff between two versions:

exuberant-ctags version

!_TAG_FILE_FORMAT	2	/extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED	2	/0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR	Darren Hiebert	/dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME	Exuberant Ctags	//
!_TAG_PROGRAM_URL	http://ctags.sourceforge.net	/official site/
!_TAG_PROGRAM_VERSION	5.8	//
test_pending_credits_init	test.c	/^void test_pending_credits_init();$/;"	p	language:C	file:
test_pending_try_credits	test.c	/^void test_pending_try_credits();$/;"	p	language:C	file:
test_pe_init_params	test.c	/^int test_pe_init_params;$/;"	v	language:C
test_pe_try_credits	test.c	/^int test_pe_try_credits;	$/;"	v	language:C

!_TAG_FILE_FORMAT	2	/extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED	2	/0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR	Darren Hiebert	/dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME	Exuberant Ctags	//
!_TAG_PROGRAM_URL	http://ctags.sourceforge.net	/official site/
!_TAG_PROGRAM_VERSION	5.8	//
test_pe_init_params	/nfs/home/jreybert/test/easytags/test.c	/^int test_pe_init_params;$/;"	v	language:C
test_pe_try_credits	/nfs/home/jreybert/test/easytags/test.c	/^int test_pe_try_credits;	$/;"	v	language:C
test_pending_credits_init	/nfs/home/jreybert/test/easytags/test.c	/^void test_pending_credits_init();$/;"	p	language:C	file:
test_pending_try_credits	/nfs/home/jreybert/test/easytags/test.c	/^void test_pending_try_credits();$/;"	p	language:C	file: