1 Outline

      The Cases
      char, signed char, unsigned char (gcc man)
      EOF Character

The Cases

The post-processor ‘tex4ht.c’ prepares a ‘.lg’ file in which it lists the pictures that need to be generated, and the entries encountered in \Needs{...}. The ‘.log’ file contains the entries encountered in the \Needs-{...}. The t4ht program (used to be a Perl script?) treats as commands the entries that are enclosed between double-quote (") characters, and the other entries as comments. It first works on the ‘.lg’ file and then on the ‘.log’ file. The main output is a new ‘.css’.

<..main’s body..>
 <.load env file.>
 lg_file = open_file(lg_name,LG_EXT);
 if( lg_file ) {
    <.mark start lg file.>
    <.rewind lg file.>  <.stop, if tex4ht.c err.>
    <.rewind lg file.>  <.CopyTo files.>
    <.rewind lg file.>  <.htfcss from lg.>
    <.rewind lg file.>  <.font=(...) from lg.>
    <.rewind lg file.>  <.identify the empty pictures.>
    <.rewind lg file.>  <.process gif’s.>
    <.rewind lg file.>  <.process css.>
    <.rewind lg file.>  <.post-process ext files.>
    <.rewind lg file.>  <.post-process files.>
    <.rewind lg file.>  <.mv lg/File to dir and chmod.>
    <.rewind lg file.>  <.process user commands.>
    (IGNORED) fclose(lg_file);
 }
 -_-_-

<..mv lg/File to dir and chmod..>
 eoln_ch = (int) ’x’;
 while( eoln_ch != EOF ) {
    status = scan_str("File: ", TRUE, lg_file);
    status = scan_until_end_str("", 1, status, lg_file);
    status = status && !eq_str(match[1],tmp_name);
    if( status ){
                     FILE* file;
      file = fopen(match[1], READ_TEXT_FLAGS);
      if( file ){
         (IGNORED) fclose(file);
      } else { status = FALSE; }
    }
    if( status ){
       if( dir ){
          (void) execute_script(copy_script, match[1],
                                dir? dir :"",".","");
       }
       if( ch_mod ){
          (void) execute_script(chmod_script, ch_mod,
                                dir? dir:"",match[1], "");
       }
 }  }
 -_-_-

<..TeX4ht copyright..>
 %
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License, either
 % version 1.3c of this license or (at your option) any
 % later version. The latest version of this license is in
 %   http://www.latex-project.org/lppl.txt
 % and version 1.3c or later is part of all distributions
 % of LaTeX version 2005/12/01 or later.
 %
 % This work has the LPPL maintenance status "maintained".
 %
 % The Current Maintainer of this work
 % is the TeX4ht Project <http://tug.org/tex4ht>.
 %
 % If you modify this program, changing the
 % version identification would be appreciated.-_-_-

<..TeX4ht copywrite..>
 |<TeX4ht copyright|>\immediate\write-1{version |version}
 -_-_-

<..t4ht.c..>
 /* t4ht.c (2014-05-24-12:31), generated from tex4ht-t4ht.tex
    Copyright (C) 2009-2012 TeX Users Group
    Copyright (C) 1998-2009 Eitan M. Gurari
 <.TeX4ht copyright.>
 */
 <.t4ht.h.>
 <.defines.>
 <.vars.>
 <.header functions.>
 <.functions.>
 
 int <.CDECL.> main(argc, argv)
        int  argc;
        Q_CHAR **argv
 ;{ <.main’s vars.>
    <.resplit argv for windows.>
    <.set signals.>
    <.program signature.>
    <.main’s init.>
 
   <.scan job args.>
    <.main’s body.>
    return 0;
 }
 -_-_-

<..program signature..>
 (IGNORED) printf("----------------------------\n");
 #ifndef KPATHSEA
 #ifdef PLATFORM
    (IGNORED) printf("t4ht.c (2014-05-24-12:31 %s)\n",PLATFORM);
 #else
    (IGNORED) printf("t4ht.c (2014-05-24-12:31)\n");
 #endif
 #else
 #ifdef PLATFORM
    (IGNORED) printf("t4ht.c (2014-05-24-12:31 %s kpathsea)\n",PLATFORM);
 #else
    (IGNORED) printf("t4ht.c (2014-05-24-12:31 kpathsea)\n");
 #endif
 #endif
 
 <.handle quoted arguments.>
 { int i;
   for(i=0; i<argc; i++){
     (IGNORED) printf("%s%s ", (i>1)?"\n  " : "", argv[i]); }
   (IGNORED) printf("\n");
 }
 -_-_-

char, signed char, unsigned char (gcc man)

:

Each kind of machine has a default for what char should be. It is either like unsigned char by default or like signed char by default.

Ideally, a portable program should always use signed char or unsigned char when it depends on the signedness of an object. But many programs have been written to use plain char and expect it to be signed, or expect it to be unsigned, depending on the machines they were written for. This option, and its inverse, let you make such a program work with the opposite default.

The type char is always a distinct type from each of signed char and unsigned char, even though its behavior is always just like one of those two.

<..definesNO..>
 #define Q_CHAR signed char
 #define U_CHAR unsigned char
 #define C_CHAR char
 #define Q_NULL (Q_CHAR *) 0
 #define U_NULL (U_CHAR *) 0
 #define C_NULL (C_CHAR *) 0
 -_-_-

Pointers to strings must use ‘C_CHAR’, since we don’t know how string constants are treated there.

<..defines..>
 #define Q_CHAR char
 #define U_CHAR char
 #define C_CHAR char
 #define Q_NULL (Q_CHAR *) 0
 #define U_NULL (U_CHAR *) 0
 #define C_NULL (C_CHAR *) 0
 -_-_-

EOF Character

<..vars..>
 static int eoln_ch;
 -_-_-

OBTW: when compiling t4ht.c, I get messages about the uselessness of comparing 
chars (which are unsigned, at least on a IRIX 6.5) to EOF which is defined as 
-1 in stdio.h).... and indeed it program loops endlessly. 
Adding the lines 
   #undef EOF 
   #define EOF 255 
after the last #include gets the effect that you probably want (or perhaps 
better would be to define a constant EOFCHAR or something.) 

The getc returns the next character as an unsigned char converted to int. This is so to allow all characters to be return as well as end-of-file indicators (-1 in stdio) and error indicator.