parseAFM.cxx (86e1cf34) parseAFM.cxx (c1e8cc3a)
1/*
2 * (C) 1988, 1989, 1990 by Adobe Systems Incorporated. All rights reserved.
3 *
4 * This file may be freely copied and redistributed as long as:
5 * 1) This entire notice continues to be included in the file,
6 * 2) If the file has been modified in any way, a notice of such
7 * modification is conspicuously indicated.
8 *

--- 320 unchanged lines hidden (view full) ---

329 * valid AFM entries (check the keyStrings array above).
330 * "ident" contains everything from white space through the
331 * next space, tab, or ":" character.
332 *
333 * The algorithm is a standard Knuth binary search.
334 */
335#include "afm_hash.cpp"
336
1/*
2 * (C) 1988, 1989, 1990 by Adobe Systems Incorporated. All rights reserved.
3 *
4 * This file may be freely copied and redistributed as long as:
5 * 1) This entire notice continues to be included in the file,
6 * 2) If the file has been modified in any way, a notice of such
7 * modification is conspicuously indicated.
8 *

--- 320 unchanged lines hidden (view full) ---

329 * valid AFM entries (check the keyStrings array above).
330 * "ident" contains everything from white space through the
331 * next space, tab, or ":" character.
332 *
333 * The algorithm is a standard Knuth binary search.
334 */
335#include "afm_hash.cpp"
336
337static inline enum parseKey recognize( register char* ident, int len)
337static inline enum parseKey recognize( char* ident, int len)
338{
339 const hash_entry* pEntry = AfmKeywordHash::in_word_set( ident, len );
340 return pEntry ? pEntry->eKey : NOPE;
341
342} /* recognize */
343
344
345/************************* parseGlobals *****************************/

--- 12 unchanged lines hidden (view full) ---

358 * given file, will have the usual default initialization value
359 * for its type (i.e. entries of type int will be 0, etc).
360 *
361 * This function returns an error code specifying whether there was
362 * a premature EOF or a parsing error. This return value is used by
363 * parseFile to determine if there is more file to parse.
364 */
365
338{
339 const hash_entry* pEntry = AfmKeywordHash::in_word_set( ident, len );
340 return pEntry ? pEntry->eKey : NOPE;
341
342} /* recognize */
343
344
345/************************* parseGlobals *****************************/

--- 12 unchanged lines hidden (view full) ---

358 * given file, will have the usual default initialization value
359 * for its type (i.e. entries of type int will be 0, etc).
360 *
361 * This function returns an error code specifying whether there was
362 * a premature EOF or a parsing error. This return value is used by
363 * parseFile to determine if there is more file to parse.
364 */
365
366static int parseGlobals( FileInputStream* fp, register GlobalFontInfo* gfi )
366static int parseGlobals( FileInputStream* fp, GlobalFontInfo* gfi )
367{
368 bool cont = true, save = (gfi != NULL);
369 int error = ok;
367{
368 bool cont = true, save = (gfi != NULL);
369 int error = ok;
370 register char *keyword;
370 char *keyword;
371 int direction = -1;
372 int tokenlen;
373
374 while (cont)
375 {
376 keyword = token(fp, tokenlen);
377
378 if (keyword == NULL)

--- 183 unchanged lines hidden (view full) ---

562 * for a space character (by comparing character names). If found,
563 * the width of the space character will be used to initialize the
564 * values in the array of character widths.
565 *
566 * Before returning, the position of the read/write pointer of the
567 * FileInputStream is reset to be where it was upon entering this function.
568 */
569
371 int direction = -1;
372 int tokenlen;
373
374 while (cont)
375 {
376 keyword = token(fp, tokenlen);
377
378 if (keyword == NULL)

--- 183 unchanged lines hidden (view full) ---

562 * for a space character (by comparing character names). If found,
563 * the width of the space character will be used to initialize the
564 * values in the array of character widths.
565 *
566 * Before returning, the position of the read/write pointer of the
567 * FileInputStream is reset to be where it was upon entering this function.
568 */
569
570static int initializeArray( FileInputStream* fp, register int* cwi)
570static int initializeArray( FileInputStream* fp, int* cwi)
571{
572 bool cont = true, found = false;
573 unsigned int opos = fp->tell();
574 int code = 0, width = 0, i = 0, error = 0, tokenlen;
571{
572 bool cont = true, found = false;
573 unsigned int opos = fp->tell();
574 int code = 0, width = 0, i = 0, error = 0, tokenlen;
575 register char *keyword;
575 char *keyword;
576
577 while (cont)
578 {
579 keyword = token(fp,tokenlen);
580 if (keyword == NULL)
581 {
582 error = earlyEOF;
583 break; /* get out of loop */

--- 68 unchanged lines hidden (view full) ---

652 * for the encoded characters into the array using the character code
653 * as the index into that array.
654 *
655 * This function returns an error code specifying whether there was
656 * a premature EOF or a parsing error. This return value is used by
657 * parseFile to determine if there is more file to parse.
658 */
659
576
577 while (cont)
578 {
579 keyword = token(fp,tokenlen);
580 if (keyword == NULL)
581 {
582 error = earlyEOF;
583 break; /* get out of loop */

--- 68 unchanged lines hidden (view full) ---

652 * for the encoded characters into the array using the character code
653 * as the index into that array.
654 *
655 * This function returns an error code specifying whether there was
656 * a premature EOF or a parsing error. This return value is used by
657 * parseFile to determine if there is more file to parse.
658 */
659
660static int parseCharWidths( FileInputStream* fp, register int* cwi)
660static int parseCharWidths( FileInputStream* fp, int* cwi)
661{
662 bool cont = true, save = (cwi != NULL);
663 int pos = 0, error = ok, tokenlen;
661{
662 bool cont = true, save = (cwi != NULL);
663 int pos = 0, error = ok, tokenlen;
664 register char *keyword;
664 char *keyword;
665
666 while (cont)
667 {
668 keyword = token(fp,tokenlen);
669 /* Have reached an early and unexpected EOF. */
670 /* Set flag and stop parsing */
671 if (keyword == NULL)
672 {

--- 132 unchanged lines hidden (view full) ---

805 * metric information for the ALL characters (mapped and unmapped)
806 * into the array.
807 *
808 * This function returns an error code specifying whether there was
809 * a premature EOF or a parsing error. This return value is used by
810 * parseFile to determine if there is more file to parse.
811 */
812
665
666 while (cont)
667 {
668 keyword = token(fp,tokenlen);
669 /* Have reached an early and unexpected EOF. */
670 /* Set flag and stop parsing */
671 if (keyword == NULL)
672 {

--- 132 unchanged lines hidden (view full) ---

805 * metric information for the ALL characters (mapped and unmapped)
806 * into the array.
807 *
808 * This function returns an error code specifying whether there was
809 * a premature EOF or a parsing error. This return value is used by
810 * parseFile to determine if there is more file to parse.
811 */
812
813static int parseCharMetrics( FileInputStream* fp, register FontInfo* fi)
813static int parseCharMetrics( FileInputStream* fp, FontInfo* fi)
814{
815 bool cont = true, firstTime = true;
816 int error = ok, count = 0, tokenlen;
814{
815 bool cont = true, firstTime = true;
816 int error = ok, count = 0, tokenlen;
817 register CharMetricInfo *temp = fi->cmi;
818 register char *keyword;
817 CharMetricInfo *temp = fi->cmi;
818 char *keyword;
819
820 while (cont)
821 {
822 keyword = token(fp,tokenlen);
823 if (keyword == NULL)
824 {
825 error = earlyEOF;
826 break; /* get out of loop */

--- 137 unchanged lines hidden (view full) ---

964 * If data is to be saved, the FontInfo record will already contain
965 * a valid pointer to storage for the track kerning data.
966 *
967 * This function returns an error code specifying whether there was
968 * a premature EOF or a parsing error. This return value is used by
969 * parseFile to determine if there is more file to parse.
970 */
971
819
820 while (cont)
821 {
822 keyword = token(fp,tokenlen);
823 if (keyword == NULL)
824 {
825 error = earlyEOF;
826 break; /* get out of loop */

--- 137 unchanged lines hidden (view full) ---

964 * If data is to be saved, the FontInfo record will already contain
965 * a valid pointer to storage for the track kerning data.
966 *
967 * This function returns an error code specifying whether there was
968 * a premature EOF or a parsing error. This return value is used by
969 * parseFile to determine if there is more file to parse.
970 */
971
972static int parseTrackKernData( FileInputStream* fp, register FontInfo* fi)
972static int parseTrackKernData( FileInputStream* fp, FontInfo* fi)
973{
974 bool cont = true, save = (fi->tkd != NULL);
975 int pos = 0, error = ok, tcount = 0, tokenlen;
973{
974 bool cont = true, save = (fi->tkd != NULL);
975 int pos = 0, error = ok, tcount = 0, tokenlen;
976 register char *keyword;
976 char *keyword;
977
978 while (cont)
979 {
980 keyword = token(fp,tokenlen);
981
982 if (keyword == NULL)
983 {
984 error = earlyEOF;

--- 87 unchanged lines hidden (view full) ---

1072 * If data is to be saved, the FontInfo record will already contain
1073 * a valid pointer to storage for the pair kerning data.
1074 *
1075 * This function returns an error code specifying whether there was
1076 * a premature EOF or a parsing error. This return value is used by
1077 * parseFile to determine if there is more file to parse.
1078 */
1079
977
978 while (cont)
979 {
980 keyword = token(fp,tokenlen);
981
982 if (keyword == NULL)
983 {
984 error = earlyEOF;

--- 87 unchanged lines hidden (view full) ---

1072 * If data is to be saved, the FontInfo record will already contain
1073 * a valid pointer to storage for the pair kerning data.
1074 *
1075 * This function returns an error code specifying whether there was
1076 * a premature EOF or a parsing error. This return value is used by
1077 * parseFile to determine if there is more file to parse.
1078 */
1079
1080static int parsePairKernData( FileInputStream* fp, register FontInfo* fi)
1080static int parsePairKernData( FileInputStream* fp, FontInfo* fi)
1081{
1082 bool cont = true, save = (fi->pkd != NULL);
1083 int pos = 0, error = ok, pcount = 0, tokenlen;
1081{
1082 bool cont = true, save = (fi->pkd != NULL);
1083 int pos = 0, error = ok, pcount = 0, tokenlen;
1084 register char *keyword;
1084 char *keyword;
1085
1086 while (cont)
1087 {
1088 keyword = token(fp,tokenlen);
1089
1090 if (keyword == NULL)
1091 {
1092 error = earlyEOF;

--- 109 unchanged lines hidden (view full) ---

1202 * the composite character data and store a pointer to the storage
1203 * in the FontInfo record.
1204 *
1205 * This function returns an error code specifying whether there was
1206 * a premature EOF or a parsing error. This return value is used by
1207 * parseFile to determine if there is more file to parse.
1208 */
1209
1085
1086 while (cont)
1087 {
1088 keyword = token(fp,tokenlen);
1089
1090 if (keyword == NULL)
1091 {
1092 error = earlyEOF;

--- 109 unchanged lines hidden (view full) ---

1202 * the composite character data and store a pointer to the storage
1203 * in the FontInfo record.
1204 *
1205 * This function returns an error code specifying whether there was
1206 * a premature EOF or a parsing error. This return value is used by
1207 * parseFile to determine if there is more file to parse.
1208 */
1209
1210static int parseCompCharData( FileInputStream* fp, register FontInfo* fi)
1210static int parseCompCharData( FileInputStream* fp, FontInfo* fi)
1211{
1212 bool cont = true, firstTime = true, save = (fi->ccd != NULL);
1213 int pos = 0, j = 0, error = ok, ccount = 0, pcount = 0, tokenlen;
1211{
1212 bool cont = true, firstTime = true, save = (fi->ccd != NULL);
1213 int pos = 0, j = 0, error = ok, ccount = 0, pcount = 0, tokenlen;
1214 register char *keyword;
1214 char *keyword;
1215
1216 while (cont)
1217 {
1218 keyword = token(fp,tokenlen);
1219 if (keyword == NULL)
1220 /* Have reached an early and unexpected EOF. */
1221 /* Set flag and stop parsing */
1222 {

--- 134 unchanged lines hidden (view full) ---

1357int parseFile( const char* pFilename, FontInfo** fi, FLAGS flags)
1358{
1359 FileInputStream aFile( pFilename );
1360
1361 int code = ok; /* return code from each of the parsing routines */
1362 int error = ok; /* used as the return code from this function */
1363 int tokenlen;
1364
1215
1216 while (cont)
1217 {
1218 keyword = token(fp,tokenlen);
1219 if (keyword == NULL)
1220 /* Have reached an early and unexpected EOF. */
1221 /* Set flag and stop parsing */
1222 {

--- 134 unchanged lines hidden (view full) ---

1357int parseFile( const char* pFilename, FontInfo** fi, FLAGS flags)
1358{
1359 FileInputStream aFile( pFilename );
1360
1361 int code = ok; /* return code from each of the parsing routines */
1362 int error = ok; /* used as the return code from this function */
1363 int tokenlen;
1364
1365 register char *keyword; /* used to store a token */
1365 char *keyword; /* used to store a token */
1366
1367
1368 (*fi) = (FontInfo *) calloc(1, sizeof(FontInfo));
1369 if ((*fi) == NULL) {error = storageProblem; return(error);}
1370
1371 if (flags & P_G)
1372 {
1373 (*fi)->gfi = (GlobalFontInfo *) calloc(1, sizeof(GlobalFontInfo));

--- 204 unchanged lines hidden ---
1366
1367
1368 (*fi) = (FontInfo *) calloc(1, sizeof(FontInfo));
1369 if ((*fi) == NULL) {error = storageProblem; return(error);}
1370
1371 if (flags & P_G)
1372 {
1373 (*fi)->gfi = (GlobalFontInfo *) calloc(1, sizeof(GlobalFontInfo));

--- 204 unchanged lines hidden ---