56 #if defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__)
57 #define SYNCTEX_WINDOWS 1
64 #ifdef _WIN32_WINNT_WINXP
65 #define SYNCTEX_RECENT_WINDOWS 1
68 #ifdef SYNCTEX_WINDOWS
73 void * ptr = malloc(size);
84 va_start (arg, reason);
85 # ifdef SYNCTEX_RECENT_WINDOWS
96 OutputDebugStringA(
"SyncTeX ERROR: ");
97 len = _vscprintf(reason, arg) + 1;
98 buff = (
char*)malloc( len *
sizeof(
char) );
99 result = vsprintf(buff, reason, arg) +strlen(
"SyncTeX ERROR: ");
100 OutputDebugStringA(buff);
101 OutputDebugStringA(
"\n");
105 result =
fprintf(stderr,
"SyncTeX ERROR: ");
106 result += vfprintf(stderr, reason, arg);
107 result +=
fprintf(stderr,
"\n");
116 char * last_component = NULL;
117 char * last_extension = NULL;
120 if(NULL == (last_component = strstr(
string,
"/"))){
121 last_component = string;
124 while((next = strstr(last_component,
"/"))){
125 last_component = next+1;
128 # if defined(SYNCTEX_WINDOWS) || defined(SYNCTEX_OS2)
130 while((next = strstr(last_component,
"\\"))){
131 last_component = next+1;
135 if((last_extension = strstr(last_component,
"."))){
137 while((next = strstr(last_extension,
"."))){
138 last_extension = next+1;
141 if(last_extension>last_component){
142 last_extension[0] =
'\0';
167 const char * ptr = path;
214 # if defined(SYNCTEX_WINDOWS) || defined(SYNCTEX_OS2)
226 const char * c = name+strlen(name);
243 if(src && dest_ref) {
244 # define dest (*dest_ref)
248 if(
strchr(lpc,
' ') && lpc[0]!=
'"' && lpc[strlen(lpc)-1]!=
'"') {
253 if(strlen(src)<size) {
254 if((
dest = (
char *)malloc(size+2))) {
255 char * dpc =
dest + (lpc-src);
256 if(
dest != strncpy(
dest,src,size)) {
257 _synctex_error(
"! _synctex_copy_with_quoting_last_path_component: Copy problem");
262 memmove(dpc+1,dpc,strlen(dpc)+1);
264 dpc[strlen(dpc)+1]=
'\0';
265 dpc[strlen(dpc)]=
'"';
270 _synctex_error(
"! _synctex_copy_with_quoting_last_path_component: Internal inconsistency");
289 va_start (arg, first);
292 size_t len = strlen(temp);
293 if(UINT_MAX-len<size) {
298 }
while( (temp = va_arg(arg,
const char *)) != NULL);
301 char * result = NULL;
304 if(NULL!=(result = (
char *)malloc(size))) {
305 char *
dest = result;
306 va_start (arg, first);
309 if((size = strlen(temp))>0) {
311 if(dest != strncpy(dest,temp,size)) {
319 }
while( (temp = va_arg(arg,
const char *)) != NULL);
336 if(output && synctex_name_ref && io_mode_ref) {
343 if(strlen(base_name)>0) {
345 const char * temp = NULL;
346 char * core_name = NULL;
347 char * dir_name = NULL;
348 char * quoted_core_name = NULL;
349 char * basic_name = NULL;
350 char * gz_name = NULL;
351 char * quoted_name = NULL;
352 char * quoted_gz_name = NULL;
353 char * build_name = NULL;
354 char * build_gz_name = NULL;
355 char * build_quoted_name = NULL;
356 char * build_quoted_gz_name = NULL;
362 if((temp =
strrchr(base_name,
'.')) && (size = temp - base_name)>0) {
364 if(NULL == (core_name = (
char *)malloc(size+1))) {
368 if(core_name != strncpy(core_name,base_name,size)) {
374 core_name[size] =
'\0';
382 size = strlen(output)-strlen(base_name);
385 if(NULL == (dir_name = (
char *)malloc(size+1))) {
391 if(dir_name != strncpy(dir_name,output,size)) {
399 dir_name[size] =
'\0';
403 if(
strchr(core_name,
' ')) {
407 if(dir_name &&strlen(dir_name)>0) {
409 if(quoted_core_name && strlen(quoted_core_name)>0) {
414 if(quoted_core_name && strlen(quoted_core_name)>0) {
419 temp = build_directory + size - 1;
422 if(quoted_core_name && strlen(quoted_core_name)>0) {
427 if(quoted_core_name && strlen(quoted_core_name)>0) {
441 if(build_quoted_name) {
446 # define TEST(FILENAME,COMPRESS_MODE) \
448 if (stat(FILENAME, &buf)) { \
451 } else if (buf.st_mtime>the_time) { \
452 the_time=buf.st_mtime; \
453 synctex_name = FILENAME; \
454 if (COMPRESS_MODE) { \
455 io_mode |= synctex_io_gz_mask; \
457 io_mode &= ~synctex_io_gz_mask; \
471 # define CLEAN_AND_REMOVE(FILENAME) \
472 if(FILENAME && (FILENAME!=synctex_name)) {\
474 printf("synctex tool info: %s removed\n",FILENAME);\
486 # undef CLEAN_AND_REMOVE
488 * synctex_name_ref = synctex_name;
489 * io_mode_ref = io_mode;
498 static const char * synctex_io_modes[4] = {
"r",
"rb",
"a",
"ab"};
500 return synctex_io_modes[index];