+ /* Keep the original LEX so we can print an error if the included file can't be opened. */
+ LEX* lfori = lf;
+
+ lf->state = lex_none;
+ lf = lex_open_file(lf, lf->str, lf->scan_error);
+ if (lf == NULL) {
+ berrno be;
+ scan_err2(lfori, _("Cannot open included config file %s: %s\n"),
+ lfori->str, be.bstrerror());
+ return T_ERROR;
+ }
+ break;
+ }
+ add_str(lf, ch);
+ break;
+ case lex_utf8_bom:
+ /* we only end up in this state if we have read an 0xEF
+ as the first byte of the file, indicating we are probably
+ reading a UTF-8 file */
+ if (ch == 0xBB && bom_bytes_seen == 1) {
+ bom_bytes_seen++;
+ } else if (ch == 0xBF && bom_bytes_seen == 2) {
+ token = T_UTF8_BOM;
+ lf->state = lex_none;
+ } else {
+ token = T_ERROR;
+ }
+ break;
+ case lex_utf16_le_bom:
+ /* we only end up in this state if we have read an 0xFF
+ as the first byte of the file -- indicating that we are
+ probably dealing with an Intel based (little endian) UTF-16 file*/
+ if (ch == 0xFE) {
+ token = T_UTF16_BOM;
+ lf->state = lex_none;
+ } else {
+ token = T_ERROR;
+ }
+ break;