#endif
#pragma warning(disable:4996)
+#include <kpathsea/kpathsea.h>
#pragma warning(disable:4131) // old style declarator
#pragma warning(disable:4135) // conversion between different integral types
#pragma warning(disable:4127) // conditional expression is constant
#define BUILDNAMEDIRECT /* avoid malloc for string concat */
-bool test_read_access (unsigned char *, int); /* in ourpaths.c - bkph */
-
extern char *unixify (char *); /* in pathsrch.c bkph */
-extern void try_and_open (char *); /* in local.c bkph */
-
extern int shorten_file_name; /* in local.c bkph */
#ifdef FUNNY_CORE_DUMP
-/* This is defined in ./texmf.c. */
-extern void funny_core_dump();
-#endif /* FUNNY_CORE_DUMP */
+ extern void funny_core_dump();
+#endif
#ifdef MSDOS
#ifdef BUILDNAMEDIRECT
-/* kpathsea/concat.c */
-/* kpathsea/concat3.c */
-/* similar to concat, but AVOIDS using malloc, pass in place to put result */
+// similar to concat, but AVOIDS using malloc, pass in place to put result
char *xconcat (char *buffer, char *s1, char *s2)
{
int n1 = strlen(s1);
if (buffer == s2)
{
- memmove (buffer + n1, buffer, n2 + 1); /* trailing null ! */
+ memmove (buffer + n1, buffer, n2 + 1);
strncpy (buffer, s1, n1);
}
else
return buffer;
}
-/* similar to concat3, but avoids using malloc, pass in place to put result */
+// similar to concat3, but avoids using malloc, pass in place to put result
char *xconcat3 (char *buffer, char *s1, char *s2, char *s3)
{
int n1 = strlen(s1);
int n3 = strlen(s3);
if (buffer == s3)
- { /* treat special case of overlap */
- memmove (buffer + n1 + n2, buffer, n3 + 1); /* trailing null ! */
+ {
+ memmove (buffer + n1 + n2, buffer, n3 + 1);
strncpy (buffer, s1, n1);
strncpy (buffer + n1, s2, n2);
}
strcat(buffer + n1, s2);
strcat(buffer + n1 + n2, s3);
}
+
return buffer;
}
-#endif /* end of BUILDNAMEDIRECT */
+#endif
-#endif /* end of ifdef MSDOS ??? */
+#endif
#ifdef MSDOS
-/* separated out 1996/Jan/20 to make easier to read */
-/* assumes path does not end in PATH_SEP */
+// separated out 1996/Jan/20 to make easier to read
+// assumes path does not end in PATH_SEP
void patch_in_path (unsigned char *buffer, unsigned char *name, unsigned char *path)
{
#ifdef BUILDNAMEDIRECT
xconcat3((char *) buffer, (char *) path, PATH_SEP_STRING, (char *) name);
#else
string temp_name;
- temp_name = concat3 (path, PATH_SEP_STRING, name);
+ temp_name = concat3(path, PATH_SEP_STRING, name);
strcpy (buffer, temp_name);
free (temp_name);
#endif
}
#endif /* end of MSDOS */
-/* Following works on null-terminated strings */
-
+// Following works on null-terminated strings
void check_short_name (unsigned char *s)
{
unsigned char *star, *sdot;
bool open_input (FILE **f, path_constant_type path_index, char *fopen_mode)
{
bool openable = false;
+ char * file_name = NULL;
#if defined (FUNNY_CORE_DUMP) && !defined (BibTeX)
if (path_index == TEXINPUTPATH &&
- strncmp (name_of_file + 1, "HackyInputFileNameForCoreDump.tex", 33) == 0)
+ strncmp (name_of_file + 1, "HackyInputFileNameForCoreDump.tex", 33) == 0)
funny_core_dump();
#endif /* FUNNY_CORE_DUMP and not BibTeX */
show_line(log_line, 0);
}
- if (test_read_access(name_of_file + 1, path_index))
+ switch (path_index)
{
- *f = xfopen((char *) name_of_file + 1, fopen_mode);
+ case TEXINPUTPATH:
+ file_name = kpse_find_file((const_string)name_of_file + 1, kpse_tex_format, 0);
+ break;
+ case TEXFORMATPATH:
+ file_name = kpse_find_file((const_string)name_of_file + 1, kpse_fmt_format, 0);
+ break;
+ case TFMFILEPATH:
+ file_name = kpse_find_file((const_string)name_of_file + 1, kpse_tfm_format, 0);
+ break;
+ }
+
+ if (file_name != NULL)
+ {
+ strcpy ((char *)name_of_file + 1, file_name);
+ *f = xfopen((char *) file_name, fopen_mode);
#ifdef MSDOS
if (name_of_file[1] == '.' && (name_of_file[2] == PATH_SEP || name_of_file[2] == '\\'))
else
name_length = strlen((char *) name_of_file + 1);
-#ifdef TeX
if (path_index == TFMFILEPATH)
{
tfm_temp = getc (*f);
- }
-#endif /* TeX */
+ }
#ifdef MSDOS
if (strstr((char *) name_of_file + 1, ".fmt") != NULL)
format_file = xstrdup((char *) name_of_file + 1);
}
}
- else if (strstr((char *)name_of_file + 1, ".poo") != NULL)
- {
- if (string_file == NULL)
- {
- string_file = xstrdup((char *) name_of_file + 1);
- }
- }
else if (strstr((char *)name_of_file+1, ".tfm") != NULL)
{
if (show_tfm_flag && log_opened)
fprintf(log_file, "(%s)", name_of_file + 1);
file_offset += n+3;
-/* space_terminate (name_of_file + 1); */
#endif /* end of WRAPLINES */
}
}
#endif /* end of MSDOS */
openable = true;
}
-/* space_terminate (name_of_file + 1); */
+
{
unsigned temp_length = strlen((char *) name_of_file + 1);
name_of_file[temp_length + 1] = ' '; /* space terminate */
-/* set up name_length ??? */
}
return openable;
{
unsigned temp_length;
- name_of_file[name_length + 1] = '\0'; /* null terminate */
+ name_of_file[name_length + 1] = '\0';
if (pseudo_tilde != 0 || pseudo_space != 0)
{
#endif
#ifdef MSDOS
-
if (prepend_path_if (name_of_file + 1, name_of_file + 1, ".dvi", (unsigned char *) dvi_directory) ||
prepend_path_if (name_of_file + 1, name_of_file + 1, ".log", (unsigned char *) log_directory) ||
prepend_path_if (name_of_file + 1, name_of_file + 1, ".aux", (unsigned char *) aux_directory) ||
unixify(log_line);
dvi_file_name = xstrdup(log_line);
}
+ else if (strstr((char *) name_of_file + 1, ".pdf") != NULL)
+ {
+ if (qualified(name_of_file + 1))
+ *log_line = '\0';
+ else
+ {
+ (void) _getcwd(log_line, sizeof(log_line));
+ strcat(log_line, PATH_SEP_STRING);
+ }
+
+ strcat(log_line, (char*) name_of_file + 1);
+ unixify(log_line);
+ pdf_file_name = xstrdup(log_line);
+ }
else if (strstr((char *)name_of_file + 1, ".log") != NULL)
{
if (qualified(name_of_file + 1))