2010/7/28 Dominique Pellé <dominique.pe...@gmail.com>: > I send this patch again with slightly more elegant way of doing it > saving 3 lines of code. Sorry for the noise.
>From your patch: +/* Used in qsort */ +static int cmp_str(s1, s2) + const void *s1; + const void *s2; +{ + return STRCMP(*(char_u **)s1, *(char_u **)s2); +} + ... + /* Sort and remove dupes which can happen when specifying multiple + * directories in dirnames such as "{syntax,ftplugin,indent}" + */ + qsort(*file, *num_file, sizeof(char_u *), cmp_str); + for (i = *num_file - 1; i > 0; i--) + { + if (STRCMP((*file)[i - 1], (*file)[i]) == 0) + { + /* Remove dupe (*file)[i] */ + vim_free((*file)[i]); + if (*num_file - i - 1 > 0) + mch_memmove(&(*file)[i], &(*file)[i + 1], + (*num_file - i - 1)*sizeof(char *)); + --*num_file; + } + } The code to achieve this (sort and remove duplicates) are already implemented and you can reuse it in place of the codes above. The functions misc2.c:sort_strings() and misc1.c:remove_duplicates() can be used as-is. You'll have to export misc1.c:remove_duplicates() though. See the sample usage in misc1.c:9455. nazri. -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php