示例#1
0
void Error::TraceWrite(const TCHAR * bufp, va_list args)
{
	// wxWidgets doesn't expect newlines in the string, but Camelot source provides them. So we print each bit
	// separately
#if 1
	// replace \n by a space - the real solution is to remove the \n from all the trace statements (yawn)
	TCHAR buf[MAXERRORFORMATLENGTH];
	camStrncpy(buf, bufp, MAXERRORFORMATLENGTH);
	buf[MAXERRORFORMATLENGTH-1]=0;
	TCHAR * b=buf;
	do
	{
		if (*b == '\n') *b=' ';
	} while(*b++);
	wxVLogDebug(buf, args);

#else
	// this way is bad as it doesn't work with args either side of the newline

	TCHAR * newline;

	do
	{
		newline = camStrchr(bufp, _T('\n'));
		if (newline) *newline++=0;
		// We really should pass only the args before the newline here, but...
		wxVLogDebug(bufp, args);

		bufp=newline;
	} while (bufp && *bufp);
#endif
}	
示例#2
0
文件: stemplate.cpp 项目: vata/xarino
BOOL WebAddress::ShouldCorrectHTTP(String_256* pstrCorrect)  
{	
	//Check our parameter
	ERROR2IF(pstrCorrect==NULL, FALSE, "WebAddress::CorrectBackslash - NULL parameter");

	//Get the length of the string
	INT32 iLength=pstrCorrect->Length();

	//If the string is empty, return FALSE
	if (iLength<=0)
		return FALSE;

	//Now, here is the set of characters to test for
	TCHAR* strAllowed=";?&=%abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890$-_.+!*'(),";
	
	//If the first character is a full stop, return FALSE
	if ((*pstrCorrect)[0]=='.')
		return FALSE;

	//And this variable will keep a count of the number of full stops
	INT32 iFullStops=0;

	//This variable will tell us if the last character we looked at
	//was a full stop
	BOOL fLastCharWasFullStop=FALSE;

	//Now, starting at the first character in the string, scan through
	//each character in turn until we get to something that is not
	//in our set of allowed characters
	for (INT32 i=0; i<iLength && (camStrchr(strAllowed, (*pstrCorrect)[i]))!=NULL; i++)
		 {
			 //If the letter we are looking at is a full stop,
			  if ((*pstrCorrect)[i]=='.')
			  {
				  //Then, was the last character we looked at a full stop?
				  if (fLastCharWasFullStop)
				  {
					  //Yes. So we've found two full stops together. Return FALSE
					  return FALSE;
				  }
				  else
				  {
					  //No. So add one to our count of full stops and remember
					  //that this character was a full stop
					   iFullStops++;
					   fLastCharWasFullStop=TRUE;
				  }
			  }
			  else
			  {
				  //No, this character is not a full stop
				  fLastCharWasFullStop=FALSE;
			  }
		 }

	//And return true if we found more than one full stop	
	return (iFullStops>=2);

}
示例#3
0
void OpCreateFontThumbnails::Do(OpDescriptor*)
{
	//First we put up a CFileDialog to allow the user to enter
	//the path to the index file
	CFileDialog dlgIndex(TRUE);

	dlgIndex.DoModal();

	PathName pthIndex=(const TCHAR*) dlgIndex.GetPathName();

	//Now we're going to open that file
	CCDiskFile fileIndex(1024, FALSE, TRUE);

	fileIndex.open(pthIndex, ios::in | ios::binary);

	//And get it ready for lexical reading...
	fileIndex.InitLexer();

	fileIndex.SetDelimiters("\r\n");		
	fileIndex.SetCommentMarker('#');
	fileIndex.SetWhitespace("\t");
	
	//This variable will point to the buffer that has been read in
	const TCHAR* TokenBuf = fileIndex.GetTokenBuf();

	//And this indicates the sort of token that has been read in
	LexTokenType tokType=TOKEN_NORMAL;

	//Now, start reading from the file until we reach the "START" token
	//or we reach the end of the file
	while (tokType != TOKEN_EOF && camStrcmp(TokenBuf, "START")!=0)
	{
		//Get a token frm the file
		fileIndex.GetToken();

		//Find out what sort of token it is
		tokType = fileIndex.GetTokenType();
	}

	//Now read until we reach the end of the file
	while (tokType!=TOKEN_EOF)
	{
		//Get a token frm the file
		fileIndex.GetToken();

		//Find out what sort of token it is
		tokType = fileIndex.GetTokenType();

		//Right, now let's find the first comma in the string
		TCHAR* pcFindPtr=camStrchr(TokenBuf, ',');

		//If we've found one
		if (pcFindPtr)
		{
			//Then move the string pointer on by two characters
			pcFindPtr=camStrninc(pcFindPtr, 2);

			//And if we didn't go past the end of the string
			if (pcFindPtr && *pcFindPtr!='\0')
			{
				//Then pcFindPtr should now be pointing to the font name

				//Then find a pointer to the next comma in the string
				TCHAR* pcSecondComma=camStrchr(pcFindPtr, ',');

				if (!pcSecondComma)
					break;

				//And copy everything from the pcFindPtr (inclusive) to that second comma
				//(exclusive) into a new string
				String_256 strFontName;

				while (pcFindPtr && pcFindPtr!=pcSecondComma && *pcFindPtr!='\0')
				{
					strFontName+=(*pcFindPtr);
					pcFindPtr=camStrinc(pcFindPtr);
				}

				//Now we want to find the ID of the font. That will occur after the
				//second comma. So set pcFindPtr so it points to two characters
				//after the second comma
				pcFindPtr=camStrninc(pcSecondComma, 2);

				//And copy everything from the pcFindPtr (inclusive) to the third comma
				//(exclusive) into a new string
				String_256 strFontID;

				while (pcFindPtr && *pcFindPtr!=',' && *pcFindPtr!='\0')
				{
					strFontID+=(*pcFindPtr);
					pcFindPtr=camStrinc(pcFindPtr);
				}

				//And translate that string into a number
				INT32 lFontID=atol(strFontID);

				//Now find the font item with that name
				SGDisplayPreviewFonts* pFontItem=FindFontFromName(strFontName);

				//And if there is a font with that name
				if (pFontItem)
				{
					//Then create three bitmap thumbnails from that font and
					//save them in the same directory as the index
					CreateThumbnailFiles(pFontItem, lFontID, pthIndex);
				}
			}
		}
	}
}