diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 21e5f9be..30acc5c1 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -744,6 +744,13 @@ jobs: if [ "$out" != "$want" ]; then echo "FAIL(stdin blank line): stdout was:"; echo "$out"; exit 1 fi + # A UTF-8 BOM ahead of the first path, as a .NET or PowerShell caller + # on Windows writes, used to make the first input "no such input file". + out=$( { printf '\xEF\xBB\xBF'; printf '%s\n' a.txt b.txt c.txt; } | ./bin/nlp -ANA "$FIX" -WORK ./ -STDIN | tr -d '\r') + want=$(printf '%s\n' "first=1 last=0 dir=1 n=1" "first=0 last=0 dir=1 n=2" "first=0 last=1 dir=1 n=3") + if [ "$out" != "$want" ]; then + echo "FAIL(stdin BOM): stdout was:"; echo "$out"; exit 1 + fi echo "[stdin] one load, KB carried across inputs, last-file flag set at end of stream" - name: Non-ASCII punctuation in rules (#467) (Non-20.04) diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 40ab9e3c..25c5fe77 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -666,6 +666,13 @@ jobs: if [ "$out" != "$want" ]; then echo "FAIL(stdin blank line): stdout was:"; echo "$out"; exit 1 fi + # A UTF-8 BOM ahead of the first path, as a .NET or PowerShell caller + # on Windows writes, used to make the first input "no such input file". + out=$( { printf '\xEF\xBB\xBF'; printf '%s\n' a.txt b.txt c.txt; } | ./bin/Release/nlp.exe -ANA "$FIX" -WORK ./ -STDIN | tr -d '\r') + want=$(printf '%s\n' "first=1 last=0 dir=1 n=1" "first=0 last=0 dir=1 n=2" "first=0 last=1 dir=1 n=3") + if [ "$out" != "$want" ]; then + echo "FAIL(stdin BOM): stdout was:"; echo "$out"; exit 1 + fi echo "[stdin] one load, KB carried across inputs, last-file flag set at end of stream" - name: Non-ASCII punctuation in rules (#467) diff --git a/lite/nlp_engine.cpp b/lite/nlp_engine.cpp index 59c6d582..29f066b3 100644 --- a/lite/nlp_engine.cpp +++ b/lite/nlp_engine.cpp @@ -529,7 +529,13 @@ int NLP_ENGINE::analyzeStream( const char *space = " \t\r\n"; std::string line, held; long count = 0; + bool first = true; while (std::getline(in, line)) { + // A .NET or PowerShell caller on Windows writes a UTF-8 BOM ahead of + // the first line, which made the first path "no such input file". + if (first && line.compare(0, 3, "\xEF\xBB\xBF") == 0) + line.erase(0, 3); + first = false; size_t beg = line.find_first_not_of(space); if (beg == std::string::npos) break; // A blank line ends the stream, like EOF. diff --git a/nlp/main.cpp b/nlp/main.cpp index 76d9628f..ffea0e85 100644 --- a/nlp/main.cpp +++ b/nlp/main.cpp @@ -15,7 +15,7 @@ All rights reserved. #include "lite/nlp_engine.h" #include "version.h" -#define NLP_ENGINE_VERSION "4.2.45" +#define NLP_ENGINE_VERSION "4.2.46" bool cmdReadArgs(int, _TCHAR *argv[], _TCHAR *&, _TCHAR *&, _TCHAR *&, _TCHAR *&, bool &, bool &, bool &, bool &, bool &, bool &, int &, bool &, bool &, _TCHAR *&, double &); void cmdHelpargs(_TCHAR *);