Commit Graph

18315 Commits

Author SHA1 Message Date
christos fcf85103b4 More WIDECHAR elimination (Ingo Schwarze) 2016-04-09 18:43:17 +00:00
dholland eb0c9743f2 _SC_PAGESIZE is not the page size; it's a symbolic code for retrieving
the page size.
2016-04-07 06:21:48 +00:00
christos ee5f11c12c pretty-print link addresses. 2016-04-06 18:04:58 +00:00
roy cdda39d7e5 Revert prior, no idea why it was causing me problems, but it no longer does. 2016-04-06 11:07:58 +00:00
wiz 54920d4dc7 Drop trailing whitespace. 2016-04-06 08:18:35 +00:00
christos 7ffce30f1b revert part of previous; not needed. 2016-04-06 04:09:10 +00:00
christos a071bd3ff9 - clarify si_signo difference for waitid and wait6 as per POSIX.
- implement it.
- document WIFCONTINUED
2016-04-06 03:50:03 +00:00
dholland 3f5237a6a3 improve usage 2016-04-06 03:38:31 +00:00
roy da98c8b8e3 Stop calling reallocarr and just do the same bounds checking but without
messing around with copying pointers which was causing ssh to crash.
2016-04-05 15:01:26 +00:00
christos d6b67564a6 some ports need <sys/wait.h> 2016-04-04 22:14:38 +00:00
christos cacc57bfc6 catch up with p_xstat split. 2016-04-04 21:08:44 +00:00
martin 53a4b022d2 For the benefit of compilers not using our native C runtime environment,
install a "sysident.o" file providing the note identifying NetBSD
executables (and marking the currently installed version).
2016-04-04 18:29:07 +00:00
wiz 386cb828c3 Use more markup, fix a typo. 2016-04-04 13:13:09 +00:00
christos eb687c986e simplify 2016-04-03 01:49:51 +00:00
christos aad157eb21 add idtype.h to mklintstub and say who generates it. 2016-04-03 00:48:29 +00:00
christos 406ebcd6ac userland bits for wait6/waitid. 2016-04-03 00:19:42 +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
msaitoh 43e79b977e Add malloc.conf.5 (link to jemalloc.3). 2016-04-01 12:37:48 +00:00
martin a13d81e5df No fenv for m68k with SOFTFLOAT for now - so at least it builds. 2016-03-30 07:44:06 +00:00
martin a49d73fd0a Drop fixxfdi.c for m68k (where double == long double and this isn't needed
but causes duplicate symbols with softfloat, if compiling MKSOFTFLOAT=yes)
2016-03-30 07:25:33 +00:00
skrll e4a98f388f crt0-common.c is miscompiled by gcc 5.3 on evbarm with -O2 so use -O1. Do
this for all non-x86 arches.
2016-03-29 21:23:05 +00:00
martin 60de583e7a Avoid warnings (signed/unsigned comparision and unused variable) 2016-03-29 18:42:29 +00:00
mrg 19cbd6805c distinguish between partial and failed read, so that "read 0xffffffff bytes failed"
is not output..
2016-03-29 06:51:40 +00:00
mrg 09a7b9833f add a hack for GCC 5 and non-x86 platforms:
build crtbeginS.o with -O1 as GCC tries to be very smart with the
__DTOR_LIST__ as it believes it knows the size of the array at
compile time (which is not true until link time).  on SPARC and
MIPS, the result was emitting a call to 0.

technically, i believe that GCC isn't "wrong" to make this choice,
as the array is declared with a well-known initialiser size in the
crtbegin.c compilation unit, and we have noticed that the libgcc
version of this code has some hacks added, most likely to avoid
being bitten by this optimisation.


this makes sshd work for me on earm and sparc with GCC 5.
2016-03-27 00:03:06 +00:00
martin 1d9390077f Do not store FP registers in softfloat userland 2016-03-26 11:57:32 +00:00
martin 6e8af743d4 Make sure to define __SOFT_FP__ when building a SOFTFLOAT userland 2016-03-26 07:31:11 +00:00
riastradh bec9c2fe3c KNF 2016-03-25 22:13:23 +00:00
christos 4e541d85ca Start removing the WIDECHAR ifdefs; building without it has stopped working
anyway. (Ingo Schwarze)
2016-03-23 22:27:48 +00:00
christos 62666ab4cc put back NUL check (Ingo Schwarze) 2016-03-22 01:38:17 +00:00
christos 6b5dea1b27 Fix reversed condition in tty_end() (Ingo Schwarze)
Also don't succeed if calling setup twice.
2016-03-22 01:34:32 +00:00
wiz 1b0989ebef Sort errors. Improve markup. 2016-03-20 20:09:49 +00:00
skrll 3593a88925 Update {read,write}fpsr to work everywhere 2016-03-20 14:22:46 +00:00
christos 4f0a81a7d2 Save and restore all the registers we need instead of playing tricks and
"knowing" which registers the compiler clobbers. gcc-5.3 clobbers both
rcx and rdx...
2016-03-19 21:27:38 +00:00
dholland 71d3320a40 Sync documentation of struct ktr_header with reality:
- there is a ktr_version field
   - the ordering of ktr_type and ktr_version is byte-order dependent
   - ktr_time is now a timespec, not a timeval
   - there's now a ktr_lid field
   - there is no such thing as a ktr_buf field and it's certainly not
     a caddr_t.

XXX: I would appreciate it if someone who knows how this stuff works
XXX: could review this file in case it's still lying in some more
XXX: subtle way.
2016-03-19 17:15:13 +00:00
dholland 02cda16070 Update documented prerequisite includes. PR 50633 and PR 50634.
Remove sys/uio.h, and swap sys/param.h for sys/types.h as sys/ktrace.h
depends on MAXCOMLEN.

Bump date; first time since 1993.
2016-03-19 17:05:36 +00:00
ginsbach bec9db1ba3 Use the correct upper bounds for the types array. The correct upper
bound is typecnt not timecnt.  Now perpetual 'standard' time zones
will work correctly as they have a typecnt of 1 but a timecnt of 0.
2016-03-18 12:41:25 +00:00
nros 71f379ad51 Added ldexpl to ldexp manpage since it is missing.
Also added ldexpf manpage link since it is missing.
2016-03-17 18:29:58 +00:00
christos 3ae9c71097 undo the dso protected for clang 2016-03-17 17:38:14 +00:00
wiz 310b2e7c40 Fix typo, add whitespace for better formatting, bump date for previous. 2016-03-17 09:44:56 +00:00
wiz 7230ee2fa7 Bump date for previous. 2016-03-17 09:43:38 +00:00
riastradh dcfb17cada strtod yields ERANGE for below-subnormal magnitudes, not underflow.
For a floating-point computation, in the language of IEEE 754,
`underflow' means the output was rounded and is too small to be
represented *normally*.

There are many nonzero floating-point numbers to which the exact
output may have been rounded -- namely subnormals.  The condition
under which strtod returns ERANGE for small magnitudes is when the
magnitude of the exact result is so small it is rounded to zero, not
even to a subnormal.

While here, use parallel language about large magnitudes instead of
the (albeit correct) word `overflow', to avoid temptation to treat
`underflow' as the opposite notion with zero instead of infinity.
2016-03-17 03:26:15 +00:00
mrg 25c9b8d685 don't build libmudflap* for GCC 5.3.
also, disable libasan here as well (for now).
2016-03-17 00:09:47 +00:00
nros cf57e34dd1 Add fabsl to the manpage describing the fabs functions. 2016-03-17 00:00:44 +00:00
christos 1417657ee3 change static to volatile. 2016-03-16 22:32:32 +00:00
christos 9dca99590e Avoid setjmp clobbering. 2016-03-16 21:38:22 +00:00
nros ccbaa1faff Add modfl to the modf manpage, the link to modfl was already there but the
content was missing.
2016-03-15 15:29:19 +00:00
christos e4c8546a4c Sync with 2016b 2016-03-15 15:16:01 +00:00
christos d7904a2801 PR/50937: Henning Petersen: Fix subnormal printf for long double x86. From
FreeBSD PR 85080.
2016-03-13 19:44:58 +00:00
mrg 8872ffd0f4 remove some more GCC 4.5 code. make GCC 5.3 be HAVE_GCC=53, so that,
for example, HAVE_GCC >= 48 works properly.
2016-03-13 01:06:51 +00:00
christos 23a151b438 PR/50919: David Binderman: Re-do all the debug stuff in a more sustainable way. 2016-03-09 19:47:13 +00:00
christos 2ebf0c7f4d Undo the __dso_protected hackery. 2016-03-08 04:00:11 +00:00
christos 95e3bb37fd PR/50907: David Binderman: Remove useless strlen()'s and memcpy()'s. 2016-03-07 14:35:39 +00:00
christos 72614d1ec0 Remove advertising clause. 2016-03-07 00:05:20 +00:00
christos d784c57539 PR/50880: David Binderman: Remove redundant code.
While here, fix all debugging formats.
2016-03-02 19:24:20 +00:00
aymeric 904c2b2729 protect __RCSID the same way other reg*.c files do, so that we can use this
file in libnbcompat
2016-02-29 22:10:13 +00:00
riastradh 17ca604b7a Skip libctf if MKCTF=no irrespective of MKDTRACE, for real.
Apparently this logic is copied in lib/Makefile and in
external/cddl/osnet/lib/Makefile.  Is the latter even used?
2016-02-29 20:59:35 +00:00
adam 2e943c33fb Fix buidling with MKPROFILE=no 2016-02-29 14:57:07 +00:00
christos e7df8a2227 convert to 2 clause 2016-02-29 00:54:19 +00:00
christos fc5e336abc remove 4 clause licenses. 2016-02-28 23:02:24 +00:00
joerg c550715550 Sync with changes in the profiling implementation of compiler-rt.
Switch to the "Linux" runtime, which is kind of misnamed for the mostly
ELF based implementation. Make sure to hook up the runtime source
only for the profile library as it uses constructors for the output
creation.
2016-02-27 19:08:23 +00:00
joerg 80b4ccd26e Long double complex multiplication and division helpers are needed on
Sparc64 and AArch64.
2016-02-27 19:06:56 +00:00
christos a1f44db787 PR/50863: John Hein: libedit el_end() messes up term settings if piped
Keep track if we initialized the tty, and only reset it if we did.
2016-02-27 18:13:21 +00:00
christos f98000db53 Add _SC_TIMER_MAX 2016-02-26 17:13:01 +00:00
christos 77126bb261 lint comment 2016-02-26 17:12:53 +00:00
wiz e1ae5a11b8 Use \- for minus sign, use Ev, use Er. 2016-02-25 14:59:22 +00:00
christos 1674f8e308 Fix el_{w,}getc documentation (Ingo Schwarze) 2016-02-24 19:45:48 +00:00
christos 7fc140d15b Fixes from OpenBSD via Ingo Schwarze:
1) Missing comma after tok_str in NAME.
   OpenBSD rev. 1.38 Sep 10, 2015 (schwarze)
2) Style: void in argument list.
   OpenBSD rev. 1.39 Sep 14, 2015 (schwarze)
3) English punctuation: stray comma.
   OpenBSD rev. 1.37 Mar 13, 2015 (jmc)
2016-02-24 18:28:54 +00:00
christos fe2cf455d0 Tuck in mbstate_t to the wide char version only to avoid exposing the zeroing
hack and doing it in the narrow case.
2016-02-24 17:20:01 +00:00
christos 94623721e8 Make the read_char function always take a wchar_t * argument (Ingo Schwarze) 2016-02-24 17:13:22 +00:00
christos 5f47d9bd72 A very simple, non-intrusive patch to fix a segfault (and a
functional error) in c_gets(), file chared.c.

Run any program using libedit in the default way.  At the el_[w]gets()
prompt, invoke ed-command (for example, in emacs mode, press the
escape key, then type the letter 'x').  You should see a ": " prompt.
Type the letter 'x' again.  Now press the backspace key a few times,
looking at the screen after each key press:

 - The 1st BS deletes the 'x'.
 - The 2nd BS deletes the blank after the prompt.
 - The 3rd BS deletes the colon of the prompt.
 - The 4th BS moves the cursor up one line.
 - The 5th BS gives me "Segmentation fault (core dumped)".

Depending on your platform, it might take a few more or a few less
backspaces for the buffer underrun to trigger the segfault, but
you should be able to hit it sooner or later no matter what.

Run the same program again, connect again and invoke ed-command again.
Now type: 'b', backspace, 'i', backspace, 'n', backspace, 'd', enter.
The "bind" command gets executed, even though you deleted what you
typed before hitting enter.

From Ingo Schwatze.
2016-02-24 14:29:21 +00:00
christos 7ba8c71b0d Get split el_getc and el_wgetc completely and call el_wgetc internally.
Change some character constants to they wide versions. (Ingo Schwarze)
2016-02-24 14:25:38 +00:00
christos ebc28b6bda PR/50133: Martin Husemann: Can't cache $TZ.
XXX: Pullup-7
2016-02-20 20:11:37 +00:00
riastradh 301aaf756f Note that SCHED_OTHER must have priority PRI_NONE. 2016-02-20 16:00:10 +00:00
christos f9c7ee08d4 PR/50822: David Binderman: Fix copy length. 2016-02-17 19:54:11 +00:00
christos be8ee66399 PR/50823: David Binderman: Limit scanf width 2016-02-17 19:52:20 +00:00
christos 22383670cc whitespace and header sorting changes (Ingo Schwarze). No functional changes. 2016-02-17 19:47:49 +00:00
christos e84df91e32 More header cleanups from Ingo Schwarze. 2016-02-16 22:53:14 +00:00
christos bc4f01ce82 - don't set _GNU_SOURCE. We are not supposed to make decisions for others.
- don't special-case wcsdup()
From Ingo Schwarze.
2016-02-16 19:29:51 +00:00
christos 23f3e7075d get rid of bool_t (Ingo Schwarze) 2016-02-16 19:11:25 +00:00
christos 747f681109 more include file cleanup (Ingo Schwarze) 2016-02-16 19:08:41 +00:00
christos a539b892c3 include errno.h 2016-02-16 15:54:15 +00:00
christos aefc1e4460 From Ingo Scharze:
Let "el.h" include everything needed for struct editline,
and don't include that stuff multiple times.  That also improves
consistency, also avoids circular inclusions, and also makes it
easier to follow what is going on, even though not quite as nice.
But it seems like the best we can do...
2016-02-16 15:53:48 +00:00
christos f09cb8c626 cleanup chartype.h includes (Ingo Schwarze) 2016-02-16 14:08:25 +00:00
christos c807fdff98 one more 2016-02-16 14:07:47 +00:00
christos 40850369f8 cleanup inclusion of histedit.h (Ingo Schwarze) 2016-02-16 14:06:05 +00:00
christos 89cffc1532 include explicitly errno.h since we use it. 2016-02-16 14:04:58 +00:00
christos 67bb823526 No need to include "sys.h" from here; it is included from config.h 2016-02-16 14:04:24 +00:00
christos d8252c8b23 attribute unused 2016-02-15 23:36:30 +00:00
christos 67b10d3e9e OpenBSD term.c rev. 1.7 2002/11/29 20:13:39 deraadt
spelling
2016-02-15 22:53:38 +00:00
christos f91f480498 OpenBSD readline.c rev. 1.14 2015/02/06 23:21:58 millert
use SIZE_MAX
2016-02-15 22:48:59 +00:00
christos 92b1772005 OpenBSD readline.c rev. 1.13 2015/01/13 08:33:12 reyk
rl_set_keyboard_input_timeout() for readline 4.2 compat
2016-02-15 21:58:37 +00:00
christos f8ee3c5528 OpenBSD eln.c rev. 1.3 2011/11/27 21:46:44 pascal
kill a C++-style comment
2016-02-15 21:56:35 +00:00
christos 42e2a4d875 Compile with WIDECHAR the same way the main Makefile does (Ingo Schwarze) 2016-02-15 21:38:07 +00:00
christos 1e12a8d1ca Don't free getline memory (Ingo Schwarze). 2016-02-15 21:35:52 +00:00
christos e8d0e8c012 forgot one fgetln define 2016-02-15 17:35:39 +00:00
christos 5390c8faa5 change tests for fgetln. 2016-02-15 16:14:39 +00:00
mbalmer 13a5a21897 Fix function name, no functional change.
Found by Travis Paul, (see PR/50786), thanks for reporting!
2016-02-15 15:56:33 +00:00
christos a7ab79fbe5 Use getline for better portability. 2016-02-15 15:53:45 +00:00
christos c0d16449e0 OpenBSD tokenizer.c rev. 1.8 2003/08/11 18:21:40 deraadt
don't increase amax on realloc failure
2016-02-15 15:37:20 +00:00
christos efeef4e587 OpenBSD term.c rev. 1.13 2009/12/11 18:58:59 jacekm
fix two memory leaks
2016-02-15 15:35:03 +00:00
christos c825536317 Change the test for the size of encoded buffer to include the NULL, from
OpenBSD; no functional change.
2016-02-15 15:30:50 +00:00
christos 5367da5f9e OpenBSD sig.c rev. 1.6 2001/12/06 04:26:00 deraadt
save and restore errno in signal handler
2016-02-15 15:29:25 +00:00
christos 87240809e9 Use fparseln to avoid newline hacks. 2016-02-15 15:26:48 +00:00
christos 70a36d136a use fparseln() to avoid needing to deal with missing \n in the last line
and also to handle comments automatically.
2016-02-15 15:18:01 +00:00
martin 4739ebdb41 Avoid strict alias violation for VAX 2016-02-15 11:07:48 +00:00
christos 2884af9fee From Ingo Schwarze:
el_getc() for the WIDECHAR case, that is, the version in eln.c.
For a UTF-8 locale, it is broken in four ways:

 1. If the character read is outside the ASCII range, the function
    does an undefined cast from wchar_t to char.  Even if wchar_t
    is internally represented as UCS-4, that is wrong and dangerous
    because characters beyond codepoint U+0255 get their high bits
    truncated, meaning that perfectly valid printable Unicode
    characters get mapped to arbitrary bytes, even the ASCII escape
    character for some Unicode characters.  But wchar_t need not
    be implemented in terms of UCS-4, so the outcome of this function
    is undefined for any and all input.

 2. If insufficient space is available for the result, the function
    fails to detect failure and returns garbage rather than -1 as
    specified in the documentation.

 3. The documentation says that errno will be set on failure, but
    that doesn't happen either in the above case.

 4. Even for ASCII characters, the results may be wrong if wchar_t
    is not using UCS-4.
2016-02-14 17:06:24 +00:00
christos f54e4f97f9 From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.

Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t.  Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not.  Consequently, the #define Int
is pointless.

Note that removing it is not gratuitious churn.  Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved.  It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t".  Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous.  Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c.  If WIDECHAR was defined, it printed an
Int = wint_t value with %c.  Fortunately, that bug only affects
debugging, not production.  The fix is contained in the patch.

With WIDECHAR, this doesn't change anything.  For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.

This only changes internal interfaces; public ones remain unchanged.
2016-02-14 14:49:34 +00:00
christos 61ee30487d From Ingo Schwartze:
Next step:  Remove #ifdef'ing in read_char(), in the same style
as we did for setlocale(3) in el.c.

A few remarks are required to explain the choices made.

 * On first sight, handling mbrtowc(3) seems a bit less trivial
   than handling setlocale(3) because its prototype uses the data
   type mbstate_t from <wchar.h>.  However, it turns out that
   "histedit.h" already includes <wchar.h> unconditionally (i don't
   like headers including other headers, but that ship has sailed,
   people are by now certainly used to the fact that including
   "histedit.h" doesn't require including <wchar.h> before), and
   "histedit.h" is of course included all over the place.  So from
   that perspective, there is no problem with using mbrtowc(3)
   unconditionally ever for !WIDECHAR.

 * However, <wchar.h> also defines the mbrtowc(3) prototype,
   so we cannot just #define mbrtowc away, or including the header
   will break.  It would also be a bad idea to porovide a local
   implementation of mbrtowc() and hope that it overrides the one
   in libc.  Besides, the required prototype is subtly different:
   While mbrtowc(3) takes "wchar_t *" as its first argument, we
   need a function that takes "Char *".  So unfortunately, we have
   to keep a ct_mbrtowc #define, at least until we can maybe get
   rid of "Char *" in the more remote future.

 * After getting rid of the #else clause in read_char(), we can
   pull "return 1;" into the default: clause.  After that, we can
   get rid of the ugly "goto again_lastbyte;" and just "break;".
   As a bonus, that also gets rid of the ugly CONSTCOND.

 * While here, delete the unused ct_mbtowc() from chartype.h.
2016-02-14 14:47:48 +00:00
christos cc7f005f24 Avoid c99 for now. 2016-02-12 17:23:21 +00:00
christos 57c556fd79 GC IGNORE_EXTCHARS and simplify code (Ingo Schwarze) 2016-02-12 15:36:08 +00:00
christos 0e1288d7c8 From Ingo Schwarze:
If CHARSET_IS_UTF8 is not set, read_char() is broken in a large
number of ways:

 1. The isascii(3) check can yield false positives.  If a string in
    an arbitrary encoding contains a byte in the range 0..127,
    that does not at all imply that it forms a character all by
    itself, and even less that it represents the same character
    as in ASCII.  Consequently, read_char() may return characters
    the user never typed.
    Even if the encoding is not state dependent, the assumption that
    bytes in the range 0..127 represent ASCII characters is broken.
    Consider UTF-16, for example.

 2. The reverse problem can also occur.  In an arbitrary encoding,
    there is no guarantee that a character that can be represented
    by ASCII is represented by a seven-bit byte, and even less by
    the same byte as in ASCII.
    Even for single-byte encodings, these assumptions are broken.
    Consider the ISO 646 national variants, for example.
    Consequently, the current code is insufficient to keep ASCII
    characters working even for single-byte encodings.

 3. The condition "++cbp != 1" can never trigger (because initially,
    cbp is 0, and the code can only go back up via the final goto,
    which has another cbp = 0 right before it) and it has no effect
    (because cbp isn't used afterwards).

 4. bytes = ct_mbtowc(cp, cbuf, cbp) is broken.  If this returns -1,
    the code assumes that is can just call mbtowc(3) again for later
    input bytes.  In some implementations, that may even be broken
    for state-independent encodings, but trying again after mbtowc(3)
    failure certainly produces completely erratic and meaningless
    results in state-dependent encodings.

 5. The assignment "*cp = (Char)(unsigned char)cbuf[0]" is
    completely bogus.  Even if the byte cbuf[0] represents a
    character all by itself, which it usually will not, whether
    or not the cast produces the desired result depends on the
    internal representation of wchar_t in the C library, which
    the application program can know nothing about.  Even for ASCII
    in the C/POSIX locale, an ASCII character other than '\0' ==
    L'\0' == 0 need not have the same numeric value as a char and
    as a wchar_t.

To summarize, this code only works if all of the following
conditions hold:

 - The encoding is a single-byte encoding.
 - ASCII is a subset of the encoding.
 - The implementation of mbtowc(3) in the C library does not
   require re-initialization after encoding errors.
 - The implementation of wchar_t in the C library uses the
   same numerical values as ASCII.

Otherwise, it silently produces wrong results.

The simplest way to fix this is to just use the same code as for
UTF-8 (right above).  Of course, that causes functional changes
but that shouldn't matter since current behaviour is undefined.

The patch below provides the following improvements:

 - It works for all stateless single-byte encodings, no matter
   whether they are somehow related to ASCII, no matter how
   mb[r]towc(3) are internally implemented, and no matter how
   wchar_t is internally represented.
 - Instead of producing unpredictable and definitely wrong
   results for non-UTF-8 multibyte characters, it behaves in
   a well-defined way: It aborts input processing, sets errno,
   and returns failure.
   Note that short of providing full support for arbitrary locales,
   it is impossible to do better.  We cannot know whether a given
   unsupported locale is state-dependent, and for a state-dependent
   locale, it makes no sense to retry parsing after an encoding
   error, so the best we can do is abort processing for *any*
   unsupported multi-byte character.
 - Note that single-byte characters in arbitrary state-independent
   locales still work, even in locales that may potentially also
   contain multibyte characters, as long as those don't occur in
   input.  I'm not sure whether any such locales exist in practice...

Tested with UTF-8 and C/POSIX on OpenBSD.  Also tested that in the
C/POSIX locale, non-ASCII bytes get through unmangled.  You may
wish to test with ISO-LATIN on NetBSD if NetBSD supports that.

----
Also use a constant for meta to avoid warnings.
2016-02-12 15:11:09 +00:00
christos 6af8d6733f - Add some more Char casts
- reduce ifdefs by providing empty defs for nls functions (Ingo Schwarze)
2016-02-11 19:21:04 +00:00
christos 28c0290948 remove unused wrapper (Ingo Schwarze) 2016-02-11 19:10:18 +00:00
christos 3ae44d1033 Remove utf8_islead() mbrtowc() handles this just fine (Ingo Schwarze) 2016-02-11 16:08:47 +00:00
christos 6b42622b31 UTF-8 fixes from Ingo Schwarze:
1. Assume that errno is non-zero when entering read_char()
    and that read(2) returns 0 (indicating end of file).
    Then, the code will clear errno before returning.
    (Obviously, the statement "errno = 0" is almost always
     a bug unless there is save_errno = errno right before it
     and the previous value is properly restored later,
     in all reachable code paths.)

 2. When encountering an invalid byte sequence, the code discards
    all following bytes until MB_LEN_MAX overflows; consider, for
    example, 0xc2 immediately followed by a few valid ASCII bytes.
    Three of those ASCII bytes will be discarded.

 3. On a POSIX system, EILSEQ will always be set after reading a
    valid (yes, valid, not invalid!) UTF-8 character.  The reason
    is that mbtowc(3) will first be called with a length limit
    (third argument) of 1, which will fail, return -1, and - on
    a POSIX system - set errno to EILSEQ.
    This third bug is mitigated a bit because i couldn't find any
    system that actually conforms to POSIX in this respect:  None
    of OpenBSD, NetBSD, FreeBSD, Solaris 11, and glibc set errno
    when an incomplete character is passed to mbtowc(3), even though
    that is required by POSIX.
    Anyway, that mbtowc(3) bug will be fixed at least in OpenBSD
    after release unlock, so it would be good to fix this bug in
    libedit before fixing the bug in mbtowc(3).

How can these three bugs be fixed?

 1. As far as i understand it, the intention of the bogus errno = 0
    is to undo the effects of failing system calls in el_wset(),
    sig_set(), and read__fixio() if the subsequent read(2) indicates
    end of file.  So, restoring errno has to be moved right after
    read__fixio().  Of course, neither 0 nor e is the right value
    to restore: 0 is wrong if errno happened to be set on entry, e
    would be wrong because if one read(2) fails but a second attempt
    succeeds after read__fixio(), errno should not be touched.  So,
    the errno to be restored in this case has to be saved before
    calling read(2) for the first time.

 2. Solving the second issue requires distinguishing invalid and
    incomplete characters, but that is impossible with the function
    mbtowc(3) because it returns -1 in both cases and sets errno
    to EILSEQ in both cases (once properly implemented).

    It is vital that each input character is processed right away.
    It is not acceptable to wait for the next input character before
    processing the previous one because this is an interactive
    library, not a batch system.  Consequently, the only situation
    where it is acceptable to wait for the next byte without first
    processing the previous one(s) is when the previous one(s) form
    an incomplete sequence that can be continued to form a valid
    character.

    Consequently, short of reimplementing a full UTF-8 state machine
    by hand, the only correct way forward is to use mbrtowc(3).
    Even then, care is needed to always have the state object
    properly initialized before using it, and to not discard a valid
    ASCII or UTF-8 lead byte if it happens to follow an invalid
    sequence.

 3. Fortunately, solution 2. also solves issue 3. as a side effect,
    by no longer using mbtowc(3) in the first place.
2016-02-08 17:18:43 +00:00
riastradh 5f6d9a7f5f Avoid shadowing global. 2016-02-06 19:33:07 +00:00
christos 8397619c32 PR/50695: coypu: ctrl-c in su password input breaks shell (bash, csh)
Always restore the tty settings.
2016-01-31 23:41:38 +00:00
bouyer 76e24fab26 Some NFS servers return RPC_PROGNOTREGISTERED instead of RPC_PROGVERSMISMATCH
when they don't support EXT_RQUOTAVERS but support RQUOTAVERS, so
retry with RQUOTAVERS for both RPC_PROGNOTREGISTERED and RPC_PROGVERSMISMATCH
return code.
Fix issue against a NetApp server reported by 6bone on current-users
2016-01-30 16:31:28 +00:00
christos ef555cf8bb Whitespace fix (Ingo Schwarze) 2016-01-30 15:05:27 +00:00
christos 7ce9f672f2 Fix misplaced parentheses (Ingo Schwarze) 2016-01-30 04:02:51 +00:00
christos 2f4394e35b add or1k 2016-01-29 21:38:35 +00:00
christos 65691b0e16 One macro is enough (Ingo Schwarze) 2016-01-29 19:59:11 +00:00
christos b466259f09 missing ia64. 2016-01-29 18:05:38 +00:00
christos bcffc9ad49 disable dso protected to work around binutils bug. 2016-01-29 15:18:08 +00:00
christos 22253bc332 use EXTERNAL_BINUTILS_SUBDIR 2016-01-26 17:47:35 +00:00
christos 3d64af45d4 PR/50711: David Binderman: Fix memory leak on error 2016-01-26 16:05:18 +00:00
christos e447d67050 prefer <sys/cpu.h> instead of <machine/cpu.h> 2016-01-25 18:14:04 +00:00
christos cb9f529bfe use __register_t 2016-01-25 16:44:42 +00:00
pooka d35b86acad Don't include <rump/rumpvnode_if.h> from rump.h. It's not needed
unless you're doing something special, but requires register_t.
Adjust the few places which actually need rumpvnode_if.h.
2016-01-25 11:45:57 +00:00
pooka 9331c560dd Move librumpuser compile-time options into the librumpuser source
directory.  Those options apply only for the in-tree implementation.
2016-01-25 00:24:23 +00:00
christos 013af8a944 use __register_t 2016-01-24 22:02:48 +00:00
christos f058dc0d02 vmparam.h is a kernel header. 2016-01-24 21:56:43 +00:00
gson 94608659ce Fix incorrect magic numbers in scaling. From FreeBSD commit 23397, by
way of Rin Okuyama.  Fixes PR lib/50698.
2016-01-24 20:34:30 +00:00
christos e2d23afe0f Undo previous; the lossage is more basic. 2016-01-24 16:47:32 +00:00
christos 470f85c6c7 Alpha needs _KERNTYPES 2016-01-24 16:27:38 +00:00
christos c4abdb423f mips needs _KMEMUSER for label_t in pcb.h 2016-01-24 16:07:48 +00:00
christos 29d18e37d5 cache stuff needs _KERNTYPES 2016-01-24 16:01:56 +00:00
christos 2e41c44fee Use namespace protected types. 2016-01-24 16:01:43 +00:00
christos 54d8ff1b7f assym.h needs _KERNTYPES 2016-01-24 15:55:34 +00:00
christos ba2647ff5b pmc_evid_, pmc_ctr_t etc are defined in <machine/types.h> but are not exposed
anymore by default since they violate the userland namespace. Either we
should create __pmc types, or a separate machine/pmc.h header.
2016-01-23 21:44:55 +00:00
christos ffeb8dbf4e Define _KERNTYPES for things that need it. 2016-01-23 21:22:45 +00:00
christos 421f456123 Don't include <sys/vnode.h> to get the pager constants. 2016-01-23 16:39:31 +00:00
christos ffb42684fe don't use kernel types. 2016-01-23 14:02:21 +00:00
dholland 2a52e0ce6c MAXNAMLEN, not MAXNAMELEN. From Giuseppe Gatta on netbsd-docs. 2016-01-23 08:17:18 +00:00
wiz 48a57620e7 unsigned -> unsigned int 2016-01-23 07:21:18 +00:00
dholland 398f572480 Apparently a recent round of vandalism by the C++ standards committee
includes disallowing the standard and historic type name "unsigned". Add
a gratuitous "int" to recent changes.

C++ is really a blight on the world.
2016-01-23 01:26:14 +00:00
dholland 65f8003146 Update synopses to match u_int/u_long/etc. changes. Do not bump date as
it's not a substantive change.
2016-01-23 00:43:42 +00:00
dholland fd9823afae Uses __BEGIN_DECLS so needs sys/cdefs.h; also needs stdint.h.
And, while here, add missing include guard.
2016-01-22 23:51:23 +00:00
dholland e9e4a6c4b0 Uses FILE *, needs stdio.h. 2016-01-22 23:25:51 +00:00
dholland f4816d95e4 Needs stdint.h. 2016-01-22 22:39:29 +00:00
dholland f6f5ee7dea Needs sys/cdefs.h for __BEGIN_DECLS and sys/types.h for mode_t. 2016-01-22 22:25:50 +00:00
dholland 5d13788b5e u_int -> unsigned; also requires stddef.h and stdint.h to be compilable. 2016-01-22 22:22:48 +00:00
dholland 89567fa520 The actual header file for these functions is dm.h, not libdm.h.
Bump date.
2016-01-22 22:12:40 +00:00
dholland dd39275be6 - Has __BEGIN_DECLS so needs sys/cdefs.h;
- Needs stddef.h and stdint.h to be compilable on its own
2016-01-22 22:11:28 +00:00
wiz e1f3670be7 Try to reduce singular/plural confusion. Use more markup. 2016-01-22 10:58:39 +00:00
pgoyette 1d24ee4c01 Improved wording. 2016-01-22 09:32:50 +00:00
plunky aae8472c42 correct comment in literal section 2016-01-22 08:51:40 +00:00
plunky 3afdcf10ba clarify closing of descriptor returned by dirfd(3) 2016-01-22 08:50:00 +00:00
zafer b8492eb072 fix typo. 2016-01-22 03:38:57 +00:00
christos e17fe16cac Don't return NULL when we are freeing the root node; return a free'd pointer
instead.
2016-01-20 20:47:41 +00:00
christos 801bf996c3 Add support for Windows I{32,64} formats from Jason Hood via file(1). 2016-01-20 15:43:05 +00:00
christos 2e3cfa464e PR/50681: Markiyan Kushnir: Fix memory leak when we delete the root node.
It is questionable if we should return NULL in that case, but what is the
parent of root? The new adjusted root?
2016-01-20 15:31:55 +00:00
christos 6510a8eabd modernize. 2016-01-16 21:31:38 +00:00
christos 5a327b6e14 fix typo 2016-01-16 21:29:33 +00:00
christos 370ae5dba9 PR/50660: David Binderman: bad calls to printf, in test part 2016-01-16 19:44:05 +00:00
christos acccbba8bc catch up with regsub -> regnsub 2016-01-14 22:06:42 +00:00
christos baf7db8b0f rename to regnsub, regsub is a very popular name. 2016-01-14 21:45:01 +00:00
christos f7bf81e728 stravis, reg{,a}sub 2016-01-14 20:42:29 +00:00
christos 4c892c323a add reg{,a}sub 2016-01-14 20:41:47 +00:00
christos 607e9de17b add stravis(3) from OpenBSD 2016-01-14 20:41:23 +00:00
christos 26492c8912 switch to the external version of libmalloc 2016-01-13 21:57:26 +00:00
christos caa46aef53 fix lint build 2016-01-11 01:34:39 +00:00
jdc b120305be0 Clear the "forced" flag after updating a line, otherwise we'll always do
complete line redraws.
2016-01-10 08:11:06 +00:00
jdc dfb25fd120 Remove extra new line in debugging output. 2016-01-09 19:05:13 +00:00
jakllsch d804fd3f29 Fix buffer-overrun/off-by-one in hid_set_data(3).
(The tests only detected this as a problem on ARMv7, not i386.)
2016-01-07 19:49:45 +00:00
jakllsch f9e98a931a Don't crash when the device's HID Report Descriptor Pops from an empty stack. 2016-01-07 16:10:49 +00:00
jdc 210cd3d8d9 Display force flag in debug print. 2016-01-07 07:37:08 +00:00
jdc 3c6f106b95 Add missing new line in debug print. 2016-01-07 07:36:35 +00:00
christos 8ec658f57a - Change LDADD/DPADD in library dependencies to LIBDPLIBS
- Fix some LDADD abuse and remove useless dependencies
- include <bsd.init.mk> in the right place where appropriate
From Rin Okuyama
2016-01-05 13:07:46 +00:00
christos 10deb451c0 minor type fixes. 2016-01-02 21:58:10 +00:00
jakllsch aaf9a4516d Teach hid_parse_usage_in_page() how to understand hex literals, in
addition to the usual table lookup.
2016-01-02 01:24:44 +00:00
jakllsch f5863ab3d2 Fix round-trip of hid_usage_in_page(hid_parse_usage_in_page()) when
the usage is a catch-all format string.

This should allow usbhidctl(1) to understand an item argument of
"Button:Button_65535".
2016-01-02 01:04:15 +00:00
jakllsch c8b0c3452c Fix hid_get_data() for negative or 32-bit report data. 2016-01-01 22:59:12 +00:00
jakllsch f74c09dad4 Alphanumeric is spelled Alphanumeric 2016-01-01 19:14:45 +00:00
jakllsch f8ec6d43b4 compare pointer against NULL instead of 0 2015-12-31 20:35:21 +00:00
christos 3f38d7cad6 Move blacklistd later now that it depends on libpthread (From Rin Okuyama) 2015-12-31 20:11:32 +00:00
dholland 4f3e8539c0 When computing relative months, use mktime() directly and don't call
our Convert(). And check it for failure. This fixes three sets of
problems:

  (1) depending on the passed-in value of Timezone it might
      disassemble the time in one timezone and reassemble it in
      another, causing mysterious offsets of a few hours;

  (2) with the previous set of changes to this file, Convert() fails
      if it ends up normalizing a date, so e.g. going three months
      forward from March 31 would fail;

  (3) previously if Convert() failed we passed -1 on to DSTcorrect(),
      which made a mess.

PR 50574.
2015-12-31 10:52:06 +00:00
dholland 2213a9c409 Always use localtime_r; I don't think any of this code is tripping
itself up, but it's still good practice for library functions to not
trash static libc state. Might be relevant to PR 50574.
2015-12-31 10:31:07 +00:00
dholland 4c7b8eec63 Reformat grammar part according to my standards for yacc grammars. 2015-12-31 09:12:57 +00:00
wiz b02bef0817 Fix xrefs. 2015-12-30 16:51:31 +00:00
plunky ea8091c08e point to more information about clock_id 2015-12-30 16:47:24 +00:00
christos 841722be1c Add printf/scanf man pages from FreeBSD 2015-12-29 17:55:23 +00:00
christos 420437aa3e Add sqrtl 2015-12-29 16:57:35 +00:00
wiz ee3b5f656a Fix typo, from FreeBSD. 2015-12-26 10:34:36 +00:00
christos 64bdb50ef0 add fenv for m68k 2015-12-24 14:12:12 +00:00
christos 63aea4bd5b Add mips fenv.c (From FreeBSD) 2015-12-21 17:02:02 +00:00
christos 161588a5e8 Powerpc fenv.c from FreeBSD 2015-12-20 16:24:25 +00:00
christos bee41132a3 PR/50552: Kyle Amon: RFC3493 section 6.1 wants us to accept non-dotted-quad
INET4 addresses.
XXX: pullup-7
2015-12-14 22:07:37 +00:00
ozaki-r fa956bf5d1 KNF 2015-12-14 03:49:54 +00:00
christos 6ddc858cb0 mention ip6addrctl 2015-12-13 14:54:17 +00:00