Thread: [Winmerge-svn] SF.net SVN: winmerge: [5621] trunk/Src (Page 20)
Windows visual diff and merge for files and directories
Brought to you by:
christianlist,
grimmdp
From: <ki...@us...> - 2008-07-15 19:45:22
|
Revision: 5621 http://winmerge.svn.sourceforge.net/winmerge/?rev=5621&view=rev Author: kimmov Date: 2008-07-15 12:44:58 -0700 (Tue, 15 Jul 2008) Log Message: ----------- Use enum UNICODESET instead of int as a unicoding variable. Modified Paths: -------------- trunk/Src/Common/UniFile.h trunk/Src/Common/multiformatText.cpp trunk/Src/Common/unicoder.h trunk/Src/DiffTextBuffer.h trunk/Src/FileTextEncoding.cpp trunk/Src/FileTextEncoding.h trunk/Src/MergeDoc.cpp Modified: trunk/Src/Common/UniFile.h =================================================================== --- trunk/Src/Common/UniFile.h 2008-07-15 17:34:10 UTC (rev 5620) +++ trunk/Src/Common/UniFile.h 2008-07-15 19:44:58 UTC (rev 5621) @@ -50,8 +50,8 @@ virtual bool HasBom() = 0; virtual void SetBom(bool bom) = 0; - virtual int GetUnicoding() const = 0; - virtual void SetUnicoding(int unicoding) = 0; + virtual ucr::UNICODESET GetUnicoding() const = 0; + virtual void SetUnicoding(ucr::UNICODESET unicoding) = 0; virtual int GetCodepage() const = 0; virtual void SetCodepage(int codepage) = 0; @@ -91,8 +91,8 @@ virtual String GetFullyQualifiedPath() const { return m_filepath; } virtual const UniError & GetLastUniError() const { return m_lastError; } - virtual int GetUnicoding() const { return m_unicoding; } - virtual void SetUnicoding(int unicoding) { m_unicoding = unicoding; } + virtual ucr::UNICODESET GetUnicoding() const { return m_unicoding; } + virtual void SetUnicoding(ucr::UNICODESET unicoding) { m_unicoding = unicoding; } virtual int GetCodepage() const { return m_codepage; } virtual void SetCodepage(int codepage) { m_codepage = codepage; } @@ -113,7 +113,7 @@ String m_filename; int m_lineno; // current 0-based line of m_current UniError m_lastError; - int m_unicoding; // enum UNICODESET in unicoder.h + ucr::UNICODESET m_unicoding; int m_charsize; // 2 for UCS-2, else 1 int m_codepage; // only valid if m_unicoding==ucr::NONE; txtstats m_txtstats; Modified: trunk/Src/Common/multiformatText.cpp =================================================================== --- trunk/Src/Common/multiformatText.cpp 2008-07-15 17:34:10 UTC (rev 5620) +++ trunk/Src/Common/multiformatText.cpp 2008-07-15 19:44:58 UTC (rev 5621) @@ -604,7 +604,7 @@ if (!ufile.OpenReadOnly(filepath) || !ufile.IsUnicode()) return TRUE; // not unicode file, nothing to do - int codeOldBOM = ufile.GetUnicoding(); + ucr::UNICODESET codeOldBOM = ufile.GetUnicoding(); if (codeOldBOM == ucr::UCS2LE) return TRUE; // unicode UCS-2LE, nothing to do bool bBom = ufile.HasBom(); @@ -701,7 +701,7 @@ UniMemFile ufile; if (!ufile.OpenReadOnly(filepath) || !ufile.IsUnicode()) return TRUE; // not unicode file, nothing to do - int unicoding = ufile.GetUnicoding(); + ucr::UNICODESET unicoding = ufile.GetUnicoding(); // Finished with examing file contents ufile.Close(); Modified: trunk/Src/Common/unicoder.h =================================================================== --- trunk/Src/Common/unicoder.h 2008-07-15 17:34:10 UTC (rev 5620) +++ trunk/Src/Common/unicoder.h 2008-07-15 19:44:58 UTC (rev 5621) @@ -28,13 +28,13 @@ }; /** @brief Known Unicode encodings. */ -typedef enum +enum UNICODESET { NONE = 0, /**< No unicode. */ UCS2LE, /**< UCS-2 little endian. */ UCS2BE, /**< UCS-2 big endian. */ UTF8, /**< UTF-8. */ -} UNICODESET; +}; int Ucs4_to_Utf8(UINT unich, unsigned char * utf8); int Utf8len_fromLeadByte(unsigned char ch); Modified: trunk/Src/DiffTextBuffer.h =================================================================== --- trunk/Src/DiffTextBuffer.h 2008-07-15 17:34:10 UTC (rev 5620) +++ trunk/Src/DiffTextBuffer.h 2008-07-15 19:44:58 UTC (rev 5621) @@ -56,8 +56,8 @@ int SaveToFile (LPCTSTR pszFileName, BOOL bTempFile, CString & sError, PackingInfo * infoUnpacker = NULL, CRLFSTYLE nCrlfStyle = CRLF_STYLE_AUTOMATIC, BOOL bClearModifiedFlag = TRUE ); - int getUnicoding() const { return m_encoding.m_unicoding; } - void setUnicoding(int value) { m_encoding.m_unicoding = value; } + ucr::UNICODESET getUnicoding() const { return m_encoding.m_unicoding; } + void setUnicoding(ucr::UNICODESET value) { m_encoding.m_unicoding = value; } int getCodepage() const { return m_encoding.m_codepage; } void setCodepage(int value) { m_encoding.m_codepage = value; } const FileTextEncoding & getEncoding() const { return m_encoding; } Modified: trunk/Src/FileTextEncoding.cpp =================================================================== --- trunk/Src/FileTextEncoding.cpp 2008-07-15 17:34:10 UTC (rev 5620) +++ trunk/Src/FileTextEncoding.cpp 2008-07-15 19:44:58 UTC (rev 5621) @@ -27,7 +27,7 @@ void FileTextEncoding::Clear() { m_codepage = -1; - m_unicoding = 0; // assume unicoding==0 means none + m_unicoding = ucr::NONE; m_bom = false; m_guessed = false; } @@ -43,7 +43,7 @@ m_unicoding = ucr::UTF8; } -void FileTextEncoding::SetUnicoding(int unicoding) +void FileTextEncoding::SetUnicoding(ucr::UNICODESET unicoding) { if (unicoding == ucr::NONE) m_codepage = CP_ACP; // not sure what to do here Modified: trunk/Src/FileTextEncoding.h =================================================================== --- trunk/Src/FileTextEncoding.h 2008-07-15 17:34:10 UTC (rev 5620) +++ trunk/Src/FileTextEncoding.h 2008-07-15 19:44:58 UTC (rev 5621) @@ -9,20 +9,22 @@ #ifndef FileTextEncoding_h_included #define FileTextEncoding_h_included +#include "unicoder.h" + /** * @brief Text encoding (eg, UTF-8, or CP-1252) */ struct FileTextEncoding { int m_codepage; /**< 8bit codepage, if applicable, -1 is unknown or N/A */ - int m_unicoding; /**< Unicode encoding (assumes 0 is none, use values from ucr::CODESET) */ + ucr::UNICODESET m_unicoding; /**< Unicode encoding. */ bool m_bom; /**< Unicode byte marker */ bool m_guessed; /**< Whether encoding was guessed from content */ FileTextEncoding(); void Clear(); void SetCodepage(int codepage); - void SetUnicoding(int unicoding); + void SetUnicoding(ucr::UNICODESET unicoding); String GetName() const; static int Collate(const FileTextEncoding & fte1, const FileTextEncoding & fte2); Modified: trunk/Src/MergeDoc.cpp =================================================================== --- trunk/Src/MergeDoc.cpp 2008-07-15 17:34:10 UTC (rev 5620) +++ trunk/Src/MergeDoc.cpp 2008-07-15 19:44:58 UTC (rev 5621) @@ -80,6 +80,9 @@ _T ("\x0d") // Macintosh style }; +static void SaveBuffForDiff(CDiffTextBuffer & buf, LPCTSTR filepath); +static void UnescapeControlChars(CString &s); + ///////////////////////////////////////////////////////////////////////////// // CMergeDoc @@ -333,7 +336,7 @@ { ASSERT(buf.m_nSourceEncoding == buf.m_nDefaultEncoding); int orig_codepage = buf.getCodepage(); - int orig_unicoding = buf.getUnicoding(); + ucr::UNICODESET orig_unicoding = buf.getUnicoding(); // If file was in Unicode if (orig_unicoding!=ucr::NONE) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ki...@us...> - 2008-07-15 22:41:25
|
Revision: 5624 http://winmerge.svn.sourceforge.net/winmerge/?rev=5624&view=rev Author: kimmov Date: 2008-07-15 15:41:20 -0700 (Tue, 15 Jul 2008) Log Message: ----------- CString to String conversion for unicoder's maketchar/maketstring functions. Modified Paths: -------------- trunk/Src/Common/UniFile.cpp trunk/Src/Common/unicoder.cpp trunk/Src/Common/unicoder.h trunk/Src/UniMarkdownFile.cpp Modified: trunk/Src/Common/UniFile.cpp =================================================================== --- trunk/Src/Common/UniFile.cpp 2008-07-15 20:04:26 UTC (rev 5623) +++ trunk/Src/Common/UniFile.cpp 2008-07-15 22:41:20 UTC (rev 5624) @@ -553,7 +553,8 @@ RecordZero(m_txtstats, offset); } } - line = ucr::maketstring((LPCSTR)m_current, eolptr-m_current, m_codepage, lossy); + String localLine = ucr::maketstring((LPCSTR)m_current, eolptr-m_current, m_codepage, lossy); + line = localLine.c_str(); if (lossy && *lossy) ++m_txtstats.nlosses; if (!eof) @@ -615,10 +616,10 @@ // convert from Unicode codepoint to TCHAR string // could be multicharacter if decomposition took place, for example bool lossy = false; // try to avoid lossy conversion - CString sch = ucr::maketchar(ch, lossy); + String sch = ucr::maketchar(ch, lossy); if (lossy) ++m_txtstats.nlosses; - if (sch.GetLength() >= 1) + if (sch.length() >= 1) ch = sch[0]; else ch = 0; @@ -679,7 +680,7 @@ line.ReleaseBuffer(cchLine); return TRUE; } - cchLine = Append(line, cchLine, sch, sch.GetLength()); + cchLine = Append(line, cchLine, sch.c_str(), sch.length()); } line.ReleaseBuffer(cchLine); return TRUE; Modified: trunk/Src/Common/unicoder.cpp =================================================================== --- trunk/Src/Common/unicoder.cpp 2008-07-15 20:04:26 UTC (rev 5623) +++ trunk/Src/Common/unicoder.cpp 2008-07-15 22:41:20 UTC (rev 5624) @@ -17,6 +17,7 @@ */ #include "StdAfx.h" +#include "UnicodeString.h" #include "unicoder.h" #include "codepage.h" #include "Utf8FileDetect.h" @@ -41,8 +42,7 @@ /** * @brief fetch current OS version into file level variable & set flag */ -static void -fetch_verinfo() +static void fetch_verinfo() { memset(&f_osvi, 0, sizeof(f_osvi)); f_osvi.dwOSVersionInfoSize = sizeof(f_osvi); @@ -57,8 +57,7 @@ * returns length of byte string written * Does not zero-terminate! */ -int -Ucs4_to_Utf8(UINT unich, unsigned char * utf8) +int Ucs4_to_Utf8(UINT unich, unsigned char * utf8) { #pragma warning(disable: 4244) // possible loss of data due to type conversion if (unich <= 0x7f) @@ -117,10 +116,11 @@ } /** - * @brief return byte length of UTF-8 character from its initial character (-1 if invalid) + * @brief Gets a length of UTF-8 character in bytes. + * @param [in] ch The character for which to get the length. + * @return Byte length of UTF-8 character, -1 if invalid. */ -int -Utf8len_fromLeadByte(unsigned char ch) +int Utf8len_fromLeadByte(unsigned char ch) { if (ch < 0x80) return 1; if (ch < 0xC0) return -1; @@ -135,8 +135,7 @@ /** * @brief return #bytes required to represent Unicode codepoint as UTF-8 */ -int -Utf8len_fromCodepoint(UINT ch) +int Utf8len_fromCodepoint(UINT ch) { if (ch <= 0x7F) return 1; if (ch <= 0x7FF) return 2; @@ -154,8 +153,7 @@ * * @bug Fails for files larger than 2gigs */ -UINT -Utf8len_of_string(LPCWSTR text, int size) +UINT Utf8len_of_string(LPCWSTR text, int size) { UINT len=0; for (int i=0; i<size; ++i) @@ -173,8 +171,7 @@ * * @bug Fails for files larger than 2gigs */ -UINT -stringlen_of_utf8(LPCSTR text, int size) +UINT stringlen_of_utf8(LPCSTR text, int size) { UINT len=0; for (int i=0; i<size; ) @@ -190,8 +187,7 @@ /** * @brief Read UTF-8 character and return as Unicode */ -UINT -GetUtf8Char(unsigned char * str) +UINT GetUtf8Char(unsigned char * str) { /* test short cases first, as probably much more common */ if (!(*str & 0x80 && *str & 0x40)) { @@ -297,7 +293,7 @@ /** * @brief convert character passed (Unicode codepoint) to a TCHAR (set lossy flag if imperfect conversion) */ -CString maketchar(UINT unich, bool & lossy) +String maketchar(UINT unich, bool & lossy) { static UINT codepage = CP_ACP; // NB: Windows always draws in CP_ACP, not CP_THREAD_ACP, so we must use CP_ACP as an internal codepage @@ -308,21 +304,20 @@ /** * @brief convert character passed (Unicode codepoint) to a TCHAR (set lossy flag if imperfect conversion) */ -CString maketchar(UINT unich, bool & lossy, UINT codepage) +String maketchar(UINT unich, bool & lossy, UINT codepage) { #ifdef _UNICODE if (unich < 0x10000) { - CString s; - s = (TCHAR)unich; + String s(1, (TCHAR)unich); return s; } lossy = TRUE; - return '?'; + return _T("?"); #else if (unich < 0x80) { - CString s = (TCHAR)unich; + String s(1, (TCHAR)unich); return s; } wchar_t wch = (wchar_t)unich; @@ -365,8 +360,7 @@ /** * @brief convert 8-bit character input to Unicode codepoint and return it */ -UINT -byteToUnicode (unsigned char ch) +UINT byteToUnicode (unsigned char ch) { static UINT codepage = CP_ACP; // NB: Windows always draws in CP_ACP, not CP_THREAD_ACP, so we must use CP_ACP as an internal codepage @@ -377,8 +371,7 @@ /** * @brief convert 8-bit character input to Unicode codepoint and return it */ -UINT -byteToUnicode (unsigned char ch, UINT codepage) +UINT byteToUnicode (unsigned char ch, UINT codepage) { if (ch < 0x80) @@ -412,8 +405,7 @@ * @brief Write appropriate BOM (Unicode byte order marker) * returns #bytes written */ -int -writeBom(LPVOID dest, UNICODESET unicoding) +int writeBom(LPVOID dest, UNICODESET unicoding) { unsigned char * lpd = reinterpret_cast<unsigned char *>(dest); // write Unicode byte order marker (BOM) @@ -444,8 +436,7 @@ * This does not handle MBCS or UTF-8 codepages correctly! * Client should not use this except for Unicode or SBCS codepages. */ -UINT -get_unicode_char(unsigned char * ptr, UNICODESET codeset, int codepage) +UINT get_unicode_char(unsigned char * ptr, UNICODESET codeset, int codepage) { UINT ch; switch (codeset) @@ -471,11 +462,12 @@ * In fact, this doesn't even know. Probably going to have to make * two passes, the first with MB_ERR_INVALID_CHARS. Ugh. :( */ -CString maketstring(LPCSTR lpd, UINT len, int codepage, bool * lossy) +String maketstring(LPCSTR lpd, UINT len, int codepage, bool * lossy) { int defcodepage = getDefaultCodepage(); - if (!len) return _T(""); + if (!len) + return _T(""); // 0 is a valid value (CP_ACP)! if (codepage == -1) @@ -484,10 +476,11 @@ #ifdef UNICODE // Convert input to Unicode, using specified codepage // TCHAR is wchar_t, so convert into CString (str) - CString str; DWORD flags = MB_ERR_INVALID_CHARS; - int wlen = len*2+6; - LPWSTR wbuff = str.GetBuffer(wlen); + int wlen = len * 2 + 6; + String str; + str.resize(wlen); + LPWSTR wbuff = &*str.begin(); do { int n = MultiByteToWideChar(codepage, flags, lpd, len, wbuff, wlen-1); @@ -508,7 +501,7 @@ ASSERT(FALSE); --n; } - str.ReleaseBuffer(n); + str.resize(n); return str; } *lossy = true; @@ -522,10 +515,10 @@ { // trivial case, they want the bytes in the file interpreted in our current codepage // Only caveat is that input (lpd) is not zero-terminated - return CString(lpd, len); + return String(lpd, len); } - CString str = CrossConvertToStringA(lpd, len, codepage, defcodepage, lossy); + String str = CrossConvertToStringA(lpd, len, codepage, defcodepage, lossy); return str; #endif } @@ -534,16 +527,15 @@ * @brief (ANSI build only) Convert from one 8 bit codepage to another */ #ifndef UNICODE -CString -CrossConvertToStringA(LPCSTR src, UINT srclen, int cpin, int cpout, bool * lossy) +String CrossConvertToStringA(LPCSTR src, UINT srclen, int cpin, int cpout, bool * lossy) { - - CString str; int wlen = srclen*2+6; int clen = wlen * 2 + 6; - LPSTR cbuff = str.GetBuffer(clen); + String str; + str.resize(clen); + LPSTR cbuff = &*str.begin(); int nbytes = CrossConvert(src, srclen, cbuff, clen, cpin, cpout, lossy); - str.ReleaseBuffer(nbytes); + str.resize(nbytes); return str; } #endif @@ -553,8 +545,7 @@ * * destsize must be at least 2 */ -int -CrossConvert(LPCSTR src, UINT srclen, LPSTR dest, UINT destsize, int cpin, int cpout, bool * lossy) +int CrossConvert(LPCSTR src, UINT srclen, LPSTR dest, UINT destsize, int cpin, int cpout, bool * lossy) { ASSERT(destsize > 1); @@ -779,4 +770,3 @@ return (cp1 == cp2) || (NormalizeCodepage(cp1) == NormalizeCodepage(cp2)); } - Modified: trunk/Src/Common/unicoder.h =================================================================== --- trunk/Src/Common/unicoder.h 2008-07-15 20:04:26 UTC (rev 5623) +++ trunk/Src/Common/unicoder.h 2008-07-15 22:41:20 UTC (rev 5624) @@ -43,12 +43,12 @@ UINT stringlen_of_utf8(LPCSTR text, int size); UINT GetUtf8Char(unsigned char * str); int to_utf8_advance(UINT u, unsigned char * &lpd); -CString maketchar(UINT ch, bool & lossy); +String maketchar(UINT ch, bool & lossy); int writeBom(LPVOID dest, UNICODESET unicoding); UINT get_unicode_char(unsigned char * ptr, UNICODESET unicoding, int codepage=0); -CString maketstring(LPCSTR lpd, UINT len, int codepage, bool * lossy); -CString maketchar(UINT unich, bool & lossy); -CString maketchar(UINT unich, bool & lossy, UINT codepage); +String maketstring(LPCSTR lpd, UINT len, int codepage, bool * lossy); +String maketchar(UINT unich, bool & lossy); +String maketchar(UINT unich, bool & lossy, UINT codepage); UINT byteToUnicode(unsigned char ch); UINT byteToUnicode(unsigned char ch, UINT codepage); void getInternalEncoding(UNICODESET * unicoding, int * codepage); @@ -58,7 +58,7 @@ int CrossConvert(LPCSTR src, UINT srclen, LPSTR dest, UINT destsize, int cpin, int cpout, bool * lossy); #ifndef UNICODE -CString CrossConvertToStringA(LPCSTR src, UINT srclen, int cpin, int cpout, bool * lossy); +String CrossConvertToStringA(LPCSTR src, UINT srclen, int cpin, int cpout, bool * lossy); #endif UNICODESET DetermineEncoding(LPBYTE pBuffer, int size, bool * pBom); Modified: trunk/Src/UniMarkdownFile.cpp =================================================================== --- trunk/Src/UniMarkdownFile.cpp 2008-07-15 20:04:26 UTC (rev 5623) +++ trunk/Src/UniMarkdownFile.cpp 2008-07-15 22:41:20 UTC (rev 5624) @@ -7,6 +7,7 @@ // $Id$ #include "stdafx.h" +#include "UnicodeString.h" #include "UniMarkdownFile.h" #include "markdown.h" #include "unicoder.h" @@ -140,8 +141,9 @@ bool bDone = false; if (m_current < (LPBYTE)m_pMarkdown->lower) { - line = ucr::maketstring((const char *)m_current, m_pMarkdown->lower - + String localLine = ucr::maketstring((const char *)m_current, m_pMarkdown->lower - (const char *)m_current, m_codepage, lossy); + line = localLine.c_str(); CollapseWhitespace(line); bDone = !line.IsEmpty(); m_current = (LPBYTE)m_pMarkdown->lower; @@ -160,7 +162,8 @@ { ++m_current; } - line = ucr::maketstring((const char *)current, m_current - current, m_codepage, lossy); + String localLine = ucr::maketstring((const char *)current, m_current - current, m_codepage, lossy); + line = localLine.c_str(); if (m_current < m_transparent) { current = m_current; @@ -214,16 +217,18 @@ } if (bDone) { - line = ucr::maketstring((const char *)m_current, m_pMarkdown->first - + String localLine = ucr::maketstring((const char *)m_current, m_pMarkdown->first - (const char *)m_current, m_codepage, lossy); + line = localLine.c_str(); CollapseWhitespace(line); m_current = (LPBYTE)m_pMarkdown->first; } else if (m_current < m_base + m_filesize) { bDone = true; - line = ucr::maketstring((const char *)m_current, m_base + m_filesize - + String localLine = ucr::maketstring((const char *)m_current, m_base + m_filesize - m_current, m_codepage, lossy); + line = localLine.c_str(); CollapseWhitespace(line); m_current = m_base + m_filesize; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ki...@us...> - 2008-07-16 08:24:54
|
Revision: 5626 http://winmerge.svn.sourceforge.net/winmerge/?rev=5626&view=rev Author: kimmov Date: 2008-07-16 01:24:27 -0700 (Wed, 16 Jul 2008) Log Message: ----------- Convert rest of CStrings to Strings in unicoder. Bunch of other CString to String conversions. Modified Paths: -------------- trunk/Src/Common/unicoder.cpp trunk/Src/DiffTextBuffer.cpp trunk/Src/DiffTextBuffer.h trunk/Src/Environment.cpp trunk/Src/MergeDoc.cpp trunk/Src/MergeDoc.h trunk/Src/MergeEditView.cpp trunk/Src/StdAfx.cpp trunk/Src/StdAfx.h trunk/Src/VSSHelper.cpp Modified: trunk/Src/Common/unicoder.cpp =================================================================== --- trunk/Src/Common/unicoder.cpp 2008-07-16 07:08:15 UTC (rev 5625) +++ trunk/Src/Common/unicoder.cpp 2008-07-16 08:24:27 UTC (rev 5626) @@ -339,7 +339,7 @@ if (WideCharToMultiByte(codepage, flags, &wch, 1, &outch, 1, NULL, &defaulted) && !defaulted) { - CString s = outch; + String s(1, outch); return s; } lossy = TRUE; @@ -387,7 +387,7 @@ } /** - * @brief Return encoding used for TCHAR & CString + * @brief Return encoding used for TCHAR & String */ void getInternalEncoding(UNICODESET * unicoding, int * codepage) { @@ -475,7 +475,7 @@ #ifdef UNICODE // Convert input to Unicode, using specified codepage - // TCHAR is wchar_t, so convert into CString (str) + // TCHAR is wchar_t, so convert into String (str) DWORD flags = MB_ERR_INVALID_CHARS; int wlen = len * 2 + 6; String str; @@ -557,7 +557,7 @@ if (!n) { int nsyserr = ::GetLastError(); - CString syserrstr = GetSysError(nsyserr); + String syserrstr = GetSysError(nsyserr); delete [] wbuff; dest[0] = '?'; return 1; @@ -586,7 +586,7 @@ if (!n) { int nsyserr = ::GetLastError(); - CString syserrstr = GetSysError(nsyserr); + String syserrstr = GetSysError(nsyserr); } dest[n] = 0; delete [] wbuff; Modified: trunk/Src/DiffTextBuffer.cpp =================================================================== --- trunk/Src/DiffTextBuffer.cpp 2008-07-16 07:08:15 UTC (rev 5625) +++ trunk/Src/DiffTextBuffer.cpp 2008-07-16 08:24:27 UTC (rev 5626) @@ -537,7 +537,7 @@ * @return SAVE_DONE or an error code (list in MergeDoc.h) */ int CDiffTextBuffer::SaveToFile (LPCTSTR pszFileName, - BOOL bTempFile, CString & sError, PackingInfo * infoUnpacker /*= NULL*/, + BOOL bTempFile, String & sError, PackingInfo * infoUnpacker /*= NULL*/, CRLFSTYLE nCrlfStyle /*= CRLF_STYLE_AUTOMATIC*/, BOOL bClearModifiedFlag /*= TRUE*/ ) { Modified: trunk/Src/DiffTextBuffer.h =================================================================== --- trunk/Src/DiffTextBuffer.h 2008-07-16 07:08:15 UTC (rev 5625) +++ trunk/Src/DiffTextBuffer.h 2008-07-16 08:24:27 UTC (rev 5626) @@ -53,7 +53,7 @@ int LoadFromFile(LPCTSTR pszFileName, PackingInfo * infoUnpacker, LPCTSTR filteredFilenames, BOOL & readOnly, CRLFSTYLE nCrlfStyle, const FileTextEncoding & encoding, CString &sError); - int SaveToFile (LPCTSTR pszFileName, BOOL bTempFile, CString & sError, + int SaveToFile (LPCTSTR pszFileName, BOOL bTempFile, String & sError, PackingInfo * infoUnpacker = NULL, CRLFSTYLE nCrlfStyle = CRLF_STYLE_AUTOMATIC, BOOL bClearModifiedFlag = TRUE ); ucr::UNICODESET getUnicoding() const { return m_encoding.m_unicoding; } Modified: trunk/Src/Environment.cpp =================================================================== --- trunk/Src/Environment.cpp 2008-07-16 07:08:15 UTC (rev 5625) +++ trunk/Src/Environment.cpp 2008-07-16 08:24:27 UTC (rev 5626) @@ -37,7 +37,7 @@ if (pnerr) *pnerr = err; #ifdef _DEBUG - CString sysErr = GetSysError(err); // for debugging + String sysErr = GetSysError(err); // for debugging #endif return strTempPath.c_str(); // empty } @@ -70,7 +70,7 @@ if (pnerr) *pnerr = err; #ifdef _DEBUG - CString sysErr = GetSysError(err); // for debugging + String sysErr = GetSysError(err); // for debugging #endif return _T(""); } Modified: trunk/Src/MergeDoc.cpp =================================================================== --- trunk/Src/MergeDoc.cpp 2008-07-16 07:08:15 UTC (rev 5625) +++ trunk/Src/MergeDoc.cpp 2008-07-16 08:24:27 UTC (rev 5626) @@ -350,7 +350,7 @@ PackingInfo * tempPacker = NULL; // write buffer out to temporary file - CString sError; + String sError; int retVal = buf.SaveToFile(filepath, TRUE, sError, tempPacker, CRLF_STYLE_AUTOMATIC, FALSE); @@ -949,7 +949,7 @@ * @sa CMergeDoc::DoSaveAs() * @sa CMergeDoc::CDiffTextBuffer::SaveToFile() */ -BOOL CMergeDoc::TrySaveAs(CString &strPath, int &nSaveResult, CString & sError, +BOOL CMergeDoc::TrySaveAs(CString &strPath, int &nSaveResult, String & sError, int nBuffer, PackingInfo * pInfoTempUnpacker) { CString s; @@ -984,7 +984,7 @@ } else { - LangFormatString2(s, IDS_FILESAVE_FAILED, strPath, sError); + LangFormatString2(s, IDS_FILESAVE_FAILED, strPath, sError.c_str()); } // SAVE_NO_FILENAME is temporarily used for scratchpad. @@ -1058,7 +1058,6 @@ { DiffFileInfo fileInfo; CString strSavePath(szPath); - CString sError; BOOL bFileChanged = FALSE; BOOL bApplyToAll = FALSE; int nRetVal = -1; @@ -1125,6 +1124,7 @@ (m_nBufferType[nBuffer] == BUFFER_UNNAMED)) nSaveErrorCode = SAVE_NO_FILENAME; + String sError; if (nSaveErrorCode == SAVE_DONE) // We have a filename, just try to save nSaveErrorCode = pBuffer->SaveToFile(strSavePath, FALSE, sError, &infoTempUnpacker); @@ -1183,7 +1183,6 @@ BOOL CMergeDoc::DoSaveAs(LPCTSTR szPath, BOOL &bSaveSuccess, int nBuffer) { CString strSavePath(szPath); - CString sError; // use a temp packer // first copy the m_pInfoUnpacker @@ -1203,6 +1202,7 @@ nSaveErrorCode = SAVE_NO_FILENAME; // Loop until user succeeds saving or cancels + String sError; do result = TrySaveAs(strSavePath, nSaveErrorCode, sError, nBuffer, &infoTempUnpacker); while (!result); @@ -2601,7 +2601,8 @@ UniStdioFile file; if (!file.Open(s, _T("wt"))) { - ResMsgBox1(IDS_REPORT_ERROR, GetSysError(GetLastError()), MB_OK | MB_ICONSTOP); + String errMsg = GetSysError(GetLastError()); + ResMsgBox1(IDS_REPORT_ERROR, errMsg.c_str(), MB_OK | MB_ICONSTOP); return; } Modified: trunk/Src/MergeDoc.h =================================================================== --- trunk/Src/MergeDoc.h 2008-07-16 07:08:15 UTC (rev 5625) +++ trunk/Src/MergeDoc.h 2008-07-16 08:24:27 UTC (rev 5626) @@ -155,7 +155,7 @@ void CopyMultipleList(int srcPane, int dstPane, int firstDiff, int lastDiff); BOOL SanityCheckDiff(DIFFRANGE dr); bool ListCopy(int srcPane, int dstPane, int nDiff = -1, bool bGroupWithPrevious = false); - BOOL TrySaveAs(CString &strPath, int &nLastErrorCode, CString & sError, + BOOL TrySaveAs(CString &strPath, int &nLastErrorCode, String & sError, int nBuffer, PackingInfo * pInfoTempUnpacker); BOOL DoSave(LPCTSTR szPath, BOOL &bSaveSuccess, int nBuffer); BOOL DoSaveAs(LPCTSTR szPath, BOOL &bSaveSuccess, int nBuffer); Modified: trunk/Src/MergeEditView.cpp =================================================================== --- trunk/Src/MergeEditView.cpp 2008-07-16 07:08:15 UTC (rev 5625) +++ trunk/Src/MergeEditView.cpp 2008-07-16 08:24:27 UTC (rev 5626) @@ -1880,7 +1880,7 @@ if (!ok) { int nerr = GetLastError(); - CString syserr = GetSysError(nerr); + String syserr = GetSysError(nerr); } return ok; } Modified: trunk/Src/StdAfx.cpp =================================================================== --- trunk/Src/StdAfx.cpp 2008-07-16 07:08:15 UTC (rev 5625) +++ trunk/Src/StdAfx.cpp 2008-07-16 08:24:27 UTC (rev 5626) @@ -150,10 +150,10 @@ } // Get user language description of error, if available -CString GetSysError(int nerr) +String GetSysError(int nerr) { LPVOID lpMsgBuf; - CString str = _T("?"); + String str = _T("?"); if (FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | Modified: trunk/Src/StdAfx.h =================================================================== --- trunk/Src/StdAfx.h 2008-07-16 07:08:15 UTC (rev 5625) +++ trunk/Src/StdAfx.h 2008-07-16 08:24:27 UTC (rev 5626) @@ -126,7 +126,7 @@ int ResMsgBox1(UINT msgid, LPCTSTR arg, UINT nType = MB_OK, UINT nIDHelp = 0); /** @brief Retrieve error description from Windows; uses FormatMessage */ -CString GetSysError(int nerr); +String GetSysError(int nerr); /** @brief Send message to log file (in theory; actually doesn't yet) */ void LogErrorString(LPCTSTR sz); Modified: trunk/Src/VSSHelper.cpp =================================================================== --- trunk/Src/VSSHelper.cpp 2008-07-16 07:08:15 UTC (rev 5625) +++ trunk/Src/VSSHelper.cpp 2008-07-16 08:24:27 UTC (rev 5626) @@ -109,8 +109,8 @@ msg.Format(_T("CMainFrame::ReLinkVCProj() ") _T("- failed to open file: %s"), strSavePath); LogErrorString(msg); - LangFormatString2(msg, IDS_ERROR_FILEOPEN, - GetSysError(GetLastError()), strSavePath); + String errMsg = GetSysError(GetLastError()); + LangFormatString2(msg, IDS_ERROR_FILEOPEN, errMsg.c_str(), strSavePath); *psError = msg; } if (tfile == INVALID_HANDLE_VALUE) @@ -118,8 +118,8 @@ msg.Format(_T("CMainFrame::ReLinkVCProj() ") _T("- failed to open temporary file: %s"), tempFile.c_str()); LogErrorString(msg); - LangFormatString2(msg, IDS_ERROR_FILEOPEN, - GetSysError(GetLastError()), tempFile.c_str()); + String errMsg = GetSysError(GetLastError()); + LangFormatString2(msg, IDS_ERROR_FILEOPEN, errMsg.c_str(), tempFile.c_str()); *psError = msg; } return FALSE; @@ -163,7 +163,7 @@ { if (!CopyFile(tempFile.c_str(), strSavePath, FALSE)) { - *psError = GetSysError(GetLastError()); + *psError = GetSysError(GetLastError()).c_str(); DeleteFile(tempFile.c_str()); return FALSE; } @@ -173,8 +173,8 @@ else { CString msg; - LangFormatString2(msg, IDS_ERROR_FILEOPEN, - strSavePath, GetSysError(GetLastError())); + String errMsg = GetSysError(GetLastError()); + LangFormatString2(msg, IDS_ERROR_FILEOPEN, strSavePath, errMsg.c_str()); *psError = msg; return FALSE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |