-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: rxvt-unicode-sixel
action: commit
revision:
path_from:
revision_from: f7ea9ba06169fdcb48dbe18f9f19e651dbdf3fbb:
path_to:
revision_to:

git.thebackupbox.net

rxvt-unicode-sixel

git://git.thebackupbox.net/rxvt-unicode-sixel

commit f7ea9ba06169fdcb48dbe18f9f19e651dbdf3fbb
Author: Emanuele Giaquinta <emanuele.giaquinta@gmail.com>
Date:   Mon May 30 18:39:04 2011 +0000

    Migrate to libecb.

diff --git a/MANIFEST b/MANIFEST

index c992a4ec9775d0552377b2ebaf7608afe86bd551..

index ..daa6ad9c4d44717f1f7022f8102bb6235d81c4fb 100644

--- a/MANIFEST
+++ b/MANIFEST
@@ -180,3 +180,5 @@ libev/ev_kqueue.c
 libev/ev_port.c
 libev/libev.m4

+libecb/ecb.h
+
diff --git a/src/Makefile.in b/src/Makefile.in

index fb2ba72624a27dd5cfe4fe129f67e9dfa05c43f3..

index ..d811b7907acb1d2863c5c23fccea746627fd2843 100644

--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -21,7 +21,7 @@ DEFS = @DEFS@
 LIBS = @LIBS@
 XINC = @X_CFLAGS@ @AFTERIMAGE_CFLAGS@ @PIXBUF_CFLAGS@
 XLIB = @X_LIBS@ @AFTERIMAGE_LIBS@ -lX11 @X_EXTRA_LIBS@ @PIXBUF_LIBS@
-COMPILE = $(CXX) -I.. -I$(srcdir) -I. -I$(srcdir)/../libev $(DEFS) $(CPPFLAGS) $(CXXFLAGS) $(XINC)
+COMPILE = $(CXX) -I.. -I$(srcdir) -I. -I$(srcdir)/../libev -I$(srcdir)/../libecb $(DEFS) $(CPPFLAGS) $(CXXFLAGS) $(XINC)
 LINK = @LINKER@ $(LDFLAGS)
 EXEEXT = @EXEEXT@
 PERLFLAGS = @PERLFLAGS@
diff --git a/src/background.C b/src/background.C

index 543974fec545551c0cbe2cd0740352b0fb81a405..

index ..974a7c38b46f9c63b0c82a7f8477a2b0eb94bd36 100644

--- a/src/background.C
+++ b/src/background.C
@@ -622,16 +622,16 @@ rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc,
   else
     return false;

-  width_r = rxvt_popcount (visual->red_mask);
-  width_g = rxvt_popcount (visual->green_mask);
-  width_b = rxvt_popcount (visual->blue_mask);
+  width_r = ecb_popcount32 (visual->red_mask);
+  width_g = ecb_popcount32 (visual->green_mask);
+  width_b = ecb_popcount32 (visual->blue_mask);

   if (width_r > 8 || width_g > 8 || width_b > 8)
     return false;

-  sh_r = rxvt_ctz (visual->red_mask);
-  sh_g = rxvt_ctz (visual->green_mask);
-  sh_b = rxvt_ctz (visual->blue_mask);
+  sh_r = ecb_ctz32 (visual->red_mask);
+  sh_g = ecb_ctz32 (visual->green_mask);
+  sh_b = ecb_ctz32 (visual->blue_mask);

   if (width > INT_MAX / height / bytes_per_pixel)
     return false;
@@ -648,7 +648,7 @@ rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc,
       return false;
     }

-  ximage->byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst;
+  ximage->byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;

   rowstride = gdk_pixbuf_get_rowstride (pixbuf);
   channels = gdk_pixbuf_get_n_channels (pixbuf);
@@ -1441,7 +1441,7 @@ shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c)
   rgba low;
   rgba high;
   int i;
-  int host_byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst;
+  int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;

   if (visual->c_class != TrueColor || ximage->format != ZPixmap) return;

diff --git a/src/command.C b/src/command.C

index b0bad8a46cafaccdf6d26e1c870fd5db2d5cc757..

index ..c088ea2cbc7ae35a93eaad88b11829d5dbc80496 100644

--- a/src/command.C
+++ b/src/command.C
@@ -2221,7 +2221,7 @@ rxvt_term::cmd_parse ()

   for (;;)
     {
-      if (expect_false (ch == NOCHAR))
+      if (ecb_unlikely (ch == NOCHAR))
         {
           seq_begin = cmdbuf_ptr;
           ch = next_char ();
@@ -2230,9 +2230,9 @@ rxvt_term::cmd_parse ()
             break;
         }

-      if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT))
+      if (ecb_likely (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT))
         {
-          if (expect_false (!seen_input))
+          if (ecb_unlikely (!seen_input))
             {
               seen_input = 1;
               // many badly-written programs (e.g. jed) contain a race condition:
@@ -2255,12 +2255,12 @@ rxvt_term::cmd_parse ()

           for (;;)
             {
-              if (expect_false (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)))
+              if (ecb_unlikely (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)))
                 break;

               *str++ = ch;

-              if (expect_false (ch == C0_LF || str >= eol))
+              if (ecb_unlikely (ch == C0_LF || str >= eol))
                 {
                   if (ch == C0_LF)
                     nlines++;
@@ -2348,7 +2348,7 @@ rxvt_term::next_char () NOTHROW
   while (cmdbuf_ptr < cmdbuf_endp)
     {
       // assume 7-bit to be ascii ALWAYS
-      if (expect_true ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b))
+      if (ecb_likely ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b))
         return *cmdbuf_ptr++;

       wchar_t wc;
@@ -2674,7 +2674,7 @@ rxvt_term::process_escape_seq ()
       case C1_NEL:		/* ESC E */
         {
           wchar_t nlcr[] = { C0_LF, C0_CR };
-          scr_add_lines (nlcr, ARRAY_LENGTH(nlcr), 1);
+          scr_add_lines (nlcr, ecb_array_length (nlcr), 1);
         }
         break;

@@ -2860,8 +2860,8 @@ rxvt_term::process_csi_seq ()
                 static const int pm_h[] = { 7, 25 };
                 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1015, 1049 };

-                process_terminal_mode ('h', 0, ARRAY_LENGTH(pm_h), pm_h);
-                process_terminal_mode ('l', 0, ARRAY_LENGTH(pm_l), pm_l);
+                process_terminal_mode ('h', 0, ecb_array_length (pm_h), pm_h);
+                process_terminal_mode ('l', 0, ecb_array_length (pm_l), pm_l);
               }
           break;
         }
@@ -3606,7 +3606,7 @@ rxvt_term::privcases (int mode, unsigned long bit)

 /* we're not using priv _yet_ */
 void
-rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg)
+rxvt_term::process_terminal_mode (int mode, int priv ecb_unused, unsigned int nargs, const int *arg)
 {
   unsigned int i, j;
   int state;
@@ -3677,7 +3677,7 @@ rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs,
       state = -1;

       /* basic handling */
-      for (j = 0; j < ARRAY_LENGTH(argtopriv); j++)
+      for (j = 0; j < ecb_array_length (argtopriv); j++)
         if (argtopriv[j].argval == arg[i])
           {
             state = privcases (mode, argtopriv[j].bit);
diff --git a/src/encoding.C b/src/encoding.C

index 335a832bb02a3b656e524b859b7d74f3ada368e2..

index ..909f06161bb177e2ecfa02de4390988e98e29c69 100644

--- a/src/encoding.C
+++ b/src/encoding.C
@@ -288,7 +288,7 @@ unicode_t
 rxvt_compose (unicode_t c1, unicode_t c2)
 {
   int l = 0;
-  int r = ARRAY_LENGTH(rxvt_compose_table) - 1;
+  int r = ecb_array_length (rxvt_compose_table) - 1;
   int m;

   while (r >= l)
diff --git a/src/init.C b/src/init.C

index 65e879f14e4339d497e05cb469b2892195796713..

index ..b2c605f1400c22239ef85aed86231cb21d33d8db 100644

--- a/src/init.C
+++ b/src/init.C
@@ -1506,7 +1506,7 @@ rxvt_term::create_windows (int argc, const char *const *argv)
 #endif
   };

-  XSetWMProtocols (dpy, top, protocols, ARRAY_LENGTH(protocols));
+  XSetWMProtocols (dpy, top, protocols, ecb_array_length (protocols));

 #if ENABLE_FRILLS
   if (rs[Rs_transient_for])
diff --git a/src/keyboard.C b/src/keyboard.C

index 9fbde630f3207ef5ed794299788309e006d4d520..

index ..00a5e8cead6b02f16ea25f6bf245febd95cd9019 100644

--- a/src/keyboard.C
+++ b/src/keyboard.C
@@ -80,8 +80,8 @@ static int
 compare_priority (keysym_t *a, keysym_t *b)
 {
   // (the more '1's in state; the less range): the greater priority
-  int ca = rxvt_popcount (a->state /* & OtherModMask */);
-  int cb = rxvt_popcount (b->state /* & OtherModMask */);
+  int ca = ecb_popcount32 (a->state /* & OtherModMask */);
+  int cb = ecb_popcount32 (b->state /* & OtherModMask */);

   if (ca != cb)
     return ca - cb;
diff --git a/src/rxvt.h b/src/rxvt.h

index 68d283f2e80613b607f825af6439aa1eaf70737c..

index ..98bacb53f667c1f943c98e6c6433ac5621e4fa3d 100644

--- a/src/rxvt.h
+++ b/src/rxvt.h
@@ -159,8 +159,8 @@ const char *     rxvt_basename                    (const char *str) NOTHROW;
 void             rxvt_vlog                        (const char *fmt, va_list arg_ptr) NOTHROW;
 void             rxvt_log                         (const char *fmt,...) NOTHROW;
 void             rxvt_warn                        (const char *fmt,...) NOTHROW;
-void             rxvt_fatal                       (const char *fmt, ...) THROW ((class rxvt_failure_exception)) NORETURN;
-void             rxvt_exit_failure                () THROW ((class rxvt_failure_exception)) NORETURN;
+void             rxvt_fatal                       (const char *fmt, ...) THROW ((class rxvt_failure_exception)) ecb_noreturn;
+void             rxvt_exit_failure                () THROW ((class rxvt_failure_exception)) ecb_noreturn;

 char           * rxvt_strtrim                     (char *str) NOTHROW;
 char          ** rxvt_strsplit                    (char delim, const char *str) NOTHROW;
@@ -669,7 +669,7 @@ typedef struct _mwmhints
 // return attributes defining the background, encoding doesn't matter
 // depends on RS_fgShift > RS_bgShift
 #define GET_BGATTR(x)                                      \
-  (expect_false ((x) & RS_RVid)                            \
+  (ecb_unlikely ((x) & RS_RVid)                            \
     ? (((x) & (RS_attrMask & ~RS_RVid))                    \
       | (((x) & RS_fgMask) >> (RS_fgShift - RS_bgShift)))  \
     : ((x) & (RS_attrMask | RS_bgMask)))
diff --git a/src/rxvtfont.C b/src/rxvtfont.C

index aba990a33ba5545fe4f3b1f286bb9f79e909275c..

index ..55d3a75ad5f5835709bfdf2562bff86d1f439632 100644

--- a/src/rxvtfont.C
+++ b/src/rxvtfont.C
@@ -927,7 +927,7 @@ rxvt_font_x11::load (const rxvt_fontprop &prop, bool force_prop)

   width = 1;

-  for (uint16_t *t = extent_test_chars + ARRAY_LENGTH(extent_test_chars); t-- > extent_test_chars; )
+  for (uint16_t *t = extent_test_chars + ecb_array_length (extent_test_chars); t-- > extent_test_chars; )
     {
       if (FROM_UNICODE (cs, *t) == NOCHAR)
         continue;
@@ -1249,7 +1249,7 @@ rxvt_font_xft::load (const rxvt_fontprop &prop, bool force_prop)

       int glheight = height;

-      for (uint16_t *t = extent_test_chars + ARRAY_LENGTH(extent_test_chars); t-- > extent_test_chars; )
+      for (uint16_t *t = extent_test_chars + ecb_array_length (extent_test_chars); t-- > extent_test_chars; )
         {
           FcChar16 ch = *t;

diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs

index ed4d7bc5865ec8410c9d938f50071ba80d9e2085..

index ..f450350517fdf810f2e814b995a13e109d4ff4c8 100644

--- a/src/rxvtperl.xs
+++ b/src/rxvtperl.xs
@@ -343,7 +343,7 @@ rxvt_perl_interp::init (rxvt_term *term)
           ""
           "use urxvt;"
         };
-        int argc = ARRAY_LENGTH(args);
+        int argc = ecb_array_length (args);
         char **argv = args;

         PERL_SYS_INIT3 (&argc, &argv, &environ);
@@ -790,7 +790,7 @@ BOOT:
 #   endif
   };

-  for (civ = const_iv + ARRAY_LENGTH(const_iv); civ-- > const_iv; )
+  for (civ = const_iv + ecb_array_length (const_iv); civ-- > const_iv; )
     newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
 }

@@ -1483,7 +1483,7 @@ rxvt_term::_resource (char *name, int index, SV *newval = 0)
 #	  undef reserve
         };

-        rs = rslist + ARRAY_LENGTH(rslist);
+        rs = rslist + ecb_array_length (rslist);

         if (*name)
           {
diff --git a/src/rxvttoolkit.C b/src/rxvttoolkit.C

index 6b3429957ebfec4dc44a55cf3ff07b39afd71b03..

index ..fe9932ba4fc0a7b6e8f001e0f2b2298489a796a1 100644

--- a/src/rxvttoolkit.C
+++ b/src/rxvttoolkit.C
@@ -451,7 +451,7 @@ bool rxvt_display::ref_init ()
   screen = DefaultScreen     (dpy);
   root   = DefaultRootWindow (dpy);

-  assert (ARRAY_LENGTH(xa_names) == NUM_XA);
+  assert (ecb_array_length (xa_names) == NUM_XA);
   XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa);

   XrmSetDatabase (dpy, get_resources (false));
@@ -736,9 +736,9 @@ rxvt_color::alloc (rxvt_screen *screen, const rgba &color)

   if (screen->visual->c_class == TrueColor)
     {
-      c.pixel = (color.r >> (16 - rxvt_popcount (screen->visual->red_mask  )) << rxvt_ctz (screen->visual->red_mask  ))
-              | (color.g >> (16 - rxvt_popcount (screen->visual->green_mask)) << rxvt_ctz (screen->visual->green_mask))
-              | (color.b >> (16 - rxvt_popcount (screen->visual->blue_mask )) << rxvt_ctz (screen->visual->blue_mask ));
+      c.pixel = (color.r >> (16 - ecb_popcount32 (screen->visual->red_mask  )) << ecb_ctz32 (screen->visual->red_mask  ))
+              | (color.g >> (16 - ecb_popcount32 (screen->visual->green_mask)) << ecb_ctz32 (screen->visual->green_mask))
+              | (color.b >> (16 - ecb_popcount32 (screen->visual->blue_mask )) << ecb_ctz32 (screen->visual->blue_mask ));

       return true;
     }
diff --git a/src/rxvtutil.C b/src/rxvtutil.C

index 30d4ee62861cd5003b2f1277f7b3aec4a2606908..

index ..5cc47015b02e132e855606cb397e4beba8241b67 100644

--- a/src/rxvtutil.C
+++ b/src/rxvtutil.C
@@ -26,33 +26,6 @@

 #include "rxvtutil.h"

-#if !HAVE_GCC_BUILTINS
-int rxvt_ctz (unsigned int x) CONST
-{
-  int r = 0;
-
-  x &= -x; // this isolates the lowest bit
-
-  if (x & 0xaaaaaaaa) r +=  1;
-  if (x & 0xcccccccc) r +=  2;
-  if (x & 0xf0f0f0f0) r +=  4;
-  if (x & 0xff00ff00) r +=  8;
-  if (x & 0xffff0000) r += 16;
-
-  return r;
-}
-
-int rxvt_popcount (unsigned int x) CONST
-{
-  x -=  (x >> 1) & 0x55555555;
-  x  = ((x >> 2) & 0x33333333) + (x & 0x33333333);
-  x  = ((x >> 4) + x) & 0x0f0f0f0f;
-  x *= 0x01010101;
-
-  return x >> 24;
-}
-#endif
-
 void *
 zero_initialized::operator new (size_t s)
 {
diff --git a/src/rxvtutil.h b/src/rxvtutil.h

index 7e9e0417deb5d621355ee06025e819e4419a1b8b..

index ..6109177c610c7891b26739a8fab74ae5e27f649c 100644

--- a/src/rxvtutil.h
+++ b/src/rxvtutil.h
@@ -4,36 +4,10 @@
 #include <cstdlib>
 #include <cstring>
 #include <inttypes.h>
+#include "ecb.h"

 using namespace std;

-#define ARRAY_LENGTH(v) (sizeof (v) / sizeof ((v)[0]))
-
-#define PP_CONCAT_(a, b) a ## b
-#define PP_CONCAT(a, b) PP_CONCAT_(a, b)
-#define PP_STRINGIFY_(a) #a
-#define PP_STRINGIFY(a) PP_STRINGIFY_(a)
-
-#define HAVE_GCC_BUILTINS (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ == 4))
-
-#if __GNUC__ >= 4
-# define rxvt_attribute(x) __attribute__(x)
-# define expect(expr,value)         __builtin_expect ((expr),(value))
-#else
-# define rxvt_attribute(x)
-# define expect(expr,value)         (expr)
-#endif
-
-// put into ifs if you are very sure that the expression
-// is mostly true or mostly false. note that these return
-// booleans, not the expression.
-#define expect_false(expr) expect ((expr) != 0, 0)
-#define expect_true(expr)  expect ((expr) != 0, 1)
-
-#define NORETURN rxvt_attribute ((noreturn))
-#define UNUSED   rxvt_attribute ((unused))
-#define CONST    rxvt_attribute ((const))
-
 // increases code size unless -fno-enforce-eh-specs
 #if __GNUC__
 # define NOTHROW
@@ -43,19 +17,6 @@ using namespace std;
 # define THROW(x) throw x
 #endif

-namespace byteorder {
-  static unsigned char e ()
-  {
-    const uint32_t u = 0x11223344;
-    return *(unsigned char *)&u;
-  }
-
-  static bool big_endian    () { return e () == 0x11;     };
-  static bool network       () { return big_endian ();    };
-  static bool little_endian () { return e () == 0x44;     };
-  static bool vax           () { return little_endian (); };
-};
-
 // various utility functions
 template<typename T, typename U> static inline T    min    (T  a, U b) { return a < (T)b ? a : (T)b; }
 template<typename T, typename U> static inline void min_it (T &a, U b) {    a = a < (T)b ? a : (T)b; }
@@ -96,17 +57,6 @@ rxvt_temp_buf (int len)
   return (T *)rxvt_temp_buf (len * sizeof (T));
 }

-// some bit functions, xft fuck me plenty
-#if HAVE_GCC_BUILTINS
-/* netbsd stupidly defines popcount itself and puts it into string.h */
-static inline int rxvt_ctz      (unsigned int x) { return __builtin_ctz      (x); }
-static inline int rxvt_popcount (unsigned int x) { return __builtin_popcount (x); }
-#else
-// count trailing zero bits and count # of one bits
-int rxvt_ctz      (unsigned int x) CONST;
-int rxvt_popcount (unsigned int x) CONST;
-#endif
-
 // in range including end
 #define IN_RANGE_INC(val,beg,end) \
   ((unsigned int)(val) - (unsigned int)(beg) <= (unsigned int)(end) - (unsigned int)(beg))
diff --git a/src/screen.C b/src/screen.C

index ea24c4856bbd7db17ee95af273f9a6a8830c0bd1..

index ..e75a38f32c286decf57adff0b07885fc9c2a060a 100644

--- a/src/screen.C
+++ b/src/screen.C
@@ -801,7 +801,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
     {
       c = (unicode_t)*str++; // convert to rxvt-unicodes representation

-      if (expect_false (c < 0x20))
+      if (ecb_unlikely (c < 0x20))
         if (c == C0_LF)
           {
             max_it (line->l, screen.cur.col);
@@ -830,7 +830,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
             continue;
           }

-      if (expect_false (
+      if (ecb_unlikely (
             checksel            /* see if we're writing within selection */
             && !ROWCOL_IS_BEFORE (screen.cur, selection.beg)
             && ROWCOL_IS_BEFORE (screen.cur, selection.end)
@@ -845,7 +845,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
           CLEAR_SELECTION ();
         }

-      if (expect_false (screen.flags & Screen_WrapNext))
+      if (ecb_unlikely (screen.flags & Screen_WrapNext))
         {
           scr_do_wrap ();

@@ -857,7 +857,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
         }

       // some utf-8 decoders "decode" surrogate characters: let's fix this.
-      if (expect_false (IN_RANGE_INC (c, 0xd800, 0xdfff)))
+      if (ecb_unlikely (IN_RANGE_INC (c, 0xd800, 0xdfff)))
         c = 0xfffd;

       // rely on wcwidth to tell us the character width, do wcwidth before
@@ -866,7 +866,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
       // locale.
       int width = WCWIDTH (c);

-      if (expect_false (charsets [screen.charset] == '0')) // DEC SPECIAL
+      if (ecb_unlikely (charsets [screen.charset] == '0')) // DEC SPECIAL
         {
           // vt100 special graphics and line drawing
           // 5f-7e standard vt100
@@ -889,7 +889,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
             }
         }

-      if (expect_false (screen.flags & Screen_Insert))
+      if (ecb_unlikely (screen.flags & Screen_Insert))
         scr_insdel_chars (width, INSERT);

       if (width != 0)
@@ -907,7 +907,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
           rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c));

           // if the character doesn't fit into the remaining columns...
-          if (expect_false (screen.cur.col > ncol - width && ncol >= width))
+          if (ecb_unlikely (screen.cur.col > ncol - width && ncol >= width))
             {
               if (screen.flags & Screen_Autowrap)
                 {
@@ -924,7 +924,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
           // due to wonderful coincidences everywhere else in this loop
           // we never have to check for overwriting a wide char itself,
           // only its tail.
-          if (expect_false (line->t[screen.cur.col] == NOCHAR))
+          if (ecb_unlikely (line->t[screen.cur.col] == NOCHAR))
             scr_kill_char (*line, screen.cur.col);

           line->touch ();
@@ -934,7 +934,7 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
               line->t[screen.cur.col] = c;
               line->r[screen.cur.col] = rend;

-              if (expect_true (screen.cur.col < ncol - 1))
+              if (ecb_likely (screen.cur.col < ncol - 1))
                 screen.cur.col++;
               else
                 {
@@ -947,10 +947,10 @@ rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW

               c = NOCHAR;
             }
-          while (expect_false (--width > 0));
+          while (ecb_unlikely (--width > 0));

           // pad with spaces when overwriting wide character with smaller one
-          for (int c = screen.cur.col; expect_false (c < ncol && line->t[c] == NOCHAR); c++)
+          for (int c = screen.cur.col; ecb_unlikely (c < ncol && line->t[c] == NOCHAR); c++)
             {
               line->t[c] = ' ';
               line->r[c] = rend;
@@ -2236,7 +2236,7 @@ rxvt_term::scr_refresh () NOTHROW
           // redraw one or more characters

           // seek to the beginning of wide characters
-          while (expect_false (stp[col] == NOCHAR && col > 0))
+          while (ecb_unlikely (stp[col] == NOCHAR && col > 0))
             --col;

           rend_t rend = srp[col];     /* screen rendition (target rendition) */
@@ -2284,7 +2284,7 @@ rxvt_term::scr_refresh () NOTHROW
           count -= i; /* dump any matching trailing chars */

           // sometimes we optimize away the trailing NOCHAR's, add them back
-          while (expect_false (i && text[count] == NOCHAR))
+          while (ecb_unlikely (i && text[count] == NOCHAR))
             count++, i--;

           /*
@@ -2294,7 +2294,7 @@ rxvt_term::scr_refresh () NOTHROW
           int back = bgcolor_of (rend); // desired background

           // only do special processing if any attributes are set, which is unlikely
-          if (expect_false (rend & (RS_baseattrMask | RS_Careful | RS_Sel)))
+          if (ecb_unlikely (rend & (RS_baseattrMask | RS_Careful | RS_Sel)))
             {
               bool invert = rend & RS_RVid;

@@ -2393,7 +2393,7 @@ rxvt_term::scr_refresh () NOTHROW
            */
           rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)];

-          if (expect_true (have_bg && back == Color_bg))
+          if (ecb_likely (have_bg && back == Color_bg))
             {
               // this is very ugly, maybe push it into ->draw?

@@ -2410,7 +2410,7 @@ rxvt_term::scr_refresh () NOTHROW
           else
             font->draw (*drawable, xpixel, ypixel, text, count, fore, back);

-          if (expect_false (rend & RS_Uline && font->descent > 1 && fore != back))
+          if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back))
             {
 #if ENABLE_FRILLS
               if (ISSET_PIXCOLOR (Color_underline))
diff --git a/src/xdefaults.C b/src/xdefaults.C

index 55f8092d2f2ff1cec2dd1b00f8018d5b8374a1bf..

index ..97d85d04d6f1f9a22b9fa466962133279568be7e 100644

--- a/src/xdefaults.C
+++ b/src/xdefaults.C
@@ -399,7 +399,7 @@ rxvt_usage (int type)
       case 0:			/* brief listing */
         rxvt_log (" [-help] [--help]\n");

-        for (col = 1, i = 0; i < ARRAY_LENGTH(optList); i++)
+        for (col = 1, i = 0; i < ecb_array_length (optList); i++)
           if (optList[i].desc != NULL)
             {
               int len = 0;
@@ -427,7 +427,7 @@ rxvt_usage (int type)
       case 1:			/* full command-line listing */
         rxvt_log (" [options] [-e command args]\n\nwhere options include:\n");

-        for (i = 0; i < ARRAY_LENGTH(optList); i++)
+        for (i = 0; i < ecb_array_length (optList); i++)
           if (optList[i].desc != NULL)
             {
               assert (optList[i].opt != NULL);
@@ -446,7 +446,7 @@ rxvt_usage (int type)
         rxvt_log (" [options] [-e command args]\n\n"
                    "where resources (long-options) include:\n");

-        for (i = 0; i < ARRAY_LENGTH(optList); i++)
+        for (i = 0; i < ecb_array_length (optList); i++)
           if (optList[i].kw != NULL)
             rxvt_log ("  %s: %*s%s\n",
                     optList[i].kw,
@@ -509,13 +509,13 @@ rxvt_term::get_options (int argc, const char *const *argv)
         rxvt_usage (0);

       /* feature: always try to match long-options */
-      for (entry = 0; entry < ARRAY_LENGTH(optList); entry++)
+      for (entry = 0; entry < ecb_array_length (optList); entry++)
         if ((optList[entry].kw && !strcmp (opt, optList[entry].kw))
             || (!longopt
                 && optList[entry].opt && !strcmp (opt, optList[entry].opt)))
           break;

-      if (entry < ARRAY_LENGTH(optList))
+      if (entry < ecb_array_length (optList))
         {
           if (optList_isReverse (entry))
             flag = !flag;
@@ -587,12 +587,12 @@ rxvt_term::get_options (int argc, const char *const *argv)
  *   value will be a string
  */
 int
-rxvt_define_key (XrmDatabase *database UNUSED,
-                 XrmBindingList bindings UNUSED,
+rxvt_define_key (XrmDatabase *database ecb_unused,
+                 XrmBindingList bindings ecb_unused,
                  XrmQuarkList quarks,
-                 XrmRepresentation *type UNUSED,
+                 XrmRepresentation *type ecb_unused,
                  XrmValue *value,
-                 XPointer closure UNUSED)
+                 XPointer closure ecb_unused)
 {
   int last;

@@ -665,7 +665,7 @@ rxvt_term::parse_keysym (const char *str, const char *arg)
     {
       unsigned int i;

-      for (i=0; i < ARRAY_LENGTH(keysym_vocabulary); ++i)
+      for (i=0; i < ecb_array_length (keysym_vocabulary); ++i)
         {
           if (strncmp (str, keysym_vocabulary [i].name, keysym_vocabulary [i].len) == 0)
             {
@@ -675,7 +675,7 @@ rxvt_term::parse_keysym (const char *str, const char *arg)
             }
         }

-      if (i >= ARRAY_LENGTH(keysym_vocabulary))
+      if (i >= ecb_array_length (keysym_vocabulary))
         return -1;

       if (*str == '-')
@@ -745,7 +745,7 @@ rxvt_term::extract_resources ()
   /*
    * Query resources for options that affect us
    */
-  for (int entry = 0; entry < ARRAY_LENGTH(optList); entry++)
+  for (int entry = 0; entry < ecb_array_length (optList); entry++)
     {
       int s;
       const char *kw = optList[entry].kw;

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 13:46:32 2024