Esempio n. 1
0
void vstring::strCopy (char * & target, const char * source1, const char * source2)
{
   char * tmptarget = 0x0000;           // Zunaechst einen Temporaeren Speicher deklarieren, weil diese Routine auch arbeiten soll, wenn einer oder beide SourceString identisch mit dem Target sind. Also darf dieser erst geloescht werden, wenn alles fertig kopiert ist
   strSizeType i = strLength (source1) + strLength (source2);  // Anzahl der zu kopierenden Zeichen holen
   strAlloc (tmptarget, i);             // dann fuer den temporaeren String den Speicher belegen
   if (tmptarget != 0x0000)             // War die gesamtlaenge groesser als 0 ?
   {
      strSizeType j = 0;                // Offset es aktuellen Quellstring in den Zielstring
      if (source1 != 0x0000)            // ist der betreffende Quellstring ueberhaupt vorhanden
      {
         i = 0;                         // Zaehlvariable im Quellstring
         while (source1[i] != 0)        // bis zum Null-Terminierungsbyte durchlaufen..
         {
            tmptarget[j + i] = source1[i];  // und Zeichen fuer Zeichen kopieren
            i++;
         }
         j += i;                        // nun den Offset im Zielstring entsprechend der Eben kopierten Anzahl weitersetzen fuer den naechsten String
      }
      if (source2 != 0x0000)            // ist der zweite String vorhanden ?
      {
         i = 0;                         // genau das selbe vorgehen, wie im ersten Sring. Dieser Teil koennte fuer weitere Funktionen beliebig oft hintereinander kopiert werden
         while (source2[i] != 0)
         {
            tmptarget[j + i] = source2[i];
            i++;
         }
         j += i;
      }
      tmptarget[j] = 0;                 // Und schliesslich das Null-Terminierungs-Byte am ende des Zielstrings setzen
   }
   strFree (target);                    // Nun den Zielstring freigeben, falls er belegt war
   target = tmptarget;                  // Nun den Zeiger einfach umsetzten. Hier muss nicht mehr kopiert werden....
   tmptarget = 0x0000;                  // weil wir hier den temporaeren string als frei markieren, ohne den Speicher wieder freizugeben.
}
Esempio n. 2
0
int vstring::strCompare (const char * x, const char * y)
{
   int result = 0;                      // Rueckgabewert - Vorbelegung
   strSizeType xLen = strLength (x);    // hole zunaechst die Laenge der Strings
   strSizeType yLen = strLength (y);
   if (xLen == 0 || yLen == 0)          // falls einer der Strings keinen inhalt hat (egal ob Pointer NULL ist oder gleich das erste Byte das Null-Terminierungsbyte ist)
   {
      result = (xLen != 0) - (yLen != 0);  // je nachdem welcher String leer war bekommen wir eine positive oder negative Zahl, falls beide Leer waren dann 0
   }
   else                                 // der vorherige Vergleich brachte keine Entscheidung, beide String sind vorhanden
   {
      strSizeType i = 0;                // Zaehlvariable
      while (i < xLen && i < yLen && x[i] == y[i])  // solange die Zeichen identisch sind und beide String noch nicht zuende
      {
         i++;                           // dann zaehle weiter um das naechste Zeichen zu vergleichen
      }
      // entweder ist hier der erste Unterschied, oder einer der Zaehler steht auf einem der Null-Terminierungsbytes (Oder auch beide).
      if (x[i] != y[i])                 // Tatsaechlich einen Unterschied gefunden (oder beide strings zuende) ?
      {
         // Die 'casts' sind notwendig, um sicherzustellen dass ASCII-Zeichen > 127 nicht negativ betrachtet werden und hinter den normalen Zeichen einsortiert werden
         result = static_cast < int > (static_cast < unsigned char > (x[i]) - static_cast < unsigned char > (y[i]));
      }
   }
   return result;                       // liefere das Gesamtresultat zurueck
}
Esempio n. 3
0
void vstring::strReplace (char * & target, const char * replace, const char * by)
{
   char * tmptarget = 0x0000;           // Zunaechst einen temporaeren Speicher deklarieren
   strSizeType n = strLength (target);
   strSizeType k = strLength (replace);
   if (k > 0)                           // ist ueberhaupt ein String angegeben, nach dem gesucht werden soll ?
   {
      strSizeType l = strLength (by);
      char strBuffer[256];              // Lege nun eine Zwischenpuffer an, der eine Feste groesse hat, und immer bei vollstaendiger Fuellung and den Zielstring angefuegt wird
      strSizeType strBufferCounter = 0;
      if (n > 0)
      {
         strSizeType i = 0, j;          // Schleifenzaehler
         while (i + k <= n)
         {
            j = 0;
            while (j < k && target[i + j] == replace[j])
            {
               j++;
            }
            if (j == k)                 // der 'replace' string wurde gefunden, also den 'by' string in den puffer einfuegen
            {
               j = 0;
               while (j < l)
               {
                  // Kopiere den string Zeichen fuer Zeichen in unseren Zwischenpuffer
                  strBuffer[strBufferCounter++] = by[j];
                  if (strBufferCounter == 256 - 1)
                  {
                     strBuffer[strBufferCounter] = 0;
                     strCopy (tmptarget, tmptarget, strBuffer);
                     strBufferCounter = 0;
                  }
                  j++;
               }
               i += k;                  // dann muessen wir erst wieder hinter dem gefundenen String weiter arbeiten
            }
            else
            {
               // der 'replace' string wurde nicht gefunden , also nur den einen character in den puffer einfuegen
               strBuffer[strBufferCounter++] = target[i];
               if (strBufferCounter == 256 - 1)
               {
                  strBuffer[strBufferCounter] = 0;
                  strCopy (tmptarget, tmptarget, strBuffer);
                  strBufferCounter = 0;
               }
               i++;
            }
         }
         // schliesslich noch den rest des puffers an unseren target string anfuegen
         strBuffer[strBufferCounter] = 0;
         strCopy (tmptarget, tmptarget, strBuffer);
         strBufferCounter = 0;
      }
      strFree (target);                 // Nun den Zielstring freigeben, falls er belegt war
      target = tmptarget;               // Nun den Zeiger einfach umsetzten. Hier muss nicht mehr kopiert werden....
      tmptarget = 0x0000;               // weil wir hier den temporaeren string als frei markieren, ohne den Speicher wieder freizugeben.
   }
}
int main()
{
	int n, nCount;

	scanf("%d", &nCount);
	for (n = 0; n < nCount; n++)
	{
		int i,j;
		int max;

		scanf("%s\n%s", &a, &b);
		a_count = strLength(a); b_count = strLength(b);
		
		// Initialize
		for (i = 0; i<=a_count; i++)
			for (j = 0; j<=b_count; j++)
				dp[i][j] = 0;

		// DP - 자기자신을 검사하는 것이 아닌 이전에 같다면 그 개수를 기록
		max = 0;
		for (i = 1; i<=a_count; i++){ // 마지막까지 계산해야하므로 기본 배열 범위보다 +1 
			for (j = 1; j<=b_count; j++){ // 마지막까지 계산해야하므로 기본 배열 범위보다 +1 
				if (a[i - 1] == b[j - 1]){ // 이전 값이 같다면 개수를 기록
					dp[i][j] = dp[i - 1][j - 1] + 1; // 증가시켜줘버령
					
					if (max < dp[i][j]) // 최대 개수를 기록
						max = dp[i][j];
				}
			}
		}
		printf("%d\n", max); // 개어렵...
	}
	return 0;
}
Esempio n. 5
0
int main () {

	const char text[] = "The quick brown fox jumped over the lazy dog."; // text to search
	const char look[] = "The";	// substring to look for in text[]
	int txtLen, lookLen;		// variables to store length of text[] and look[] 
	int found = 0, pos = -1, i, j; // found flag for detection of look[] in text[]
								   // pos to hold the position of look[] in text[]
								   // i and j used as loop counters.
	
	txtLen = strLength(text);		// get the length of the text to search		
	lookLen = strLength(look);		// get the length of the substring to look 
									// for in the text
	
	// stop outer loop when substring is found or until there aren't enough characters
	// left in the text to match the substring
	for (i = 0; (i < (txtLen - lookLen + 1)) && !found; i++) {
		found = 1; 
		for (j = 0; j < lookLen && found; j++) {
			if (text[i + j] == look[j]) {	// match for char in text and char in substring
				pos = i;					// store position in text
				found = 1;					// set flag to potentially found
			}
			else {							// if there isn't a match
				pos = -1;					// reset position and found flag
				found = 0;
			}
		}
	}
	
	while (1);				  
}
int areIsoMorphic(char *a, char *b)		//it checks for the isomorphism of two given strings by assuming a-z is one set and A-Z is another set only
{
	printf("%s  %s  ", a, b);
	int i = 0;
	int len1 = strLength(a);		//length of 1st string
	int len2 = strLength(b);		//length of 2nd string
	char before1_a = 0;				//using to store the 1st string's previous elements of set-1
	char before1_b = 0;				//using to store the 2nd string's previous elements of set-1
	char before2_a = 0;				//using to store the 1st string's previous elements of set-2
	char before2_b = 0;				//using to store the 2nd string's previous elements of set-2
	if (len1 != len2)
		return 0;
	else
	{
		while (a[i] != '\0' && ((a[i] <= 'Z' && b[i] <= 'Z' && a[i] >= 'A' && b[i] >= 'A') || (a[i] >= 'a' && b[i] >= 'a' && a[i] <= 'z' && b[i] <= 'z')))
		{					//if letters at the corresponding indices of two strings belongs to same set
			if ((a[i] <= 'Z' && b[i] <= 'Z'))	//for uppercase series
			{
				if (before1_a)			//if having any previous value then checking for pattern
				{
					if (!((before1_a - a[i] + 26) % 26 == (before1_b - b[i] + 26) % 26))
						break;
					i++;
				}
				else					//if not having any previous element then storing the current element
				{
					before1_a = a[i];
					before1_b = b[i];
					i++;
				}
			}
			else					//for lowercase series
			{
				if (before2_a)
				{
					if (!((before2_a - a[i] + 26) % 26 == (before2_b - b[i] + 26) % 26))
						break;
					i++;
				}
				else
				{
					before2_a = a[i];
					before2_b = b[i];
					i++;
				}
			}
		}
		if (i == len1)	//means all the elements in the array are following the pattern
			return 1;
		else
			return 0;
	}
}
Esempio n. 7
0
bool Parser::extractLength( int& length, std::string::size_type& pos,
                            const std::string& buffer )
throw( MessageParseError )
{
  if( !buffer.size() ) return false;

  std::string::size_type startPos = buffer.find( "\0019=", 0 );
  if( startPos == std::string::npos ) return false;
  startPos += 3;
  std::string::size_type endPos = buffer.find( "\001", startPos );
  if( endPos == std::string::npos ) return false;

  std::string strLength( buffer, startPos, endPos - startPos );

  try
  {
    length = IntConvertor::convert( strLength );
    if( length < 0 ) throw MessageParseError();
  }
  catch( FieldConvertError& )
  { throw MessageParseError(); }

  pos = endPos + 1;
  return true;
}
Esempio n. 8
0
void KConfigBase::writeEntry(const char *pKey, const QStringList &list, char sep, bool bPersistent, bool bGlobal, bool bNLS, bool bExpand)
{
    if(list.isEmpty())
    {
        writeEntry(pKey, QString::fromLatin1(""), bPersistent);
        return;
    }
    QString str_list;
    str_list.reserve(4096);
    QStringList::ConstIterator it = list.begin();
    for(; it != list.end(); ++it)
    {
        QString value = *it;
        uint i;
        uint strLength(value.length());
        for(i = 0; i < strLength; i++)
        {
            if(value[i] == sep || value[i] == '\\')
                str_list += '\\';
            str_list += value[i];
        }
        str_list += sep;
    }
    if(str_list.at(str_list.length() - 1) == sep)
        str_list.truncate(str_list.length() - 1);
    writeEntry(pKey, str_list, bPersistent, bGlobal, bNLS, bExpand);
}
Esempio n. 9
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// PBook::EcoSummary():
//    Produce a summary from the PBook for the specified ECO code prefix.
void
PBook::EcoSummary (const char * ecoPrefix, DString * dstr)
{
    uint depth = strLength (ecoPrefix);
    const char * prevEcoStr = "";
    for (uint i=0; i < NodeListCount; i++) {
        bookNodeT * node = NodeList[i];
        if (node == NULL) { continue; }
        const char * comment = node->data.comment;
        const char * ecoStr = epd_findOpcode (comment, "eco");
        const char * movesStr = epd_findOpcode (comment, "moves");
        if (ecoStr != NULL  &&  strIsPrefix (ecoPrefix, ecoStr)) {
            if (depth < 3  &&  strPrefix (ecoStr, prevEcoStr) >= depth+1) {
                continue;
            }
            prevEcoStr = ecoStr;
            while (*ecoStr != '\n'  &&  *ecoStr != 0) {
                dstr->AddChar (*ecoStr);
                ecoStr++;
            }
            dstr->Append ("  ");
            while (*movesStr != '\n'  &&  *movesStr != 0) {
                dstr->AddChar (*movesStr);
                movesStr++;
            }
            dstr->AddChar ('\n');
        }
    }    
}
Esempio n. 10
0
bool areEquial (String *string1, String *string2)
{
	bool result = true;
	if (strLength(string1) != strLength(string2))
		return false;
	StringElement *tmp1 = string1->first;
	StringElement *tmp2 = string2->first; 
	while ((tmp1->next != nullptr) && (tmp2->next != nullptr) && (result))
	{
		if (tmp1->symb != tmp2->symb)
			result = false;
		tmp1 = tmp1->next;
		tmp2 = tmp2->next;
	}
	return result;
}
Esempio n. 11
0
void ConfFile::autogenerateDirNamesByProgId(const char* progId, char* dir1Name, char* dir2Name) {
  // autogenerate dir name
  const byte progIdLength = strLength(progId);
  if (progIdLength > 7) {
    // split by two
    for (byte i = 0; i < 7; i++) {
      dir1Name[i] = progId[i];
    }
    dir1Name[7] = '.';
    dir1Name[8] = '_';
    dir1Name[9] = '_';
    dir1Name[10] = '_';
    dir1Name[11] = 0;

    for (byte i = 0; i < 8; i++) {
      dir2Name[i] = progId[i + 7];
    }
    dir2Name[8] = 0;
  } else {
    for (byte i = 0; i < progIdLength; i++) {
      dir1Name[i] = progId[i];
    }
    dir1Name[progIdLength] = 0;
  }
}
Esempio n. 12
0
END_TEST

START_TEST(test_strLength)
{
    char *string = "Hello World!";

    fail_unless(strLength(string) == 12, NULL);
}
Esempio n. 13
0
String
bufGets(Buffer b)
{
	UByte	*s = b->argv + b->pos;
	int	cc = strLength((String) s);
	bufSkip(b, cc + 1);
	return (String) s;
}
Esempio n. 14
0
int stringCompare(char *c1, char *c2){
int l1 = strLength(c1), l2 = strLength(c2),i,j,count=0;
for(i=0;i<l1;i++){
  for(j=0;j<l2;j++){
    if(c1[i]==c2[j]){
      count++;
      break;
    }
  }
}
if(count>= getMin(l1,l2)){
  return 1;
}
else{
  return 0;
}
}
Esempio n. 15
0
int microinterface::get_position_for_value(int menu_value)
{
	// return offset for x
	itoa(menu_value, _buf, 10); // fixme need use sprintf ?
	
	int offset = strLength(_buf);
	return (_lcd_x + _menu_max_item_length + _menu_max_value_length - offset);
}
// ---------------------------------------------------------------------------
// CSmileyIcon::SetSmileyString
// ---------------------------------------------------------------------------
//
void CSmileyIcon::SetSmileyString( const TDesC& aString )
    { 
    TInt strLength( aString.Length() );
    if ( strLength > CSmileyManager::KMaxLength )
        {
        strLength = CSmileyManager::KMaxLength;
        }
    iStr.Copy( aString.Mid( 0, strLength ) ); 
    };
Esempio n. 17
0
void strToChar (String *string, char *newStr)
{
	StringElement *tmp = string->first->next;
	for (int i = 0; i < strLength(string); ++i)
	{
		newStr[i] = tmp->symb;
		tmp = tmp->next;
	}
}
Esempio n. 18
0
int
bufPuts(Buffer b, const char *s)
{
	int	cc = strLength(s);
	bufAddn(b, s, cc);
	bufAdd1(b,char0);
	bufBack1(b);
	return cc;
}
Esempio n. 19
0
int
bufWrString(Buffer buf, String s)
{
	int cc = strLength(s) + 1;

	bufPutSInt(buf, cc);
	bufPutChars(buf, s, cc);

	return SINT_BYTES + cc;
}
Esempio n. 20
0
void vstring::strReflow (char * & target, strSizeType width, const char * preString, const char * postString, int align)
{
   strRemoveWhiteSpace (target);        // zunaechst mal alle vorhandenen CR und LF loeschen, um dann neue einzufuegen
   strTrim (target);
   strSizeType n = strLength (target);
   char * result = 0x0000;              // hierin speichern wir den ganzen neu gestalteten Absatz zwischen
   if (n > width && width > 0)          // nur dann was tun, wenn der ganze String nicht in eine Zeile passt
   {
      char * line = 0x0000;             // hierin speichern wir eine einzelne Zeile zwischen
      strSizeType a = 0;                // Position, bis zu der bisher der absatz abgearbeitet wurde
      strSizeType b = 0;                // Position bis zu der die neue naechste Zeile geht
      while (b < n)                     // Den ganzen String abarbeiten, bis alles in einzelne Zeilen aufgeteilt wurde
      {
         b = a + width;                 // zunaechst das optimale Ende der naechsten Zeile setzen
         if (b < n)                     // Feststellen, ob der ganze reststring ueberhaupt noch aufgeteilt werden muss
         {
            while (b > a && target[b] != ' ')  // nach vorne suchen, bis wir eine Trennstelle finden
            {
               b--;
            }
            if (b == a)                 // Wenn keine Trennstelle gefunden, dann muessen wir doch nach hinten suchen
            {
               b = a + width;           // Wieder den ausgangswert setzen
               while (b < n && target[b] != ' ')  // und erstes leerzeichen nach hinten suchen
               {
                  b++;
               }
            }
         }
         else
         {
            b = n;                      // Eine weitere Aufteilung ist nicht notwendig, also den ganzen reststring einfach nehmen
         }
         strCopy (line, target, a, b);  // Kopiere jetzt die Zeile aus dem ganzen String heraus
         if (!(align == 3 && b == n))   // die letze Zeile wird beim Blocksatz nicht mehr formatiert
         {
            strReflowLine (line, width, align);  // fuege jetzt je nach ausrichtung vorne oder zwischen drin Leerzeichen ein
         }
         strCopy (result, result, preString);  // kopiere prefix dran
         strCopy (result, result, line);  // kopiere nun die eigentliche Zeile an
         strCopy (result, result, postString);  // kopiere nun den Suffix hinten dran (das LF)
         a = b + 1;                     // und setze nun den beginn des reststring hinter das leerzeichen, an dem wir grade getrennt haben
      }
      strFree (line);                   // und loesche die temporaeren zwiscehnspeicher
   }
   else
   {
      strCopy (result, result, preString);  // kopiere prefix dran
      strCopy (result, result, target);  // kopiere nun die eigentliche Zeile an
      strCopy (result, result, postString);  // kopiere nun den Suffix hinten dran (das LF)
   }
   strCopy (target, result);            // kopiere nun das gesamtergebnis in den uebergebenen String
   strFree (result);
}
Esempio n. 21
0
local String
arRdItemArch(Archive ar)
{
	String	name = arRdItemArch0(ar);
	ULong	idx = 0L;
	Buffer	buf;
	String	ptr;

	if (name[0] != '\0')
		return name;

	if (name[1] == '/') {
		/* Do we ever get more than one of these? */
		arReadNameTable(ar);


		/* Just go round again... */
		return arRdItemArch(ar);
	}


	/* Indirect name: character offset into the name table. */
	(void)sscanf(&name[1], "%8lu ", &idx);


	/* Debugging */
	arDEBUG(dbOut, ">>> Reading offset #%lu (out of %lu)\n",
		idx, (ULong)strLength(ar->names));


	/* Start a new character buffer */
	buf = bufNew();


	/* Jump to the correct place in the buffer */
	ptr = ar->names + idx;


	/* Scan characters up until a / or newline */
	while ((*ptr != '\n') && (*ptr != '/') && *ptr)
		bufPutc(buf, *ptr++);


	/* Convert the buffer into a text string */
	name = bufLiberate(buf);


	/* Debugging */
	arDEBUG(dbOut, ">>> [%s]\n", name);


	/* Return the name from the directory table */
	return name;
}
Esempio n. 22
0
char *reverseString(char *str)
{
	int Length = strLength(str);

	for(int i = 0; i < Length/2; i++)
	{
		swapP( &str[i], &str[Length - i - 1] );
	}

	return str;
}
Esempio n. 23
0
int main ()
{
	FILE *file1 = open();
	FILE *file2 = open();
	String *strFile1[maxLinesNumber];
	String *strFile2[maxLinesNumber];
	for (int i = 0; i < maxLinesNumber; ++i)
	{
		strFile1[i] = createString();
		strFile2[i] = createString();
	}
	int strNumb1 = fileToStringArray (file1, strFile1);
	int strNumb2 = fileToStringArray (file2, strFile2);
	fclose(file1);
	fclose(file2);
	FILE *fileOut;
	fileOut = fopen("result.txt", "w");
	char *add = new char[maxStrLength];
	for (int i = 0; i <= strNumb1; ++i)
	{
		bool isFind = false;
		int j = 0;
		while ((!isFind) && (j <= strNumb2))
		{
			if (areEquial(strFile1[i], strFile2[j]))
			{
				for (int i = 0; i < maxStrLength; ++i)
					add[i] = 0;
				strToChar(strFile1[i], add);
				for (int i = 0; i < strLength(add) - 1; ++i)
				{
					fprintf(fileOut, "%c", add[i]);
				}
				fprintf(fileOut, "\n");
				isFind = true;
			}
			++j;
		}
	}

	fclose(fileOut);
	for (int i = 0; i < maxLinesNumber; ++i)
	{
		deleteString(strFile1[i]);
		deleteString(strFile2[i]);
		delete strFile1[i];
		delete strFile2[i];
	}
	//delete strFile1;
	//delete strFile2;
	delete []add;
}
Esempio n. 24
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// StrAllocator::Duplicate():
//      Duplicates an existing string.
//
char *
StrAllocator::Duplicate (const char * original)
{
    ASSERT (original != NULL);
    uint length = strLength (original);
    char * newStr = New (length + 1);
    char * s = newStr;
    while (*original) {
        *s = *original;  s++;  original++;
    }
    *s = 0;
    return newStr;
}
Esempio n. 25
0
File: doc.c Progetto: dokterp/aldor
Doc
docNewFrString(String s)
{
	Doc		doc;
	Length		cc = strLength(s) + 1;

	doc = docNewEmpty(cc);

	doc->corpus	= strcpy(doc->corpus, s);
	doc->hash	= strHash(s);

	return doc;
}
void print(char* msg, int colour){
	int leng = strLength(msg);
	int i=0;
	int j=0;

	while(i < leng){
	currentVideo[j] = msg[i];
	currentVideo[j+1] = (char) colour;
	i++;
	j+=2;
	}
 
}
Esempio n. 27
0
boolean ConfFile::getFilePathByProgIdAndMcuModel(const char* progId, byte mcuModelId, char* mcuModelBuf, char* filePath, byte& statusRes) {
  while (true) {
    readRootConfFile(progId, mcuModelBuf, filePath, statusRes); checkStatusV(false);
    if (strLength(mcuModelBuf) == 0) {
      return false; // No match found!
    }

    // check if mcuModel matches mcuModelBuf
    byte detectedMcuModelId = UtilsAVR::getAVRModelIdByName(mcuModelBuf, statusRes); checkStatusV(false);
    logDebugD("mcuModel:", detectedMcuModelId);
    if (mcuModelId == detectedMcuModelId) {
      return true; // SUCCESS
    }
  }
}
Esempio n. 28
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// strDuplicate(): Duplicates a string using new[] operator.
//
char *
strDuplicate (const char * original)
{
    ASSERT (original != NULL);
    char * newStr = new char [strLength(original) + 1];
    if (newStr == NULL)  return NULL;
    char *s = newStr;
    while (*original != 0) {
        *s = *original;
        s++; original++;
    }
    *s = 0;   // Add trailing '\0'.
    //printf ("Dup: %p: %s\n", newStr, newStr);
    return newStr;
}
Esempio n. 29
0
File: doc.c Progetto: dokterp/aldor
Doc
docNewFrList(TokenList tl)
{
	Doc		doc;
	TokenList	l;
	Length		cc = 1;

	for (l = tl; l; l = cdr(l))
		cc += strLength(car(l)->val.str) + 1;

	doc = docNewEmpty(cc);

	doc->corpus[0]	= 0;
	for (l = tl; l; l = cdr(l)) {
		strcat(doc->corpus, car(l)->val.str);
		strcat(doc->corpus, "\n");
	}
	doc->hash	= strHash(doc->corpus);

	phaseDEBUG(dbOut, "docNewFrList:  cc = %d; strlen = %d\n",
		   (int) cc, (int) strLength(doc->corpus));

	return doc;
}
Esempio n. 30
0
inline const char *
epd_findOpcode (const char * epdStr, const char * opcode)
{
    const char * s = epdStr;
    while (*s != 0) {
        while (*s == ' '  ||  *s == '\n') { s++; }
        if (strIsPrefix (opcode, s)) {
            const char *codeEnd = s + strLength(opcode);
            if (*codeEnd == ' ') {
                return codeEnd + 1;
            }
        }
        while (*s != '\n'  &&  *s != 0) { s++; }
    }
    return NULL;
}