Skip to content

Commit 0ae3939

Browse files
GillesDuvertGiloo
andauthored
Closes #1981 (#1982)
Co-authored-by: Giloo <gildas@localhost>
1 parent c19e323 commit 0ae3939

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

src/basic_fun_jmg.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,8 @@ namespace lib {
711711
return fileStatus; // OPEN tag is init to zero (SpDByte::GetInstance())
712712

713713
struct stat buffer;
714-
int status = fstat(lun, &buffer);
714+
// int status = //status will be bad on the units used by SPAWN, UNIT=XXX; Do not check status
715+
stat(actUnit.Name().c_str(), &buffer);
715716

716717
fileStatus->InitTag("NAME", DStringGDL( actUnit.Name()));
717718
fileStatus->InitTag("OPEN", DByteGDL( 1));

src/io.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ void AnyStream::Close() {
202202
std::basic_streambuf<char> *current=ifStream->std::ios::rdbuf();
203203
ifStream->std::ios::rdbuf(old_rdbuf_in);
204204
old_rdbuf_in=nullptr;
205+
ispipe = false;
205206
}
206207
ifStream->close();
207208
ifStream->clear();
@@ -211,6 +212,7 @@ void AnyStream::Close() {
211212
std::basic_streambuf<char> *current=ofStream->std::ios::rdbuf();
212213
ifStream->std::ios::rdbuf(old_rdbuf_out);
213214
old_rdbuf_out=nullptr;
215+
ispipe = false;
214216
}
215217
ofStream->close();
216218
ofStream->clear();
@@ -243,6 +245,7 @@ void AnyStream::OpenAsPipes(const std::string& name_, const std::ios_base::openm
243245
}
244246
old_rdbuf_in = ifStream->std::ios::rdbuf();
245247
ifStream->std::ios::rdbuf(in);
248+
ispipe=true;
246249
}
247250
if (mode_ & std::ios_base::out) {
248251
stdio_filebuf<char> * out = fileBufFromFD(pipeOutFd, std::ios_base::out);
@@ -256,6 +259,7 @@ void AnyStream::OpenAsPipes(const std::string& name_, const std::ios_base::openm
256259
}
257260
old_rdbuf_out = ofStream->std::ios::rdbuf();
258261
ofStream->std::ios::rdbuf(out);
262+
ispipe=true;
259263
}
260264
}
261265
#else
@@ -403,9 +407,11 @@ bool AnyStream::Eof() {
403407
if (ifStream != NULL) {
404408
ifStream->clear(); // clear old EOF
405409

406-
ifStream->peek(); // trigger EOF if at EOF
407-
408-
return ifStream->eof();
410+
if (ispipe) return true;
411+
else {
412+
ifStream->peek(); // trigger EOF if at EOF
413+
return ifStream->eof();
414+
}
409415
}
410416
if (igzStream != NULL) {
411417
igzStream->clear(); // clear old EOF

src/io.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class AnyStream
5555
{
5656
// GGH made all these public
5757
public:
58+
bool ispipe;
5859
std::fstream* ifStream;
5960
std::fstream* ofStream;
6061
igzstream* igzStream; // for gzip compressed input
@@ -63,7 +64,8 @@ class AnyStream
6364
std::basic_streambuf<char> *old_rdbuf_out;
6465
//public:
6566
AnyStream()
66-
: ifStream(NULL)
67+
: ispipe(false)
68+
, ifStream(NULL)
6769
, ofStream(NULL)
6870
, igzStream(NULL)
6971
, ogzStream(NULL)

src/print.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace lib {
7272
//
7373
//check lun is disguized tty as in scrn = filepath(/TERMINAL) & openw,lun,scrn,/more,/get_lun
7474
struct stat buffer;
75-
int status = fstat(lun, &buffer);
75+
int status = stat((fileUnits[ lun - 1].Name()).c_str(), &buffer);
7676
if (status == 0)
7777
is_a_tty = isatty(lun);
7878
}

0 commit comments

Comments
 (0)