File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -245,7 +245,7 @@ class simplecpp::TokenList::Stream {
245245 // character is non-ASCII character then replace it with 0xff
246246 if (isUtf16) {
247247 const unsigned char ch2 = static_cast <unsigned char >(get ());
248- const int ch16 = (bom == 0xfeff ) ? (ch<< 8 | ch2) : (ch2<< 8 | ch );
248+ const int ch16 = makeUtf16Char (ch, ch2);
249249 ch = static_cast <unsigned char >(((ch16 >= 0x80 ) ? 0xff : ch16));
250250 }
251251
@@ -257,7 +257,7 @@ class simplecpp::TokenList::Stream {
257257 else if (isUtf16) {
258258 const int c1 = get ();
259259 const int c2 = get ();
260- const int ch16 = (bom == 0xfeff ) ? (c1<< 8 | c2) : (c2<< 8 | c1 );
260+ const int ch16 = makeUtf16Char (c1, c2 );
261261 if (ch16 != ' \n ' ) {
262262 unget ();
263263 unget ();
@@ -278,7 +278,7 @@ class simplecpp::TokenList::Stream {
278278 (void )get ();
279279 const unsigned char ch2 = static_cast <unsigned char >(peek ());
280280 unget ();
281- const int ch16 = (bom == 0xfeff ) ? (ch<< 8 | ch2) : (ch2<< 8 | ch );
281+ const int ch16 = makeUtf16Char (ch, ch2);
282282 ch = static_cast <unsigned char >(((ch16 >= 0x80 ) ? 0xff : ch16));
283283 }
284284
@@ -303,6 +303,11 @@ class simplecpp::TokenList::Stream {
303303 }
304304
305305private:
306+ inline int makeUtf16Char (const unsigned char ch, const unsigned char ch2) const
307+ {
308+ return (bom == 0xfeff ) ? (ch<<8 | ch2) : (ch2<<8 | ch);
309+ }
310+
306311 unsigned short getAndSkipBOM ()
307312 {
308313 const int ch1 = peek ();
You can’t perform that action at this time.
0 commit comments