File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -247,7 +247,7 @@ class simplecpp::TokenList::Stream {
247247 // character is non-ASCII character then replace it with 0xff
248248 if (isUtf16) {
249249 const unsigned char ch2 = static_cast <unsigned char >(get ());
250- const int ch16 = (bom == 0xfeff ) ? (ch<< 8 | ch2) : (ch2<< 8 | ch );
250+ const int ch16 = makeUtf16Char (ch, ch2);
251251 ch = static_cast <unsigned char >(((ch16 >= 0x80 ) ? 0xff : ch16));
252252 }
253253
@@ -259,7 +259,7 @@ class simplecpp::TokenList::Stream {
259259 else if (isUtf16) {
260260 const int c1 = get ();
261261 const int c2 = get ();
262- const int ch16 = (bom == 0xfeff ) ? (c1<< 8 | c2) : (c2<< 8 | c1 );
262+ const int ch16 = makeUtf16Char (c1, c2 );
263263 if (ch16 != ' \n ' ) {
264264 unget ();
265265 unget ();
@@ -280,7 +280,7 @@ class simplecpp::TokenList::Stream {
280280 (void )get ();
281281 const unsigned char ch2 = static_cast <unsigned char >(peek ());
282282 unget ();
283- const int ch16 = (bom == 0xfeff ) ? (ch<< 8 | ch2) : (ch2<< 8 | ch );
283+ const int ch16 = makeUtf16Char (ch, ch2);
284284 ch = static_cast <unsigned char >(((ch16 >= 0x80 ) ? 0xff : ch16));
285285 }
286286
@@ -305,6 +305,11 @@ class simplecpp::TokenList::Stream {
305305 }
306306
307307private:
308+ inline int makeUtf16Char (const unsigned char ch, const unsigned char ch2) const
309+ {
310+ return (bom == 0xfeff ) ? (ch<<8 | ch2) : (ch2<<8 | ch);
311+ }
312+
308313 unsigned short getAndSkipBOM ()
309314 {
310315 const int ch1 = peek ();
You can’t perform that action at this time.
0 commit comments