예제 #1
0
void CRegProfile::SetRegistryKey(LPCTSTR lpszRegistryKey, LPCTSTR lpszProfileName)
{
    TCHAR szModuleName[_MAX_PATH];

    ASSERTATLMFC(m_pszRegistryKey == NULL);
    ASSERTATLMFC(lpszRegistryKey != NULL);

    if (lpszProfileName == NULL)
    {
        TCHAR szBuff[_MAX_PATH];
        ::GetModuleFileName(_Module.m_hInst, szBuff, _MAX_PATH);

        LPTSTR lpszExt = _tcsrchr(szBuff, '.');
        _ASSERT(lpszExt != NULL);
        _ASSERT(*lpszExt == '.');
        *lpszExt = 0;       // no suffix

        // always capture the complete file name including extension (if present)
        LPCTSTR lpszTemp = (LPTSTR)szBuff;
        for (LPCTSTR lpsz = szBuff; *lpsz != '\0'; lpsz = _tcsinc(lpsz))
        {
            if (*lpsz == '\\' || *lpsz == '/' || *lpsz == ':')
                lpszTemp = (LPTSTR)_tcsinc(lpsz);
        }

        lstrcpy(szModuleName, lpszTemp);
        lpszProfileName = szModuleName;
    }

    free((void*)m_pszRegistryKey);
    m_pszRegistryKey = _tcsdup(lpszRegistryKey);
    free((void*)m_pszProfileName);
    m_pszProfileName = _tcsdup(lpszProfileName);
}
예제 #2
0
// formatting (using wsprintf style formatting)
void __cdecl CStrClass::Format(LPCTSTR lpszFormat, ...)
{
	va_list argList;
	va_start(argList, lpszFormat);

	// make a guess at the maximum length of the resulting string
	int nMaxLen = 0;
	for (LPCTSTR lpsz = lpszFormat; *lpsz != '\0'; lpsz = _tcsinc(lpsz))
	{
		// handle '%' character, but watch out for '%%'
		if (*lpsz != '%' || *(lpsz = _tcsinc(lpsz)) == '%')
		{
			nMaxLen += _tclen(lpsz);
			continue;
		}

		int nItemLen = 0;

		// handle '%' character with format
		int nWidth = 0;
		for (; *lpsz != '\0'; lpsz = _tcsinc(lpsz))
		{
			// check for valid flags
			if (*lpsz == '#')
				nMaxLen += 2;	// for '0x'
			else if (*lpsz == '*')
				nWidth = *va_arg(argList, int*);
			else if (*lpsz == '-' || *lpsz == '+' || *lpsz == '0' ||
				*lpsz == ' ')
				;
			else // hit non-flag character
				break;
		}
		// get width and skip it
		if (nWidth == 0)
		{
			// width indicated by
			int nWidth = _ttoi(lpsz);
			for (; *lpsz != '\0' && _istdigit(*lpsz); lpsz = _tcsinc(lpsz))
				;
		}

		int nPrecision = 0;
		if (*lpsz == '.')
		{
			// skip past '.' separator (width.precision)
			lpsz = _tcsinc(lpsz);

			// get precision and skip it
			if (*lpsz == '*')
				nPrecision = *va_arg(argList, int*);
			else
			{
예제 #3
0
파일: XSTRING.CPP 프로젝트: Spritutu/AiPI-1
void COXString::LTrim()
{    
	int nStringIndex = 0;
	int nLength = GetLength();

	// find first non-space character
	LPCTSTR lpsz = *this;
	while (_istspace(*lpsz))
#ifdef WIN32
		lpsz = _tcsinc(lpsz);
#else
		lpsz++;
#endif

	// fix up data and length
#if _MFC_VER < 0x0700
	nStringIndex = lpsz - m_pchData;
#else
	nStringIndex = PtrToInt(lpsz - GetBuffer());
#endif
	if (nStringIndex == nLength)
		*this = COXString(_T(""));
	else	
		*this = Mid(nStringIndex);	
}
예제 #4
0
파일: File.cpp 프로젝트: ebutusov/Molecules
//-----------------------------------------------------------------------------
// Retrieves the filename of the selected file.
//-----------------------------------------------------------------------------
string CXFile::GetFileName() const
{
	_ASSERT(m_hFile && ((m_hFile) != INVALID_HANDLE_VALUE));
	_ASSERT(!m_strFileName.empty());		// file name should not be empty

	// Always capture the complete file name including extension
	LPTSTR lpszTemp = const_cast<LPTSTR>(m_strFileName.c_str());
	for (LPCTSTR lpsz = m_strFileName.c_str(); *lpsz != '\0'; lpsz = _tcsinc(lpsz))
	{
		// Remember last directory/drive separator
		if (*lpsz == '\\' || *lpsz == '/' || *lpsz == ':')
			lpszTemp = const_cast<LPTSTR>(_tcsinc(lpsz));
	}

	return string(lpszTemp);
}
예제 #5
0
static bool MakeDataTypeBitset(CGT_CDiagMsg*      pdm, 
                               LPCTSTR            pszKADFileAndPath,
                               IXMLDOMNode*       pNode,
                               const TCHAR*       pszAttrName,
                               const TCHAR*       pszTypes,
                               CG_BITSET*         pbsIecTypes)
{
    LPCTSTR    pszInput = pszTypes;
    FC_CString sType;

    while(pszTypes && *pszTypes != 0)
    {
        sType.clear();
        sType.appendUpTo(pszTypes, _T(","), &pszTypes);
        sType.trim();
        CG_DTYPES type = CGT_TypeKeywordToCG_DTYPES(sType);
        if (type == CG_DTYPES_UNDEF)
            CGT_XMLDiagAttrValue(pdm,pNode,pszAttrName,pszInput,NULL);

        *pbsIecTypes |= CGT_DTypesToTBS(type);

        if (*pszTypes != 0)
            pszTypes = _tcsinc(pszTypes);
    }

    return true;
}
예제 #6
0
FC_TOAPI const TCHAR* FC_TODECL FC_StringAppendUpTo(
    FC_StringTYP*  pData, 
    const TCHAR*   pszFrom, 
    const TCHAR*   pszStopCharSet,
    const TCHAR**  ppEndPtr
)
{
    const TCHAR* pc;
    
    pc = _tcspbrk(pszFrom, pszStopCharSet);
    if(!pc)
        pc = pszFrom + _tcslen(pszFrom); //point to the 0-char

    if(ppEndPtr)
        *ppEndPtr = pc; //set *ppEndPtr to the char that stopped the append


    FC_StringAppendChars(pData, pszFrom, pc - pszFrom); 
    
    //get the next char in pszFrom that is not a stop char
    while(*pc && _tcschr(pszStopCharSet, *pc))
        pc = _tcsinc(pc);

    return pc;
}
예제 #7
0
BOOL AFXAPI AfxComparePath(LPCTSTR lpszPath1, LPCTSTR lpszPath2)
{
#ifdef _MAC
	FSSpec fssTemp1;
	FSSpec fssTemp2;
	if (!UnwrapFile(lpszPath1, &fssTemp1) || !UnwrapFile(lpszPath2, &fssTemp2))
		return FALSE;
	return fssTemp1.vRefNum == fssTemp2.vRefNum &&
		fssTemp1.parID == fssTemp2.parID &&
		EqualString(fssTemp1.name, fssTemp2.name, false, true);
#else
	// use case insensitive compare as a starter
	if (lstrcmpi(lpszPath1, lpszPath2) != 0)
		return FALSE;

	// on non-DBCS systems, we are done
	if (!GetSystemMetrics(SM_DBCSENABLED))
		return TRUE;

	// on DBCS systems, the file name may not actually be the same
	// in particular, the file system is case sensitive with respect to
	// "full width" roman characters.
	// (ie. fullwidth-R is different from fullwidth-r).
	int nLen = lstrlen(lpszPath1);
	if (nLen != lstrlen(lpszPath2))
		return FALSE;
	ASSERT(nLen < _MAX_PATH);

	// need to get both CT_CTYPE1 and CT_CTYPE3 for each filename
	LCID lcid = GetThreadLocale();
	WORD aCharType11[_MAX_PATH];
	VERIFY(GetStringTypeEx(lcid, CT_CTYPE1, lpszPath1, -1, aCharType11));
	WORD aCharType13[_MAX_PATH];
	VERIFY(GetStringTypeEx(lcid, CT_CTYPE3, lpszPath1, -1, aCharType13));
	WORD aCharType21[_MAX_PATH];
	VERIFY(GetStringTypeEx(lcid, CT_CTYPE1, lpszPath2, -1, aCharType21));
#ifdef _DEBUG
	WORD aCharType23[_MAX_PATH];
	VERIFY(GetStringTypeEx(lcid, CT_CTYPE3, lpszPath2, -1, aCharType23));
#endif

	// for every C3_FULLWIDTH character, make sure it has same C1 value
	int i = 0;
	for (LPCTSTR lpsz = lpszPath1; *lpsz != 0; lpsz = _tcsinc(lpsz))
	{
		// check for C3_FULLWIDTH characters only
		if (aCharType13[i] & C3_FULLWIDTH)
		{
			ASSERT(aCharType23[i] & C3_FULLWIDTH); // should always match!

			// if CT_CTYPE1 is different then file system considers these
			// file names different.
			if (aCharType11[i] != aCharType21[i])
				return FALSE;
		}
		++i; // look at next character type
	}
	return TRUE; // otherwise file name is truly the same
#endif
}
예제 #8
0
void CShellFileOp::FillSzzBuffer ( TCHAR* pBuffer, const CStringList& list )
{
TCHAR*   pCurrPos;
POSITION pos;
CString  cstr;

    // If this assert fires, the passed-in list was empty. This ought to
    // never fire, actually, since Go() won't even call this function if
    // either list is empty when it shouldn't be.

    ASSERT ( !list.IsEmpty() );

    ASSERT ( pBuffer != NULL );


    pCurrPos = pBuffer;

    pos = list.GetHeadPosition();

    while ( NULL != pos )
        {
        cstr = list.GetNext ( pos );

        _tcscpy ( pCurrPos, (LPCTSTR) cstr );

        pCurrPos = _tcsinc ( _tcschr ( pCurrPos, '\0' ) );
        }

                                        // Tack on the final null
    *pCurrPos = '\0';
}
예제 #9
0
// Get the file name including extention.
BOOL ClsFindFile::GetFileName( ClsString& strName ) const
{
	_ASSERT( m_bFoundFile );

	try
	{
		// Find the last slash.
		LPCTSTR pszSlash = _tcsrchr( &m_findData.cFileName[ 0 ], _T( '\\' ));
		if ( pszSlash )
		{
			// Get a pointer to the next character which is
			// either a 0-character or the first character
			// of the file name.
			pszSlash = _tcsinc( pszSlash );

			// Set the string to the result.
			strName = pszSlash;
		}
		else
			// Use the whole name.
			strName = &m_findData.cFileName[ 0 ];
		return TRUE;
	}
	catch( ClsMemoryException& me )
	{
		// Failure...
		me;
	}
	return FALSE;
}
예제 #10
0
파일: action.cpp 프로젝트: ArildF/masters
void
makeMacro()
{
    STRINGLIST *q;
    char *t;

    if (_tcschr(name, '$')) {              // expand name
        q = macros;
        t = expandMacros(name, &macros);    // name holds result
        if (!*t)                            // error if macro to left of = is undefined
            makeError(currentLine, SYNTAX_NO_MACRO_NAME);
        while ((macros = q)) {
            q = q->next;
            FREE_STRINGLIST(macros);
        }
        FREE(name);
        name = t;
    }

    for (t = name; *t && MACRO_CHAR(*t); t = _tcsinc (t))   // Check for illegal chars
        ;

    if (*t)
        makeError(currentLine, SYNTAX_BAD_CHAR, *t);

    fInheritUserEnv = (BOOL)TRUE;

    // Put Env Var in Env & macros in table.

    if (!putMacro(name, string, 0)) {
        FREE(name);
        FREE(string);
    }
    name = string = NULL;
}
예제 #11
0
static bool MakeSegmentTypeBitset(CGT_CDiagMsg*      pdm, 
                                  LPCTSTR            pszKADFileAndPath,
                                  IXMLDOMNode*       pNode,
                                  const TCHAR*       pszAttrName,
                                  const TCHAR*       pszSegments,
                                  VM_BITSET*         pbsSegmentTypes)
{
    LPCTSTR    pszInput = pszSegments;
    FC_CString sSegment;

    while(pszSegments && *pszSegments != 0)
    {
        sSegment.clear();
        sSegment.appendUpTo(pszSegments, _T(","), &pszSegments);
        sSegment.trim();
        VM_BITSET segm = VM_SegmentKeywordToSegmentBS(sSegment);
        if (segm == VM_BS_SEGM_UNDEF)
        {
            CGT_XMLDiagAttrValue(pdm,pNode,pszAttrName,pszInput,NULL);
            return false;
        }

        *pbsSegmentTypes |= segm;

        if (*pszSegments != 0)
            pszSegments = _tcsinc(pszSegments);
    }

    return true;
}
예제 #12
0
void	CRecent::MakeManuPath( LPSTR lpszPath )
{
	string	FullPath = lpszPath;
	string	FileName = CPathlib::SplitFnameExt( lpszPath );

	// 30文字以下はそのまま
	if( FullPath.size() <= 30 )
		return;

	// ファイル名が30文字以上の場合
	if( ::strlen( FileName.c_str() ) >= 30 ) {
		::strcpy( lpszPath, FileName.c_str() );
		return;
	}

	LPCSTR lpszCur = lpszPath + 2;
	if( lpszPath[0] == '\\' && lpszPath[1] == '\\' ) {
		while (*lpszCur != '\\') {
			lpszCur = _tcsinc(lpszCur);
		}
	}

	if( ::strlen(FullPath.c_str()) - ::strlen(FileName.c_str()) > 3 ) {
		lpszCur = _tcsinc(lpszCur);
		while( *lpszCur != '\\' ) {
			lpszCur = _tcsinc(lpszCur);
		}
	}

	INT	nVolume = lpszCur - lpszPath;
	if( 30 < nVolume+5+::strlen(FileName.c_str()) ) {
		::strcpy( lpszPath, FileName.c_str() );
		return;
	}

	while ( nVolume+4+::strlen(lpszCur) > 30 ) {
		do {
			lpszCur = _tcsinc(lpszCur);
		}
		while( *lpszCur != '\\' );
	}

	lpszPath[nVolume] = '\0';
	::strcat( lpszPath, "\\..." );
	::strcat( lpszPath, lpszCur );
}
예제 #13
0
// Get file name with extension from the given path.
// Eg returns "Stuff.neo" from "C:\Documents\Stuff.neo"
// Code from MFC routine.
// static
CString Library::GetFileName(LPCTSTR pszPathName)
{
  
	CString s;

	// Always capture the complete file name including extension (if present)
	LPTSTR pszTemp = (LPTSTR) pszPathName;
	for (LPCTSTR psz = pszPathName; *psz != '\0'; psz = _tcsinc(psz))
	{
		// Remember last directory/drive separator
		if (*psz == '\\' || *psz == '/' || *psz == ':')
			pszTemp = (LPTSTR)_tcsinc(psz);
	}

	s = pszTemp;
	return s;	
}
void CXTPSyntaxEditDrawTextProcessor::SetRowTabPositions(int nRow, LPCTSTR pcszOrigRowText)
{
	CXTPRowInfo* pRowI = GetRowInfo(nRow);
	ASSERT(pRowI);
	if (!pRowI)
		return;

	pRowI->arTabs.RemoveAll();
	pRowI->arDispCol2StrPos.RemoveAll();
	pRowI->arStrPos2DispCol.RemoveAll();

	int nDispPos = 0;
	int nStrPos = 0;
	for (LPCTSTR p = pcszOrigRowText; p && *p != 0; p = _tcsinc(p), nStrPos++)
	{
		pRowI->arStrPos2DispCol.AddData(nDispPos);

		if (*p == _T('\t'))
		{
			int nSpaces = m_nTabSize - (nDispPos % m_nTabSize);
			for (int i = 0; i < nSpaces; i++)
			{
				if (i == 0)
				{
					pRowI->arTabs.AddData(0);
					pRowI->arDispCol2StrPos.AddData(nStrPos);
				}
				else
				{
					pRowI->arTabs.AddData((BYTE)(nSpaces - i));
					//pRowI->arDispCol2StrPos.AddData(nStrPos + 1);
//Corrected, only with the next real character we have the next nStrPos.
					pRowI->arDispCol2StrPos.AddData(nStrPos);
				}
			}
			nDispPos += nSpaces;
		}
		else
		{
#ifdef XTP_FIXED
// multi-byte character incorrect.
			for (int index = 0; index < ( isleadbyte(*p) != 0 ? 2 : 1 ); index ++)
			{
				pRowI->arTabs.AddData(0);
				pRowI->arDispCol2StrPos.AddData(nStrPos);
				nDispPos++;
			}
#else
			pRowI->arTabs.AddData(0);
			pRowI->arDispCol2StrPos.AddData(nStrPos);
			nDispPos++;
#endif
		}
	}
	pRowI->arStrPos2DispCol.AddData(nDispPos);
	pRowI->arDispCol2StrPos.AddData(nStrPos);
}
예제 #15
0
int InputBoxDlg::StrMatchMBS( const TCHAR *Ptn, const TCHAR *Str ){ //追加 2012.12.01

	//const char *Ptn …ワイルドカード付き文字列
	//const char *Str …検索対象
	//戻り値 …1/0:真/偽

	//_mbsinc()を_tcsinc()に _mbsnextc()を_tcsnextc()に、変更 2011.09.09

	switch( *Ptn )
	{
		case _T('\0'):
			return (_tcsnextc(Str)==_T('\0'));
		case _T('*'):
			return StrMatchMBS( _tcsinc(Ptn), Str ) || (_tcsnextc(Str)!=_T('\0')) && StrMatchMBS( Ptn, _tcsinc(Str) );
		case _T('?'):
			return (_tcsnextc(Str)!=_T('\0')) && StrMatchMBS( _tcsinc(Ptn), _tcsinc(Str) );
		default:
			return (_tcsnextc(Ptn)==_tcsnextc(Str)) && StrMatchMBS( _tcsinc(Ptn), _tcsinc(Str) );
	}
}
예제 #16
0
// logical char counter (useful in DBCS environment)
int log_strlen( LPCTSTR psz )
{
	int nChars = 0;
	while ( *psz )
	{
		nChars++;
		psz = _tcsinc( psz );
	}

	return nChars;
}
예제 #17
0
void AFXAPI AfxGetRoot(LPCTSTR lpszPath, CString& strRoot)
{
	ASSERT(lpszPath != NULL);
	// determine the root name of the volume
	LPTSTR lpszRoot = strRoot.GetBuffer(_MAX_PATH);
	memset(lpszRoot, 0, _MAX_PATH);
	lstrcpyn(lpszRoot, lpszPath, _MAX_PATH);
	for (LPTSTR lpsz = lpszRoot; *lpsz != '\0'; lpsz = _tcsinc(lpsz))
	{
		// find first double slash and stop
		if (IsDirSep(lpsz[0]) && IsDirSep(lpsz[1]))
			break;
	}
	if (*lpsz != '\0')
	{
		// it is a UNC name, find second slash past '\\'
		ASSERT(IsDirSep(lpsz[0]));
		ASSERT(IsDirSep(lpsz[1]));
		lpsz += 2;
		while (*lpsz != '\0' && (!IsDirSep(*lpsz)))
			lpsz = _tcsinc(lpsz);
		if (*lpsz != '\0')
			lpsz = _tcsinc(lpsz);
		while (*lpsz != '\0' && (!IsDirSep(*lpsz)))
			lpsz = _tcsinc(lpsz);
		// terminate it just after the UNC root (ie. '\\server\share\')
		if (*lpsz != '\0')
			lpsz[1] = '\0';
	}
	else
	{
		// not a UNC, look for just the first slash
		lpsz = lpszRoot;
		while (*lpsz != '\0' && (!IsDirSep(*lpsz)))
			lpsz = _tcsinc(lpsz);
		// terminate it just after root (ie. 'x:\')
		if (*lpsz != '\0')
			lpsz[1] = '\0';
	}
	strRoot.ReleaseBuffer();
}
예제 #18
0
void CCOMString::TrimLeft()
{
	LPTSTR lpsz = m_pszString;

	while (_istspace(*lpsz))
		lpsz = _tcsinc(lpsz);

	if (lpsz != m_pszString)
	{
		memmove(m_pszString, lpsz, (GetLength()+1) * sizeof(TCHAR));
	}
}
예제 #19
0
///////////////////////////////////////////////////////////////////////////////////////////////
// Pendant zu wsprintf() für string-Parameter;
// im Unterschied zu Format() werden hier die übergebenen Parameter auf den Stack erwartet;
// der Hauptteil dieser Routine beschäftigt sich damit, die Zeichenanzahl für den char*-Puffer
// pTmp zu ermitteln, der dann nur noch an die Bibliotheksfunktion _vstprintf() übergeben wird
void FormatV (string& rStr, LPCTSTR lpszFormat, va_list argList)
{
	TX_ASSERT (TIsValidString(lpszFormat, false));

va_list argListSave = argList;

// make a guess at the maximum length of the resulting string
int nMaxLen = 0;

	for (LPCTSTR lpsz = lpszFormat; *lpsz != '\0'; lpsz = _tcsinc(lpsz))
	{
		// handle '%' character, but watch out for '%%'
		if (*lpsz != '%' || *(lpsz = _tcsinc(lpsz)) == '%')
		{
			nMaxLen += _tclen(lpsz);
			continue;
		}

	int nItemLen = 0;

	// handle '%' character with format
	int nWidth = 0;

		for (; *lpsz != '\0'; lpsz = _tcsinc(lpsz))
		{
			// check for valid flags
			if (*lpsz == '#')
				nMaxLen += 2;   // for '0x'
			else if (*lpsz == '*')
				nWidth = va_arg(argList, int);
			else if (*lpsz == '-' || *lpsz == '+' || *lpsz == '0' ||
				*lpsz == ' ')
				;
			else // hit non-flag character
				break;
		}
		// get width and skip it
		if (nWidth == 0)
		{
			// width indicated by
			nWidth = _ttoi(lpsz);
			for (; *lpsz != '\0' && _istdigit(*lpsz); lpsz = _tcsinc(lpsz))
				;
		}
		TX_ASSERT (nWidth >= 0);

	int nPrecision = 0;

		if (*lpsz == '.')
		{
			// skip past '.' separator (width.precision)
			lpsz = _tcsinc(lpsz);

			// get precision and skip it
			if (*lpsz == '*')
			{
				nPrecision = va_arg(argList, int);
				lpsz = _tcsinc(lpsz);
			}
예제 #20
0
bool IsValidBlueprintName (LPCTSTR pszName)
{
	if (*pszName == 0)
		return false;
	while (*pszName)
	{
		int c = _tcsnextc (pszName);
		pszName = _tcsinc (pszName);
		if (!_istalnum (c) && c != '_')
			return false;
	}
	return true;
}
예제 #21
0
파일: strex.cpp 프로젝트: ngphloc/agmagic
int CString::Remove(TCHAR chRemove)
{
	CopyBeforeWrite();

	LPTSTR pstrSource = m_pchData;
	LPTSTR pstrDest = m_pchData;
	LPTSTR pstrEnd = m_pchData + GetData()->nDataLength;

	while (pstrSource < pstrEnd)
	{
		if (*pstrSource != chRemove)
		{
			*pstrDest = *pstrSource;
			pstrDest = _tcsinc(pstrDest);
		}
		pstrSource = _tcsinc(pstrSource);
	}
	*pstrDest = '\0';
	int nCount = pstrSource - pstrDest;
	GetData()->nDataLength -= nCount;

	return nCount;
}
FC_TOAPI const TCHAR* FC_TODECL FC_StringGetFilePart(
    const TCHAR* pszPath 
)
{
    const TCHAR* p     = pszPath;
    const TCHAR* pLast = NULL;

    while(*p)
    {
        if(*p==_T('\\') || *p==_T('/'))
            pLast = p;
        p = _tcsinc(p);
    }
    return pLast?++pLast:pszPath;
}
예제 #23
0
char* trimleft( char* string )
{
	char* lpsz = string;

	while (_istspace(*lpsz))
		lpsz = _tcsinc(lpsz);

	if (lpsz != string)
	{
		// fix up data and length
		int nDataLength = strlen(string) - (lpsz - string);
		memmove(string, lpsz, (nDataLength+1)*sizeof(TCHAR));
	}
	return string;
}
예제 #24
0
static void ReadNumberPerSegment(CGT_CDiagMsg*      pdm, 
                                 LPCTSTR            pszKADFileAndPath,
                                 IXMLDOMNode*       pNode,
                                 const TCHAR*       pszAttrName,
                                 const TCHAR*       pszNumPerSegments,
                                 long*              plMaxRegions)
{
    LPCTSTR    pszInput  = pszNumPerSegments;
    LPCTSTR    pszNum    = NULL;
    bool       bNumValid = true;
    FC_CString sNum;
    FC_CString sSegm;

    while(pszNumPerSegments && *pszNumPerSegments != 0)
    {
        sSegm.clear();
        sSegm.appendUpTo(pszNumPerSegments, _T(":"), &pszNumPerSegments);
        sSegm.trim();
        if (*(pszNumPerSegments+1) == 0)
            goto Error;

        sNum.clear();
        sNum.appendUpTo(pszNumPerSegments+1, _T(","), &pszNumPerSegments);
        sNum.trim();

        // evaluate segment and number
        VM_SEGM_TYP segm = VM_SegmentKeywordToSegmentEnum(sSegm);
        if (segm == VM_SEGM_UNDEF)
            goto Error;

        for (pszNum = sNum; *pszNum; pszNum++)
            if ( ! _istdigit(*pszNum))
                goto Error;

        plMaxRegions[segm] = strtol(sNum, NULL, 10);

        if (*pszNumPerSegments != 0)
            pszNumPerSegments = _tcsinc(pszNumPerSegments);
    }

    return;

Error:
    CGT_XMLDiagAttrValue(pdm,pNode,pszAttrName,pszInput,NULL);
    return;
}
예제 #25
0
static _TCHAR *GetLastBufferChar( _TCHAR *buffer, size_t count )
{
	_TCHAR	*last = NULL;
	_TCHAR	*cur = buffer;

	while ( (size_t)(cur - buffer) < count )
	{
		last = cur;

		if ( !*last )
			break;

		cur = _tcsinc(last);
	}

	return last;
}
예제 #26
0
FC_TOAPI int FC_TODECL FC_StringMatchFilePattern(
    const TCHAR*  pszToken, 
    const TCHAR*  pszPattern 
)
{
    const TCHAR* pszT = pszToken;
    const TCHAR* pszT2;
    const TCHAR* pszP = pszPattern;

    while(*pszT && *pszP)
    {
        if(*pszP==_T('?'))
        {
            pszP = _tcsinc(pszP);
            pszT = _tcsinc(pszT);
            continue;
        }
        else if(*pszP==_T('*'))
        {
            // SIS, 16.03.01: if pattern is "*" return true
            if(_tcslen(pszP) == 1)
            {
                return 1;
            }
            //text=xyzuvw
            //patt=*uvw
            pszP = _tcsinc(pszP);
            for(pszT2=pszT;*pszT2;pszT2=_tcsinc(pszT2))
            {
                if(FC_StringMatchFilePattern(pszT2, pszP))
                    return 1; 
            }
            return 0;
        }

        if(tolower(*pszT)==tolower(*pszP))
        {
            pszP = _tcsinc(pszP);
            pszT = _tcsinc(pszT);
        }   
        else
        {
            break;
        }
    }
    // SIS, 16.03.01: if pattern only contains "*" return true
    if(_tcscmp(pszP, _T("*")) == 0)
    {
        return 1;
    }
    return !*pszT && !*pszP;
}
예제 #27
0
inline int GetFormatLength(LPCTSTR apszFormat, va_list argList)
{

	int nMaxLen = 0;
	for (LPCTSTR lpsz = apszFormat; *lpsz != '\0'; lpsz = _tcsinc(lpsz))
	{
		// handle '%' character, but watch out for '%%'
		if (*lpsz != '%' || *(lpsz = _tcsinc(lpsz)) == '%')
		{
			nMaxLen += _tclen(lpsz);
			continue;
		}

		int nItemLen = 0;

		// handle '%' character with format
		int nWidth = 0;
		for (; *lpsz != '\0'; lpsz = _tcsinc(lpsz))
		{
			// check for valid flags
			if (*lpsz == '#')
				nMaxLen += 2;   // for '0x'
			else if (*lpsz == '*')
				nWidth = va_arg(argList, int);
			else if (*lpsz == '-' || *lpsz == '+' || *lpsz == '0' ||
				*lpsz == ' ')
				;
			else // hit non-flag character
				break;
		}
		// get width and skip it
		if (nWidth == 0)
		{
			// width indicated by
			nWidth = _ttoi(lpsz);
			for (; *lpsz != '\0' && _istdigit(*lpsz); lpsz = _tcsinc(lpsz))
				;
		}
		ASSERT(nWidth >= 0);

		int nPrecision = 0;
		if (*lpsz == '.')
		{
			// skip past '.' separator (width.precision)
			lpsz = _tcsinc(lpsz);

			// get precision and skip it
			if (*lpsz == '*')
			{
				nPrecision = va_arg(argList, int);
				lpsz = _tcsinc(lpsz);
			}
예제 #28
0
파일: action.cpp 프로젝트: ArildF/masters
BOOL
defineMacro(
    char *s,                        // commandline or env definitions
    char *t,
    UCHAR flags
    )
{
    char *u;

    for (u = s; *u && MACRO_CHAR(*u); u = _tcsinc(u))  // check for illegal
        ;
    if (*u) {
        if (ON(flags, M_ENVIRONMENT_DEF)) { // ignore bad macros
            return(FALSE);
        }
        makeError(currentLine, SYNTAX_BAD_CHAR, *u);    // chars,  bad syntax
    }
    return(putMacro(s, t, flags));          // put macro in table
}
예제 #29
0
void CCOMString::TrimRight()
{
	LPTSTR lpsz = m_pszString;
	LPTSTR lpszLast = NULL;

	while (*lpsz != '\0')
	{
		if (_istspace(*lpsz))
		{
			if (lpszLast == NULL)
				lpszLast = lpsz;
		}
		else
			lpszLast = NULL;
		lpsz = _tcsinc(lpsz);
	}

	if (lpszLast != NULL)
		*lpszLast = '\0';
}
FC_TOAPI int FC_TODECL FC_StringCutFilePart(
    TCHAR* pszPath 
)
{
    TCHAR* p     = pszPath;
    TCHAR* pLast = NULL;

    while(*p)
    {
        if(*p==_T('\\') || *p==_T('/'))
            pLast = p;
        p = _tcsinc(p);
    }
    if(pLast)
    {
        *pLast = 0;
        return (pLast - pszPath);
    }
    return (p-pszPath);
}