KNF
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 24 Aug 1992 00:51:34 +0000 (16:51 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 24 Aug 1992 00:51:34 +0000 (16:51 -0800)
SCCS-vsn: lib/libcurses/addbytes.c 5.5

usr/src/lib/libcurses/addbytes.c

index 124a0b2..b93948b 100644 (file)
 
 #ifndef lint
 static char sccsid[] = "@(#)addbytes.c 5.5 (Berkeley) %G%";
 
 #ifndef lint
 static char sccsid[] = "@(#)addbytes.c 5.5 (Berkeley) %G%";
-#endif /* not lint */
+#endif /* not lint */
 
 
-# include      "curses.ext"
+#include <curses.h>
+
+#define        SYNCH_IN        {y = win->_cury; x = win->_curx;}
+#define        SYNCH_OUT       {win->_cury = y; win->_curx = x;}
 
 /*
 
 /*
- *     This routine adds the character to the current position
- *
+ * waddbytes --
+ *     Add the character to the current position in the given window.
  */
 waddbytes(win, bytes, count)
  */
 waddbytes(win, bytes, count)
-reg WINDOW     *win;
-reg char       *bytes;
-reg int                count;
+       register WINDOW *win;
+       register char *bytes;
+       register int count;
 {
 {
-#define        SYNCH_OUT()     {win->_cury = y; win->_curx = x;}
-#define        SYNCH_IN()      {y = win->_cury; x = win->_curx;}
-       reg int         x, y;
-       reg int         newx;
+       static char blanks[] = "        ";
+       register int c, newx, x, y;
 
 
-       SYNCH_IN();
-# ifdef FULLDEBUG
-       fprintf(outf, "ADDBYTES('%c') at (%d, %d)\n", c, y, x);
-# endif
+       SYNCH_IN;
+#ifdef DEBUG
+       __TRACE("ADDBYTES('%c') at (%d, %d)\n", c, y, x);
+#endif
        while (count--) {
        while (count--) {
-           register int c;
-           static char blanks[] = "        ";
-
-           c = *bytes++;
-           switch (c) {
-             case '\t':
-                   SYNCH_IN();
-                   if (waddbytes(win, blanks, 8-(x%8)) == ERR) {
-                       return ERR;
-                   }
-                   SYNCH_OUT();
-                   break;
+               c = *bytes++;
+               switch (c) {
+               case '\t':
+                       SYNCH_IN;
+                       if (waddbytes(win, blanks, 8 - (x % 8)) == ERR)
+                               return (ERR);
+                       SYNCH_OUT;
+                       break;
 
 
-             default:
-# ifdef FULLDEBUG
-                   fprintf(outf, "ADDBYTES: 1: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]);
-# endif
-                   if (win->_flags & _STANDOUT)
-                           c |= _STANDOUT;
-                   {
-# ifdef        FULLDEBUG
-                           fprintf(outf, "ADDBYTES(%0.2o, %d, %d)\n", win, y, x);
-# endif
-                           if (win->_y[y][x] != c) {
-                                   newx = x + win->_ch_off;
-                                   if (win->_firstch[y] == _NOCHANGE) {
-                                           win->_firstch[y] =
-                                                           win->_lastch[y] = newx;
-                                   } else if (newx < win->_firstch[y])
-                                           win->_firstch[y] = newx;
-                                   else if (newx > win->_lastch[y])
+               default:
+#ifdef DEBUG
+       __TRACE("ADDBYTES: 1: y = %d, x = %d, firstch = %d, lastch = %d\n",
+           y, x, win->_firstch[y], win->_lastch[y]);
+#endif
+                       if (win->_flags & _STANDOUT)
+                               c |= _STANDOUT;
+#ifdef DEBUG
+       __TRACE("ADDBYTES(%0.2o, %d, %d)\n", win, y, x);
+#endif
+                       if (win->_y[y][x] != c) {
+                               newx = x + win->_ch_off;
+                               if (win->_firstch[y] == _NOCHANGE)
+                                       win->_firstch[y] =
                                            win->_lastch[y] = newx;
                                            win->_lastch[y] = newx;
-# ifdef FULLDEBUG
-                                   fprintf(outf, "ADDBYTES: change gives f/l: %d/%d [%d/%d]\n",
-                                           win->_firstch[y], win->_lastch[y],
-                                           win->_firstch[y] - win->_ch_off,
-                                           win->_lastch[y] - win->_ch_off);
-# endif
-                           }
-                   }
-                   win->_y[y][x++] = c;
-                   if (x >= win->_maxx) {
-                           x = 0;
-    newline:
-                           if (++y >= win->_maxy)
-                                   if (win->_scroll) {
-                                           SYNCH_OUT();
-                                           scroll(win);
-                                           SYNCH_IN();
-                                           --y;
-                                   }
-                                   else
-                                           return ERR;
-                   }
-# ifdef FULLDEBUG
-                   fprintf(outf, "ADDBYTES: 2: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]);
-# endif
-                   break;
-             case '\n':
-                   SYNCH_OUT();
-                   wclrtoeol(win);
-                   SYNCH_IN();
-                   if (!NONL)
-                           x = 0;
-                   goto newline;
-             case '\r':
-                   x = 0;
-                   break;
-             case '\b':
-                   if (--x < 0)
-                           x = 0;
-                   break;
-           }
-    }
-    SYNCH_OUT();
-    return OK;
+                               else if (newx < win->_firstch[y])
+                                       win->_firstch[y] = newx;
+                               else if (newx > win->_lastch[y])
+                                       win->_lastch[y] = newx;
+#ifdef __TRACE
+       __TRACE("ADDBYTES: change gives f/l: %d/%d [%d/%d]\n",
+           win->_firstch[y], win->_lastch[y], win->_firstch[y] - win->_ch_off,
+           win->_lastch[y] - win->_ch_off);
+#endif
+                       }
+                       win->_y[y][x++] = c;
+                       if (x >= win->_maxx) {
+                               x = 0;
+newline:                       if (++y >= win->_maxy)
+                                       if (win->_scroll) {
+                                               SYNCH_OUT;
+                                               scroll(win);
+                                               SYNCH_IN;
+                                               --y;
+                                       } else
+                                               return (ERR);
+                       }
+#ifdef DEBUG
+       __TRACE("ADDBYTES: 2: y = %d, x = %d, firstch = %d, lastch = %d\n",
+           y, x, win->_firstch[y], win->_lastch[y]);
+#endif
+                       break;
+               case '\n':
+                       SYNCH_OUT;
+                       wclrtoeol(win);
+                       SYNCH_IN;
+                       if (!NONL)
+                               x = 0;
+                       goto newline;
+               case '\r':
+                       x = 0;
+                       break;
+               case '\b':
+                       if (--x < 0)
+                               x = 0;
+                       break;
+               }
+       }
+       SYNCH_OUT;
+       return (OK);
 }
 }