-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set *errin* isTTY properly in package mode (-p) #2269
set *errin* isTTY properly in package mode (-p) #2269
Conversation
When running in package mode (-p), as used by xgap, GAP sets *errin* to be the same as *stdin*. It should at the same time set isTTY to be the same as for *stdin*.
Codecov Report
@@ Coverage Diff @@
## master #2269 +/- ##
==========================================
+ Coverage 70.57% 70.85% +0.27%
==========================================
Files 481 480 -1
Lines 253237 253236 -1
==========================================
+ Hits 178728 179435 +707
+ Misses 74509 73801 -708
|
src/system.c
Outdated
@@ -1936,6 +1936,7 @@ void InitSystem ( | |||
/* SyLineEdit = 1; | |||
SyCTRD = 1; */ | |||
syBuf[2].fp = fileno(stdin); syBuf[2].echo = fileno(stdout); | |||
syBuf[2].isTTY = syBuf[0].isTTY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is not "obviously" right. If we really "know" that syBuf[0]
refers to stdin/stdout, i'd rather copy all three values from it.
Or else, use isatty
directly, i.e. syBuf[2].isTTY = isatty(syBuf[2].fp);
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with your comment. To expand a little, the line added and preceding line should read either as:
syBuf[2].fp = syBuf[0].fp; syBuf[2].echo = syBuf[0].echo;
syBuf[2].isTTY = syBuf[0].isTTY;
or else as:
syBuf[2].fp = fileno(stdin); syBuf[2].echo = fileno(stdout);
syBuf[2].isTTY = (isatty(syBuf[2].fp) && ttyname(syBuf[2].fp) != NULL);
The former one seems a little more correct to me, but the latter is a bit more conservative. In the former case, the next line in the code (setting syBuf[3].fp) should probably also be changed to a similar style. I'm not sure if it should also set syBuf[3].echo or not. The code at the top of the init routine is a little inconsistent in that respect.
Note that the ttyname check in the latter solution mirrors the check for isTTY earlier in the code.
I'll try and edit the proposed patch for the less conservative solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either of the two solutions would be fine by me (assuming they both "work" for you, i.e. solve your original problem).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually tested both (including sending an ACK in a break loop), and both seemed to work. Neither seems likely to cause any new problems.
I edited the pull request to match the first solution. (Let me know if I did it incorrectly.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; but when merging, I'd squash thos into a single commit
When running in package mode (-p), as used by xgap, GAP sets *errin* to be the same as *stdin*. It should at the same time set isTTY to be the same as for *stdin*.
When running in package mode (-p), as used by xgap, GAP
sets errin to be the same as stdin. It should at the same
time also set the isTTY property of errin to be the same as
that for stdin.