From df56f6b2fce7cc4c2e2cf2bd84ef8e18c0299340 Mon Sep 17 00:00:00 2001 From: dzaima Date: Sun, 13 Aug 2023 03:51:06 +0300 Subject: [PATCH] =?UTF-8?q?fix=20=F0=9D=95=A8=E2=80=A2FLines=F0=9D=95=A9?= =?UTF-8?q?=20with=20invalid=20elements=20in=20=F0=9D=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/sysfn.c | 8 ++++---- test/cases/system.bqn | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index 88be265f..f7294c4d 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -757,13 +757,13 @@ B flines_c1(B d, B x) { } B flines_c2(B d, B w, B x) { if (isAtm(x) || RNK(x)!=1) thrM("•file.Lines: 𝕩 must be a list"); - B nl, s = emptyCVec(); + B s = emptyCVec(); usz ia = IA(x); SGet(x) for (u64 i = 0; i < ia; i++) { - nl = Get(x, i); - if (isAtm(s) || RNK(s)!=1) thrM("•file.Lines: Elements of 𝕩 must be lists of characters"); - s = vec_join(s, nl); + B l = Get(x, i); + if (isAtm(l) || RNK(l)!=1) thrM("•file.Lines: Elements of 𝕩 must be lists of characters"); + s = vec_join(s, l); //if (windows) s = vec_add(s, m_c32('\r')); TODO figure out whether or not this is a thing that should be done s = vec_addN(s, m_c32('\n')); } diff --git a/test/cases/system.bqn b/test/cases/system.bqn index fe6b1fa7..69d8f9ed 100644 --- a/test/cases/system.bqn +++ b/test/cases/system.bqn @@ -76,6 +76,9 @@ f ← •ReBQN{repl⇐"none"} ⋄ !6≡•Type F "⇐" !"•file.Lines: 𝕩 must be a list" % "testfile.bqn" •FLines 2‿2⥊<"abcd" !"•file.Lines: 𝕩 must be a list" % "testfile.bqn" •file.Lines <"abcd" +!"•file.Lines: Elements of 𝕩 must be lists of characters" % "testfile.bqn" •FLines "abcd" +!"Expected character" % "testfile.bqn" •FLines ⋈"ab"‿"cd" +!"Expected character" % "testfile.bqn" •FLines ⋈1‿2 !"Expected character" % "testfile.bqn" •FChars ⋈"abcd" !"•file.Chars: 𝕩 must be a list of characters" % "testfile.bqn" •FChars <'a' !"Expected character" % "testfile.bqn" •FBytes ⋈"abcd"