diff options
author | Russell Lang <gsview@ghostgum.com.au> | 2001-08-01 09:03:40 +0000 |
---|---|---|
committer | Russell Lang <gsview@ghostgum.com.au> | 2001-08-01 09:03:40 +0000 |
commit | 86023ef16c199a4442cb844bcea64fbc6774d114 (patch) | |
tree | fa76658706bc9956d1775a38c132f67826dd9bb3 /gs | |
parent | 45f2cae5c1b6554a52c4413d46faa18c8d66f715 (diff) | |
download | ghostpdl-86023ef16c199a4442cb844bcea64fbc6774d114.tar.gz |
Fix: Ignore white space between %%DocumentData: and argument.
Fix: Set dsc->preview correctly to DOS EPS if both DOS EPS and
EPSI previews are present.
Update to latest dscparse.c/h used in GSview. Change dscparse to mark
internal functions "dsc_private" not "private", so it can be compiled
as C++ (needed by GSview, not Ghostscript).
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@1654 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'gs')
-rw-r--r-- | gs/src/dscparse.c | 154 | ||||
-rw-r--r-- | gs/src/dscparse.h | 8 |
2 files changed, 88 insertions, 74 deletions
diff --git a/gs/src/dscparse.c b/gs/src/dscparse.c index 693dae1d2..56c81dd48 100644 --- a/gs/src/dscparse.c +++ b/gs/src/dscparse.c @@ -80,47 +80,47 @@ #define CDSC_NEEDMORE 11 /* local prototypes */ -private void * dsc_memalloc(P2(CDSC *dsc, size_t size)); -private void dsc_memfree(P2(CDSC*dsc, void *ptr)); -private CDSC * dsc_init2(P1(CDSC *dsc)); -private void dsc_reset(P1(CDSC *dsc)); -private void dsc_section_join(P3(unsigned long begin, unsigned long *pend, unsigned long **pplast)); -private int dsc_read_line(P1(CDSC *dsc)); -private int dsc_read_doseps(P1(CDSC *dsc)); -private char * dsc_alloc_string(P3(CDSC *dsc, const char *str, int len)); -private char * dsc_add_line(P3(CDSC *dsc, const char *line, unsigned int len)); -private char * dsc_copy_string(P5(char *str, unsigned int slen, +dsc_private void * dsc_memalloc(P2(CDSC *dsc, size_t size)); +dsc_private void dsc_memfree(P2(CDSC*dsc, void *ptr)); +dsc_private CDSC * dsc_init2(P1(CDSC *dsc)); +dsc_private void dsc_reset(P1(CDSC *dsc)); +dsc_private void dsc_section_join(P3(unsigned long begin, unsigned long *pend, unsigned long **pplast)); +dsc_private int dsc_read_line(P1(CDSC *dsc)); +dsc_private int dsc_read_doseps(P1(CDSC *dsc)); +dsc_private char * dsc_alloc_string(P3(CDSC *dsc, const char *str, int len)); +dsc_private char * dsc_add_line(P3(CDSC *dsc, const char *line, unsigned int len)); +dsc_private char * dsc_copy_string(P5(char *str, unsigned int slen, char *line, unsigned int len, unsigned int *offset)); -private GSDWORD dsc_get_dword(P1(const unsigned char *buf)); -private GSWORD dsc_get_word(P1(const unsigned char *buf)); -private int dsc_get_int(P3(const char *line, unsigned int len, unsigned int *offset)); -private float dsc_get_real(P3(const char *line, unsigned int len, +dsc_private GSDWORD dsc_get_dword(P1(const unsigned char *buf)); +dsc_private GSWORD dsc_get_word(P1(const unsigned char *buf)); +dsc_private int dsc_get_int(P3(const char *line, unsigned int len, unsigned int *offset)); +dsc_private float dsc_get_real(P3(const char *line, unsigned int len, unsigned int *offset)); -private int dsc_stricmp(P2(const char *s, const char *t)); -private void dsc_unknown(P1(CDSC *dsc)); -private int dsc_parse_pages(P1(CDSC *dsc)); -private int dsc_parse_bounding_box(P3(CDSC *dsc, CDSCBBOX** pbbox, int offset)); -private int dsc_parse_orientation(P3(CDSC *dsc, unsigned int *porientation, +dsc_private int dsc_stricmp(P2(const char *s, const char *t)); +dsc_private void dsc_unknown(P1(CDSC *dsc)); +dsc_private int dsc_parse_pages(P1(CDSC *dsc)); +dsc_private int dsc_parse_bounding_box(P3(CDSC *dsc, CDSCBBOX** pbbox, int offset)); +dsc_private int dsc_parse_orientation(P3(CDSC *dsc, unsigned int *porientation, int offset)); -private int dsc_parse_order(P1(CDSC *dsc)); -private int dsc_parse_media(P2(CDSC *dsc, const CDSCMEDIA **page_media)); -private int dsc_parse_document_media(P1(CDSC *dsc)); -private int dsc_parse_viewing_orientation(P2(CDSC *dsc, CDSCCTM **pctm)); -private int dsc_parse_page(P1(CDSC *dsc)); -private void dsc_save_line(P1(CDSC *dsc)); -private int dsc_scan_type(P1(CDSC *dsc)); -private int dsc_scan_comments(P1(CDSC *dsc)); -private int dsc_scan_preview(P1(CDSC *dsc)); -private int dsc_scan_defaults(P1(CDSC *dsc)); -private int dsc_scan_prolog(P1(CDSC *dsc)); -private int dsc_scan_setup(P1(CDSC *dsc)); -private int dsc_scan_page(P1(CDSC *dsc)); -private int dsc_scan_trailer(P1(CDSC *dsc)); -private int dsc_error(P4(CDSC *dsc, unsigned int explanation, +dsc_private int dsc_parse_order(P1(CDSC *dsc)); +dsc_private int dsc_parse_media(P2(CDSC *dsc, const CDSCMEDIA **page_media)); +dsc_private int dsc_parse_document_media(P1(CDSC *dsc)); +dsc_private int dsc_parse_viewing_orientation(P2(CDSC *dsc, CDSCCTM **pctm)); +dsc_private int dsc_parse_page(P1(CDSC *dsc)); +dsc_private void dsc_save_line(P1(CDSC *dsc)); +dsc_private int dsc_scan_type(P1(CDSC *dsc)); +dsc_private int dsc_scan_comments(P1(CDSC *dsc)); +dsc_private int dsc_scan_preview(P1(CDSC *dsc)); +dsc_private int dsc_scan_defaults(P1(CDSC *dsc)); +dsc_private int dsc_scan_prolog(P1(CDSC *dsc)); +dsc_private int dsc_scan_setup(P1(CDSC *dsc)); +dsc_private int dsc_scan_page(P1(CDSC *dsc)); +dsc_private int dsc_scan_trailer(P1(CDSC *dsc)); +dsc_private int dsc_error(P4(CDSC *dsc, unsigned int explanation, char *line, unsigned int line_len)); /* DSC error reporting */ -private const int dsc_severity[] = { +dsc_private const int dsc_severity[] = { CDSC_ERROR_WARN, /* CDSC_MESSAGE_BBOX */ CDSC_ERROR_WARN, /* CDSC_MESSAGE_EARLY_TRAILER */ CDSC_ERROR_WARN, /* CDSC_MESSAGE_EARLY_EOF */ @@ -663,7 +663,7 @@ dsc_set_page_bbox(CDSC *dsc, unsigned int page_number, /* Private functions below here. */ /******************************************************************/ -private void * +dsc_private void * dsc_memalloc(CDSC *dsc, size_t size) { if (dsc->memalloc) @@ -671,7 +671,7 @@ dsc_memalloc(CDSC *dsc, size_t size) return malloc(size); } -private void +dsc_private void dsc_memfree(CDSC*dsc, void *ptr) { if (dsc->memfree) @@ -681,7 +681,7 @@ dsc_memfree(CDSC*dsc, void *ptr) } /* private constructor */ -private CDSC * +dsc_private CDSC * dsc_init2(CDSC *dsc) { dsc_reset(dsc); @@ -717,7 +717,7 @@ dsc_init2(CDSC *dsc) } -private void +dsc_private void dsc_reset(CDSC *dsc) { unsigned int i; @@ -849,7 +849,7 @@ dsc_reset(CDSC *dsc) * pend is a pointer to the end of this section * pplast is a pointer to a pointer of the end of the previous section */ -private void +dsc_private void dsc_section_join(unsigned long begin, unsigned long *pend, unsigned long **pplast) { if (begin) @@ -860,7 +860,7 @@ dsc_section_join(unsigned long begin, unsigned long *pend, unsigned long **pplas /* return value is 0 if no line available, or length of line */ -private int +dsc_private int dsc_read_line(CDSC *dsc) { char *p, *last; @@ -1028,7 +1028,7 @@ dsc_read_line(CDSC *dsc) /* Save last DSC line, for use with %%+ */ -private void +dsc_private void dsc_save_line(CDSC *dsc) { int len = min(sizeof(dsc->last_line), dsc->line_length); @@ -1036,7 +1036,7 @@ dsc_save_line(CDSC *dsc) } /* display unknown DSC line */ -private void +dsc_private void dsc_unknown(CDSC *dsc) { if (dsc->debug_print_fn) { @@ -1075,7 +1075,7 @@ dsc_is_section(char *line) } -private GSDWORD +dsc_private GSDWORD dsc_get_dword(const unsigned char *buf) { GSDWORD dw; @@ -1086,7 +1086,7 @@ dsc_get_dword(const unsigned char *buf) return dw; } -private GSWORD +dsc_private GSWORD dsc_get_word(const unsigned char *buf) { GSWORD w; @@ -1095,7 +1095,7 @@ dsc_get_word(const unsigned char *buf) return w; } -private int +dsc_private int dsc_read_doseps(CDSC *dsc) { unsigned char *line = (unsigned char *)dsc->line; @@ -1119,12 +1119,17 @@ dsc_read_doseps(CDSC *dsc) /* skip from current position to start of PostScript section */ dsc->skip_bytes = dsc->doseps->ps_begin - 30; + if (dsc->doseps->tiff_begin) + dsc->preview = CDSC_TIFF; + if (dsc->doseps->wmf_begin) + dsc->preview = CDSC_WMF; + return CDSC_OK; } -private int +dsc_private int dsc_parse_pages(CDSC *dsc) { int ip, io; @@ -1215,7 +1220,7 @@ dsc_parse_pages(CDSC *dsc) return CDSC_OK; } -private int +dsc_private int dsc_parse_bounding_box(CDSC *dsc, CDSCBBOX** pbbox, int offset) { unsigned int i, n; @@ -1346,7 +1351,7 @@ dsc_parse_bounding_box(CDSC *dsc, CDSCBBOX** pbbox, int offset) return CDSC_OK; } -private int +dsc_private int dsc_parse_orientation(CDSC *dsc, unsigned int *porientation, int offset) { char *p; @@ -1407,7 +1412,7 @@ dsc_parse_orientation(CDSC *dsc, unsigned int *porientation, int offset) return CDSC_OK; } -private int +dsc_private int dsc_parse_order(CDSC *dsc) { char *p; @@ -1474,7 +1479,7 @@ dsc_parse_order(CDSC *dsc) } -private int +dsc_private int dsc_parse_media(CDSC *dsc, const CDSCMEDIA **page_media) { char media_name[MAXSTR]; @@ -1497,7 +1502,7 @@ dsc_parse_media(CDSC *dsc, const CDSCMEDIA **page_media) } -private int +dsc_private int dsc_parse_document_media(CDSC *dsc) { unsigned int i, n; @@ -1560,7 +1565,7 @@ dsc_parse_document_media(CDSC *dsc) /* viewing orientation is believed to be the first four elements of * a CTM matrix */ -private int +dsc_private int dsc_parse_viewing_orientation(CDSC *dsc, CDSCCTM **pctm) { CDSCCTM ctm; @@ -1603,7 +1608,7 @@ dsc_parse_viewing_orientation(CDSC *dsc, CDSCCTM **pctm) * need to skip a binary header which contains a new line * character */ -private int +dsc_private int dsc_scan_type(CDSC *dsc) { unsigned char *p; @@ -1740,7 +1745,7 @@ dsc_scan_type(CDSC *dsc) -private int +dsc_private int dsc_scan_comments(CDSC *dsc) { /* Comments section ends at */ @@ -2007,6 +2012,8 @@ dsc_scan_comments(CDSC *dsc) else if (IS_DSC(line, "%%DocumentData:")) { unsigned int n = continued ? 3 : 15; char *p = dsc->line + n; + while (IS_WHITE(*p)) + p++; dsc->id = CDSC_DOCUMENTDATA; if (COMPARE(p, "Clean7Bit")) dsc->document_data = CDSC_CLEAN7BIT; @@ -2043,7 +2050,7 @@ dsc_scan_comments(CDSC *dsc) } -private int +dsc_private int dsc_scan_preview(CDSC *dsc) { /* Preview section ends at */ @@ -2061,6 +2068,9 @@ dsc_scan_preview(CDSC *dsc) dsc->beginpreview = DSC_START(dsc); dsc->endpreview = DSC_END(dsc); dsc->scan_section = scan_preview; + /* Don't mark the preview as EPSI if a DOS EPS header is present */ + if (dsc->preview == CDSC_NOPREVIEW) + dsc->preview = CDSC_EPSI; return CDSC_OK; } else { @@ -2096,7 +2106,7 @@ dsc_scan_preview(CDSC *dsc) return CDSC_OK; } -private int +dsc_private int dsc_scan_defaults(CDSC *dsc) { /* Defaults section ends at */ @@ -2173,7 +2183,7 @@ dsc_scan_defaults(CDSC *dsc) /* CDSC_RESPONSE_OK and CDSC_RESPONSE_CANCEL mean ignore the * mismatch (default) */ -private int +dsc_private int dsc_check_match_prompt(CDSC *dsc, const char *str, int count) { if (count != 0) { @@ -2188,7 +2198,7 @@ dsc_check_match_prompt(CDSC *dsc, const char *str, int count) return CDSC_RESPONSE_CANCEL; } -private int +dsc_private int dsc_check_match_type(CDSC *dsc, const char *str, int count) { if (dsc_check_match_prompt(dsc, str, count) == CDSC_RESPONSE_IGNORE_ALL) @@ -2198,7 +2208,7 @@ dsc_check_match_type(CDSC *dsc, const char *str, int count) /* complain if Begin/End blocks didn't match */ /* return non-zero if we should ignore all DSC */ -private int +dsc_private int dsc_check_match(CDSC *dsc) { int rc = 0; @@ -2224,7 +2234,7 @@ dsc_check_match(CDSC *dsc) } -private int +dsc_private int dsc_scan_prolog(CDSC *dsc) { /* Prolog section ends at */ @@ -2324,7 +2334,7 @@ dsc_scan_prolog(CDSC *dsc) return CDSC_OK; } -private int +dsc_private int dsc_scan_setup(CDSC *dsc) { /* Setup section ends at */ @@ -2460,7 +2470,7 @@ dsc_scan_setup(CDSC *dsc) return CDSC_OK; } -private int +dsc_private int dsc_scan_page(CDSC *dsc) { /* Page section ends at */ @@ -2774,7 +2784,7 @@ dsc_scan_page(CDSC *dsc) * %%PageResources: */ -private int +dsc_private int dsc_scan_trailer(CDSC *dsc) { /* Trailer section start at */ @@ -2907,7 +2917,7 @@ dsc_scan_trailer(CDSC *dsc) } -private char * +dsc_private char * dsc_alloc_string(CDSC *dsc, const char *str, int len) { char *p; @@ -2955,7 +2965,7 @@ dsc_alloc_string(CDSC *dsc, const char *str, int len) } /* store line, ignoring leading spaces */ -private char * +dsc_private char * dsc_add_line(CDSC *dsc, const char *line, unsigned int len) { char *newline; @@ -2988,7 +2998,7 @@ dsc_add_line(CDSC *dsc, const char *line, unsigned int len) /* Return pointer to string */ /* Store number of used characters from line */ /* Don't copy enclosing () */ -private char * +dsc_private char * dsc_copy_string(char *str, unsigned int slen, char *line, unsigned int len, unsigned int *offset) { @@ -3078,7 +3088,7 @@ dsc_copy_string(char *str, unsigned int slen, char *line, return str; } -private int +dsc_private int dsc_get_int(const char *line, unsigned int len, unsigned int *offset) { char newline[MAXSTR]; @@ -3104,7 +3114,7 @@ dsc_get_int(const char *line, unsigned int len, unsigned int *offset) return atoi(newline); } -private float +dsc_private float dsc_get_real(const char *line, unsigned int len, unsigned int *offset) { char newline[MAXSTR]; @@ -3133,7 +3143,7 @@ dsc_get_real(const char *line, unsigned int len, unsigned int *offset) return (float)atof(newline); } -private int +dsc_private int dsc_stricmp(const char *s, const char *t) { while (toupper(*s) == toupper(*t)) { @@ -3146,7 +3156,7 @@ dsc_stricmp(const char *s, const char *t) } -private int +dsc_private int dsc_parse_page(CDSC *dsc) { char *p; @@ -3215,7 +3225,7 @@ dsc_debug_print(CDSC *dsc, const char *str) * CDSC_RESPONSE_IGNORE_ALL Ignore all DSC. */ /* Silent operation. Don't display errors. */ -private int +dsc_private int dsc_error(CDSC *dsc, unsigned int explanation, char *line, unsigned int line_len) { diff --git a/gs/src/dscparse.h b/gs/src/dscparse.h index cccabb0a9..992b56452 100644 --- a/gs/src/dscparse.h +++ b/gs/src/dscparse.h @@ -29,8 +29,12 @@ typedef unsigned int GSWORD; /* must be at least 16 bits */ # define TRUE ((GSBOOL)(!FALSE)) #endif -#ifndef private -# define private static +#ifndef dsc_private +# ifdef private +# define dsc_private private +# else +# define dsc_private static +# endif #endif #ifndef min |