]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_insstr.c
ncurses 5.3
[ncurses.git] / ncurses / base / lib_insstr.c
index a2275f9457b60d279f8d95d6ed98952c06beccd0..347b35611c8f6e386f9a7477c30741eb9a0c0c19 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc.         *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -41,9 +41,9 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_insstr.c,v 1.14 2000/04/29 21:16:41 tom Exp $")
+MODULE_ID("$Id: lib_insstr.c,v 1.20 2002/09/28 16:22:34 tom Exp $")
 
-int
+NCURSES_EXPORT(int)
 winsnstr(WINDOW *win, const char *s, int n)
 {
     int code = ERR;
@@ -52,17 +52,19 @@ winsnstr(WINDOW *win, const char *s, int n)
     const unsigned char *str = (const unsigned char *) s;
     const unsigned char *cp;
 
-    T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbuf(s), n));
+    T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbufn(s,n), n));
 
     if (win && str) {
        oy = win->_cury;
        ox = win->_curx;
        for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
-           if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b')
-               _nc_waddch_nosync(win, (chtype) (*cp));
-           else if (is7bits(*cp) && iscntrl(*cp)) {
+           if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b') {
+               NCURSES_CH_T wch;
+               SetChar2(wch, *cp);
+               _nc_waddch_nosync(win, wch);
+           } else if (is7bits(*cp) && iscntrl(*cp)) {
                winsch(win, ' ' + (chtype) (*cp));
-               winsch(win, '^');
+               winsch(win, (chtype) '^');
                win->_curx += 2;
            } else {
                winsch(win, (chtype) (*cp));