Comparing paths with strcmp is not really smart

I don't know if Dirk has already tagged 4.7.2 or not so it will be in either 4.7.2 or 4.7.3

BUGS: 274294
remotes/origin/KDE/4.7 v4.7.2
Albert Astals Cid 15 years ago
parent 2b82372f5d
commit b932ef7e0f
  1. 22
      generators/poppler/synctex/patches/08-fix_path_comparison.diff
  2. 1
      generators/poppler/synctex/patches/series
  3. 11
      generators/poppler/synctex/synctex_parser_utils.c

@ -0,0 +1,22 @@
diff --git a/generators/poppler/synctex/synctex_parser_utils.c b/generators/poppler/synctex/synctex_parser_utils.c
index 8a79da0..6a6165f 100644
--- a/generators/poppler/synctex/synctex_parser_utils.c
+++ b/generators/poppler/synctex/synctex_parser_utils.c
@@ -184,7 +184,16 @@ next_character:
++rhs;
goto next_character;
# else
- return 0 == strcmp(lhs,rhs)?synctex_YES:synctex_NO;
+ if (lhs[0] == '/' && rhs[0] == '/') { /* for absolute paths compare the real paths */
+ char *lhsreal = realpath(lhs, 0);
+ char *rhsreal = realpath(rhs, 0);
+ synctex_bool_t result = lhsreal && rhsreal && 0 == strcmp(lhsreal,rhsreal)?synctex_YES:synctex_NO;
+ free (lhsreal);
+ free (rhsreal);
+ return result;
+ } else {
+ return 0 == strcmp(lhs,rhs)?synctex_YES:synctex_NO;
+ }
# endif
}

@ -6,3 +6,4 @@
05-fix-error-formats.diff
06-mingw-_synctex_error.diff
07-synctex_scanner_new_with_output_file-reset-mode.diff
08-fix_path_comparison.diff

@ -184,7 +184,16 @@ next_character:
++rhs;
goto next_character;
# else
return 0 == strcmp(lhs,rhs)?synctex_YES:synctex_NO;
if (lhs[0] == '/' && rhs[0] == '/') { /* for absolute paths compare the real paths */
char *lhsreal = realpath(lhs, 0);
char *rhsreal = realpath(rhs, 0);
synctex_bool_t result = lhsreal && rhsreal && 0 == strcmp(lhsreal,rhsreal)?synctex_YES:synctex_NO;
free (lhsreal);
free (rhsreal);
return result;
} else {
return 0 == strcmp(lhs,rhs)?synctex_YES:synctex_NO;
}
# endif
}

Loading…
Cancel
Save