FDK/Tools/Programs/makeotf/source/cb.c
/* Refill input buffer from PFB file */
Refill input buffer from PFB file
Refill input buffer from PFB file
static char *PFBRefill(cbCtx h, long *count)
	{
 reload:
	if (h->ps.left >= BUFSIZ)
		{
		*count = fileReadN(&h->ps.file, BUFSIZ, h->ps.buf);
		if (*count != BUFSIZ)
			fileError(&h->ps.file);
		h->ps.left -= BUFSIZ;
		}
	else if (h->ps.left > 0)
		{
		*count = fileReadN(&h->ps.file, h->ps.left, h->ps.buf);
		if (*count != h->ps.left)
			fileError(&h->ps.file);
		h->ps.left = 0;
		}
	else
		{
		int escape = read1(h);
		int type = read1(h);
		if (escape != 128 || (type != 1 && type != 2 && type != 3))
			cbFatal(h, "invalid segment [%s]", h->ps.file.name);
		if (type == 3)
			*count = 0;	
		else
			{
			h->ps.left = read1(h);
			h->ps.left |= (long)read1(h)<<8;
			h->ps.left |= (long)read1(h)<<16;
			h->ps.left |= (long)read1(h)<<24;
			goto reload;
			}
		}
	return h->ps.buf;
	}
static char * PFBRefill ( cbCtx h , long * count ) { reload : if ( h -> ps . left >= BUFSIZ ) { * count = fileReadN ( & h -> ps . file , BUFSIZ , h -> ps . buf ) ; if ( * count != BUFSIZ ) fileError ( & h -> ps . file ) ; h -> ps . left -= BUFSIZ ; } else if ( h -> ps . left > 0 ) { * count = fileReadN ( & h -> ps . file , h -> ps . left , h -> ps . buf ) ; if ( * count != h -> ps . left ) fileError ( & h -> ps . file ) ; h -> ps . left = 0 ; } else { int escape = read1 ( h ) ; int type = read1 ( h ) ; if ( escape != 128 || ( type != 1 && type != 2 && type != 3 ) ) cbFatal ( h , " " , h -> ps . file . name ) ; if ( type == 3 ) * count = 0 ; else { h -> ps . left = read1 ( h ) ; h -> ps . left |= ( long ) read1 ( h ) << 8 ; h -> ps . left |= ( long ) read1 ( h ) << 16 ; h -> ps . left |= ( long ) read1 ( h ) << 24 ; goto reload ; } } return h -> ps . buf ; }
Refill input buffer from PFB file
Refill input buffer from PFB file
/* Full block */ /* Partial block */ /* New segment; read segment id */ /* Check segment id */ /* EOF */ /* Read segment length (little endian) */