** Skip an optional BOM at the start of a stream. If there is an ** incomplete BOM (the first character is correct but the rest is ** not), returns the first character anyway to force an error ** (as no chunk can start with 0xEF). */
| 777 | ** (as no chunk can start with 0xEF). |
| 778 | */ |
| 779 | static int skipBOM (FILE *f) { |
| 780 | int c = getc(f); /* read first character */ |
| 781 | if (c == 0xEF && getc(f) == 0xBB && getc(f) == 0xBF) /* correct BOM? */ |
| 782 | return getc(f); /* ignore BOM and return next char */ |
| 783 | else /* no (valid) BOM */ |
| 784 | return c; /* return first character */ |
| 785 | } |
| 786 | |
| 787 | |
| 788 | /* |