Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src add t_putws



details:   https://anonhg.NetBSD.org/src/rev/2c7a79e6e953
branches:  trunk
changeset: 580910:2c7a79e6e953
user:      christos <christos%NetBSD.org@localhost>
date:      Sun May 15 21:10:52 2005 +0000

description:
add t_putws

diffstat:

 include/wchar.h               |    7 +-
 lib/libterm/Makefile          |    6 +-
 lib/libterm/shlib_version     |    4 +-
 lib/libterm/termcap.3         |   12 ++-
 lib/libterm/termcap_private.h |    4 +-
 lib/libterm/tputs.c           |   18 ++--
 lib/libterm/tputws.c          |  163 ++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 195 insertions(+), 19 deletions(-)

diffs (truncated from 353 to 300 lines):

diff -r 7f22fa605ee7 -r 2c7a79e6e953 include/wchar.h
--- a/include/wchar.h   Sun May 15 21:01:34 2005 +0000
+++ b/include/wchar.h   Sun May 15 21:10:52 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wchar.h,v 1.23 2005/05/14 23:51:42 christos Exp $      */
+/*     $NetBSD: wchar.h,v 1.24 2005/05/15 21:10:52 christos Exp $      */
 
 /*-
  * Copyright (c)1999 Citrus Project,
@@ -184,6 +184,11 @@
     _BSD_VA_LIST_);
 int vwscanf(const wchar_t * __restrict, _BSD_VA_LIST_);
 #endif
+#if defined(_NETBSD_SOURCE)
+struct tinfo;
+int t_putws(struct tinfo *, const wchar_t *, int, void (*)(wchar_t, void *),
+    void *);
+#endif
 __END_DECLS
 
 #ifndef WEOF
diff -r 7f22fa605ee7 -r 2c7a79e6e953 lib/libterm/Makefile
--- a/lib/libterm/Makefile      Sun May 15 21:01:34 2005 +0000
+++ b/lib/libterm/Makefile      Sun May 15 21:10:52 2005 +0000
@@ -1,18 +1,18 @@
-#      $NetBSD: Makefile,v 1.28 2002/09/27 21:37:54 thorpej Exp $
+#      $NetBSD: Makefile,v 1.29 2005/05/15 21:11:13 christos Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=  yes
 
 LIB=   termcap
 CPPFLAGS+=-I${.CURDIR} -DCM_N -DCM_GT -DCM_B -DCM_D
-SRCS=  termcap.c tgoto.c tputs.c
+SRCS=  termcap.c tgoto.c tputs.c tputws.c
 
 MAN=   termcap.3
 MLINKS=        termcap.3 tgetent.3 termcap.3 tgetflag.3 termcap.3 tgetnum.3 \
        termcap.3 tgetstr.3 termcap.3 tgoto.3 termcap.3 tputs.3 \
        termcap.3 t_getent.3 termcap.3 t_getflag.3 termcap.3 t_getnum.3 \
        termcap.3 t_getstr.3 termcap.3 t_goto.3 termcap.3 t_puts.3 \
-       termcap.3 t_freent.3
+       termcap.3 t_freent.3 termcap.3 t_putws.3
 INCS=  termcap.h
 INCSDIR=/usr/include
 
diff -r 7f22fa605ee7 -r 2c7a79e6e953 lib/libterm/shlib_version
--- a/lib/libterm/shlib_version Sun May 15 21:01:34 2005 +0000
+++ b/lib/libterm/shlib_version Sun May 15 21:10:52 2005 +0000
@@ -1,5 +1,5 @@
-#      $NetBSD: shlib_version,v 1.8 2001/11/02 18:24:38 christos Exp $
+#      $NetBSD: shlib_version,v 1.9 2005/05/15 21:11:13 christos Exp $
 #      Remember to update distrib/sets/lists/base/shl.* when changing
 #
 major=0
-minor=5
+minor=6
diff -r 7f22fa605ee7 -r 2c7a79e6e953 lib/libterm/termcap.3
--- a/lib/libterm/termcap.3     Sun May 15 21:01:34 2005 +0000
+++ b/lib/libterm/termcap.3     Sun May 15 21:10:52 2005 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: termcap.3,v 1.30 2004/04/23 02:58:27 simonb Exp $
+.\"    $NetBSD: termcap.3,v 1.31 2005/05/15 21:11:13 christos Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)termcap.3  8.2 (Berkeley) 12/11/93
 .\"
-.Dd September 30, 1999
+.Dd May 15, 2005
 .Dt TERMCAP 3
 .Os
 .Sh NAME
@@ -81,6 +81,9 @@
 .Fn t_freent "struct tinfo *info"
 .Ft int
 .Fn t_setinfo "struct tinfo **info" "const char *entry"
+.In wchar.h
+.Ft int
+.Fn t_putws "struct tinfo *info" "const wchar_t *cp" "int affcnt" "void (*outc)(wchar_t, void *)" "void *args"
 .Sh DESCRIPTION
 These functions extract and use capabilities from a terminal capability data
 base, usually
@@ -417,6 +420,11 @@
 call, this object will be used to retrieve the
 .Sy pc
 attribute for the terminal.
+The function
+.Fn t_putws
+is similar to
+.Fn t_puts
+but it operates on a string of wide characters.
 The
 .Fa outc
 function is a pointer to a function that will be called by
diff -r 7f22fa605ee7 -r 2c7a79e6e953 lib/libterm/termcap_private.h
--- a/lib/libterm/termcap_private.h     Sun May 15 21:01:34 2005 +0000
+++ b/lib/libterm/termcap_private.h     Sun May 15 21:10:52 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: termcap_private.h,v 1.4 2001/11/02 18:24:20 christos Exp $     */
+/*     $NetBSD: termcap_private.h,v 1.5 2005/05/15 21:11:13 christos Exp $     */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn
@@ -44,3 +44,5 @@
                char *eptr;             /* pointer to the end of buffer */
        } *tbuf;
 };
+#define TMSPC10SIZE    15
+extern const short __tmspc10[TMSPC10SIZE];
diff -r 7f22fa605ee7 -r 2c7a79e6e953 lib/libterm/tputs.c
--- a/lib/libterm/tputs.c       Sun May 15 21:01:34 2005 +0000
+++ b/lib/libterm/tputs.c       Sun May 15 21:10:52 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tputs.c,v 1.22 2005/02/04 15:52:08 perry Exp $ */
+/*     $NetBSD: tputs.c,v 1.23 2005/05/15 21:11:13 christos Exp $      */
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)tputs.c    8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: tputs.c,v 1.22 2005/02/04 15:52:08 perry Exp $");
+__RCSID("$NetBSD: tputs.c,v 1.23 2005/05/15 21:11:13 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -43,6 +43,7 @@
 #include <termcap.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include "termcap_private.h"
 #undef ospeed
 
 /* internal functions */
@@ -53,8 +54,7 @@
  * character for each speed as returned by gtty.  Thus since 300
  * baud returns a 7, there are 33.3 milliseconds per char at 300 baud.
  */
-static const
-short  tmspc10[] = {
+const short __tmspc10[TMSPC10SIZE] = {
        0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5
 };
 
@@ -130,8 +130,7 @@
         */
        if (i == 0)
                return;
-       if (ospeed <= 0 ||
-           (size_t) ospeed >= (sizeof tmspc10 / sizeof tmspc10[0]))
+       if (ospeed <= 0 || ospeed >= TMSPC10SIZE)
                return;
 
        /*
@@ -141,7 +140,7 @@
         * Transmitting pad characters slows many
         * terminals down and also loads the system.
         */
-       mspc10 = tmspc10[ospeed];
+       mspc10 = __tmspc10[ospeed];
        i += mspc10 / 2;
        for (i /= mspc10; i > 0; i--)
                (void)(*outc)(PC);
@@ -196,8 +195,7 @@
         */
        if (i == 0)
                return 0;
-       if (ospeed <= 0 ||
-           (size_t) ospeed >= (sizeof tmspc10 / sizeof tmspc10[0]))
+       if (ospeed <= 0 || ospeed >= TMSPC10SIZE)
                return 0;
 
        /*
@@ -207,7 +205,7 @@
         * Transmitting pad characters slows many
         * terminals down and also loads the system.
         */
-       mspc10 = tmspc10[ospeed];
+       mspc10 = __tmspc10[ospeed];
        i += mspc10 / 2;
        for (i /= mspc10; i > 0; i--)
                (*outc)(pad[0], args);
diff -r 7f22fa605ee7 -r 2c7a79e6e953 lib/libterm/tputws.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libterm/tputws.c      Sun May 15 21:10:52 2005 +0000
@@ -0,0 +1,163 @@
+/*     $NetBSD: tputws.c,v 1.1 2005/05/15 21:11:13 christos Exp $      */
+
+/*
+ * Copyright (c) 1980, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)tputs.c    8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: tputws.c,v 1.1 2005/05/15 21:11:13 christos Exp $");
+#endif
+#endif /* not lint */
+
+#include <assert.h>
+#include <wctype.h>
+#include <wchar.h>
+#include <termcap.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "termcap_private.h"
+#undef ospeed
+
+/* internal functions */
+int _tputws_convert(const wchar_t **, int);
+
+/*
+ * The following array gives the number of tens of milliseconds per
+ * character for each speed as returned by gtty.  Thus since 300
+ * baud returns a 7, there are 33.3 milliseconds per char at 300 baud.
+ */
+extern short   ospeed;
+extern char    PC;
+
+int
+_tputws_convert(const wchar_t **ptr, int affcnt)
+{
+       int i = 0;
+
+       _DIAGASSERT(ptr != NULL);
+       _DIAGASSERT(*ptr != NULL);
+
+       /*
+        * Convert the number representing the delay.
+        */
+       if (iswdigit(**ptr)) {
+               do
+                       i = i * 10 + *(*ptr)++ - '0';
+               while (iswdigit(**ptr));
+       }
+       i *= 10;
+       if (*(*ptr) == '.') {
+               (*ptr)++;
+               if (iswdigit(**ptr))
+                       i += *(*ptr) - '0';
+               /*
+                * Only one digit to the right of the decimal point.
+                */
+               while (iswdigit(**ptr))
+                       (*ptr)++;
+       }
+
+       /*
+        * If the delay is followed by a `*', then
+        * multiply by the affected lines count.
+        */
+       if (*(*ptr) == '*')
+               (*ptr)++, i *= affcnt;
+
+       return i;
+}
+
+int
+t_putws(struct tinfo *info, const wchar_t *cp, int affcnt,
+    void (*outc)(wchar_t, void *), void *args)
+{
+       int i = 0;
+       size_t limit;
+       int mspc10;
+       char pad[2], *pptr;
+       char *pc;
+
+       /* XXX: info may be NULL ? */
+       /* cp is handled below */



Home | Main Index | Thread Index | Old Index