Ejemplo n.º 1
0
BOOL NMEAParser::NMEAChecksum(const TCHAR *String)
{
  if (!CheckSum) return TRUE;
  unsigned char CalcCheckSum = 0;
  unsigned char ReadCheckSum;
  int End;
  int i;
  TCHAR c1,c2;
  unsigned char v1 = 0,v2 = 0;
  TCHAR *pEnd;

  pEnd = _tcschr(String,_T('*'));
  if(pEnd == NULL)
    return FALSE;

  // Fix problem of EW micrologger missing a digit in checksum
  // now we have *XY 
  // line is terminating with 0a (\n) so count is 4 not 3!
  if(_tcslen(pEnd)<4) {
	// no checksum, only a * ?
	if (_tcslen(pEnd)==1) {
		return FALSE;
	}
	// try to recover the missing digit
	c1 = _T('0');
	c2 = pEnd[1];
  } else {
	c1 = pEnd[1], c2 = pEnd[2];
  }

  //  iswdigit('0'); // what's this for?

  if(_istdigit(c1))
    v1 = (unsigned char)(c1 - '0');
  if(_istdigit(c2))
    v2 = (unsigned char)(c2 - '0');
  if(_istalpha(c1))
    v1 = (unsigned char)(c1 - 'A' + 10);
  if(_istalpha(c2))
    v2 = (unsigned char)(c2 - 'A' + 10);

  ReadCheckSum = (unsigned char)((v1<<4) + v2);          

  End =(int)( pEnd - String);

  for(i=1;i<End;i++)
    {
      CalcCheckSum = (unsigned char)(CalcCheckSum ^ String[i]);
    }

  if(CalcCheckSum == ReadCheckSum)
    return TRUE;
  else
    return FALSE;
}
Ejemplo n.º 2
0
void CuParseEditCtrl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	WORD type;

	if (nChar < 0x20)
		type = PES_ALL;                         // always allow control chars
	else if (_istalnum(nChar) && !_istalpha(nChar))
		type = PES_NATURAL;
	else if (_istalpha(nChar))
		type = PES_LETTERS;
	else
	{
		CString strText;
		GetWindowText (strText);
		int nLen = strText.GetLength ();
		if ((TCHAR)nChar == _T('-') && (m_wParseStyle & PES_INTEGER) && nLen == 0)
			type = PES_INTEGER;
		else
		if ((TCHAR)nChar == _T('-') && (m_wParseStyle & PES_INTEGER) && nLen > 0)
		{
			int nStartChar, nEndChar;
			GetSel(nStartChar, nEndChar);
			if (nStartChar == 0 && nEndChar == 0 && strText.Find (_T('-'))== -1)
				type = PES_INTEGER;
			else
			if (nStartChar == 0 && nEndChar > 0)
			{
				//
				// If partial or all text is selected from the starting position
				// then allow typing the minus sign ('-') even if it has already
				// been in the edit.
				type = PES_INTEGER;
			}
			else
				type = PES_OTHERCHARS;
		}
		else
			type = PES_OTHERCHARS;
	}

	if (m_wParseStyle & type)
	{
		CEdit::OnChar(nChar, nRepCnt, nFlags);  // permitted
	}
	else
	{
		//
		// Illegal character - inform parent
		OnBadInput();
	}
}
Ejemplo n.º 3
0
//MAD: alternative sorting by Nullbie
static int sttCompareNicknames(const TCHAR *s1, const TCHAR *s2)
{
	// skip rubbish
	while (*s1 && !_istalpha(*s1)) ++s1;
	while (*s2 && !_istalpha(*s2)) ++s2;

	// are there ~0veRy^kEwL_n1kz?
	if (!*s1 && !*s2) return 0;
	if (!*s1 && *s2) return +1;
	if (*s1 && !*s2) return -1;

	// compare tails
	return lstrcmpi(s1, s2);
}
Ejemplo n.º 4
0
/**
 * @brief Build-in ROT-13 encoder.
 * @param [in, out] p Data (and parameters) to encode.
 */
void WINAPI Rot13Encoder(LPMEMORY_CODING p)
{
	LPBYTE q = p->lpbMemory;
	LPBYTE qMax = q + p->dwSize;
	while (q < qMax)
		*(q++) = _istalpha(*q) ? (BYTE)(tolower(*q) < 'n' ? * q + 13 : *q - 13) : *q;
}
Ejemplo n.º 5
0
static void OpenURLThread(void *arg)
{
	TOpenUrlInfo *hUrlInfo = (TOpenUrlInfo*)arg;

	// wack a protocol on it
	CMString tszUrl;
	if ((isalpha(hUrlInfo->szUrl[0]) && hUrlInfo->szUrl[1] == ':') || hUrlInfo->szUrl[0] == '\\')
		tszUrl.Format(_T("file:///%s"), hUrlInfo->szUrl);
	else {
		int i;
		for (i = 0; _istalpha(hUrlInfo->szUrl[i]); i++);
		if (hUrlInfo->szUrl[i] == ':')
			tszUrl = hUrlInfo->szUrl;
		else if (!_tcsnicmp(hUrlInfo->szUrl, _T("ftp."), 4))
			tszUrl.Format(_T("ftp://%s"), hUrlInfo->szUrl);
		else
			tszUrl.Format(_T("http://%s"), hUrlInfo->szUrl);
	}

	// check user defined browser for opening urls
	ptrT tszBrowser(db_get_tsa(NULL, "Miranda", "OpenUrlBrowser"));
	if (tszBrowser)
		ShellExecute(NULL, _T("open"), tszBrowser, tszUrl, NULL, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT);
	else
		ShellExecute(NULL, _T("open"), tszUrl, NULL, NULL, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT);

	delete hUrlInfo;
}
Ejemplo n.º 6
0
void ToggleCase (CString& str)
{
	if (str.GetLength () == 0)
		return;

	MakeUpper (str);	
	bool bNewWord = true;

	int last = str.GetLength ();

	/*int ext_pos = str.ReverseFind ('.');

	if (ext_pos != -1)
		last = ext_pos;*/

	for (int i = 0; i < last; i++)	
	{
		if (_istalpha (str[i]))
		{
			if (bNewWord)
			{
				bNewWord = false;
				str.SetAt (i, _tolower (str[i]));
			}
		}
		else
			bNewWord = true;
	}
}
Ejemplo n.º 7
0
// symbol test
static bool isSymbolChar(_TCHAR i_c)
{
	if (i_c == _T('\0'))
		return false;
	if (_istlead(i_c) ||
		_istalpha(i_c) ||
		_istdigit(i_c) ||
		_istlead(i_c))
		return true;

#ifdef UNICODE
	if (0x80 <= i_c && _istgraph(i_c))
		return true;
#endif // UNICODE

	if (_istpunct(i_c))
		return !!_tcschr(_T("-+/?_\\"), i_c);

#ifdef UNICODE
	// check arrows
	if (_tcschr(_T("\x2190\x2191\x2192\x2193"), i_c)) {
		return true;
	}
#endif // UNICODE
	return _istgraph(i_c);
}
Ejemplo n.º 8
0
bool CProperties::CreatePathToFile(LPCTSTR pszDir) 
{
  // Create intermediate directories
#ifdef _WIN32
  const TCHAR cSep='\\';
#else // UNIX
  const TCHAR cSep='/';
#endif
  for(LPCTSTR c=_tcschr(pszDir,cSep);c;c=_tcschr(c+1,cSep)){
#ifdef _WIN32
    if(c==pszDir+2 && _istalpha(pszDir[0]) && _TCHAR(':')==pszDir[1]){
      continue; // don't attempt to create "C:"
    }
#endif
    String strDir(pszDir,c-pszDir);
    struct _stat buf;
    if(!(0==_tstat(strDir,&buf) && (S_IFDIR&buf.st_mode))){
      // Need to create directory
      bool b=(0==_tmkdir(strDir));
      TRACE(_T("Create directory %s rc=%d\n"),(LPCTSTR)strDir,b);
      if(!b){
        return false;
      }
    }
  }
  return true;
}
Ejemplo n.º 9
0
BOOL CMaskData::IsValidInput(TCHAR chNewChar)
{
	BOOL bIsValidInput=FALSE;
	switch(m_eType)
	{
	// These are the input types. 
	case MaskDataTypeDIGIT             :
		bIsValidInput=_istdigit(chNewChar);
		break;
	case MaskDataTypeALPHANUMERIC      :
		bIsValidInput=_istalnum(chNewChar);
		break;
	case MaskDataTypeALPHABETIC        :
	case MaskDataTypeALPHAETICUPPER    :
	case MaskDataTypeALPHAETICLOWER    :
		bIsValidInput=_istalpha(chNewChar);
		break;
	case MaskDataTypeCHARACTER         :
		if((chNewChar >=  32) && (chNewChar <= 126))
			bIsValidInput=TRUE ;
		if((chNewChar >= 128) && (chNewChar <= 255))
			bIsValidInput=TRUE ;
		break;
	}
	return bIsValidInput;
}
Ejemplo n.º 10
0
CServerPath::CServerPath(CString path)
{
	m_nServerType = FZ_SERVERTYPE_FTP;
	path.TrimLeft( _T(" ") );
	path.TrimRight( _T(" ") );
	if (path == _MPT(""))
	{
		m_bEmpty = TRUE;
		return;
	}
	else
		m_bEmpty = FALSE;

	int pos1 = path.Find( _T(":[") );
	if (pos1 != -1 && path.Right(1) == _MPT("]") && pos1 != (path.GetLength()-1))
		m_nServerType |= FZ_SERVERTYPE_SUB_FTP_VMS;
	else if (path.GetLength() >= 3 && _istalpha(path[0]) && path[1] == _MPT(':') && (path[2] == _MPT('\\') || path[2] == _MPT('/')))
		m_nServerType |= FZ_SERVERTYPE_SUB_FTP_WINDOWS;
	else if (path[0] == FTP_MVS_DOUBLE_QUOTA && path[path.GetLength() - 1] == FTP_MVS_DOUBLE_QUOTA)
		m_nServerType |= FZ_SERVERTYPE_SUB_FTP_MVS;
	else if (path.GetLength() > 2 && path[0] == _MPT('\'') && path.Right(1) == _T("'") && path.Find(_MPT('/')) == -1 && path.Find(_MPT('\\')) == -1)
		m_nServerType |= FZ_SERVERTYPE_SUB_FTP_MVS;
	else if (path.GetLength() >= 2 && path[0] != _MPT('/') && path.Right(1) == _T("."))
		m_nServerType |= FZ_SERVERTYPE_SUB_FTP_UNKNOWN;

	*this = CServerPath(path, m_nServerType);
}
Ejemplo n.º 11
0
// 取得命令名
static int getCmd(const MyString& cmd, int pos, MyString* name)
{
    int i = pos;
    while (i < cmd.size() && !_istgraph(cmd[i]))
        ++i;

    int j = i;
    while (j < cmd.size() && _istalpha(cmd[j]))
        ++j;
    // 仅在识别出类似绝对路径时进行回溯
    if ((i + 1) < cmd.size() && _istalpha(cmd[i]) && cmd[i + 1] == _T(':'))
        return i;

    *name = cmd.substr(i, j - i);
    return j;
}
Ejemplo n.º 12
0
static void _split_arg(const char_t *pbeg, const char_t *pend, std::vector<_ArgItem> &vArg, bool bAddHead)
{
	const char_t *px=pbeg,*pbx=NULL;
	int nhead=0; //number of anonymous varibles, which must be placed at the start of command-line
	int ni=0;    //number of named varibles, which can be placed anywhere after anonymous varibles
	int nq=0;   //number of quotes

	while(px<pend)
	{	
		if(
			(*px==_TX('-')&&px+1!=pend&&_istalpha((ushort)px[1])||*px==_TX('/'))&&(px==pbeg||_istspace((ushort)px[-1]))
			)
		{//the beginning of a named varible, either the following two cases:
		 // 1) '-' followed by alphabetic letters ('-' followed by number may be an negative number)
		 // 2) '/' followed by any character

			if((nq&1)==0) //if not in double quotes
			{
				if(pbx)
				{//save the value of previous varible
					vArg.back().m_value.append(pbx,px);
				}
				pbx=_skip_non_space(px,pend); //the end of the varible name
				
				vArg.push_back(_ArgItem());
				vArg.back().m_name=string_t(px+1,pbx);
				px=pbx;
				++ni; 
			}
		}
		else
			if(ni==0&&bAddHead&&!_istspace((ushort)*px))
			{//the beginning of an anonymous varible
				const char_t *px0=px;
				px=_skip_non_str_non_space(px,pend);

				char_t buf[16];
				_stprintf(buf,_TX("#%d"),nhead); //make an name for the varible

				vArg.push_back(_ArgItem());
				vArg.back().m_name=buf;
				vArg.back().m_value=string_t(px0,px);
				++nhead;
			}
			else
			{
				if(*px==_TX('\"')&&(px==pbeg||px[-1]!=_CH_CVT))
				{
					++nq;
				}
			}
		++px;
	}
	
	if(pbx&&ni>0)
	{//save the value of the last varible
		vArg.back().m_value.append(pbx,pend);
	}
}
Ejemplo n.º 13
0
bool _is_meaningless_char(TCHAR ax){
	if(_istdigit(ax) || _istalpha(ax)){
		return false;
	}
	if(ax >= 0x0080){
		return false;
	}
	return true;
}
Ejemplo n.º 14
0
bool GermanStemmer::isStemmable(const TCHAR* term, size_t length) const {
    if (length < 0) {
        length = _tcslen(term);
    }
    for (size_t c = 0; c < length; c++) {
        if (_istalpha(term[c]) == 0)
            return false;
    }
    return true;
}
Ejemplo n.º 15
0
bool CFileName::IsAbsolute() const
{
  int nLength=GetLength();
  LPCTSTR psz=*this;
  return 
    (nLength>0 && (cSep==psz[0]))|| // starts with '\'
    (nLength>1 && (
    (_istalpha(psz[0]) && _TCHAR(':')==psz[1]) ||  // starts with [e.g.] "c:\"
    (cSep==psz[0] && cSep==psz[1])));              // UNC
}
Ejemplo n.º 16
0
static int getSwitch(const MyString& cmd, int pos, MyString* s)
{
    int i = pos;
    while (i < cmd.size() && !_istgraph(cmd[i]))
        ++i;
    // 仅有首个字符为"\"
    int j = i + 1;
    while (j < cmd.size() && _istalpha(cmd[j]))
        ++j;
    *s = cmd.substr(i, j - i);
    return j;
}
Ejemplo n.º 17
0
Archivo: path.cpp Proyecto: unoyx/vfs
// C:\
// \name
bool isAbs(MyString path)
{
    /*文件名需要忽略大小写 */
    if (path.startWith(_T("\\")))
    {
        return true;
    }
    else if (match(path, _T("?:*")) && _istalpha(path[0]))
    {
        return true;
    }
    return false;
}
Ejemplo n.º 18
0
BOOL SMaskEdit::IsAlphaChar(TCHAR nChar)
{
    if (_istalpha(nChar))
        return TRUE;

    if (ConvertUnicodeAlpha(nChar, TRUE) != nChar)
        return TRUE;

    if (ConvertUnicodeAlpha(nChar, FALSE) != nChar)
        return TRUE;

    return FALSE;
}
Ejemplo n.º 19
0
static int __inline IsBefore(char *p1 ,char *p2)
{
  char *p;
  if (!p1 || !p2)
    return 0;
  for (p=p1; *p ; CMnext(p))
    {
    if (_istalpha (*p))
      {
      p1=p;
      break;
      }
    }
  for (p=p2; *p ; CMnext(p))
    {
    if (_istalpha (*p))
      {
      p2=p;
      break;
      }
    }
  return (_tcsicmp (p1,p2)<0);
}
Ejemplo n.º 20
0
static void
propident(char *buffer, int size)
{
  if (lookahead == -1 || !_istupper(lookahead)) 
    parse_error("Expected an upper case letter", 0);
  while (lookahead != -1 && _istalpha(lookahead)) {
    if (_istupper(lookahead) && size > 1) {
      *buffer++ = lookahead;
      size--;
    }
    nexttoken();
  }
  *buffer = '\0';
}
Ejemplo n.º 21
0
// Helper for Relative()  psz is in full format.
CFileName CFileName::Drive(LPCTSTR psz)
{
  if(_istalpha(psz[0])){
    return psz[0];
  } else if(cSep==psz[0]&&cSep==psz[1]){
    TCHAR *c=_tcschr(psz+2,cSep);
    if(c){
      c=_tcschr(c+1,cSep);
      if(c){
        return CString(psz,c-psz);
      }
    }
  }
  return _T("");
}
Ejemplo n.º 22
0
/**
 * Function name    IsIdentifier
 * Description      checks whether String is an st identifier
 * @param           CString String
 * @return          BOOL
 * @exception       -
 * @see             -
*/
BOOL IsIdentifier(CString String)
{
    if (String.IsEmpty())                       // 1
    {
        return FALSE;
    }

	if (IsKeyword(String))
	{
		return FALSE;
	}

    if (String.Find(_T("__")) != -1)            // 2
    {
        // "__" is not allowed within an identifier. 
        return FALSE;
    }

    int StringLength = String.GetLength();

	ASSERT(StringLength > 0);                   // owing to 1

    const int StartIndex = 0;
    _TCHAR c = String.GetAt(StartIndex);
    
    if (!_istalpha(c) &&
        !((c == _T('_')) && (StringLength > 1)))
    {
        // First char is not a-z or A-Z and
        // first char is not    '_'-and-followed-by-an-other-char.
        // ('_' is no valid identifier.
        // String.GetAt(StartIndex + 1) does not equal '_' due to 2.)
        return FALSE;                           
    }

    for (int i = StartIndex + 1; i < StringLength; i++)
    {
        c = String.GetAt(i);
        if ((!_istalnum(c)) && (c != _T('_')))
        {
            // String contains a char which is not a-z, A-Z, 0-9, or '_',                               
            return FALSE;                       
        }
    }

	return TRUE;
}
Ejemplo n.º 23
0
bool CFileName::CreateDirectory(bool bParentsToo,bool bFailIfAlreadyExists) const
{
  LPCTSTR pszDir=m_pchData;
  if(bParentsToo){
    // Create intermediate directories
    for(LPCTSTR c=_tcschr(pszDir,_TCHAR('\\'));c;c=_tcschr(c+1,_TCHAR('\\'))){
      if(c==pszDir+2 && _istalpha(pszDir[0]) && _TCHAR(':')==pszDir[1]){
        continue; // don't attempt to create "C:"
      }
      const CFileName strDir(pszDir,c-pszDir);
      if(!(strDir.IsDir()? (!bFailIfAlreadyExists) : ::CreateDirectory(strDir,NULL))){
        return false;
      }
    }
  }
  return IsDir()? (!bFailIfAlreadyExists) : (TRUE==::CreateDirectory(pszDir,NULL));
}
Ejemplo n.º 24
0
void CSymbolEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
  //Allowed inputs are passed on to the base class
  if (nChar == VK_BACK) {
    CEdit::OnChar(nChar, nRepCnt, nFlags);
    return;
  }

  wint_t wChar = reinterpret_cast<wint_t &>(nChar);
  // Must not be alphanumeric nor have and Alt/Ctrl key
  if ((_istalpha(wChar) == 0 && _istdigit(wChar) == 0 && (nFlags & 0xE0800000) == 0)) {
    CString cs_text;
    GetWindowText(cs_text);
    // Must not have duplicates
    if (cs_text.Find(wChar) == -1)
      CEdit::OnChar(nChar, 0, nFlags);
  }
}
Ejemplo n.º 25
0
void CSetPageBase::SetTidyControl(LPCTSTR lpszTidy, int nPos, int nSize)
{
	if (lpszTidy[nPos] != '-' || nSize < 2)
	{
		return;
	}

	CString strTextParam(lpszTidy + nPos + 1, nSize - 1);
	int nPosFlag = strTextParam.Find(STR_SHORT_TEXT_FALG);
	if (nPosFlag > 0)
	{
		CString strBstrValue(strTextParam.Mid(nPosFlag + 1));
		strTextParam = strTextParam.Left(nPosFlag);
		SetTidyProp(strTextParam, (LPCTSTR)strBstrValue);
	}
	else
	{
		int nNumValue = nSize;
		for (int i = nPos + 1; i < nPos + nSize; ++i)
		{
			if (!_istalpha(lpszTidy[i]))
			{
				nNumValue = i - nPos;
				break;
			}
		}
		CString strParam(lpszTidy + nPos + 1, nNumValue - 1);
		if (nNumValue != nSize)
		{
			CString strNum(lpszTidy + nPos + nNumValue, nSize - nNumValue);
			nNumValue = _ttoi(strNum);
		}
		else
		{
			nNumValue = INT_MIN;
		}

		if (!SetTidyProp(strParam, nNumValue))
		{
			strParam.AppendFormat(_T("%d"), nNumValue);
			SetTidyProp(strParam, nNumValue);
		}
	}
}
Ejemplo n.º 26
0
static int
ParseFlags(const TCHAR *input, const TCHAR **endptr_r)
{
  int Flags = 0;

  while (_istalpha(*input)) {
    switch (*input++) {
    case 'A':
      Flags |= AIRPORT;
      break;

    case 'T':
      Flags |= TURNPOINT;
      break;

    case 'L':
      Flags |= LANDPOINT;
      break;

    case 'H':
      Flags |= HOME;
      break;

    case 'S':
      Flags |= START;
      break;

    case 'F':
      Flags |= FINISH;
      break;

    case 'R':
      Flags |= RESTRICTED;
      break;

    case 'W':
      Flags |= WAYPOINTFLAG;
      break;
    }
  }

  *endptr_r = input;
  return Flags;
}
Ejemplo n.º 27
0
/**
 Extracts a description string from a \ProvidesXXX command. Works similar as ExtractOptionCount
 */
int CStyleFile::ExtractDescription(const TCHAR *closePar, const TCHAR *openBr, const TCHAR *closeBr, CString &desc)
{
	if (closePar == NULL || openBr == NULL || closeBr == NULL)
	{
		desc.Empty();
		return -2; /* No desc available */
	}

	int d = closeBr - openBr - 1;
	if (d <= 0)
	{
		desc.Empty();
		return -4;
	}

	if (d >= MAX_DESC_LEN)
	{
		d = MAX_DESC_LEN - 1;
	}
	TCHAR *p = (TCHAR*)closePar;

	++p;
	while (p < openBr)
	{
		if (_istdigit(*p) || _istalpha(*p))
		{
			desc.Empty();
			return -3;
		}
		++p;
	}

	TCHAR buf[MAX_DESC_LEN];
	_tcsncpy(buf, openBr + 1, d);
	buf[d] = 0;
	desc = buf;

	return 0;
}
Ejemplo n.º 28
0
const CFileName CFileName::CygPath () const 
{
  TCHAR buf[2+MAX_PATH];
  LPCTSTR rc=buf+1;
  if(!GetShortPathName(m_pchData,1+buf,MAX_PATH)){
    _tcscpy(1+buf,m_pchData);
  }
  if(_istalpha(*rc)&&_TCHAR(':')==rc[1]){
    // Convert c:\ to //c/ [this is the bit that requires the first char of buf]
    buf[0]=_TCHAR('/');
    buf[2]=buf[1];
    buf[1]=_TCHAR('/');
    rc=buf;
  }
  for(TCHAR *c=buf+1;*c;c++){
    if(_TCHAR('\\')==*c){
      *c=_TCHAR('/');
    }
  }
  
  return rc;
}
Ejemplo n.º 29
0
LRESULT CSymbolEdit::OnPaste(WPARAM , LPARAM )
{
  // Only allow symbols to be pasted and stop duplicates
  if (!OpenClipboard() || !IsClipboardFormatAvailable(CF_UNICODETEXT))
    return 0L; 
 
  std::wstring cs_data;
	HANDLE hData = GetClipboardData(CF_UNICODETEXT);
  if (hData != NULL) {
    wchar_t *buffer = (wchar_t *)GlobalLock(hData);
    if (buffer != NULL) {
      cs_data = buffer;
      GlobalUnlock(hData);
    }
  }
	CloseClipboard();

  CString cs_text, cs_oldtext;;
  GetWindowText(cs_text);
  cs_oldtext = cs_text;

  // Must not be alphanumeric
  for (size_t i = 0; i < cs_data.length(); i++) {
    wchar_t wChar = cs_data.at(i);
    if ((_istalpha(wChar) == 0 && _istdigit(wChar) == 0)) {
      // Must not have duplicates
      if (cs_text.Find(wChar) == -1)
        cs_text += wChar;
    }
  }

  if (cs_text.Compare(cs_oldtext) != 0)
    SetWindowText(cs_text);

  return 0L;
}
Ejemplo n.º 30
0
/**
 Retrieves the number of options of a command or environment. Does not work for commands
 defined via _T('\def') (TeX-Style).
 */
int CStyleFile::ExtractOptionCount(const TCHAR *closePar, const TCHAR *openBr, const TCHAR *closeBr)
{
	if (closePar == NULL || openBr == NULL || closeBr == NULL) return -2; /* No option avalable */

	int d = closeBr - openBr;
	if (d < 0 || d > 2) return -1;
	TCHAR *p = (TCHAR*)closePar;
	TCHAR buf[10];

	++p;
	while (p < openBr)
	{
		if (_istdigit(*p) || _istalpha(*p))
		{
			return -3;
		}
		++p;
	}

	_tcsncpy(buf, openBr + 1, d);
	buf[d] = 0;

	return _ttoi(buf);
}