예제 #1
0
static bool
AttrHasSuffix(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName,
              nsIAtom* aStr_)
{
  FakeRef<nsIAtom> aStr(aStr_);
  auto match = [aStr](const nsAttrValue* aValue) {
    nsAutoString str;
    aValue->ToString(str);
    return StringEndsWith(str, nsDependentAtomString(aStr));
  };
  return DoMatch(aElement, aNS, aName, match);
}
예제 #2
0
static bool
AttrIncludes(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName,
             nsIAtom* aStr_)
{
  FakeRef<nsIAtom> aStr(aStr_);
  auto match = [aStr](const nsAttrValue* aValue) {
    nsAutoString str;
    aValue->ToString(str);
    const nsDefaultStringComparator c;
    return nsStyleUtil::ValueIncludes(str, nsDependentAtomString(aStr), c);
  };
  return DoMatch(aElement, aNS, aName, match);
}
예제 #3
0
/* PHIdent: parse a hmm ident and do pattern match */
static void PHIdent(ILink *models, HMMSet *hset)
{
   char pattern[MAXSTRLEN];
   int h;
   MLink q;
   LabId hmmId;
   Boolean fullName=TRUE; /* are there wildcards in the name */
   char *p;

   SkipSpaces();
   GetAlpha(pattern);
   p = pattern; h=0;
   while ((*p != '\0') && (h<MAXSTRLEN) && (fullName)) {
     if ((*p=='*')||(*p=='?')||(*p=='%')) fullName=FALSE;
     h++;
     p = pattern+h;
   }
   if (fullName) { /* this is the name of the model */
      hmmId = GetLabId(pattern,FALSE);
      q = FindMacroName(hset,'l',hmmId);
      if (q != NULL) {
         if (trace & T_ITM)
            printf("%s ",hmmId->name);
         AddItem((HLink) q->structure, q->structure, models);
      }
   } else { /* need to search for all models that match */
     for (h=0; h<MACHASHSIZE; h++)
       for (q=hset->mtab[h]; q!=NULL; q=q->next)
         if (((q->type=='h') && (parsePhysicalHMM)) || ((q->type=='l') && (!parsePhysicalHMM))) {
	   if (DoMatch(q->id->name,pattern)) {
	     if (trace & T_ITM)
	       printf("%s ",q->id->name);
	     AddItem((HLink) q->structure, q->structure, models);
	   }
         }
   }
}
예제 #4
0
static bool
HasAttr(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName)
{
  auto match = [](const nsAttrValue* aValue) { return true; };
  return DoMatch(aElement, aNS, aName, match);
}
예제 #5
0
/* OpenLabFile: opens a file corresponding to given fname, the file
                returned may be a real file or simply the MLF seek'ed
                to the start of an immediate file definition, isMLF
                tells you which it is.  Returns NULL if nothing found  */
static FILE * OpenLabFile(char *fname, Boolean *isMLF)
{
   FILE *f;
   MLFEntry *e;
   char path[MAXFNAMELEN],name[MAXSTRLEN],tryspec[MAXFNAMELEN];
   Boolean isMatch = FALSE;
   unsigned fixedHash;     /* hash value for PAT_FIXED */
   unsigned anypathHash;   /* hash value for PAT_ANYPATH */ 
   char *fnStart;          /* start of actual file name */
   static MLFEntry *q=NULL;/* entry after last one accessed - checked first */
   
   *isMLF = FALSE; 
   fixedHash = anypathHash = MLFHash(fname);
   fnStart = strrchr(fname,PATHCHAR);
   if (fnStart != NULL) {
      ++fnStart;
      anypathHash = MLFHash(fnStart);
   } else 
      fnStart = fname;
   if (trace&T_MLF)
      printf("HLabel: Searching for label file %s\n",fname);
   if (trace&T_MHASH) 
      printf("HLabel:  anypath hash = %d;  fixed hash = %d\n",anypathHash,fixedHash);
   for (e=(q==NULL?mlfHead:q); e != NULL; e = (e==NULL?mlfHead:e->next)) {
      switch (e->patType){
      case PAT_GENERAL:
         if (trace&T_MAT) 
            printf("HLabel:  general match against %s\n",e->pattern);
         isMatch = DoMatch(fname,e->pattern);
         break;
      case PAT_ANYPATH:
         if (trace&T_MAT) 
            printf("HLabel:  anypath match against %s[%d]\n",e->pattern,e->patHash);
         if (e->patHash == anypathHash)
            isMatch = (strcmp(e->pattern,fnStart) == 0) ? TRUE : FALSE;
         else
            isMatch = FALSE;
         break;
      case PAT_FIXED:
         if (trace&T_MAT) 
            printf("HLabel:  fixed match against %s[%d]\n",e->pattern,e->patHash);
         if (e->patHash == fixedHash)
            isMatch = (strcmp(e->pattern,fname) == 0) ? TRUE : FALSE;
         else
            isMatch = FALSE;
         break;
      }
      if ( isMatch ) {
         if (e->type == MLF_IMMEDIATE) {
            f = mlfile[e->def.immed.fidx];
            if (fseek(f,e->def.immed.offset,SEEK_SET) != 0)
               HError(6521,"OpenLabFile: cant seek to label def in MLF");
            *isMLF=TRUE;
            if (trace&T_MLF)
               printf("HLabel: Loading Immediate Def [Pattern %s]\n",
                      e->pattern);
            q=e->next;
            return f;
         } else {
            name[0] = '\0'; strcpy(path,fname);
            SplitPath(path,name,e->def.subdir,tryspec);
            if (trace&T_SUBD)
               printf("HLabel: trying %s\n",tryspec);
            f = fopen(tryspec,"rb");
            while (f==NULL && e->type == MLF_FULL && strlen(path)>0) {
               SplitPath(path,name,e->def.subdir,tryspec);
               if (trace&T_SUBD)
                  printf("HLabel: trying %s\n",tryspec);
               f = fopen(tryspec,"rb");
            }
            if (f != NULL) {
               if (trace&T_MLF)
                  printf("HLabel: Loading Label File %s [Pattern %s]\n",
                         tryspec,e->pattern);
               return f;
            }
         }
      }
      if (q!=NULL) e=NULL;
      q = NULL;
   }
   /* No MLF Match so try direct open */  
   if (trace&T_SUBD)
      printf("HLabel: trying actual file %s\n",fname);
   f = fopen(fname,"rb");
   if (f !=NULL && trace&T_MLF)
      printf("HLabel: Loading Actual Label File %s\n", fname);
   return f;
}