1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2006 - Stefan Kueng
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
19 #include ".\utils.h"
\r
21 CUtils::CUtils(void)
\r
25 CUtils::~CUtils(void)
\r
29 void CUtils::StringExtend(LPTSTR str)
\r
34 cPos = _tcschr(cPos, '\\');
\r
37 memmove(cPos+1, cPos, _tcslen(cPos)*sizeof(TCHAR));
\r
43 } while (cPos != NULL);
\r
47 cPos = _tcschr(cPos, '\n');
\r
50 memmove(cPos+1, cPos, _tcslen(cPos)*sizeof(TCHAR));
\r
54 } while (cPos != NULL);
\r
58 cPos = _tcschr(cPos, '\r');
\r
61 memmove(cPos+1, cPos, _tcslen(cPos)*sizeof(TCHAR));
\r
65 } while (cPos != NULL);
\r
69 cPos = _tcschr(cPos, '\t');
\r
72 memmove(cPos+1, cPos, _tcslen(cPos)*sizeof(TCHAR));
\r
76 } while (cPos != NULL);
\r
80 cPos = _tcschr(cPos, '"');
\r
83 memmove(cPos+1, cPos, _tcslen(cPos)*sizeof(TCHAR));
\r
89 } while (cPos != NULL);
\r
92 void CUtils::StringCollapse(LPTSTR str)
\r
97 cPos = _tcschr(cPos, '\\');
\r
100 if (*(cPos+1) == 'n')
\r
103 memmove(cPos+1, cPos+2, (_tcslen(cPos+2)+1)*sizeof(TCHAR));
\r
105 else if (*(cPos+1) == 'r')
\r
108 memmove(cPos+1, cPos+2, (_tcslen(cPos+2)+1)*sizeof(TCHAR));
\r
110 else if (*(cPos+1) == 't')
\r
113 memmove(cPos+1, cPos+2, (_tcslen(cPos+2)+1)*sizeof(TCHAR));
\r
115 else if (*(cPos+1) == '"')
\r
118 memmove(cPos+1, cPos+2, (_tcslen(cPos+2)+1)*sizeof(TCHAR));
\r
120 else if (*(cPos+1) == '\\')
\r
123 memmove(cPos+1, cPos+2, (_tcslen(cPos+2)+1)*sizeof(TCHAR));
\r
127 } while (cPos != NULL);
\r
130 void CUtils::Error()
\r
133 if (!FormatMessage(
\r
134 FORMAT_MESSAGE_ALLOCATE_BUFFER |
\r
135 FORMAT_MESSAGE_FROM_SYSTEM |
\r
136 FORMAT_MESSAGE_IGNORE_INSERTS,
\r
139 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
\r
140 (LPTSTR) &lpMsgBuf,
\r
147 // Display the string.
\r
148 _ftprintf(stderr, _T("%s\n"), (LPCTSTR)lpMsgBuf);
\r
150 // Free the buffer.
\r
151 LocalFree( lpMsgBuf );
\r