fix 𝕨•FLines𝕩 with invalid elements in 𝕩

This commit is contained in:
dzaima 2023-08-13 03:51:06 +03:00
parent a175c48104
commit df56f6b2fc
2 changed files with 7 additions and 4 deletions

View File

@ -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'));
}

View File

@ -76,6 +76,9 @@ f ← •ReBQN{repl⇐"none"} ⋄ !6≡•Type F "⇐"
!"•file.Lines: 𝕩 must be a list" % "testfile.bqn" •FLines 22<"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 12
!"Expected character" % "testfile.bqn" •FChars "abcd"
!"•file.Chars: 𝕩 must be a list of characters" % "testfile.bqn" •FChars <'a'
!"Expected character" % "testfile.bqn" •FBytes "abcd"