Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1f7ec67

Browse filesBrowse files
stasoidtordex
authored andcommitted
fix linux build
1 parent 4cd7347 commit 1f7ec67
Copy full SHA for 1f7ec67

File tree

Expand file treeCollapse file tree

3 files changed

+36
-38
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+36
-38
lines changed

‎CMakeLists.txt

Copy file name to clipboardExpand all lines: CMakeLists.txt
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ set(SOURCE_LITEHTML
4949
src/el_text.cpp
5050
src/el_title.cpp
5151
src/el_tr.cpp
52+
src/encodings.cpp
5253
src/html.cpp
5354
src/html_tag.cpp
5455
src/iterators.cpp
@@ -111,6 +112,7 @@ set(HEADER_LITEHTML
111112
include/litehtml/el_title.h
112113
include/litehtml/el_tr.h
113114
include/litehtml/element.h
115+
include/litehtml/encodings.h
114116
include/litehtml/html.h
115117
include/litehtml/html_tag.h
116118
include/litehtml/iterators.h

‎src/encodings.cpp

Copy file name to clipboardExpand all lines: src/encodings.cpp
+23-27Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#define out
66
#define inout
7-
#define countof(a) (sizeof(a)/sizeof(a[0]))
7+
#define countof(a) int(sizeof(a)/sizeof(a[0]))
88

99
#define is_surrogate(ch) ((ch) >= 0xD800 && (ch) < 0xE000)
1010

@@ -133,14 +133,9 @@ decoder::result decoder::process_an_item(string& input, int& index, string& outp
133133
// https://encoding.spec.whatwg.org/#bom-sniff
134134
encoding bom_sniff(const string& str)
135135
{
136-
if (str.size() < 2) return encoding::null;
137-
138-
byte utf8_bom[] = {0xEF, 0xBB, 0xBF};
139-
if (str.size() >= 3 && memcmp(str.data(), utf8_bom, 3) == 0) return encoding::utf_8;
140-
141-
if (str[0] == 0xFE && str[1] == 0xFF) return encoding::utf_16be;
142-
if (str[0] == 0xFF && str[1] == 0xFE) return encoding::utf_16le;
143-
136+
if (str.substr(0, 3) == "\xEF\xBB\xBF") return encoding::utf_8;
137+
if (str.substr(0, 2) == "\xFE\xFF") return encoding::utf_16be;
138+
if (str.substr(0, 2) == "\xFF\xFE") return encoding::utf_16le;
144139
return encoding::null;
145140
}
146141

@@ -183,7 +178,7 @@ struct utf_8_decoder : decoder
183178
// https://encoding.spec.whatwg.org/#utf-8-decoder
184179
decoder::result utf_8_decoder::handler(inout string& input, inout int& index, out int ch[2])
185180
{
186-
int b = index == input.size() ? EOF : (byte)input[index++]; // read byte from input
181+
int b = index == (int)input.size() ? EOF : (byte)input[index++]; // read byte from input
187182

188183
// 1. If byte is end-of-queue and UTF-8 bytes needed is not 0, set UTF-8 bytes needed to 0 and return error.
189184
if (b == EOF && m_bytes_needed != 0)
@@ -385,7 +380,7 @@ int* single_byte_decoder::m_indexes[] =
385380
// https://encoding.spec.whatwg.org/#single-byte-decoder
386381
decoder::result single_byte_decoder::handler(string& input, int& index, int ch[2])
387382
{
388-
int b = index == input.size() ? EOF : (byte)input[index++]; // read input byte
383+
int b = index == (int)input.size() ? EOF : (byte)input[index++]; // read input byte
389384

390385
// 1. If byte is end-of-queue, return finished.
391386
if (b == EOF) return result_finished;
@@ -459,7 +454,7 @@ int gb18030_decoder::ranges_code_point(int pointer)
459454
// https://encoding.spec.whatwg.org/#gb18030-decoder
460455
decoder::result gb18030_decoder::handler(string& input, int& index, int ch[2])
461456
{
462-
int b = index == input.size() ? EOF : (byte)input[index++]; // read input byte
457+
int b = index == (int)input.size() ? EOF : (byte)input[index++]; // read input byte
463458

464459
// 1. If byte is end-of-queue and gb18030 first, gb18030 second, and gb18030 third are 0x00, return finished.
465460
if (b == EOF && m_first == 0 && m_second == 0 && m_third == 0)
@@ -611,7 +606,7 @@ int big5_decoder::m_index[] = {null,null,null,null,null,null,null,null,null,null
611606
// https://encoding.spec.whatwg.org/#big5-decoder
612607
decoder::result big5_decoder::handler(inout string& input, inout int& index, out int ch[2])
613608
{
614-
int b = index == input.size() ? EOF : (byte)input[index++]; // read input byte
609+
int b = index == (int)input.size() ? EOF : (byte)input[index++]; // read input byte
615610

616611
// 1. If byte is end-of-queue and Big5 lead is not 0x00, set Big5 lead to 0x00 and return error.
617612
if (b == EOF && m_lead != 0)
@@ -703,7 +698,7 @@ struct euc_jp_decoder : jis_decoder
703698
// https://encoding.spec.whatwg.org/#euc-jp-decoder
704699
decoder::result euc_jp_decoder::handler(inout string& input, inout int& index, out int ch[2])
705700
{
706-
int b = index == input.size() ? EOF : (byte)input[index++]; // read input byte
701+
int b = index == (int)input.size() ? EOF : (byte)input[index++]; // read input byte
707702

708703
// 1. If byte is end-of-queue and EUC-JP lead is not 0x00, set EUC-JP lead to 0x00, and return error.
709704
if (b == EOF && m_lead != 0)
@@ -812,7 +807,7 @@ struct iso_2022_jp_decoder : jis_decoder
812807
// https://encoding.spec.whatwg.org/#iso-2022-jp-decoder
813808
decoder::result iso_2022_jp_decoder::handler(inout string& input, inout int& index, out int ch[2])
814809
{
815-
int b = index == input.size() ? EOF : (byte)input[index++]; // read input byte
810+
int b = index == (int)input.size() ? EOF : (byte)input[index++]; // read input byte
816811

817812
switch (m_state)
818813
{
@@ -1013,7 +1008,7 @@ struct shift_jis_decoder : jis_decoder
10131008
// https://encoding.spec.whatwg.org/#shift_jis-decoder
10141009
decoder::result shift_jis_decoder::handler(inout string& input, inout int& index, out int ch[2])
10151010
{
1016-
int b = index == input.size() ? EOF : (byte)input[index++]; // read input byte
1011+
int b = index == (int)input.size() ? EOF : (byte)input[index++]; // read input byte
10171012

10181013
// 1. If byte is end-of-queue and Shift_JIS lead is not 0x00, set Shift_JIS lead to 0x00 and return error.
10191014
if (b == EOF && m_lead != 0)
@@ -1107,7 +1102,7 @@ int euc_kr_decoder::m_index[] = {44034,44035,44037,44038,44043,44044,44045,44046
11071102
// https://encoding.spec.whatwg.org/#euc-kr-decoder
11081103
decoder::result euc_kr_decoder::handler(inout string& input, inout int& index, out int ch[2])
11091104
{
1110-
int b = index == input.size() ? EOF : (byte)input[index++]; // read input byte
1105+
int b = index == (int)input.size() ? EOF : (byte)input[index++]; // read input byte
11111106

11121107
// 1. If byte is end-of-queue and EUC-KR lead is not 0x00, set EUC-KR lead to 0x00 and return error.
11131108
if (b == EOF && m_lead != 0)
@@ -1175,10 +1170,10 @@ struct replacement_decoder : decoder
11751170
};
11761171

11771172
// https://encoding.spec.whatwg.org/#replacement-decoder
1178-
decoder::result replacement_decoder::handler(inout string& input, inout int& index, out int ch[2])
1173+
decoder::result replacement_decoder::handler(inout string& input, inout int& index, int[2])
11791174
{
11801175
// 1. If byte is end-of-queue, return finished.
1181-
if (index == input.size())
1176+
if (index == (int)input.size())
11821177
return result_finished;
11831178

11841179
// 2. If replacement error returned is false, set replacement error returned to true and return error.
@@ -1208,7 +1203,7 @@ struct utf_16_decoder : decoder
12081203
// https://encoding.spec.whatwg.org/#shared-utf-16-decoder
12091204
decoder::result utf_16_decoder::handler(inout string& input, inout int& index, out int ch[2])
12101205
{
1211-
int b = index == input.size() ? EOF : (byte)input[index++]; // read input byte
1206+
int b = index == (int)input.size() ? EOF : (byte)input[index++]; // read input byte
12121207

12131208
// 1. If byte is end-of-queue and either UTF-16 lead byte or UTF-16 lead surrogate is non-null, set UTF-16 lead byte and UTF-16 lead surrogate to null, and return error.
12141209
if (b == EOF && (m_lead_byte != 0 || m_lead_surrogate != 0))
@@ -1285,7 +1280,7 @@ struct x_user_defined_decoder : decoder
12851280
// https://encoding.spec.whatwg.org/#x-user-defined-decoder
12861281
decoder::result x_user_defined_decoder::handler(inout string& input, inout int& index, out int ch[2])
12871282
{
1288-
int b = index == input.size() ? EOF : (byte)input[index++]; // read input byte
1283+
int b = index == (int)input.size() ? EOF : (byte)input[index++]; // read input byte
12891284

12901285
// 1. If byte is end-of-queue, return finished.
12911286
if (b == EOF)
@@ -1341,11 +1336,12 @@ decoder::ptr get_decoder(encoding _encoding)
13411336

13421337
case encoding::x_user_defined:
13431338
return make_shared<x_user_defined_decoder>();
1344-
}
13451339

1346-
// single-byte encoding
1347-
if (_encoding >= encoding::ibm866 && _encoding <= encoding::x_mac_cyrillic)
1348-
return make_shared<single_byte_decoder>(_encoding);
1340+
default:
1341+
// single-byte encoding
1342+
if (_encoding >= encoding::ibm866 && _encoding <= encoding::x_mac_cyrillic)
1343+
return make_shared<single_byte_decoder>(_encoding);
1344+
}
13491345

13501346
return nullptr;
13511347
}
@@ -1357,7 +1353,7 @@ decoder::ptr get_decoder(encoding _encoding)
13571353
// https://encoding.spec.whatwg.org/encodings.json
13581354
struct {
13591355
const char* name;
1360-
encoding encoding;
1356+
encoding coding;
13611357
} labels[] =
13621358
{
13631359
"unicode-1-1-utf-8", encoding::utf_8,
@@ -1636,7 +1632,7 @@ encoding get_encoding(string label)
16361632
for (int i = 0; i < countof(labels); i++)
16371633
{
16381634
if (label == labels[i].name)
1639-
return labels[i].encoding;
1635+
return labels[i].coding;
16401636
}
16411637
return encoding::null;
16421638
}

‎src/html.cpp

Copy file name to clipboardExpand all lines: src/html.cpp
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ string& trim(string &s, const string& chars_to_trim)
2424
return s;
2525
}
2626

27-
void litehtml::lcase(string &s)
27+
void lcase(string &s)
2828
{
2929
for(char & i : s)
3030
{
3131
i = t_tolower(i);
3232
}
3333
}
3434

35-
litehtml::string::size_type litehtml::find_close_bracket(const string &s, string::size_type off, char open_b, char close_b)
35+
string::size_type find_close_bracket(const string &s, string::size_type off, char open_b, char close_b)
3636
{
3737
int cnt = 0;
3838
for(string::size_type i = off; i < s.length(); i++)
@@ -52,7 +52,7 @@ litehtml::string::size_type litehtml::find_close_bracket(const string &s, string
5252
return string::npos;
5353
}
5454

55-
litehtml::string litehtml::index_value(int index, const string& strings, char delim)
55+
string index_value(int index, const string& strings, char delim)
5656
{
5757
std::vector<string> vals;
5858
string delims;
@@ -65,7 +65,7 @@ litehtml::string litehtml::index_value(int index, const string& strings, char de
6565
return std::to_string(index);
6666
}
6767

68-
int litehtml::value_index( const string& val, const string& strings, int defValue, char delim )
68+
int value_index( const string& val, const string& strings, int defValue, char delim )
6969
{
7070
if(val.empty() || strings.empty() || !delim)
7171
{
@@ -102,7 +102,7 @@ int litehtml::value_index( const string& val, const string& strings, int defValu
102102
return defValue;
103103
}
104104

105-
bool litehtml::value_in_list( const string& val, const string& strings, char delim )
105+
bool value_in_list( const string& val, const string& strings, char delim )
106106
{
107107
int idx = value_index(val, strings, -1, delim);
108108
if(idx >= 0)
@@ -112,7 +112,7 @@ bool litehtml::value_in_list( const string& val, const string& strings, char del
112112
return false;
113113
}
114114

115-
void litehtml::split_string(const string& str, string_vector& tokens, const string& delims, const string& delims_preserve, const string& quote)
115+
void split_string(const string& str, string_vector& tokens, const string& delims, const string& delims_preserve, const string& quote)
116116
{
117117
if(str.empty() || (delims.empty() && delims_preserve.empty()))
118118
{
@@ -174,7 +174,7 @@ void litehtml::split_string(const string& str, string_vector& tokens, const stri
174174
}
175175
}
176176

177-
void litehtml::join_string(string& str, const string_vector& tokens, const string& delims)
177+
void join_string(string& str, const string_vector& tokens, const string& delims)
178178
{
179179
str = "";
180180
for (size_t i = 0; i < tokens.size(); i++)
@@ -187,7 +187,7 @@ void litehtml::join_string(string& str, const string_vector& tokens, const strin
187187
}
188188
}
189189

190-
int litehtml::t_strcasecmp(const char *s1, const char *s2)
190+
int t_strcasecmp(const char *s1, const char *s2)
191191
{
192192
int i, d, c;
193193

@@ -204,7 +204,7 @@ int litehtml::t_strcasecmp(const char *s1, const char *s2)
204204
}
205205
}
206206

207-
int litehtml::t_strncasecmp(const char *s1, const char *s2, size_t n)
207+
int t_strncasecmp(const char *s1, const char *s2, size_t n)
208208
{
209209
int i, d, c;
210210

@@ -223,7 +223,7 @@ int litehtml::t_strncasecmp(const char *s1, const char *s2, size_t n)
223223
return 0;
224224
}
225225

226-
litehtml::string litehtml::get_escaped_string(const string& in_str)
226+
string get_escaped_string(const string& in_str)
227227
{
228228
string ret;
229229
for (auto ch : in_str)
@@ -281,7 +281,7 @@ litehtml::string litehtml::get_escaped_string(const string& in_str)
281281
return ret;
282282
}
283283

284-
bool litehtml::is_number(const string& string, const bool allow_dot) {
284+
bool is_number(const string& string, const bool allow_dot) {
285285
for (auto ch : string)
286286
{
287287
if (!(t_isdigit(ch) || (allow_dot && ch == '.')))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.