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.


On Feb 28 14:31, Corinna Vinschen wrote:
> [CC Hans]
> 
> On Feb 28 11:14, Takashi Yano wrote:
> > On Thu, 27 Feb 2020 18:03:47 +0000
> > Jon Turney wrote:
> > > > +#define wpbuf_put(x) \
> > > > +  wpbuf[wpixput++] = x; \
> > > > +  if (wpixput > WPBUF_LEN) \
> > > > +    wpixput--;
> > > > +
> > > 
> > > So I think either the macro need it contents contained by a 'do { ... } 
> > > while(0)',  or that instance of it needs to be surrounded by braces, to 
> > > do what you intend.
> > 
> > Thanks for the advice. Fortunately, "if" statement does not
> > cause a problem even if it is accidentally executed outside
> > "else" block in this case.
> > 
> > Hans,
> > as for making a patch for this issue, may I leave it to you
> > because you are already working on it? 
> > 
> > -- 
> > Takashi Yano <takashi.yano@nifty.ne.jp>

What about an inline function instead?

diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 64e12b8320a1..6c3e33818aca 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -63,10 +63,14 @@ static struct fhandler_base::rabuf_t con_ra;
 static unsigned char wpbuf[WPBUF_LEN];
 static int wpixput;
 static unsigned char last_char;
-#define wpbuf_put(x) \
-  wpbuf[wpixput++] = x; \
-  if (wpixput > WPBUF_LEN) \
+
+static inline void
+wpbuf_put (unsigned char x)
+{
+  wpbuf[wpixput++] = x;
+  if (wpixput > WPBUF_LEN)
     wpixput--;
+}
 
 static void
 beep ()


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

Attachment: signature.asc
Description: PGP signature


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