<..script for dvigif..>
if( debug ){ (IGNORED) printf(".......’G’ script\n"); }
dvigif_script = add_script(dvigif_script);
-_-_-
<..process gif’s..>
{ BOOL characters, skip;
characters = skip = FALSE;
while( TRUE ) {
status = scan_until_str("--- ", 1, TRUE, lg_file);
status = scan_until_str( " ---" , 2, status, lg_file);
if( status ) {
if( eq_str(match[1],"--- ") ){
if( eq_str(match[2],"needs ---") ){
<.--- needs ---....>
} else if( eq_str(match[2],"characters ---") ){
<.--- characters ---....>
} else { <.--- ??? ---....> }
} else { <.???--- needs ---....> }
}
if ( eoln_ch == EOF ){ break; }
} }
-_-_-
<..--- ??? ---.....>
status = scan_until_end_str("", 1, status, lg_file);
-_-_-
<..???--- ??? ---.....>
status = scan_until_end_str("", 1, status, lg_file);
-_-_-
<..--- characters ---.....>
status = scan_until_end_str("", 1, status, lg_file);
characters = eq_str(match[1],"");
-_-_-
<..--- needs ---.....>
status = scan_until_str(" ", 1, status, lg_file);
status = scan_until_str(".idv", 1, status, lg_file);
status = scan_until_str("[", 2, status, lg_file);
status = scan_until_str("] ==> ", 2, status, lg_file);
status = scan_until_str(" ", 3, status, lg_file);
*(match[3] + (int) strlen((char *) match[3]) - 1) = ’\0’;
status = scan_until_end_str("---", 4, status, lg_file);
if( status ) {
<.dvi2gif vars.>
long int gif_i;
Q_CHAR *p;
gif_i = get_long_int(match[2]);
p = match[2];
*(p + (int) strlen((char *) p) - 6) = ’\0’;
if( characters ){
<.translate symbol gifs.>
} else { <.translate non-symbol gifs.> }
}
-_-_-
‘--- needs --- aa.idv[80] ==> aa79x.gif ---’
<..translate non-symbol gifs..>
if( gif_i == <.empty picture.> ) {
<.insert empty picture.>
} else { <.insert non-empty picture.> }
-_-_-
<..insert non-empty picture..>
if( !nopict && !skip ){
<.dvi into gif.>
}
-_-_-
<..insert empty picture..>
if( !skip ){
(void) execute_script(empty_fig_script,
(dir && !bitmaps_no_dm )? dir :"", match[3],"","");
if( ch_mod && !bitmaps_no_dm && !system_return ){
(void) execute_script(chmod_script, ch_mod,
dir?dir:"",match[3], "");
}
}
empty_pic = empty_pic->next;
-_-_-
<..empty picture..>
empty_pic->n
-_-_-
<..translate symbol gifs..>
Q_CHAR filename[255];
FILE* file;
(IGNORED) strcpy((char *) filename, "");
if( dir && !bitmaps_no_dm ){ (IGNORED) strct(filename, dir); }
(IGNORED) strct(filename, match[3]);
file = fopen(filename, READ_TEXT_FLAGS);
if( !file || noreuse ){
<.dvi symbols into gif.>
} else {
(IGNORED) fclose(file);
if( newchmod )
{ <.chmod for glyphs.> }
(IGNORED) printf("%s already in %s\n", match[3],
dir? dir : "current directory" );
}
-_-_-
<..dvi into gif..>
filtered_dvigif_script = filterGifScript(dvigif_script, match[3]);
(void) execute_script(
filtered_dvigif_script,match[1],match[2],match[3],job_name);
(void) free_script( filtered_dvigif_script );
if( dir && !bitmaps_no_dm && !system_return ){
(void) execute_script(move_script,match[3],dir,".","");
}
if( ch_mod && !bitmaps_no_dm && !system_return ){
(void) execute_script(chmod_script, ch_mod, dir?dir:"",match[3], "");
}
-_-_-
<..dvi symbols into gif..>
filtered_dvigif_script = dvigif_glyp_script?
filterGifScript(dvigif_glyp_script, match[3]):
filterGifScript(dvigif_script, match[3]);
(void) execute_script(
filtered_dvigif_script,match[1],match[2],match[3],job_name);
(void) free_script( filtered_dvigif_script );
if( dir && !bitmaps_no_dm && !system_return ){
(void) execute_script(move_script,match[3],dir,".","");
<.chmod for glyphs.>
}
-_-_-
<..chmod for glyphs..>
if( ch_mod && !bitmaps_no_dm && !system_return ){
(void) execute_script(chmod_script, ch_mod, dir?dir:"",match[3], "");
}
-_-_-
<..dvi2gif vars..>
struct script_struct
* filtered_dvigif_script = NULL_SCRIPT;
-_-_-
<..header functions..>+
static void execute_script(
ARG_V(struct script_struct*,const Q_CHAR *,const Q_CHAR *,const Q_CHAR *,const Q_CHAR *) );
-_-_-
<..functions..>+
static void execute_script(script,match_1,match_2,match_3,match_4)
struct script_struct* script;
const Q_CHAR * match_1;
const Q_CHAR * match_2;
const Q_CHAR * match_3;
const Q_CHAR * match_4
;{ struct script_struct* temp;
Q_CHAR *p, *q;
const Q_CHAR *t;
<.texmf := ....>
temp = script; system_return = 0;
while( temp ){
<.command = temp-command.>
if( (command[0] != ’\0’) && !system_return ){
<.execute system command.> }
temp = temp->next;
} }
-_-_-
We went to ‘%%%’, ‘%%1’, ... instead of ‘%%’, ‘%1’, ... to accomodate some needds of dos. Example (yet, where exactly the conflict is?):
<..command = temp-command..>
p = temp->command;
q = command;
while( *p != ’\0’ ){
*q = *(p++);
if( (*q == ’%’) && (*p == ’%’)
&& ( (*(p+1) == ’%’)
|| (*(p+1) == ’~’)
|| ( (*(p+1) >= ’0’) && (*(p+1) < ’5’) ) )
){ p++;
switch( *(p++) ){
case ’%’:{ q++; break; }
case ’0’:{ t = job_name;
while( *t != ’\0’ ){ *(q++) = *(t++); } break; }
case ’1’:{ t = match_1;
while( *t != ’\0’ ){ *(q++) = *(t++); } break; }
case ’2’:{ t = match_2;
while( *t != ’\0’ ){ *(q++) = *(t++); } break; }
case ’3’:{ t = match_3;
while( *t != ’\0’ ){ *(q++) = *(t++); } break; }
case ’4’:{ t = match_4;
while( *t != ’\0’ ){ *(q++) = *(t++); } break; }
case ’~’:{ <.q += texmf path.> break; }
default: { }
}} else { q++; }
}
*q = ’\0’;
-_-_-
The argument ‘%%~’ is replaced with the value of ${SELFAUTOPARENT} under KPATHSEA. If such a value is not available, the character ‘~’ is used. The variable offers the grandparent directory of where texmf resides.
<..texmf := .....>
#ifdef KPATHSEA
const char * texmf = kpse_var_value( "SELFAUTOPARENT" );
#endif
-_-_-
<..q += texmf path..>
#ifdef KPATHSEA
if( texmf ){
t = texmf;
while( *t != ’\0’ ){ *(q++) = *(t++); }
} else {
*(q++) = ’~’;
}
#else
*(q++) = ’~’;
#endif
-_-_-
<..defines..>+
#ifndef HTFDIR
#define HTFDIR ""
#endif
-_-_-
Three cases for ‘G’ and ‘F’ scripts.
<..header functions..>+
static struct script_struct * filterGifScript(
ARG_II( struct script_struct *, Q_CHAR *) );
-_-_-
<..functions..>+
static struct script_struct * filterGifScript( script, file)
struct script_struct *script;
Q_CHAR *file
;{
struct script_struct *filtered_script, *scr,
*old_script,
*new_script;
Q_CHAR *command, *ext;
filtered_script = NULL_SCRIPT;
if( script == NULL_SCRIPT )
return filtered_script;
old_script = script;
command = old_script->command;
if( *command != ’.’ ){
<.script until dot.>
} else {
<.script from dot.>
}
}
-_-_-
<..script until dot..>
new_script = NULL_SCRIPT;
while( old_script != NULL_SCRIPT ){
command = old_script->command;
if( *command == ’.’ ){ return filtered_script; }
scr = (struct script_struct *)
m_alloc(struct script_struct, (int) 1);
scr->command = old_script->command;
scr->next = NULL_SCRIPT;
if( new_script == NULL_SCRIPT ){
filtered_script = new_script = scr;
} else {
new_script = new_script->next = scr;
}
old_script = old_script->next;
}
return filtered_script;
-_-_-
<..script from dot..>
<.ext = file ext.>
while( TRUE ){
if( old_script == NULL_SCRIPT ){
return NULL_SCRIPT;
}
command = old_script->command;
if(*command != ’.’) {
old_script = old_script->next;
continue;
}
old_script = old_script->next;
if( (*(command+1) == ’\0’) || eq_str(ext,command) ){
break;
}
}
<.script until dot.>
-_-_-
<..ext = file ext..>
ext = file;
while( *ext != ’\0’ ){ ext++; }
while( (*ext != ’.’) && (ext != file) ){ ext--; }
-_-_-
<..header functions..>+
void free_script(
ARG_I( struct script_struct *) );
-_-_-
<..functions..>+
void free_script(script)
struct script_struct *script
;{
struct script_struct *temp;
while( script != NULL_SCRIPT ){
temp = script;
script = script->next;
free( temp );
}
}
-_-_-
<..???--- ??? ---.....>+
status = scan_until_end_str("", 1, status, lg_file);
-_-_-
We didn’t check below the ‘l. dddd ’ part.
<..???--- needs ---.....>
status = scan_until_end_str(" ignore ---", 2, status, lg_file);
if( status ){
skip = eq_str(match[2]," ignore ---") ? TRUE :
( eq_str(match[2]," end ignore ---") ? FALSE : skip );
}
-_-_-