src/gedlib/charmaps.c
/*===================================================
 * translate_match -- Find match for current point in string
 *  tt:    [in] tran table
 *  in:    [in] in string
 *  match: [out] match string
 * returns length of input matched
 * match string output points directly into trans table
 * memory, so it is longer-lived than a static buffer
 * Created: 2001/07/21 (Perry Rapp)
 *=================================================*/
- Find match for current point in string
tt:    [in] tran table
in:    [in] in string
match: [out] match string
returns length of input matched
match string output points directly into trans table
memory, so it is longer-lived than a static buffer
Created: 2001/07/21 (Perry Rapp)
- Find match for current point in string tt : [ in ] tran table in : [ in ] in string match : [ out ] match string returns length of input matched match string output points directly into trans table memory so it is longer - lived than a static buffer Created : 2001 / 07 / 21 ( Perry Rapp )
static INT
translate_match (TRANTABLE tt, CNSTRING in, CNSTRING * out)
{
	XNODE node, chnode;
	INT nxtch;
	CNSTRING q = in;
	node = tt->start[(uchar)*in];
	if (!node) {
		*out = "";
		return 0;
	}
	q = in+1;
	while (*q && node->child) {
		nxtch = (uchar)*q;
		chnode = node->child;
		while (chnode && chnode->achar != nxtch)
			chnode = chnode->sibling;
		if (!chnode) break;
		node = chnode;
		q++;
	}
	while (TRUE) {
		if (node->replace) {
			*out = node->replace;
			return q - in;
		}
		if (node->parent) {
			node = node->parent;
			--q;
			continue;
		}
		ASSERT(q == in+1);
		*out = "";
		return 0;
	}
	return 0;
}
static INT translate_match ( TRANTABLE tt , CNSTRING in , CNSTRING * out ) { XNODE node , chnode ; INT nxtch ; CNSTRING q = in ; node = tt -> start [ ( uchar ) * in ] ; if ( ! node ) { * out = " " ; return 0 ; } q = in + 1 ; while ( * q && node -> child ) { nxtch = ( uchar ) * q ; chnode = node -> child ; while ( chnode && chnode -> achar != nxtch ) chnode = chnode -> sibling ; if ( ! chnode ) break ; node = chnode ; q ++ ; } while ( TRUE ) { if ( node -> replace ) { * out = node -> replace ; return q - in ; } if ( node -> parent ) { node = node -> parent ; -- q ; continue ; } ASSERT ( q == in + 1 ) ; * out = " " ; return 0 ; } return 0 ; }
translate_match -- Find match for current point in string
  tt:    [in] tran table
  in:    [in] in string
  match: [out] match string
 returns length of input matched
 match string output points directly into trans table
 memory, so it is longer-lived than a static buffer
 Created: 2001/07/21 (Perry Rapp)
translate_match -- Find match for current point in string tt : [ in ] tran table in : [ in ] in string match : [ out ] match string returns length of input matched match string output points directly into trans table memory so it is longer - lived than a static buffer Created : 2001 / 07 / 21 ( Perry Rapp )
/* Match as far as possible */ /* replacing match */ /* no replacement, only partial match,
		climb back & keep looking - we might have gone past
		a shorter but full (replacing) match */ /*
		no replacement matches
		(climbed all the way back to start
		*/