crblib/matchpat.c
/**

given the first three, fill in the last

**/
given the first three, fill in the last
given the first three fill in the last
bool RenameByPat(pattern FmPat,char *FmStr,pattern ToPat,char *ToStr)
{
patchar FmPatT[1000],ToPatT[1000];
bool ret=0;
#define finish(val) { ret = val; goto RenameByPatDone; }
RenameByPatSimplify(FmPat,FmPatT);
RenameByPatSimplify(ToPat,ToPatT);
FmPat = FmPatT;
ToPat = ToPatT;
for(;;)
  {
  while ( *ToPat != WANY )
    {
    *ToStr++ = *ToPat++;
    if ( ! *ToPat )
      {
      *ToStr = 0;
      finish(1);   
      }
    }
  while ( *FmPat != WANY )
    {
    FmPat++; FmStr++;
    if (! *FmPat )
      {
      *ToStr = 0;
      finish(0); 	
      }
    }
  FmPat++; ToPat++; 
	if ( *ToPat == '$' )
	{
		ToPat++;
	  while ( ! MatchPatternNoCase(FmStr,FmPat) ) FmStr++;
	}
	else
	{
	  while ( ! MatchPatternNoCase(FmStr,FmPat) ) *ToStr++ = *FmStr++;
	}
  }
finish(0);
RenameByPatDone:
return(ret);
}
bool RenameByPat ( pattern FmPat , char * FmStr , pattern ToPat , char * ToStr ) { patchar FmPatT [ 1000 ] , ToPatT [ 1000 ] ; bool ret = 0 ; #define finish ( val )  { ret = val; goto RenameByPatDone; } RenameByPatSimplify ( FmPat , FmPatT ) ; RenameByPatSimplify ( ToPat , ToPatT ) ; FmPat = FmPatT ; ToPat = ToPatT ; for ( ; ; ) { while ( * ToPat != WANY ) { * ToStr ++ = * ToPat ++ ; if ( ! * ToPat ) { * ToStr = 0 ; finish ( 1 ) ; } } while ( * FmPat != WANY ) { FmPat ++ ; FmStr ++ ; if ( ! * FmPat ) { * ToStr = 0 ; finish ( 0 ) ; } } FmPat ++ ; ToPat ++ ; if ( * ToPat == ' ' ) { ToPat ++ ; while ( ! MatchPatternNoCase ( FmStr , FmPat ) ) FmStr ++ ; } else { while ( ! MatchPatternNoCase ( FmStr , FmPat ) ) * ToStr ++ = * FmStr ++ ; } } finish ( 0 ) ; RenameByPatDone : return ( ret ) ; }
given the first three, fill in the last
given the first three fill in the last
/** now only literals and * characters remain **/ /* ok for To to end early, it's a crop */ /* not Ok for Fm to end early, it's an underflow of input */ /* skip the stars */