From 569129a570ba3b0423587befce51906144c1f5dd Mon Sep 17 00:00:00 2001 From: maqiyuan Date: Fri, 4 Apr 2014 01:22:36 +0800 Subject: [PATCH] code cleaned. --- src/dvisourc/dviextra.c | 208 +++++++++++------- src/dvisourc/dvipslog.c | 569 +++++++++++++++++++++++++++++++----------------- src/dvisourc/dvipsone.c | 12 +- src/dvisourc/dvispeci.c | 324 +++++++++++++++++---------- src/dvisourc/dvitiff.c | 543 ++++++++++++++++++++++++++++----------------- src/dvisourc/makedll | 1 + src/dvisourc/makefile | 1 + 7 files changed, 1056 insertions(+), 602 deletions(-) diff --git a/src/dvisourc/dviextra.c b/src/dvisourc/dviextra.c index 8ff3c00..043d4f9 100644 --- a/src/dvisourc/dviextra.c +++ b/src/dvisourc/dviextra.c @@ -4802,8 +4802,9 @@ int fontremapsub (char *font) /* WARNING: following writes back into argument */ /* NOT ANYMORE IT DOESN'T - now caller needs to pick up fontsubto[k] */ -/* int fontremap (char *font) { */ /* expects lower case fontname */ -int fontremap (char *font) { /* expects lower case fontname */ +/* expects lower case fontname */ +int fontremap (char *font) +{ int k; // char oldname[MAXFONTNAME]; char oldname[FNAMELEN]; @@ -4811,7 +4812,8 @@ int fontremap (char *font) { /* expects lower case fontname */ char newname[FNAMELEN]; if (font == NULL) return -1; - if ((k = fontremapsub(font)) >= 0) { + if ((k = fontremapsub(font)) >= 0) + { // strcpy(newname, fontsubto + k * MAXFONTNAME); strcpy(newname, fontsubto[k]); if (verboseflag && quietflag == 0 && @@ -4827,19 +4829,21 @@ int fontremap (char *font) { /* expects lower case fontname */ // strcpy(font, newname); /* NO! */ } return k; /* pointer to substitute */ -} +} /* need also copy across fontsubprop[k] to fontproper[.] ? */ /* not announce if its just a remap ? */ /* not announce if its just printer resident ? */ /* see whether this font is being forced to be substituted */ - -int forcedsubstitute (char *font) { /* expects lower case fontname */ +/* expects lower case fontname */ +int forcedsubstitute (char *font) +{ int k; if (font == NULL) return -1; - for (k = 0; k < ksubst; k++) { + for (k = 0; k < ksubst; k++) + { if ((fontsubprop[k] & C_FORCESUB) != 0 && /* if (((fontsubprop[k] & C_FORCESUB) != 0 || */ /* NO */ /* (fontsubprop[k] & C_RESIDENT) != 0) && *//* 1992/July/4 */ @@ -4858,8 +4862,9 @@ int forcedsubstitute (char *font) { /* expects lower case fontname */ } /* is this font synthetic based on substitution table -- 1993/Nov/6 */ - -int checksynthetic (char *font) { /* expects lower case fontname */ +/* expects lower case fontname */ +int checksynthetic (char *font) +{ int k; if (font == NULL) return -1; @@ -4875,8 +4880,9 @@ int checksynthetic (char *font) { /* expects lower case fontname */ } /* see whether font name is being aliased based on font substitution table */ - -void replacealias (void) { /* replace aliases with real names */ +/* replace aliases with real names */ +void replacealias (void) +{ int k, n; /* need to have these `near' for verboseflag output ... */ // char newname[MAXFONTNAME]; @@ -4912,8 +4918,9 @@ void replacealias (void) { /* replace aliases with real names */ } /* see whether font name is being aliased based on texfonts.map 95/Dec/29 */ - -void replacetexfontsmap (void) { /* replace aliases with real names */ +/* replace aliases with real names */ +void replacetexfontsmap (void) +{ int k; /* int n; */ char *s; @@ -4954,7 +4961,8 @@ void replacetexfontsmap (void) { /* replace aliases with real names */ /* returns 0 normally, -1 on EOF, +1 if start of new section (128) */ -int readaline (char *line, FILE *input) { +int readaline (char *line, FILE *input) +{ int c; char *s=line; @@ -4985,7 +4993,8 @@ int readaline (char *line, FILE *input) { /* Could we do this using the new ATMFonts table ??? 2000 July 7 */ -int FindMMBaseFile (int k) { +int FindMMBaseFile (int k) +{ /* char FontName[MAXTEXNAME]; */ /* 95/May/25 */ // char FontName[MAXFONTNAME]; /* 95/July/27 */ char FontName[FNAMELEN]; /* 99/Nov/6 */ @@ -5093,7 +5102,9 @@ int FindMMBaseFile (int k) { /* Finds corresponding MM base font - or adds it if not found */ /* Adds characters needed by new instance */ -int AddMMBase (int m) { /* add the corresponding MM base 94/Dec/6 */ +/* add the corresponding MM base 94/Dec/6 */ +int AddMMBase (int m) +{ int k, i; char *basewantchrs; /* wanted chars array of MM base font */ char *instwantchrs; /* wanted chars array of MM instance */ @@ -5109,7 +5120,8 @@ int AddMMBase (int m) { /* add the corresponding MM base 94/Dec/6 */ if (subfontname[m] != NULL) strcpy(psfontname, subfontname[m]); else *psfontname = '\0'; /* Truncate MM instance PS FontName if that is what we have 97/June/1 */ - if ((s = strchr(psfontname, '_')) != NULL && s > psfontname) { + if ((s = strchr(psfontname, '_')) != NULL && s > psfontname) + { *s = '\0'; } /* if (bMMShortCut == 0) { @@ -5161,7 +5173,8 @@ int AddMMBase (int m) { /* add the corresponding MM base 94/Dec/6 */ } #ifdef DEBUG - if (traceflag) { + if (traceflag) + { sprintf(logline, "Need to construct new MM base entry %s\n", psfontname); showline(logline, 0); } @@ -5183,12 +5196,13 @@ int AddMMBase (int m) { /* add the corresponding MM base 94/Dec/6 */ /* if (bMMShortCut == 0) { */ /* copy PS FileName from instance, exists yet ??? */ /* strcpy(subfontname + fnext * MAXFONTNAME, subfontname + m * MAXFONTNAME); */ #ifdef DEBUG - if (traceflag) { + if (traceflag) + { sprintf(logline, "New base font with PS FontName %s\n", psfontname); showline(logline, 0); } #endif -// strcpy(subfontname + fnext * MAXFONTNAME, psfontname); +// strcpy(subfontname + fnext * MAXFONTNAME, psfontname); if (subfontname[fnext] != NULL) free(subfontname[fnext]); subfontname[fnext] = zstrdup(psfontname); /* hope this does not create problems with tests on subfontname ... */ @@ -5215,7 +5229,8 @@ int AddMMBase (int m) { /* add the corresponding MM base 94/Dec/6 */ } fnext++; mmcount++; /* how many MM base fonts */ - if (fnext >= maxfonts - 1) { + if (fnext >= maxfonts - 1) + { /* fprintf(errout, "Too many MM base fonts (%d)\n", fnext - mmbase); */ sprintf(logline, " ERROR: Too many MM base fonts (%d)\n", mmcount); showline(logline, 1); @@ -5231,10 +5246,12 @@ int AddMMBase (int m) { /* add the corresponding MM base 94/Dec/6 */ /* Not used anymore ? */ #ifdef IGNORED -void AddInBaseFonts(void) { +void AddInBaseFonts(void) +{ int k; /* for (k = 0; k < mmbase; k++) { */ - for (k = 0; k < fnext; k++) { + for (k = 0; k < fnext; k++) + { /* if (fontproper[k] & C_MULTIPLE) continue; */ if (fontproper[k] & C_INSTANCE) AddMMBase(k); } @@ -5265,16 +5282,17 @@ definefont pop */ /* Could we do this using the new ATMFonts table ??? 2000 July 7 */ //int AddMMFontName (FILE *input, int k, int pssflag, char *FileName) -int AddMMFontName (FILE *input, int k, int pssflag, char *FileName, int nlen) { +int AddMMFontName (FILE *input, int k, int pssflag, char *FileName, int nlen) +{ int c, m, flag; char *s; -// *(subfontname + k * MAXFONTNAME) = '\0'; +// *(subfontname + k * MAXFONTNAME) = '\0'; if (subfontname[k] != NULL) { /* reset in case not found */ free(subfontname[k]); subfontname[k] = NULL; } -/* PSS file case first --- now outdated since ATM NT no longer */ +/* PSS file case first --- now outdated since ATM NT no longer */ if (pssflag) { /* read PSS file to extract MM base FontName */ if ((c = getc(input)) != 128) return -1; /* sanity test */ if ((c = getc(input)) != 1) return -1; /* sanity test */ @@ -5282,7 +5300,8 @@ int AddMMFontName (FILE *input, int k, int pssflag, char *FileName, int nlen) { while (readaline(line, input) == 0) { /* printf("LINE: %s", line); */ /* debugging 95/May/25 */ if (*line == '%') continue; /* ignore comments */ - if ((s = strstr(line, "findfont")) != NULL) { + if ((s = strstr(line, "findfont")) != NULL) + { s--; while (*s <= ' ' && s >= line) *s-- = '\0'; if ((s = strrchr(line, '/')) == NULL) return -1; @@ -5341,7 +5360,8 @@ int notvalidPSS (int pssflag) { /* PSS or PFM file */ /* we are assuming this happens *before* we start adding MM base fonts */ -void checksubstitute (void) { +void checksubstitute (void) +{ FILE *fp_in; int k, j, i, n, baseexist, wipeflag; // char fontnamek[MAXTEXNAME]; @@ -5611,7 +5631,8 @@ void checksubstitute (void) { /* now pass in subfile as argument so we can read more than one 1994/Feb/4 */ /* FILE *OpenFontsub(void) { */ -FILE *OpenFontsub (char *subfile) { +FILE *OpenFontsub (char *subfile) +{ FILE *input; if (strcmp(subfile, "") == 0) return NULL; /* 1994/Feb/4 */ @@ -5672,7 +5693,9 @@ FILE *OpenFontsub (char *subfile) { return 0; } */ -int charneeded (char *wantchrs) { /* see whether font actually used */ +/* see whether font actually used */ +int charneeded (char *wantchrs) +{ int k; if (wantchrs == NULL) return 0; /* test in decreasing order of expected use */ @@ -5687,7 +5710,9 @@ int charneeded (char *wantchrs) { /* see whether font actually used */ /* read font substitution table */ /* returns non-zero if success */ -int GetSubstitutes (void) { /* return value not used ? */ +/* return value not used ? */ +int GetSubstitutes (void) +{ FILE *input; char nextfontsub[FNAMELEN]; /* need for multi sub files */ int k, flag=0; /* 1994/Feb/5 */ @@ -5704,7 +5729,8 @@ int GetSubstitutes (void) { /* return value not used ? */ /* input = OpenFontsub(fontsubrest); */ strcpy(nextfontsub, s); /* if ((input = OpenFontsub(s)) != NULL) { */ - if ((input = OpenFontsub(nextfontsub)) != NULL) { + if ((input = OpenFontsub(nextfontsub)) != NULL) + { /* if (traceflag) printf("Reading %s\n", nextfontsub); */ /* debugging */ readsubstitutes(input); /* read font substitution file */ @@ -5713,7 +5739,8 @@ int GetSubstitutes (void) { /* return value not used ? */ /* if (traceflag) showsubtable(stdout); */ /* an experiment */ /* return -1; */ /* OK, specified file worked */ } - else { + else + { sl = removepath(fontsubfile); /* fprintf(errout, "WARNING: Can't find font subst file: "); */ sprintf(logline, " WARNING: Can't find %s subst file %s\n", @@ -5740,14 +5767,16 @@ int GetSubstitutes (void) { /* return value not used ? */ /* if (strcmp(fontsubrest, "standard") != 0) { */ /* 1994/Feb/10 */ /* strcpy(fontsubrest, "standard"); */ /* if((input = OpenFontsub()) != NULL) { */ - if((input = OpenFontsub("standard")) != NULL) { - readsubstitutes(input); + if((input = OpenFontsub("standard")) != NULL) + { + readsubstitutes(input); fclose(input); /* 1994/Feb/4 */ /* if (traceflag) showsubtable(stdout); */ /* an experiment */ /* return -1; */ /* OK, standard file worked */ flag++; } - else { + else + { sl = removepath(fontsubfile); /* substitute = 0; */ /* NO: still have built in table ? */ sprintf(logline, " WARNING: Can't find %s subst file %s\n", @@ -5761,19 +5790,23 @@ int GetSubstitutes (void) { /* return value not used ? */ /* return 0; */ /* No success ! */ } /* if (traceflag) showsubtable(stdout); */ /* an experiment */ - if (showsubflag) { + if (showsubflag) + { showsubtable(); /* an experiment */ -// if (logfileflag) showsubtable(logfile); +// if (logfileflag) showsubtable(logfile); } return flag; /* non zero if some substitution table has been read */ } -int markunusedfonts0 (void) { /* separated out 94/Oct/5 */ +/* separated out 94/Oct/5 */ +int markunusedfonts0 (void) +{ int k, unused=0; /* fontproper[k] &= ~C_UNUSED; */ - for (k = 0; k < fnext; k++) { + for (k = 0; k < fnext; k++) + { /* if (charneeded(fontchar[k]) == 0) */ // if (fontproper[k] | C_MULTIPLE) continue; /* for now 94/Dec/6 ??? */ if (fontproper[k] & C_MULTIPLE) continue; /* fixed 2000 July 4 */ @@ -5782,14 +5815,16 @@ int markunusedfonts0 (void) { /* separated out 94/Oct/5 */ fontproper[k] |= C_UNUSED; unused++; } - } + } return unused; } /* following called from dvipsone.c before calling extract itself */ /* task = "checking for duplicate & substitutions"; */ -void preextract (void) { /* get font tables straightened out first */ +/* get font tables straightened out first */ +void preextract (void) +{ int k; /* FILE *input; */ // char fontnamek[MAXTEXNAME]; @@ -5829,8 +5864,10 @@ void preextract (void) { /* get font tables straightened out first */ /* Deal with situtation where all fonts considered resident */ /* moved down here 1992/July/4 */ /* do this LAST */ - if (forcereside != 0) { - for (k = 0; k < fnext; k++) { + if (forcereside != 0) + { + for (k = 0; k < fnext; k++) + { /* debugging output 95/Sep/16 */ /* if (fontsubflag[k] < 0) { */ /* 1992/July/4 */ /* Don't mark fonts substituted for as resident */ @@ -5860,7 +5897,8 @@ void preextract (void) { /* get font tables straightened out first */ if (subfontname[k] != NULL) strcpy(subfontnamek, subfontname[k]); else *subfontnamek = '\0'; #ifdef DEBUG - if (traceflag) { + if (traceflag) + { sprintf(logline, "%d %s %s %d\n", k, fontnamek, subfontnamek, fontproper[k]); /* debugging */ showline(logline, 0); @@ -5883,25 +5921,31 @@ void preextract (void) { /* get font tables straightened out first */ /* following contains kludgy test to avoid repeating vector */ -void constructvectors(FILE *fp_out) { +void constructvectors(FILE *fp_out) +{ int k, i, flag; /* maybe nothing to do here if just need ansinew due to `-X' flag */ /* we should already have the ansinew vector dumped out */ writedvistart(fp_out); /* 93/Sep/30 */ - for (k=0; k < fnext; k++) { + for (k=0; k < fnext; k++) + { if ((fontproper[k] & C_REMAPIT) != 0 && - (fontproper[k] & C_RESIDENT) != 0) { + (fontproper[k] & C_RESIDENT) != 0) + { flag = 0; - for (i = 0; i < k; i ++) { + for (i = 0; i < k; i ++) + { if ((fontproper[i] & C_REMAPIT) != 0 && - (fontproper[i] & C_RESIDENT) != 0 && -// strcmp(fontvector + i * MAXVECNAME, fontvector + k * MAXVECNAME) == 0) - fontvector[i] != NULL && fontvector[k] != NULL && - strcmp(fontvector[i], fontvector[k]) == 0) { - flag = 1; break; - } + (fontproper[i] & C_RESIDENT) != 0 && +/* strcmp(fontvector + i * MAXVECNAME, fontvector + k * MAXVECNAME) == 0) */ + fontvector[i] != NULL && + fontvector[k] != NULL && + strcmp(fontvector[i], fontvector[k]) == 0) + { + flag = 1; break; + } } if (flag == 0) { // readencoding(fontvector + k * MAXVECNAME); @@ -5920,7 +5964,8 @@ void constructvectors(FILE *fp_out) { /* Check whether font itself, or its base font are resident */ -int fontreside (int f) { /* 1995/July/5 */ +int fontreside (int f) /* 1995/July/5 */ +{ int k; if ((fontproper[f] & C_RESIDENT) != 0) return 1; if ((fontproper[f] & C_DEPENDENT) != 0) { @@ -5938,7 +5983,8 @@ int fontreside (int f) { /* 1995/July/5 */ /* fn is the internal font number if bShortFont == 0 || bUseInternal != 0 */ /* fn is the short font number if bShortFont != 0 && bUseInternal == 0 */ -void dofont (FILE *fp_out, int f, int fn) { +void dofont (FILE *fp_out, int f, int fn) +{ // char fname[MAXFONTNAME]; char fname[FNAMELEN]; int n; @@ -5947,12 +5993,12 @@ void dofont (FILE *fp_out, int f, int fn) { if (f < 0 || f >= maxfonts) { /* 93/May/23 */ sprintf(logline, "Bad font index %d\n", f); /* debugging */ showline(logline, 1); -/* should we skip it in this case to avoid access errors ? */ +/* should we skip it in this case to avoid access errors ? */ } property = fontproper[f]; /* 97/June/1 */ /* if (traceflag) - printf("font %d fontname %s subfontname %s fontsubflag %d\n", + printf("font %d fontname %s subfontname %s fontsubflag %d\n", f, fontname[f], subfontname[f], fontsubflag[f]); */ // strcpy(fname, fontname + f * MAXTEXNAME); if (fontname[f] != NULL) strcpy(fname, fontname[f]); @@ -6139,7 +6185,8 @@ void dofont (FILE *fp_out, int f, int fn) { /* Replace PostScript FontName in PSS stub with new one */ -int replacename (char *line, char *fname) { +int replacename (char *line, char *fname) +{ char *s, *t; char buffer[FNAMELEN]; @@ -6163,8 +6210,8 @@ int replacename (char *line, char *fname) { /* int copyPSS_sub(FILE *output, FILE *input, char *fname, char *encode) { */ /* int copyPSS_sub(FILE *output, FILE *input, char *fname, char *bname, char *encode) { */ -int copyPSS_sub(FILE *output, FILE *input, char *fname, char *bname, - char *encode, int proper) { +int copyPSS_sub(FILE *output, FILE *input, char *fname, char *bname, char *encode, int proper) +{ /* int c; */ char *s; // char basename[MAXTEXNAME]; /* char basename[16]; */ @@ -6181,10 +6228,10 @@ int copyPSS_sub(FILE *output, FILE *input, char *fname, char *bname, if (readaline(line, input) != 0) return -1; } /* while ((s = strchr(line, '/')) == NULL) { */ - while ((s = strstr(line, "findfont")) == NULL) { + while ((s = strstr(line, "findfont")) == NULL) { // fputs(line, output); PSputs(line, output); - if (readaline(line, input) != 0) return -1; + if (readaline(line, input) != 0) return -1; } if ((s = strchr(line, '/')) == NULL) return -1; /* replace PostScript Multiple Master *Instance* FontName */ @@ -6194,7 +6241,7 @@ int copyPSS_sub(FILE *output, FILE *input, char *fname, char *bname, /* Construct MM base font file name from stub PSS file name */ if (bMMShortCut) { /* disallow this ? */ strcpy(basename, fname); - strcpy(basename+5, "___"); + strcpy(basename+5, "___"); /* MM base font has same name, but ends in ___ simple minded ? */ } else strcpy(basename, bname); @@ -6250,7 +6297,8 @@ int copyPSS_sub(FILE *output, FILE *input, char *fname, char *bname, /* work in progress: deal with PSS stub for Multiple Master */ -int copyPSS(FILE *fp_out, FILE *fp_in, int k) { +int copyPSS(FILE *fp_out, FILE *fp_in, int k) +{ int flag, m; int proper=0; char *s; @@ -6314,7 +6362,8 @@ int copyPSS(FILE *fp_out, FILE *fp_in, int k) { return flag; } -int IsItUsed (char *wantchrs) { +int IsItUsed (char *wantchrs) +{ int k; if (wantchrs == NULL) return 0; /* test in decreasing order of expected use */ @@ -6329,7 +6378,8 @@ int IsItUsed (char *wantchrs) { /* See if can mark unused fonts (in jobs with less than full page range) */ -int MarkUnusedFonts (void) { /* an experiment 95/Mar/5 */ +int MarkUnusedFonts (void) /* an experiment 95/Mar/5 */ +{ int fn, flag=0; /* int k, count, property; */ // char fontnamek[MAXTEXNAME]; @@ -6368,7 +6418,8 @@ int MarkUnusedFonts (void) { /* an experiment 95/Mar/5 */ /* following split off 95/May/13 to improve readability ... */ -int extractafont (FILE *fp_out, int k) { +int extractafont (FILE *fp_out, int k) +{ FILE *fp_in; int flag=0; int proper; /* 1992/Aug/23 */ @@ -6475,7 +6526,8 @@ int extractafont (FILE *fp_out, int k) { /* once it has been verified this works correctly, strip out IGNORE part */ /* present order is: MM base fonts, PSS stub files, other fonts ... */ -int extractfonts (FILE *fp_out) { /* was called by main */ +int extractfonts (FILE *fp_out) /* was called by main */ +{ int k; int proper; /* 1992/Aug/23 */ /* int oldsuppress; */ @@ -6515,7 +6567,8 @@ int extractfonts (FILE *fp_out) { /* was called by main */ /* extract PSS stub files next */ - for (k = 0; k < fnext; k++) { + for (k = 0; k < fnext; k++) + { proper = fontproper[k]; if ((proper & C_INSTANCE) == 0) continue; if (extractafont(fp_out, k) != 0) nfonts++; /* do we count these ? */ @@ -6555,7 +6608,8 @@ int extractfonts (FILE *fp_out) { /* was called by main */ /* separated out from the above 94/Mar/3 ************************** */ -void fontsetup (FILE *fp_out) { +void fontsetup (FILE *fp_out) +{ int k, i, ne, f; /* int n; */ int count, flag; @@ -6882,17 +6936,19 @@ void fontsetup (FILE *fp_out) { /* fputs("%%EndSetup\n", fp_out); */ /* ??? */ } -/* Following called from dvispeci.c +/* Following called from dvispeci.c */ /* Don't expand %%IncludeFont for printer resident fonts */ /* Use a fixed list ??? */ /* tir, tii, tib, tibi, hv, hvo, hvb, hvbo, com, coo, cob, cobo, sy, zd */ -int ResidentFont (char *FileName) { /* 1994/Feb/10 */ +int ResidentFont (char *FileName) /* 1994/Feb/10 */ +{ char *s, *t; int k; #ifdef DEBUG - if (traceflag) { + if (traceflag) + { sprintf(logline, "ResidentFont %s?\n", FileName); /* debugging 97/June/5 */ showline(logline, 0); } @@ -6904,7 +6960,7 @@ int ResidentFont (char *FileName) { /* 1994/Feb/10 */ else s = FileName; */ s = removepath(FileName); /* 95/May/28 */ /* get rid of extension */ - if ((t = strrchr(s, '.')) != NULL) *t ='\0'; + if ((t = strrchr(s, '.')) != NULL) *t ='\0'; t = s + strlen(s) - 1; while (*t == '_') *t-- = '\0'; /* strip underscores */ #ifdef DEBUG diff --git a/src/dvisourc/dvipslog.c b/src/dvisourc/dvipslog.c index 00c5a2b..ce295fe 100644 --- a/src/dvisourc/dvipslog.c +++ b/src/dvisourc/dvipslog.c @@ -86,15 +86,16 @@ long pageno; /* for convenience in error messages - may be logical page */ /* now for the scan of the DVI file for PS output generation */ -void reset_stack(void) { +void reset_stack(void) +{ stinx = 0; } -void check_stack(int pageno) { - if (stinx != 0) { - sprintf(logline, - " ERROR: stack not empty at EOP: %d on page %d ", - stinx, pageno); /* pageno ? logical page */ +void check_stack(int pageno) +{ + if (stinx != 0) + { + sprintf(logline, " ERROR: stack not empty at EOP: %d on page %d ", stinx, pageno); /* pageno ? logical page */ showline(logline, 1); tellwhere(input, 1); /* errcount(0); */ @@ -110,18 +111,21 @@ void check_stack(int pageno) { return getc(infile); } */ -static unsigned int ureadtwo (FILE *infile) { - return (getc(infile) << 8) | getc(infile); +static unsigned int ureadtwo (FILE *infile) +{ + return (getc(infile) << 8) | getc(infile); } -static unsigned long ureadthree (FILE *infile) { +static unsigned long ureadthree (FILE *infile) +{ int c, d, e; /* unsigned int c, d, e; */ c = getc(infile); d = getc(infile); e = getc(infile); return ((((unsigned long) c << 8) | d) << 8) | e; } -static unsigned long ureadfour (FILE *infile) { +static unsigned long ureadfour (FILE *infile) +{ int c, d, e, f; c = getc(infile); d = getc(infile); e = getc(infile); f = getc(infile); @@ -139,7 +143,8 @@ static unsigned long ureadfour (FILE *infile) { #ifdef IGNORED /* static short int sreadtwo (FILE *infile) { */ /* ??? */ -static int sreadtwo (FILE *infile) { +static int sreadtwo (FILE *infile) +{ short int result; /* return (getc(infile) << 8) | getc(infile); */ /* 1995/Nov/15 */ /* result = (getc(infile) << 8) | getc(infile); */ @@ -150,10 +155,11 @@ static int sreadtwo (FILE *infile) { /* avoid possible compiler optimization error */ -static int sreadtwo (FILE *input) { /* experiment 98/Feb/7 */ +static int sreadtwo (FILE *input) /* experiment 98/Feb/7 */ +{ int c, d; c = getc(input); d = getc(input); - if (c > 127) c = c - 256; + if (c > 127) c = c - 256; return (c << 8) | d; } @@ -164,7 +170,8 @@ static int sreadtwo (FILE *input) { /* experiment 98/Feb/7 */ return ((((long) c << 8) | d) << 8) | e; } */ -static long sreadfour (FILE *infile) { +static long sreadfour (FILE *infile) +{ int c, d, e, f; c = getc(infile); d = getc(infile); e = getc(infile); f = getc(infile); @@ -181,7 +188,8 @@ COLORSPEC **ColorStacks=NULL; /* array of saved color stacks, one per page */ /* restore at start of page what was current at end of page-1 */ /* called from dvianal.c */ /* page is physical DVI page from start of file */ -void RestoreColorStack (int page) { +void RestoreColorStack (int page) +{ COLORSPEC *SavedStack; int k; /* don't bother if color \special{...} was never used */ @@ -195,7 +203,8 @@ void RestoreColorStack (int page) { if (ColorStacks == NULL) return; /* sanity check */ /* GrabColor(); */ SavedStack = ColorStacks[page]; - if (SavedStack == NULL) { + if (SavedStack == NULL) + { sprintf(logline, " Bad Color Restore page %d (%d)", page, MaxColor-1); showline(logline, 1); @@ -204,7 +213,8 @@ void RestoreColorStack (int page) { } colorindex = (int) (SavedStack[0].D + 0.5); /* depth of saved stack */ #ifdef DEBUGCOLORSTACK - if (traceflag) { + if (traceflag) + { sprintf(logline, " RestoreColorStack from page-1 %d colorindex %d\n", page, colorindex); showline(logline, 0); @@ -223,7 +233,8 @@ void RestoreColorStack (int page) { /* Save at end of page for start of page+1 */ /* called from logdo_eop dvipslog.c */ /* page is DVI page from start of file */ -void SaveColorStack (int page, int colorindex) { +void SaveColorStack (int page, int colorindex) +{ COLORSPEC *SavedStack; int k; /* if (bCarryColor == 0 || bColorUsed == 0) return; */ @@ -238,7 +249,8 @@ void SaveColorStack (int page, int colorindex) { /* free(lpColor[page]); */ } #ifdef DEBUGCOLORSTACK - if (traceflag) { + if (traceflag) + { sprintf(logline, " SaveColorStack page %d colorindex %d\n", page, colorindex); showline(logline, 0); @@ -257,7 +269,8 @@ void SaveColorStack (int page, int colorindex) { /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ -void logdo_push(void) { +void logdo_push(void) +{ if (skipflag == 0) { stinx++; if (stinx > maxstinx) maxstinx = stinx; @@ -268,10 +281,13 @@ void logdo_push(void) { } } -void logdo_pop(void) { - if (skipflag == 0) { +void logdo_pop(void) +{ + if (skipflag == 0) + { stinx--; - if (stinx < 0) { + if (stinx < 0) + { sprintf(logline, " ERROR: The stack will underflow on page %d ", pageno); /* pagenumber ??? logical page */ @@ -284,7 +300,8 @@ void logdo_pop(void) { /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ -void invalidset(int c) { +void invalidset(int c) +{ sprintf(logline, " ERROR: Setting char %d without font on page %d ", c, pageno); /* pagenumber ??? logical page */ showline(logline, 1); @@ -294,7 +311,8 @@ void invalidset(int c) { /* common subroutine for set2 set3 set4 --- which should not occur */ -void logdo_setsub(unsigned long c) { +void logdo_setsub(unsigned long c) +{ if (skipflag == 0) { /* if (ff < 0) invalidset((int) c); */ if (ff == BLANKFONT) invalidset((int) c); @@ -322,7 +340,8 @@ void logdo_setsub(unsigned long c) { /* For speed we keep the set1 case separate since it occurs often */ -void logdo_set1(FILE *infile) { +void logdo_set1(FILE *infile) +{ unsigned int c; /* c = ureadone(infile); */ c = getc(infile); @@ -352,12 +371,14 @@ void logdo_set1(FILE *infile) { /* simplified 95/Oct/17 by using logo_setsub for logdo_set2 */ -void logdo_set2(FILE *infile) { +void logdo_set2(FILE *infile) +{ logdo_setsub(ureadtwo(infile)); } #ifdef IGNORED -void logdo_set2(FILE *infile) { +void logdo_set2(FILE *infile) +{ unsigned int c; c = ureadtwo(infile); if (skipflag == 0) { @@ -385,11 +406,13 @@ void logdo_set2(FILE *infile) { } #endif -void logdo_set3(FILE *infile) { +void logdo_set3(FILE *infile) +{ logdo_setsub(ureadthree(infile)); } -void logdo_set4(FILE *infile) { +void logdo_set4(FILE *infile) +{ logdo_setsub(ureadfour(infile)); } @@ -397,8 +420,10 @@ void logdo_set4(FILE *infile) { /* common subroutine for put2, put3, pu4 --- which should not occur */ -void logdo_putsub(unsigned long c) { - if (skipflag == 0) { +void logdo_putsub(unsigned long c) +{ + if (skipflag == 0) + { /* if (ff < 0) invalidset((int) c); */ if (ff == BLANKFONT) invalidset((int) c); else if (c < 256) { @@ -424,7 +449,8 @@ void logdo_putsub(unsigned long c) { /* For speed we keep the set1 case separate since it occurs sometimes */ -void logdo_put1(FILE *infile) { +void logdo_put1(FILE *infile) +{ unsigned int c; /* c = ureadone(infile); */ c = getc(infile); @@ -454,12 +480,14 @@ void logdo_put1(FILE *infile) { /* simplified 95/Oct/17 by using logo_putsub for logdo_put2 */ -void logdo_put2(FILE *infile) { +void logdo_put2(FILE *infile) +{ logdo_putsub(ureadtwo(infile)); } #ifdef IGNORED -void logdo_put2(FILE *infile) { +void logdo_put2(FILE *infile) +{ unsigned int c; c = ureadtwo(infile); if (skipflag == 0) { @@ -487,20 +515,24 @@ void logdo_put2(FILE *infile) { } #endif -void logdo_put3(FILE *infile) { +void logdo_put3(FILE *infile) +{ logdo_putsub(ureadthree(infile)); } -void logdo_put4(FILE *infile) { +void logdo_put4(FILE *infile) +{ logdo_putsub(ureadfour(infile)); } -void logdo_set_rule(FILE *infile) { +void logdo_set_rule(FILE *infile) +{ int k; for (k=0; k < 8; k++) (void) getc(infile); } -void logdo_put_rule(FILE *infile) { +void logdo_put_rule(FILE *infile) +{ int k; for (k=0; k < 8; k++) (void) getc(infile); } @@ -514,7 +546,8 @@ int pagesequence; /* count of ascending page sequence */ /* returns zero if page is to be printed */ /* non-zero if to be skipped */ -int skipthispage(long pageno) { +int skipthispage(long pageno) +{ int k; /* int hitrange=0; */ /* int wantpage=0; */ @@ -554,7 +587,8 @@ int skipthispage(long pageno) { return 1; /* not inside any specified range */ } -void logdo_bop(FILE *infile) { /* beginning of page */ +void logdo_bop(FILE *infile) /* beginning of page */ +{ int k; long current; /* ??? */ @@ -622,121 +656,150 @@ void logdo_eop(FILE *infile) { /* end of page */ skipflag = 0; } -void logdo_right1(FILE *infile) { /* rare */ +void logdo_right1(FILE *infile) /* rare */ +{ (void) getc(infile); } -void logdo_right2(FILE *infile) { +void logdo_right2(FILE *infile) +{ (void) getc(infile); (void) getc(infile); } -void logdo_right3(FILE *infile) { +void logdo_right3(FILE *infile) +{ (void) getc(infile); (void) getc(infile); (void) getc(infile); } -void logdo_right4(FILE *infile) { - (void) getc(infile); (void) getc(infile); +void logdo_right4(FILE *infile) +{ + (void) getc(infile); (void) getc(infile); (void) getc(infile); (void) getc(infile); } -void logdo_w0(void) { +void logdo_w0(void) +{ } -void logdo_w1(FILE *infile) { /* rare */ - (void) getc(infile); +void logdo_w1(FILE *infile) /* rare */ +{ + (void) getc(infile); } -void logdo_w2(FILE *infile) { +void logdo_w2(FILE *infile) +{ (void) getc(infile); (void) getc(infile); } -void logdo_w3(FILE *infile) { +void logdo_w3(FILE *infile) +{ (void) getc(infile); (void) getc(infile); (void) getc(infile); } -void logdo_w4(FILE *infile) { - (void) getc(infile); (void) getc(infile); +void logdo_w4(FILE *infile) +{ (void) getc(infile); (void) getc(infile); -} + (void) getc(infile); (void) getc(infile); +} -void logdo_x0(void) { +void logdo_x0(void) +{ } -void logdo_x1(FILE *infile) { /* rare */ +void logdo_x1(FILE *infile) /* rare */ +{ (void) getc(infile); } -void logdo_x2(FILE *infile) { +void logdo_x2(FILE *infile) +{ (void) getc(infile); (void) getc(infile); } -void logdo_x3(FILE *infile) { +void logdo_x3(FILE *infile) +{ (void) getc(infile); (void) getc(infile); (void) getc(infile); } -void logdo_x4(FILE *infile) { - (void) getc(infile); (void) getc(infile); +void logdo_x4(FILE *infile) +{ + (void) getc(infile); (void) getc(infile); (void) getc(infile); (void) getc(infile); } -void logdo_down1(FILE *infile) { /* rare */ +void logdo_down1(FILE *infile) /* rare */ +{ (void) getc(infile); } -void logdo_down2(FILE *infile) { /* rare */ +void logdo_down2(FILE *infile) /* rare */ +{ (void) getc(infile); (void) getc(infile); -} +} -void logdo_down3(FILE *infile) { +void logdo_down3(FILE *infile) +{ (void) getc(infile); (void) getc(infile); (void) getc(infile); } -void logdo_down4(FILE *infile) { - (void) getc(infile); (void) getc(infile); +void logdo_down4(FILE *infile) +{ (void) getc(infile); (void) getc(infile); -} + (void) getc(infile); (void) getc(infile); +} -void logdo_y0(void) { +void logdo_y0(void) +{ } -void logdo_y1(FILE *infile) { /* rare */ +void logdo_y1(FILE *infile) /* rare */ +{ (void) getc(infile); } -void logdo_y2(FILE *infile) { +void logdo_y2(FILE *infile) +{ (void) getc(infile); (void) getc(infile); -} +} -void logdo_y3(FILE *infile) { +void logdo_y3(FILE *infile) +{ (void) getc(infile); (void) getc(infile); (void) getc(infile); } -void logdo_y4(FILE *infile) { /* not used */ - (void) getc(infile); (void) getc(infile); +void logdo_y4(FILE *infile) /* not used */ +{ (void) getc(infile); (void) getc(infile); -} + (void) getc(infile); (void) getc(infile); +} -void logdo_z0(void) { +void logdo_z0(void) +{ } -void logdo_z1(FILE *infile) { /* rare */ +void logdo_z1(FILE *infile) /* rare */ +{ (void) getc(infile); } -void logdo_z2(FILE *infile) { +void logdo_z2(FILE *infile) +{ (void) getc(infile); (void) getc(infile); } -void logdo_z3(FILE *infile) { +void logdo_z3(FILE *infile) +{ (void) getc(infile); (void) getc(infile); (void) getc(infile); } -void logdo_z4(FILE *infile) { - (void) getc(infile); (void) getc(infile); +void logdo_z4(FILE *infile) +{ (void) getc(infile); (void) getc(infile); -} + (void) getc(infile); (void) getc(infile); +} -void logswitchfont(int fn, FILE *infile) { /* switching to other font */ +void logswitchfont(int fn, FILE *infile) /* switching to other font */ +{ int c; ff = fn; /* set state */ fnt = finx[fn]; @@ -745,8 +808,7 @@ void logswitchfont(int fn, FILE *infile) { /* switching to other font */ if (fn == 52) { c = getc(infile); (void) ungetc(c, infile); if (c == 171 + 52) { - sprintf(logline, - " ERROR: Unexpected encounter of DVI trailer on page %d ", pagenumber); + sprintf(logline, " ERROR: Unexpected encounter of DVI trailer on page %d ", pagenumber); showline(logline, 1); /* errcount(0); */ /* finish = -1; */ @@ -767,7 +829,8 @@ void logswitchfont(int fn, FILE *infile) { /* switching to other font */ fonthit[fnt] = 1; /* even if skipflag != 0 ? */ } -void logdo_fnt1(FILE *infile) { /* switch fonts */ +void logdo_fnt1(FILE *infile) /* switch fonts */ +{ int fn; /* fn = ureadone(infile); */ fn = getc(infile); @@ -775,7 +838,8 @@ void logdo_fnt1(FILE *infile) { /* switch fonts */ logswitchfont(fn, infile); } -void logdo_fnt2(FILE *infile) { /* switch fonts */ +void logdo_fnt2(FILE *infile) /* switch fonts */ +{ unsigned int fn; fn = ureadtwo(infile); /* if (skipflag == 0) */ @@ -783,19 +847,22 @@ void logdo_fnt2(FILE *infile) { /* switch fonts */ logswitchfont((int) fn, infile); } -void logdo_fntsub(unsigned long fn, FILE *infile) { /* switch fonts */ +void logdo_fntsub(unsigned long fn, FILE *infile) /* switch fonts */ +{ /* if (skipflag == 0) */ if (fn >= MAXFONTNUMBERS) fn = MAXFONTNUMBERS-1; logswitchfont((int) fn, infile); } -void logdo_fnt3(FILE *infile) { /* switch fonts */ +void logdo_fnt3(FILE *infile) /* switch fonts */ +{ /* unsigned long fn; fn = ureadthree(infile); */ logdo_fntsub(ureadthree(infile), infile); } -void logdo_fnt4(FILE *infile) { /* switch fonts */ +void logdo_fnt4(FILE *infile) /* switch fonts */ +{ long fn; fn = sreadfour(infile); /* if (skipflag == 0) */ @@ -805,7 +872,8 @@ void logdo_fnt4(FILE *infile) { /* switch fonts */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ -void getheadername (FILE *infile) { /* new version 95/Aug/30 */ +void getheadername (FILE *infile) /* new version 95/Aug/30 */ +{ char fname[FNAMELEN]; /* buffer to get token into */ char *s; @@ -863,7 +931,8 @@ void getheadername (FILE *infile) { /* new version 95/Aug/30 */ /* get name of file with DSC header comments */ /* only one allowed */ -void getcustomname (FILE *infile) { +void getcustomname (FILE *infile) +{ /* int n=0; */ if (dscfile != NULL) { @@ -883,7 +952,8 @@ void getcustomname (FILE *infile) { /* accumulate verbatim PS header text for prolog */ - void getheadertext (FILE *infile) { /* new 1993/Dec/29 */ +void getheadertext (FILE *infile) /* new 1993/Dec/29 */ +{ char *headernew; char *u; int n; @@ -899,7 +969,7 @@ void getcustomname (FILE *infile) { /* errcount(0); */ /* return; */ checkexit(1); /* 1995/July/15 */ -// more serious exit(1) ??? +// more serious exit(1) ??? } headertext = headernew; u = headernew + headertextlen; @@ -910,7 +980,8 @@ void getcustomname (FILE *infile) { /* accumulate command line args for DVIPSONE - passed through DVI file */ -void getcommandspec (FILE *infile) { // 99/Sept/6 +void getcommandspec (FILE *infile) // 99/Sept/6 +{ char *commandnew; char *u; int n; @@ -931,7 +1002,8 @@ void getcommandspec (FILE *infile) { // 99/Sept/6 /* accumulate verbatim PS header text for prolog */ -void getcustomtext (FILE *infile) { /* new 1995/July/15 */ +void getcustomtext (FILE *infile) /* new 1995/July/15 */ +{ int c, n, needpercent=0; char *customnew; char *u; @@ -963,7 +1035,8 @@ void getcustomtext (FILE *infile) { /* new 1995/July/15 */ *u++ = '\n'; *u++ = '\0'; /* terminating linefeed and \0 */ } -void getbbox (FILE *infile) { /* Use for CropBox pdfmark not tested */ +void getbbox (FILE *infile) /* Use for CropBox pdfmark not tested */ +{ /* Right now this is in PS coordinates, should be in TeX coordinates */ if (gettoken(infile, line, sizeof(line)) != 0) { /* MAXLINE */ sscanf(line, "%d", &BBxll); @@ -981,7 +1054,8 @@ void getbbox (FILE *infile) { /* Use for CropBox pdfmark not tested */ /* accumulate Keywords for DOCINFO pdfmark */ -void getkeywords (FILE *infile) { /* 1996/May/10 */ +void getkeywords (FILE *infile) /* 1996/May/10 */ +{ char *keywordsnew; char *u; int n, c; @@ -1019,7 +1093,8 @@ void getkeywords (FILE *infile) { /* 1996/May/10 */ } // void getcommonstring (FILE *infile, char *newstring) -char *getcommonstring (FILE *infile) { +char *getcommonstring (FILE *infile) +{ char *u; char *newstring = malloc ((size_t) (nspecial+1)); if (newstring == NULL) { @@ -1035,42 +1110,48 @@ char *getcommonstring (FILE *infile) { // unadvertized ability to change Creator fieldin DocInfo -void getcreator (FILE *infile) { +void getcreator (FILE *infile) +{ if (creatorstring != NULL) return; /* ignore all but first */ // creatorstring = malloc ((size_t) (nspecial+1)); // getcommonstring(infile, creatorstring); creatorstring = getcommonstring(infile); } -void gettitle (FILE *infile) { +void gettitle (FILE *infile) +{ if (titlestring != NULL) return; /* ignore all but first */ // titlestring = malloc ((size_t) (nspecial+1)); // getcommonstring(infile, titlestring); titlestring = getcommonstring(infile); } -void getsubject (FILE *infile) { +void getsubject (FILE *infile) +{ if (subjectstring != NULL) return; /* ignore all but first */ // subjectstring = malloc ((size_t) (nspecial+1)); // getcommonstring(infile, subjectstring); subjectstring = getcommonstring(infile); } -void getauthor (FILE *infile) { +void getauthor (FILE *infile) +{ if (authorstring != NULL) return; /* ignore all but first */ // authorstring = malloc ((size_t) (nspecial+1)); // getcommonstring(infile, authorstring); authorstring = getcommonstring(infile); } -void getbase (FILE *infile) { +void getbase (FILE *infile) +{ if (basestring != NULL) return; /* ignore all but first */ // basestring = malloc ((size_t) (nspecial+1)); // getcommonstring(infile, basestring); basestring = getcommonstring(infile); } -void getpagemode (FILE *infile) { +void getpagemode (FILE *infile) +{ if (pagemode != NULL) return; /* ignore all but first */ // pagemode = malloc ((size_t) (nspecial+1)); // getcommonstring(infile, pagemode); @@ -1079,7 +1160,8 @@ void getpagemode (FILE *infile) { /* example \special{papersize=5.04in,3.751in} */ -void getpapersize (FILE *infile) { +void getpapersize (FILE *infile) +{ // if (strcmp(papersize,"") != 0) return; /* ignore all but first */ if (papersize != NULL) return; // papersize = malloc ((size_t) (nspecial+1)); @@ -1093,13 +1175,15 @@ int bComplainSpecial=1; /* Attempt at \special{background rgb 0 0 1} support 98 June 30 */ -void DoBackGround (FILE *infile, int c) { +void DoBackGround (FILE *infile, int c) +{ char *s; int n, m; int setcolor=0; COLORSPEC SavedColor; - if (bBackGroundFlag == 0) { + if (bBackGroundFlag == 0) + { flushspecial(infile); return; } @@ -1109,7 +1193,8 @@ void DoBackGround (FILE *infile, int c) { *s = '\0'; /* just in case */ (void) scanspecial(input, line, MAXLINE); - if (traceflag) { + if (traceflag) + { sprintf(logline, "\n%s %c (%d) ", line, c, c); showline(logline, 0); } @@ -1120,15 +1205,18 @@ void DoBackGround (FILE *infile, int c) { if (bKeepBlack) return; /* 96/Nov/3 */ SavedColor = CurrColor; /* 99/Apr/06 */ - if (strncmp(s, "rgb", 3) == 0) { + if (strncmp(s, "rgb", 3) == 0) + { s += 3; m = sscanf(s, "%g %g %g%n\n", &CurrColor.A, &CurrColor.B, &CurrColor.C, &n); - if (m == 3) { + if (m == 3) + { CurrColor.D = -1.0F; setcolor=1; s += n; } - else { + else + { complainspecial(input); return; } @@ -1181,7 +1269,8 @@ void DoBackGround (FILE *infile, int c) { return; } - if (traceflag) { + if (traceflag) + { sprintf(logline, " PAGENUMBER %d (%d %d) ", pagenumber, dvi_t, MaxColor); showline(logline, 0); } @@ -1193,7 +1282,8 @@ void DoBackGround (FILE *infile, int c) { return; } - if (traceflag) { + if (traceflag) + { sprintf(logline, "\npage %d %g %g %g %g\n", pagenumber, CurrColor.A, CurrColor.B, CurrColor.C, CurrColor.D); @@ -1226,11 +1316,13 @@ char *tpiccommands = "pa fp ip da dt sp pn ar ia sh wh bk tx"; /* also check for \special{color ...} */ /* also check for \special{background ...} 98/Jun/30 */ -void logdo_com (FILE *infile) { +void logdo_com (FILE *infile) +{ int c; /* int k=0; */ - if (bIgnoreSpecials) { + if (bIgnoreSpecials) + { flushspecial(infile); return; } @@ -1321,43 +1413,50 @@ void logdo_com (FILE *infile) { flushspecial(infile); } -void logdo_xxxi(FILE *infile, unsigned int n) { +void logdo_xxxi(FILE *infile, unsigned int n) +{ /* unsigned int k; */ nspecial = (long) n; logdo_com(infile); /* for(k = 0; k < n; k++) getc(infile); */ } -void logdo_xxx1(FILE *infile) { /* for /special */ +void logdo_xxx1(FILE *infile) /* for /special */ +{ unsigned int k; k = getc(infile); logdo_xxxi(infile, k); } -void logdo_xxx2(FILE *infile) { /* for /special */ - unsigned int k; +void logdo_xxx2(FILE *infile) /* for /special */ +{ + unsigned int k; k = ureadtwo(infile); logdo_xxxi(infile, k); } -void logdo_xxxl(FILE *infile, unsigned long n) { +void logdo_xxxl(FILE *infile, unsigned long n) +{ /* unsigned long k; */ nspecial=(long) n; logdo_com(infile); /* for(k = 0; k < n; k++) getc(infile); */ } -void logdo_xxx3(FILE *infile) { +void logdo_xxx3(FILE *infile) +{ logdo_xxxl(infile, ureadthree(infile)); } -void logdo_xxx4(FILE *infile) { +void logdo_xxx4(FILE *infile) +{ logdo_xxxl(infile, ureadfour(infile)); } /* need to do this even if skipping pages */ -void logfnt_def(FILE *infile, unsigned int k) { +void logfnt_def(FILE *infile, unsigned int k) +{ int fn; unsigned int na, nl, i; int newfont=1; /* if this is a new one (not defined before) */ @@ -1445,32 +1544,37 @@ void logfnt_def(FILE *infile, unsigned int k) { memset(fontchar[fn], 0, MAXCHRS); } -void logdo_fnt_def1(FILE *infile) { /* define font */ +void logdo_fnt_def1(FILE *infile) /* define font */ +{ unsigned int k; /* k = ureadone(infile); */ k = getc(infile); logfnt_def(infile, k); } -void logdo_fnt_def2(FILE *infile) { /* define font */ +void logdo_fnt_def2(FILE *infile) /* define font */ +{ unsigned int k; k = ureadtwo(infile); if (k >= MAXFONTNUMBERS) k = MAXFONTNUMBERS-1; logfnt_def(infile, k); } -void logdo_fnt_defsub(FILE *infile, unsigned long k) { +void logdo_fnt_defsub(FILE *infile, unsigned long k) +{ if (k >= MAXFONTNUMBERS) k = MAXFONTNUMBERS-1; logfnt_def(infile, (unsigned int) k); } -void logdo_fnt_def3(FILE *infile) { /* define font */ +void logdo_fnt_def3(FILE *infile) /* define font */ +{ /* unsigned long k; k = ureadthree(infile); */ logdo_fnt_defsub(infile, ureadthree(infile)); } -void logdo_fnt_def4(FILE *infile) { /* define font */ +void logdo_fnt_def4(FILE *infile) /* define font */ +{ long k; k = sreadfour(infile); if (k < 0) k = 0; @@ -1479,19 +1583,22 @@ void logdo_fnt_def4(FILE *infile) { /* define font */ /* need to do this even if skipping pages */ -void logdo_pre(FILE *infile) { +void logdo_pre(FILE *infile) +{ unsigned int i, k, j; int c; char *s; /* i = ureadone(infile); */ i = getc(infile); - if (i < 1 || i > 3) { + if (i < 1 || i > 3) + { showline("Not a valid DVI file ", 1); giveup(3); return; } - else if (i != ID_BYTE) { + else if (i != ID_BYTE) + { sprintf(logline, "File is DVI version %d - *not* %d\n", i, ID_BYTE); showline(logline, 1); @@ -1510,18 +1617,20 @@ void logdo_pre(FILE *infile) { comment = NULL; } comment = malloc(k+1); - if (comment == NULL) { + if (comment == NULL) + { showline(" Unable to allocate memory\n", 1); checkexit(1); // more serious exit(1) ??? } - s = comment; + s = comment; /* if (traceflag) fprintf(stdout, "Comment:"); */ c = getc(infile); /* try and discard initial space */ - if (c == ' ') k--; + if (c == ' ') k--; else (void) ungetc(c, infile); - for (j=0; j < k; j++) { - c = getc(infile); + for (j=0; j < k; j++) + { + c = getc(infile); if (j < MAXCOMMENT) *s++ = (char) c; /* if (verboseflag) putc(c, stdout); */ } @@ -1536,14 +1645,16 @@ void logdo_pre(FILE *infile) { /* need to do this even if skipping pages */ -void logdo_post(FILE *infile) { +void logdo_post(FILE *infile) +{ /* int k; */ previous = sreadfour(infile); /* was ureadfour ... */ num = ureadfour(infile); den = ureadfour(infile); mag = ureadfour(infile); - if (traceflag) { + if (traceflag) + { sprintf(logline, " POST: previous %ld num %ld den %ld mag %ld\n", previous, num, den, mag); showline(logline, 0); @@ -1566,7 +1677,8 @@ void logdo_post(FILE *infile) { /* could do this even in forward mode to check on number of pages ? */ -void logdo_post_post(FILE *infile) { /* only in reverse ? */ +void logdo_post_post(FILE *infile) /* only in reverse ? */ +{ /* unsigned long q; */ /* unsigned int i; */ @@ -1588,7 +1700,8 @@ void logdo_post_post(FILE *infile) { /* only in reverse ? */ /* Search for 3 or more zeros in a row, followed by dont-care (length) */ /* - followed by pre and ID_BYTE */ -int readovertext(FILE *infile) { +int readovertext(FILE *infile) +{ int c, n; c = getc(infile); @@ -1615,7 +1728,8 @@ int readovertext(FILE *infile) { } } -void resetpagerangehit (int flag) { +void resetpagerangehit (int flag) +{ /* int k; */ /* for (k = 0; k < rangeindex; k++) pagerangehit[k] = 0; */ /* 1994/Jan/16 */ /* currentrange = -1; */ @@ -1628,15 +1742,18 @@ void resetpagerangehit (int flag) { /***************************************************************************/ -void alloccolorsave (int npages) { +void alloccolorsave (int npages) +{ int k; - if (ColorStacks != NULL) { + if (ColorStacks != NULL) + { showline(" ERROR: color save stacks allocation\n", 1); freecolorsave(); } #ifdef DEBUGCOLORSTACK - if (traceflag) { + if (traceflag) + { sprintf(logline, "Allocating color save stack for %d pages\n", npages); showline(logline, 0); } @@ -1652,7 +1769,8 @@ void alloccolorsave (int npages) { MaxColor = npages+1; /* make note of size of allocation */ } -void freecolorsave (void) { +void freecolorsave (void) +{ int k, npages = MaxColor; if (ColorStacks == NULL) return; @@ -1672,11 +1790,13 @@ void freecolorsave (void) { } #ifdef DEBUGCOLORSTACK -void dumpcolorsave (void) { /* debugging only */ +void dumpcolorsave (void) /* debugging only */ +{ int k, m, i, npages = MaxColor-1; COLORSPEC *ColorSaved; - if (ColorStacks == NULL) { + if (ColorStacks == NULL) + { showline(" No saved color stacks to show\n", 1); return; } @@ -1704,7 +1824,8 @@ void dumpcolorsave (void) { /* debugging only */ } #endif -void allocbackground (int npages) { +void allocbackground (int npages) +{ int k; if (BackColors != NULL) { showline(" ERROR: background allocation\n", 1); @@ -1732,7 +1853,8 @@ void freebackground (void) { /***************************************************************************/ -int scanlogfileaux(FILE *fp_in) { +int scanlogfileaux(FILE *fp_in) +{ int c, k, fn; /* long filptr; */ @@ -1758,7 +1880,8 @@ int scanlogfileaux(FILE *fp_in) { bBackUsed=0; /* non-zero of \special{background ...} used */ bColorUsed = 0; /* assume no color \special until ... 98/Feb/15 */ - if (bCarryColor || bBackGroundFlag) { + if (bCarryColor || bBackGroundFlag) + { postposition = gotopost(input); /* in dvianal.c */ (void) getc(input); /* absorb the post byte */ logdo_post(input); @@ -1925,7 +2048,8 @@ int scanlogfileaux(FILE *fp_in) { /* main entry point, prescan DVI file font usage, \specials */ -int scanlogfile (FILE *fp_in) { +int scanlogfile (FILE *fp_in) +{ int c, d; input = fp_in; /* remember file handle */ @@ -1935,7 +2059,8 @@ int scanlogfile (FILE *fp_in) { d = getc(fp_in); rewind(fp_in); // we now forget about Textures files 99/July/14 - if (c != pre || d != ID_BYTE) { + if (c != pre || d != ID_BYTE) + { sprintf(logline, " Not a proper DVI file `%s'\n", (filenamex != NULL) ? filenamex : ""); showline(logline, 1); @@ -1970,23 +2095,26 @@ typedef struct map_element_struct { /* list element key . value pair */ struct map_element_struct *next; } map_element_type; -typedef map_element_type **map_type; +typedef map_element_type **map_type; /* **************************** auxiliary functions *********************** */ -static void complain_mem (unsigned int size) { /* out of memory */ +static void complain_mem (unsigned int size) /* out of memory */ +{ sprintf(logline, "Unable to honor request for %u bytes.\n", size); showline(logline, 1); checkexit(1); } -static void *xmalloc (unsigned int size) { +static void *xmalloc (unsigned int size) +{ void *new_mem = (void *) malloc (size); if (new_mem == NULL) complain_mem(size); return new_mem; } -static void *xrealloc (void *old_ptr, unsigned int size) { +static void *xrealloc (void *old_ptr, unsigned int size) +{ void *new_mem; if (old_ptr == NULL) /* new_mem = xmalloc (size); *//* could just let realloc do this case? */ @@ -1999,7 +2127,8 @@ static void *xrealloc (void *old_ptr, unsigned int size) { return new_mem; } -static char *xstrdup (char *s) { +static char *xstrdup (char *s) +{ char *new_string = (char *) xmalloc (strlen (s) + 1); return strcpy (new_string, s); } @@ -2013,7 +2142,8 @@ static char *xstrdup (char *s) { return answer; } */ /* used by extend_filename only */ -static void *xcalloc (unsigned int nelem, unsigned int elsize) { +static void *xcalloc (unsigned int nelem, unsigned int elsize) +{ void *new_mem = (void *) calloc (nelem, elsize); if (new_mem == NULL) complain_mem (nelem * elsize); return new_mem; @@ -2059,7 +2189,8 @@ static void *xcalloc (unsigned int nelem, unsigned int elsize) { #define BLOCK_SIZE 40 -static char *read_line (FILE *f) { +static char *read_line (FILE *f) +{ int c; unsigned int limit = BLOCK_SIZE; unsigned int loc = 0; @@ -2093,7 +2224,8 @@ static char *read_line (FILE *f) { /* The hash function. We go for simplicity here. */ -static unsigned int map_hash (char *key) { +static unsigned int map_hash (char *key) +{ unsigned int n = 0; char *s = key; /* There are very few font names which are anagrams of each other @@ -2111,7 +2243,8 @@ static unsigned int map_hash (char *key) { /* Look up STR in MAP. Return the corresponding `value' or NULL. */ -static char *map_lookup_str (map_type map, char *key) { +static char *map_lookup_str (map_type map, char *key) +{ unsigned int n = map_hash (key); map_element_type *p; @@ -2140,7 +2273,8 @@ static char *map_lookup_str (map_type map, char *key) { } #ifdef DEBUGALIAS -static void map_show (map_type map) { /* debugging tool */ +static void map_show (map_type map) /* debugging tool */ +{ map_element_type *p; unsigned int n; @@ -2163,7 +2297,8 @@ static void map_show (map_type map) { /* debugging tool */ /* Append the same suffix we took off, if necessary. */ /* if (ret) ret = extend_filename (ret, suffix); */ -char *map_lookup (map_type map, char *key) { +char *map_lookup (map_type map, char *key) +{ char *ret = map_lookup_str(map, key); /* char *suffix; */ @@ -2184,12 +2319,13 @@ char *map_lookup (map_type map, char *key) { /* If KEY is not already in MAP, insert it and VALUE. */ /* This was a total mess! Fixed 1994/March/18 */ -static void map_insert (map_type map, char *key, char *value) { +static void map_insert (map_type map, char *key, char *value) +{ unsigned int n = map_hash (key); - map_element_type **ptr = &map[n]; + map_element_type **ptr = &map[n]; - while (*ptr != NULL && !(strcmp(key, (*ptr)->key) == 0)) - ptr = &((*ptr)->next); + while (*ptr != NULL && !(strcmp(key, (*ptr)->key) == 0)) + ptr = &((*ptr)->next); if (*ptr == NULL) { *ptr = (map_element_type *) xmalloc (sizeof(map_element_type)); @@ -2210,7 +2346,8 @@ static void map_insert (map_type map, char *key, char *value) { `r', because of the virtual fonts Dvips uses. And what a load of bull! And who cares about DVIPS and VF files !*/ -static void map_file_parse (map_type map, char *map_filename) { +static void map_file_parse (map_type map, char *map_filename) +{ char *l; unsigned int map_lineno = 0; unsigned int entries = 0; @@ -2290,7 +2427,8 @@ static void map_file_parse (map_type map, char *map_filename) { TEXFONTS. Entries in earlier files override later files. */ /* void oursearchenv (char *mapname, char *envvar, char *pathname) { */ -void oursearchenv (char *mapname, char *searchpath, char *pathname) { +void oursearchenv (char *mapname, char *searchpath, char *pathname) +{ /* char *searchpath; */ /* 97/May/10 */ int foundfile=0; /* set, but not used ? */ #ifndef SUBDIRSEARCH @@ -2329,7 +2467,8 @@ void oursearchenv (char *mapname, char *searchpath, char *pathname) { /* Returns NULL if it failed for some reason */ /* map_type map_create (char *envvar) { */ /* 94/May/23 */ -map_type map_create (char *texfonts) { /* 97/May/10 */ +map_type map_create (char *texfonts) /* 97/May/10 */ +{ char pathname[_MAX_PATH]; map_type map; @@ -2364,7 +2503,8 @@ map_type fontmap = NULL; /* static - keep around once set */ /* returns NULL if failed to find an alias */ -char *alias (char *name) { +char *alias (char *name) +{ /* static map_type fontmap = NULL; */ /* static - keep around once set */ char *mapped_name; @@ -2402,7 +2542,8 @@ char *alias (char *name) { /* used for pfb search path and eps search path */ /* this version also allows space as separator */ -char *nextpathname(char *pathname, char *searchpath) { +char *nextpathname(char *pathname, char *searchpath) +{ int n; char *s; @@ -2478,7 +2619,8 @@ char *nextpathname(char *pathname, char *searchpath) { /* so save on stack space, by having one copy, not one per expand_subdir */ /* possibly allocate this in the caller of findsubpath ? not static ? */ -int findsubpath (char *filename, char *pathname, int recurse) { +int findsubpath (char *filename, char *pathname, int recurse) +{ char *s; int code; int ret; @@ -2622,8 +2764,9 @@ int findsubpath (char *filename, char *pathname, int recurse) { /* If a path in `pathlist' ends in \\, then this works recursively */ /* (which may be slow and cause stack overflows ...) */ -int searchalongpath (char *filename, char *pathlist, char *pathname, int current) { -/* struct _find_t c_file; * /* need to preserve across calls to DOS */ +int searchalongpath (char *filename, char *pathlist, char *pathname, int current) +{ +/* struct _find_t c_file; */ /* need to preserve across calls to DOS */ char *s, *t, *u, *send; int c, n; int recurse; @@ -2734,8 +2877,8 @@ int searchalongpath (char *filename, char *pathlist, char *pathname, int current /* if current < 0, look in PFM sub directories also */ // only place we use _alloca ... -FILE *findandopen (char *filename, char *pathlist, char *pathname, - char *mode, int current) { +FILE *findandopen (char *filename, char *pathlist, char *pathname, char *mode, int current) +{ FILE *file; if (pathname == NULL) { @@ -2759,14 +2902,15 @@ FILE *findandopen (char *filename, char *pathlist, char *pathname, /* stuff for reading .afm files */ -int readafm(char *font, FILE *fp_afm, long widths[]) { +int readafm(char *font, FILE *fp_afm, long widths[]) +{ double fwidth; int chr, k=0; /* if (fp_afm == NULL) checkexit(5); */ (void) getrealline(fp_afm, line); - while (strstr(line, "StartCharMetrics") == NULL) { + while (strstr(line, "StartCharMetrics") == NULL) { if(getrealline(fp_afm, line) == 0) { sprintf(logline, " Can't find CharMetrics in AFM file for %s\n", font); @@ -2803,7 +2947,8 @@ int readafm(char *font, FILE *fp_afm, long widths[]) { /* lf, lh, nw, nh, nd, ni, nl, nk, ne are numbers of words */ -int readtfm(char *font, FILE *fp_tfm, long widths[]) { +int readtfm(char *font, FILE *fp_tfm, long widths[]) +{ static long qwidths[MAXCHRS]; /* 256 */ int lf, lh, bc, ec, nw, nh, nd, ni, nl, nk, ne, np; int k; @@ -2839,7 +2984,7 @@ int readtfm(char *font, FILE *fp_tfm, long widths[]) { (void) sreadtwo(fp_tfm); /* design size */ /* discard rest of header */ for (k = 2; k < lh; k++) { - (void) getc(fp_tfm); (void) getc(fp_tfm); + (void) getc(fp_tfm); (void) getc(fp_tfm); } /* now read the actual widths */ fseek(fp_tfm, (long) ((6 + lh + (ec - bc + 1)) << 2), SEEK_SET); @@ -2879,7 +3024,8 @@ int readtfm(char *font, FILE *fp_tfm, long widths[]) { /* stuff for reading widths from .pfm files */ -int readpfm(char *font, FILE *fp_pfm, long widths[]) { +int readpfm(char *font, FILE *fp_pfm, long widths[]) +{ unsigned long length, offset; /* double fwidth; */ long lwidth; @@ -2887,7 +3033,8 @@ int readpfm(char *font, FILE *fp_pfm, long widths[]) { /* if (fp_pfm == NULL) checkexit(5); */ /* first check that this is a PFM file - start with version number */ - if ((c = getc(fp_pfm)) != 0 || (c = getc(fp_pfm)) != 1) { + if ((c = getc(fp_pfm)) != 0 || (c = getc(fp_pfm)) != 1) + { sprintf(logline, " Not a proper PFM file %s\n", font); showline(logline, 1); errcount(0); @@ -2945,7 +3092,8 @@ int readpfm(char *font, FILE *fp_pfm, long widths[]) { /* int pfminstance (FILE *input, char *FontName, int nlen) { */ int NamesFromPFM (FILE *input, char *FaceName, int nface, - char *FontName, int nfont, char *FileName) { + char *FontName, int nfont, char *FileName) +{ short version; long length, offset; int n, ndrive; @@ -3115,7 +3263,8 @@ int NamesFromPFM (FILE *input, char *FaceName, int nface, /* stuff for reading ATMREG.ATM imported from winpslog.c 98/Jan/9 */ -unsigned int xreadtwo (FILE *input) { +unsigned int xreadtwo (FILE *input) +{ unsigned int c, d, n; c = getc(input); d = getc(input); @@ -3123,7 +3272,8 @@ unsigned int xreadtwo (FILE *input) { return n; } -unsigned long xreadfour (FILE *input) { +unsigned long xreadfour (FILE *input) +{ unsigned int a, b, c, d; unsigned long n; a = getc(input); @@ -3142,7 +3292,8 @@ int bATM41=0; // needs to be set based on ATMREG.ATM header /* read string from ATMREG.ATM up to null, string may be empty */ /* returns -1 if hit EOF or name too long */ -int ReadString (FILE *input, char *name, int nlen) { +int ReadString (FILE *input, char *name, int nlen) +{ int c; int n=0; char *s=name; @@ -3205,7 +3356,8 @@ char **DirPaths=NULL; int dirindex=0; -void FreeDirs (void) { +void FreeDirs (void) +{ int k; if (DirPaths == NULL) return; for (k = 0; k <= nDirs; k++) { @@ -3217,7 +3369,8 @@ void FreeDirs (void) { DirPaths = NULL; } -int AllocDirs (int nDirs) { +int AllocDirs (int nDirs) +{ int k, nlen; if (DirPaths != NULL) FreeDirs(); nlen = (nDirs + 1) * sizeof(char *); @@ -3234,7 +3387,8 @@ int AllocDirs (int nDirs) { return 0; } -void FreeFonts (void) { +void FreeFonts (void) +{ int k; if (ATMFonts == NULL) return; for (k = 0; k < ATMfontindex; k++) { @@ -3247,7 +3401,8 @@ void FreeFonts (void) { ATMFonts = NULL; } -int AllocFonts (int nFonts) { +int AllocFonts (int nFonts) +{ int nlen; if (ATMFonts != NULL) FreeFonts(); nlen = nFonts * sizeof(struct ATMRegRec); @@ -3265,7 +3420,8 @@ int AllocFonts (int nFonts) { return 0; } -void ShowATMREG (void) { +void ShowATMREG (void) +{ int k; char *szType; sprintf(logline, "ATMREG has %d T1 font entries (out of %d total):\n", ATMfontindex, nFonts); @@ -3289,7 +3445,8 @@ void ShowATMREG (void) { /**********************************************************************************/ -int SetupDirs (FILE *input, unsigned long startdirlist, unsigned long enddirlist) { +int SetupDirs (FILE *input, unsigned long startdirlist, unsigned long enddirlist) +{ int c, k, noff, nlen; int npath=0; unsigned long noffset; @@ -3375,7 +3532,8 @@ int SetupDirs (FILE *input, unsigned long startdirlist, unsigned long enddirlist #ifdef IGNORED int SearchATMReg (FILE *input, unsigned long endfontlist, - char *szPSFontName, char *szPFBFileName) { + char *szPSFontName, char *szPFBFileName) +{ int c, k; unsigned int stroffset, nlen; unsigned long next; @@ -3502,7 +3660,8 @@ donext: /* 1999/Mar/1 */ /* WRITES BACK INTO SECOND ARGUMENT */ /* returns 0 if found, -1 if not found */ -int SearchATMReg (char *szPSFontName, char *szPFBFileName) { +int SearchATMReg (char *szPSFontName, char *szPFBFileName) +{ int k; for (k = 0; k < ATMfontindex; k++) { if (strcmp(szPSFontName, ATMFonts[k].FontName) == 0) { @@ -3517,7 +3676,8 @@ int SearchATMReg (char *szPSFontName, char *szPFBFileName) { /* Create new ATMFonts data structure 2000 July */ -int ScanATMReg (FILE *input, unsigned long endfontlist) { +int ScanATMReg (FILE *input, unsigned long endfontlist) +{ int c, k; unsigned int stroffset, nlen; unsigned long next; @@ -3645,7 +3805,8 @@ donext: /* 1999/Mar/1 */ /* also determines whether wide strings are used (ATM 4.1) */ /* also reads in directory path table */ -unsigned long ReadPointers (FILE *input) { +unsigned long ReadPointers (FILE *input) +{ (void) fseek(input, 6, SEEK_SET); nDirs = xreadtwo(input); /* 6 number of directory paths */ nFonts = xreadtwo(input); /* 8 number of font entries */ @@ -3673,7 +3834,8 @@ unsigned long ReadPointers (FILE *input) { return endfontlist; } -int SetupATMReg (void) { +int SetupATMReg (void) +{ char szFullFileName[FNAMELEN]=""; if (useatmreg == 0) return -1; /* tried already and failed */ @@ -3694,7 +3856,8 @@ int SetupATMReg (void) { // LOAD information from ATMREG.ATM in convenient form 2000 July 6 -int LoadATMREG (void) { +int LoadATMREG (void) +{ FILE *input; int count; @@ -3736,7 +3899,8 @@ int LoadATMREG (void) { /* WRITES BACK INTO SECOND ARGUMENT */ #ifdef IGNORED -int LookupATMReg (char *szPSFontName, char *szPSFileName) { +int LookupATMReg (char *szPSFontName, char *szPSFileName) +{ FILE *input; int n=0; @@ -3764,7 +3928,8 @@ int LookupATMReg (char *szPSFontName, char *szPSFileName) { /* First arg is PS FontName */ /* WRITES BACK INTO SECOND ARG */ -int LookupATMReg (char *szPSFontName, char *szPSFileName) { +int LookupATMReg (char *szPSFontName, char *szPSFileName) +{ int n; if (! useatmreg) return -1; // tried before and failed if (szATMRegAtm == NULL) { // create ATMFonts structure diff --git a/src/dvisourc/dvipsone.c b/src/dvisourc/dvipsone.c index 39c2430..582ab5e 100644 --- a/src/dvisourc/dvipsone.c +++ b/src/dvisourc/dvipsone.c @@ -897,7 +897,7 @@ char *zstrdup (char *s) /* new central location 1996/Aug/28 */ // exit(1); // pretty serious ! #endif uexit(1); - return new; // keep compiler happy +// return new; // keep compiler happy } /*****************************************************************************/ @@ -1799,7 +1799,7 @@ int abortjob (void) #ifdef _WINDOWS showline("ABORTJOB", 1); // debugging only - can't happen #endif - cleanup(); + cleanup(); checkexit(3); return -1; } @@ -1809,7 +1809,8 @@ void errcount (int flag) { if (flag) errlevel++; /* if (errlevel > MAXERRORS) { */ - if (errlevel > nMaxErrors && nMaxErrors > 0) { /* 95/Dec/28 */ + if (errlevel > nMaxErrors && nMaxErrors > 0) /* 95/Dec/28 */ + { showline("\n", 0); sprintf(logline, "Too many errors (> %d) - giving up", nMaxErrors); showline(logline, 1); @@ -4534,12 +4535,13 @@ int dodefaults (void) /* moved out 1994/May/23 */ if (yoffsete == UNKNOWNOFFSET) yoffsete = 0.0; if (yoffseto == UNKNOWNOFFSET) yoffseto = yoffsete; - if (quietflag == 3) { /* dvipsone -qqq */ + if (quietflag == 3) /* dvipsone -qqq */ + { // showpedigree(stdout); showpedigree(line, sizeof(line)); /* MAXLINE */ showline(line, 0); checkexit(0); /* 96/Feb/25 */ - return 0; +// return 0; } quietflag = (quietflag & 1); /* only depend on even/odd */ diff --git a/src/dvisourc/dvispeci.c b/src/dvisourc/dvispeci.c index 21d1fc1..76c53ca 100644 --- a/src/dvisourc/dvispeci.c +++ b/src/dvisourc/dvispeci.c @@ -111,7 +111,8 @@ char moreline[MAXLINE]; // for tokens in special double xll, yll, xur, yur; /* error message output of beginning of long item */ -char *showbeginning (char *s, char *t, int n) { +char *showbeginning (char *s, char *t, int n) +{ int k; for (k=0; k < n; k++) *s++ = *t++; // fputs("...\n", output); @@ -124,7 +125,8 @@ char *showbeginning (char *s, char *t, int n) { /* returns 0 if no more tokens found - else returns terminator */ /* what to do if error ? */ -int getalphatoken (FILE *input, char *token, int nmax) { +int getalphatoken (FILE *input, char *token, int nmax) +{ int c, k = 0; char *s = token; @@ -181,7 +183,8 @@ int getalphatoken (FILE *input, char *token, int nmax) { /* flush rest of special to get back to rest of DVI code */ -void flushspecial(FILE *input) { +void flushspecial(FILE *input) +{ int c; if (nspecial <= 0) return; c = getc(input); nspecial--; @@ -193,7 +196,8 @@ void flushspecial(FILE *input) { /* - either up to white space - or - double quote delimited */ /* returns 0 if no more tokens found - else returns terminator */ -int gettoken (FILE *input, char *buff, int nmax) { +int gettoken (FILE *input, char *buff, int nmax) +{ int c, k=0, marker=' '; // end of token marker char *s=buff; @@ -259,7 +263,8 @@ int gettoken (FILE *input, char *buff, int nmax) { /* copy special into line buffer for sscanf */ /* - either double quote delimited - or - up to end of special */ -int scanspecial (FILE *input, char *buff, int nmax) { +int scanspecial (FILE *input, char *buff, int nmax) +{ int c, k=0; char *s=buff; @@ -311,7 +316,8 @@ int scanspecial (FILE *input, char *buff, int nmax) { /* As above, but do not fiddle with "..." 97/Nov/11 needed for "mark" */ -int scanspecialraw (FILE *input, char *buff, int nmax) { +int scanspecialraw (FILE *input, char *buff, int nmax) +{ int c, k=0; char *s=buff; @@ -349,7 +355,8 @@ int scanspecialraw (FILE *input, char *buff, int nmax) { /* possibly just use scanspecial or gettoken instead ? */ /* return value seems to be mostly ignored */ -int getstring (FILE *input, char *buff, int nmax) { +int getstring (FILE *input, char *buff, int nmax) +{ int c, k = 0; char *s=buff; @@ -383,7 +390,8 @@ int getstring (FILE *input, char *buff, int nmax) { } /* skip forward to comma in special string */ -void skiptocomma(FILE *input) { +void skiptocomma(FILE *input) +{ int c; if (nspecial <= 0) return; c = getc(input); --nspecial; @@ -393,7 +401,8 @@ void skiptocomma(FILE *input) { } /* skip over double-quote-delimited string in special string */ -void flushstring (FILE *input) { +void flushstring (FILE *input) +{ int c; if (nspecial <= 0) return; c = getc(input); --nspecial; @@ -415,7 +424,8 @@ void flushstring (FILE *input) { /* copystring starts by emitting '\n' */ /* copystring ends by emitting '\n' when it is done */ -void copystring (FILE *output, FILE *input) { +void copystring (FILE *output, FILE *input) +{ int c; int column=0; int nesting=0; /* 1999/Feb/28 */ @@ -505,7 +515,8 @@ void copystring (FILE *output, FILE *input) { /* copy verbatim PostScript - but strip bracket enclosed crap first */ /* global | local | inline | asis | begin | end ??? */ -void stripbracket (FILE *output, FILE *input) { +void stripbracket (FILE *output, FILE *input) +{ int c; c = getc(input); nspecial--; @@ -533,7 +544,8 @@ void stripbracket (FILE *output, FILE *input) { /* try and find bbox at end of file */ /* the following may inefficiently read stuff several times, but, so what */ -int findbboxatend (FILE *special, char *fname, long pslength) { +int findbboxatend (FILE *special, char *fname, long pslength) +{ int k, foundit = 0; /* if (pslength > 0) fseek(special, pslength - (long) STEPSIZE, SEEK_SET); */ @@ -572,7 +584,8 @@ int skiphpjunkathead (FILE *, int); /* extract bounding box from inserted eps file and offset */ -int readbbox (FILE *special, char *fname, long pslength) { +int readbbox (FILE *special, char *fname, long pslength) +{ char *s; int c, k; @@ -649,8 +662,8 @@ int readbbox (FILE *special, char *fname, long pslength) { /* if needshift < 0 then (xll, yur) is at TeX's current point */ /* - last one only used by DVIALW ? */ -void dealwithbbox (FILE *output, FILE *special, char *fname, - long pslength, int needshift) { +void dealwithbbox (FILE *output, FILE *special, char *fname, long pslength, int needshift) +{ if (readbbox(special, fname, pslength) > 0) { /* now perform shift - if asked for it */ if (needshift > 0) { @@ -676,7 +689,8 @@ void dealwithbbox (FILE *output, FILE *special, char *fname, /* returns 0 if not found, +1 if found and not resident, -1 if resident */ /* file name returned in second arg */ /* first arg *is* case sensitive */ -int FindFileName (char *fontname, char *filename) { /* experiment 94/Aug/15 */ +int FindFileName (char *fontname, char *filename) /* experiment 94/Aug/15 */ +{ int k; if (fontname == NULL) return 0; @@ -727,7 +741,8 @@ int FindFileName (char *fontname, char *filename) { /* experiment 94/Aug/15 */ /* Emits on stdout the font file name (minus trailing _) unless mmflag set */ char *fopenfont_sub (FILE *atmfile, char *FontName, char *pfbname, - int atmflag, int mmflag){ + int atmflag, int mmflag) +{ /* FILE *atmfile; */ /* char atmini[FNAMELEN]; */ /* char *windir; */ @@ -881,7 +896,8 @@ char *fopenfont_sub (FILE *atmfile, char *FontName, char *pfbname, /* maybe don't look along PSFONTS path if pfbname contains \ or / ? */ /* changed to look in current directory first 98/Jul/20 */ -FILE *findpfbfile (char *pfbname, char *FileName) { /* 1994/Aug/18 */ +FILE *findpfbfile (char *pfbname, char *FileName) /* 1994/Aug/18 */ +{ FILE *pfbfile; char filename[FNAMELEN]; /* used for PFB file name ? */ @@ -915,7 +931,8 @@ FILE *findpfbfile (char *pfbname, char *FileName) { /* 1994/Aug/18 */ #else -FILE *findpfbfile (char *pfbname, char *FileName) { +FILE *findpfbfile (char *pfbname, char *FileName) +{ FILE *pfbfile; char *searchpath; char filename[FNAMELEN]; /* used for PFB file name ? */ @@ -959,7 +976,8 @@ FILE *findpfbfile (char *pfbname, char *FileName) { /* find the atmfonts.map file and get its full path */ -int setupatmfontsmap (void) { +int setupatmfontsmap (void) +{ FILE *atmfile=NULL; char atmfilename[FNAMELEN]; #ifndef SUBDIRSEARCH @@ -1021,9 +1039,10 @@ int setupatmfontsmap (void) { /* Returns NULL if font file not found */ /* FILE *fopenfont (char *FontName, char *FileName) */ -FILE *fopenfont (char *FontName, char *FileName, int mmflag) { +FILE *fopenfont (char *FontName, char *FileName, int mmflag) +{ FILE *atmfile=NULL; - FILE *pfbfile=NULL; + FILE *pfbfile=NULL; char pfbfilename[FNAMELEN]; /* use for full PFB file name */ /* char *windir; */ char *s; @@ -1144,7 +1163,8 @@ FILE *fopenfont (char *FontName, char *FileName, int mmflag) { /* Returns 0 if plain ASCII format - or length of PS section if not */ /* Also advances file to start of PostScript part */ -long checkpcform (FILE *special, char *fname) { +long checkpcform (FILE *special, char *fname) +{ unsigned long n, m; /* unsigned long i; */ int c, k; @@ -1193,26 +1213,26 @@ long checkpcform (FILE *special, char *fname) { /**************************************************************************** * * -* The EPSF header has the following structure: * +* The EPSF header has the following structure: * * * -* 0-3 the first four bytes are the letters EPSF with the meta-bit on - * -* that is, hex C5D0D3C6. * -* 4-7 the next four are the byte position of start of the PS section * +* 0-3 the first four bytes are the letters EPSF with the meta-bit on - * +* that is, hex C5D0D3C6. * +* 4-7 the next four are the byte position of start of the PS section * * 8-11 The next four are the length of the PostScript part of file; * -* 12-15 The next four are the byte position of start of MetaFile version; * -* 16-19 The next four are the length of the MetaFile version; * -* 20-23 The next four are the byte position of start of TIFF version; * -* 24-27 The next four are the length of the TIFF version; * -* 28-29 The next two bytes are the header checksum or hex FFFF * -* that is, two bytes that are all ones (meta-control-? = 255) * +* 12-15 The next four are the byte position of start of MetaFile version; * +* 16-19 The next four are the length of the MetaFile version; * +* 20-23 The next four are the byte position of start of TIFF version; * +* 24-27 The next four are the length of the TIFF version; * +* 28-29 The next two bytes are the header checksum or hex FFFF * +* that is, two bytes that are all ones (meta-control-? = 255) * * * -* IN EACH CASE THE LOW ORDER BYTE IS GIVEN FIRST * +* IN EACH CASE THE LOW ORDER BYTE IS GIVEN FIRST * * * -* Either the MetaFile length or the TIFF length or both are zero * +* Either the MetaFile length or the TIFF length or both are zero * * * -* If there is no MetaFile or Tiff version, the PS code starts at 30 * +* If there is no MetaFile or Tiff version, the PS code starts at 30 * * * -* The file produced as plain PS by Designer, instead starts and ends * +* The file produced as plain PS by Designer, instead starts and ends * * on control-D. The first control-D is followed by %, * * which is non-standard, to say the least. * * * @@ -1221,7 +1241,8 @@ long checkpcform (FILE *special, char *fname) { /* FreeHand produces EPS file only %%EndDocument, no %%BeginDocument ! */ /* Canvas produces EPS file that end with %%EndDocument: */ -void warnnesting (int nesting) { +void warnnesting (int nesting) +{ if (nesting != 0) { sprintf(logline, " nesting level %d at end", nesting); showline(logline, 1); @@ -1232,7 +1253,8 @@ void warnnesting (int nesting) { /* and also for EPS when -*s on command line */ /* flush blank lines ? flush comment lines ? <- NOT SAFE */ -int copyepssimple (FILE *output, FILE *special) { /* 1993/Jan/24 */ +int copyepssimple (FILE *output, FILE *special) /* 1993/Jan/24 */ +{ int c; while ((c = getc(special)) != EOF) { if (c >= 128) { @@ -1267,7 +1289,8 @@ int copyepssimple (FILE *output, FILE *special) { /* 1993/Jan/24 */ return 0; } -void reincludefont (FILE *output, char *FontName) { +void reincludefont (FILE *output, char *FontName) +{ /* fputs(line, output); */ /* line has been changed */ // fputs("%%", output); PSputs("%%", output); @@ -1291,7 +1314,8 @@ void reincludefont (FILE *output, char *FontName) { /* Should really implement more modern %%BeginData also ? */ -int CopyBinary (FILE *output, FILE *special, long nbytes) { +int CopyBinary (FILE *output, FILE *special, long nbytes) +{ long kk; int c=0; @@ -1326,7 +1350,8 @@ int CopyBinary (FILE *output, FILE *special, long nbytes) { /* Skip %%BeginPreview: .... to %%EndPreview */ -long SkipEPSI (FILE *special) { /* 97/June/5 */ +long SkipEPSI (FILE *special) /* 97/June/5 */ +{ long nbytes=0; int k; for (;;) { @@ -1348,7 +1373,8 @@ long SkipEPSI (FILE *special) { /* 97/June/5 */ // %-12345X@PJL EOJ // %-12345X -int skiphpjunkathead (FILE *special, int flag) { // 99/Oct/14 +int skiphpjunkathead (FILE *special, int flag) // 99/Oct/14 +{ int c; c = getc(special); // escape character (27) c = getc(special); // % @@ -1377,7 +1403,8 @@ int skiphpjunkathead (FILE *special, int flag) { // 99/Oct/14 /* called only by copyepsfileaux --- copyepsfilesub does not close file */ -void copyepsfilesub (FILE *output, FILE *special, long pslength) { +void copyepsfilesub (FILE *output, FILE *special, long pslength) +{ int k, nesting=0; int c=0; /* keep down complaints */ int hpjunkflag=0; // set if escape (27) at start @@ -1761,7 +1788,8 @@ void copyepsfilesub (FILE *output, FILE *special, long pslength) { /* Is there any problem here because of C-M and C-J ??? */ /* Input now is `rb' mode, output possibly in `w' (or `wb' mode) */ -int copyepsfilesimple (FILE *output, FILE *special, long pslength) { +int copyepsfilesimple (FILE *output, FILE *special, long pslength) +{ int c; if (! bPassEPSF) { /* 1994/Mar/9 */ @@ -1783,7 +1811,8 @@ int copyepsfilesimple (FILE *output, FILE *special, long pslength) { /* do similar hack for extension longer than 3 characters ? */ /* trunactes file name is long */ -int islongname (char *name) { +int islongname (char *name) +{ char *s, *t; if ((t = strrchr(name, '.')) == NULL) t = name + strlen(name); s = t; @@ -1822,7 +1851,8 @@ int islongname (char *name) { /* FINDEPSFILE: Try to open the file to be included (or overlayed) */ /* FILE *findepsfile(char *name, int warnflag) { */ /* 1993/Oct/13 */ -FILE *findepsfile (char *name, char *ext, int warnflag, int readflag) { +FILE *findepsfile (char *name, char *ext, int warnflag, int readflag) +{ FILE *special=NULL; char *s; char *epsname=""; /* may be used before defined ??? */ @@ -1953,14 +1983,15 @@ FILE *findepsfile (char *name, char *ext, int warnflag, int readflag) { showline(logline, 0); } /* if ((ret = _stat(filename, &statbuf)) != 0) { - sprintf(logline, "ERROR: Unable to obtain info on %s\n", filename); + sprintf(logline, "ERROR: Unable to obtain info on %s\n", filename); } */ /* printf("- FILENAME %s - EPSNAME %s - ", filename, epsname); */ return special; } -void copyepsfileaux (FILE *output, FILE *special, char *fname) { +void copyepsfileaux (FILE *output, FILE *special, char *fname) +{ long pslength; /* zero or length of PS section in EPSF file */ int ret; char *s; @@ -2059,7 +2090,8 @@ int setupbbox(char *epsfilename) { /* Note: copyepsfile also opens and closes the special file */ -void copyepsfile (FILE *output, char *epsfilename, int inclflag, int needshift) { +void copyepsfile (FILE *output, char *epsfilename, int inclflag, int needshift) +{ FILE *special; long pslength; @@ -2082,7 +2114,8 @@ void copyepsfile (FILE *output, char *epsfilename, int inclflag, int needshift) /* copy rest of special to get back to rest of DVI code (used by Textures) */ -void colontoslash (char *name, char *buff) { +void colontoslash (char *name, char *buff) +{ int c; char *s=name; char *t=buff; @@ -2100,31 +2133,36 @@ void colontoslash (char *name, char *buff) { *s = '\0'; } -void startspecial (FILE *output) { +void startspecial (FILE *output) +{ PSputc('\n', output); // always in new line ? PSputs("dvispsav undsclx dvispbeg ", output); } -void startspecial1 (FILE *output) { +void startspecial1 (FILE *output) +{ PSputc('\n', output); // always in new line ? PSputs("dvispsav ", output); } -void startspecial2 (FILE *output) { +void startspecial2 (FILE *output) +{ PSputc('\n', output); // always in new line ? PSputs("dvispbeg ", output); } /* dvidict /dvispend get exec <== 92/Nov/26 */ -void endspecial (FILE *output) { +void endspecial (FILE *output) +{ // PSputc('\n', output); // always in new line ? PSputs("dvidict /dvispend get exec\n", output); } #define MAXCOMPLAIN 127 -void complainspecial (FILE *input) { /* list contents and do flushspecial */ +void complainspecial (FILE *input) /* list contents and do flushspecial */ +{ int c, k=0; /* long specnow; */ @@ -2165,7 +2203,8 @@ void complainspecial (FILE *input) { /* list contents and do flushspecial */ /* fseek(input, specnow, SEEK_SET); */ /* and restore count ? */ } -void complainjflag (FILE *input) { /* 1993/Oct/17 */ +void complainjflag (FILE *input) /* 1993/Oct/17 */ +{ /* if (complainedaboutj++ > 0) return; */ if (complainedaboutj++ == 0) showline(" WARNING: verbatim PS - use `j' flag?", 1); @@ -2174,7 +2213,8 @@ void complainjflag (FILE *input) { /* 1993/Oct/17 */ /* Textures style include eps file */ /* added "scaled " ? */ -void readtextures (FILE *output, FILE *input) { /* Texture style special ? */ +void readtextures (FILE *output, FILE *input) /* Texture style special ? */ +{ int c; int clipflag = 0; double scale=1.0; @@ -2248,7 +2288,8 @@ void readtextures (FILE *output, FILE *input) { /* Texture style special ? */ /* Textures style "postscript" - direct inclusion of PostScript code */ /* void copypostscript(FILE *output, FILE *input) {*/ /* Texture style special ? */ -void copypostscript (FILE *output, FILE *input, int rawflag) { /* 1994/July/4 */ +void copypostscript (FILE *output, FILE *input, int rawflag) /* 1994/July/4 */ +{ /* startspecial(output); */ /* why not just use undscl ??? */ /* fputs("\nrevscl ", output); */ @@ -2278,7 +2319,8 @@ void copypostscript (FILE *output, FILE *input, int rawflag) { /* 1994/July/4 */ /* can this really take a scale factor ? */ /* should this neuter stuff ? and use save-restore pair ? */ /* void readpostscript(FILE *output, FILE *input) { */ /* Texture style special ? */ -void readpostscript (FILE *output, FILE *input, int rawflag) { /* 1994/July/5 */ +void readpostscript (FILE *output, FILE *input, int rawflag) /* 1994/July/5 */ +{ /* int c; */ double scale=1.0; char epsname[FNAMELEN]=""; @@ -2326,7 +2368,8 @@ void readpostscript (FILE *output, FILE *input, int rawflag) { /* 1994/July/5 */ /* There may be a problem if /magnification != 1000 */ /* - since OzTeX uses absolute 72 per inch scaling ??? */ -int readandrew (FILE *output, FILE *input) { +int readandrew (FILE *output, FILE *input) +{ FILE *special; char epsfilename[FNAMELEN]=""; @@ -2366,7 +2409,8 @@ int readandrew (FILE *output, FILE *input) { } /* separator is ` ' (space) */ /* DVIALW style special ? */ -int readdvialw (FILE *output, FILE *input) { +int readdvialw (FILE *output, FILE *input) +{ char epsfilename[FNAMELEN]=""; long flitpos=0; /* place in file where literal was */ long fendspec; /* saved pointer to end of special */ @@ -2523,7 +2567,7 @@ void doclip (FILE *output) { /* 92/Nov/28 */ void texlandscape(FILE *output) { /* 92/Nov/28 */ PSputc('\n', output); // always on new line ? PSputs("dvidict begin ", output); - PSputs("revscl Texlandscape forscl end\n", output); + PSputs("revscl Texlandscape forscl end\n", output); } void endtexfig(FILE *output) { /* 92/Nov/28 */ @@ -2550,7 +2594,8 @@ void starttexfig(FILE *output, long pswidth, long psheight, /* ... need to touch up coords in startTexFig line */ #ifdef ALLOWSCALE -void rescaletexfig (char *line) { +void rescaletexfig (char *line) +{ char *s; int n; long w, h, llx, lly, urx, ury; @@ -2588,7 +2633,8 @@ void cantfind (FILE *input, char *s, char *line) { /* complain about missing fie /* output verbatim what is in buffer - except leading white space */ /* rewritten 1994/June/27 for crude wrapping of long lines */ -void verbout (FILE *output, char *str) { +void verbout (FILE *output, char *str) +{ char *s=str; // work from string int c; int column=0; @@ -2633,7 +2679,8 @@ void verbout (FILE *output, char *str) { /* split up the following - its too darn long ! */ /* Separator is `=' dvi2ps style */ -int readdvi2ps (FILE *output, FILE *input) { +int readdvi2ps (FILE *output, FILE *input) +{ char epsfilename[FNAMELEN]=""; /* int includeflag=1; */ /* always include instead of overlay */ int firsttime=1; /* already read first token */ @@ -2928,7 +2975,8 @@ int readdvi2ps (FILE *output, FILE *input) { /* example: \special{picture screen0 scaled 500} */ /* To do this, one would need to extract a bit-map */ -void readpicture (FILE *output, FILE *input) { +void readpicture (FILE *output, FILE *input) +{ complainspecial(input); } @@ -2950,7 +2998,8 @@ COLORSPEC CurrColor; /* The following were separated out for convenience 96/Nov/3 */ -int doColorPop (int pageno) { +int doColorPop (int pageno) +{ int flag = 0; if (colorindex <= 0) { sprintf(logline, " %s stack underflow on page %d\n", "color", pageno); @@ -2966,7 +3015,8 @@ int doColorPop (int pageno) { CurrentD = ColorD[colorindex]; */ CurrColor = ColorStack[--colorindex]; if (colorindex == 0) { /* hit bottom of stack ? */ - if (CurrColor.A == 0.0 && CurrColor.B == 0.0 && CurrColor.C == 0.0) { + if (CurrColor.A == 0.0 && CurrColor.B == 0.0 && CurrColor.C == 0.0) + { if (colortypeflag == 2) /* cmyk */ CurrColor.D = 1.0F; else if (colortypeflag == 1) /* rgb */ @@ -2980,7 +3030,8 @@ int doColorPop (int pageno) { return flag; } -int doColorPush (int pageno) { +int doColorPush (int pageno) +{ /* ColorA[colorindex] = CurrentA; ColorB[colorindex] = CurrentB; ColorC[colorindex] = CurrentC; @@ -3005,15 +3056,18 @@ int doColorPush (int pageno) { /* popflag == 2 => beginning of page color setting */ /* popflag == 3 => background color setting at top of page */ -void doColorSet (FILE *output, int popflag) { +void doColorSet (FILE *output, int popflag) +{ if (! freshflag) PSputc('\n', output); - if (CurrColor.D >= 0.0) { + if (CurrColor.D >= 0.0) + { sprintf(logline, "%g %g %g %g cmyk ", CurrColor.A, CurrColor.B, CurrColor.C, CurrColor.D); PSputs(logline, output); } - else if (CurrColor.D == -1.0F) { + else if (CurrColor.D == -1.0F) + { sprintf(logline, "%g %g %g rgb ", CurrColor.A, CurrColor.B, CurrColor.C); PSputs(logline, output); @@ -3023,7 +3077,8 @@ void doColorSet (FILE *output, int popflag) { sprintf(logline, "%g gray ", CurrColor.A); PSputs(logline, output); } - if (popflag && ! directprint) { + if (popflag && ! directprint) + { if (popflag == 1) { PSputs("% pop", output); } @@ -3040,7 +3095,8 @@ void doColorSet (FILE *output, int popflag) { showcount = 0; } -int doColorPopAll (int pageno) { /* 1996/Nov/3 */ +int doColorPopAll (int pageno) /* 1996/Nov/3 */ +{ if (colorindex == 0) return -1; while (colorindex > 0) doColorPop(pageno); return 0; @@ -3048,7 +3104,8 @@ int doColorPopAll (int pageno) { /* 1996/Nov/3 */ /* called from dvianal.c if color stack not empty at EOP */ -int checkColorStack (FILE *output) { /* 96/Nov/3 */ +int checkColorStack (FILE *output) /* 96/Nov/3 */ +{ if (colorindex == 0) return 0; if (bCarryColor == 0) { /* 98/Feb/14 */ showline(" color stack not empty at EOP", 1); @@ -3068,7 +3125,8 @@ int checkColorStack (FILE *output) { /* 96/Nov/3 */ /* outflag controls whether emitting PS output - off when skipflag set */ -void doColor (FILE *output, FILE *input, int c, int outflag) { /* 95/Mar/1 */ +void doColor (FILE *output, FILE *input, int c, int outflag) /* 95/Mar/1 */ +{ char *s; int n, m, setcolor=0, popflag = 0; long page; @@ -3203,7 +3261,8 @@ int CTMstackindex= 0; /* try and avoid underflow at least */ /* flag != 0 (pop*) means do not preserve current point */ -int popCTM (FILE *output, int flag) { +int popCTM (FILE *output, int flag) +{ CTMstackindex--; if (CTMstackindex < 0) { sprintf(logline, " %s stack underflow on page %d\n", "CTM", pageno); @@ -3223,14 +3282,16 @@ int popCTM (FILE *output, int flag) { return 0; } -void popallCTM (FILE *output, int flag) { +void popallCTM (FILE *output, int flag) +{ // PSputs(" grestoreall\n", output); // PSputs(" curentfont grestoreall setfont\n", output); PSputs(restoreCTMall, output); CTMstackindex = 0; } -int checkCTM (FILE *output) { /* CALL AT END OF PAGE */ +int checkCTM (FILE *output) /* CALL AT END OF PAGE */ +{ if (CTMstackindex == 0) return 0; showline(" CTM stack not empty at EOP", 1); popallCTM(output, 0); @@ -3238,7 +3299,8 @@ int checkCTM (FILE *output) { /* CALL AT END OF PAGE */ return -1; } -int pushCTM (FILE *output, int flag) { +int pushCTM (FILE *output, int flag) +{ CTMstackindex++; // PSputs(" gsave\n", output); PSputs(saveCTM, output); @@ -3249,7 +3311,8 @@ int pushCTM (FILE *output, int flag) { /* NOTE: This has different semantics from rotate, scale, and concat */ /* If would make no sense to make it relative to current point! */ -void translateCTM (FILE *output, double dx, double dy, int flag) { +void translateCTM (FILE *output, double dx, double dy, int flag) +{ PSputs(" currentpoint\n", output); // remember current point dy = - dy; /* upside down coordinate system 96/Nov/5 */ if (flag == 0) { @@ -3264,7 +3327,8 @@ void translateCTM (FILE *output, double dx, double dy, int flag) { /* flag != 0 (scale*) means scale by inverse of given factors */ -int scaleCTM (FILE *output, double sx, double sy, int flag) { +int scaleCTM (FILE *output, double sx, double sy, int flag) +{ PSputs(tranCP, output); // PSputc('\n', output); if (flag == 0) { @@ -3286,7 +3350,8 @@ int scaleCTM (FILE *output, double sx, double sy, int flag) { /* flag != 0 (rotate*) means rotate in opposite direction */ /* NOTE: we are in a left-hand coordinate system so flip sign of angle */ -void rotateCTM (FILE *output, double theta, int flag) { +void rotateCTM (FILE *output, double theta, int flag) +{ PSputs(tranCP, output); // PSputc('\n', output); if (flag == 0) { @@ -3305,7 +3370,8 @@ void rotateCTM (FILE *output, double theta, int flag) { void concatCTM (FILE* output, double m11, double m12, double m21, double m22, double m31, double m32, - int flag) { + int flag) +{ double det, n11, n12, n21, n22, n31, n32; PSputs(tranCP, output); // PSputc('\n', output); @@ -3338,7 +3404,8 @@ void concatCTM (FILE* output, /* Deal with \special{CTM: ...} push pop rotate scale translate concat */ /* Some of these have alternate forms indicated by trailing `*' */ -void doCTM (FILE *output, FILE *input) { /* \special{CTM: } 96/Oct/10 */ +void doCTM (FILE *output, FILE *input) /* \special{CTM: } 96/Oct/10 */ +{ char *s; int n, flag; double dx, dy, sx, sy, theta, m11, m12, m21, m22, m31, m32; @@ -3443,7 +3510,8 @@ void doCTM (FILE *output, FILE *input) { /* \special{CTM: } 96/Oct/10 */ /* logical coordinates upper left corner, lower right corner */ -void clipbox (FILE *output, long dwidth, long dheight, int flag) { +void clipbox (FILE *output, long dwidth, long dheight, int flag) +{ /* int ret; */ PSputc('\n', output); // always on new line ? @@ -3457,7 +3525,8 @@ void clipbox (FILE *output, long dwidth, long dheight, int flag) { } */ } -void doClipBoxPush (FILE *output) { +void doClipBoxPush (FILE *output) +{ // PSputc('\n', output); // always on new line ? // PSputs("gsave ", output); // PSputs(" gsave\n", output); // saveCTM @@ -3465,7 +3534,8 @@ void doClipBoxPush (FILE *output) { clipstackindex++; } -void doClipBoxPop (FILE *output) { +void doClipBoxPop (FILE *output) +{ if (clipstackindex <= 0) return; /* avoid stack underflow */ clipstackindex--; // PSputc('\n', output); // always on new line ? @@ -3474,13 +3544,15 @@ void doClipBoxPop (FILE *output) { PSputs(restoreCTM, output); } -void doClipBoxPopAll (FILE *output) { +void doClipBoxPopAll (FILE *output) +{ while (clipstackindex > 0) doClipBoxPop(output); } /* int c is terminating character */ -void doClipBox (FILE *output, FILE *input, int c) { /* 98/Sep/8 */ +void doClipBox (FILE *output, FILE *input, int c) /* 98/Sep/8 */ +{ char *s; long dwidth, dheight; /* long cxll, cyll, cxur, cyur; */ @@ -3558,13 +3630,15 @@ char *unitnames[] = { }; double unitscale[] = { - (72.0 / 72.27), 12.0 * (72.0 / 72.27), 72.0, 1.0, - (72.0 / 2.54), (72.0 / 25.4), (1238.0 / 1157.0) * (72.0 / 72.27), - 12.0 * (1238.0 / 1157.0) * (72.0 / 72.27), - (72.0 / 72.27) / 65536.0 + (72.0 / 72.27), + 12.0 * (72.0 / 72.27), 72.0, 1.0, + (72.0 / 2.54), (72.0 / 25.4), (1238.0 / 1157.0) * (72.0 / 72.27), + 12.0 * (1238.0 / 1157.0) * (72.0 / 72.27), + (72.0 / 72.27) / 65536.0 }; -double decodeunits (char *units) { +double decodeunits (char *units) +{ int k; for (k = 0; k < 9; k++) { if (strcmp(unitnames[k], units) == 0) @@ -3577,7 +3651,8 @@ double decodeunits (char *units) { /* make common to save string space */ -void dvitopsmiss (void) { +void dvitopsmiss (void) +{ showline(" File name missing in DVITPS, DVITOPS or PC-TeX special ", 1); } @@ -3586,7 +3661,8 @@ void dvitopsmiss (void) { /* added PC-TeX \special{eps: } 94/Jun/17 */ /* void readdvitops(FILE *output, FILE *input) { */ /* 1994/June/17 */ -int readdvitops (FILE *output, FILE *input, int pctexflag) { +int readdvitops (FILE *output, FILE *input, int pctexflag) +{ double width=0.0, height=0.0, widthd, heightd; double hscale, vscale, scale, multiple; double xshift, yshift; @@ -3754,7 +3830,8 @@ void reademtex(FILE *, FILE *); /* em:point n --- remember current coordinates for point n */ /* em:line a[h|v|p],b[h|v|p][,w] draw line thickness w from point a to b */ -void reademtex (FILE *output, FILE *input) { +void reademtex (FILE *output, FILE *input) +{ double linewidth, multiple; long emline = 26214; /* default 0.4pt * 65536 */ char *s; @@ -3762,11 +3839,13 @@ void reademtex (FILE *output, FILE *input) { int n; /* if (getalphatoken(input, line, MAXLINE) == 0) { */ - if (getalphatoken(input, line, sizeof(line)) == 0) { + if (getalphatoken(input, line, sizeof(line)) == 0) + { complainspecial(input); return; } - if (strcmp(line, "message") == 0) { + if (strcmp(line, "message") == 0) + { // putc(' ', stdout); showline(" ", 0); (void) scanspecial(input, line, MAXLINE); @@ -3821,7 +3900,8 @@ void reademtex (FILE *output, FILE *input) { /* DVITPS specials for figure insertion --- 1993/March/24 */ /* Not done as carefully as it should be, see DVI2PS and DVIPS code */ -int readdvitps (FILE *output, FILE *input) { +int readdvitps (FILE *output, FILE *input) +{ char epsfilename[FNAMELEN]=""; /* char units[3]; */ long pslength; @@ -3884,7 +3964,8 @@ int readdvitps (FILE *output, FILE *input) { /* Special starts with `ps:' or `ps::' - lots of possibilities ... */ /* DVIPS style? - some DVIPS stuff not implemented */ /* Also DVIPS operates in left-handed coordinate system */ -int readdvips (FILE *output, FILE *input) { +int readdvips (FILE *output, FILE *input) +{ int c; double scale=1.0; char *s, *t; @@ -4153,7 +4234,8 @@ int readdvips (FILE *output, FILE *input) { /* support \special{src123file.tex} */ -void DoScr (FILE *output, FILE *input) { /* 98/Nov/4 */ +void DoScr (FILE *output, FILE *input) /* 98/Nov/4 */ +{ int lineno=0; char srcfile[FILENAME_MAX]=""; @@ -4171,12 +4253,13 @@ void DoScr (FILE *output, FILE *input) { /* 98/Nov/4 */ /* Terminated by : => ArborText style special or DVITOPS or DVITPS or EM */ /* Separator is `:' */ /* or HP TAG tiff: */ -int readdvilaserps (FILE *output, FILE *input) { +int readdvilaserps (FILE *output, FILE *input) +{ if (strcmp(line, "ps") == 0) readdvips(output, input); - else if (strcmp(line, "dvitops") == 0) readdvitops(output, input, 0); - else if (strcmp(line, "eps") == 0) readdvitops(output, input, 1); - else if (strcmp(line, "dvitps") == 0) readdvitps(output, input); - else if (strcmp(line, "em") == 0) reademtex(output, input); + else if (strcmp(line, "dvitops") == 0) readdvitops(output, input, 0); + else if (strcmp(line, "eps") == 0) readdvitops(output, input, 1); + else if (strcmp(line, "dvitps") == 0) readdvitps(output, input); + else if (strcmp(line, "em") == 0) reademtex(output, input); else if (strcmp(line, "tiff") == 0) dohptag(output, input); /* Is it one of DVIWINDO's specials ? */ /* colon after `color' 95/June/21 */ else if (strcmp(line, "color") == 0) doColor(output, input, ':', 1); @@ -4227,13 +4310,15 @@ int readdvilaserps (FILE *output, FILE *input) { /* * 0.001 => in */ /* * 72.27 => points */ /* * 65536 => scaled points */ -long convscal (long z) { /* convert to scaled point from 0.001 inch */ +long convscal (long z) /* convert to scaled point from 0.001 inch */ +{ /* return (long) ((double) z * 0.001 * 72.27 * 65536); */ /* return (long) ((double) z * 4736.28672); */ return z * 4736; /* avoid round-off error accumulation & floating */ } -long convscaldouble (double z) { /* as above, but for positive double */ +long convscaldouble (double z) /* as above, but for positive double */ +{ if (z < 0.0) return - (long) (-z * 4736.0 + 0.5); else return (long) (z * 4736.0 + 0.5); } @@ -4246,7 +4331,8 @@ long xold=0, yold=0; /* last point placed in path */ // On entry contains TPIC command token in line // If it takes arguments, scanspecial is used to read in the rest -int readtpic (FILE *output, FILE *input) { +int readtpic (FILE *output, FILE *input) +{ long x=xold, y=yold; double z=0.0; long xr=0, yr=0; @@ -4257,7 +4343,7 @@ int readtpic (FILE *output, FILE *input) { int c, k; char *s; char temp[3]; - char bits[16]="0112122312232334"; /* "0123456789ABCDEF" */ + char bits[17]="0112122312232334"; /* "0123456789ABCDEF" */ // check whether it could be TPIC command if (strlen(line) != 2) return 0; /* quick exit */ @@ -4452,7 +4538,8 @@ int readtpic (FILE *output, FILE *input) { /* read and analysize special command called from dvianal.c xxx */ -int readspecial (FILE *output, FILE *input, unsigned long ns) { +int readspecial (FILE *output, FILE *input, unsigned long ns) +{ int c; if (bIgnoreSpecials != 0) { /* ignore \specials ? */ @@ -4503,7 +4590,8 @@ int readspecial (FILE *output, FILE *input, unsigned long ns) { (void) ungetc(c, input); /* put back the first byte */ nspecial++; - if ((c = getalphatoken(input, line, sizeof(line))) == 0) { + if ((c = getalphatoken(input, line, sizeof(line))) == 0) + { if (quietflag == 0) showline(" Blank special", 1); return 0; /* found nothing ! */ } @@ -4569,7 +4657,8 @@ int readspecial (FILE *output, FILE *input, unsigned long ns) { /* Use this while skipping pages *//* used just to keep track of color stack */ /* all other \specials are ignored *//* added 98/Feb/14 */ -void prereadspecial (FILE *input, unsigned long ns) { +void prereadspecial (FILE *input, unsigned long ns) +{ int c; if (bIgnoreSpecials != 0) { /* ignore \specials ? */ @@ -4628,7 +4717,8 @@ void prereadspecial (FILE *input, unsigned long ns) { /* em:point n --- remember current coordinates for point n */ /* em:line a[h|v|p],b[h|v|p][,w] draw line thickness w from point a to b */ -void reademtex (FILE *output, FILE *input) { +void reademtex (FILE *output, FILE *input) +{ double linewidth, multiple; long emline = 26214; /* default 0.4pt * 65536 */ char *s; diff --git a/src/dvisourc/dvitiff.c b/src/dvisourc/dvitiff.c index 0903a46..beed5c3 100644 --- a/src/dvisourc/dvitiff.c +++ b/src/dvisourc/dvitiff.c @@ -162,23 +162,23 @@ int bTextColor=0; double textred=0.0; /* color of text */ double textgreen=0.0; -double textblue=0.0; +double textblue=0.0; int bRuleColor=0; double rulered=0.0; /* color of rules */ double rulegreen=0.0; -double ruleblue=0.0; +double ruleblue=0.0; int bFigureColor=0; /* figure color has been specified */ double figurered=0.0; /* foreground of figure */ double figuregreen=0.0; -double figureblue=0.0; +double figureblue=0.0; double backred=1.0; /* background of figure */ double backgreen=1.0; -double backblue=1.0; +double backblue=1.0; int bReverseVideo=0; @@ -193,7 +193,7 @@ unsigned int bLeastFirst=1; /* least significant first */ unsigned int IFDCount; /* number of items image file directory */ unsigned long IFDPosition; /* position of image file directory */ -#pragma optimize ("lge", off) +//#pragma optimize ("lge", off) /* static unsigned short int ureadtwo(FILE *input) { unsigned short int c, d; @@ -394,7 +394,7 @@ int readfields (FILE *input, unsigned long ifdpos) int c; #ifdef DEBUGTIFF - if (traceflag) showline("Now reading TIFF images fields\n", 0); + if (traceflag) showline("Now reading TIFF images fields\n", 0); #endif if (fseek(input, (long) ifdpos + TIFFOffset, SEEK_SET) != 0) @@ -420,7 +420,8 @@ int readfields (FILE *input, unsigned long ifdpos) xresden = yresden = 1; ResolutionUnit = 2; - for (k = 0; k < IFDCount; k++) { + for (k = 0; k < IFDCount; k++) + { tag = ureadtwo(input); /* tag - key */ type = ureadtwo(input); /* value type */ if (tag == 0 && type == 0) { /* invalid */ @@ -445,7 +446,7 @@ int readfields (FILE *input, unsigned long ifdpos) if (length == 1) { if (type == TYPE_LONG) offset = ureadfour(input); else if (type == TYPE_SHORT) { - offset = ureadtwo(input); + offset = ureadtwo(input); (void) ureadtwo(input); /* should be zero */ } else if (type == TYPE_BYTE) { @@ -572,7 +573,8 @@ void LZWput(int, FILE *); /* do we need to use unsigned short for NT ? */ -int ReadColorMap (FILE *input, long ColorMapPtr, int BitsPerSample) { +int ReadColorMap (FILE *input, long ColorMapPtr, int BitsPerSample) +{ long present; int k, n, nint; @@ -585,13 +587,13 @@ int ReadColorMap (FILE *input, long ColorMapPtr, int BitsPerSample) { #ifdef DEBUGTIFF #ifdef USESHORTINT - unsigned short int *PaletteRed; + unsigned short int *PaletteRed; unsigned short int *PaletteGreen; - unsigned short int *PaletteBlue; + unsigned short int *PaletteBlue; #else - unsigned int *PaletteRed; - unsigned int *PaletteGreen; - unsigned int *PaletteBlue; + unsigned int *PaletteRed; + unsigned int *PaletteGreen; + unsigned int *PaletteBlue; #endif #endif @@ -600,7 +602,8 @@ int ReadColorMap (FILE *input, long ColorMapPtr, int BitsPerSample) { PaletteSize = n; /* remember for later */ nint = n * 3; /* total number of integers */ #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { sprintf(logline, "Reading Color Map of size %d\n", n); showline(logline, 1); } @@ -611,22 +614,25 @@ int ReadColorMap (FILE *input, long ColorMapPtr, int BitsPerSample) { malloc(nint * sizeof(unsigned short int)); #else /* Palette = (unsigned int *) malloc(nint * 2); */ /* bytes */ - Palette = (unsigned int *) malloc(nint * sizeof(unsigned int)); + Palette = (unsigned int *) malloc(nint * sizeof(unsigned int)); #endif - if (Palette == NULL) { + if (Palette == NULL) + { showline(" ERROR: Unable to allocate memory\n", 1); checkexit(1); // or more serious exit(1) ??? } present = ftell(input); #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { sprintf(logline, "Going to ColorMap at %ld + %lu\n", ColorMapPtr, TIFFOffset); showline(logline, 1); } #endif - if (fseek (input, (long) ColorMapPtr + TIFFOffset, SEEK_SET) != 0) { + if (fseek (input, (long) ColorMapPtr + TIFFOffset, SEEK_SET) != 0) + { sprintf(logline, " Error in seek %s\n", " to ColorMap"); showline(logline, 1); } @@ -641,18 +647,21 @@ int ReadColorMap (FILE *input, long ColorMapPtr, int BitsPerSample) { PaletteBlue = PaletteGreen + PaletteSize; bGrayFlag = 1; // non-zero if palette is all grays - for (k = 0; k < n; k++) { + for (k = 0; k < n; k++) + { if (PaletteRed[k] != PaletteGreen[k] || - PaletteGreen[k] != PaletteBlue[k]) { + PaletteGreen[k] != PaletteBlue[k]) + { bGrayFlag = 0; break; } } // bGrayFlag presently not used - bLinearFlag = 0; // non-zero if Palette is simply linear + bLinearFlag = 0; // non-zero if Palette is simply linear if (bGrayFlag) { bLinearFlag = 1; - for (k = 0; k < n; k++) { + for (k = 0; k < n; k++) + { if (PaletteRed[k] != (unsigned int) (k * 255 / (n-1))) { bLinearFlag = 0; break; @@ -663,7 +672,8 @@ int ReadColorMap (FILE *input, long ColorMapPtr, int BitsPerSample) { // bGrayFlag and bLinearFlag could be used to produce smaller output files #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { PaletteRed = Palette; PaletteGreen = PaletteRed + PaletteSize; PaletteBlue = PaletteGreen + PaletteSize; @@ -685,7 +695,8 @@ int ReadColorMap (FILE *input, long ColorMapPtr, int BitsPerSample) { /* write out a row of image */ int ProcessRow (FILE *output, unsigned char *lpBuffer, long InRowLengthX, - long BufferLength, long OutRowLength) { + long BufferLength, long OutRowLength) +{ /* if (traceflag) printf("ProcessRow InRowLengthX %d\n", InRowLengthX); */ /* DEBUGGING */ /* if (traceflag) @@ -699,7 +710,7 @@ int ProcessRow (FILE *output, unsigned char *lpBuffer, long InRowLengthX, if (bCompressColor) compresscolor(lpBuffer, BufferLength); #ifdef DEBUGTIFF if (traceflag) { /* DEBUGGING */ - sprintf(logline, "ProcessRow OutRowLength %d\n", OutRowLength); + sprintf(logline, "ProcessRow OutRowLength %d\n", OutRowLength); showline(logline, 0); } #endif @@ -710,13 +721,15 @@ int ProcessRow (FILE *output, unsigned char *lpBuffer, long InRowLengthX, /* Throw out ExtraSamples in SamplesPerPixel */ /* IMPORTANT NOTE: assume for the moment samples are one byte */ -int RemoveExtraSamples (unsigned char *lpBuffer, int InRowLength) { +int RemoveExtraSamples (unsigned char *lpBuffer, int InRowLength) +{ unsigned char *s = lpBuffer; unsigned char *t = lpBuffer; int i, k, n = InRowLength / SamplesPerPixel; #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { sprintf(logline, "RemoveExtraSamples InRowLength %d\n", InRowLength); showline(logline, 1); } @@ -733,7 +746,8 @@ int RemoveExtraSamples (unsigned char *lpBuffer, int InRowLength) { /* readflag != 0 when reading file only to get tag fields */ int readTIFFfile (FILE *output, FILE *input, - long dwidth, long dheight, int nifd, int readflag) { + long dwidth, long dheight, int nifd, int readflag) +{ /* int i, j, flag; */ int i, flag; /* long present; */ @@ -744,7 +758,8 @@ int readTIFFfile (FILE *output, FILE *input, int nLen; TIFFVersion = ureadtwo(input); - if (TIFFVersion != TIFF_VERSION) { + if (TIFFVersion != TIFF_VERSION) + { sprintf(logline, " Incorrect TIFF version code %d\n", TIFFVersion); showline(logline, 1); return -1; /* bad version number for TIFF file */ @@ -754,7 +769,8 @@ int readTIFFfile (FILE *output, FILE *input, IFDPosition = ureadfour(input); /* get first IFD offset in file */ while (nifd-- > 1) { - if (skipthisimage(input, IFDPosition) < 0) { + if (skipthisimage(input, IFDPosition) < 0) + { sprintf(logline, " ERROR: Subimage %d not found", nifd); showline(logline, 1); return -1; @@ -780,7 +796,8 @@ int readTIFFfile (FILE *output, FILE *input, } #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { sprintf(logline, "Width %ld, Height %ld, BitsPerSample %d, SamplesPerPixel %d\n", ImageWidth, ImageLength, BitsPerSample, SamplesPerPixel); showline(logline, 1); @@ -788,7 +805,8 @@ int readTIFFfile (FILE *output, FILE *input, #endif #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { sprintf(logline, "Compression %u PhotometricInterpretation %d\n", compression, PhotometricInterpretation); showline(logline, 1); @@ -796,7 +814,8 @@ int readTIFFfile (FILE *output, FILE *input, #endif #ifdef DEBUGTIFF - if (traceflag && Predictor != 1) { + if (traceflag && Predictor != 1) + { sprintf(logline, "Predictor %d\n", Predictor); showline(logline, 1); } @@ -825,7 +844,8 @@ int readTIFFfile (FILE *output, FILE *input, /* if (bitsperpixel == 24 && bCompressFlag != 0 && forceice == 0) */ /* if (BitsPerPixel == 24 && bCompressFlag != 0) */ /* if ((BitsPerPixel == 24 || bExpandColor) && bAllowColor == 0) */ - if ((BitsPerPixelX == 24 || bExpandColor) && ! bAllowColor) { + if ((BitsPerPixelX == 24 || bExpandColor) && ! bAllowColor) + { sprintf(logline, " color image (bits %d expand %d): use `*c' flag?", BitsPerPixelX, bExpandColor); /* 96/Aug/15 */ // showline(logline, 1); @@ -834,9 +854,10 @@ int readTIFFfile (FILE *output, FILE *input, OutRowLength = BufferLength / 3; } else OutRowLength = BufferLength; - + #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { sprintf(logline, "InRowLength %ld BufferLength %ld OutRowLength %ld\n", InRowLength, BufferLength, OutRowLength); showline(logline, 1); @@ -846,7 +867,8 @@ int readTIFFfile (FILE *output, FILE *input, /* deal with GhostScript TIFF file format with gaps */ /* 94/Dec/16 */ /* shouldn't this only kick in if we are not using (LZW) compression ? */ if (bGhostHackFlag) { /* made conditional 95/Nov/10 */ - if (InRowLength + 1 == StripByteCount) { + if (InRowLength + 1 == StripByteCount) + { InRowLength++; /* a hack */ } } @@ -863,7 +885,8 @@ int readTIFFfile (FILE *output, FILE *input, #ifdef LZWCOMPRESSION bLZWFlag = 0; /* Use LZW if runlength encoding not chosen */ - if (bRunLengthFlag == 0) { + if (bRunLengthFlag == 0) + { // if (compression == LZW_COMPRESSION) bLZWFlag = 1; // else; bLZWFlag = 1 /* otherwise use LZW */ bLZWFlag = 1; @@ -879,16 +902,18 @@ int readTIFFfile (FILE *output, FILE *input, /* following should already be taken care of in `computeheader' */ /* if (compression > 1 && compression != PACK_BITS) */ if (compression > TIFF_CCITT && compression != LZW_COMPRESSION && - compression != PACK_BITS) { + compression != PACK_BITS) + { sprintf(logline, " ERROR: Unknown compression scheme (%d)", compression); showline(logline, 1); - return -1; + return -1; } - + /* ImageSize = (unsigned long) InRowLength * ImageLength; */ ImageSize = (unsigned long) InRowLengthX * ImageLength; -/* check whether values reasonable */ - if (ImageSize == 0) { +/* check whether values reasonable */ + if (ImageSize == 0) + { sprintf(logline, " ERROR: Zero image size, %d %d (%s)", InRowLengthX, ImageLength, "readTIFFfile"); showline(logline, 1); @@ -897,7 +922,7 @@ int readTIFFfile (FILE *output, FILE *input, if (ImageWidth > MAXIMAGE || ImageLength > MAXIMAGE || /* bad data ? */ ImageSize > 67108864) { /* arbitrary limits (to catch bad files) */ sprintf(logline, - " ERROR: image file too large\n(%ld x %ld (%d) => %ld bytes)", + " ERROR: image file too large\n(%ld x %ld (%d) => %ld bytes)", ImageWidth, ImageLength, BitsPerPixel, ImageSize); showline(logline, 1); return -1; @@ -906,9 +931,10 @@ int readTIFFfile (FILE *output, FILE *input, StripOffset < 0) { /* missing fields */ showline(" ERROR: TIFF file missing required tags", 1); return -1; - } + } - if (fseek(input, (long) StripOffset + TIFFOffset, SEEK_SET) != 0) { + if (fseek(input, (long) StripOffset + TIFFOffset, SEEK_SET) != 0) + { sprintf(logline, " Error in seek %s\n", " to StripOffset\n"); showline(logline, 1); return -1; @@ -921,8 +947,9 @@ int readTIFFfile (FILE *output, FILE *input, /* Accomodate GhostScript gap bug work around ... just in case 95/Nov/10 */ /* nLen = BufferLength + 1; */ nLen = (int) ((BufferLength + 3) / 4) * 4; - if ((lpBuffer = malloc(nLen)) == NULL) { - sprintf(logline, " ERROR: Unable to allocate %d bytes\n", nLen); + if ((lpBuffer = malloc(nLen)) == NULL) + { + sprintf(logline, " ERROR: Unable to allocate %d bytes\n", nLen); showline(logline, 1); checkexit(1); /* 1995/July/15 ? */ // or more serious exit(1) ??? @@ -939,24 +966,27 @@ int readTIFFfile (FILE *output, FILE *input, /* following should already be taken care of in `computeheader' */ if (compression > TIFF_CCITT && compression != LZW_COMPRESSION && - compression != PACK_BITS) { + compression != PACK_BITS) + { sprintf(logline, " ERROR: Unknown compression scheme (%d)", compression); showline(logline, 1); return -1; } #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { if (compression == PACK_BITS) sprintf(logline, "Using PACK_BITS\n"); else if (compression == TIFF_CCITT) sprintf(logline, "Using TIFF_CCITT\n"); else if (compression == LZW_COMPRESSION) sprintf(logline, "Using LZW\n"); showline(logline, 1); - } + } #endif flag = 0; /* flag gets set if EOF hit */ #ifdef PSLEVEL2 - if (bLevel2) { + if (bLevel2) + { ASCIIinitfilter(output); /* 96/Dec/20 */ if (bRunLengthFlag) RUNinitfilter(output); /* 96/Dec/24 */ #ifdef LZWCOMPRESSION @@ -967,7 +997,7 @@ int readTIFFfile (FILE *output, FILE *input, /* LZW needs to be done by strips, the others can be done by row */ - if (compression == LZW_COMPRESSION) DecodeLZW(output, input, lpBuffer); + if (compression == LZW_COMPRESSION) DecodeLZW(output, input, lpBuffer); else { /* else not LZW compression */ @@ -994,16 +1024,18 @@ int readTIFFfile (FILE *output, FILE *input, } } #ifdef DEBUGTIFF - if (traceflag) { - sprintf(logline, "readTIFFFile InRowLength %d\n", InRowLength); - showline(logline, 1); + if (traceflag) + { + sprintf(logline, "readTIFFFile InRowLength %d\n", InRowLength); + showline(logline, 1); } #endif if (ExtraSamples > 0) (void) RemoveExtraSamples(lpBuffer, InRowLength); /* 99/May/10 */ #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { sprintf(logline, "readTIFFFile OutRowLength %d BufferLength %d\n", OutRowLength, BufferLength); showline(logline, 1); @@ -1012,7 +1044,8 @@ int readTIFFfile (FILE *output, FILE *input, /* if (ProcessRow (output, lpBuffer, InRowLength, BufferLength, */ if (ProcessRow (output, lpBuffer, InRowLengthX, BufferLength, - OutRowLength) != 0) { + OutRowLength) != 0) + { showline("\n", 0); showline("ERROR: Output error ", 1); perrormod((outputfile != NULL) ? outputfile : ""); @@ -1025,7 +1058,8 @@ int readTIFFfile (FILE *output, FILE *input, // Have to flush filters in reverse order #ifdef PSLEVEL2 - if (bLevel2) { + if (bLevel2) + { if (bRunLengthFlag) RUNflushfilter(output); /* 96/Dec/24 */ #ifdef LZWCOMPRESSION else if (bLZWFlag) LZWflushfilter(output); /* 96/Dec/28 */ @@ -1078,7 +1112,7 @@ typedef struct tagBITMAPFILEHEADER { } BITMAPFILEHEADER, FAR *LPBITMAPFILEHEADER, *PBITMAPFILEHEADER; #include -typedef struct tagBITMAPINFOHEADER{ +typedef struct tagBITMAPINFOHEADER { DWORD biSize; LONG biWidth; LONG biHeight; @@ -1116,7 +1150,8 @@ BITMAPINFOHEADER bmih; /* RGBQUAD colortable[256]; */ -int dpifrom(int res) { +int dpifrom(int res) +{ double dres = (double) res * 25.4 / 1000.0; dres = (double) ((int) (dres * 10.0 + 0.5)) / 10.0; return (int) (dres + 0.5); @@ -1130,7 +1165,8 @@ long ImageSize; /* ??? */ /* readflag is non-zero in prescan */ -int readBMPfields (FILE *input, int readflag) { +int readBMPfields (FILE *input, int readflag) +{ long nLen; double dw, dh; @@ -1161,7 +1197,8 @@ int readBMPfields (FILE *input, int readflag) { OffBits = bmfh.bfOffBits; /* "Offset to image %lu\n", bmih.bfOffBits */ #ifdef DEBUGBMP - if (traceflag && sreadflag) { + if (traceflag && sreadflag) + { sprintf(logline, "\nnLen %ld bfSize %ld bfOffBits %ld ", nLen, bmfh.bfSize, bmfh.bfOffBits); showline(logline, 1); @@ -1239,7 +1276,8 @@ int readBMPfields (FILE *input, int readflag) { if (bmih.biSizeImage > 0) ImageSize = bmih.biSizeImage; else ImageSize = nLen - OffBits; #ifdef DEBUGBMP - if (traceflag && readflag) { + if (traceflag && readflag) + { sprintf(logline, "\nImage at %ld size %ld bytes ", OffBits, ImageSize); showline(logline, 1); } @@ -1247,20 +1285,21 @@ int readBMPfields (FILE *input, int readflag) { return 0; } -int readBMPPalette (FILE *input, long ColorMapPtr, int BitsPerSample) { +int readBMPPalette (FILE *input, long ColorMapPtr, int BitsPerSample) +{ long present; int k, n, nint; RGBQUAD rgb; /* should make all these unsigned short int instead for NT */ #ifdef USESHORTINT - unsigned short int *PaletteRed; + unsigned short int *PaletteRed; unsigned short int *PaletteGreen; - unsigned short int *PaletteBlue; + unsigned short int *PaletteBlue; #else - unsigned int *PaletteRed; - unsigned int *PaletteGreen; - unsigned int *PaletteBlue; + unsigned int *PaletteRed; + unsigned int *PaletteGreen; + unsigned int *PaletteBlue; #endif /* need three tables each of 2 ^ BitsPerSample integers */ @@ -1296,7 +1335,8 @@ int readBMPPalette (FILE *input, long ColorMapPtr, int BitsPerSample) { showline(logline, 1); } #endif - if (fseek (input, (long) ColorMapPtr, SEEK_SET) != 0) { + if (fseek (input, (long) ColorMapPtr, SEEK_SET) != 0) + { sprintf(logline, " Error in seek %s\n", " to ColorMap\n"); showline(logline, 1); } @@ -1351,7 +1391,8 @@ int readBMPPalette (FILE *input, long ColorMapPtr, int BitsPerSample) { /* readflag != 0 when prescanning to get fields */ int readBMPfile (FILE *output, FILE *input, - long dwidth, long dheight, int readflag) { + long dwidth, long dheight, int readflag) +{ unsigned char *lpBuffer=NULL; int i, flag; int nLen; @@ -1434,7 +1475,8 @@ int readBMPfile (FILE *output, FILE *input, else OutRowLength = BufferLength; #ifdef DEBUGBMP - if (traceflag) { + if (traceflag) + { sprintf(logline, "InRowLength %ld BufferLength %ld OutRowLength %ld\n", InRowLength, BufferLength, OutRowLength); showline(logline, 1); @@ -1484,19 +1526,22 @@ int readBMPfile (FILE *output, FILE *input, } #ifdef DEBUGBMP - if (traceflag) { + if (traceflag) + { sprintf(logline, "Seeking to %ld\n", OffBits); showline(logline, 1); } #endif - if (fseek(input, (long) OffBits, SEEK_SET) != 0) { + if (fseek(input, (long) OffBits, SEEK_SET) != 0) + { sprintf(logline, " Error in seek %s\n", " to OffBits\n"); showline(logline, 1); return -1; } nLen = (int) ((BufferLength + 3) / 4) * 4; lpBuffer = malloc(nLen); - if (lpBuffer == NULL) { + if (lpBuffer == NULL) + { sprintf(logline, " ERROR: Unable to allocate %d bytes\n", nLen); showline(logline, 1); checkexit(1); @@ -1506,7 +1551,8 @@ int readBMPfile (FILE *output, FILE *input, flag = 0; /* flag gets set if EOF hit */ #ifdef PSLEVEL2 - if (bLevel2) { + if (bLevel2) + { ASCIIinitfilter(output); /* 96/Dec/20 */ if (bRunLengthFlag) RUNinitfilter(output); /* 96/Dec/24 */ #ifdef LZWCOMPRESSION @@ -1797,7 +1843,8 @@ int readBMPfile (FILE *output, FILE *input, /* fills in TIFFOffset and PSOffset and MetaOffset and lengths */ /* returns zero if not an EPSF file */ /* file position is end of EPSF head */ -int readepsfhead (FILE *special) { +int readepsfhead (FILE *special) +{ int c, d, e, f; PSOffset = 0; /* redundant */ @@ -1824,7 +1871,8 @@ int readepsfhead (FILE *special) { int BMPflag=0; /* non-zero while processing BMP image */ int readimagefilesub (FILE *output, FILE *special, - long dwidth, long dheight, int nifd, int readflag) { + long dwidth, long dheight, int nifd, int readflag) +{ /* long present; */ int c, d; @@ -1842,14 +1890,15 @@ int readimagefilesub (FILE *output, FILE *special, showline(" ERROR: Zero TIFF offset or length\n", 1); return -1; } - if (fseek(special, TIFFOffset, SEEK_SET) != 0) { + if (fseek(special, TIFFOffset, SEEK_SET) != 0) + { sprintf(logline, " Error in seek %s\n", "to TIFFOffset\n"); showline(logline, 1); return -1; } } else { - showline(" ERROR: Not a valid EPSF or TIFF file\n", 1); + showline(" ERROR: Not a valid EPSF or TIFF file\n", 1); return -1; } } /* end of c > 128 (EPSF file) */ @@ -1865,14 +1914,14 @@ int readimagefilesub (FILE *output, FILE *special, else if (c == 'M' && d == 'M') bLeastFirst = 0; /* Mac style TIFF file */ else if (c == 'B' && d == 'M') BMPflag = 1; /* BMP 98/Jun/28 */ else { - showline(" ERROR: Not a valid EPSF, TIFF or BMP file\n", 1); + showline(" ERROR: Not a valid EPSF, TIFF or BMP file\n", 1); return -1; /* not a TIFF subfile !!! */ } /* now have decided that this is a TIFF file (or TIFF preview) or BMP */ if (BMPflag) (void) readBMPfile(output, special, dwidth, dheight, readflag); - else + else (void) readTIFFfile(output, special, dwidth, dheight, nifd, readflag); return 0; } @@ -1883,7 +1932,8 @@ int readimagefilesub (FILE *output, FILE *special, /* Returns -1 if file not found */ int readimagefile (FILE *output, char *filename, - long dwidth, long dheight, int nifd, int readflag) { + long dwidth, long dheight, int nifd, int readflag) +{ /* char infilename[FILENAME_MAX]; */ /* make global */ FILE *special; /* long present; */ @@ -1897,8 +1947,9 @@ int readimagefile (FILE *output, char *filename, return -1; #ifdef DEBUGTIFF - if (traceflag) { - sprintf(logline, "\nManaged to open file %s\n", infilename); + if (traceflag) + { + sprintf(logline, "\nManaged to open file %s\n", infilename); showline(logline, 0); } #endif @@ -1917,7 +1968,8 @@ int column; /* Expand palette color image into full RGB color image */ /* Presently only set up for 8 bit palettes ... !!! */ -void expandcolor (unsigned char *lpBuffer, long width) { +void expandcolor (unsigned char *lpBuffer, long width) +{ int k, n, ns; #ifdef USESHORTINT unsigned short int *PaletteRed; @@ -1938,7 +1990,8 @@ void expandcolor (unsigned char *lpBuffer, long width) { /* if (traceflag) printf("Palette Color => Color "); */ #endif - if (Palette == NULL) { + if (Palette == NULL) + { showline(" ERROR: missing palette information\n", 1); return; } @@ -2015,7 +2068,8 @@ void expandcolor (unsigned char *lpBuffer, long width) { /* This is called for BMP image when palette is used, but it is gray */ /* (i.e. R=G=B) and it is *not* linear (i.e. Palette[k] == k) */ -void expandgray (unsigned char *lpBuffer, long width) { +void expandgray (unsigned char *lpBuffer, long width) +{ int k, n, ns; #ifdef USESHORTINT unsigned short int *PaletteRed; @@ -2036,7 +2090,8 @@ void expandgray (unsigned char *lpBuffer, long width) { /* if (traceflag) printf("Palette Gray => Gray "); */ #endif - if (Palette == NULL) { + if (Palette == NULL) + { showline(" ERROR: missing palette information\n", 1); return; } @@ -2051,7 +2106,8 @@ void expandgray (unsigned char *lpBuffer, long width) { ns = (int) ImageWidth; /* samples per row */ /* if (BufferLength <= InRowLength) */ - if (BufferLength <= InRowLengthX) { + if (BufferLength <= InRowLengthX) + { showline(" ERROR: buffer overflow\n", 1); return; } @@ -2104,7 +2160,8 @@ void expandgray (unsigned char *lpBuffer, long width) { /* gray = 0.3 * red + 0.59 * green + 0.11 * blue */ - void compresscolor (unsigned char *lpBuffer, long width) { +void compresscolor (unsigned char *lpBuffer, long width) +{ int k, n; unsigned char *s; unsigned char *t; @@ -2127,7 +2184,7 @@ void expandgray (unsigned char *lpBuffer, long width) { #ifdef PSLEVEL2 -#pragma optimize ("lge", on) /* 2000 June 17 */ +//#pragma optimize ("lge", on) /* 2000 June 17 */ /* use ASCII85Encode if bLevel2 enabled */ @@ -2151,7 +2208,8 @@ int asciicount = 0; /* how many bytes accumulated so far */ /* nbytes is number of bytes accumulated, which is 4 until the last time */ /* Move this inline for speed ? */ -void ASCIIlong (FILE *output, unsigned long n, int nbytes) { +void ASCIIlong (FILE *output, unsigned long n, int nbytes) +{ unsigned int c[5]; int k; @@ -2193,7 +2251,8 @@ void ASCIIlong (FILE *output, unsigned long n, int nbytes) { /* Output single byte (accumulate until four seen, then call ASCIIlong) */ /* Move this inline for speed ? */ -void ASCIIout (FILE *output, unsigned int x) { +void ASCIIout (FILE *output, unsigned int x) +{ // sprintf(logline, "ASCII %d ", x); // showline(logline, 0); // debugging only if (x > 255) x = x & 255; // sanity check ??? @@ -2208,20 +2267,23 @@ void ASCIIout (FILE *output, unsigned int x) { /* initialize ASCII85 filter */ -void ASCIIinitfilter (FILE *output) { /* 96/Dec/20 */ +void ASCIIinitfilter (FILE *output) /* 96/Dec/20 */ +{ // showline("ASCIIinitfilter ", 0); // debugging only asciinum = 0; asciicount = 0; column = 0; /* ??? */ } -void RUNinitfilter (FILE *output) { /* 95/Dec/24 */ +void RUNinitfilter (FILE *output) /* 95/Dec/24 */ +{ /* apparently nothing special to do */ } /* flush out anything left in ASCII85 filter */ -void ASCIIflushfilter (FILE *output) { /* 96/Dec/20 */ +void ASCIIflushfilter (FILE *output) /* 96/Dec/20 */ +{ int k; // showline("ASCIIflushfilter ", 0); // debugging only for (k = asciicount; k < 4; k++) { @@ -2232,7 +2294,8 @@ void ASCIIflushfilter (FILE *output) { /* 96/Dec/20 */ asciicount = 0; } -void RUNflushfilter (FILE *output) { +void RUNflushfilter (FILE *output) +{ ASCIIout(output, 128); /* EOD */ } @@ -2240,7 +2303,8 @@ void RUNflushfilter (FILE *output) { /* write a row in ASCII85 format */ -void writearowASCII (FILE *output, unsigned char *s, unsigned long width) { +void writearowASCII (FILE *output, unsigned char *s, unsigned long width) +{ unsigned int c; int k, n, i; unsigned long num; @@ -2277,7 +2341,8 @@ int debugflag=1; /* debugging output */ /* Do run encoding per row (rather than image) --- easier, if not optimal */ -void dumprun(FILE *output, int nlen, int previous) { +void dumprun(FILE *output, int nlen, int previous) +{ #ifdef DEBUGRUNLENGTH int i; if (nlen <= 0) { @@ -2302,7 +2367,8 @@ void dumprun(FILE *output, int nlen, int previous) { ASCIIout(output, previous); } -void dumpnonrun(FILE *output, int nlen, unsigned char *buffer) { +void dumpnonrun(FILE *output, int nlen, unsigned char *buffer) +{ int i; unsigned char *s; @@ -2339,7 +2405,8 @@ void dumpnonrun(FILE *output, int nlen, unsigned char *buffer) { /* Here (1) is the starting state */ /* Dumps out when (i) state changes (ii) 128 bytes seen (iii) end input */ -void writearowrun (FILE *output, unsigned char *s, unsigned long width) { +void writearowrun (FILE *output, unsigned char *s, unsigned long width) +{ int runflag; /* non-zero if in accumulating run state */ int previous; /* character that appears to be repeating */ int repeat; /* how many times we have seen previous */ @@ -2443,14 +2510,16 @@ int currentnode; // code of node currently at int nextnode; // code of next node to be used int codelength; // how many bits needed for code at this stage 9, 10, 11, 12 -void DeAllocStringsOut (void) { // called from dvibody() in dvipsone.c +void DeAllocStringsOut (void) // called from dvibody() in dvipsone.c +{ if (node != NULL) { free(node); node = NULL; } } -void CleanOut (FILE *output, int n) { +void CleanOut (FILE *output, int n) +{ int k; // sprintf(logline, "CLEANOUT %d\n", n); @@ -2468,7 +2537,8 @@ void CleanOut (FILE *output, int n) { codelength = 9; // reset code length now } -int SetupNodes (FILE *output) { +int SetupNodes (FILE *output) +{ int nlen; if (node == NULL) { @@ -2494,7 +2564,8 @@ int SetupNodes (FILE *output) { #ifdef IGNORED // We are at node n and adding a new branch for byte chr -- NOT USED -void AddaNode (FILE *output, int n, int chr, int previous) { +void AddaNode (FILE *output, int n, int chr, int previous) +{ int k, klast; // if (nextnode < 0 || nextnode >= MAXCODES) showline("TABLE OVERFLOW", 1); // Is there already a node at the next level ? @@ -2591,7 +2662,8 @@ void DoNextByte (FILE *output, int chr) { // called from writearowLZW } #ifdef IGNORED -void DoCleanup (FILE *output) { // not used - see LZWflushfilter +void DoCleanup (FILE *output) // not used - see LZWflushfilter +{ if (currentnode >= 0) LZWput(currentnode, output); // LZWput(CLEAR, output); // nextnode = FIRSTCODE; @@ -2612,12 +2684,14 @@ int bitsused; /* bits used so far */ /* may produce one or two bytes ready to spit out */ /* bitsused is always < 8 before and always < 8 after this */ -void LZWput (int code, FILE *output) { +void LZWput (int code, FILE *output) +{ int c; // if (bitsused < 0 || bitsused >= 8) showline("ERROR ", 1); #ifdef DEBUGLZWENCODE - if (debugflag) { + if (debugflag) + { if (code >= (1 << codelength)) sprintf(logline, "code %d too long for code length %d\n", code, codelength); @@ -2645,7 +2719,8 @@ void LZWputinit (FILE *output) { /* called from LZWinitfilter */ bitsused = 0; } -void LZWputflush (FILE *output) { +void LZWputflush (FILE *output) +{ int c; // showline("LZWputflush ", 0); // debugging only if (bitsused == 0) return; /* nothing left to push out */ @@ -2656,7 +2731,8 @@ void LZWputflush (FILE *output) { /* bitsused = 0; */ } -void LZWinitfilter (FILE *output) { /* initialization */ +void LZWinitfilter (FILE *output) /* initialization */ +{ // showline("LZWinitfilter ", 0); // debugging only LZWputinit(output); // LZWput(CLEAR, output); /* write CLEAR */ @@ -2665,7 +2741,8 @@ void LZWinitfilter (FILE *output) { /* initialization */ /* codelength = 9; */ } -void LZWflushfilter (FILE *output) { /* termination */ +void LZWflushfilter (FILE *output) /* termination */ +{ // showline("LZWflushfilter ", 0); // debugging only if (currentnode >= 0) { LZWput(currentnode, output); @@ -2690,7 +2767,8 @@ void LZWflushfilter (FILE *output) { /* termination */ /* int code; */ /* code of the string matched so far to input */ /* int last; */ /* last character of input string */ -int writearowLZW (FILE *output, unsigned char *s, unsigned long width) { +int writearowLZW (FILE *output, unsigned char *s, unsigned long width) +{ unsigned char *send = s + width; /* This picks up unfinished business --- currentnode >= 0 */ @@ -2705,13 +2783,14 @@ int writearowLZW (FILE *output, unsigned char *s, unsigned long width) { /*************************************************************************/ -#pragma optimize ("lge", off) +//#pragma optimize ("lge", off) #endif /* end of ifdef PSLEVEL2 */ /* write row in hex format */ -void writearowhex (FILE *output, unsigned char *s, unsigned long width) { +void writearowhex (FILE *output, unsigned char *s, unsigned long width) +{ unsigned int c, d; int k, n; @@ -2752,7 +2831,8 @@ void writearowhex (FILE *output, unsigned char *s, unsigned long width) { /* returns -1 if output error */ /* write a row of data in hex */ -int writearow (FILE *output, unsigned char *s, unsigned long width) { +int writearow (FILE *output, unsigned char *s, unsigned long width) +{ #ifdef PSLEVEL2 if (bLevel2) { if (bRunLengthFlag) writearowrun(output, s, width); @@ -2767,7 +2847,8 @@ int writearow (FILE *output, unsigned char *s, unsigned long width) { #endif // if (ferror(output)) - if (output != NULL && ferror(output)) { + if (output != NULL && ferror(output)) + { showline(" ERROR: Output error\n", 1); perrormod((outputfile != NULL) ? outputfile : ""); return -1; @@ -2832,7 +2913,7 @@ int computeheader (void) { } } /* if (verboseflag && PhotometricInterpretation > 3) { - printf("Photometricinterpretation %d\n", PhotometricInterpretation); + printf("Photometricinterpretation %d\n", PhotometricInterpretation); } */ /* 0 => 0 will be white and 2^n-1 black */ /* 1 => 0 will be black and 2^n-1 white (default) */ @@ -2846,13 +2927,16 @@ int computeheader (void) { showline(" ERROR: Palette Color Image must have Palette!\n", 1); return -1; } - if (PhotometricInterpretation == 2) { + if (PhotometricInterpretation == 2) + { /* if (SamplesPerPixel == 1) */ - if (SamplesPerPixelX == 1) { + if (SamplesPerPixelX == 1) + { sprintf(logline, " %s, but not more than one sample per pixel?\n", "RGB"); showline(logline, 1); } - if (! bAllowColor) { + if (! bAllowColor) + { sprintf(logline, " WARNING: %s color image (%d) use `*c' flag?", "RGB", SamplesPerPixel); // showline(logline, 1); showline(logline, 0); @@ -2862,11 +2946,13 @@ int computeheader (void) { } if (PhotometricInterpretation == 5) { // 2000 May 27 /* if (SamplesPerPixel == 1) */ - if (SamplesPerPixelX == 1) { + if (SamplesPerPixelX == 1) + { sprintf(logline, " %s, but not more than one sample per pixel?\n", "CMYK"); showline(logline, 1); } - if (! bAllowColor) { + if (! bAllowColor) + { sprintf(logline, " WARNING: %s color image (%d) use `*c' flag?", "CMYK", SamplesPerPixel); // showline(logline, 1); showline(logline, 0); @@ -2877,7 +2963,8 @@ int computeheader (void) { /* 0 => 0 will be white and 2^n-1 black */ /* 1 => 0 will be black and 2^n-1 white (default) */ - if (PhotometricInterpretation == 0) { + if (PhotometricInterpretation == 0) + { #ifdef DEBUGTIFF if (traceflag) showline("Image grey levels will be inverted\n", 0); #endif @@ -2886,7 +2973,8 @@ int computeheader (void) { else bInvertImage = 0; #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { sprintf(logline, "ExpandColor %d CompressColor %d InvertImage %d\n", bExpandColor, bCompressColor, bInvertImage); showline(logline, 0); @@ -2901,7 +2989,7 @@ int computeheader (void) { bytes = (int) OutRowLength; /* ever used ? */ #ifdef DEBUGTIFF if (traceflag) { - sprintf(logline, "%d bytes per row\n", bytes); + sprintf(logline, "%d bytes per row\n", bytes); showline(logline, 0); } #endif @@ -2917,7 +3005,8 @@ int computeheader (void) { /* compress some of this code into DVIPREAM.PS ? */ -void writepsheader (FILE *output, long dwidth, long dheight) { +void writepsheader (FILE *output, long dwidth, long dheight) +{ int bits=1; /* bits per pixel in image */ int samples=3; /* samples per pixel 96/July/7 */ int bMonoChrome=0; /* if need to use image mask */ @@ -2926,7 +3015,7 @@ void writepsheader (FILE *output, long dwidth, long dheight) { long YOffset; #ifdef DEBUGTIFF - if (traceflag) showline("Now writing out header information\n", 0); + if (traceflag) showline("Now writing out header information\n", 0); #endif /* if (BitsPerSample == 1) bMonoChrome = 1; */ /* use image mask */ @@ -2939,7 +3028,7 @@ void writepsheader (FILE *output, long dwidth, long dheight) { if (bExpandColor) samples = 3; else if (bExpandGray) samples = 1; /* else samples = SamplesPerPixel; */ /* 96/July/7 */ - else samples = SamplesPerPixelX; + else samples = SamplesPerPixelX; // fprintf(output, "\nsave\n"); // putc('\n', output); @@ -3124,11 +3213,12 @@ void writepsheader (FILE *output, long dwidth, long dheight) { /* image data must follow right away */ } -void writepstrailer (FILE *output) { +void writepstrailer (FILE *output) +{ #ifdef DEBUGTIFF - if (traceflag) showline("Now writing trailer\n", 0); + if (traceflag) showline("Now writing trailer\n", 0); #endif -/* if (BitsPerSample == 1) { +/* if (BitsPerSample == 1) { if (bTextColor) fprintf(output, "%lg %lg %lg rgb\n", Textred, Textgreen, Textblue); else if(bFigureColor) fputs("black\n"); @@ -3142,7 +3232,8 @@ void writepstrailer (FILE *output) { /* Read a row using PACK_BITS compression scheme */ /* returns non-zero if problems encountered */ -int readpackbits (unsigned char *lpBuffer, FILE *input, int RowLength) { +int readpackbits (unsigned char *lpBuffer, FILE *input, int RowLength) +{ unsigned char *u=lpBuffer; int c, k, n, total=0, flag=0; @@ -3182,7 +3273,8 @@ int readpackbits (unsigned char *lpBuffer, FILE *input, int RowLength) { int bytex, bitsleft; /* input buffering in splitting bits */ -int getbit (FILE *input) { +int getbit (FILE *input) +{ if (bitsleft-- <= 0) { if ((bytex = getc(input)) == EOF) { sprintf(logline, " Unexpected EOF (%s)\n", "getbit TIFF"); @@ -3202,15 +3294,16 @@ int getbit (FILE *input) { else return 0; } -#pragma optimize ("lge", on) +//#pragma optimize ("lge", on) /* It's the Huffman code stuff that wants to be not optimized */ -#pragma optimize ("lge", off) +//#pragma optimize ("lge", off) /* Actually commonmake may be OK with compiler optimizations ON */ -int commonmake (FILE *input) { /* common black/white make up codes (7 zeros) */ +int commonmake (FILE *input) /* common black/white make up codes (7 zeros) */ +{ #ifdef DEBUGTIFF if (traceflag) { showline("commonmake entry ", 0); @@ -3298,9 +3391,11 @@ int commonmake (FILE *input) { /* common black/white make up codes (7 zeros) */ /* Compiler screws up the following code if optimizations turned on */ -int whiterun (FILE *input) { +int whiterun (FILE *input) +{ #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { showline("whiterun entry ", 0); } #endif @@ -3766,9 +3861,10 @@ int whiterun (FILE *input) { /* Compiler screws up the following code if optimizations turned on */ -int blackzero (FILE *input) { /* black run code starts with four zeros */ +int blackzero (FILE *input) /* black run code starts with four zeros */ +{ #ifdef DEBUGTIFF - if (traceflag) showline (" blackzero entry ", 0); + if (traceflag) showline (" blackzero entry ", 0); #endif if (getbit(input)) { /* 00001 */ if (getbit(input)) { /* 000011 */ @@ -4189,9 +4285,11 @@ int blackzero (FILE *input) { /* black run code starts with four zeros */ /* blackrun may actually be OK with compiler optimizations turned on */ -int blackrun (FILE *input) { +int blackrun (FILE *input) +{ #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { showline ("blackrun entry ", 0); } #endif @@ -4246,13 +4344,13 @@ int blackrun (FILE *input) { return -1; /* error */ } -#pragma optimize ("lge", on) +//#pragma optimize ("lge", on) /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* FOLLOWING IS EXPERIMENT 97/OCT/21 */ -#pragma optimize ("lge", off) +//#pragma optimize ("lge", off) int index, bitinx; /* index into row of bytes and bits within them */ @@ -4260,7 +4358,8 @@ int total; /* maybe long ? */ /* Following could be speeded up some ... */ -int writewhite (unsigned char *lpBuffer, int run, int width) { +int writewhite (unsigned char *lpBuffer, int run, int width) +{ if (run == 0) return 0; /* nothing to do */ if (run < 0) return -1; /* hit invalid run */ total += run; @@ -4304,7 +4403,8 @@ int writewhite (unsigned char *lpBuffer, int run, int width) { else return 0; } -int writeblack (unsigned char *lpBuffer, int run, int width) { +int writeblack (unsigned char *lpBuffer, int run, int width) +{ if (run == 0) return 0; /* nothing to do */ if (run < 0) return -1; /* hit invalid run */ total += run; @@ -4349,7 +4449,8 @@ int writeblack (unsigned char *lpBuffer, int run, int width) { /* make width long ? */ -int huffmanrow (unsigned char *lpBuffer, FILE *input, int width) { +int huffmanrow (unsigned char *lpBuffer, FILE *input, int width) +{ int k, bytes; int run; /* int total = 0; */ /* long total ? */ @@ -4436,7 +4537,7 @@ int huffmanrow (unsigned char *lpBuffer, FILE *input, int width) { /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ -#pragma optimize ("lge", on) /* experiment 2000 June 17 */ +//#pragma optimize ("lge", on) /* experiment 2000 June 17 */ /* Here is the code for LZW (compression scheme number 5) input side */ @@ -4464,7 +4565,8 @@ int CodeLength=9; /* current code length INPUT */ /* following is never called ? now called from dvipsone.c when exiting */ -void DeAllocStringsIn (void) { /* remember to do this at end */ +void DeAllocStringsIn (void) /* remember to do this at end */ +{ /* if (Memory != NULL) { free(Memory); Memory = NULL; } */ @@ -4484,10 +4586,11 @@ void DeAllocStringsIn (void) { /* remember to do this at end */ /* worry here about allocation in NT ? sizeof(int) */ -int AllocStringsIn (void) { -/* if (Memory == NULL) { +int AllocStringsIn (void) +{ +/* if (Memory == NULL) { Memory = (char *) malloc(INIMEMORY); - MemorySize = INIMEMORY; + MemorySize = INIMEMORY; } */ /* memory for strings in string table */ if (StringByte == NULL) { /* allocate string table indeces */ StringByte = (char *) malloc(MAXCODES * sizeof(char)); @@ -4523,7 +4626,8 @@ int AllocStringsIn (void) { return 0; } -void InitializeStringTable (void) { /* set up string table initially */ +void InitializeStringTable (void) /* set up string table initially */ +{ int k; AllocStringsIn(); /* grab memory for tables if needed */ @@ -4539,14 +4643,17 @@ void InitializeStringTable (void) { /* set up string table initially */ CodeLength = 9; /* initial code length */ } -void ResetStringTable (int quietflag) { /* clear string table */ +void ResetStringTable (int quietflag) /* clear string table */ +{ /* int k; */ #ifdef DEBUGTIFF - if (!quietflag) { + if (!quietflag) + { if (traceflag) showline("CLEAR ", 0); - if (traceflag) showline("\n", 0); - if (traceflag && TableIndex > FIRSTCODE) { + if (traceflag) showline("\n", 0); + if (traceflag && TableIndex > FIRSTCODE) + { /* printf("TableIndex %d FreeIndex %u CodeLength %d\n", TableIndex, FreeIndex, CodeLength); */ sprintf(logline, "TableIndex %d CodeLength %d\n", TableIndex, CodeLength); @@ -4555,7 +4662,7 @@ void ResetStringTable (int quietflag) { /* clear string table */ } #endif /* following not really needed */ -/* for (k = FIRSTCODE; k < TableIndex; k++) { +/* for (k = FIRSTCODE; k < TableIndex; k++) { StringTable[k] = 0; StringLength[k] = 0; } */ @@ -4565,16 +4672,19 @@ void ResetStringTable (int quietflag) { /* clear string table */ } #ifdef USESHORTINT -void AddNewEntry (short int OldCode, short int Code) { +void AddNewEntry (short int OldCode, short int Code) +{ #else -void AddNewEntry (int OldCode, int Code) { +void AddNewEntry (int OldCode, int Code) +{ #endif /* char *s; */ /* char *t; */ /* int k; */ #ifdef DEBUGLZW - if (traceflag) { + if (traceflag) + { sprintf(logline, "Add string TableIndex %4d (%d)\n", TableIndex, StringLength[OldCode] + 1); showline(logline, 0); @@ -4589,7 +4699,7 @@ void AddNewEntry (int OldCode, int Code) { StringPrevious[TableIndex] = OldCode; #ifdef USESHORTINT StringLength[TableIndex] = - (unsigned short int) (StringLength[OldCode] + 1); + (unsigned short int) (StringLength[OldCode] + 1); #else StringLength[TableIndex] = StringLength[OldCode] + 1; #endif @@ -4601,31 +4711,36 @@ void AddNewEntry (int OldCode, int Code) { /* *s = *t; */ /* last byte comes from next code string */ /* FreeIndex += len; */ - if (TableIndex == 511 || TableIndex == 1023 || TableIndex == 2047) { + if (TableIndex == 511 || TableIndex == 1023 || TableIndex == 2047) + { CodeLength++; #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { sprintf(logline, "LENGTH %d (%d)\n", TableIndex, CodeLength); showline(logline, 0); } #endif } - if (TableIndex > MAXCODES) { + if (TableIndex > MAXCODES) + { showline(" ERROR: Table overflow\n", 1); - checkexit(1); + checkexit(1); } -} +} /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ -int IsInTable (int Code) { /* is code already in table ? */ +int IsInTable (int Code) /* is code already in table ? */ +{ return (Code >= 0 && Code < TableIndex); } /* copy string from table by code number */ -unsigned char *WriteString (unsigned char *buffer, int Code) { +unsigned char *WriteString (unsigned char *buffer, int Code) +{ /* int k; */ int n, len=0; unsigned char *s; @@ -4634,7 +4749,7 @@ unsigned char *WriteString (unsigned char *buffer, int Code) { /* s = buffer; */ /* t = Memory + StringTable[Code]; */ // if (Code < TableIndex) - len = StringLength[Code]; + len = StringLength[Code]; t = buffer + len; /* byte after last one to copy */ if (t > StripData + StripDataLen) { /* special case kludge if terminates right after code length switch */ @@ -4678,7 +4793,7 @@ unsigned char *WriteString (unsigned char *buffer, int Code) { sprintf(logline, "Off by %d (len %d Code %d)\n", err, len, Code); showline(logline, 1); } -/* s = buffer; +/* s = buffer; while (s < t) { if (*s++ != 0) putc('1', stdout); else putc('0', stdout); @@ -4694,9 +4809,11 @@ unsigned long OldByte=0; /* cadaver being eaten */ int OldBitsLeft=0; /* how many bits left in OldByte */ #ifdef USESHORTINT -short int GetNextCode (FILE *input) { /* get next LZW code number from input */ +short int GetNextCode (FILE *input) /* get next LZW code number from input */ +{ #else -int GetNextCode (FILE *input) { /* get next LZW code number from input */ +int GetNextCode (FILE *input) /* get next LZW code number from input */ +{ #endif int bits; int c; @@ -4704,7 +4821,7 @@ int GetNextCode (FILE *input) { /* get next LZW code number from input */ bits = OldBitsLeft; /* how many bits do we have */ k = OldByte; /* start with old bits */ - + while (bits < CodeLength) { /* need more bits ? */ if (InStripLen-- <= 0) { /* treat as EOD 96/Nov/17 */ if (traceflag) { @@ -4713,7 +4830,8 @@ int GetNextCode (FILE *input) { /* get next LZW code number from input */ } return EOD; } - if ((c = getc(input)) == EOF) { + if ((c = getc(input)) == EOF) + { sprintf(logline, " Unexpected EOF (%s)\n", "getnextcode"); showline(logline, 1); checkexit(1); @@ -4741,7 +4859,8 @@ int GetNextCode (FILE *input) { /* get next LZW code number from input */ #endif } -void LZWdecompress (unsigned char *StripData, FILE *input) { +void LZWdecompress (unsigned char *StripData, FILE *input) +{ #ifdef USESHORTINT short int Code, OldCode; #else @@ -4834,7 +4953,8 @@ void LZWdecompress (unsigned char *StripData, FILE *input) { /* reset table for next one */ ResetStringTable(0); #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { sprintf(logline, "Now at byte %ld in file\n", ftell(input)); showline(logline, 0); } @@ -4848,7 +4968,8 @@ void LZWdecompress (unsigned char *StripData, FILE *input) { /* First one was already set up - don't disturb in case not indirect */ /* In practice, strips are usually contiguous, but no guarantee... */ -long SetupStrip (FILE *input, int k) { /* 96/Nov/17 */ +long SetupStrip (FILE *input, int k) /* 96/Nov/17 */ +{ if (k > 0) { StripOffset = indirectvalue(StripOffsetsType, 1, StripOffsetsPtr + k * typesize[StripOffsetsType], input); @@ -4862,7 +4983,8 @@ long SetupStrip (FILE *input, int k) { /* 96/Nov/17 */ showline(logline, 0); } #endif - if (fseek (input, StripOffset, SEEK_SET)) { + if (fseek (input, StripOffset, SEEK_SET)) + { showline("Error in seek to StripOffset", 1); /* ??? */ finish = -1; return -1; @@ -4875,7 +4997,8 @@ long SetupStrip (FILE *input, int k) { /* 96/Nov/17 */ /* Copy a row from far space used by LZW to near space used for output */ void CopyRow (unsigned char *lpBuffer, unsigned char *StripData, - long InRowLength) { + long InRowLength) +{ int k, n; unsigned char *s=lpBuffer; unsigned char *t=StripData; @@ -4894,7 +5017,8 @@ void CopyRow (unsigned char *lpBuffer, unsigned char *StripData, /* A whole strip is treated as one unit for LZW encoding ... */ /* So need to do once per strip and need memory for strip output */ -int DecodeLZW (FILE *output, FILE *input, unsigned char *lpBuffer) { +int DecodeLZW (FILE *output, FILE *input, unsigned char *lpBuffer) +{ int k, row = 0, i, j, n, m, flag = 0; /* unsigned char *StripData; */ long nlen; @@ -5029,7 +5153,8 @@ BOOL bTIFFAllow=1; /* x * (numer / denom) 1995/Oct/12 */ /* or use MulDiv ??? */ -long MulRatio (long x, unsigned long numer, unsigned long denom) { +long MulRatio (long x, unsigned long numer, unsigned long denom) +{ long result; if (denom == 0 || numer == 0) return 0; if ((numer % denom) == 0) { @@ -5063,7 +5188,8 @@ long MulRatio (long x, unsigned long numer, unsigned long denom) { /* if dheight == 0 => calculate dheight from dwidth based on aspect ratio */ int showtiffhere (FILE *output, char *filename, long dwidth, long dheight, - double xscale, double yscale, int nifd) { + double xscale, double yscale, int nifd) +{ int flag; if (bTIFFAllow != 0) { /* if (dheight == 0) { */ /* need aspect ratio from TIFF file */ @@ -5162,7 +5288,8 @@ int showtiffhere (FILE *output, char *filename, long dwidth, long dheight, /* made common to save string space */ -void dontunderline (void) { +void dontunderline (void) +{ // showline(" ERROR: don't understand ", 1); // showline(line, 1); sprintf(logline, " ERROR: don't understand: %s", line); @@ -5217,15 +5344,18 @@ void platformindependent (char *buffer, char *name) { /* 96/Mar/3 */ /* char *badcharinname=" \t\n\r\f()<>[]{}/%"; */ char *badcharinname=" \b\t\n\f\r()<>[]{}/%"; -void cleanupname (char *name) { +void cleanupname (char *name) +{ char *s; #ifdef DEBUGCLEANUP - if (traceflag) { + if (traceflag) + { sprintf(logline, " CLEANUPNAME: %s", name); /* debugging */ showline(logline, 0); } #endif - if (*name == '\0') { + if (*name == '\0') + { showline(" ERROR: empty mark or button", 1); } s = name; @@ -5233,7 +5363,8 @@ void cleanupname (char *name) { strcpy(s, s+1); if (strlen(name) > MAXPSNAME) *(name+MAXPSNAME) = '\0'; /* 96/Aug/12 */ #ifdef DEBUGCLEANUP - if (traceflag) { + if (traceflag) + { sprintf(logline, " CLEANEXIT: %s", name); /* debugging */ showline(logline, 0); } @@ -5243,7 +5374,8 @@ void cleanupname (char *name) { /* support for old textcolor / rulecolor specials */ -int oldcolor (FILE *output, FILE *input) { +int oldcolor (FILE *output, FILE *input) +{ char *s; int n; /* old text color support */ @@ -5398,7 +5530,8 @@ int oldcolor (FILE *output, FILE *input) { /* new to allow quoted file names with spaces 98/Jul/9 */ -char *scaninsert(char *line, char *filename) { +char *scaninsert(char *line, char *filename) +{ char *s = line; char *t = filename; @@ -5430,7 +5563,8 @@ char *scaninsert(char *line, char *filename) { /* returns zero if *not* one of our DVIWindo \specials */ -int newspecials (FILE *output, FILE *input) { +int newspecials (FILE *output, FILE *input) +{ int nifd=1; long dheight, dwidth; char filename[FILENAME_MAX]; @@ -5446,28 +5580,32 @@ int newspecials (FILE *output, FILE *input) { double xscale, yscale; #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { sprintf(logline, " %s:", line); showline(logline, 0); } #endif /* insert TIFF or BMP image */ - if (strcmp(line, "insertimage") == 0) { + if (strcmp(line, "insertimage") == 0) + { /* (void) scanspecial (input, line, MAXLINE); */ (void) scanspecialraw (input, line, MAXLINE); #ifdef DEBUGTIFF - if (traceflag) { + if (traceflag) + { sprintf(logline, " %s ", line); showline(logline, 0); } #endif nifd = 1; /* n-th (sub-)image in TIFF file */ - dwidth = dheight = 0; /* NEW - use all info from file */ + dwidth = dheight = 0; /* NEW - use all info from file */ xscale = yscale = 0.0; /* 99/July/2 */ /* if (sscanf(line, "%s %ld %ld %d", filename, &dwidth, &dheight, &nifd) */ s = scaninsert(line, filename); - if ((t = strstr(s, "scaled")) == NULL) { + if ((t = strstr(s, "scaled")) == NULL) + { sscanf(s, "%ld %ld %d", &dwidth, &dheight, &nifd); /* normal */ } else { /* new case 99/July/2 */ @@ -5754,7 +5892,7 @@ int newspecials (FILE *output, FILE *input) { return 1; /* we recognize it, but ignore it */ } #ifdef DEBUGTIFF - else if (traceflag) showline(line, 1); + else if (traceflag) showline(line, 1); #endif return 0; /* not a DVIWindo special */ } @@ -5768,13 +5906,14 @@ int newspecials (FILE *output, FILE *input) { rclip=0.000000 tclip=0.000000 nostrip */ /* New stuff for HPTAG */ /* 95/Oct/12 */ -int dohptag (FILE *output, FILE *input) { +int dohptag (FILE *output, FILE *input) +{ /* double bclip=0, lclip=0, rclip=0, tclip=0; */ /* int hleft=1, hright=0, vhigh=1, vlow=0; */ /* double xmag=1, ymag=1; */ /* int nostrip=1; */ char *s, *t; - char filename[FILENAME_MAX]; + char filename[FILENAME_MAX]; (void) scanspecial (input, line, MAXLINE); if ((s = strchr(line, ' ')) != NULL) *s = '\0'; diff --git a/src/dvisourc/makedll b/src/dvisourc/makedll index 6cc56bb..926ed3b 100644 --- a/src/dvisourc/makedll +++ b/src/dvisourc/makedll @@ -1,4 +1,5 @@ # Copyright 2007 TeX Users Group +# Copyright 2014 Clerk Ma # You may freely use, modify and/or distribute this file. # Makefile for DVIPSONE diff --git a/src/dvisourc/makefile b/src/dvisourc/makefile index 5e87c7f..4c2c4f6 100644 --- a/src/dvisourc/makefile +++ b/src/dvisourc/makefile @@ -1,4 +1,5 @@ # Copyright 2007 TeX Users Group +# Copyright 2014 Clerk Ma # You may freely use, modify and/or distribute this file. # Makefile for DVIPSONE -- 2.11.0