From b72a9517dc589ec351dbfd5229e1e8b42d68ef7b Mon Sep 17 00:00:00 2001 From: Marcel Gosselin Date: Sat, 6 Sep 2008 02:48:07 +0000 Subject: [PATCH] Remove dead code --- Src/Common/coretools.cpp | 405 ----------------------------------------------- Src/Common/coretools.h | 8 - 2 files changed, 413 deletions(-) diff --git a/Src/Common/coretools.cpp b/Src/Common/coretools.cpp index fae47a6c3..585c7e2f0 100644 --- a/Src/Common/coretools.cpp +++ b/Src/Common/coretools.cpp @@ -113,35 +113,6 @@ void GetLocalDrives(LPTSTR letters) } } -/* - Commented out - can't use this file by just including - coretools.h because of gethostaname() & gethostbyname(). - -BOOL GetIP(LPTSTR straddr) -{ - char szHostname[100]; - HOSTENT *pHent; - SOCKADDR_IN sinRemote; - - gethostname( szHostname, sizeof( szHostname )); - pHent = gethostbyname( szHostname ); - - if (pHent != NULL) - { - sinRemote.sin_addr.s_addr = *(u_long *)pHent->h_addr; - _stprintf(straddr,_T("%d.%d.%d.%d"), - sinRemote.sin_addr.S_un.S_un_b.s_b1, - sinRemote.sin_addr.S_un.S_un_b.s_b2, - sinRemote.sin_addr.S_un.S_un_b.s_b3, - sinRemote.sin_addr.S_un.S_un_b.s_b4); - return TRUE; - } - - *straddr=_T('\0'); - return FALSE; -} -*/ - DWORD FPRINTF(HANDLE hf, LPCTSTR fmt, ... ) { static TCHAR fprintf_buffer[8192]; @@ -462,52 +433,6 @@ static BOOL MyCreateDirectoryIfNeeded(LPCTSTR lpPathName, String * perrstr) return rtn; } -// Not used - remove later? -#ifdef _UNUSED_ -BOOL MkDirEx(LPCTSTR foldername) -{ - TCHAR tempPath[_MAX_PATH] = {0}; - LPTSTR p; - - _tcscpy(tempPath, foldername); - if (*_tcsinc(foldername) == _T(':')) - p = _tcschr(_tcsninc(tempPath, 3), _T('\\')); - else if (*foldername == _T('\\')) - p = _tcschr(_tcsinc(tempPath), _T('\\')); - else - p = tempPath; - String errstr; - if (p != NULL) - for (; *p != _T('\0'); p = _tcsinc(p)) - { - if (*p == _T('\\')) - { - *p = _T('\0');; - if (0 && _tcscmp(tempPath, _T(".")) == 0) - { - // Don't call CreateDirectory(".") - } - else - { - if (!MyCreateDirectoryIfNeeded(tempPath, &errstr) - && !MyCreateDirectoryIfNeeded(tempPath, &errstr)) - TRACE(_T("Failed to create folder %s: %s\n"), tempPath, errstr.c_str()); - *p = _T('\\'); - } - } - - } - - if (!MyCreateDirectoryIfNeeded(foldername, &errstr) - && !MyCreateDirectoryIfNeeded(foldername, &errstr)) - TRACE(_T("Failed to create folder %s: %s\n"), foldername, errstr.c_str()); - - struct _stat mystats = {0}; - int stat_result = _tstat(foldername, &mystats); - return stat_result != 0; -} -#endif // _UNUSED_ - float RoundMeasure(float measure, float units) { float res1,res2,divisor; @@ -606,336 +531,6 @@ static double tenpow(int expon) return rtn; } -// These are not used - remove later? -#ifdef _UNUSED_ -void DDX_Float( CDataExchange* pDX, int nIDC, float& value ) -{ - pDX->PrepareEditCtrl(nIDC); - CEdit *pEdit = (CEdit *)pDX->m_pDlgWnd->GetDlgItem(nIDC); - if (pDX->m_bSaveAndValidate) - { - //DDX_Text(pDX, nIDC, value); - static TCHAR dec[4]=_T(""); - static TCHAR thous[4]=_T(""); - static TCHAR negsign[4]=_T(""); - static int negstyle=1; - - if (*dec == _T('\0')) - { - LCID lcid = GetThreadLocale(); - GetLocaleInfo(lcid, LOCALE_INEGNUMBER, dec, 4); - negstyle = _ttoi(dec); - GetLocaleInfo(lcid, LOCALE_SDECIMAL, dec, 4); - GetLocaleInfo(lcid, LOCALE_STHOUSAND, thous, 4); - GetLocaleInfo(lcid, LOCALE_SNEGATIVESIGN, negsign, 4); - } - - value = 0.f; - - // are we negative? - TCHAR *p,text[80]; - pEdit->GetWindowText(text, 80); - BOOL bIsNeg = (_tcschr(text, negsign[0])!=NULL); - - // separate at the decimal point - TCHAR istr[80]=_T(""); - TCHAR fstr[80]=_T(""); - p = _tcstok(text, dec); - if (p != NULL) - { - _tcscpy(istr, p); - p = _tcstok(NULL, dec); - if (p != NULL) - _tcscpy(fstr, p); - } - - // get the int part - if (*istr != _T('\0')) - { - CString strResult(_T("")); - CString sep(negsign); - sep += thous; - p = _tcstok(istr, sep); - while (p != NULL) - { - strResult += p; - p = _tcstok(NULL, sep); - } - value = (float)_ttoi(strResult); - } - - // get the fract part - if (*fstr != _T('\0')) - { - p = _tcstok(fstr, negsign); - if (p != NULL) - { - double shift = tenpow(_tcslen(p)); - if (shift) - value += (float)(_tcstod(p,NULL)/shift); - else - pDX->Fail(); - } - } - - // convert to neg - if (bIsNeg) - value *= -1.f; - } - else - { - if (pEdit != NULL) - { - CString s = GetLocalizedNumberString(value, 4); - pEdit->SetWindowText(s); - } - } -} - -void DDX_Double( CDataExchange* pDX, int nIDC, double& value ) -{ - pDX->PrepareEditCtrl(nIDC); - CEdit *pEdit = (CEdit *)pDX->m_pDlgWnd->GetDlgItem(nIDC); - if (pDX->m_bSaveAndValidate) - { - //DDX_Text(pDX, nIDC, value); - static TCHAR dec[4]=_T(""); - static TCHAR thous[4]=_T(""); - static TCHAR negsign[4]=_T(""); - static int negstyle=1; - - if (*dec == _T('\0')) - { - LCID lcid = GetThreadLocale(); - GetLocaleInfo(lcid, LOCALE_INEGNUMBER, dec, 4); - negstyle = _ttoi(dec); - GetLocaleInfo(lcid, LOCALE_SDECIMAL, dec, 4); - GetLocaleInfo(lcid, LOCALE_STHOUSAND, thous, 4); - GetLocaleInfo(lcid, LOCALE_SNEGATIVESIGN, negsign, 4); - } - - value = 0.f; - - // are we negative? - TCHAR *p,text[80]; - pEdit->GetWindowText(text, 80); - BOOL bIsNeg = (_tcschr(text, negsign[0])!=NULL); - - // separate at the decimal point - TCHAR istr[80]=_T(""); - TCHAR fstr[80]=_T(""); - p = _tcstok(text, dec); - if (p != NULL) - { - _tcscpy(istr, p); - p = _tcstok(NULL, dec); - if (p != NULL) - _tcscpy(fstr, p); - } - - // get the int part - if (*istr != _T('\0')) - { - CString strResult(_T("")); - CString sep(negsign); - sep += thous; - p = _tcstok(istr, sep); - while (p != NULL) - { - strResult += p; - p = _tcstok(NULL, sep); - } - value = /*(float)*/_ttoi(strResult); - } - - // get the fract part - if (*fstr != _T('\0')) - { - p = _tcstok(fstr, negsign); - if (p != NULL) - { - double shift = tenpow(_tcslen(p)); - if (shift) - value += /*(float)*/(_tcstod(p,NULL)/shift); - else - pDX->Fail(); - } - } - - // convert to neg - if (bIsNeg) - value *= -1.f; - } - else - { - if (pEdit != NULL) - { - CString s = GetLocalizedNumberString(value, 4); - pEdit->SetWindowText(s); - } - } -} - - -CString GetLocalizedNumberString(double dVal, int nPlaces /*=-1*/, BOOL bSeparate /*=FALSE*/, BOOL bTrailZeros /*=FALSE*/, LCID lcidNew /*=LOCALE_USER_DEFAULT*/) -// this function is duplicated in CFloatEdit -{ - static LCID lcid = 0; - static TCHAR dec[4]=_T("."); - static TCHAR thous[4]=_T(","); - static TCHAR buf[80]; - static int nGrpSize=3; - static int nDecimals=2; - static BOOL bLeadZero=TRUE; - static int negstyle=1; - CString s, s2, strResult(_T("")); - DWORD intpart=0; - BOOL bIsNeg=(dVal < 0.0); - - ASSERT(nPlaces!=0); - - if (lcid != lcidNew) - { - lcid = lcidNew; - GetLocaleInfo(lcid, LOCALE_SDECIMAL, dec, 4); - GetLocaleInfo(lcid, LOCALE_STHOUSAND, thous, 4); - GetLocaleInfo(lcid, LOCALE_SGROUPING, buf, 80); - s = buf[0]; - nGrpSize = _ttoi(s); - GetLocaleInfo(lcid, LOCALE_IDIGITS, buf, 4); - nDecimals = _ttoi(buf); - GetLocaleInfo(lcid, LOCALE_ILZERO, buf, 4); - bLeadZero = !_tcsncmp(buf,_T("1"), 1); - GetLocaleInfo(lcid, LOCALE_INEGNUMBER, buf, 4); - negstyle = _ttoi(buf); - } - - TCHAR szFract[80]; - - // split into integer & fraction - char tszInt[80],tszFract[80]; - int places = (nPlaces==-1? nDecimals : nPlaces); - int decimal, sign; - char *buffer; - - buffer = _fcvt( dVal+1e-10, places, &decimal, &sign ); - if (decimal > 0) - { - strncpy(tszInt, buffer, decimal); - tszInt[decimal] = NULL; - } - strncpy(tszFract, &buffer[decimal], strlen(buffer)-decimal); - tszFract[strlen(buffer)-decimal] = NULL; - intpart = (DWORD)atoi(tszInt); -#ifdef _UNICODE - mbstowcs(szFract, tszFract, strlen(tszFract)); -#else - _tcscpy(szFract, tszFract); -#endif - - // take care of leading negative sign - if (bIsNeg) - { - if (negstyle==0) - strResult = _T("("); - else if (negstyle==1) - strResult = _T("-"); - else if (negstyle==2) - strResult = _T("- "); - } - - // format integer part - if (intpart >= 1) - { - s.Format(_T("%lu"), intpart); - - // do thousands separation - if (bSeparate) - { - int len = s.GetLength(); - int leftover = (len % nGrpSize); - - // format the leading group - if (leftover) - { - s2 = s.Left(leftover); - len -= leftover; - s = s.Right(len); - strResult += s2; - } - else if (len) - { - s2 = s.Left(nGrpSize); - len -= nGrpSize; - s = s.Right(len); - strResult += s2; - } - - // format the remaining groups - while (len) - { - s2 = s.Left(nGrpSize); - len -= nGrpSize; - s = s.Right(len); - strResult += thous + s2; - } - } - // want integer value without thousands separation - else - { - strResult += s; - } - } - else - { - // add leading zero - if (bLeadZero) - strResult += _T("0"); - } - - // add decimal separator & fractional part - if (szFract != NULL) - { - // add the decimal separator - strResult += dec; - strResult += szFract; - - // get rid of trailing zeros - if (!bTrailZeros) - { - LPTSTR p, start = strResult.GetBuffer(1); - p = _tcsdec(start, start + _tcslen(start)); - if (p != NULL) - { - for (; p > start && *p==_T('0'); - p = _tcsdec(start, p)); - if (p != NULL) - { - if (*p==_T('.')) // we don't want numbers like 4. - *p=_T('\0'); - else - *(p+1)=_T('\0'); - } - } - strResult.ReleaseBuffer(); - } - } - - // take care of trailing negative sign - if (bIsNeg) - { - if (negstyle==0) - strResult += _T(")"); - else if (negstyle==3) - strResult += _T("-"); - else if (negstyle==4) - strResult += _T(" -"); - } - - return strResult; -} -#endif // _UNUSED_ - HANDLE RunIt(LPCTSTR szExeFile, LPCTSTR szArgs, BOOL bMinimized /*= TRUE*/, BOOL bNewConsole /*= FALSE*/) { STARTUPINFO si = {0}; diff --git a/Src/Common/coretools.h b/Src/Common/coretools.h index 48c93a599..61261c9f4 100644 --- a/Src/Common/coretools.h +++ b/Src/Common/coretools.h @@ -88,7 +88,6 @@ DWORD FPRINTF(HANDLE hf, LPCTSTR fmt, ... ); DWORD FPUTS(LPCTSTR s, HANDLE hf); HANDLE FOPEN(LPCTSTR path, DWORD mode = GENERIC_READ, DWORD access = OPEN_EXISTING); void GetLocalDrives(LPTSTR letters); -//BOOL GetIP(LPTSTR straddr); void replace_char(LPTSTR s, int target, int repl); BOOL FileExtMatches(LPCTSTR filename, LPCTSTR ext); void SplitFilename(LPCTSTR s, String * path, String * name, String * ext); @@ -99,19 +98,12 @@ int fcmp(float a,float b); BOOL FindAnyFile(LPTSTR filespec, LPTSTR name); long SwapEndian(long val); short int SwapEndian(short int val); -//BOOL MkDirEx(LPCTSTR foldername); String GetModulePath(HMODULE hModule = NULL); String GetPathOnly(LPCTSTR fullpath); float RoundMeasure(float measure, float units); String LegalizeFileName(LPCTSTR szFileName); -#ifdef _UNUSED_ -CString GetLocalizedNumberString(double dVal, int nPlaces =-1, BOOL bSeparate =FALSE, BOOL bTrailZeros =FALSE, LCID lcidNew =LOCALE_USER_DEFAULT); -void DDX_Float( CDataExchange* pDX, int nIDC, float& value ); -void DDX_Double( CDataExchange* pDX, int nIDC, double& value ); -#endif - int tcssubptr(LPCTSTR start, LPCTSTR end); HANDLE RunIt(LPCTSTR szExeFile, LPCTSTR szArgs, BOOL bMinimized = TRUE, BOOL bNewConsole = FALSE); -- 2.11.0