Changeset 115 for trunk


Ignore:
Timestamp:
Sep 5, 2012, 3:23:55 PM (12 years ago)
Author:
roman
Message:
  • more patterns: 8000401a, '8000401a'
  • fixed lost minus prefix
Location:
trunk/Utilities/ShowHresult
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/ShowHresult/NotifyIconWindow.h

    r108 r115  
    385385                }
    386386        }
     387        static BOOL IsDecimal(TCHAR nCharacter) throw()
     388        {
     389                return _tcschr(_T("0123456789"), nCharacter) != NULL;
     390        }
     391        static BOOL IsDecimal(const TCHAR* pszCharacters, SIZE_T nCount) throw()
     392        {
     393                for(SIZE_T nIndex = 0; nIndex < nCount; nIndex++)
     394                        if(!IsDecimal(pszCharacters[nIndex]))
     395                                return FALSE;
     396                return TRUE;
     397        }
     398        static BOOL IsDecimal(const TCHAR* pszCharacters) throw()
     399        {
     400                return IsDecimal(pszCharacters, _tcslen(pszCharacters));
     401        }
     402        static BOOL IsHexadecimal(TCHAR nCharacter) throw()
     403        {
     404                return _tcschr(_T("0123456789ABCDEFabcdef"), nCharacter) != NULL;
     405        }
     406        static BOOL IsHexadecimal(const TCHAR* pszCharacters, SIZE_T nCount) throw()
     407        {
     408                for(SIZE_T nIndex = 0; nIndex < nCount; nIndex++)
     409                        if(!IsHexadecimal(pszCharacters[nIndex]))
     410                                return FALSE;
     411                return TRUE;
     412        }
     413        static BOOL IsHexadecimal(const TCHAR* pszCharacters) throw()
     414        {
     415                return IsHexadecimal(pszCharacters, _tcslen(pszCharacters));
     416        }
    387417        BOOL Process(LPCTSTR pszText)
    388418        {
     
    392422                CString sText = pszText;
    393423                sText.Trim();
     424                #pragma region Delete Trailing L (as in 0x00000000L)
    394425                if(!sText.IsEmpty() && _tcschr(_T("Ll"), sText[sText.GetLength() - 1]))
    395426                        sText.Delete(sText.GetLength() - 1);
     427                #pragma endregion
     428                #pragma region Unquote Single Quote
     429                if(sText.GetLength() > 2 && sText[0] == _T('\'') && sText[sText.GetLength() - 1] == _T('\''))
     430                {
     431                        sText = sText.Mid(1, sText.GetLength() - 2);
     432                        sText.Trim();
     433                }
     434                #pragma endregion
    396435                if(sText.IsEmpty())
    397436                        return FALSE;
    398437                LONGLONG nLongLongResult;
     438                #pragma region Hexadecimal
    399439                if(_tcsnicmp(sText, _T("0x"), 2) == 0)
    400440                {
    401                         SIZE_T nIndex = 2;
    402                         for(; nIndex < (SIZE_T) sText.GetLength(); nIndex++)
    403                                 if(!_tcschr(_T("0123456789ABCDEFabcdef"), sText[nIndex]))
    404                                         return FALSE;
     441                        if(!IsHexadecimal((LPCTSTR) sText + 2))
     442                                return FALSE;
    405443                        if(!StrToInt64Ex(sText, STIF_SUPPORT_HEX, &nLongLongResult))
    406444                                return FALSE;
    407445                } else
     446                #pragma endregion
     447                #pragma region Integer
    408448                {
    409449                        SIZE_T nIndex = 0;
    410450                        if(sText[0] == _T('-'))
    411451                                nIndex++;
    412                         for(; nIndex < (SIZE_T) sText.GetLength(); nIndex++)
    413                                 if(!_tcschr(_T("0123456789"), sText[nIndex]))
     452                        if(!IsDecimal((LPCTSTR) sText + nIndex))
     453                        {
     454                                #pragma region Eight Characater Long Hexadecimal without Prefix
     455                                if(sText.GetLength() == nIndex + 8 && IsHexadecimal((LPCTSTR) sText + nIndex))
     456                                {
     457                                        sText.Insert(0, _T("0x"));
     458                                        if(!StrToInt64Ex(sText, STIF_SUPPORT_HEX, &nLongLongResult))
     459                                                return FALSE;
     460                                } else
     461                                #pragma endregion
    414462                                        return FALSE;
    415                         nLongLongResult = _ttoi64(sText);
     463                        } else
     464                                nLongLongResult = _ttoi64(sText);
     465                        if(nIndex)
     466                                nLongLongResult = -nLongLongResult;
    416467                }
     468                #pragma endregion
    417469                const LONG nHighLongLongResult = (LONG) (nLongLongResult >> 32);
    418470                if(!nLongLongResult || nHighLongLongResult > 0 || nHighLongLongResult < -1)
  • trunk/Utilities/ShowHresult/ShowHresult_i.c

    r108 r115  
    77
    88 /* File created by MIDL compiler version 7.00.0555 */
    9 /* at Thu Aug 30 16:44:55 2012
     9/* at Thu Sep 06 01:20:21 2012
    1010 */
    1111/* Compiler settings for ShowHresult.idl:
  • trunk/Utilities/ShowHresult/ShowHresult_i.h

    r108 r115  
    55
    66 /* File created by MIDL compiler version 7.00.0555 */
    7 /* at Thu Aug 30 16:44:55 2012
     7/* at Thu Sep 06 01:20:21 2012
    88 */
    99/* Compiler settings for ShowHresult.idl:
Note: See TracChangeset for help on using the changeset viewer.