Must be called right after a file is opened as stdin. Will attempt to remove any UTF-8 unicode signature (byte-order mark, BOM) at the beginning of the file. Unicode: U+FEFF UTF-8: EF BB BF First bytes Encoding Must remove? 00 00 FE FF UTF-32 big endian Yes FF FE 00 00 UTF-32 little endian Yes FE FF UTF-16 big endian Yes FF FE UTF-16 li
| 260 | otherwise UTF-8 No |
| 261 | */ |
| 262 | static void remove_BOM(void) |
| 263 | { |
| 264 | int c1 = getchar(); |
| 265 | if (c1 == 0xEF) { |
| 266 | int c2 = getchar(); |
| 267 | if (c2 == 0xBB) { |
| 268 | int c3 = getchar(); |
| 269 | if (c3 == 0xBF) { |
| 270 | return; |
| 271 | } |
| 272 | if (c3 != EOF) buffer[buffered++] = c3; |
| 273 | } |
| 274 | if (c2 != EOF) buffer[buffered++] = c2; |
| 275 | } |
| 276 | if (c1 != EOF) buffer[buffered++] = c1; |
| 277 | } |
| 278 | |
| 279 | int open_as_stdin(const char *file) |
| 280 | { |
nothing calls this directly
no outgoing calls
no test coverage detected