1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013, 2015-2016 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "SerialPatch.h"
24 CSerialPatch::CSerialPatch()
28 CSerialPatch::~CSerialPatch()
31 int CSerialPatch::Parse(const CString
& pathfile
, bool parseBody
)
33 m_PathFile
= pathfile
;
37 if (!PatchFile
.Open(m_PathFile
, CFile::modeRead
))
40 PatchFile
.Read(CStrBufA(m_Body
, (UINT
)PatchFile
.GetLength()), (UINT
)PatchFile
.GetLength());
47 one
= m_Body
.Tokenize("\n", start
);
51 one
= m_Body
.Tokenize("\n", start
);
52 if (one
.GetLength()>6)
53 CGit::StringAppend(&m_Author
, (BYTE
*)(LPCSTR
)one
+ 6, CP_UTF8
, one
.GetLength() - 6);
54 m_Author
.TrimRight(L
'\r');
58 one
= m_Body
.Tokenize("\n", start
);
59 if (one
.GetLength()>6)
60 CGit::StringAppend(&m_Date
, (BYTE
*)(LPCSTR
)one
+ 6, CP_UTF8
, one
.GetLength() - 6);
61 m_Date
.TrimRight(L
'\r');
65 one
= m_Body
.Tokenize("\n", start
);
66 if (one
.GetLength()>9)
68 CGit::StringAppend(&m_Subject
, (BYTE
*)(LPCSTR
)one
+ 9, CP_UTF8
, one
.GetLength() - 9);
69 while (m_Body
.GetLength() > start
&& m_Body
.GetAt(start
) == L
' ')
71 one
= m_Body
.Tokenize("\n", start
);
72 CGit::StringAppend(&m_Subject
, (BYTE
*)(LPCSTR
)one
, CP_UTF8
, one
.GetLength());
74 m_Subject
.TrimRight(L
'\r');
82 if (m_Body
.Mid(start
- 1, 2) == L
"\n\n")
84 if (m_Body
.Mid(start
- 4, 4) == L
"\r\n\r\n")
89 m_Body
.Tokenize("\n", start
);
95 if (start
+ 1 < m_Body
.GetLength())
96 CGit::StringAppend(&m_strBody
, (BYTE
*)(LPCSTR
)m_Body
+ start
+ 1, CP_UTF8
, m_Body
.GetLength() - start
- 1);