//*****************************************
int isPalindrome (char mystr[], int size) {
     int i, j, answer;
     
     if(size==1) // if the array has 1 element, it's a palindrome
     return 1;
     
     answer=1; // Initialize to 1; it's a palindrome
     i=0;
     j=size-1;

     // Loop to check for palindrome
     while(i < j) {
         //If mystr[i] is not a letter or a number, increment i
         while(isFiller(mystr[i])==1 && i<=size-1)
             i++;
              
         while(isFiller(mystr[j])==1 && j>=1)
             j--;
         
         //printf("DEBUG: mystr[%d]=%c, mystr[%d]=%c\n", i,mystr[i],j,mystr[j]);
         if( compareChars(mystr[i], mystr[j]) == 0)
              answer = 0;
         
         i++;
         j--;
     }
     return answer;
}
 int32_t TermBuffer::compareTo(LuceneObjectPtr other)
 {
     TermBufferPtr otherTermBuffer(boost::static_pointer_cast<TermBuffer>(other));
     if (field == otherTermBuffer->field)
         return compareChars(text->result.get(), text->length, otherTermBuffer->text->result.get(), otherTermBuffer->text->length);
     else
         return field.compare(otherTermBuffer->field);
 }
Exemple #3
0
static int
makeCorrections ()
{
  int k;
  if (!table->corrections)
    return 1;
  src = 0;
  dest = 0;
  for (k = 0; k < NUMVAR; k++)
    passVariables[k] = 0;
  while (src < srcmax)
    {
      int length = srcmax - src;
      const TranslationTableCharacter *character = back_findCharOrDots
	(currentInput[src], 0);
      const TranslationTableCharacter *character2;
      int tryThis = 0;
      if (!findAttribOrSwapRules ())
	while (tryThis < 3)
	  {
	    TranslationTableOffset ruleOffset = 0;
	    unsigned long int makeHash = 0;
	    switch (tryThis)
	      {
	      case 0:
		if (!(length >= 2))
		  break;
		makeHash = (unsigned long int) character->lowercase << 8;
		character2 = back_findCharOrDots (currentInput[src + 1], 0);
		makeHash += (unsigned long int) character2->lowercase;
		makeHash %= HASHNUM;
		ruleOffset = table->forRules[makeHash];
		break;
	      case 1:
		if (!(length >= 1))
		  break;
		length = 1;
		ruleOffset = character->otherRules;
		break;
	      case 2:		/*No rule found */
		currentOpcode = CTO_Always;
		ruleOffset = 0;
		break;
	      }
	    while (ruleOffset)
	      {
		currentRule =
		  (TranslationTableRule *) & table->ruleArea[ruleOffset];
		currentOpcode = currentRule->opcode;
		currentCharslen = currentRule->charslen;
		if (tryThis == 1 || (currentCharslen <= length &&
				     compareChars (&currentRule->
						   charsdots[0],
						   &currentInput[src],
						   currentCharslen, 0)))
		  {
		    if (currentOpcode == CTO_Correct && back_passDoTest ())
		      {
			tryThis = 4;
			break;
		      }
		  }
		ruleOffset = currentRule->charsnext;
	      }
	    tryThis++;
	  }
      switch (currentOpcode)
	{
	case CTO_Always:
	  if (dest >= destmax)
	    goto failure;
	  srcMapping[dest] = srcMapping[src];
	  currentOutput[dest++] = currentInput[src++];
	  break;
	case CTO_Correct:
	  if (appliedRules != NULL && appliedRulesCount < maxAppliedRules)
	    appliedRules[appliedRulesCount++] = currentRule;
	  if (!back_passDoAction ())
	    goto failure;
	  src = endReplace;
	  break;
	default:
	  break;
	}
    }
failure:
  return 1;
}