+ modify test/picsmap.c to read xpm files.
+ modify package/debian/* to create documentation packages, so the
related files can be checked with lintian.
+ fix some typos in manpages (report/patch by Sven Joachim).
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
-------------------------------------------------------------------------------
--- $Id: NEWS,v 1.2841 2017/05/13 23:01:06 tom Exp $
+-- $Id: NEWS,v 1.2844 2017/05/21 00:24:14 tom Exp $
-------------------------------------------------------------------------------
This is a log of changes that ncurses has gone through since Zeyd started
Changes through 1.9.9e did not credit all contributions;
it is not possible to add this information.
+20170520
+ + modify test/picsmap.c to read xpm files.
+ + modify package/debian/* to create documentation packages, so the
+ related files can be checked with lintian.
+ + fix some typos in manpages (report/patch by Sven Joachim).
+
20170513
+ add test/picsmap.c to fill in some testing issues not met by dots.
The initial version reads X bitmap (".xbm") files.
-5:0:9 6.0 20170513
+5:0:9 6.0 20170520
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: dist.mk,v 1.1163 2017/05/07 17:07:55 tom Exp $
+# $Id: dist.mk,v 1.1164 2017/05/14 15:18:36 tom Exp $
# Makefile for creating ncurses distributions.
#
# This only needs to be used directly as a makefile by developers, but
# These define the major/minor/patch versions of ncurses.
NCURSES_MAJOR = 6
NCURSES_MINOR = 0
-NCURSES_PATCH = 20170513
+NCURSES_PATCH = 20170520
# We don't append the patch to the version, since this only applies to releases
VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>, <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
</PRE><H2><a name="h2-AUTHOR">AUTHOR</a></H2><PRE>
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************
- * @Id: curs_add_wch.3x,v 1.22 2017/05/06 14:01:26 tom Exp @
+ * @Id: curs_add_wch.3x,v 1.23 2017/05/20 14:45:24 Sven.Joachim Exp @
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
intended. But there are several possibilities, all with problems.
Unicode 6.0 (2010) does provide two lantern symbols: U+1F383 and
- U+1F3EE. Those were not availble in 2002, and are irrelevant since
- they lie outside the BMP and as a result are not generally avail-
- able in terminals. They are not storm lanterns, in any case.
+ U+1F3EE. Those were not available in 2002, and are irrelevant
+ since they lie outside the BMP and as a result are not generally
+ available in terminals. They are not storm lanterns, in any case.
Most <EM>storm</EM> <EM>lanterns</EM> have a tapering glass chimney (to guard against
tipping); some have a wire grid protecting the chimney.
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************
- * @Id: curs_mouse.3x,v 1.45 2017/05/06 17:29:26 tom Exp @
+ * @Id: curs_mouse.3x,v 1.46 2017/05/20 14:42:41 Sven.Joachim Exp @
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
SVr4 curses had support for the mouse in a variant of <STRONG>xterm</STRONG>. It is
mentioned in a few places, but with no supporting documentation:
- <STRONG>o</STRONG> the libcurses manual page lists functions for this feature which
+ <STRONG>o</STRONG> the "libcurses" manual page lists functions for this feature which
are prototyped in <STRONG>curses.h</STRONG>:
extern int mouse_set(long int);
extern void wmouse_position(WINDOW *, int *, int *);
extern unsigned long getmouse(void), getbmap(void);
- <STRONG>o</STRONG> the terminfo manual page lists capabilities for the feature
+ <STRONG>o</STRONG> the "terminfo" manual page lists capabilities for the feature
buttons btns BT Number of buttons on the mouse
get_mouse getm Gm Curses should get button events
- key_mouse kmous Km 0631, Mouse event has occured
+ key_mouse kmous Km 0631, Mouse event has occurred
mouse_info minfo Mi Mouse status information
req_mouse_pos reqmp RQ Request mouse position report
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG> and related pages whose names begin "form_" for detailed
descriptions of the entry points.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
http://invisible-island.net/ncurses/tctest.html
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
</PRE><H2><a name="h2-AUTHOR">AUTHOR</a></H2><PRE>
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>, <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
</PRE><H2><a name="h2-AUTHOR">AUTHOR</a></H2><PRE>
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG> and related pages whose names begin "menu_" for detailed
descriptions of the entry points.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
method of updating character screens with reasonable optimization.
This implementation is "new curses" (ncurses) and is the approved
replacement for 4.4BSD classic curses, which has been discontinued.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
The <STRONG>ncurses</STRONG> library emulates the curses library of System V Release 4
UNIX, and XPG4 (X/Open Portability Guide) curses (also known as XSI
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_variables.3x.html">curs_variables(3x)</A></STRONG>,
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
</PRE><H2><a name="h2-AUTHOR">AUTHOR</a></H2><PRE>
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>, <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>, <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
<EM>Terminfo</EM> describes terminals by giving a set of capabilities which they
have, by specifying how to perform screen operations, and by specifying
padding requirements and initialization sequences. This describes
- <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
</PRE><H3><a name="h3-Terminfo-Entry-Syntax">Terminfo Entry Syntax</a></H3><PRE>
<STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>, <STRONG><A HREF="captoinfo.1m.html">captoinfo(1m)</A></STRONG>, <STRONG><A HREF="infotocap.1m.html">infotocap(1m)</A></STRONG>, <STRONG><A HREF="toe.1m.html">toe(1m)</A></STRONG>, <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>,
<STRONG><A HREF="term.5.html">term(5)</A></STRONG>. <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
</PRE><H2><a name="h2-AUTHOR">AUTHOR</a></H2><PRE>
<STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>, <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>, <STRONG><A HREF="captoinfo.1m.html">captoinfo(1m)</A></STRONG>, <STRONG><A HREF="infotocap.1m.html">infotocap(1m)</A></STRONG>, <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG>ter-</STRONG>
<STRONG><A HREF="terminfo.5.html">minfo(5)</A></STRONG>.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
</PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
<STRONG><A HREF="clear.1.html">clear(1)</A></STRONG>, <STRONG>stty(1)</STRONG>, <STRONG><A HREF="tabs.1.html">tabs(1)</A></STRONG>, <STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>, <STRONG><A HREF="curs_termcap.3x.html">curs_termcap(3x)</A></STRONG>.
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
<STRONG>csh(1)</STRONG>, <STRONG>sh(1)</STRONG>, <STRONG>stty(1)</STRONG>, <STRONG><A HREF="curs_terminfo.3x.html">curs_terminfo(3x)</A></STRONG>, <STRONG>tty(4)</STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>,
<STRONG>ttys(5)</STRONG>, <STRONG>environ(7)</STRONG>
- This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170506).
+ This describes <STRONG>ncurses</STRONG> version 6.0 (patch 20170520).
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $Id: curs_add_wch.3x,v 1.22 2017/05/06 14:01:26 tom Exp $
+.\" $Id: curs_add_wch.3x,v 1.23 2017/05/20 14:45:24 Sven.Joachim Exp $
.TH curs_add_wch 3X ""
.ie \n(.g .ds `` \(lq
.el .ds `` ``
But there are several possibilities, all with problems.
.IP
Unicode 6.0 (2010) does provide two lantern symbols: U+1F383 and U+1F3EE.
-Those were not availble in 2002, and are irrelevant since
+Those were not available in 2002, and are irrelevant since
they lie outside the BMP and as a result are not generally available
in terminals.
They are not storm lanterns, in any case.
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $Id: curs_mouse.3x,v 1.45 2017/05/06 17:29:26 tom Exp $
+.\" $Id: curs_mouse.3x,v 1.46 2017/05/20 14:42:41 Sven.Joachim Exp $
+.ie \n(.g .ds `` \(lq
+.el .ds `` ``
+.ie \n(.g .ds '' \(rq
+.el .ds '' ''
.de NS
.ie \n(.sp
.el .sp .5
.NS
buttons btns BT Number of buttons on the mouse
get_mouse getm Gm Curses should get button events
-key_mouse kmous Km 0631, Mouse event has occured
+key_mouse kmous Km 0631, Mouse event has occurred
mouse_info minfo Mi Mouse status information
req_mouse_pos reqmp RQ Request mouse position report
.NE
-ncurses6 (6.0+20170513) unstable; urgency=low
+ncurses6 (6.0+20170520) unstable; urgency=low
* latest weekly patch
- -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 07 May 2017 13:07:55 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 14 May 2017 11:18:36 -0400
ncurses6 (5.9-20131005) unstable; urgency=low
-ncurses6 (6.0+20170513) unstable; urgency=low
+ncurses6 (6.0+20170520) unstable; urgency=low
* latest weekly patch
- -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 07 May 2017 13:07:55 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 14 May 2017 11:18:36 -0400
ncurses6 (5.9-20131005) unstable; urgency=low
-ncurses6 (6.0+20170513) unstable; urgency=low
+ncurses6 (6.0+20170520) unstable; urgency=low
* latest weekly patch
- -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 07 May 2017 13:07:55 -0400
+ -- Thomas E. Dickey <dickey@invisible-island.net> Sun, 14 May 2017 11:18:35 -0400
ncurses6 (5.9-20120608) unstable; urgency=low
updating character screens with reasonable optimization.
.
This package is used for testing ABI 6 with pthreads.
+
+Package: ncurses6-doc
+Section: doc
+Architecture: all
+Depends: groff-base
+Description: shared libraries for terminal handling
+ The ncurses library routines are a terminal-independent method of
+ updating character screens with reasonable optimization.
+ .
+ This package is used for testing ncurses6 document packaging.
+
+Package: ncurses6-doc-html
+Section: doc
+Architecture: all
+Description: shared libraries for terminal handling
+ The ncurses library routines are a terminal-independent method of
+ updating character screens with reasonable optimization.
+ .
+ This package is used for testing ncurses6 document packaging.
#export DH_VERBOSE=1
# packages
-PACKAGES.indep = # ncurses6-docs
+PACKAGES.indep = ncurses6-doc ncurses6-doc-html
PACKAGES.arch = ncurses6 ncursest6
# These are used for cross-compiling and for saving the configure script
--with-pthread
touch $@
+config-ncurses6-doc-stamp \
+config-ncurses6-doc-html-stamp: config-ncurses6-stamp
+ touch $@
+
build-ncurses6-stamp: config-ncurses6-stamp
dh_testdir
touch $@
+build-ncurses6-doc-stamp \
+build-ncurses6-doc-html-stamp: build-ncurses6-stamp
+ touch $@
+
install-ncurses6-stamp: build-ncurses6-stamp
dh_testdir
dh_testroot
touch $@
+install-ncurses6-doc-stamp: build-ncurses6-stamp
+ dh_testdir
+ dh_testroot
+ dh_installdirs $(verbose)
+ dh_prep $(verbose) -pncurses6-doc
+
+ $(MAKE) -C t/ncurses6 install.man DESTDIR=$(NCURSES6_DIR)-doc
+
+ touch $@
+
+HTML_DESTDIR=$(NCURSES6_DIR)-doc-html/usr/share/ncurses6-doc-html
+install-ncurses6-doc-html-stamp: build-ncurses6-stamp
+ dh_testdir
+ dh_testroot
+ dh_installdirs $(verbose)
+ dh_prep $(verbose) -pncurses6-doc-html
+
+ cd doc/html && find * -type d | sort | xargs -I{} mkdir -p -v $(HTML_DESTDIR)/{}
+ cd doc/html && find * -type f -name '*.html' | sort | xargs -I{} install -m 644 -p -v -T {} $(HTML_DESTDIR)/{}
+
+ touch $@
+
# Build architecture-independent files here.
binary-indep: install-indep
ifneq ($(PACKAGES.indep),)
-; $Id: mingw-ncurses.nsi,v 1.211 2017/05/07 17:07:55 tom Exp $\r
+; $Id: mingw-ncurses.nsi,v 1.212 2017/05/14 15:18:36 tom Exp $\r
\r
; TODO add examples\r
; TODO bump ABI to 6\r
!define VERSION_MAJOR "6"\r
!define VERSION_MINOR "0"\r
!define VERSION_YYYY "2017"\r
-!define VERSION_MMDD "0513"\r
+!define VERSION_MMDD "0520"\r
!define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD}\r
\r
!define MY_ABI "5"\r
Summary: shared libraries for terminal handling
Name: mingw32-ncurses6
Version: 6.0
-Release: 20170513
+Release: 20170520
License: X11
Group: Development/Libraries
Source: ncurses-%{version}-%{release}.tgz
Summary: shared libraries for terminal handling
Name: ncurses6
Version: 6.0
-Release: 20170513
+Release: 20170520
License: X11
Group: Development/Libraries
Source: ncurses-%{version}-%{release}.tgz
* authorization. *
****************************************************************************/
/*
- * $Id: picsmap.c,v 1.8 2017/05/14 01:26:30 tom Exp $
+ * $Id: picsmap.c,v 1.17 2017/05/21 00:22:22 tom Exp $
*
* Author: Thomas E. Dickey
*
* A little more interesting than "dots", read a simple image into memory and
* measure the time taken to paint it normally vs randomly.
*
- * TODO read xpm file
+ * TODO handle hex color-codes for xpm other than 3-bytes
+ * TODO read rgb.txt to handle xpm color names other than "None"
* TODO read "convert" via pipe (from ImageMagick)
* TODO write cells/second to stderr (or log)
* TODO write picture left-to-right/top-to-bottom
static bool in_curses = FALSE;
+static void
+free_data(char **data)
+{
+ free(data[0]);
+ free(data);
+}
+
+static void
+free_pics_head(PICS_HEAD * pics)
+{
+ free(pics->pairs);
+ free(pics->cells);
+ free(pics);
+}
+
/*
* Simplify reading xbm/xpm files by first making an array of lines. Blank
* lines are filtered out.
return value;
}
+static int match_c(const char *, const char *,...) GCC_SCANFLIKE(2,3);
+
+static const char *
+skip_s(const char *s)
+{
+ while (isspace(UChar(*s)))
+ s++;
+ return s;
+}
+
+static int
+match_c(const char *source, const char *pattern,...)
+{
+ const char *last_s = source + strlen(source);
+ va_list ap;
+ int ch;
+ int *ip;
+ char *cp;
+ long lv;
+
+ va_start(ap, pattern);
+
+ while (*pattern != '\0') {
+ ch = UChar(*pattern++);
+ /* blank in the pattern matches zero-or-more blanks in source */
+ if (isspace(ch)) {
+ source = skip_s(source);
+ continue;
+ }
+ /* %c, %d, %s are like sscanf except for special treatment of blanks */
+ if (ch == '%' && *pattern != '\0' && strchr("cds", *pattern)) {
+ bool found = FALSE;
+ ch = *pattern++;
+ switch (ch) {
+ case 'c':
+ cp = va_arg(ap, char *);
+ *cp = *source++;
+ break;
+ case 'd':
+ ip = va_arg(ap, int *);
+ lv = strtol(source, &cp, 0);
+ if (cp != 0 && cp != source) {
+ *ip = (int) lv;
+ source = cp;
+ } else {
+ goto finish;
+ }
+ break;
+ case 's':
+ cp = va_arg(ap, char *);
+ while (*source != '\0') {
+ ch = UChar(*source);
+ if (isspace(ch)) {
+ break;
+ } else if (found && (ch == *skip_s(pattern))) {
+ break;
+ } else {
+ *cp++ = *source++;
+ found = TRUE;
+ }
+ }
+ *cp = '\0';
+ break;
+ }
+ continue;
+ }
+ /* other characters are matched literally */
+ if (*source++ != ch) {
+ break;
+ }
+ }
+ finish:
+
+ va_end(ap);
+ if (source > last_s)
+ source = last_s;
+ return (*source || *pattern) ? 0 : 1;
+}
+
static PICS_HEAD *
parse_xbm(char **data)
{
return result;
}
+static PICS_HEAD *
+parse_xpm(char **data)
+{
+ int state = 0;
+ PICS_HEAD *result = typeCalloc(PICS_HEAD, 1);
+ int n;
+ int cells = 0;
+ int color = 0;
+ int cpp = 1; /* chars per pixel */
+ int num[6];
+ int which = 0;
+ char ch;
+ const char *cs;
+ char *s;
+ char buf[BUFSIZ];
+ char arg1[BUFSIZ];
+ char arg2[BUFSIZ];
+ char arg3[BUFSIZ];
+ char **list = 0;
+
+ for (n = 0; data[n] != 0; ++n) {
+ if (strlen(s = data[n]) >= sizeof(buf) - 1)
+ continue;
+ switch (state) {
+ case 0:
+ if (match_c(s, " /* XPM */ ")) {
+ state = 1;
+ }
+ break;
+ case 1:
+ if (match_c(s, " static char * %s [] = %c ", arg1, &ch) &&
+ ch == L_CURL) {
+ result->name = strdup(arg1);
+ state = 2;
+ }
+ break;
+ case 2:
+ if (match_c(s, " \" %d %d %d %d \" , ",
+ num + 0, num + 1, num + 2, num + 3) ||
+ match_c(s, " \" %d %d %d %d %d %d \" , ",
+ num + 0, num + 1, num + 2, num + 3, num + 4, num + 5)) {
+ result->wide = num[0];
+ result->high = num[1];
+ result->colors = num[2];
+ result->pairs = typeCalloc(PICS_PAIR, result->colors);
+ cells = (size_t) (result->wide * result->high);
+ result->cells = typeCalloc(PICS_CELL, cells);
+ list = typeCalloc(char *, result->colors);
+ cpp = num[3];
+ state = 3;
+ }
+ break;
+ case 3:
+ if (match_c(s, " \" %s %s %s \" , ", arg1, arg2, arg3)) {
+ ;
+ } else if (match_c(s, " \" %s %s \" , ", arg2, arg3)) {
+ strcpy(arg1, " ");
+ } else {
+ break;
+ }
+ while ((int) strlen(arg1) < cpp)
+ strcat(arg1, " ");
+ list[color] = strdup(arg1);
+ if (!strcmp(arg3, "None")) {
+ result->pairs[color].fg = -1;
+ } else if (*arg3 == '#') {
+ unsigned long value = strtoul(arg3 + 1, &s, 16);
+ result->pairs[color].fg = (int) value;
+ } else {
+ result->pairs[color].fg = 0; /* actually an error */
+ }
+ if (++color >= result->colors)
+ state = 4;
+ break;
+ case 4:
+ if (*(cs = skip_s(s)) == '"') {
+ ++cs;
+ while (*cs != '\0' && *cs != '"') {
+ int c;
+
+ for (c = 0; c < result->colors; ++c) {
+ if (!strncmp(cs, list[c], cpp)) {
+ result->cells[which].ch = list[c][0];
+ result->cells[which].fg = c;
+ break;
+ }
+ }
+
+ if (result->cells[which].ch == 0) {
+ result->cells[which].ch = '?';
+ result->cells[which].fg = 0;
+ }
+
+ if (++which >= cells) {
+ state = 5;
+ break;
+ }
+ for (c = cpp; c > 0; --c, ++cs) ;
+ }
+ }
+ break;
+ }
+ }
+
+ if (result && list) {
+ for (n = 0; n < result->colors; ++n)
+ free(list[n]);
+ free(list);
+ }
+
+ if (state < 5) {
+ free_pics_head(result);
+ result = 0;
+ }
+
+ return result;
+}
+
+static PICS_HEAD *
+read_picture(const char *filename, char **data)
+{
+ PICS_HEAD *pics;
+ if ((pics = parse_xbm(data)) == 0) {
+ if ((pics = parse_xpm(data)) == 0) {
+ free_data(data);
+ giveup("unexpected file-format for \"%s\"", filename);
+ }
+ }
+ return pics;
+}
+
static void
dump_picture(PICS_HEAD * pics)
{
printf("Name %s\n", pics->name);
printf("Size %dx%d\n", pics->high, pics->wide);
+ printf("Color\n");
+ for (y = 0; y < pics->colors; ++y) {
+ if (pics->pairs[y].fg < 0) {
+ printf(" %3d: %d\n", y, pics->pairs[y].fg);
+ } else {
+ printf(" %3d: #%06x\n", y, pics->pairs[y].fg);
+ }
+ }
for (y = 0; y < pics->high; ++y) {
for (x = 0; x < pics->wide; ++x) {
putchar(pics->cells[y * pics->wide + x].ch);
PICS_HEAD *pics;
if (data == 0) {
giveup("cannot read \"%s\"", argv[n]);
- } else if ((pics = parse_xbm(data)) == 0) {
+ }
+ if ((pics = read_picture(argv[n], data)) == 0) {
+ free_data(data);
giveup("unexpected file-format for \"%s\"", argv[n]);
- } else if (isatty(fileno(stdout))) {
+ }
+ if (isatty(fileno(stdout))) {
show_picture(pics);
} else {
dump_picture(pics);
}
+ free_data(data);
+ free_pics_head(pics);
}
} else {
usage();