/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1989-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#include "update.h"
/*
** Find the longest prefix of tar that match some substring of src
** This uses an inverted index for speed.
*/
{
register int i;
{
for(i = 0; i < ALPHA; ++i)
if(n_index[i] > 0)
}
}
/* initial assumptions: src[0] == tar[0] && src+n_match <= endsrc */
{
/* see if this really improves on the current match */
break;
/* got an improvement, match as many more as we can */
{
break;
}
}
/* the real thing */
{
long n_match;
register int i;
register long n_ind;
register char **ind;
static long *N_index = 0;
static int Alloced = 0;
/* free old inverted indices if necessary */
{
if(Alloced)
Alloced = 0;
Cursrc = 0;
}
/* nothing to do */
return 0;
/* build new index structure */
{
Alloced = 1;
{
register char *sp;
{
N_index = 0;
Alloced = 0;
}
{
i = (int)(*((unsigned char *)(sp)));
/* make sure we have space */
{
}
if(ind)
{
N_index[i] += 1;
}
else
{
N_index = 0;
Index = 0;
Alloced = 0;
break;
}
}
}
}
/* find longest matching prefix */
i = (int)(*((unsigned char *)(tar)));
n_match = 0;
while(1)
{
register long m;
if(ind)
{
n_ind -= 1;
}
break;
break;
{
n_match = m;
break;
}
}
return n_match;
}