Back to index

texmacs  1.0.7.15
cmap_read.c
Go to the documentation of this file.
00001 /*  $Header: /home/cvsroot/dvipdfmx/src/cmap_read.c,v 1.4 2009/05/06 01:51:01 chofchof Exp $
00002 
00003     This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
00004 
00005     Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
00006     the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
00007 
00008     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
00009 
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU General Public License for more details.
00019 
00020     You should have received a copy of the GNU General Public License
00021     along with this program; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00023 */
00024 
00025 #include <string.h>
00026 
00027 #include "system.h"
00028 #include "mem.h"
00029 #include "error.h"
00030 
00031 #include "dpxutil.h"
00032 #include "pst.h"
00033 
00034 #include "cmap_p.h"
00035 #include "cmap.h"
00036 
00037 #include "cmap_read.h"
00038 
00039 static int __verbose = 0;
00040 
00041 #define CMAP_PARSE_DEBUG_STR "CMap_parse:"
00042 #define CMAP_PARSE_DEBUG     3
00043 
00044 #ifdef HAVE_DPXFILE
00045 #include "dpxfile.h"
00046 #else
00047 #include "mfileio.h"
00048 
00049 typedef struct {
00050   unsigned char *cursor;
00051   unsigned char *endptr;
00052 
00053   unsigned char *buf;
00054   long    max;
00055   FILE   *fp;
00056   long    unread;
00057 } ifreader;
00058 
00059 static ifreader *ifreader_create  (FILE *fp, long remain, long bufsize);
00060 static long      ifreader_read    (ifreader *reader, long size);
00061 static void      ifreader_destroy (ifreader *reader);
00062 
00063 static ifreader *
00064 ifreader_create (FILE *fp, long size, long bufsize)
00065 {
00066   ifreader *reader;
00067 
00068   reader = NEW(1, ifreader);
00069   reader->buf = NEW(bufsize+1, unsigned char);
00070   reader->max = bufsize;
00071   reader->fp  = fp;
00072   reader->unread = size;
00073 
00074   reader->cursor = reader->endptr = reader->buf;
00075   *reader->endptr = 0;
00076 
00077   return reader;
00078 }
00079 
00080 static void
00081 ifreader_destroy (ifreader *reader)
00082 {
00083   ASSERT(reader);
00084   if (reader->buf)
00085     RELEASE(reader->buf);
00086   RELEASE(reader);
00087 }
00088 
00089 
00090 static long
00091 ifreader_read (ifreader *reader, long size)
00092 {
00093   long bytesread = 0, bytesrem = 0;
00094 
00095   ASSERT(reader);
00096   bytesrem = (long) reader->endptr - (long) reader->cursor;
00097   if (size > reader->max) {
00098     if (__verbose)
00099       MESG("\nExtending buffer (%ld bytes)...\n", size);
00100     reader->buf = RENEW(reader->buf, size+1, unsigned char);
00101     reader->max = size;
00102   }
00103   if (reader->unread > 0 && bytesrem < size) {
00104     bytesread = MIN(reader->max - bytesrem, reader->unread);
00105     memmove(reader->buf, reader->cursor, bytesrem);
00106     reader->cursor = reader->buf;
00107     reader->endptr = reader->buf + bytesrem;
00108     if (fread(reader->endptr, 1, bytesread, reader->fp) != bytesread)
00109       ERROR("Reading file failed.");
00110     reader->endptr += bytesread;
00111     reader->unread -= bytesread;
00112     if (__verbose)
00113       MESG("Reading more %ld bytes (%ld bytes remains in buffer)...\n", bytesread, bytesrem);
00114   }
00115 
00116   *reader->endptr = 0;
00117 
00118   return bytesread + bytesrem;
00119 }
00120 #define ifreader_need(f,s) ifreader_read((f),(s))
00121 
00122 #endif /* HAVE_DPXFILE */
00123 
00124 static int check_next_token  (ifreader *input, const char *key);
00125 static int get_coderange     (ifreader *input, unsigned char *codeLo, unsigned char *codeHi, int *dim, int maxlen);
00126 
00127 static int handle_codearray  (CMap *cmap, ifreader *input, unsigned char *codeLo, int dim, int count);
00128 static int do_codespacerange (CMap *cmap, ifreader *input, int count);
00129 static int do_notdefrange    (CMap *cmap, ifreader *input, int count);
00130 static int do_bfrange        (CMap *cmap, ifreader *input, int count);
00131 static int do_cidrange       (CMap *cmap, ifreader *input, int count);
00132 static int do_notdefchar     (CMap *cmap, ifreader *input, int count);
00133 static int do_bfchar         (CMap *cmap, ifreader *input, int count);
00134 static int do_cidchar        (CMap *cmap, ifreader *input, int count);
00135 
00136 #define TOKEN_LEN_MAX 127
00137 
00138 static int
00139 check_next_token (ifreader *input, const char *key)
00140 {
00141   int      cmp;
00142   pst_obj *token;
00143   char    *str;
00144 
00145   if (ifreader_need(input, strlen(key)) < 0)
00146     return -1;
00147   if ((token = pst_get_token(&(input->cursor), input->endptr)) == NULL)
00148     return -1;
00149 
00150   str = (char *) pst_getSV(token);
00151   cmp = strcmp(str, key) ? -1 : 0;
00152   if (str)
00153     RELEASE(str);
00154   pst_release_obj(token);
00155 
00156   return cmp;
00157 }
00158 
00159 static int
00160 get_coderange (ifreader *input,
00161               unsigned char *codeLo, unsigned char *codeHi, int *dim, int maxlen)
00162 {
00163   pst_obj *tok1, *tok2;
00164   int      dim1, dim2;
00165 
00166   if ((tok1 = pst_get_token(&(input->cursor), input->endptr)) == NULL)
00167     return -1;
00168   if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) == NULL) {
00169     pst_release_obj(tok1);
00170     return -1;
00171   }
00172 
00173   if (!PST_STRINGTYPE(tok1) || !PST_STRINGTYPE(tok2)) {
00174     pst_release_obj(tok1);
00175     pst_release_obj(tok2);
00176     return -1;
00177   }
00178 
00179   dim1 = pst_length_of(tok1);
00180   dim2 = pst_length_of(tok2);
00181   if (dim1 != dim2 || dim1 > maxlen) {
00182     pst_release_obj(tok1);
00183     pst_release_obj(tok2);
00184     return -1;
00185   }
00186 
00187   memcpy(codeLo, pst_data_ptr(tok1), dim1);
00188   memcpy(codeHi, pst_data_ptr(tok2), dim2);
00189   pst_release_obj(tok1);
00190   pst_release_obj(tok2);
00191 
00192   *dim = dim1;
00193   return 0;
00194 }
00195 
00196 static int
00197 do_codespacerange (CMap *cmap, ifreader *input, int count)
00198 {
00199   unsigned char codeLo[TOKEN_LEN_MAX], codeHi[TOKEN_LEN_MAX];
00200   int dim;
00201 
00202   while (count-- > 0) { 
00203     if (get_coderange(input, codeLo, codeHi, &dim, TOKEN_LEN_MAX) < 0)
00204       return -1;
00205     CMap_add_codespacerange(cmap, codeLo, codeHi, dim);
00206   }
00207 
00208   return check_next_token(input, "endcodespacerange");
00209 }
00210 
00211 /*
00212  * bfrange
00213  *  <codeLo> <codeHi> [destCode1 destCode2 ...]
00214  */
00215 static int
00216 handle_codearray (CMap *cmap, ifreader *input, unsigned char *codeLo, int dim, int count)
00217 {
00218   pst_obj *tok = NULL;
00219 
00220   if (dim < 1)
00221     ERROR("Invalid code range.");
00222   while (count-- > 0) {
00223     if ((tok = pst_get_token(&(input->cursor), input->endptr)) == NULL)
00224       return -1;
00225     else if (PST_STRINGTYPE(tok)) {
00226       CMap_add_bfchar(cmap, codeLo, dim, (unsigned char *) pst_data_ptr(tok), (int) pst_length_of(tok));
00227     } else if (PST_MARKTYPE(tok) || !PST_NAMETYPE(tok))
00228       ERROR("%s: Invalid CMap mapping record.", CMAP_PARSE_DEBUG_STR);
00229     else
00230       ERROR("%s: Mapping to charName not supported.", CMAP_PARSE_DEBUG_STR);
00231     pst_release_obj(tok);
00232     codeLo[dim-1] += 1;
00233   }
00234 
00235   return check_next_token(input, "]");
00236 }
00237 
00238 static int
00239 do_notdefrange (CMap *cmap, ifreader *input, int count)
00240 {
00241   pst_obj *tok;
00242   unsigned char   codeLo[TOKEN_LEN_MAX], codeHi[TOKEN_LEN_MAX];
00243   long     dstCID;
00244   int      dim;
00245 
00246   while (count-- > 0) { 
00247     if (ifreader_need(input, TOKEN_LEN_MAX*3) < 0)
00248       return -1;
00249     if (get_coderange(input, codeLo, codeHi, &dim, TOKEN_LEN_MAX) < 0 ||
00250        (tok = pst_get_token(&(input->cursor), input->endptr)) == NULL)
00251       return -1;
00252     if (PST_INTEGERTYPE(tok)) {
00253       dstCID = pst_getIV(tok);
00254       if (dstCID >= 0 && dstCID <= CID_MAX)
00255        CMap_add_notdefrange(cmap, codeLo, codeHi, dim, (CID) dstCID);
00256     } else
00257       WARN("%s: Invalid CMap mapping record. (ignored)", CMAP_PARSE_DEBUG_STR);
00258     pst_release_obj(tok);
00259   }
00260 
00261   return check_next_token(input, "endnotdefrange");
00262 }
00263 
00264 static int
00265 do_bfrange (CMap *cmap, ifreader *input, int count)
00266 {
00267   pst_obj *tok; 
00268   unsigned char   codeLo[TOKEN_LEN_MAX], codeHi[TOKEN_LEN_MAX];
00269   int      srcdim;
00270 
00271   while (count-- > 0) { 
00272     if (ifreader_need(input, TOKEN_LEN_MAX*3) < 0)
00273       return -1;
00274     if (get_coderange(input, codeLo, codeHi, &srcdim, TOKEN_LEN_MAX) < 0    ||
00275        (tok = pst_get_token(&(input->cursor), input->endptr)) == NULL)
00276       return -1;
00277     if (PST_STRINGTYPE(tok)) {
00278       CMap_add_bfrange(cmap, codeLo, codeHi, srcdim,
00279                      (unsigned char *) pst_data_ptr(tok), (int) pst_length_of(tok));
00280     } else if (PST_MARKTYPE(tok)) {
00281       if (handle_codearray(cmap, input, codeLo, srcdim,
00282                         codeHi[srcdim-1] - codeLo[srcdim-1] + 1) < 0) {
00283        pst_release_obj(tok);
00284        return -1;
00285       }
00286     } else
00287       WARN("%s: Invalid CMap mapping record. (ignored)", CMAP_PARSE_DEBUG_STR);
00288     pst_release_obj(tok);
00289   }
00290   
00291   return check_next_token(input, "endbfrange");
00292 }
00293 
00294 static int
00295 do_cidrange (CMap *cmap, ifreader *input, int count)
00296 {
00297   pst_obj *tok;
00298   unsigned char   codeLo[TOKEN_LEN_MAX], codeHi[TOKEN_LEN_MAX];
00299   long     dstCID;
00300   int      dim;
00301 
00302   while (count-- > 0) { 
00303     if (ifreader_need(input, TOKEN_LEN_MAX*3) < 0)
00304       return -1;
00305     if (get_coderange(input, codeLo, codeHi, &dim, TOKEN_LEN_MAX) < 0 ||
00306        (tok = pst_get_token(&(input->cursor), input->endptr)) == NULL)
00307       return -1;
00308     if (PST_INTEGERTYPE(tok)) {
00309       dstCID = pst_getIV(tok);
00310       if (dstCID >= 0 && dstCID <= CID_MAX)
00311        CMap_add_cidrange(cmap, codeLo, codeHi, dim, (CID) dstCID);
00312     } else
00313       WARN("%s: Invalid CMap mapping record. (ignored)", CMAP_PARSE_DEBUG_STR);
00314     pst_release_obj(tok);
00315   }
00316 
00317   return check_next_token(input, "endcidrange");
00318 }
00319 
00320 static int
00321 do_notdefchar (CMap *cmap, ifreader *input, int count)
00322 {
00323   pst_obj *tok1, *tok2;
00324   long     dstCID;
00325 
00326   while (count-- > 0) { 
00327     if (ifreader_need(input, TOKEN_LEN_MAX*2) < 0)
00328       return -1;
00329     if ((tok1 = pst_get_token(&(input->cursor), input->endptr)) == NULL)
00330       return -1;
00331     if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) == NULL) {
00332       pst_release_obj(tok1);
00333       return -1;
00334     }
00335     if (PST_STRINGTYPE(tok1) && PST_INTEGERTYPE(tok2)) {
00336       dstCID = pst_getIV(tok2);
00337       if (dstCID >= 0 && dstCID <= CID_MAX)
00338        CMap_add_notdefchar(cmap, pst_data_ptr(tok1), pst_length_of(tok1), (CID) dstCID);
00339     } else
00340       WARN("%s: Invalid CMap mapping record. (ignored)", CMAP_PARSE_DEBUG_STR);
00341     pst_release_obj(tok1);
00342     pst_release_obj(tok2);
00343   }
00344 
00345   return check_next_token(input, "endnotdefchar");
00346 }
00347 
00348 static int
00349 do_bfchar (CMap *cmap, ifreader *input, int count)
00350 {
00351   pst_obj *tok1, *tok2;
00352 
00353   while (count-- > 0) { 
00354     if (ifreader_need(input, TOKEN_LEN_MAX*2) < 0)
00355       return -1;
00356     if ((tok1 = pst_get_token(&(input->cursor), input->endptr)) == NULL)
00357       return -1;
00358     if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) == NULL) {
00359       pst_release_obj(tok1);
00360       return -1;
00361     }
00362     /* We only support single CID font as descendant font, charName should not come here. */
00363     if (PST_STRINGTYPE(tok1) && PST_STRINGTYPE(tok2)) {
00364       CMap_add_bfchar(cmap,
00365                     (unsigned char *) pst_data_ptr(tok1), (int) pst_length_of(tok1),
00366                     (unsigned char *) pst_data_ptr(tok2), (int) pst_length_of(tok2));
00367     } else if (PST_NAMETYPE(tok2))
00368       ERROR("%s: Mapping to charName not supported.", CMAP_PARSE_DEBUG_STR);
00369     else
00370       WARN("%s: Invalid CMap mapping record. (ignored)", CMAP_PARSE_DEBUG_STR);
00371     pst_release_obj(tok1);
00372     pst_release_obj(tok2);
00373   }
00374 
00375   return check_next_token(input, "endbfchar");
00376 }
00377 
00378 static int
00379 do_cidchar (CMap *cmap, ifreader *input, int count)
00380 {
00381   pst_obj *tok1, *tok2;
00382   long     dstCID;
00383 
00384   while (count-- > 0) { 
00385     if (ifreader_need(input, TOKEN_LEN_MAX*2) < 0)
00386       return -1;
00387     if ((tok1 = pst_get_token(&(input->cursor), input->endptr)) == NULL)
00388       return -1;
00389     if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) == NULL) {
00390       pst_release_obj(tok1);
00391       return -1;
00392     }
00393     if (PST_STRINGTYPE(tok1) && PST_INTEGERTYPE(tok2)) {
00394       dstCID = pst_getIV(tok2);
00395       if (dstCID >= 0 && dstCID <= CID_MAX)
00396        CMap_add_cidchar(cmap, pst_data_ptr(tok1), pst_length_of(tok1), (CID) dstCID);
00397     } else
00398       WARN("%s: Invalid CMap mapping record. (ignored)", CMAP_PARSE_DEBUG_STR);
00399     pst_release_obj(tok1);
00400     pst_release_obj(tok2);
00401   }
00402 
00403   return check_next_token(input, "endcidchar");
00404 }
00405 
00406 
00407 #define MATCH_NAME(t,n) (PST_NAMETYPE((t))    && !memcmp(pst_data_ptr((t)),(n),strlen((n))))
00408 #define MATCH_OP(t,n)   (PST_UNKNOWNTYPE((t)) && !memcmp(pst_data_ptr((t)),(n),strlen((n))))
00409 
00410 static int
00411 do_cidsysteminfo (CMap *cmap, ifreader *input)
00412 {
00413   pst_obj   *tok1, *tok2;
00414   CIDSysInfo csi = {NULL, NULL, -1};
00415   int        simpledict = 0;
00416   int        error = 0;
00417 
00418   ifreader_need(input, TOKEN_LEN_MAX*2);
00419   /*
00420    * Assuming /CIDSystemInfo 3 dict dup begin .... end def
00421    * or /CIDSystemInfo << ... >> def
00422    */
00423   while ((tok1 = pst_get_token(&(input->cursor), input->endptr)) != NULL) {
00424     if (PST_MARKTYPE(tok1)) {
00425       simpledict = 1;
00426       pst_release_obj(tok1);
00427       break;
00428     } else if (MATCH_OP(tok1, "begin")) {
00429       simpledict = 0;
00430       pst_release_obj(tok1);
00431       break;
00432     } else {
00433       pst_release_obj(tok1);
00434       /* continue */
00435     }
00436   }
00437   tok1 = tok2 = NULL;
00438   while (!error &&
00439          (tok1 = pst_get_token(&(input->cursor), input->endptr)) != NULL) {
00440     if (MATCH_OP(tok1, ">>") && simpledict) {
00441       pst_release_obj(tok1);
00442       break;
00443     } else if (MATCH_OP(tok1, "end") && !simpledict) {
00444       pst_release_obj(tok1);
00445       break;
00446     } else if (MATCH_NAME(tok1, "Registry") &&
00447                (tok2 = pst_get_token(&(input->cursor), input->endptr)) != NULL) {
00448       if (!PST_STRINGTYPE(tok2))
00449         error = -1;
00450       else if (!simpledict &&
00451                 check_next_token(input, "def"))
00452         error = -1;
00453       if (!error)
00454         csi.registry = (char *) pst_getSV(tok2);
00455     } else if (MATCH_NAME(tok1, "Ordering") &&
00456                (tok2 = pst_get_token(&(input->cursor), input->endptr)) != NULL) {
00457       if (!PST_STRINGTYPE(tok2))
00458         error = -1;
00459       else if (!simpledict &&
00460                 check_next_token(input, "def"))
00461         error = -1;
00462       if (!error)
00463         csi.ordering = (char *) pst_getSV(tok2);
00464     } else if (MATCH_NAME(tok1, "Supplement") &&
00465                (tok2 = pst_get_token(&(input->cursor), input->endptr)) != NULL) {
00466       if (!PST_INTEGERTYPE(tok2))
00467         error = -1;
00468       else if (!simpledict &&
00469                 check_next_token(input, "def"))
00470         error = -1;
00471       if (!error)
00472         csi.supplement = pst_getIV(tok2);
00473     }
00474     if (tok2)
00475       pst_release_obj(tok2);
00476     if (tok1)
00477       pst_release_obj(tok1);
00478     tok1 = tok2 = NULL;
00479   }
00480   if (!error &&
00481        check_next_token(input, "def"))
00482     error = -1;
00483 
00484   if (!error &&
00485        csi.registry && csi.ordering &&
00486        csi.supplement >= 0) {
00487     CMap_set_CIDSysInfo(cmap, &csi);
00488   }
00489 
00490   if (csi.registry)
00491     RELEASE(csi.registry);
00492   if (csi.ordering)
00493     RELEASE(csi.ordering);
00494 
00495   return  error;
00496 }
00497 
00498 #define INPUT_BUF_SIZE 4096
00499 #define CMAP_SIG_MAX   64
00500 int
00501 CMap_parse_check_sig (FILE *fp)
00502 {
00503   int  result = -1;
00504   char sig[CMAP_SIG_MAX+1];
00505 
00506   if (!fp)
00507     return -1;
00508 
00509   rewind(fp);
00510   if (fread(sig, sizeof(char), CMAP_SIG_MAX, fp) != CMAP_SIG_MAX)
00511     result = -1;
00512   else {
00513     sig[CMAP_SIG_MAX] = 0;
00514     if (strncmp(sig, "%!PS", 4))
00515       result = -1;
00516     else if (strstr(sig+4, "Resource-CMap"))
00517       result = 0;
00518   }
00519   rewind(fp);
00520 
00521   return result;
00522 }
00523 
00524 int
00525 CMap_parse (CMap *cmap, FILE *fp)
00526 {
00527   pst_obj  *tok1, *tok2;
00528   ifreader *input;
00529   int       status = 0, tmpint = -1;
00530 
00531   ASSERT(cmap && fp);
00532 
00533   input = ifreader_create(fp, file_size(fp), INPUT_BUF_SIZE-1);
00534 
00535   while (status >= 0) {
00536     tok1 = tok2 = NULL;
00537     ifreader_read(input, INPUT_BUF_SIZE/2);
00538     tok1 = pst_get_token(&(input->cursor), input->endptr);
00539     if (tok1 == NULL)
00540       break;
00541     else if (MATCH_NAME(tok1, "CMapName")) {
00542       if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) == NULL ||
00543          !(PST_NAMETYPE(tok2) || PST_STRINGTYPE(tok2)) ||
00544          check_next_token(input, "def") < 0)
00545        status = -1;
00546       else
00547        CMap_set_name(cmap, pst_data_ptr(tok2));
00548     } else if (MATCH_NAME(tok1, "CMapType")) {
00549       if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) == NULL ||
00550          !PST_INTEGERTYPE(tok2) ||
00551          check_next_token(input, "def") < 0)
00552        status = -1;
00553       else
00554        CMap_set_type(cmap, pst_getIV(tok2));
00555     } else if (MATCH_NAME(tok1, "WMode")) {
00556       if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) == NULL ||
00557          !PST_INTEGERTYPE(tok2) ||
00558          check_next_token(input, "def") < 0)
00559        status = -1;
00560       else
00561        CMap_set_wmode(cmap, pst_getIV(tok2));
00562     } else if (MATCH_NAME(tok1, "CIDSystemInfo")) {
00563       status = do_cidsysteminfo(cmap, input);
00564     } else if (MATCH_NAME(tok1, "Version") ||
00565               MATCH_NAME(tok1, "UIDOffset") ||
00566               MATCH_NAME(tok1, "XUID")) {
00567        /* Ignore */
00568     } else if (PST_NAMETYPE(tok1)) {
00569       /* Possibly usecmap comes next */
00570       if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) != NULL &&
00571          MATCH_OP(tok2, "usecmap")) {
00572        int   id;
00573        CMap *ucmap;
00574        id = CMap_cache_find(pst_data_ptr(tok1));
00575        if (id < 0)
00576          status = -1;
00577        else {
00578          ucmap = CMap_cache_get(id);
00579          CMap_set_usecmap(cmap, ucmap);
00580        }
00581       }
00582     } else if (MATCH_OP(tok1, "begincodespacerange")) {
00583       status = do_codespacerange(cmap, input, tmpint);
00584     } else if (MATCH_OP(tok1, "beginnotdefrange")) {
00585       status = do_notdefrange(cmap, input, tmpint);
00586     } else if (MATCH_OP(tok1, "beginnotdefchar")) {
00587       status = do_notdefchar(cmap, input, tmpint);
00588     } else if (MATCH_OP(tok1, "beginbfrange")) {
00589       status = do_bfrange(cmap, input, tmpint);
00590     } else if (MATCH_OP(tok1, "beginbfchar")) {
00591       status =  do_bfchar(cmap, input, tmpint);
00592     } else if (MATCH_OP(tok1, "begincidrange")) {
00593       status = do_cidrange(cmap, input, tmpint);
00594     } else if (MATCH_OP(tok1, "begincidchar")) {
00595       status =  do_cidchar(cmap, input, tmpint);
00596     } else if (PST_INTEGERTYPE(tok1)) {
00597       tmpint = pst_getIV(tok1);
00598     } /* else Simply ignore */
00599     if (tok1)
00600       pst_release_obj(tok1);
00601     if (tok2)
00602       pst_release_obj(tok2);
00603   }
00604 
00605   ifreader_destroy(input);
00606 
00607   return (status < 0) ? -1 : CMap_is_valid(cmap);
00608 }