OSDN Git Service

code clean.
[putex/putex.git] / src / texsourc / openinou.c
index f171ec5..4b5ee16 100644 (file)
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301 USA.  */
 
-#ifdef _WINDOWS
-  #define NOCOMM
-  #define NOSOUND
-  #define NODRIVERS
-  #define STRICT
-  #pragma warning(disable:4115) // kill rpcasync.h complaint
-  #include <windows.h>
-  #define MYLIBAPI __declspec(dllexport)
-#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
-
-#include <setjmp.h>
-
-#include <direct.h>           /* for _getcwd() */
-
 #define EXTERN extern
 
 #include "texd.h"
@@ -56,11 +36,9 @@ extern int shorten_file_name;       /* in local.c bkph */
   extern void funny_core_dump();
 #endif
 
-#ifdef MSDOS
 
 #ifdef BUILDNAMEDIRECT
-// similar to concat, but AVOIDS using malloc, pass in place to put result
-char *xconcat (char *buffer, char *s1, char *s2)
+char * xconcat (char *buffer, char *s1, char *s2)
 {
   int n1 = strlen(s1);
   int n2 = strlen(s2);
@@ -78,8 +56,7 @@ char *xconcat (char *buffer, char *s1, char *s2)
 
   return buffer;
 }
-// similar to concat3, but avoids using malloc, pass in place to put result
-char *xconcat3 (char *buffer, char *s1, char *s2, char *s3)
+char * xconcat3 (char *buffer, char *s1, char *s2, char *s3)
 {
   int n1 = strlen(s1);
   int n2 = strlen(s2);
@@ -102,24 +79,14 @@ char *xconcat3 (char *buffer, char *s1, char *s2, char *s3)
 }
 #endif
 
-#endif
-
-#ifdef MSDOS
 // 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
   if (*path == '\0')
     strcpy((char *) buffer, (char *) name);
   else
     xconcat3((char *) buffer, (char *) path, PATH_SEP_STRING, (char *) name);
-#else
-  string temp_name;
-  temp_name = concat3(path, PATH_SEP_STRING, name);
-  strcpy (buffer, temp_name);
-  free (temp_name);
-#endif
 }
 
 int qualified (unsigned char * name)
@@ -154,7 +121,7 @@ int prepend_path_if (unsigned char *buffer, unsigned char *name, char *ext, unsi
 
   return 1;
 }
-#endif      /* end of MSDOS */
+
 
 //  Following works on null-terminated strings
 void check_short_name (unsigned char *s)
@@ -219,56 +186,51 @@ bool open_input (FILE **f, path_constant_type path_index, char *fopen_mode)
   if (path_index == TEXINPUTPATH &&
     strncmp (name_of_file + 1, "HackyInputFileNameForCoreDump.tex", 33) == 0)
     funny_core_dump();
-#endif /* FUNNY_CORE_DUMP and not BibTeX */
+#endif
 
-#ifdef MSDOS
   if (return_flag)
   {
     if (strcmp(fopen_mode, "r") == 0)
       fopen_mode = "rb";    /* so can catch `return' bkph */
   }
-#endif /* MSDOS */
 
-  name_of_file[name_length + 1] = '\0'; /* null terminate */
+  name_of_file[name_length + 1] = '\0';
 
 /* reinsert '~' and ' ' in file names -  95/June/5 */
 /* done late to prevent problems with  null_terminate / space_terminate */  
   if (pseudo_tilde != 0 || pseudo_space != 0)
     retwiddle(name_of_file + 1);
 
-#ifdef MSDOS
-/* 8 + 3 file names on Windows NT 95/Feb/20 */
   if (shorten_file_name)
   {
     check_short_name(name_of_file + 1);
   }
-#endif  /* MSDOS */
   
   if (open_trace_flag)
   {
-    sprintf(log_line, " Open `%s' for input ", name_of_file + 1); /* Pascal */
+    sprintf(log_line, " Open `%s' for input ", name_of_file + 1);
     show_line(log_line, 0);
   }
 
   switch (path_index)
   {
     case TEXINPUTPATH:
-      file_name = kpse_find_file((const_string)name_of_file + 1, kpse_tex_format, 0);
+      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);
+      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);
+      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);
+    strcpy ((char *) name_of_file + 1, file_name);
     *f = xfopen((char *) file_name, fopen_mode);
 
-#ifdef MSDOS
+#ifdef _WIN32
     if (name_of_file[1] == '.' && (name_of_file[2] == PATH_SEP || name_of_file[2] == '\\'))
 #else
     if (name_of_file[1] == '.' && name_of_file[2] == PATH_SEP)
@@ -293,7 +255,6 @@ bool open_input (FILE **f, path_constant_type path_index, char *fopen_mode)
       tfm_temp = getc (*f);
     } 
 
-#ifdef MSDOS
     if (strstr((char *) name_of_file + 1, ".fmt") != NULL)
     {
       if (format_file == NULL)
@@ -305,19 +266,6 @@ bool open_input (FILE **f, path_constant_type path_index, char *fopen_mode)
     {
       if (show_tfm_flag && log_opened)
       {
-#ifdef WRAPLINES
-        int old_setting = selector;
-        char *s = name_of_file + 1;
-        selector = log_only;
-        print_char(' ');
-        print_char('(');
-
-        while (*s != '\0')
-          print_char (*s++);
-
-        print_char(')');
-        selector = old_setting;
-#else
         int n; 
         n = strlen((char *) name_of_file + 1);
 
@@ -330,8 +278,7 @@ bool open_input (FILE **f, path_constant_type path_index, char *fopen_mode)
           putc(' ', log_file);
 
         fprintf(log_file, "(%s)", name_of_file + 1);
-        file_offset += n+3;
-#endif  /*  end of WRAPLINES */
+        file_offset += n + 3;
       }
     }
 /*    code added 98/Sep/29 to catch first file input */
@@ -359,7 +306,7 @@ bool open_input (FILE **f, path_constant_type path_index, char *fopen_mode)
         show_line(log_line, 0);
       }
     }
-#endif  /* end of MSDOS */
+
     openable = true;
   }
 
@@ -375,21 +322,13 @@ bool open_input (FILE **f, path_constant_type path_index, char *fopen_mode)
 /* This nonsense probably only works for Unix anyway. bkph */
 /* For one thing, MakeTeXTFM etc is more than 8 characters ! */
 
-#ifdef MSDOS
-  #define NO_MAKETEX
-#endif
-
-#define TEXONLY
-
 char *get_env_shroud (char *);    /* defined in texmf.c */
 
-/* char outputdirectory[PATH_MAX]; */       /* defined in local.c */
-
-extern char * dvi_directory; /* defined in local.c */
-extern char * log_directory; /* defined in local.c */
-extern char * aux_directory; /* defined in local.c */
-extern char * fmt_directory; /* defined in local.c */
-extern char * pdf_directory; /* defined in local.c */
+extern char * dvi_directory;
+extern char * log_directory;
+extern char * aux_directory;
+extern char * fmt_directory;
+extern char * pdf_directory;
 
 /* At least check for I/O error (such as disk full) when closing */
 /* Would be better to check while writing - but this is better than nothing */
@@ -398,10 +337,9 @@ extern char * pdf_directory; /* defined in local.c */
 /* now a_close returns -1 on error --- which could be used by caller */
 /* probably want to ignore on input files ... */
 
-void perrormod (char *s);       /* in local.c */
+extern void perrormod (char *s);       /* in local.c */
 
 // check_fclose not used by anything
-/* 1993/Nov/20 - bkph */
 int check_fclose (FILE * f)
 {
   if (f == NULL)
@@ -410,14 +348,13 @@ int check_fclose (FILE * f)
   if (ferror(f) || fclose (f))
   {
     perrormod("\n! I/O Error");
-    uexit (1);    // ???
+    uexit (1);
   }
 
   return 0;
 }
 
-/* open_output moved down here to avoid potential pragma problem */
-
+// open_output moved down here to avoid potential pragma problem
 bool open_output (FILE **f, char *fopen_mode)
 {
   unsigned temp_length;
@@ -429,15 +366,12 @@ bool open_output (FILE **f, char *fopen_mode)
     retwiddle(name_of_file + 1);
   }
 
-#ifdef MSDOS
 /* 8 + 3 file names on Windows NT 95/Feb/20 */
   if (shorten_file_name)
   {
     check_short_name(name_of_file + 1);
   }
-#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) ||
@@ -446,11 +380,10 @@ bool open_output (FILE **f, char *fopen_mode)
   {
     if (open_trace_flag)
     {
-      sprintf(log_line, "After prepend %s\n", name_of_file+1);
+      sprintf(log_line, "After prepend %s\n", name_of_file + 1);
       show_line(log_line, 0);
     }
   }
-#endif
 
   if (open_trace_flag)
   {
@@ -460,7 +393,6 @@ bool open_output (FILE **f, char *fopen_mode)
 
 /* Is the filename openable as given?  */
 
-/*  if share_flag is non-zero and we are opening for reading use fsopen */
 /*  but we can assume this is opening here for *output* */
   *f = fopen((char *) name_of_file + 1, fopen_mode);
 
@@ -482,7 +414,7 @@ bool open_output (FILE **f, char *fopen_mode)
 #endif
       if (deslash)
         unixify((char *) temp_name);     /* deslashify 93/Dec/28 */
-/*  If share_flag is non-zero and we are opening for reading use fsopen */
+
 /*  but we can assume this is opening here for *output* */
       *f = fopen((char*)temp_name, fopen_mode);
 /*  If this succeeded, change name_of_file accordingly.  */
@@ -500,7 +432,7 @@ bool open_output (FILE **f, char *fopen_mode)
       *log_line = '\0';
     else
     {
-      (void) _getcwd(log_line, sizeof(log_line));
+      (void) getcwd(log_line, sizeof(log_line));
       strcat(log_line, PATH_SEP_STRING);
     }
 
@@ -514,7 +446,7 @@ bool open_output (FILE **f, char *fopen_mode)
       *log_line = '\0';
     else
     {
-      (void) _getcwd(log_line, sizeof(log_line));
+      (void) getcwd(log_line, sizeof(log_line));
       strcat(log_line, PATH_SEP_STRING);
     }
 
@@ -528,7 +460,7 @@ bool open_output (FILE **f, char *fopen_mode)
       *log_line = '\0';
     else
     {
-      (void) _getcwd(log_line, sizeof(log_line));
+      (void) getcwd(log_line, sizeof(log_line));
       strcat(log_line, PATH_SEP_STRING);
     }