X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fpathlist.c;h=e14c1877aaa549f807ebbd781682a0d9e20f16a3;hb=ea914185bfdd6d2a000a341566f4dbbb7ecc2319;hp=3bfec2ef062687b1810cf65a8eb3c6ff348c3fd5;hpb=d9675dd5814394373d9871c6e9b7b35325b3d21d;p=wimlib diff --git a/src/pathlist.c b/src/pathlist.c index 3bfec2ef..e14c1877 100644 --- a/src/pathlist.c +++ b/src/pathlist.c @@ -90,6 +90,7 @@ read_utf8_file_contents(const tchar *path, tchar **buf_ret, size_t *buflen_ret) int ret; char *buf_utf8; size_t bufsize_utf8; + size_t offset_utf8; tchar *buf_tstr; size_t bufsize_tstr; @@ -97,7 +98,15 @@ read_utf8_file_contents(const tchar *path, tchar **buf_ret, size_t *buflen_ret) if (ret) return ret; - ret = utf8_to_tstr(buf_utf8, bufsize_utf8, &buf_tstr, &bufsize_tstr); + /* Ignore UTF-8 BOM. */ + if (bufsize_utf8 >= 3 && (u8)buf_utf8[0] == 0xef && + (u8)buf_utf8[1] == 0xbb && (u8)buf_utf8[2] == 0xbf) + offset_utf8 = 3; + else + offset_utf8 = 0; + + ret = utf8_to_tstr(buf_utf8 + offset_utf8, bufsize_utf8 - offset_utf8, + &buf_tstr, &bufsize_tstr); FREE(buf_utf8); if (ret) return ret; @@ -181,6 +190,8 @@ read_path_list_file(const tchar *listfile, if (ret) return ret; + buf[buflen++] = T('\n'); + ret = parse_path_list_file(buf, buflen, paths_ret, num_paths_ret); if (ret) { FREE(buf);