[tex-live] SyncTeX should always write absolute paths
Akira Kakuto
kakuto at fuk.kindai.ac.jp
Sat Oct 3 03:07:54 CEST 2009
Philipp Stephani wrote:
> probably this is the wrong place to ask, but I'm unsure who exactly is
> responsible for SyncTeX in TeX Live. However, I think that SyncTeX
> should always output absolute paths. The current behavior is to write
> relative paths for the input files, which breaks inverse search e.g.
> in Skim when a different output directory is set via -output-
> directory. I could easily fix this by having my build script replace
> all input paths with absolute paths. It would be great if SyncTeX
> wrote absolute paths right from the beginning.
The above will be realized by, for example
--- texmfmp.c.orig Sun Sep 06 02:28:26 2009
+++ texmfmp.c Sat Oct 03 09:58:01 2009
@@ -2420,6 +2420,18 @@
return ret;
}
+string
+get_current_directory(void)
+{
+ char buf[513];
+ string ret;
+
+ (void)getcwd(buf, 512);
+ ret = (string)xmalloc(strlen(buf) + 1);
+ strcpy(ret, buf);
+ return ret;
+}
+
#ifdef XeTeX /* the string pool is UTF-16 but we want a UTF-8 string */
string
@@ -2428,6 +2440,8 @@
unsigned bytesToWrite = 0;
poolpointer len, i, j;
string name;
+ string curdir;
+ string ret;
len = strstart[s + 1 - 65536L] - strstart[s - 65536L];
name = (string)xmalloc(len * 3 + 1); /* max UTF16->UTF8 expansion (code units, not bytes) */
for (i = 0, j = 0; i < len; i++) {
@@ -2462,7 +2476,20 @@
j += bytesToWrite;
}
name[j] = 0;
- return name;
+ if(kpse_absolute_p(name, 0))
+ ret = name;
+ else {
+ if(*name == '.' && *(name+1) == '/')
+ name+=2;
+ curdir = get_current_directory();
+ ret = (string)xmalloc(strlen(curdir)+strlen(name)+2);
+ strcpy(ret, curdir);
+ strcat(ret, "/");
+ strcat(ret, name);
+ free(curdir);
+ free(name);
+ }
+ return ret;
}
#else
@@ -2472,6 +2499,8 @@
{
poolpointer len;
string name;
+ string curdir;
+ string ret;
#if !defined(Aleph)
len = strstart[s + 1] - strstart[s];
#else
@@ -2488,7 +2517,20 @@
}
#endif
name[len] = 0;
- return name;
+ if(kpse_absolute_p(name, 0))
+ ret = name;
+ else {
+ if(*name == '.' && *(name+1) == '/')
+ name+=2;
+ curdir = get_current_directory();
+ ret = (string)xmalloc(strlen(curdir)+strlen(name)+2);
+ strcpy(ret, curdir);
+ strcat(ret, "/");
+ strcat(ret, name);
+ free(curdir);
+ free(name);
+ }
+ return ret;
}
#endif /* not XeTeX */
Thanks,
Akira
More information about the tex-live
mailing list