FDK/Tools/Programs/makeotf/source/cb.c
/* Validate glyph name and return a NULL pointer if the name failed to validate
   else return a pointer to character that stopped the scan. */
Validate glyph name and return a NULL pointer if the name failed to validate
else return a pointer to character that stopped the scan.
Validate glyph name and return a NULL pointer if the name failed to validate else return a pointer to character that stopped the scan .
static char *gnameScan(cbCtx h, char *p)
	{
	static unsigned char next[3][4] =
		{
		{	1,		0,		2,		0},		
		{	1,		1,		1,		0},		
		{	1,		2,		2,		0},		
		};
#define	Q_	(1<<0)	/* Quit scan on unrecognized character */
#define	E_	(1<<1)	/* Report syntax error */
	static unsigned char action[3][4] =
		{
		{	0,		E_,		0,		Q_},	
		{	0,		0,		0,		Q_},	
		{	0,		0,		0,		E_},	
		};
	char *start = p;
	int state = 0;
	for (;;)
		{
		int actn;
		int class;
		int c = *p;
		if (isalpha(c) || c == '_' )
			class = 0;
		else if (isdigit(c))
			class = 1;
		else if (c == '.')
			class = 2;
		else
			class = 3;
		actn = action[state][class];
		state = next[state][class];
		if (actn == 0)
			{
			p++;
			continue;
			}
		if (actn & E_)
			return NULL;
		if (actn & Q_)
			{
			if (p - start > MAX_CHAR_NAME_LEN)
				return NULL;	
			return p;
			}
		}
	}
static char * gnameScan ( cbCtx h , char * p ) { static unsigned char next [ 3 ] [ 4 ] = { { 1 , 0 , 2 , 0 } , { 1 , 1 , 1 , 0 } , { 1 , 2 , 2 , 0 } , } ; #define Q_ 	(1<<0)	/* Quit scan on unrecognized character */ #define E_ 	(1<<1)	/* Report syntax error */ static unsigned char action [ 3 ] [ 4 ] = { { 0 , E_ , 0 , Q_ } , { 0 , 0 , 0 , Q_ } , { 0 , 0 , 0 , E_ } , } ; char * start = p ; int state = 0 ; for ( ; ; ) { int actn ; int class ; int c = * p ; if ( isalpha ( c ) || c == ' ' ) class = 0 ; else if ( isdigit ( c ) ) class = 1 ; else if ( c == ' ' ) class = 2 ; else class = 3 ; actn = action [ state ] [ class ] ; state = next [ state ] [ class ] ; if ( actn == 0 ) { p ++ ; continue ; } if ( actn & E_ ) return NULL ; if ( actn & Q_ ) { if ( p - start > MAX_CHAR_NAME_LEN ) return NULL ; return p ; } } }
Validate glyph name and return a NULL pointer if the name failed to validate
else return a pointer to character that stopped the scan.
Validate glyph name and return a NULL pointer if the name failed to validate else return a pointer to character that stopped the scan .
/* Next state table */ /* 	A-Za-z_	0-9		.		*		index  */ /* -------- ------- ------- ------- ------ */ /* [0] */ /* [1] */ /* [2] */ /* Action table */ /* 	A-Za-z_	0-9		.		*		index  */ /* -------- ------- ------- ------- ------ */ /* [0] */ /* [1] */ /* [2] */ /* Determine character class */ /* Fetch action and change state */ /* Performs actions */ /* Maximum glyph name length exceeded */