mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 12:42:45 +08:00
parent
851f0bcfb3
commit
fa588db148
3
common.h
3
common.h
|
@ -59,6 +59,9 @@ typedef std::vector<wcstring> wcstring_list_t;
|
|||
*/
|
||||
#define BYTE_MAX 0xffu
|
||||
|
||||
/** BOM value */
|
||||
#define UTF8_BOM_WCHAR 0xFEFFu
|
||||
|
||||
/* Flags for unescape_string functions */
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -4205,7 +4205,7 @@ static int read_ni(int fd, const io_chain_t &io)
|
|||
acc.insert(acc.end(), buff, buff + c);
|
||||
}
|
||||
|
||||
const wcstring str = acc.empty() ? wcstring() : str2wcstring(&acc.at(0), acc.size());
|
||||
wcstring str = acc.empty() ? wcstring() : str2wcstring(&acc.at(0), acc.size());
|
||||
acc.clear();
|
||||
|
||||
if (fclose(in_stream))
|
||||
|
@ -4216,6 +4216,12 @@ static int read_ni(int fd, const io_chain_t &io)
|
|||
res = 1;
|
||||
}
|
||||
|
||||
/* Swallow a BOM (#1518) */
|
||||
if (! str.empty() && str.at(0) == UTF8_BOM_WCHAR)
|
||||
{
|
||||
str.erase(0, 1);
|
||||
}
|
||||
|
||||
parse_error_list_t errors;
|
||||
if (! parse_util_detect_errors(str, &errors, false /* do not accept incomplete */))
|
||||
{
|
||||
|
|
|
@ -113,4 +113,7 @@ try_unbalanced_block 'if false'
|
|||
"while" false; end
|
||||
"wh"'ile' false; "e"nd
|
||||
|
||||
# BOM checking (see #1518)
|
||||
echo \uFEFF"echo bom_test" | source
|
||||
|
||||
false
|
||||
|
|
|
@ -17,3 +17,4 @@ foo
|
|||
bar
|
||||
baz
|
||||
psub file was deleted
|
||||
bom_test
|
||||
|
|
Loading…
Reference in New Issue
Block a user