This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 1/4] Cygwin: console: Add workaround for broken IL/DL in xterm mode.


Am 28.02.2020 um 14:31 schrieb Corinna Vinschen:
[CC Hans]

Thanks.  I wasn't subscribed to -patches so far.  Will change that.

Hans,
as for making a patch for this issue, may I leave it to you
because you are already working on it?

My patch was meant only as a minimally-invasive stop-gap fix, because the new GCC refused to compile the code as-is (it triggers a -Werror...). As such, sorry for hurting Brian's eyes. ;-)

I agree that this really should be an inline function. I barely speak C++, but even I have glimpsed that multi-statement macros are rightfully frowned upon in C++ circles.

I believe a more C++-like implementation would have to encapsulate wpbuf and wpixput into a helper class. This is what my _very_ rusty C++ allowed me to come up with:

// simple helper class to accumulate output in a buffer
// and send that to the console on request:
static class
{
private:
  unsigned char buf[WPBUF_LEN];
  int ixput;

public:
  inline void put(unsigned char x)
  {
    if (ixput < WPBUF_LEN)
      {
        buf[ixput++] = x;
      }
  };
  inline void empty() { ixput = 0; };
  inline void sendOut(HANDLE &handle, DWORD *wn) {
    WriteConsoleA (handle, buf, ixput, wn, 0);
  };
} wpbuf;

Using it works like this:

s/wpbuf_put/wpbuf.put/
s/wpixput = 0/wpbuf.empty()/
s/WriteConsoleA ( get_output_handle (), wpbuf, wpixput, \(&w*n\), 0 /wpbuf.sendOut( get_output_handle (), \1/g

Yes, sendOut() is ugly --- I didn't manage to find out how this class could access get_output_handle() itself, so I had to let its callers deal with that.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]