diff options
Diffstat (limited to 'cut-n-paste/synctex/synctex_parser_utils.c')
-rw-r--r-- | cut-n-paste/synctex/synctex_parser_utils.c | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/cut-n-paste/synctex/synctex_parser_utils.c b/cut-n-paste/synctex/synctex_parser_utils.c index d9f65038..6ba6dc9f 100644 --- a/cut-n-paste/synctex/synctex_parser_utils.c +++ b/cut-n-paste/synctex/synctex_parser_utils.c @@ -5,7 +5,7 @@ This file is part of the SyncTeX package. Latest Revision: Tue Jun 14 08:23:30 UTC 2011 -Version: 1.16 +Version: 1.17 See synctex_parser_readme.txt for more details @@ -141,36 +141,57 @@ void _synctex_strip_last_path_extension(char * string) { } } -const char * synctex_ignore_leading_dot_slash(const char * name) +synctex_bool_t synctex_ignore_leading_dot_slash_in_path(const char ** name_ref) { - while(SYNCTEX_IS_DOT(*name) && SYNCTEX_IS_PATH_SEPARATOR(name[1])) { - name += 2; - while (SYNCTEX_IS_PATH_SEPARATOR(*name)) { - ++name; - } + if (SYNCTEX_IS_DOT((*name_ref)[0]) && SYNCTEX_IS_PATH_SEPARATOR((*name_ref)[1])) { + do { + (*name_ref) += 2; + while (SYNCTEX_IS_PATH_SEPARATOR((*name_ref)[1])) { + ++(*name_ref); + } + } while(SYNCTEX_IS_DOT((*name_ref)[0]) && SYNCTEX_IS_PATH_SEPARATOR((*name_ref)[1])); + return synctex_YES; } - return name; + return synctex_NO; +} + +/* The base name is necessary to deal with the 2011 file naming convention... + * path is a '\0' terminated string + * The return value is the trailing part of the argument, + * just following the first occurrence of the regexp pattern "[^|/|\].[\|/]+".*/ +const char * _synctex_base_name(const char *path) { + const char * ptr = path; + do { + if (synctex_ignore_leading_dot_slash_in_path(&ptr)) { + return ptr; + } + do { + if (!*(++ptr)) { + return path; + } + } while (!SYNCTEX_IS_PATH_SEPARATOR(*ptr)); + } while (*(++ptr)); + return path; } /* Compare two file names, windows is sometimes case insensitive... */ synctex_bool_t _synctex_is_equivalent_file_name(const char *lhs, const char *rhs) { /* Remove the leading regex '(\./+)*' in both rhs and lhs */ - lhs = synctex_ignore_leading_dot_slash(lhs); - rhs = synctex_ignore_leading_dot_slash(rhs); -# if SYNCTEX_WINDOWS - /* On Windows, filename should be compared case insensitive. - * The characters '/' and '\' are both valid path separators. - * There will be a very serious problem concerning UTF8 because - * not all the characters must be toupper... - * I would like to have URL's instead of filenames. */ + synctex_ignore_leading_dot_slash_in_path(&lhs); + synctex_ignore_leading_dot_slash_in_path(&rhs); next_character: - if(SYNCTEX_IS_PATH_SEPARATOR(*lhs)) {/* lhs points to a path separator */ - if(!SYNCTEX_IS_PATH_SEPARATOR(*rhs)) {/* but not rhs */ + if (SYNCTEX_IS_PATH_SEPARATOR(*lhs)) {/* lhs points to a path separator */ + if (!SYNCTEX_IS_PATH_SEPARATOR(*rhs)) {/* but not rhs */ return synctex_NO; } - } else if(SYNCTEX_IS_PATH_SEPARATOR(*rhs)) {/* rhs points to a path separator but not lhs */ + ++lhs; + ++rhs; + synctex_ignore_leading_dot_slash_in_path(&lhs); + synctex_ignore_leading_dot_slash_in_path(&rhs); + goto next_character; + } else if (SYNCTEX_IS_PATH_SEPARATOR(*rhs)) {/* rhs points to a path separator but not lhs */ return synctex_NO; - } else if(toupper(*lhs) != toupper(*rhs)){/* uppercase do not match */ + } else if (SYNCTEX_ARE_PATH_CHARACTERS_EQUAL(*lhs,*rhs)){/* uppercase do not match */ return synctex_NO; } else if (!*lhs) {/* lhs is at the end of the string */ return *rhs ? synctex_NO : synctex_YES; @@ -180,9 +201,6 @@ next_character: ++lhs; ++rhs; goto next_character; -# else - return 0 == strcmp(lhs,rhs)?synctex_YES:synctex_NO; -# endif } synctex_bool_t _synctex_path_is_absolute(const char * name) { |