diff options
author | Thomas Wienecke <wienecke.t@gmail.com> | 2014-03-30 01:04:52 +0100 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-03 10:32:41 -0300 |
commit | 98b1f73c3f364d11ba54e9950fc2168712da3996 (patch) | |
tree | c343dce1f7e599103861cf8a2ccf3909e038823d | |
parent | db92e0b0945fc71ebd6c4620836c3a8d900443f4 (diff) | |
download | rneovim-98b1f73c3f364d11ba54e9950fc2168712da3996.tar.gz rneovim-98b1f73c3f364d11ba54e9950fc2168712da3996.tar.bz2 rneovim-98b1f73c3f364d11ba54e9950fc2168712da3996.zip |
Make FPC_* defines an enum type in path.h.
-rw-r--r-- | src/path.c | 14 | ||||
-rw-r--r-- | src/path.h | 20 | ||||
-rw-r--r-- | src/vim.h | 8 | ||||
-rw-r--r-- | test/unit/path.moon (renamed from test/unit/misc1.moon) | 18 |
4 files changed, 29 insertions, 31 deletions
diff --git a/src/path.c b/src/path.c index 9f46dc4e12..91cf567418 100644 --- a/src/path.c +++ b/src/path.c @@ -29,20 +29,10 @@ #define URL_SLASH 1 /* path_is_url() has found "://" */ #define URL_BACKSLASH 2 /* path_is_url() has found ":\\" */ -/* - * Compare two file names and return: - * FPC_SAME if they both exist and are the same file. - * FPC_SAMEX if they both don't exist and have the same file name. - * FPC_DIFF if they both exist and are different files. - * FPC_NOTX if they both don't exist. - * FPC_DIFFX if one of them doesn't exist. - * For the first name environment variables are expanded - */ -int -fullpathcmp ( +FileComparison fullpathcmp ( char_u *s1, char_u *s2, - int checkname /* when both don't exist, check file names */ + int checkname ) { #ifdef UNIX diff --git a/src/path.h b/src/path.h index 834431e1bb..5802128db5 100644 --- a/src/path.h +++ b/src/path.h @@ -1,5 +1,24 @@ #ifndef NEOVIM_PATH_H #define NEOVIM_PATH_H + +/// Return value for the comparison of two files. Also @see fullpathcmp. +typedef enum file_comparison { + FPC_SAME = 1, ///< Both exist and are the same file. + FPC_DIFF = 2, ///< Both exist and are different files. + FPC_NOTX = 4, ///< Both don't exist. + FPC_DIFFX = 6, ///< One of them doesn't exist. + FPC_SAMEX = 7 ///< Both don't exist and file names are same. +} FileComparison; + +/// Compare two file names. +/// +/// @param s1 First file name. Environment variables in this name will be +/// expanded. +/// @param s2 Second file name. +/// @param checkname When both files don't exist, only compare their names. +/// @return Enum of type FileComparison. @see FileComparison. +FileComparison fullpathcmp(char_u *s1, char_u *s2, int checkname); + int vim_ispathsep(int c); int vim_ispathsep_nocolon(int c); int vim_ispathlistsep(int c); @@ -14,7 +33,6 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file, int flags); void addfile(garray_T *gap, char_u *f, int flags); -int fullpathcmp(char_u *s1, char_u *s2, int checkname); char_u *gettail(char_u *fname); char_u *gettail_sep(char_u *fname); char_u *getnextcomp(char_u *fname); @@ -537,14 +537,6 @@ enum { # define REX_SET 1 /* to allow \z\(...\), */ # define REX_USE 2 /* to allow \z\1 et al. */ -/* Return values for fullpathcmp() */ -/* Note: can use (fullpathcmp() & FPC_SAME) to check for equal files */ -#define FPC_SAME 1 /* both exist and are the same file. */ -#define FPC_DIFF 2 /* both exist and are different files. */ -#define FPC_NOTX 4 /* both don't exist. */ -#define FPC_DIFFX 6 /* one of them doesn't exist. */ -#define FPC_SAMEX 7 /* both don't exist and file names are same. */ - /* flags for do_ecmd() */ #define ECMD_HIDE 0x01 /* don't free the current buffer */ #define ECMD_SET_HELP 0x02 /* set b_help flag of (new) buffer before diff --git a/test/unit/misc1.moon b/test/unit/path.moon index f408f3d5ec..90142a8cbb 100644 --- a/test/unit/misc1.moon +++ b/test/unit/path.moon @@ -1,26 +1,24 @@ {:cimport, :internalize, :eq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers' ---misc1 = cimport './src/misc1.h' +path = lib --- remove these statements once 'cimport' is working properly for misc1.h -misc1 = lib ffi.cdef [[ -enum FPC { +typedef enum file_comparison { FPC_SAME = 1, FPC_DIFF = 2, FPC_NOTX = 4, FPC_DIFFX = 6, FPC_SAMEX = 7 -}; -int fullpathcmp(char_u *s1, char_u *s2, int checkname); +} FileComparison; +FileComparison fullpathcmp(char_u *s1, char_u *s2, int checkname); ]] -- import constants parsed by ffi -{:FPC_SAME, :FPC_DIFF, :FPC_NOTX, :FPC_DIFFX, :FPC_SAMEX} = lib +{:FPC_SAME, :FPC_DIFF, :FPC_NOTX, :FPC_DIFFX, :FPC_SAMEX} = path -describe 'misc1 function', -> +describe 'path function', -> describe 'fullpathcmp', -> fullpathcmp = (s1, s2, cn) -> s1 = to_cstr s1 s2 = to_cstr s2 - misc1.fullpathcmp s1, s2, cn or 0 + path.fullpathcmp s1, s2, cn or 0 f1 = 'f1.o' f2 = 'f2.o' @@ -33,7 +31,7 @@ describe 'misc1 function', -> after_each -> os.remove f1 os.remove f2 - + it 'returns FPC_SAME when passed the same file', -> eq FPC_SAME, (fullpathcmp f1, f1) |