Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2010-12-17 19:42:55 +0300
committerXhmikosR <xhmikosr@users.sourceforge.net>2010-12-17 19:42:55 +0300
commit7359bd509afa235acc2ac2f7f95fc9cb5cafd1a4 (patch)
treeb5bb90eeca58fdeb9fde6825f21a25a319823cb4 /src/DSUtil/text.cpp
parentd30b15ed4b98c28951d6d45b8928f4c2b6a11129 (diff)
apply astyle formatting
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@2786 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/DSUtil/text.cpp')
-rw-r--r--src/DSUtil/text.cpp82
1 files changed, 51 insertions, 31 deletions
diff --git a/src/DSUtil/text.cpp b/src/DSUtil/text.cpp
index faadaf119..cf953105c 100644
--- a/src/DSUtil/text.cpp
+++ b/src/DSUtil/text.cpp
@@ -70,8 +70,12 @@ CString Implode(CAtlList<CString>& sl, TCHAR sep)
DWORD CharSetToCodePage(DWORD dwCharSet)
{
- if(dwCharSet == CP_UTF8) return CP_UTF8;
- if(dwCharSet == CP_UTF7) return CP_UTF7;
+ if(dwCharSet == CP_UTF8) {
+ return CP_UTF8;
+ }
+ if(dwCharSet == CP_UTF7) {
+ return CP_UTF7;
+ }
CHARSETINFO cs= {0};
::TranslateCharsetInfo((DWORD *)dwCharSet, &cs, TCI_SRCCHARSET);
return cs.ciACP;
@@ -108,13 +112,15 @@ CStringA UrlEncode(CStringA str, bool fRaw)
{
CStringA urlstr;
- for(size_t i = 0; i < str.GetLength(); i++)
- {
+ for(size_t i = 0; i < str.GetLength(); i++) {
CHAR c = str[i];
- if(fRaw && c == '+') urlstr += "%2B";
- else if(c > 0x20 && c < 0x7f && c != '&') urlstr += c;
- else if(c == 0x20) urlstr += fRaw ? ' ' : '+';
- else {
+ if(fRaw && c == '+') {
+ urlstr += "%2B";
+ } else if(c > 0x20 && c < 0x7f && c != '&') {
+ urlstr += c;
+ } else if(c == 0x20) {
+ urlstr += fRaw ? ' ' : '+';
+ } else {
CStringA tmp;
tmp.Format("%%%02x", (BYTE)c);
urlstr += tmp;
@@ -132,27 +138,29 @@ CStringA UrlDecode(CStringA str, bool fRaw)
CHAR* e = s + str.GetLength();
CHAR* s1 = s;
CHAR* s2 = s;
- while(s1 < e)
- {
+ while(s1 < e) {
CHAR s11 = (s1 < e-1) ? (__isascii(s1[1]) && isupper(s1[1]) ? tolower(s1[1]) : s1[1]) : 0;
CHAR s12 = (s1 < e-2) ? (__isascii(s1[2]) && isupper(s1[2]) ? tolower(s1[2]) : s1[2]) : 0;
if(*s1 == '%' && s1 < e-2
&& (s1[1] >= '0' && s1[1] <= '9' || s11 >= 'a' && s11 <= 'f')
- && (s1[2] >= '0' && s1[2] <= '9' || s12 >= 'a' && s12 <= 'f'))
- {
+ && (s1[2] >= '0' && s1[2] <= '9' || s12 >= 'a' && s12 <= 'f')) {
s1[1] = s11;
s1[2] = s12;
*s2 = 0;
- if(s1[1] >= '0' && s1[1] <= '9') *s2 |= s1[1]-'0';
- else if(s1[1] >= 'a' && s1[1] <= 'f') *s2 |= s1[1]-'a'+10;
+ if(s1[1] >= '0' && s1[1] <= '9') {
+ *s2 |= s1[1]-'0';
+ } else if(s1[1] >= 'a' && s1[1] <= 'f') {
+ *s2 |= s1[1]-'a'+10;
+ }
*s2 <<= 4;
- if(s1[2] >= '0' && s1[2] <= '9') *s2 |= s1[2]-'0';
- else if(s1[2] >= 'a' && s1[2] <= 'f') *s2 |= s1[2]-'a'+10;
+ if(s1[2] >= '0' && s1[2] <= '9') {
+ *s2 |= s1[2]-'0';
+ } else if(s1[2] >= 'a' && s1[2] <= 'f') {
+ *s2 |= s1[2]-'a'+10;
+ }
s1 += 2;
- }
- else
- {
+ } else {
*s2 = *s1 == '+' && !fRaw ? ' ' : *s1;
}
@@ -174,25 +182,32 @@ CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing)
tag.TrimLeft('/');
int i = tag.Find(' ');
- if(i < 0) i = tag.GetLength();
+ if(i < 0) {
+ i = tag.GetLength();
+ }
CString type = tag.Left(i).MakeLower();
tag = tag.Mid(i).Trim();
- while((i = tag.Find('=')) > 0)
- {
+ while((i = tag.Find('=')) > 0) {
CString attrib = tag.Left(i).Trim().MakeLower();
tag = tag.Mid(i+1);
- for(i = 0; i < tag.GetLength() && _istspace(tag[i]); i++);
+ for(i = 0; i < tag.GetLength() && _istspace(tag[i]); i++) {
+ ;
+ }
tag = i < tag.GetLength() ? tag.Mid(i) : _T("");
if(!tag.IsEmpty() && tag[0] == '\"') {
tag = tag.Mid(1);
i = tag.Find('\"');
+ } else {
+ i = tag.Find(' ');
+ }
+ if(i < 0) {
+ i = tag.GetLength();
}
- else i = tag.Find(' ');
- if(i < 0) i = tag.GetLength();
CString param = tag.Left(i).Trim();
- if(!param.IsEmpty())
+ if(!param.IsEmpty()) {
attribs[attrib] = param;
+ }
tag = i+1 < tag.GetLength() ? tag.Mid(i+1) : _T("");
}
@@ -202,26 +217,31 @@ CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing)
CAtlList<CString>& MakeLower(CAtlList<CString>& sl)
{
POSITION pos = sl.GetHeadPosition();
- while(pos) sl.GetNext(pos).MakeLower();
+ while(pos) {
+ sl.GetNext(pos).MakeLower();
+ }
return sl;
}
CAtlList<CString>& MakeUpper(CAtlList<CString>& sl)
{
POSITION pos = sl.GetHeadPosition();
- while(pos) sl.GetNext(pos).MakeUpper();
+ while(pos) {
+ sl.GetNext(pos).MakeUpper();
+ }
return sl;
}
CAtlList<CString>& RemoveStrings(CAtlList<CString>& sl, int minlen, int maxlen)
{
POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION tmp = pos;
CString& str = sl.GetNext(pos);
int len = str.GetLength();
- if(len < minlen || len > maxlen) sl.RemoveAt(tmp);
+ if(len < minlen || len > maxlen) {
+ sl.RemoveAt(tmp);
+ }
}
return sl;
}