3 Platform-dependent Code

      PreProcessor Directives
      KPATHSEA
      Compilers
      DJGPP
      Slashes n Directory Pathes

PreProcessor Directives

Symantec C++ for wid95: sc t4ht.c -mn -o+time -WA -3 -a8 -c -D_CONSOLE=1 -ot4ht.obj

<..defines..>+
 #define IGNORED void
 -_-_-

<..t4ht.h..>
 /* **********************************************
     Compiler options                            *
     (uncommented | command line)                *
 ------------------------------------------------*
        Classic C (CC)             default
 #define ANSI                      ansi-c, c++
 #define DOS_C
 #define HAVE_STRING_H             <string.h>
 #define HAVE_DIRENT_H             <dirent.h>
 #define HAVE_SYS_NDIR_H           <sys/ndir.h>
 #define HAVE_SYS_DIR_H            <sys/dir.h>
 #define HAVE_NDIR_H               <ndir.h>
 #define HAVE_IO_H                 <io.h>
 #define HAVE_UNISTD_H             <unistd.h>
 #define WIN32
 #define KPATHSEA
 #define SYSTEM_FUNCTION_OK
 #define CDECL                    ..........
 #define BCC32                    bordland c++
 
 *************************************************
     Tex4ht variables                            *
     (uncommented | command line)                *
 ----------------------------------------------- */
 <.h-defines.>
 /* ******************************************** */
 <.define MSVC-1-52.>
 <.bordland: bcc32 -DBCC32 t4ht.>
 <.bordland: bcc -DBCC tex4ht.>
 <.DJGPP.>
 #ifdef DOS_C
 #define DOS
 #endif
 #ifdef DOS
 #define DOS_WIN32
 #ifndef HAVE_STRING_H
 #define HAVE_STRING_H
 #endif
 #endif
 #ifdef WIN32
 #define DOS_WIN32
 #endif
 <.h-defines DOS-WIN32.>
 <.h-defines KWIN32.>
 <.h-include.>
 <.h-defines 2.>
 -_-_-

<..bordland: bcc32 -DBCC32 t4ht..>
 #ifdef BCC32
 #define WIN32
 #define ANSI
 #define HAVE_IO_H
 #define HAVE_STRING_H
 #define PLATFORM "ms-win32"
 #endif
 -_-_-

<..bordland: bcc -DBCC tex4ht..>
 #ifdef BCC
 #define DOS_C
 #define ANSI
 #define HAVE_IO_H
 #define PLATFORM "ms-dos"
 #endif
 -_-_-

<..h-include..>
 #ifdef KPATHSEA
 #include <kpathsea/config.h>
 #endif
 #include <stdio.h>    EOF, FILE 
 #include <stdlib.h>   EXIT_FAILURE 
 -_-_-

Under ANSI C, all malloc stuff is declared in ‘<stdlib.h>’ (which you also include), hence this non-standard header is redundant.

<..defines..>+
 #ifndef EXIT_FAILURE
 #define EXIT_FAILURE 1
 #endif
 -_-_-

<..h-include..>+
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
 -_-_-

<..h-defines DOS-WIN32..>
 #ifdef DOS_WIN32
 #define STRUCT_DIRENT
 #endif
 -_-_-

<..h-include..>+
 #ifdef HAVE_DIRENT_H
 <.needs dirent.h.>
 #else
 #ifndef STRUCT_DIRENT
 #define STRUCT_DIRECT
 #endif
 <.needs simulated dirent.h.>
 #endif
 -_-_-

<..needs dirent.h..>
 #include <dirent.h>
 -_-_-

<..needs simulated dirent.h..>
 #ifdef HAVE_SYS_NDIR_H
 #include <sys/ndir.h>
 #endif
 #ifdef HAVE_SYS_DIR_H
 #include <sys/dir.h>
 #endif
 #ifdef HAVE_NDIR_H
 #include <ndir.h>
 #endif
 -_-_-

REPLACE EXIT with somthing that DOS also accept.

<..t4ht.h..>+
 #ifdef DOS
 #define PROTOTYP
 #endif
 #ifdef ANSI
 #define PROTOTYP
 #endif
 #ifdef KWIN32
 #define PROTOTYP
 #endif
 -_-_-

<..defines..>+
 #ifdef PROTOTYP
 #define MYVOID void
 #define ARG_I(x) x
 #define ARG_II(x,y) x,y
 #define ARG_III(x,y,z) x,y,z
 #define ARG_IV(x,y,z,w) x,y,z,w
 #define ARG_V(x,y,z,w,u) x,y,z,w,u
 #else
 #define MYVOID
 #define ARG_I(x)
 #define ARG_II(x,y)
 #define ARG_III(x,y,z)
 #define ARG_IV(x,y,z,w)
 #define ARG_V(x,y,z,w,u)
 #endif
 -_-_-

KPATHSEA

<..h-defines 2NO..>
 <.h-include before KPATHSEA.>
 #ifdef KPATHSEA
 #ifndef HAVE_STRCHR
 #define  strchr  index
 #endif
 #ifndef HAVE_STRRCHR
 #define  strrchr  rindex
 #endif
 #include <kpathsea/c-errno.h>
 #include <kpathsea/c-ctype.h>
 #include <kpathsea/c-fopen.h>
 #include <kpathsea/c-pathmx.h>
 #include <kpathsea/proginit.h>
 #include <kpathsea/tex-file.h>
 #include <kpathsea/tex-make.h>
 #include <kpathsea/variable.h>
 #include <signal.h>
 #if !defined(_AMIGA) && !defined(WIN32)
 #include <sys/time.h>
 #endif
 #include <fcntl.h>
 #include <setjmp.h>
 #endif /* KPATHSEA */
 <.h-include after KPATHSEA.>
 -_-_-

<..h-defines 2..>
 <.h-include before KPATHSEA.>
 #ifdef KPATHSEA
 #include <kpathsea/c-errno.h>
 #include <kpathsea/c-ctype.h>
 #include <kpathsea/c-fopen.h>
 #include <kpathsea/c-pathmx.h>
 #include <kpathsea/proginit.h>
 #include <kpathsea/tex-file.h>
 #include <kpathsea/tex-make.h>
 #include <kpathsea/variable.h>
 #include <signal.h>
 #if !defined(_AMIGA) && !defined(WIN32)
 #include <sys/time.h>
 #endif
 #include <fcntl.h>
 #include <setjmp.h>
 #endif /* KPATHSEA */
 <.h-include after KPATHSEA.>
 -_-_-

The ‘__cdecl’ is defined in KPATHSEA: kpathsea/c-protos.h is defined to nothing for compilers other than MS.

<..t4ht.h..>+
 #ifdef KPATHSEA
 #ifdef WIN32
 #undef CDECL
 #define CDECL                     __cdecl
 #else
 #define CDECL
 #endif
 #endif
 -_-_-

<..h-defines KWIN32..>
 #ifdef KPATHSEA
 #ifdef WIN32
 #define KWIN32
 #endif
 #endif
 -_-_-

Compilers

BCC32

For Win 95.

Options (bcc32 comamnd):

Borland C++ 5.0 for Win32 Copyright (c) 1993, 1996 Borland International 
Syntax is: BCC32 [ options ] file[s]     * = default; -x- = turn switch x off 
  -3    * 80386 Instructions        -4      80486 Instructions 
  -Ax     Disable extensions        -B      Compile via assembly 
  -C      Allow nested comments     -Dxxx   Define macro 
  -Exxx   Alternate Assembler name  -Hxxx   Use pre-compiled headers 
  -Ixxx   Include files directory   -K      Default char is unsigned 
  -Lxxx   Libraries directory       -M      Generate link map 
  -N      Check stack overflow      -Ox     Optimizations 
  -P      Force C++ compile         -R      Produce browser info 
  -RT   * Generate RTTI             -S      Produce assembly output 
  -Txxx   Set assembler option      -Uxxx   Undefine macro 
  -Vx     Virtual table control     -X      Suppress autodep. output 
  -aN     Align on N bytes          -b    * Treat enums as integers 
  -c      Compile only              -d      Merge duplicate strings 
  -exxx   Executable file name      -fxx    Floating point options 
  -gN     Stop after N warnings     -iN     Max. identifier length 
  -jN     Stop after N errors       -k    * Standard stack frame 
  -lx     Set linker option         -nxxx   Output file directory 
  -oxxx   Object file name          -p      Pascal calls 
  -tWxxx  Create Windows app        -u    * Underscores on externs 
  -v      Source level debugging    -wxxx   Warning control 
  -xxxx   Exception handling        -y      Produce line number info 
  -zxxx   Set segment names 
BCC

For DOS.

MSVC++

For DOS.

c:\msvc\bin\cl -Ic:\msvc\include -DDOS t4ht.c

In tex-live ‘ cl -D_X86_=1 -DWINVER=0x0400 -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN -D_MT -D_DLL -DKPATHSEA -D_IMPORT -DANSI -I. -I. -I.. -IG:\fptex\source\web2c-7.2 -c -W3 -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -O2x -G5rs -Gy -c /Fodynamic\t4ht.obj .\t4ht.c

The following are the available flags (c:\msvc\bin\cl -help).

                         C COMPILER OPTIONS 
 
                            -MEMORY MODEL- 
/AS small model (default)               /AC compact model 
/AM medium model                        /AL large model 
/AH huge model                          /AT tiny model (.COM files) 
/A<string> (custom memory model) 
                            -OPTIMIZATION- 
/O enable optimization (same as /Ot)    /O1 minimize space 
/O2 maximize speed                      /Oa assume no aliasing 
/Ob<n> inline expansion (default n=0)   /Oc local common subexpression opt. 
/Od disable optimization (default)      /Oe enable registers allocation 
/Of[-] toggle p-code quoting            /Og global common subexpression opt. 
/Oi enable intrinsic functions          /Ol enable loop optimizations 
/On disable ‘‘unsafe’’ optimizations      /Oo[-] toggle post code-gen. opt. 
/Op[-] improve floating-pt consistency  /Oq enable maximum p-code optimization 
/Or gen. common exit code (CodeView)    /Os favor code size 
/Ot favor code speed                    /Ov[-] toggle p-code frame sorting 
/OV<n> control inlining by func. size   /Ow assume cross-function aliasing 
/Ox maximum opts. (/Ob1cegilnot /Gs)    /Oz enable ‘‘unsafe’’ optimizations 
                          -CODE GENERATION- 
/G0 8086 instructions (default)         /G1  186 instructions 
/G2  286 instructions                   /G3  386 instructions 
  (press <return> to continue) 
/GA protected-mode Win entry/exit code  /GD protected-mode Win entry/exit code 
/GE<x> customize Windows entry/exit     /Gq backwards compatibility with v. 6 
/Gc Pascal style calling conventions    /Gd C style calling conventions 
/Ge use stack-check calls               /Gf enable string pooling 
/Ge use stack-check calls               /Gf enable string pooling 
/Gs remove stack-check calls            /Gn remove p-code native entry points 
/Gp<num> specify p-code entry tables    /Gr _fastcall style calling convention 
/Gt[num] data size threshold            /GW real-mode Windows entry/exit code 
/Gw real-mode Windows entry/exit code   /Gx assume that data is near 
/Gx- assume that data is far            /Gy separate functions for linker 
/Zr check null pointers (/f only) 
                            -OUTPUT FILES- 
/Fa[file] name assembly listing file    /Fc[file] name source/object listing 
/Fd[file] name .PDB filename            /Fe<file> name executable filename 
/Fl[file] name object listing filename  /Fm[file] name map filename 
/Fo<file> name object filename          /Fr[file] name .SBR filename 
/Fp<file> name .PCH filename            /FR[file] name extended .SBR filename 
/Fs[file] name source listing filename 
                            -PREPROCESSOR- 
/C don’t strip comments                 /D<name>[=|#text] define macro 
/E preprocess to stdout                 /EP same as /E but no #line 
/I<directory> add #include path         /P preprocess to file 
/U<name> remove predefined macro        /u remove all defined macros 
  (press <return> to continue) 
/X ignore "standard places" 
                              -LANGUAGE- 
/vd{0|1} disable/enable vtordisp        /vm<x> type of pointers to members 
/Z7 C 7 style CodeView information      /Za disable extensions (implies /Op) 
/Zd line number information             /Ze enable extensions (default) 
/Zg generate function prototypes        /Zi prepare for debugging (CodeView) 
/Zl omit default library name in .OBJ   /Zp[n] pack structs on n-byte boundary 
/Zs check syntax only 
                           -FLOATING POINT- 
/FPa calls with altmath                 /FPc calls with emulator 
/FPc87 calls with 8087 library          /FPi inline with emulator (default) 
/FPi87 inline with 8087 
                          -SOURCE LISTING- 
/Sl<columns> set line width             /Sp<lines> set page length 
/St<string> set title string            /Ss<string> set subtitle string 
                           -MISCELLANEOUS- 
/batch specify batch mode compilation   /Bm<num> set compiler’s available mem. 
/c compile only, no link                /H<num> external name length 
/J default char type is unsigned        /f select fast compiler (default) 
/f- select optimizing compiler          /Yc create .PCH file 
/Yd put debug info in .PCH file         /Yu use .PCH file 
/YX automatic precompiled header        /nologo suppress copyright message 
  (press <return> to continue) 
/Mq compile for QuickWin                /ND<name> name data segment 
/NM<name> name code segment             /NQ<name> combine p-code temp segments 
/NT<name> name code segment             /NV<name> name far v-table segment 
/Tc<file> compile file without .c       /Tp<file> compile file without .cpp 
/V<string> set version string           /W<n> warning level (default n=1) 
/w disable all warnings                 /WX treat all warnings as errors 
/Zn turn off SBRPACK for .SBR files 
                            -MASM SUPPORT- 
/MA<MASM switch>                        /Ta<file> assemble file without .asm 
                              -LINKING- 
/F <hex_num> stack size (hex. bytes)    /Lr append ’r’ to default lib in .OBJ 
/link [lib] give lib name to linker     /Ln do not link CRT.LIB 
/Ld select dynamically-linked library   /Lw select statically-linked library 

DJGPP

 
        * tex4ht.c [__DJGPP__] (ANSI, DOS_GIF_FILE): Define. 
        (WRITE_BIN_FLAGS, READ_BIN_FLAGS): Use binary mode with DJGPP. 
        (dos_file_names): New variable. 
        (sig_err): If got fatal signal other than SIGINT or SIGQUIT, don’t 
        return to caller, since the program will be aborted otherwise. 
        (main) [KPATHSEA]: If input is from stdin which is not a console 
        device, switch it to binary mode.  Set dos_file_names to TRUE for 
        all DOS platforms, FALSE on Unix and WIN32, and compute at runtime 
        for DJGPP.  Simplify logic of finding the init file by pushing 
        HOME=C: into environment if $HOME isn’t defined on DOSISH systems. 

<..DJGPP..>
 #ifdef __DJGPP__
 #define DOS_WIN32
 #define ANSI
 #endif
 -_-_-

<..DJGPP signals..>
 #ifdef __DJGPP__
   if (s != SIGINT && s != SIGQUIT)
     exit(EXIT_FAILURE);
 #endif
 -_-_-

Slashes n Directory Pathes

<..defines..>+
 #if defined(DOS_WIN32) || defined(__DJGPP__)
 #define dir_path_slash(str) (is_forward_slash(str)? ’/’ : ’\\’)
 #else
 #define dir_path_slash(str)  ’/’
 #endif
 -_-_-

<..header functions..>
 #if defined(DOS_WIN32) || defined(__DJGPP__)
    static BOOL is_forward_slash( ARG_I(Q_CHAR *) );
 #endif
 -_-_-

<..functions..>
 #if defined(DOS_WIN32) || defined(__DJGPP__)
 
 static BOOL is_forward_slash(str)
                                     Q_CHAR * str
 ;{
    while( *str ){  if( *(str++) == ’/’ ) { return TRUE; } }
    return FALSE;
 }
 #endif
 -_-_-