Back to index

tetex-bin  3.0
Classes | Defines | Functions | Variables
dosection.c File Reference
#include "dvips.h"
#include "protos.h"
#include <ctype.h>

Go to the source code of this file.

Classes

struct  p_list_str

Defines

#define MAXPAGE   (1000000000) /* assume no pages out of this range */
#define white(x)   ((x) == ' ' || (x) == '\t' || (x) == ',')

Functions

void dosection P2C (sectiontype *, s, int, c)
int InPageList P1C (integer, i)
void InstallPL P2C (integer, pslow, integer, pshigh)
int ParsePages P1C (register char *, s)

Variables

shalfword linepos
FILEdvifile
FILEbitfile
integer pagenum
long bytesleft
quarterwordraster
int quiet
Boolean reverse
Boolean multiplesects
Boolean disablecomments
Boolean evenpages
Boolean oddpages
Boolean pagelist
int actualdpi
int vactualdpi
int prettycolumn
integer hpapersize
integer vpapersize
integer pagecopies
static int psfont
double mag
char * fulliname
struct p_list_strppages

Class Documentation

struct p_list_str

Definition at line 196 of file dosection.c.

Collaboration diagram for p_list_str:
Class Members
struct p_list_str * next
integer ps_high
integer ps_low

Define Documentation

#define MAXPAGE   (1000000000) /* assume no pages out of this range */

Definition at line 195 of file dosection.c.

#define white (   x)    ((x) == ' ' || (x) == '\t' || (x) == ',')

Function Documentation

Definition at line 207 of file dosection.c.

{
    register struct p_list_str *pl = ppages;

    while (pl) {
           if ( i >= pl -> ps_low && i <= pl -> ps_high)
              return 1;            /* success */
       pl = pl -> next;
    }
    return 0;
}
int ParsePages P1C ( register char *  ,
s   
)

Definition at line 234 of file dosection.c.

{
    register int    c ;            /* current character */
    register integer  n = 0,       /* current numeric value */
                  innumber; /* true => gathering a number */
    integer ps_low = 0, ps_high = 0 ;
    int     range,          /* true => saw a range indicator */
           negative = 0;    /* true => number being built is negative */

#define white(x) ((x) == ' ' || (x) == '\t' || (x) == ',')

    range = 0;
    innumber = 0;
    for (;;) {
       c = *s++;
       if ( !innumber && !range) {/* nothing special going on */
           if (c == 0)
              return 0;
           if (white (c))
              continue;
       }
       if (c == '-' && !innumber) {
              innumber++;
              negative++;
              n = 0;
              continue;
       }
       if ('0' <= c && c <= '9') { /* accumulate numeric value */
           if (!innumber) {
              innumber++;
              negative = 0;
              n = c - '0';
              continue;
           }
           n *= 10;
           n += negative ? '0' - c : c - '0';
           continue;
       }
       if (c == '-' || c == ':') {/* here's a range */
           if (range)
              return (-1);
           if (innumber) {  /* have a lower bound */
              ps_low = n;
           }
           else
              ps_low = -MAXPAGE;
           range++;
           innumber = 0;
           continue;
       }
       if (c == 0 || white (c)) {/* end of this range */
           if (!innumber) { /* no upper bound */
              ps_high = MAXPAGE;
              if (!range)   /* no lower bound either */
                  ps_low = -MAXPAGE;
           }
           else {           /* have an upper bound */
              ps_high = n;
              if (!range) { /* no range => lower bound == upper */
                  ps_low = ps_high;
              }
           }
           InstallPL (ps_low, ps_high);
           if (c == 0)
              return 0;
           range = 0;
           innumber = 0;
           continue;
       }
       return (-1);
    }
#undef white
}
void dosection P2C ( sectiontype ,
s  ,
int  ,
c   
)

Definition at line 38 of file dosection.c.

{
   charusetype *cu ;
   integer prevptr ;
   int np ;
   int k ;
   integer thispage = 0 ;
   char buf[104];

   dopsfont(s) ;
#ifdef HPS
        if (HPS_FLAG) pagecounter = 0;
#endif

   if (multiplesects) {
     setup() ;
   }
   cmdout("TeXDict") ;
   cmdout("begin") ;
   numout(hpapersize) ;
   numout(vpapersize) ;
   doubleout(mag) ;
   numout((integer)DPI) ;
   numout((integer)VDPI) ;
   sprintf(buf, "(%.99s)", fulliname) ;
   cmdout(buf) ;
   cmdout("@start") ;
   if (multiplesects)
      cmdout("bos") ;
/*
 *   We insure raster is even-word aligned, because download might want that.
 */
   if (bytesleft & 1) {
      bytesleft-- ;
      raster++ ;
   }
   cleanres() ;
   cu = (charusetype *) (s + 1) ;
   psfont = 1 ;
   while (cu->fd) {
      if (cu->psfused)
         cu->fd->psflag = EXISTS ;
      download(cu++, psfont++) ;
   }
   fonttableout() ;
   if (! multiplesects) {
      cmdout("end") ;
      setup() ;
   }
   for (cu=(charusetype *)(s+1); cu->fd; cu++)
      cu->fd->psflag = 0 ;
   while (c > 0) {
      c-- ;
      prevptr = s->bos ;
      if (! reverse)
         (void)fseek(dvifile, (long)prevptr, 0) ;
      np = s->numpages ;
      while (np-- != 0) {
         if (reverse)
            (void)fseek(dvifile, (long)prevptr, 0) ;
         pagenum = signedquad() ;
        if ((evenpages && (pagenum & 1)) || (oddpages && (pagenum & 1)==0) ||
         (pagelist && !InPageList(pagenum))) {
           if (reverse) {
               skipover(36) ;
               prevptr = signedquad()+1 ;
           } else {
               skipover(40) ;
              skippage() ;
              skipnop() ;
           }
           ++np ;    /* this page wasn't counted for s->numpages */
           continue;
        }
/*
 *   We want to take the base 10 log of the number.  It's probably
 *   small, so we do it quick.
 */
         if (! quiet) {
            int t = pagenum, i = 0 ;
            if (t < 0) {
               t = -t ;
               i++ ;
            }
            do {
               i++ ;
               t /= 10 ;
            } while (t > 0) ;
            if (pagecopies < 20)
               i += pagecopies - 1 ;
            if (i + prettycolumn > STDOUTSIZE) {
               fprintf(stderr, "\n") ;
               prettycolumn = 0 ;
            }
            prettycolumn += i + 1 ;
#ifdef SHORTINT
            (void)fprintf(stderr, "[%ld", pagenum) ;
#else  /* ~SHORTINT */
            (void)fprintf(stderr, "[%d", pagenum) ;
#endif /* ~SHORTINT */
            (void)fflush(stderr) ;
         }
         skipover(36) ;
         prevptr = signedquad()+1 ;
         for (k=0; k<pagecopies; k++) {
            if (k == 0) {
               if (pagecopies > 1)
                  thispage = ftell(dvifile) ;
            } else {
               (void)fseek(dvifile, (long)thispage, 0) ;
               if (prettycolumn + 1 > STDOUTSIZE) {
                  (void)fprintf(stderr, "\n") ;
                  prettycolumn = 0 ;
               }
               (void)fprintf(stderr, ".") ;
               (void)fflush(stderr) ;
               prettycolumn++ ;
            }
            dopage() ;
         }
         if (! quiet) {
            (void)fprintf(stderr, "] ") ;
            (void)fflush(stderr) ;
            prettycolumn += 2 ;
         }
         if (! reverse)
            (void)skipnop() ;
      }
   }
   if (! multiplesects && ! disablecomments) {
      newline() ;
      (void)fprintf(bitfile, "%%%%Trailer\n") ;
   }
   if (multiplesects) {
      if (! disablecomments) {
         newline() ;
         (void)fprintf(bitfile, "%%DVIPSSectionTrailer\n") ;
      }
      cmdout("eos") ;
      cmdout("end") ;
   }
#ifdef HPS
   if (HPS_FLAG) cmdout("\nend") ; /* close off HPSDict */
#endif
   if (multiplesects && ! disablecomments) {
      newline() ;
      (void)fprintf(bitfile, "%%DVIPSEndSection\n") ;
      linepos = 0 ;
   }
}

Here is the call graph for this function:

void InstallPL P2C ( integer  ,
pslow  ,
integer  ,
pshigh   
)

Definition at line 219 of file dosection.c.

{
    register struct p_list_str   *pl;

    pl = (struct p_list_str *)mymalloc((integer)(sizeof *pl));
    pl -> next = ppages;
    pl -> ps_low = pslow;
    pl -> ps_high = pshigh;
    ppages = pl;
}

Variable Documentation

Definition at line 103 of file dvips.c.

Definition at line 93 of file dvips.c.

long bytesleft

Definition at line 112 of file dvips.c.

Definition at line 173 of file dvips.c.

Definition at line 93 of file dvips.c.

Definition at line 74 of file dvips.c.

char* fulliname

Definition at line 90 of file dvips.c.

Definition at line 82 of file dvips.c.

Definition at line 71 of file dvips.c.

double mag

Definition at line 598 of file dvi2xx.h.

Definition at line 172 of file dvips.c.

Definition at line 74 of file dvips.c.

Definition at line 70 of file dvips.c.

Definition at line 75 of file dvips.c.

Definition at line 111 of file dvips.c.

struct p_list_str * ppages

Definition at line 161 of file dvips.c.

int psfont [static]

Definition at line 27 of file dosection.c.

Definition at line 158 of file dvips.c.

Definition at line 113 of file dvips.c.

Definition at line 165 of file dvips.c.

Definition at line 104 of file dvips.c.

Definition at line 82 of file dvips.c.