Commit Graph

152 Commits

Author SHA1 Message Date
roy f236a33b97 libterminfo: cast to uint16/32_t before conversion to preserve negativity
Otherwise the ABSENT_NUMERIC(-1) or CANCELLED_NUMERIC(-2) will be converted
incorrectly to size_t and then down to uint16/32_t.
Picked up by DIAGNOSTIC builds.

Thanks to Michael Forney for the fix for PR lib/52293.
2020-06-21 15:05:23 +00:00
roy c3293770af terminfo(5): Numbre -> Number
Thanks to yukonbob
2020-06-05 22:08:10 +00:00
roy 877982596a terminfo: test strlcpy result against space free, not string length
riastradh@ yep, looks good.
2020-05-30 16:03:58 +00:00
martin b6924e8af2 Conditionalize a few more functions (hopefully fixing the build) 2020-04-05 14:53:39 +00:00
roy 9e387da605 terminfo: Add guards to optionally build parts of libterminfo
Reading from a database is now optional.
Compiling terminfo descriptions (including from $TERMINFO) is now optional.
Compat support is now optional.

This removes 17k on amd64 from the binary size, which allows it to be used
again on space constrained ramdisks.
2020-04-05 12:31:02 +00:00
roy 2d748ff84b terminfo: satisfy gcc bitching 2020-03-30 02:08:11 +00:00
roy 7f0204b5ec terminfo: v3 records should create v3 aliases 2020-03-30 00:09:06 +00:00
roy 5159a4258d terminfo: Promote a terminfo description to v3 when required
Blindly scanning the capabilities for # and checking that the following
number is bigger than a short isn't reliable because this could be a
string value:

SomeString#1234

Instead, if we process the numeric as normal and if it's value is too big
for v1 then promote the record to v3.
2020-03-29 21:46:22 +00:00
roy 59ea2669e1 terminfo: allow _ti_getname to convert from and to any version 2020-03-29 18:54:57 +00:00
roy 664218069f terminfo: Clamp numeric bounds to storage not API.
While here, fix decoding of numeric -1 stored in uint16_t to still be -1.
2020-03-29 18:32:45 +00:00
christos e2a9896bc4 PR/55118: Andreas Gustafsson: Oops, set the right flag variable. 2020-03-28 15:45:56 +00:00
roy 0b457be2fc terminfo: Add a comment for prior change. 2020-03-28 15:27:54 +00:00
roy 171093fef0 terminfo: use , as a record version delimiter rather than @
@ is allowed in a terminfo description, but a comma is not.
2020-03-28 15:25:53 +00:00
roy 96d0e34238 Whitespace 2020-03-28 15:23:33 +00:00
christos f5703f6ba1 support for older compilers 2020-03-28 02:38:15 +00:00
christos 1d30fdae10 Introduce a bunch of inline functions and utilities to avoid code duplication. 2020-03-27 17:39:53 +00:00
christos 3958d16a96 As described in tech-userlevel:
- Modify the writing code to only write entries in the new
  format for the terminal descriptions that require it.
- Store new format entries as <name>@v3
- Store old format entries with clamped values as <name> for
  backwards compatibility
- Lookup first <name>@v3 and then <name> if that is not found.
- Don't create terminfo2 anymore; old programs keep working with
  clamped entries, and new programs be able to use the wide
  fields with using the original db file.
2020-03-27 15:11:57 +00:00
roy aadfdb111b terminfo: promote numeric parameters from short to int
POSIX mandates implementations must support upto a short but may exceed it.
When NetBSD terminfo was implemented, no terminfo description used over
a short, but because ncurses has supported ints for some time, some now do.

Infact, such a terminfo description was imported where colour pairs for
screen-256color went up to 65536 which exposed a bug in the existing
implementation where it set to zero. Because the number might mean
something more than a range, we need to be able to store it accurately.

This requires a version bump because whilst the API hasn't changed thanks
to C int promotion, the ABI has. Also the underlying database structure
has changed as well - we now store the numeric paramter inside a uint32_t
field rather than a uint16_t one.
Whilst this change can still read the old style database, the old one
cannot read the new one and thus we now maintain the database as
terminfo2.cdb, leaving the old library and database alone so old programs
still work fine.

libcurses, libfrom, libmenu and libpanel have also been bumped to
accomoate this change.
2020-03-13 15:19:24 +00:00
roy 62c320f6cd terminfo: truncate numeric parameters to a short
Because that is what our API demands.
We should probably change to int when we next bump the API.
2020-03-12 14:52:04 +00:00
christos d97b323d0b Cast function pointers that take different arguments through void * 2019-10-03 18:02:05 +00:00
jakllsch 634d295103 fix typo in error message; database is spelled with one 'b' and three 'a's 2019-04-11 23:52:08 +00:00
uwe b42d6bc7c1 Fix pasto. 2018-10-10 21:09:58 +00:00
roy 7b8fbc2d04 terminfo: if $TERMINFO.cdb doesn't exist, try $TERMINFO
This allows this command sequence to work:
tic -o /tmp/foo foo
TERMINFO=/tmp/foo TERM=foo infocmp
2018-10-08 20:44:34 +00:00
abhinav 69d19b9c6c Remove tputs from NAME section since it is described in terminfo(3) 2017-10-22 16:44:51 +00:00
abhinav 6c258b9750 Add missing functions to the NAME section 2017-10-22 16:42:34 +00:00
roy 2e0a9a1da6 Improve the scope of some variables. 2017-05-16 12:03:41 +00:00
roy 8e374e1b75 Remove ticcmp and extend _ti_checkname so it can be used instead. 2017-05-16 11:16:37 +00:00
roy fc79bac804 Fix prior for multiple terminfo aliases. 2017-05-16 10:29:06 +00:00
roy 2b9f5c3f2c Instead of poking in the binary blob to work out if this is our terminal,
assume it is and load it.
Once loaded then check it's really for us.
This allows us to work out if the indexed alias entry is correct we
this was not checked previously.
2017-05-16 10:25:40 +00:00
roy 2678fcfdf5 Don't bother allocating space for the database name, just print
directly to the static buffer storage.
2017-05-16 09:19:48 +00:00
roy 3edb4adc61 Move pathbuf into the function where it's actually used. 2017-05-16 08:52:14 +00:00
roy 34c6060f1f Clean up some more warnings. 2017-05-04 09:46:30 +00:00
roy 04f58b4824 Clean up some compile warnings. 2017-05-04 09:42:23 +00:00
roy db8a6fb0b3 Fix some compile warnings. 2017-05-01 19:09:22 +00:00
roy ac826cc7fc Whitespace police. 2017-05-01 18:39:02 +00:00
roy 5b2b9b53e2 Whitespace, fit in 80 and extra braces for readability.
No functional change.
2017-04-20 08:34:23 +00:00
roy 5128a2ed79 POSIX says that use_env(3) must precede setupterm(3).
The former lives in curses.h, but the latter lives in term.h.

This is solved by moving the function to libterminfo.
Because the environment can affect the terminal capabilities for
lines and columns, it follows that the tty size should affect it to.
So move that code to libterminfo and adjust in libcurses.
2017-03-23 00:55:39 +00:00
roy d5c74a0225 Allow terminfo users to update flag and numeric capabilities as they do
strings.
2017-03-23 00:39:06 +00:00
roy c8a6d4546d Revert botched commit. 2017-03-23 00:36:37 +00:00
roy 8bf4334f27 term.h 2017-03-23 00:23:29 +00:00
roy a3b8817f64 Revert prior .... some ncurses application expect to be able to update
the terminal capabilities.
2017-03-23 00:17:57 +00:00
roy 0f7015d835 Ensure there is a terminal to return capabilities from. 2017-03-20 14:46:28 +00:00
roy 0a316e40f7 Warn about unprintable characters in capability strings. 2017-02-11 15:13:17 +00:00
roy 0fb82a6eaf Following a newline, strip leading whitespace from capability strings. 2017-02-11 14:57:15 +00:00
abhinav c8b491e821 Fix a typo. 2017-01-29 16:52:38 +00:00
roy ca57f21848 Correct terminfo variable pkey_norm to plab_norm. 2017-01-12 13:53:11 +00:00
roy 53035e70de Fix some off by one issues with arraycount ..thanks coypu. 2017-01-11 20:53:52 +00:00
christos ee97ae6abf off-by-one in memcpy. Found by ASAN (Carsten Kunze)
XXX: pullup 7.
2016-11-24 17:09:55 +00:00
christos 8b22ec00d4 - if we are freeing cur_term, set it to NULL.
- preserve and free "last" properly.

$ cat foo.c
#include <stdio.h>
#include <termcap.h>

int
main(void)
{
	tgetent(NULL, "dumb");
	tgetent(NULL, "network");
	tgetflag("so");
	return 0;
}
$ cc foo.c -lterminfo
$ MALLOC_OPTIONS=J ./a.out
Boom.

XXX: pullup-7
2016-04-01 19:59:08 +00:00
christos f5cb16e708 Always copy the area buffer, even when the length was the same
(from Rin Okuyama)
2015-11-26 01:03:22 +00:00