-
Notifications
You must be signed in to change notification settings - Fork 92
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
Work around missing TABX defines #263
Conversation
OpenBSD at least up to 7.2 didn't have them defined.
For any system, which was able to compile Even if some future versions of OpenBSD become POSIX compliant, it does not hurt to be compatible with not-so-bleeding-edge releases. |
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.
Where is TAB0 and TAB3 defined?
Does this work as expected when HAVE_TERMIOS_H is undefined?
I suspect |
@hs-viktor how does it look? |
@vdukhovni ping. |
If we're changing this, I'd very much want to see this move from an ADT to a set of Pattern Synonyms: -- | Output Mode bit fields
newtype TerminalMode = TerminalMode CUInt
pattern TAB0 :: TerminalMode
#ifdef TAB0
pattern TAB0 = TerminalMode (#const TAB0)
#else
pattern TAB0 = 0
#endif
pattern GeneralMode :: CUInt -> TerminalMode
pattern GeneralMode n = TerminalMode n
...
instance Semigroup TerminalMode where
(TerminalMode a) <> (TerminalMode b) = TerminalMode (a .|. b)
instance Monoid TerminalMode where
mempty = TerminalMode 0
hasModes :: TerminalMode -> TerminalMode -> Bool
hasModes (TerminalMode x) (TerminalMode m) = x /= 0 && (x .&. m) == x
... This is extensible without incompatible appearance of new constructors that causes incomplete pattern matches, deals with systems that return bits not known at compile time, and these values are more simply converted to the underlying integral values and used in various functions. The only thing that's a bit harder is So I'd much rather see this migrate to PatternSynonyms than dig the hole deeper. |
Pattern synonyms are even better, because the set of constructors will remain unconditional independently of a platform. @blackgnezdo do you have time to take a stab? Or maybe @vdukhovni would like to give it a go? |
This does look appealing but not without complications. The There's also this little matter that |
Another consideration is OpenBSD 7.3 will have |
I'm very keen to enable OpenBSD CI job asap, without waiting for future OpenBSD 7.3 to be available from Cirrus, so that we do not miss other potential regressions. It does not look like anyone has energy to pursue a solution via pattern synonyms, so I suggest we merge as is. |
@hs-viktor @vdukhovni just another ping. |
Noted, thanks. I'll make some time by Sunday at the latest. |
Given how small this PR is, and that the migration to PatternSynonyms is non-trivial, given the unfortunate representation we have now, I'm approving this PR as-is at present. The PatternSynonym work will have to be separate. |
No description provided.