with some help from my neighbour, i got this working at last.... 
 
you had 
 
   if( *(p = gif_open[gif_flag]) ) IGNORED) strct(str,p); 
 
which we changed to 
 
   p = gif_open[gif_flag]; 
   if( p && *p) (IGNORED) strct(str,p); 
 
because if gif_open[fig_flag] is NULL (which you initialize it to 
be!), then the *p points to a dead end..... 
 
 
this applied in some other places too, see appended diff. 
 
  {     struct group_info *p, *last; 
    p = stack[ stack_n ].begin;