Re: document USE_NOBTCFI in bsd.port.mk

2023-09-08 Thread Anthony J. Bentley
Lucas Raab writes:
> New version attached

ok bentley@

> diff /usr/src
> commit - 2933f00289463a6d1923d1b9cc5e5c1c5c697ece
> path + /usr/src
> blob - 00ec6c3f81fcf03ea69eabe8de1741a6e562
> file + share/man/man5/bsd.port.mk.5
> --- share/man/man5/bsd.port.mk.5
> +++ share/man/man5/bsd.port.mk.5
> @@ -3613,6 +3613,22 @@ and not intended to be a user setting.
>  See
>  .Ev WRKOBJDIR_MFS
>  for configuration.
> +.It Ev USE_NOBTCFI
> +If set to
> +.Sq Yes ,
> +writes a wrapper script to
> +.Pa ${WRKDIR}/bin/ld
> +in
> +.Cm patch
> +to request that the linker adds an
> +.Dv PT_OPENBSD_NOBTCFI
> +ELF section.
> +Use when a port does not work with the default strict enforcement of
> +indirect branch targets.
> +.Pp
> +Applies to all architectures; set
> +.Ev USE_NOBTCFI-${MACHINE_ARCH}
> +to apply to only a specific architecture.
>  .It Ev USE_NOEXECONLY
>  If set to
>  .Sq Yes ,



Re: document USE_NOBTCFI in bsd.port.mk

2023-09-08 Thread Anthony J. Bentley
Lucas Raab writes:
> +writes a wrapper script to ${WRKDIR}/bin/ld in

Use:

.Pa ${WRKDIR}/bin/ld

I see it's wrong elsewhere in the manpage, but let's not introduce another.

> +.Cm patch
> +to request that the linker adds an
> +.Dv PT_OPENBSD_NOBTCFI
> +ELF section. Use when a port requires no enforcement of indirect branch

The second sentence needs to begin on its own line. This affects
inter-sentence spacing in the rendered manpage.

ELF section.
Use when a port ...

> Use when a port requires no enforcement of indirect branch targets.

Reading it again, I think this could be misinterpreted. Better would be
to word it like USE_NOEXECONLY:

"Use when a port does not work with the default strict enforcement of
indirect branch targets."



Re: document USE_NOBTCFI in bsd.port.mk

2023-09-08 Thread Anthony J. Bentley
Lucas Raab writes:
> +Use when a port requires no enforcement of indirect branch targets. Use

New sentence, new line.

> +.Ev USE_NOBTCFI-${MACHINE_ARCH}
> +to apply to specific architectures instead of all architectures.

I would invert the wording: "Applies to all architectures; set
USE_NOBTCFI-${MACHINE_ARCH} to apply to only a specific architecture."



Re: simple pledge for xeyes(1)

2023-09-08 Thread Anthony J. Bentley
Sebastien Marie writes:
> For me, you are pledging too early (before initialization).

I agree with everything you said regarding pledge(2) technique,
including this statement, but it is worth remembering that the list
of promises can be narrowed later with another pledge call.

It's very important to get the final steady-state promises right.
They should be suitably narrow. But initialization code can be very
dangerous too, so a broader list of promises very early in the program
can be worth it, if it means the init code runs without some of the
big ones like exec.

The risk is that someone adds pledge to a new program with a single
broad promise, and never narrows it after initialization is over.



calendar.usholiday: add Juneteenth

2023-05-15 Thread Anthony J. Bentley
A federal holiday since 2021.

ok?

Index: usr.bin/calendar/calendars/calendar.usholiday
===
RCS file: /cvs/src/usr.bin/calendar/calendars/calendar.usholiday,v
retrieving revision 1.9
diff -u -p -r1.9 calendar.usholiday
--- usr.bin/calendar/calendars/calendar.usholiday   19 Jan 2015 18:07:47 
-  1.9
+++ usr.bin/calendar/calendars/calendar.usholiday   15 May 2023 08:51:58 
-
@@ -22,6 +22,7 @@
 05/SatThirdArmed Forces Day (3rd Saturday of May)
 05/MonLast Memorial Day (Last Monday of May)
 06/SunThirdFather's Day (3rd Sunday of June)
+06/19  Juneteenth
 06/21* Summer Solstice
 07/04  Independence Day
 09/MonFirstLabor Day (1st Monday of September)



Re: [PATCH] Add -executable, -readable, and -writable options to /usr/bin/find

2023-04-02 Thread Anthony J. Bentley
Stuart Henderson writes:
> On 2023/04/01 11:27, Jared Harper wrote:
> > For some reason I haven't received the email from Solène (even after
> > requesting it re-sent on lists.openbsd.org; nor is it in spam; I will
> > look further into this issue), so I'm adding my reply in-line here:
>
> Solène's domain publishes a DMARC p=reject record, so sites doing
> strict DMARC checks will reject it when sent via mailing lists,
> unless those lists rewrite the From address.

I don't think that alone necessarily results in a DMARC failure, but
combined with the list server stripping out the original DKIM signature
it definitely does.



Re: adding MIME type for XSLT

2022-02-11 Thread Anthony J. Bentley
Jesse Alama writes:
> XSLT is a well-established XML-based language for stylesheets. It has been ar
> ound since the late 90s; the most recent version was finalized in 2017 (see  
> https://www.w3.org/TR/xslt-30/). The mime.types file bundled with OpenBSD 7.0
>  -- typically used with httpd -- doesn't include this common MIME type. May w
> e add it? Conventionally, XSLT files use the .xsl file extension and the stan
> dard MIME type is "application/xslt+xml" (see https://datatracker.ietf.org/do
> c/html/rfc3023#section-8.17). A diff looks like this:
>
> diff -Naur /usr/share/misc/mime.types /usr/src/share/misc/mime.types
> --- /usr/share/misc/mime.typesThu Sep 30 20:01:17 2021
> +++ /usr/src/share/misc/mime.typesFri Feb 11 07:36:11 2022
> @@ -56,6 +56,7 @@
>  application/x-tcltcl tk
>  application/x-x509-ca-cert   der pem crt
>  application/x-xpinstall  xpi
> +application/xslt+xmlxsl
>  application/xhtml+xmlxhtml
>  application/zip  zip

The list is sorted alphabetically, so xslt needs to come after xhtml.

I like the idea. From some basic searches it looks like Chrome might be
unable to handle XSLT with the registered MIME type, only supporting
text/xml. Is that still the case, and if so, do we care?



Re: Xwindows keymap weirdness

2020-06-01 Thread Anthony J. Bentley
Marc Espie writes:
> > To setup the right alt key as compose, you can either:
> > 
> > - run 'setxkbmap -option compose:ralt' somewhere in your session
> >   startup script
> > 
> > - create /etc/X11/xorg.conf.d/90-keyboard.conf containing
> > 
> > --- Cut ---
> > Section "InputClass"
> > Identifier "Kbd"
> > MatchDriver "kbd"
> > Option "XkbOptions" "compose:ralt"
> > EndSection
> > --- Cut ---
>
> I used to understand that shit back in xmodmap days.
> I'll admit I'm completely lost with setxkbmap
>
> Along the same lines, how can you simply disable caps lock ?

caps:none

Personally I run with caps:ctrl_modifier (caps becomes ctrl).

These variants are documented in xkeyboard-config(7) (needs a large
terminal to be readable).



Re: httpd diff (fixes single instance of XHTML-style element)

2020-05-20 Thread Anthony J. Bentley
Hi Andras,

Andras Farkas writes:
> Today I noticed, when looking at an autoindex page on my own website,
> that despite the page being HTML (as evidenced by  being used
> rather than  further down, and also by the page being served as
> text/html) there was a single instance of an XHTML-style element:
> 
> Notice the second to last character, the slash.  This makes the META
> element here invalid HTML.

This is not actually invalid HTML these days. The HTML5 spec allows
closing slash in , even when served with a non-XML MIME type,
and simply ignores the slash.

However, it's probably worthwhile to use the modern idiom here, which is


-- 
Anthony J. Bentley



Re: Document vi range

2020-05-18 Thread Anthony J. Bentley
ile, the line
corresponding to the first address.  The first address must be less
than or equal to the second address.  The first address must be
greater than or equal to the first line of the file, and the last
address must be less than or equal to the last line of the file.

>From that I think trailing +/-, relative line numbers, and ?? regular
expressions should be described too.

> Comments, OK?

Regarding markup: Ar should be used for things that get replaced (start,
end, c, pattern) but literal characters like . $ % should use Cm.

> +.Ar 'c

This ' should be \(aq so it doesn't become a curly quote in groff -Tpdf.

-- 
Anthony J. Bentley



Re: FAQ4.html Commit Revert

2020-01-03 Thread Anthony J. Bentley
Diogo Galvao writes:
> On Fri, Jan 3, 2020 at 6:37 PM Anthony J. Bentley  wrote:
> >
> > What browser are you using that misrenders the page like that?
>
> Firefox 71.0. It must have something to do with monospace font
> rendering on Windows.

Thanks. These details were necessary to reproduce the problem.

> Even if there was no problem, the current style dt { float: left; }
> isn't very solid for the expected behavior. This becomes clear if we
> manually introduce line breaks inside one of those  tags. This is
> not a real example in this case, of course, but it shows how an element
> could be pushed beside a previous floated element. If it's desired for
> an element to be moved below another floating element that precedes it,
> the clear CSS property must be set.

Yes, we should avoid brittleness. But rather than use several display,
float, clear, and content properties to continue styling definition
lists the way we have been, I think replacing with a simple table will
be more appropriate. In general, www should be editable by mere mortals.



Re: FAQ4.html Commit Revert

2020-01-03 Thread Anthony J. Bentley
Diogo Galvao writes:
> On Thu, Jan 2, 2020 at 12:46 PM Oleg Pahl  wrote:
> >
> > could you be so kind to revert this commit in FAQ 4?
> >
> > https://cvsweb.openbsd.org/cgi-bin/cvsweb/www/faq/faq4.html.diff?r1=1.495
> 2=1.496
> >
>
> Instead of reverting the commit, this change in CSS fixes the problem:

What browser are you using that misrenders the page like that?



Re: printf.1: fix incorrect conversion of apostrophe

2019-06-02 Thread Anthony J. Bentley
Stephen Gregoratto writes:
> In the escape sequences section of printf.1, the 
> character is represented using "\e\'".  In UTF-8 mode, mandoc converts
> this to an acute accent. To fix this I explicitly used "\(aq" as per the
> Accents section of mandoc_char(7), although using "\e'" works as well.

You're correct, thanks.



Re: archaic quotes in calendar

2019-01-30 Thread Anthony J. Bentley
Jason McIntyre writes:
> in the man page you have used Sq. that will make it mark up the same as
> it already does:
>
>   (`*')

There's a difference: Ted uses a UTF-8 locale where Sq shows up as
pretty Unicode quotes. Literally typing `' doesn't (not in the terminal,
anyway).

mandoc should render Sq as ' ' in ASCII mode. We fixed Dq the same way
in both mandoc and groff a couple of years ago (`` '' to " ").

Index: usr.bin/mandoc/chars.c
===
RCS file: /cvs/src/usr.bin/mandoc/chars.c,v
retrieving revision 1.48
diff -u -p -r1.48 chars.c
--- usr.bin/mandoc/chars.c  15 Dec 2018 19:30:19 -  1.48
+++ usr.bin/mandoc/chars.c  30 Jan 2019 10:55:08 -
@@ -100,7 +100,7 @@ static struct ln lines[] = {
{ "rq", "\"",   0x201d  },
{ "Lq", "\"",   0x201c  },
{ "Rq", "\"",   0x201d  },
-   { "oq", "`",0x2018  },
+   { "oq", "\'",   0x2018  },
{ "cq", "\'",   0x2019  },
{ "aq", "\'",   0x0027  },
{ "dq", "\"",   0x0022  },



Re: httpd(8): don't send HSTS headers over unencrypted connections

2018-10-15 Thread Anthony J. Bentley
Florian Obser writes:
> On Sun, Oct 14, 2018 at 07:36:18PM -0600, Anthony J. Bentley wrote:
> > Hi,
> > 
> > RFC 6797 says:
> > 
> >An HSTS Host MUST NOT include the STS header field in HTTP responses
> >conveyed over non-secure transport.
> > 
> > Is this the correct check? With this I get what I expect: HSTS headers
>
> please use srv_conf->flags & SRVFLAG_TLS

With SRVFLAG_TLS:

Index: server_fcgi.c
===
RCS file: /cvs/src/usr.sbin/httpd/server_fcgi.c,v
retrieving revision 1.76
diff -u -p -r1.76 server_fcgi.c
--- server_fcgi.c   19 May 2018 13:56:56 -  1.76
+++ server_fcgi.c   15 Oct 2018 06:32:08 -
@@ -655,7 +655,8 @@ server_fcgi_header(struct client *clt, u
return (-1);
 
/* HSTS header */
-   if (srv_conf->flags & SRVFLAG_SERVER_HSTS) {
+   if (srv_conf->flags & SRVFLAG_SERVER_HSTS &&
+   srv_conf->flags & SRVFLAG_TLS) {
if ((cl =
kv_add(>http_headers, "Strict-Transport-Security",
NULL)) == NULL ||
Index: server_http.c
===
RCS file: /cvs/src/usr.sbin/httpd/server_http.c,v
retrieving revision 1.125
diff -u -p -r1.125 server_http.c
--- server_http.c   11 Oct 2018 09:52:22 -  1.125
+++ server_http.c   15 Oct 2018 06:32:08 -
@@ -950,7 +950,8 @@ server_abort_http(struct client *clt, un
goto done;
}
 
-   if (srv_conf->flags & SRVFLAG_SERVER_HSTS) {
+   if (srv_conf->flags & SRVFLAG_SERVER_HSTS &&
+   srv_conf->flags & SRVFLAG_TLS) {
if (asprintf(, "Strict-Transport-Security: "
"max-age=%d%s%s\r\n", srv_conf->hsts_max_age,
srv_conf->hsts_flags & HSTSFLAG_SUBDOMAINS ?
@@ -1452,7 +1453,8 @@ server_response_http(struct client *clt,
return (-1);
 
/* HSTS header */
-   if (srv_conf->flags & SRVFLAG_SERVER_HSTS) {
+   if (srv_conf->flags & SRVFLAG_SERVER_HSTS &&
+   srv_conf->flags & SRVFLAG_TLS) {
if ((cl =
kv_add(>http_headers, "Strict-Transport-Security",
NULL)) == NULL ||



Re: httpd(8): don't send HSTS headers over unencrypted connections

2018-10-15 Thread Anthony J. Bentley
Bruno Flueckiger writes:
> If you don't want to send HSTS headers then don't set the option hsts in
> httpd.conf(5). Why would you provide an option for the admin to choose
> but restrict it to only encrypted connections? 

Because it's possible to specify both "listen on * tls port 443" and
"listen on * port 80" in the same server block.

The other TLS-related options only apply to encrypted connections in
such a scenario. Then again, none of them work by injecting headers.

-- 
Anthony J. Bentley



httpd(8): don't send HSTS headers over unencrypted connections

2018-10-14 Thread Anthony J. Bentley
Hi,

RFC 6797 says:

   An HSTS Host MUST NOT include the STS header field in HTTP responses
   conveyed over non-secure transport.

Is this the correct check? With this I get what I expect: HSTS headers
over TLS, and no HSTS headers over unencrypted HTTP.

Index: server_fcgi.c
===
RCS file: /cvs/src/usr.sbin/httpd/server_fcgi.c,v
retrieving revision 1.76
diff -u -p -r1.76 server_fcgi.c
--- server_fcgi.c   19 May 2018 13:56:56 -  1.76
+++ server_fcgi.c   15 Oct 2018 01:30:28 -
@@ -655,7 +655,7 @@ server_fcgi_header(struct client *clt, u
return (-1);
 
/* HSTS header */
-   if (srv_conf->flags & SRVFLAG_SERVER_HSTS) {
+   if (srv_conf->flags & SRVFLAG_SERVER_HSTS && clt->clt_tls_ctx != NULL) {
if ((cl =
kv_add(>http_headers, "Strict-Transport-Security",
NULL)) == NULL ||
Index: server_http.c
===
RCS file: /cvs/src/usr.sbin/httpd/server_http.c,v
retrieving revision 1.125
diff -u -p -r1.125 server_http.c
--- server_http.c   11 Oct 2018 09:52:22 -  1.125
+++ server_http.c   15 Oct 2018 01:30:28 -
@@ -950,7 +950,7 @@ server_abort_http(struct client *clt, un
goto done;
}
 
-   if (srv_conf->flags & SRVFLAG_SERVER_HSTS) {
+   if (srv_conf->flags & SRVFLAG_SERVER_HSTS && clt->clt_tls_ctx != NULL) {
if (asprintf(, "Strict-Transport-Security: "
"max-age=%d%s%s\r\n", srv_conf->hsts_max_age,
srv_conf->hsts_flags & HSTSFLAG_SUBDOMAINS ?
@@ -1452,7 +1452,7 @@ server_response_http(struct client *clt,
return (-1);
 
/* HSTS header */
-   if (srv_conf->flags & SRVFLAG_SERVER_HSTS) {
+   if (srv_conf->flags & SRVFLAG_SERVER_HSTS && clt->clt_tls_ctx != NULL) {
if ((cl =
kv_add(>http_headers, "Strict-Transport-Security",
NULL)) == NULL ||



Re: [vi] moving by sentences is inconsistent

2018-10-08 Thread Anthony J. Bentley
Andras Farkas writes:
> On Mon, Oct 8, 2018 at 11:04 AM Theo de Raadt  wrote:
> > You only checked the clones?  You need to compare to the past.
> What you're implying is right: a comment (the one with the AB CD example) in
> https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr.bin/vi/vi/v_sent
> ence.c
> implies that this unfortunate and broken behavior comes from the
> original vi, working contrary to the documentation.

The original UCB vi is also in packages (traditional-vi). There the
behavior is even more broken: ( simply won't progress backward in the
examples you gave.

Unlike some of vi's (many) other bugs, this one doesn't strike me as
one that people's finger memory would rely on. Mine certainly does not.
I would be open to a diff that brings the behavior and docs to POSIX.



Fix underlining in fortunes

2018-09-14 Thread Anthony J. Bentley
Hi,

>From /usr/src/games/fortune/Notes:

Underlining is done on a word-by-word basis, with the underlines
preceding the word, e.g., "__^H^Hhi ^H^H^H^Hthere".

Two fortunes, though, do it wrong: "_^H_^Hhi _^H_^H_^H_^H_^Hthere".
This manifests as an underline beneath only the first letter of each
word (e.g., try "fortune -m squid | ul").

While here, fix the note: "there" is five letters long and so needs five
underscores.

Note that the below diff contains backspaces, so it may look funny.

ok?

Index: Notes
===
RCS file: /cvs/src/games/fortune/Notes,v
retrieving revision 1.4
diff -u -p -r1.4 Notes
--- Notes   13 Jul 2017 02:05:14 -  1.4
+++ Notes   14 Sep 2018 08:16:23 -
@@ -108,7 +108,7 @@ Limericks are indented as follows, all l
If the input was short of exact.
 
 Underlining is done on a word-by-word basis, with the underlines
-preceding the word, e.g., "__^H^Hhi ^H^H^H^Hthere".
+preceding the word, e.g., "__^H^Hhi _^H^H^H^H^Hthere".
 
 No fortune should run beyond 72 characters on a single line without good
 justification (er, no pun intended).  And no right margin justification,
Index: datfiles/fortunes
===
RCS file: /cvs/src/games/fortune/datfiles/fortunes,v
retrieving revision 1.53
diff -u -p -r1.53 fortunes
--- datfiles/fortunes   12 Jan 2018 20:13:06 -  1.53
+++ datfiles/fortunes   14 Sep 2018 08:16:24 -
@@ -301,7 +301,7 @@ ducks.
 %
 A girl and a boy bump into each other -- surely an accident.
 A girl and a boy bump and her handkerchief drops -- surely another accident.
-But when a girl gives a boy a dead squid -- *____that ___had __to 
____mean _________something*.
+But when a girl gives a boy a dead squid -- *that ___had __to 
mean _something*.
-- S. Morganstern, "The Silent Gondoliers"
 %
 A gleekzorp without a tornpee is like a quop without a fertsneet (sort
@@ -10026,7 +10026,7 @@ they charge fifteen cents for them.
 Our documentation manager was showing her two year old son around the
 office.  He was introduced to me, at which time he pointed out that we
 were both holding bags of popcorn.  We were both holding bottles of
-juice.  But only *__he* had a lollipop.
+juice.  But only *__he* had a lollipop.
 
 He asked his mother, "Why doesn't HE have a lollipop?"
 



Re: pthread_create: fix segfault when attr is NULL

2018-07-07 Thread Anthony J. Bentley
Ingo Schwarze writes:
> Hi Jason,
>
> Jason McIntyre wrote on Sat, Jul 07, 2018 at 07:17:29AM +0100:
>
> > the 2/3 pages should really reference the most recent standards too.
> > it's just the work hasn;t been done.
>
> According to my understanding, the difference in policy is deliberate.
> Some people may want to write C code according to specific language
> standards, so knowing that a feature is available in -ansiC is
> useful even if it is also available in -p1003.1-2008.  In contrast,
> writing shell scripts according to historic POSIX versions wouldn't
> really make sense.

My memory of the last time we had this discussion (documenting the
multibyte functions if I recall correctly) is the same as jmc's, that it
would be preferable to target a single standard but nobody has sat down
and done the work.



Re: Fix for vi(1) manpage Visual command

2018-02-03 Thread Anthony J. Bentley
Ingo Schwarze writes:
> > and the USD docs to update. so a man page fix will not suffice.
>
> I wouldn't bother.  They are not installed, and the base system
> doesn't even provide tools to process them.  If we ever decide
> to do anything with them, they will require a full check of accuracy
> anyway.

I am not interested in updating the USD docs, but we *should* continue
to migrate information from them to the manpage. Many user-facing parts
of vi are not adequately documented right now except in there.




Re: Fix for vi(1) manpage Visual command

2018-02-03 Thread Anthony J. Bentley
Jason McIntyre writes:
> On Fri, Feb 02, 2018 at 08:17:11PM -0700, Anthony J. Bentley wrote:
> > trondd writes:
> > > The manpage for vi(1) has a small error for the :Visual/:visual command. 
>  The
> > > 'V' can be capital or lowercase, followed by an 'i' and optionally 'sual'
> . Bu
> > > t
> > > the manpage shows the command as [Vi]i[sual] instead of [Vv]i[sual].
> > 
> > This reveals a problem with the manpage. Everywhere else [] refers to
> > optional parts of a command, but in the EX COMMANDS section, [] does
> > double duty both to mark multiple valid characters as in glob(7) and to
> > signify optional parts of the command.
> > 
> > Even in EX COMMANDS [] means "optional" only except for a few commands:
> > [Ee][dit], [Ee]x, [Ff]g, [Nn][ext], [Pp]rev[ious], [Tt]a[g], and now
> > [Vv]i[sual].
> > 
> > For readability I think these should be separate lines. Doubly so
> > because the capitalized commands actually behave differently as
> > explained in the reference documentation, and NOT explained in the
> > manpage...
> > 
> > This does leave open the question of how the usage strings in ex_cmd.c
> > should change, and whether the code there should be rearchitected so
> > that, e.g., "edit" and "Edit" can have different usage strings.
> > 
> > -- 
> > Anthony J. Bentley
> > 
>
> morning.
>
> can you explain how uppercase and lowercase variants differ? it could be
> that the simplest fix is not to list the uppercase variant (e.g. Visual)
> and just explain in a separate paragraph those few commands that have
> the variant.
>
> but that depends on what the difference is.

For each of them the capitalized variant opens the result in a new
screen instead of the current screen. (Fg foregrounds to a new screen
instead of swapping with the current screen, Tag opens the tag in a
new screen, etc.) Thus the capitalized variants are only available in
vi, not ex.

Of these, "visual" is different from the others in that in ex mode and
vi mode they are actually separate commands. Hence the current
documentation:

 [line] vi[sual] [type] [count] [flags]
 ex mode only.  Enter vi.

 [Vv]i[sual][!] [+cmd] [file]
 vi mode only.  Edit a new file.



Re: Fix for vi(1) manpage Visual command

2018-02-02 Thread Anthony J. Bentley
trondd writes:
> The manpage for vi(1) has a small error for the :Visual/:visual command.  The
> 'V' can be capital or lowercase, followed by an 'i' and optionally 'sual'. Bu
> t
> the manpage shows the command as [Vi]i[sual] instead of [Vv]i[sual].

This reveals a problem with the manpage. Everywhere else [] refers to
optional parts of a command, but in the EX COMMANDS section, [] does
double duty both to mark multiple valid characters as in glob(7) and to
signify optional parts of the command.

Even in EX COMMANDS [] means "optional" only except for a few commands:
[Ee][dit], [Ee]x, [Ff]g, [Nn][ext], [Pp]rev[ious], [Tt]a[g], and now
[Vv]i[sual].

For readability I think these should be separate lines. Doubly so
because the capitalized commands actually behave differently as
explained in the reference documentation, and NOT explained in the
manpage...

This does leave open the question of how the usage strings in ex_cmd.c
should change, and whether the code there should be rearchitected so
that, e.g., "edit" and "Edit" can have different usage strings.

-- 
Anthony J. Bentley



Disable ACPI burst mode on 2015 Chromebook Pixel

2018-01-16 Thread Anthony J. Bentley
Hi,

The 2015 Chromebook Pixel has a broken ACPI that doesn't support
burst mode and will hang on boot when it's tried.

Rev 1.54 of acpiec.c disabled it for single-byte reads and writes,
which fixed this machine, but broke others. So it got reverted, with
the note:

  "A machine/bios-dependent check could be added later to disable
  bursting on certain machines."

jcs later sent me such a diff, and I've been using it for several
months. I'm starting to tire of compiling my own kernels, so I'd
like to get it in if possible.

ok?


Index: sys/dev/acpi/acpidev.h
===
RCS file: /cvs/src/sys/dev/acpi/acpidev.h,v
retrieving revision 1.42
diff -u -p -r1.42 acpidev.h
--- sys/dev/acpi/acpidev.h  6 Sep 2017 13:01:48 -   1.42
+++ sys/dev/acpi/acpidev.h  16 Jan 2018 09:19:54 -
@@ -374,6 +374,7 @@ struct acpiec_softc {
struct acpiec_event sc_events[ACPIEC_MAX_EVENTS];
int sc_gotsci;
int sc_glk;
+   int sc_canburst;
 };
 
 void   acpibtn_disable_psw(void);
Index: sys/dev/acpi/acpiec.c
===
RCS file: /cvs/src/sys/dev/acpi/acpiec.c,v
retrieving revision 1.56
diff -u -p -r1.56 acpiec.c
--- sys/dev/acpi/acpiec.c   11 Mar 2017 21:46:32 -  1.56
+++ sys/dev/acpi/acpiec.c   16 Jan 2018 09:19:54 -
@@ -77,6 +77,8 @@ void  acpiec_unlock(struct acpiec_softc 
 
 intacpiec_reg(struct acpiec_softc *);
 
+extern char*hw_vendor, *hw_prod;
+
 struct cfattach acpiec_ca = {
sizeof(struct acpiec_softc), acpiec_match, acpiec_attach
 };
@@ -195,6 +197,9 @@ acpiec_write_1(struct acpiec_softc *sc, 
 void
 acpiec_burst_enable(struct acpiec_softc *sc)
 {
+   if (!sc->sc_canburst)
+   return;
+
acpiec_write_cmd(sc, EC_CMD_BE);
acpiec_read_data(sc);
 }
@@ -202,6 +207,9 @@ acpiec_burst_enable(struct acpiec_softc 
 void
 acpiec_burst_disable(struct acpiec_softc *sc)
 {
+   if (!sc->sc_canburst)
+   return;
+
if ((acpiec_status(sc) & EC_STAT_BURST) == EC_STAT_BURST)
acpiec_write_cmd(sc, EC_CMD_BD);
 }
@@ -273,6 +281,7 @@ acpiec_attach(struct device *parent, str
 
sc->sc_acpi = (struct acpi_softc *)parent;
sc->sc_devnode = aa->aaa_node;
+   sc->sc_canburst = 1;
 
if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "_STA", 0, NULL, ))
st = STA_PRESENT | STA_ENABLED | STA_DEV_OK;
@@ -293,6 +302,16 @@ acpiec_attach(struct device *parent, str
printf("%s: Failed to register address space\n", DEVNAME(sc));
return;
}
+
+   /*
+* Some Chromebooks using the Google EC do not support burst mode and
+* cause us to spin forever waiting for the acknowledgment.  Don't use
+* burst mode at all on these machines.
+*/
+   if (hw_vendor != NULL && hw_prod != NULL &&
+   strcmp(hw_vendor, "GOOGLE") == 0 &&
+   strcmp(hw_prod, "Samus") == 0)
+   sc->sc_canburst = 0;
 
acpiec_get_events(sc);
 



Re: Remove accents from fortunes

2017-07-12 Thread Anthony J. Bentley
Ingo Schwarze writes:
> So here is a patch that makes putting UTF-8 characters into
> fortune/datfiles safe.

And here is a patch that retains the accents in the datfiles as UTF-8.

Index: Notes
===
RCS file: /cvs/src/games/fortune/Notes,v
retrieving revision 1.3
diff -u -p -r1.3 Notes
--- Notes   28 Sep 2004 20:40:01 -  1.3
+++ Notes   12 Jul 2017 05:57:23 -
@@ -107,8 +107,7 @@ Limericks are indented as follows, all l
No more than debris,
If the input was short of exact.
 
-Accents precede the letter they are over, e.g., "`^He" for e with a grave
-accent.  Underlining is done on a word-by-word basis, with the underlines
+Underlining is done on a word-by-word basis, with the underlines
 preceding the word, e.g., "__^H^Hhi ^H^H^H^Hthere".
 
 No fortune should run beyond 72 characters on a single line without good
Index: datfiles/fortunes
===
RCS file: /cvs/src/games/fortune/datfiles/fortunes,v
retrieving revision 1.49
diff -u -p -r1.49 fortunes
--- datfiles/fortunes   28 Dec 2015 12:32:12 -  1.49
+++ datfiles/fortunes   12 Jul 2017 05:57:24 -
@@ -232,7 +232,7 @@ test", said the outsider, "because I wan
Drescher took the paper that was offered him and put it into
 the toaster -- "I wish the toaster to be happy too."
 %
-A diva who specializes in risqu'e arias is an off-coloratura soprano ...
+A diva who specializes in risqué arias is an off-coloratura soprano ...
 %
A doctor, an architect, and a computer scientist were arguing
 about whose profession was the oldest.  In the course of their
@@ -3620,8 +3620,8 @@ Error in operator: add beer
 %
 Es brilig war.  Die schlichte Toven
Wirrten und wimmelten in Waben;
-Und aller-m"umsige Burggoven
-   Dir mohmen R"ath ausgraben.
+Und aller-mümsige Burggoven
+   Dir mohmen Räth ausgraben.
-- Lewis Carroll, "Through the Looking Glass"
 %
 Eternal nothingness is fine if you happen to be dressed for it.
@@ -4066,7 +4066,7 @@ Five is a sufficiently close approximati
-- Robert Firth
 %
 Flappity, floppity, flip
-The mouse on the m"obius strip;
+The mouse on the möbius strip;
The strip revolved,
The mouse dissolved
 In a chronodimensional skip.
@@ -5245,12 +5245,12 @@ I need your help, I say 'tween sobs,
 %
 Here in my heart, I am Helen;
I'm Aspasia and Hero, at least.
-I'm Judith, and Jael, and Madame de Sta"el;
+I'm Judith, and Jael, and Madame de Staël;
I'm Salome, moon of the East.
 
 Here in my soul I am Sappho;
Lady Hamilton am I, as well.
-In me R'ecamier vies with Kitty O'Shea,
+In me Récamier vies with Kitty O'Shea,
With Dido, and Eve, and poor nell.
 
 I'm all of the glamorous ladies
@@ -5820,7 +5820,7 @@ streets and frighten the horses.
 %
 "I don't object to sex before marriage, but two minutes before?!?"
 %
-"I don't think so," said Ren'e Descartes.  Just then, he vanished.
+"I don't think so," said René Descartes.  Just then, he vanished.
 %
 I don't think they could put him in a mental hospital.  On the other
 hand, if he were already in, I don't think they'd let him out.
@@ -7056,10 +7056,10 @@ Ignisecond, n.:
door even as the brain is saying, "my keys are in there!"
-- Rich Hall, "Sniglets"
 %
-Il brilgue: les t^oves libricilleux
+Il brilgue: les tôves libricilleux
Se gyrent et frillant dans le guave,
-Enm^im'es sont les gougebosquex,
-   Et le m^omerade horgrave.
+Enmîmés sont les gougebosquex,
+   Et le mômerade horgrave.
-- Lewis Carroll, "Through the Looking Glass"
 %
 Iles's Law:
@@ -10423,7 +10423,7 @@ laughter, singing
 The square was finally cleared by armed carabineri with tears of
 laughter streaming down their faces.  The event set a record for
 hilarious civic functions, smashing the previous record set when Baron
-Hans Neizant B"ompzidaize was elected Landburgher of K"oln in 1653.
+Hans Neizant Bömpzidaize was elected Landburgher of Köln in 1653.
-- Mike Harding, "The Armchair Anarchist's Almanac"
 %
 Portable, adj.:
@@ -11211,7 +11211,7 @@ pencil.
 Science is facts; just as houses are made of stones, so is science made
 of facts; but a pile of stones is not a house and a collection of facts
 is not necessarily science.
-   -- Henri Poincair'e
+   -- Henri Poincairé
 %
 Science is what happens when preconception meets verification.
 %
@@ -11760,7 +11760,7 @@ Spouse, n.:
wouldn't have had if you'd stayed single.
 %
 Star Wars is adolescent nonsense; Close Encounters is obscurantist
-drivel; Star Trek can turn your brains to pur'ee of bat guano; and the
+drivel; Star Trek can turn your brains to purée of bat guano; and the
 greatest science fiction series of all time is Doctor Who!  And I'll
 take you all on, one-by-one or all in a 

Re: Remove accents from fortunes

2017-07-11 Thread Anthony J. Bentley
"Ted Unangst" writes:
> Anthony J. Bentley wrote:
> > Hi,
> > 
> > "Punctuation followed by backspace" hasn't been the right way to enter
> > accents for a long time.
> 
> hard to see what the diff is doing since i coudn't see the backspaces. :)
> 
> do we want to delete them? or replace them with proper utf-8 sequences?

I wouldn't mind doing that. But fortune(6) will happily print UTF-8 to a
non-UTF-8 terminal, which though probably harmless might be undesirable.
And since nobody's complained in the past few years that they couldn't
see the accents in Jabberwocky...



Remove accents from fortunes

2017-07-10 Thread Anthony J. Bentley
Hi,

"Punctuation followed by backspace" hasn't been the right way to enter
accents for a long time.

ok?

Index: Notes
===
RCS file: /cvs/src/games/fortune/Notes,v
retrieving revision 1.3
diff -u -p -r1.3 Notes
--- Notes   28 Sep 2004 20:40:01 -  1.3
+++ Notes   10 Jul 2017 15:23:31 -
@@ -107,8 +107,7 @@ Limericks are indented as follows, all l
No more than debris,
If the input was short of exact.
 
-Accents precede the letter they are over, e.g., "`^He" for e with a grave
-accent.  Underlining is done on a word-by-word basis, with the underlines
+Underlining is done on a word-by-word basis, with the underlines
 preceding the word, e.g., "__^H^Hhi ^H^H^H^Hthere".
 
 No fortune should run beyond 72 characters on a single line without good
Index: datfiles/fortunes
===
RCS file: /cvs/src/games/fortune/datfiles/fortunes,v
retrieving revision 1.49
diff -u -p -r1.49 fortunes
--- datfiles/fortunes   28 Dec 2015 12:32:12 -  1.49
+++ datfiles/fortunes   10 Jul 2017 15:23:32 -
@@ -232,7 +232,7 @@ test", said the outsider, "because I wan
Drescher took the paper that was offered him and put it into
 the toaster -- "I wish the toaster to be happy too."
 %
-A diva who specializes in risqu'e arias is an off-coloratura soprano ...
+A diva who specializes in risque arias is an off-coloratura soprano ...
 %
A doctor, an architect, and a computer scientist were arguing
 about whose profession was the oldest.  In the course of their
@@ -3620,8 +3620,8 @@ Error in operator: add beer
 %
 Es brilig war.  Die schlichte Toven
Wirrten und wimmelten in Waben;
-Und aller-m"umsige Burggoven
-   Dir mohmen R"ath ausgraben.
+Und aller-mumsige Burggoven
+   Dir mohmen Rath ausgraben.
-- Lewis Carroll, "Through the Looking Glass"
 %
 Eternal nothingness is fine if you happen to be dressed for it.
@@ -4066,7 +4066,7 @@ Five is a sufficiently close approximati
-- Robert Firth
 %
 Flappity, floppity, flip
-The mouse on the m"obius strip;
+The mouse on the mobius strip;
The strip revolved,
The mouse dissolved
 In a chronodimensional skip.
@@ -5245,12 +5245,12 @@ I need your help, I say 'tween sobs,
 %
 Here in my heart, I am Helen;
I'm Aspasia and Hero, at least.
-I'm Judith, and Jael, and Madame de Sta"el;
+I'm Judith, and Jael, and Madame de Stael;
I'm Salome, moon of the East.
 
 Here in my soul I am Sappho;
Lady Hamilton am I, as well.
-In me R'ecamier vies with Kitty O'Shea,
+In me Recamier vies with Kitty O'Shea,
With Dido, and Eve, and poor nell.
 
 I'm all of the glamorous ladies
@@ -5820,7 +5820,7 @@ streets and frighten the horses.
 %
 "I don't object to sex before marriage, but two minutes before?!?"
 %
-"I don't think so," said Ren'e Descartes.  Just then, he vanished.
+"I don't think so," said Rene Descartes.  Just then, he vanished.
 %
 I don't think they could put him in a mental hospital.  On the other
 hand, if he were already in, I don't think they'd let him out.
@@ -7056,10 +7056,10 @@ Ignisecond, n.:
door even as the brain is saying, "my keys are in there!"
-- Rich Hall, "Sniglets"
 %
-Il brilgue: les t^oves libricilleux
+Il brilgue: les toves libricilleux
Se gyrent et frillant dans le guave,
-Enm^im'es sont les gougebosquex,
-   Et le m^omerade horgrave.
+Enmimes sont les gougebosquex,
+   Et le momerade horgrave.
-- Lewis Carroll, "Through the Looking Glass"
 %
 Iles's Law:
@@ -10423,7 +10423,7 @@ laughter, singing
 The square was finally cleared by armed carabineri with tears of
 laughter streaming down their faces.  The event set a record for
 hilarious civic functions, smashing the previous record set when Baron
-Hans Neizant B"ompzidaize was elected Landburgher of K"oln in 1653.
+Hans Neizant Bompzidaize was elected Landburgher of Koln in 1653.
-- Mike Harding, "The Armchair Anarchist's Almanac"
 %
 Portable, adj.:
@@ -11211,7 +11211,7 @@ pencil.
 Science is facts; just as houses are made of stones, so is science made
 of facts; but a pile of stones is not a house and a collection of facts
 is not necessarily science.
-   -- Henri Poincair'e
+   -- Henri Poincaire
 %
 Science is what happens when preconception meets verification.
 %
@@ -11760,7 +11760,7 @@ Spouse, n.:
wouldn't have had if you'd stayed single.
 %
 Star Wars is adolescent nonsense; Close Encounters is obscurantist
-drivel; Star Trek can turn your brains to pur'ee of bat guano; and the
+drivel; Star Trek can turn your brains to puree of bat guano; and the
 greatest science fiction series of all time is Doctor Who!  And I'll
 take you all on, one-by-one or all in a bunch to back it up!
-- Harlan Ellison
@@ -14330,7 +14330,7 

Re: Remove games/fortune/tools

2017-07-09 Thread Anthony J. Bentley
Matthew Martin writes:
> As far as I can tell, it's never been linked into the build even looking
> in the NetBSD history.

It's junk. ok bentley@ to whomever wants to remove it.



Re: vi(1): remove stub settings

2017-06-30 Thread Anthony J. Bentley
Christian Weisgerber writes:
> On 2017-06-29, "Anthony J. Bentley" <anth...@anjbe.name> wrote:
> 
> > The vi manual is long enough. It doesn't seem very helpful to keep stubs
> > that have been stubs for 20 years.
> 
> Should we retain some documentation along the lines of "nex/nvi
> does not implement the following options from the original ex/vi:
> ..."?

Here's a diff that updates the STANDARDS section in the manual.
I think it will be enough to talk about our POSIX compliance. POSIX
discusses its differences from historical ex/vi in great detail,
including an explicit recommendation to delete modelines and sourceany.

Index: common/main.c
===
RCS file: /cvs/src/usr.bin/vi/common/main.c,v
retrieving revision 1.39
diff -u -p -r1.39 main.c
--- common/main.c   18 Apr 2017 01:45:35 -  1.39
+++ common/main.c   30 Jun 2017 15:16:56 -
@@ -52,7 +52,7 @@ editor(GS *gp, int argc, char *argv[])
SCR *sp;
size_t len;
u_int flags;
-   int ch, flagchk, lflag, secure, startup, readonly, rval, silent;
+   int ch, flagchk, secure, startup, readonly, rval, silent;
char *tag_f, *wsizearg, path[256];
 
static const char *optstr[3] = {
@@ -114,7 +114,7 @@ editor(GS *gp, int argc, char *argv[])
/* Parse the arguments. */
flagchk = '\0';
tag_f = wsizearg = NULL;
-   lflag = secure = silent = 0;
+   secure = silent = 0;
startup = 1;
 
/* Set the file snapshot flag. */
@@ -163,9 +163,6 @@ editor(GS *gp, int argc, char *argv[])
case 'F':   /* No snapshot. */
F_CLR(gp, G_SNAPSHOT);
break;
-   case 'l':   /* Set lisp, showmatch options. */
-   lflag = 1;
-   break;
case 'R':   /* Readonly. */
readonly = 1;
break;
@@ -260,11 +257,7 @@ editor(GS *gp, int argc, char *argv[])
goto err;
 
{ int oargs[5], *oargp = oargs;
-   if (lflag) {/* Command-line options. */
-   *oargp++ = O_LISP;
-   *oargp++ = O_SHOWMATCH;
-   }
-   if (readonly)
+   if (readonly)   /* Command-line options. */
*oargp++ = O_READONLY;
if (secure)
*oargp++ = O_SECURE;
Index: common/options.c
===
RCS file: /cvs/src/usr.bin/vi/common/options.c,v
retrieving revision 1.24
diff -u -p -r1.24 options.c
--- common/options.c30 Jun 2017 14:42:05 -  1.24
+++ common/options.c30 Jun 2017 15:16:56 -
@@ -89,12 +89,6 @@ OPTLIST const optlist[] = {
{"leftright",   f_reformat, OPT_0BOOL,  0},
 /* O_LINES   4.4BSD */
{"lines",   f_lines,OPT_NUM,OPT_NOSAVE},
-/* O_LISP  4BSD
- * XXX
- * When the lisp option is implemented, delete the OPT_NOSAVE flag,
- * so that :mkexrc dumps it.
- */
-   {"lisp",f_lisp, OPT_0BOOL,  OPT_NOSAVE},
 /* O_LIST  4BSD */
{"list",f_reformat, OPT_0BOOL,  0},
 /* O_LOCKFILES   4.4BSD
@@ -109,15 +103,6 @@ OPTLIST const optlist[] = {
{"matchtime",   NULL,   OPT_NUM,0},
 /* O_MESG  4BSD */
{"mesg",NULL,   OPT_1BOOL,  0},
-/* O_MODELINE  4BSD
- * !!!
- * This has been documented in historical systems as both "modeline"
- * and as "modelines".  Regardless of the name, this option represents
- * a security problem of mammoth proportions, not to mention a stunning
- * example of what your intro CS professor referred to as the perils of
- * mixing code and data.  Don't add it, or I will kill you.
- */
-   {"modeline",NULL,   OPT_0BOOL,  OPT_NOSET},
 /* O_NOPRINT 4.4BSD */
{"noprint", f_print,OPT_STR,OPT_EARLYSET},
 /* O_NUMBER4BSD */
@@ -126,8 +111,6 @@ OPTLIST const optlist[] = {
{"octal",   f_print,OPT_0BOOL,  OPT_EARLYSET},
 /* O_OPEN  4BSD */
{"open",NULL,   OPT_1BOOL,  0},
-/* O_OPTIMIZE  4BSD */
-   {"optimize",NULL,   OPT_1BOOL,  0},
 /* O_PARAGRAPHS4BSD */
{"paragraphs",  f_paragraph,OPT_STR,0},
 /* O_PATH4.4BSD */
@@ -140,8 +123,6 @@ OPTLIST const optlist[] = {
{"readonly",f_readonly, OPT_0BOOL,  OPT_ALWAYS},
 /* O_RECDIR  4.4BSD */
{"recdir",  NULL,   OPT_STR,0},
-/* O_REDRAW4BSD */
- 

vi(1): remove stub settings

2017-06-29 Thread Anthony J. Bentley
Hi,

>From vi(1):

 lisp [off]
 (...) This option is not yet implemented.

 modelines, modeline [off]
 (...) This option will never be implemented.

 optimize, opt [on]
 (...) This option is not yet implemented

 redraw, re [off]
 (...) This option is not yet implemented.

 slowopen, slow [off]
 (...) This option is not yet implemented.

 sourceany [off]
 (...) This option will never be implemented.

The vi manual is long enough. It doesn't seem very helpful to keep stubs
that have been stubs for 20 years.

ok?

Index: common/main.c
===
RCS file: /cvs/src/usr.bin/vi/common/main.c,v
retrieving revision 1.39
diff -u -p -r1.39 main.c
--- common/main.c   18 Apr 2017 01:45:35 -  1.39
+++ common/main.c   23 Jun 2017 07:04:55 -
@@ -52,7 +52,7 @@ editor(GS *gp, int argc, char *argv[])
SCR *sp;
size_t len;
u_int flags;
-   int ch, flagchk, lflag, secure, startup, readonly, rval, silent;
+   int ch, flagchk, secure, startup, readonly, rval, silent;
char *tag_f, *wsizearg, path[256];
 
static const char *optstr[3] = {
@@ -114,7 +114,7 @@ editor(GS *gp, int argc, char *argv[])
/* Parse the arguments. */
flagchk = '\0';
tag_f = wsizearg = NULL;
-   lflag = secure = silent = 0;
+   secure = silent = 0;
startup = 1;
 
/* Set the file snapshot flag. */
@@ -163,9 +163,6 @@ editor(GS *gp, int argc, char *argv[])
case 'F':   /* No snapshot. */
F_CLR(gp, G_SNAPSHOT);
break;
-   case 'l':   /* Set lisp, showmatch options. */
-   lflag = 1;
-   break;
case 'R':   /* Readonly. */
readonly = 1;
break;
@@ -260,11 +257,7 @@ editor(GS *gp, int argc, char *argv[])
goto err;
 
{ int oargs[5], *oargp = oargs;
-   if (lflag) {/* Command-line options. */
-   *oargp++ = O_LISP;
-   *oargp++ = O_SHOWMATCH;
-   }
-   if (readonly)
+   if (readonly)   /* Command-line options. */
*oargp++ = O_READONLY;
if (secure)
*oargp++ = O_SECURE;
Index: common/options.c
===
RCS file: /cvs/src/usr.bin/vi/common/options.c,v
retrieving revision 1.23
diff -u -p -r1.23 options.c
--- common/options.c18 Apr 2017 01:45:35 -  1.23
+++ common/options.c23 Jun 2017 07:04:55 -
@@ -89,12 +89,6 @@ OPTLIST const optlist[] = {
{"leftright",   f_reformat, OPT_0BOOL,  0},
 /* O_LINES   4.4BSD */
{"lines",   f_lines,OPT_NUM,OPT_NOSAVE},
-/* O_LISP  4BSD
- * XXX
- * When the lisp option is implemented, delete the OPT_NOSAVE flag,
- * so that :mkexrc dumps it.
- */
-   {"lisp",f_lisp, OPT_0BOOL,  OPT_NOSAVE},
 /* O_LIST  4BSD */
{"list",f_reformat, OPT_0BOOL,  0},
 /* O_LOCKFILES   4.4BSD
@@ -109,15 +103,6 @@ OPTLIST const optlist[] = {
{"matchtime",   NULL,   OPT_NUM,0},
 /* O_MESG  4BSD */
{"mesg",NULL,   OPT_1BOOL,  0},
-/* O_MODELINE  4BSD
- * !!!
- * This has been documented in historical systems as both "modeline"
- * and as "modelines".  Regardless of the name, this option represents
- * a security problem of mammoth proportions, not to mention a stunning
- * example of what your intro CS professor referred to as the perils of
- * mixing code and data.  Don't add it, or I will kill you.
- */
-   {"modeline",NULL,   OPT_0BOOL,  OPT_NOSET},
 /* O_NOPRINT 4.4BSD */
{"noprint", f_print,OPT_STR,OPT_EARLYSET},
 /* O_NUMBER4BSD */
@@ -126,8 +111,6 @@ OPTLIST const optlist[] = {
{"octal",   f_print,OPT_0BOOL,  OPT_EARLYSET},
 /* O_OPEN  4BSD */
{"open",NULL,   OPT_1BOOL,  0},
-/* O_OPTIMIZE  4BSD */
-   {"optimize",NULL,   OPT_1BOOL,  0},
 /* O_PARAGRAPHS4BSD */
{"paragraphs",  f_paragraph,OPT_STR,0},
 /* O_PATH4.4BSD */
@@ -140,8 +123,6 @@ OPTLIST const optlist[] = {
{"readonly",f_readonly, OPT_0BOOL,  OPT_ALWAYS},
 /* O_RECDIR  4.4BSD */
{"recdir",  NULL,   OPT_STR,0},
-/* O_REDRAW4BSD */
-   {"redraw",  NULL,   OPT_0BOOL,  0},
 /* O_REMAP 4BSD */
{"remap",   NULL,   OPT_1BOOL,  0},
 /* O_REPORT4BSD */
@@ -168,17 +149,6 @@ OPTLIST const optlist[] = {

Re: mdoc(7): .St for latest POSIX

2017-06-23 Thread Anthony J. Bentley
Ingo Schwarze writes:
> Hi Jason,
> 
> Jason McIntyre wrote on Thu, Jun 22, 2017 at 02:07:51PM +0100:
> 
> > so do you want to remove the entry for 1003.1-2013 as well?
> > none of our man pages use it.
> 
> The decisive point is that even current groff does not support it,
> so deleting it is unlikely to break other's pages.
> 
> OK?

ok bentley@



mdoc(7): .St for latest POSIX

2017-06-22 Thread Anthony J. Bentley
ok?

Index: share/man/man7/mdoc.7
===
RCS file: /cvs/src/share/man/man7/mdoc.7,v
retrieving revision 1.153
diff -u -p -r1.153 mdoc.7
--- share/man/man7/mdoc.7   10 Jun 2017 16:32:08 -  1.153
+++ share/man/man7/mdoc.7   22 Jun 2017 06:20:33 -
@@ -2593,6 +2593,11 @@ X/Open Portability Guide version 7.
 .St -p1003.1-2013
 .br
 This is the first Technical Corrigendum.
+.Pp
+.It \-p1003.1-2016
+.St -p1003.1-2016
+.br
+This is the second Technical Corrigendum.
 .El
 .It Other standards
 .Pp
Index: usr.bin/mandoc/st.in
===
RCS file: /cvs/src/usr.bin/mandoc/st.in,v
retrieving revision 1.22
diff -u -p -r1.22 st.in
--- usr.bin/mandoc/st.in17 Feb 2015 20:33:44 -  1.22
+++ usr.bin/mandoc/st.in22 Jun 2017 06:20:33 -
@@ -35,6 +35,7 @@ LINE("-p1003.1-2001", "IEEE Std 1003.1-2
 LINE("-p1003.1-2004",  "IEEE Std 1003.1-2004 (\\(LqPOSIX.1\\(Rq)")
 LINE("-p1003.1-2008",  "IEEE Std 1003.1-2008 (\\(LqPOSIX.1\\(Rq)")
 LINE("-p1003.1-2013",  "IEEE Std 1003.1-2008/Cor 1-2013 (\\(LqPOSIX.1\\(Rq)")
+LINE("-p1003.1-2016",  "IEEE Std 1003.1-2008/Cor 2-2016 (\\(LqPOSIX.1\\(Rq)")
 LINE("-p1003.1",   "IEEE Std 1003.1 (\\(LqPOSIX.1\\(Rq)")
 LINE("-p1003.1b",  "IEEE Std 1003.1b (\\(LqPOSIX.1b\\(Rq)")
 LINE("-p1003.1b-93",   "IEEE Std 1003.1b-1993 (\\(LqPOSIX.1b\\(Rq)")



Re: vi(1): documenting :s

2017-06-20 Thread Anthony J. Bentley
Hi,

Jason McIntyre writes:
> shouldn;t it be that we should show the suspend command as
> 
>   sus[pend]
> 
> the shortest "s" matches "substitute", right. so we show it as
> 
>   s[ubstitute]
> 
> i cannot find any text that describes what "su" *should* match though,
> so i'm not sure. logically i'd expect it to match "substitute", since
> that is first alphabetically. that's why i think it should be sus[pend],
> not sub[stitute].
> 
> i don;t have any other versions of vi to compare how other systems do
> this.

Turns out there is no consistency anywhere.

Original vi implements:
s
su[spend]
sub[stitute]

nvi (ours and others):
s
su[spend]

elvis:
s[ubstitute] (it documents sus[pend] but doesn't actually implement it)

vim:
s[ubstitute]
sus[pend]

It looks like nvi tried to mimic original vi at the beginning, but
broke the functionality sometime between 1994 and 1996, and nobody
noticed over the next 20 years.

Seeing as POSIX is unclear and everybody's inconsistent anyway, I'm
strongly inclined to just leave things as they are, commit the original
diff that documents the current reality, and leave it at that.

-- 
Anthony J. Bentley



Re: vi(1): documenting :s

2017-06-19 Thread Anthony J. Bentley
Theo Buehler writes:
> This looks like a reasonable approach and it appears to work. When I
> looked at this after jmc's question, I was scared off by the comment
> 
> >   * Adding new commands starting with 's' may break the substitute command 
> code
> >   * in ex_cmd() (the ex parser).  Read through the comments there, first.
> 
> which is also visible in your diff. I'm not entirely sure what this
> is talking about. Thus, only a hesitant ok for the C-part of your patch.

That comment is referring to the fact that, e.g., "sg" is a legal
command equivalent to ""; see ex/ex.c:430. Adding a command starting
with "sub" won't affect this, because there's no 'u' flag (plus there's
a command starting with "su" already).

-- 
Anthony J. Bentley



Re: vi(1): documenting :s

2017-06-19 Thread Anthony J. Bentley
Hi,

Jason McIntyre writes:
> ok by me. note that posix ex(1) does detail a working [s]ubstitute command,
> so i'm not sure whether we should support this or not.

Hm, so it does. I think I would prefer to follow POSIX in this case.
Here's a diff to allow "substitute" to work.

Annoyingly, there's an ambiguity in the POSIX synopsis (and ours).

 [2addr] s[ubstitute][/pattern/repl/[options][count][flags]]

This implies that "su" could expand to "substitute". But it expands (and
should expand) to "suspend" instead. Since in our vi the first match
always wins, the simplest way to implement this is to use separate ex
commands:

 [2addr] s[/pattern/repl/[options][count][flags]]
 [2addr] sub[stitute][/pattern/repl/[options][count][flags]]

There are already plenty of duplicate commands (e.g., "#"/"nu",
"cd"/"chd", "co"/"t"...) so I think it's an acceptable approach.

Index: docs/USD.doc/vi.man/vi.1
===
RCS file: /cvs/src/usr.bin/vi/docs/USD.doc/vi.man/vi.1,v
retrieving revision 1.67
diff -u -p -r1.67 vi.1
--- docs/USD.doc/vi.man/vi.115 Jun 2017 06:44:47 -  1.67
+++ docs/USD.doc/vi.man/vi.119 Jun 2017 09:19:23 -
@@ -356,7 +356,7 @@ matches the end of the word.
 .It
 .Sq ~
 matches the replacement part of the last
-.Cm substitute
+.Cm s
 command.
 .El
 .Sh BUFFERS
@@ -1996,52 +1996,65 @@ Grow or shrink the current screen.
 Rewind the argument list.
 .Pp
 .It Xo
-.Cm se Ns Op Cm t
+.Op Ar range
 .Sm off
-.Op option Oo = Oo value Oc Oc \ \&...
+.Cm s
+.Oo Cm / Ar pattern Cm / Ar replace Cm /
+.Op Ar options
+.Op Ar count
+.Op Ar flags
+.Oc
 .Sm on
-.Pf \ \& Op nooption ...
-.Op option? ...
-.Op Ar all
-.Xc
-Display or set editor options.
-.Pp
-.It Cm sh Ns Op Cm ell
-Run a shell program.
-.Pp
-.It Xo
-.Cm so Ns Op Cm urce
-.Ar file
 .Xc
-Read and execute
-.Nm ex
-commands from a file.
-.Pp
 .It Xo
 .Op Ar range
-.Cm s Ns Op Cm ubstitute
 .Sm off
-.Op / Ar pattern No / Ar replace  No /
-.Sm on
-.Pf \ \& Op Ar options
+.Cm sub Op Cm stitute
+.Oo Cm / Ar pattern Cm / Ar replace Cm /
+.Op Ar options
 .Op Ar count
 .Op Ar flags
+.Sm on
 .Xc
 .It Xo
 .Op Ar range
+.Sm off
 .Cm &
 .Op Ar options
 .Op Ar count
 .Op Ar flags
+.Sm on
 .Xc
 .It Xo
 .Op Ar range
+.Sm off
 .Cm ~
 .Op Ar options
 .Op Ar count
 .Op Ar flags
+.Sm on
 .Xc
-Make substitutions.
+Substitute the regular expression
+.Ar pattern
+with
+.Ar replace .
+When invoked as
+.Cm & ,
+or if
+.Cm / Ns Ar pattern Ns Cm / Ns Ar replace Ns Cm /
+is omitted,
+.Ar pattern
+and
+.Ar replace
+from the most recent
+.Cm s
+command are used.
+.Cm ~
+behaves like
+.Cm & ,
+except the pattern used is the most recent regular expression used by any
+command.
+.Pp
 The
 .Ar replace
 field may contain any of the following sequences:
@@ -2051,13 +2064,13 @@ The text matched by
 .Ar pattern .
 .It Sq \(a~
 The replacement part of the previous
-.Cm substitute
+.Cm s
 command.
 .It Sq %
 If this is the entire
 .Ar replace
 pattern, the replacement part of the previous
-.Cm substitute
+.Cm s
 command.
 .It Sq \e#
 Where
@@ -2082,6 +2095,40 @@ to be converted to uppercase.
 Causes the next character to be converted to uppercase.
 .El
 .Pp
+The
+.Ar options
+field may contain any of the following characters:
+.Bl -tag -width Ds
+.It Sq c
+Prompt for confirmation before each replacement is done.
+.It Sq g
+Replace all instances of
+.Ar pattern
+in a line, not just the first.
+.El
+.Pp
+.It Xo
+.Cm se Ns Op Cm t
+.Sm off
+.Op option Oo = Oo value Oc Oc \ \&...
+.Sm on
+.Pf \ \& Op nooption ...
+.Op option? ...
+.Op Ar all
+.Xc
+Display or set editor options.
+.Pp
+.It Cm sh Ns Op Cm ell
+Run a shell program.
+.Pp
+.It Xo
+.Cm so Ns Op Cm urce
+.Ar file
+.Xc
+Read and execute
+.Nm ex
+commands from a file.
+.Pp
 .It Xo
 .Cm su Ns Op Cm spend Ns
 .Op Cm !\&
@@ -2291,7 +2338,9 @@ Remember the values of the
 and
 .Sq g
 suffixes to the
-.Cm substitute
+.Cm s , &
+and
+.Cm ~
 commands, instead of initializing them as unset for each new command.
 .It Cm escapetime Bq 1
 The tenths of a second
Index: ex/ex_cmd.c
===
RCS file: /cvs/src/usr.bin/vi/ex/ex_cmd.c,v
retrieving revision 1.10
diff -u -p -r1.10 ex_cmd.c
--- ex/ex_cmd.c 19 Nov 2015 07:53:31 -  1.10
+++ ex/ex_cmd.c 19 Jun 2017 09:19:23 -
@@ -288,8 +288,8 @@ EXCMDLIST const cmds[] = {
  * Adding new commands starting with 's' may break the substitute command code
  * in ex_cmd() (the ex parser).  Read through the comments there, first.
  */
-/* C_SUBSTITUTE */
-   {"s",   ex_s,   E_ADDR2,
+/* C_S */
+   {"s",   ex_s,   E_ADDR2,
"s",
"[line [,line]] s [[/;]RE[/;]repl[/;] [cgr] [count] [#lp]]",
"substitute on lines matching an RE"},
@@ -323,6 +323,11 @@ EXCMDLIST const cmds[] = {
"!",
"su[spend][!]",
"suspend the edit session"},
+/* C_SUBSTITUTE */
+   

vi(1): documenting :s

2017-06-15 Thread Anthony J. Bentley
Hi,

>From vi(1):

 [range] s[ubstitute] [/pattern/replace/]  [options] [count] [flags]
 [range] & [options] [count] [flags]
 [range] ~ [options] [count] [flags]
 Make substitutions.  The replace field may contain any of the
 following sequences:
 (...snip...)

There are a couple of issues here.

First, the command is "s" and only "s"; trying "substitute" results in
an error.

Additionally &, ~, and the options field remain unexplained.

This diff tries to makes things better. ok?

Index: docs/USD.doc/vi.man/vi.1
===
RCS file: /cvs/src/usr.bin/vi/docs/USD.doc/vi.man/vi.1,v
retrieving revision 1.67
diff -u -p -r1.67 vi.1
--- docs/USD.doc/vi.man/vi.115 Jun 2017 06:44:47 -  1.67
+++ docs/USD.doc/vi.man/vi.115 Jun 2017 08:08:49 -
@@ -356,7 +356,7 @@ matches the end of the word.
 .It
 .Sq ~
 matches the replacement part of the last
-.Cm substitute
+.Cm s
 command.
 .El
 .Sh BUFFERS
@@ -2019,7 +2019,7 @@ commands from a file.
 .Pp
 .It Xo
 .Op Ar range
-.Cm s Ns Op Cm ubstitute
+.Cm s
 .Sm off
 .Op / Ar pattern No / Ar replace  No /
 .Sm on
@@ -2041,7 +2041,27 @@ commands from a file.
 .Op Ar count
 .Op Ar flags
 .Xc
-Make substitutions.
+Substitute the regular expression
+.Ar pattern
+with
+.Ar replace .
+When invoked as
+.Cm & ,
+or if
+.Bq Ns / Ns Ar pattern Ns / Ns Ar replace Ns /
+is omitted,
+.Ar pattern
+and
+.Ar replace
+from the most recent
+.Cm s
+command are used.
+.Cm ~
+behaves like
+.Cm & ,
+except the pattern used is the most recent regular expression used by any
+command.
+.Pp
 The
 .Ar replace
 field may contain any of the following sequences:
@@ -2051,13 +2071,13 @@ The text matched by
 .Ar pattern .
 .It Sq \(a~
 The replacement part of the previous
-.Cm substitute
+.Cm s
 command.
 .It Sq %
 If this is the entire
 .Ar replace
 pattern, the replacement part of the previous
-.Cm substitute
+.Cm s
 command.
 .It Sq \e#
 Where
@@ -2082,6 +2102,18 @@ to be converted to uppercase.
 Causes the next character to be converted to uppercase.
 .El
 .Pp
+The
+.Ar options
+field may contain any of the following characters:
+.Bl -tag -width Ds
+.It Sq c
+Prompt for confirmation before each replacement is done.
+.It Sq g
+Replace all instances of
+.Ar pattern
+in a line, not just the first.
+.El
+.Pp
 .It Xo
 .Cm su Ns Op Cm spend Ns
 .Op Cm !\&
@@ -2291,7 +2323,9 @@ Remember the values of the
 and
 .Sq g
 suffixes to the
-.Cm substitute
+.Cm s , &
+and
+.Cm ~
 commands, instead of initializing them as unset for each new command.
 .It Cm escapetime Bq 1
 The tenths of a second



Check terminal width in ps(1)

2016-09-22 Thread Anthony J. Bentley
Hi,

Unlike all the other software in the tree that checks terminal sizes, 
ps(1) used to check the stdin and stderr terminal sizes as well as stdout.
When I unified the terminal size checks in the tree in March, I missed
this, and now "ps aux | blah" gets wrapped to 79 characters no matter
how big the terminal is.

The below diff brings back the old behavior: if the output is a pipe,
ps will check if either stderr or stdin is a terminal and if so will use
its width.

ok?

Index: ps.c
===
RCS file: /cvs/src/bin/ps/ps.c,v
retrieving revision 1.70
diff -u -p -r1.70 ps.c
--- ps.c17 Mar 2016 05:27:10 -  1.70
+++ ps.c22 Sep 2016 10:14:10 -
@@ -105,7 +105,10 @@ main(int argc, char *argv[])
termwidth = 0;
if ((cols = getenv("COLUMNS")) != NULL)
termwidth = strtonum(cols, 1, INT_MAX, NULL);
-   if (termwidth == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, ) == 0 &&
+   if (termwidth == 0 &&
+   (ioctl(STDOUT_FILENO, TIOCGWINSZ, ) == 0 ||
+   ioctl(STDERR_FILENO, TIOCGWINSZ, ) == 0 ||
+   ioctl(STDIN_FILENO, TIOCGWINSZ, ) == 0) &&
ws.ws_col > 0)
termwidth = ws.ws_col - 1;
if (termwidth == 0)
Index: ps.1
===
RCS file: /cvs/src/bin/ps/ps.1,v
retrieving revision 1.108
diff -u -p -r1.108 ps.1
--- ps.18 Sep 2016 15:54:36 -   1.108
+++ ps.122 Sep 2016 10:14:10 -
@@ -543,8 +543,13 @@ If set to a positive integer,
 output is formatted to the given width in columns.
 Otherwise,
 .Nm
-defaults to the terminal width \(mi 1, or 79 columns if the output is not a
-terminal.
+defaults to the terminal width \(mi 1,
+or 79 columns if none of
+.Dv stdout ,
+.Dv stderr
+and
+.Dv stdin
+are a terminal.
 .It Ev TZ
 The time zone to use when displaying dates.
 See



Re: Sync getopt with getopt

2016-09-05 Thread Anthony J. Bentley
"Ted Unangst" writes:
> Todd C. Miller wrote:
> > On Sun, 04 Sep 2016 11:58:23 -0600, "Anthony J. Bentley" wrote:
> > 
> > > This brings /usr/share/misc/getopt in sync with the example in getopt(3).
> > 
> > OK, though I wonder if anyone actually looks at this file?
> 
> i think it's better to delete it.

Works for me.



Remove /usr/share/misc/eqnchar

2016-09-04 Thread Anthony J. Bentley
Hi,

eqnchar is a collection of eqn(7) definitions to create mathematical
symbols by constructing them from other characters. Creating circled
plus with O, a backspace, and a plus, for example. The results are
quite ugly in both mandoc and groff if it even works at all.

Nothing in base (or even anywhere?) uses these weird macros. Anyone
doing mathematical typesetting will be much better served by reading
through mandoc_char(7) or the Unicode Mathematical Operators block.

ok?

Index: Makefile
===
RCS file: /cvs/src/share/misc/Makefile,v
retrieving revision 1.13
diff -u -p -r1.13 Makefile
--- Makefile25 Aug 2014 14:29:49 -  1.13
+++ Makefile5 Sep 2016 02:15:15 -
@@ -1,7 +1,7 @@
 #  $OpenBSD: Makefile,v 1.13 2014/08/25 14:29:49 reyk Exp $
 #  from: @(#)Makefile  5.13 (Berkeley) 5/7/91
 
-FILES= airport ascii birthtoken countrycodes eqnchar getopt \
+FILES= airport ascii birthtoken countrycodes getopt \
inter.phone license.template mdoc.template mime.types \
na.phone operator scsi_modes usb_hid_usages usb_hid_usages \
zipcodes 
Index: eqnchar
===
RCS file: eqnchar
diff -N eqnchar
--- eqnchar 18 Oct 1995 08:44:44 -  1.1.1.1
+++ /dev/null   1 Jan 1970 00:00:00 -
@@ -1,90 +0,0 @@
-.EQ
-tdefine ciplus % "\o'\(pl\(ci'" %
-ndefine ciplus % O+ %
-tdefine citimes % "\o'\(mu\(ci'" %
-ndefine citimes % Ox %
-tdefine =wig % 
"\(eq\h'-\w'\(eq'u-\w'\s-2\(ap'u/2u'\v'-.4m'\s-2\z\(ap\(ap\s+2\v'.4m'\h'\w'\(eq'u-\w'\s-2\(ap'u/2u'"
 %
-ndefine =wig % ="~" %
-tdefine bigstar % "\o'\(pl\(mu'" %
-ndefine bigstar % X|- %
-tdefine =dot % "\z\(eq\v'-.6m'\h'.2m'\s+2.\s-2\v'.6m'\h'.1m'" %
-ndefine =dot % = dot %
-tdefine orsign % "\s-2\v'-.15m'\z\e\e\h'-.05m'\z\(sl\(sl\v'.15m'\s+2" %
-ndefine orsign % \e/ %
-tdefine andsign % "\s-2\v'-.15m'\z\(sl\(sl\h'-.05m'\z\e\e\v'.15m'\s+2" %
-ndefine andsign % /\e %
-tdefine =del % "\v'.3m'\z=\v'-.6m'\h'.3m'\s-1\(*D\s+1\v'.3m'" %
-ndefine =del % = to DELTA %
-tdefine oppA % 
"\s-2\v'-.15m'\z\e\e\h'-.05m'\z\(sl\(sl\v'-.15m'\h'-.75m'\z-\z-\h'.2m'\z-\z-\v'.3m'\h'.4m'\s+2"
 %
-ndefine oppA % V- %
-tdefine oppE 
%"\s-3\v'.2m'\z\(em\v'-.5m'\z\(em\v'-.5m'\z\(em\v'.55m'\h'.9m'\z\(br\z\(br\v'.25m'\s+3"
 %
-ndefine oppE % E/ %
-tdefine incl % 
"\s-1\z\(or\h'-.1m'\v'-.45m'\z\(em\v'.7m'\z\(em\v'.2m'\(em\v'-.45m'\s+1" %
-ndefine incl % C_ %
-tdefine nomem % "\o'\(mo\(sl'" %
-ndefine nomem % C-/ %
-tdefine angstrom % "\fR\zA\v'-.3m'\h'.2m'\(de\v'.3m'\fP\h'.2m'" %
-ndefine angstrom % A to o %
-tdefine star %{ roman "\v'.5m'\s+3*\s-3\v'-.5m'"}%
-ndefine star % * %
-tdefine || % \(or\(or %
-tdefine wig % "\z>\v'.4m'\(ap\v'-.4m'" %
-ndefine >wig %{ > from "~" }%
-tdefine langle % "\s-3\b'\(sl\e'\s0" %
-ndefine langle %<%
-tdefine rangle % "\s-3\b'\e\(sl'\s0" %
-ndefine rangle %>%
-tdefine hbar % "\zh\v'-.6m'\h'.05m'\(ru\v'.6m'" %
-ndefine hbar % h\u-\d %
-ndefine ppd % _| %
-tdefine ppd % "\o'\(ru\s-2\(or\s+2'" %
-tdefine <-> % "\o'\(<-\(->'" %
-ndefine <-> % "<-->" %
-tdefine <=> % "\s-2\z<\v'.05m'\h'.2m'\z=\h'.55m'=\h'-.6m'\v'-.05m'>\s+2" %
-ndefine <=> % "<=>" %
-tdefine |< % "\o'<\(or'" %
-ndefine |< % <| %
-tdefine |> % "\o'>\(or'" %
-ndefine |> % |> %
-tdefine ang % "\v'-.15m'\z\s-2\(sl\s+2\v'.15m'\(ru" %
-ndefine ang % /_ %
-tdefine rang % "\z\(or\h'.15m'\(ru" %
-ndefine rang % L %
-tdefine 3dot % "\v'-.8m'\z.\v'.5m'\z.\v'.5m'.\v'-.2m'" %
-ndefine 3dot % .\u.\u.\d\d %
-tdefine thf % ".\v'-.5m'.\v'.5m'." %
-ndefine thf % ..\u.\d %
-tdefine quarter % roman \(14 %
-ndefine quarter % 1/4 %
-tdefine 3quarter % roman \(34 %
-ndefine 3quarter % 3/4 %
-tdefine degree % \(de %
-ndefine degree % nothing sup o %
-tdefine square % \(sq %
-ndefine square % [] %
-tdefine circle % \(ci %
-ndefine circle % O %
-tdefine blot % "\fB\(sq\fP" %
-ndefine blot % HIX %
-tdefine bullet % \(bu %
-ndefine bullet % oxe %
-tdefine -wig % "\(~=" %
-ndefine -wig % - to "~" %
-tdefine wig % \(ap %
-ndefine wig % "~" %
-tdefine prop % \(pt %
-ndefine prop % oc %
-tdefine empty % \(es %
-ndefine empty % O/ %
-tdefine member % \(mo %
-ndefine member % C- %
-tdefine cup % \(cu %
-ndefine cup % U %
-define cap % \(ca %
-define subset % \(sb %
-define supset % \(sp %
-define !subset % \(ib %
-define !supset % \(ip %
-.EN



Sync getopt with getopt

2016-09-04 Thread Anthony J. Bentley
Hi,

This brings /usr/share/misc/getopt in sync with the example in getopt(3).

ok?

Index: getopt
===
RCS file: /cvs/src/share/misc/getopt,v
retrieving revision 1.8
diff -u -p -r1.8 getopt
--- getopt  1 Feb 2006 09:27:28 -   1.8
+++ getopt  4 Sep 2016 17:43:54 -
@@ -5,6 +5,8 @@
  * from: @(#)getopt5.3 (Berkeley) 3/28/94
  */
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -14,23 +16,22 @@ __dead void usage(void);
 int
 main(int argc, char *argv[])
 {
-   int bflag, ch;
-   char *file;
+   int bflag, ch, fd;
 
bflag = 0;
-   file = NULL;
-   while ((ch = getopt(argc, argv, "bf:")) != -1)
+   while ((ch = getopt(argc, argv, "bf:")) != -1) {
switch (ch) {
case 'b':
bflag = 1;
break;
case 'f':
-   file = optarg;
+   if ((fd = open(optarg, O_RDONLY, 0)) == -1)
+   err(1, "%s", optarg);
break;
default:
usage();
-   /* NOTREACHED */
}
+   }
argc -= optind;
argv += optind;
 



vi: add COLUMNS/LINES validity checks

2016-03-14 Thread Anthony J. Bentley
vi is kind of weird about COLUMNS/LINES handling.

For one, it doesn't do any error checking:

$ COLUMNS=a vi
Floating point exception (core dumped) 

The manpage also claims that COLUMNS supersedes everything else. This
is true... unless you ^Z and then unsuspend, at which point it uses
TIOCGWINSZ.

And then it has to handle :set columns, which it does by setting
environment variables and immediately unsetting them...

Maybe I just don't get it, but it all seems very complicated. For
the time being here's a diff to at least add error checking so COLUMNS
can't crash the program. Kept as strtol() since patches still flow
between our vi and sundry forks.

ok?

Index: cl/cl_term.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_term.c,v
retrieving revision 1.21
diff -u -p -r1.21 cl_term.c
--- cl/cl_term.c6 Jan 2016 22:28:52 -   1.21
+++ cl/cl_term.c14 Mar 2016 07:38:41 -
@@ -319,7 +319,8 @@ cl_ssize(SCR *sp, int sigwinch, size_t *
struct winsize win;
size_t col, row;
int rval;
-   char *p;
+   long lval;
+   char *p, *ep;
 
/* Assume it's changed. */
if (changedp != NULL)
@@ -413,10 +414,28 @@ noterm:   if (row == 0)
 * deleting the LINES and COLUMNS environment variables from their
 * dot-files.
 */
-   if ((p = getenv("LINES")) != NULL)
-   row = strtol(p, NULL, 10);
-   if ((p = getenv("COLUMNS")) != NULL)
-   col = strtol(p, NULL, 10);
+   if ((p = getenv("LINES")) != NULL) {
+   errno = 0;
+   lval = strtol(p, , 10);
+   if (p[0] == '\0' || *ep != '\0')
+   ;
+   else if ((errno == ERANGE && (lval == LONG_MAX || lval ==
+   LONG_MIN)) || (lval > INT_MAX || lval < 1))
+   ;
+   else
+   row = lval;
+   }
+   if ((p = getenv("COLUMNS")) != NULL) {
+   errno = 0;
+   lval = strtol(p, , 10);
+   if (p[0] == '\0' || *ep != '\0')
+   ;
+   else if ((errno == ERANGE && (lval == LONG_MAX || lval ==
+   LONG_MIN)) || (lval > INT_MAX || lval < 1))
+   ;
+   else
+   col = lval;
+   }
 
if (rowp != NULL)
*rowp = row;



COLUMNS handling

2016-03-14 Thread Anthony J. Bentley
COLUMNS handling in our tree is inconsistent.

POSIX specifies that if COLUMNS is a valid value (read: 1 or greater),
it takes precedence; otherwise, width is handled in an unspecified 
manner.

Most programs follow COLUMNS, TIOCGWINSZ if that fails, and use 80 if
that fails. Some do TIOCGWINSZ, then COLUMNS, then 80. Some use a
different value than 80. And they're all inconsistently documented, if
they're documented at all.

This diff switches the tree to a single pattern: COLUMNS, TIOCGWINSZ, 80;
strtonum() for range checking; and documents it in the relevant manuals.
The odd one out is ps, which respected COLUMNS but otherwise used
TIOCGWINSZ - 1 and 80 - 1. Changing that behavior seemed potentially 
scary so I left it as is.

Comments? ok?

Index: bin/ls/ls.1
===
RCS file: /cvs/src/bin/ls/ls.1,v
retrieving revision 1.74
diff -u -p -r1.74 ls.1
--- bin/ls/ls.1 11 Mar 2016 02:35:57 -  1.74
+++ bin/ls/ls.1 13 Mar 2016 11:10:57 -
@@ -436,10 +436,12 @@ option is not specified, the block count
 .Fl s )
 will be displayed in units of that size block.
 .It Ev COLUMNS
-If this variable contains a string representing a
-decimal integer, it is used as the
-column position width for displaying
-multiple-text-column output.
+If set to a positive integer,
+.Nm Ns 's
+output is formatted to the given width in columns.
+Otherwise,
+.Nm
+defaults to the terminal width, or 80 columns if the output is not a terminal.
 .It Ev LC_CTYPE
 If set to a string ending in
 .Qq .UTF-8 ,
Index: bin/ls/ls.c
===
RCS file: /cvs/src/bin/ls/ls.c,v
retrieving revision 1.44
diff -u -p -r1.44 ls.c
--- bin/ls/ls.c 1 Dec 2015 18:36:13 -   1.44
+++ bin/ls/ls.c 13 Mar 2016 11:10:57 -
@@ -66,7 +66,7 @@ static int (*sortfcn)(const FTSENT *, co
 #defineBY_TIME 2
 
 long blocksize;/* block size units */
-int termwidth = 80;/* default terminal width */
+int termwidth; /* default terminal width */
 int sortkey = BY_NAME;
 
 /* flags */
@@ -110,23 +110,19 @@ ls_main(int argc, char *argv[])
 
/* Terminal defaults to -Cq, non-terminal defaults to -1. */
if (isatty(STDOUT_FILENO)) {
-   if ((p = getenv("COLUMNS")) != NULL)
-   width = strtonum(p, 1, INT_MAX, NULL);
-   if (width == 0 &&
-   ioctl(STDOUT_FILENO, TIOCGWINSZ, ) == 0 &&
-   win.ws_col > 0)
-   width = win.ws_col;
-   if (width)
-   termwidth = width;
f_column = f_nonprint = 1;
} else {
f_singlecol = 1;
-   /* retrieve environment variable, in case of explicit -C */
-   if ((p = getenv("COLUMNS")) != NULL)
-   width = strtonum(p, 0, INT_MAX, NULL);
-   if (width)
-   termwidth = width;
}
+
+   termwidth = 0;
+   if ((p = getenv("COLUMNS")) != NULL)
+   termwidth = strtonum(p, 1, INT_MAX, NULL);
+   if (termwidth == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, ) == 0 &&
+   win.ws_col > 0)
+   termwidth = win.ws_col;
+   if (termwidth == 0)
+   termwidth = 80;
 
if (pledge("stdio rpath getpw", NULL) == -1)
err(1, "pledge");
Index: bin/ps/ps.1
===
RCS file: /cvs/src/bin/ps/ps.1,v
retrieving revision 1.102
diff -u -p -r1.102 ps.1
--- bin/ps/ps.1 22 Oct 2015 22:21:41 -  1.102
+++ bin/ps/ps.1 13 Mar 2016 11:10:58 -
@@ -543,10 +543,13 @@ The following environment variables affe
 .Nm :
 .Bl -tag -width "COLUMNS"
 .It Ev COLUMNS
-If set, specifies the user's preferred output width in column positions.
-By default,
+If set to a positive integer,
+.Nm Ns 's
+output is formatted to the given width in columns.
+Otherwise,
 .Nm
-attempts to automatically determine the terminal width.
+defaults to the terminal width \(mi 1, or 79 columns if the output is not a
+terminal.
 .It Ev TZ
 The time zone to use when displaying dates.
 See
Index: bin/ps/ps.c
===
RCS file: /cvs/src/bin/ps/ps.c,v
retrieving revision 1.69
diff -u -p -r1.69 ps.c
--- bin/ps/ps.c 10 Jan 2016 14:04:16 -  1.69
+++ bin/ps/ps.c 13 Mar 2016 11:10:58 -
@@ -102,22 +102,14 @@ main(int argc, char *argv[])
 
setlocale(LC_CTYPE, "");
 
-   if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0') {
-   const char *errstr;
-
-   termwidth = strtonum(cols, 1, INT_MAX, );
-   if (errstr != NULL)
-   warnx("COLUMNS: %s: %s", cols, errstr);
-   }
-   if (termwidth == 0) {
-   if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, ) == -1 &&
-   ioctl(STDERR_FILENO, 

Re: bug in fputwc(3) error reporting

2015-12-26 Thread Anthony J. Bentley
Hi Jérémie,

Jérémie Courrèges-Anglas writes:
> Hmm, the C standard and POSIX have slightly different texts regarding
> this.
> 
> Quoting POSIX-2013:
> -->8--
>   RETURN VALUE
> 
> Upon successful completion, fputwc() shall return wc. Otherwise, it
> shall return WEOF, the error indicator for the stream shall be set,
> [CX] and errno shall be set to indicate the error.
...
> So, the C standard doesn't say that the error indicator should be set on
> the FILE in case of an encoding error, it only speaks about errno being
> set to EILSEQ.  I'd say that we should follow the C standard here -
> after all "This volume of POSIX.1-2008 defers to the ISO C standard".

The [CX] there means it's an intentional extension of ISO C. This is
more obvious in the HTML copy of POSIX,
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fputwc.html

Quoting more POSIX (the [CX] defintion),

The functionality described is an extension to the ISO C standard.
Application developers may make use of an extension as it is
supported on all POSIX.1-2008-conforming systems.

With each function or header from the ISO C standard, a statement to
the effect that "any conflict is unintentional" is included. That is
intended to refer to a direct conflict. POSIX.1-2008 acts in part as
a profile of the ISO C standard, and it may choose to further
    constrain behaviors allowed to vary by the ISO C standard.

-- 
Anthony J. Bentley



Detect more keyboard cases when starting X

2015-12-25 Thread Anthony J. Bentley
Hi,

As X starts, it will attempt to detect features from the kbd(8)
setting--for example, us.dvorak will enable dvorak in X, and
fr.dvorak will enable French dvorak in X. However, it detects
these features with equality checks, which will fail if multiple
options are set, as in the case of us.dvorak.swapctrlcaps or
fr.dvorak.swapctrlcaps.

Instead of checking for equality, this diff instead checks if the
bits are set. Now us.dvorak.swapctrlcaps and fr.dvorak.swapctrlcaps
work, us.swapctrlcaps.iopener swaps ctrl/caps, and the ones that
already worked (de.nodead, etc) still do.

This was reported on misc@ by "Sevan / Venture37" back in June.

ok?

Index: config/wscons.c
===
RCS file: /cvs/xenocara/xserver/config/wscons.c,v
retrieving revision 1.14
diff -u -p -r1.14 wscons.c
--- config/wscons.c 15 Jan 2015 01:30:40 -  1.14
+++ config/wscons.c 25 Dec 2015 21:37:21 -
@@ -139,7 +139,7 @@ wscons_add_keyboard(void)
 break;
 }
 for (i = 0; kbdvar[i].val; i++)
-if (wsenc == kbdvar[i].val || KB_VARIANT(wsenc) == kbdvar[i].val) {
+if ((wsenc & kbdvar[i].val) == kbdvar[i].val) {
 LogMessageVerb(X_INFO, 3, "wskbd: using variant %s\n",
kbdvar[i].name);
 input_options = input_option_new(input_options,
@@ -147,7 +147,7 @@ wscons_add_keyboard(void)
 break;
 }
 for (i = 0; kbdopt[i].val; i++)
-if (KB_VARIANT(wsenc) == kbdopt[i].val) {
+if (KB_VARIANT(wsenc) & kbdopt[i].val) {
 LogMessageVerb(X_INFO, 3, "wskbd: using option %s\n",
kbdopt[i].name);
 input_options = input_option_new(input_options,



Re: vi: default to tab for filename completion

2015-11-24 Thread Anthony J. Bentley
Gregor Best writes:
> On Mon, Nov 23, 2015 at 01:36:00AM -0700, Anthony J. Bentley wrote:
> > [...]
> 
> In addition to this, my ~/.exrc also sets cedit to tab. Would this
> make sense here as well? Currently it's disabled by default, but
> IMHO it's a useful feature for longer editing sessions.

An interesting feature, but I don't think it would be a sensible
default. Filename tab completion is intuitive but tab triggering
a window that contains command history you can scroll through is
not something I would expect by default.

-- 
Anthony J. Bentley



vi: don't escape backspace with backslash

2015-11-23 Thread Anthony J. Bentley
When I hit backspace after a backslash, usually I just want to delete
the backslash. I don't think I've ever intended to input a literal ^?.
If I ever did want to insert ^H, ^?, or ^U, I would just type ^V first.

I've passed this diff around privately before and gotten a tepid
response, but it was pointed out to me that it would fit better on tech@.

Index: vi/v_txt.c
===
RCS file: /cvs/src/usr.bin/vi/vi/v_txt.c,v
retrieving revision 1.27
diff -u -p -u -p -r1.27 v_txt.c
--- vi/v_txt.c  12 Nov 2014 04:28:41 -  1.27
+++ vi/v_txt.c  19 Nov 2014 01:17:45 -
@@ -618,30 +617,21 @@ replay:   if (LF_ISSET(TXT_REPLAY))
 
/*
 * !!!
-* If this character was quoted by a K_VLNEXT or a backslash, replace
-* the placeholder (a carat or a backslash) with the new character.
-* If it was quoted by a K_VLNEXT, we've already adjusted the cursor
-* because it has to appear on top of the placeholder character.  If
-* it was quoted by a backslash, adjust the cursor now, the cursor
-* doesn't appear on top of it.  Historic practice in both cases.
+* If this character was quoted by a K_VLNEXT, replace the placeholder
+* (a carat) with the new character.  We've already adjusted the cursor
+* because it has to appear on top of the placeholder character.
+* Historic practice.
 *
 * Skip tests for abbreviations; ":ab xa XA" followed by "ixa^V"
 * doesn't perform an abbreviation.  Special case, ^V^J (not ^V^M) is
 * the same as ^J, historically.
 */
-   if (quote == Q_BTHIS || quote == Q_VTHIS) {
+   if (quote == Q_VTHIS) {
FL_CLR(ec_flags, EC_QUOTED);
if (LF_ISSET(TXT_MAPINPUT))
FL_SET(ec_flags, EC_MAPINPUT);
 
-   if (quote == Q_BTHIS &&
-   (evp->e_value == K_VERASE || evp->e_value == K_VKILL)) {
-   quote = Q_NOTSET;
-   --tp->cno;
-   ++tp->owrite;
-   goto insl_ch;
-   }
-   if (quote == Q_VTHIS && evp->e_value != K_NL) {
+   if (evp->e_value != K_NL) {
quote = Q_NOTSET;
goto insl_ch;
}
@@ -1201,31 +1191,6 @@ leftmargin:  tp->lb[tp->cno - 1] = ' ';
if (LF_ISSET(TXT_SHOWMATCH))
showmatch = 1;
goto ins_ch;
-   case K_BACKSLASH:   /* Quote next erase/kill. */
-   /*
-* !!!
-* Historic vi tried to make abbreviations after a backslash
-* escape work.  If you did ":ab x y", and inserted "x\^H",
-* (assuming the erase character was ^H) you got "x^H", and
-* no abbreviation was done.  If you inserted "x\z", however,
-* it tried to back up and do the abbreviation, i.e. replace
-* 'x' with 'y'.  The problem was it got it wrong, and you
-* ended up with "zy\".
-*
-* This is really hard to do (you have to remember the
-* word/non-word state, for example), and doesn't make any
-* sense to me.  Both backslash and the characters it
-* (usually) escapes will individually trigger the
-* abbreviation, so I don't see why the combination of them
-* wouldn't.  I don't expect to get caught on this one,
-* particularly since it never worked right, but I've been
-* wrong before.
-*
-* Do the tests for abbreviations, so ":ab xa XA",
-* "ixa\" performs the abbreviation.
-*/
-   quote = Q_BNEXT;
-   goto insq_ch;
case K_VLNEXT:  /* Quote next character. */
evp->e_c = '^';
quote = Q_VNEXT;
@@ -1363,8 +1328,6 @@ ebuf_chk: if (tp->cno >= tp->len) {
 
/* Step the quote state forward. */
if (quote != Q_NOTSET) {
-   if (quote == Q_BNEXT)
-   quote = Q_BTHIS;
if (quote == Q_VNEXT)
quote = Q_VTHIS;
}
Index: vi/vi.h
===
RCS file: /cvs/src/usr.bin/vi/vi/vi.h,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 vi.h
--- vi/vi.h 28 Nov 2013 22:12:40 -  1.7
+++ vi/vi.h 19 Nov 2014 01:17:45 -
@@ -218,7 +218,7 @@ typedef struct _smap {
 typedef enum { CNOTSET, FSEARCH, fSEARCH, TSEARCH, tSEARCH } cdir_t;
 
 typedef enum { AB_NOTSET, AB_NOTWORD, AB_INWORD } abb_t;
-typedef enum { Q_NOTSET, Q_BNEXT, Q_BTHIS, Q_VNEXT, Q_VTHIS } quote_t;
+typedef enum { Q_NOTSET, 

Re: Pledge for Vi and Ex

2015-11-19 Thread Anthony J. Bentley
"Anthony J. Bentley" writes:
> Gregor Best writes:
> > @@ -229,6 +230,14 @@ editor(GS *gp, int argc, char *argv[])
> > }
> > if (LF_ISSET(SC_EX) && F_ISSET(gp, G_SCRIPTED))
> > silent =3D 1;
> > +
> > +   if (secure) {
> > +   if (pledge("stdio rpath wpath cpath fattr flock tty", NULL))
> > +   err(1, "pledge");
> 
> I didn't include this chunk because currently even in -S mode you need
> proc/exec for cscope.

cscope is gone now, so this can be considered again.

vi uses the proc pledge for three reasons:
 - uses kill() to suspend (^Z or :suspend)
 - uses vfork() for filters (the ! command)
 - uses vfork() for shell expansion

All three of these are disabled when the -S flag is set, so we can pledge
never to proc/exec in that case.

ok?


Index: common/main.c
===
RCS file: /cvs/src/usr.bin/vi/common/main.c,v
retrieving revision 1.28
diff -u -p -r1.28 main.c
--- common/main.c   15 Nov 2015 01:22:36 -  1.28
+++ common/main.c   19 Nov 2015 08:40:11 -
@@ -223,6 +223,11 @@ editor(GS *gp, int argc, char *argv[])
argc -= optind;
argv += optind;
 
+   if (secure && pledge("stdio rpath wpath cpath fattr flock getpw tty", 
NULL) == -1) {
+   perror("pledge");
+   goto err;
+   }
+
/*
 * -s option is only meaningful to ex.
 *



Re: Pledge for Vi and Ex

2015-11-14 Thread Anthony J. Bentley
Gregor Best writes:
> Hi people,
> 
> inspired by someone on Hackernews talking about how hard it would be to
> properly pledge an editor, here's a patch to pledge Vi and Ex.

I'd like to investigate the ideas you mentioned: disabling proc/exec with
-S and making -R actually read-only. But both of those would require
some significant changes--so let's start sending patches and discussing
them, but first I want to get this pledge (equivalent to mg's) in ASAP.

I've been using this for a few days now. Anything I missed? Tests? oks?


Index: common/main.c
===
RCS file: /cvs/src/usr.bin/vi/common/main.c,v
retrieving revision 1.26
diff -u -p -r1.26 main.c
--- common/main.c   20 Nov 2014 08:50:53 -  1.26
+++ common/main.c   14 Nov 2015 15:47:09 -
@@ -55,6 +55,11 @@ editor(GS *gp, int argc, char *argv[])
int ch, flagchk, lflag, secure, startup, readonly, rval, silent;
char *tag_f, *wsizearg, path[256];
 
+   if (pledge("stdio rpath wpath cpath fattr getpw proc exec tty", NULL) 
== -1) {
+   perror("pledge");
+   goto err;
+   }
+
static const char *optstr[3] = {
 #ifdef DEBUG
"c:D:FlRrSsT:t:vw:",



Re: Pledge for Vi and Ex

2015-11-14 Thread Anthony J. Bentley
Gregor Best writes:
> @@ -229,6 +230,14 @@ editor(GS *gp, int argc, char *argv[])
>   }
>   if (LF_ISSET(SC_EX) && F_ISSET(gp, G_SCRIPTED))
>   silent = 1;
> +
> + if (secure) {
> + if (pledge("stdio rpath wpath cpath fattr flock tty", NULL))
> + err(1, "pledge");

I didn't include this chunk because currently even in -S mode you need
proc/exec for cscope.

It's unusual for base tools to have functionality that depends on
programs not in base. I'm inclined to just yank out cscope support
completely. That would allow us to provide a better pledge for -S.

I've tested this some, but not much... it's possible I broke something.
(Yes, everything in ex_def.h does need to be renumbered.)

Index: build/Makefile
===
RCS file: /cvs/src/usr.bin/vi/build/Makefile,v
retrieving revision 1.21
diff -u -p -r1.21 Makefile
--- build/Makefile  20 Nov 2014 08:50:53 -  1.21
+++ build/Makefile  14 Nov 2015 15:27:10 -
@@ -18,7 +18,7 @@ CFLAGS+= -fno-tree-dominator-opts
 
 SRCS=  cl_funcs.c cl_main.c cl_read.c cl_screen.c cl_term.c \
cut.c delete.c ex.c ex_abbrev.c ex_append.c ex_args.c ex_argv.c \
-   ex_at.c ex_bang.c ex_cd.c ex_cmd.c ex_cscope.c ex_delete.c \
+   ex_at.c ex_bang.c ex_cd.c ex_cmd.c ex_delete.c \
ex_display.c ex_edit.c ex_equal.c ex_file.c ex_filter.c \
ex_global.c ex_init.c ex_join.c ex_map.c ex_mark.c ex_mkexrc.c \
ex_move.c ex_open.c ex_preserve.c ex_print.c ex_put.c \
Index: common/common.h
===
RCS file: /cvs/src/usr.bin/vi/common/common.h,v
retrieving revision 1.7
diff -u -p -r1.7 common.h
--- common/common.h 12 Nov 2014 16:29:04 -  1.7
+++ common/common.h 14 Nov 2015 15:27:10 -
@@ -19,7 +19,6 @@
  * are far too interrelated for a clean solution.
  */
 typedef struct _cb CB;
-typedef struct _cscCSC;
 typedef struct _event  EVENT;
 typedef struct _excmd  EXCMD;
 typedef struct _exfEXF;
Index: common/exf.c
===
RCS file: /cvs/src/usr.bin/vi/common/exf.c,v
retrieving revision 1.37
diff -u -p -r1.37 exf.c
--- common/exf.c7 Jul 2015 18:34:12 -   1.37
+++ common/exf.c14 Nov 2015 15:27:11 -
@@ -933,7 +933,7 @@ file_write(SCR *sp, MARK *fm, MARK *tm, 
}
 
/*
-* There's a nasty problem with long path names.  Cscope and tags files
+* There's a nasty problem with long path names.  Tags files
 * can result in long paths and vi will request a continuation key from
 * the user.  Unfortunately, the user has typed ahead, and chaos will
 * result.  If we assume that the characters in the filenames only take
Index: common/msg.c
===
RCS file: /cvs/src/usr.bin/vi/common/msg.c,v
retrieving revision 1.22
diff -u -p -r1.22 msg.c
--- common/msg.c16 Jan 2015 06:40:14 -  1.22
+++ common/msg.c14 Nov 2015 15:27:11 -
@@ -459,7 +459,7 @@ msgq_status(SCR *sp, recno_t lno, u_int 
len = p - bp;
 
/*
-* There's a nasty problem with long path names.  Cscope and tags files
+* There's a nasty problem with long path names.  Tags files
 * can result in long paths and vi will request a continuation key from
 * the user as soon as it starts the screen.  Unfortunately, the user
 * has already typed ahead, and chaos results.  If we assume that the
Index: common/screen.h
===
RCS file: /cvs/src/usr.bin/vi/common/screen.h,v
retrieving revision 1.7
diff -u -p -r1.7 screen.h
--- common/screen.h 20 Nov 2014 08:50:53 -  1.7
+++ common/screen.h 14 Nov 2015 15:27:11 -
@@ -98,7 +98,6 @@ struct _scr {
CHAR_T   at_lbuf;   /* Ex/vi: Last executed at buffer. */
 
/* Ex/vi: re_compile flags. */
-#defineRE_C_CSCOPE 0x0001  /* Compile cscope pattern. */
 #defineRE_C_SEARCH 0x0002  /* Compile search replacement. 
*/
 #defineRE_C_SILENT 0x0004  /* No error messages. */
 #defineRE_C_SUBST  0x0008  /* Compile substitute 
replacement. */
@@ -107,7 +106,6 @@ struct _scr {
 #defineRE_WSTART   "[[:<:]]"   /* Ex/vi: not-in-word search 
pattern. */
 #defineRE_WSTOP"[[:>:]]"
/* Ex/vi: flags to search routines. */
-#defineSEARCH_CSCOPE   0x0001  /* Search for a cscope pattern. 
*/
 #defineSEARCH_EOL  0x0002  /* Offset past EOL is okay. */
 #defineSEARCH_FILE 0x0004  /* Search the entire file. */
 #defineSEARCH_INCR 

Re: ld.so crash second attempt

2015-11-03 Thread Anthony J. Bentley
Hi Philip,

Philip Guenther writes:
> Thus the diff below.  It works with your test setup (thanks for writing 
> that!), passes regress/libexec/ld.so/, and chrome hasn't choked on it.  
> Can someone who's familiar with the sdl problem case test it there?

This patch fixes my sdl2 testcase, mupen64plus. Thanks for looking into
this along with Peter.

-- 
Anthony J. Bentley



Re: wc does not count last line if no trailing newline present

2015-11-03 Thread Anthony J. Bentley
dan mclaughlin writes:
> i was writing a script when i ran across this.

Is there a wc that doesn't behave this way? POSIX wc explicitly counts
newline characters. So this is probably the behavior people write their
scripts against.



Re: utf8 hack for ls

2015-10-27 Thread Anthony J. Bentley
"Ted Unangst" writes:
> Fixing citrus is a pretty massive effort in itself. I'd prefer to see the
> replacement code prove itself as a separate API first, then we can remove
> citrus and change the wchar functions to use the new code. I'm less confident
> in a "meet in the middle" effort where we convert to wchar while simultanesou
> ly
> hoping the wchar code gets better.

So how about a compromise? Use wchar_t where necessary, and no more
than that. After several programs get converted, come up with a better
wchar_t-free API, because at that time it becomes clear what kind of
functions are necessary.

> In the mean time, maybe we should also look at a few more utilities. We seem
> to have some intuition that mbwidth() etc. will be useful, and maybe mbvis(),
> but we don't really know. So far I've poked at ul, rs, and ls. Then we've gon
> e
> around in circles polishing those particular turds, but not much effort was
> spent looking at other utilities.

schwarze@, zhuk@ and czarkoff@ (and maybe others) spent time looking at
assorted utilities and classifying them. The difference between ls and
the other programs you mentioned is that it calculates *and uses* column
widths of frequently-UTF-8 data. Counting codepoints isn't adequate--most
UTF-8 filenames on my system contain double-width characters. Until we
come up with a better API, the *only* way to check widths is wcwidth()
and friends. And the best way to come up with a better replacement is to
have real programs that count columns. Or would you prefer to add a full
range of Unicode width tables to ls?

> What about wc? file? du? top? cut? vis???
> 
> Will adding utf-8/unicode support to each of those look the same? Or will
> every utility be different?

Again--there are a few broad categories that will require different
approaches. ls(1) is in the "needs to count columns" category.

> Additionally, I think all diffs to fix ls should be accompanied by before
> and after ktrace output. :)

That's a snappy line, and one that exposes a real problem in our wchar_t
implementation, but it doesn't help ls work in ~/anime/...



Re: clean up mbtowc(3) man page

2015-10-27 Thread Anthony J. Bentley
Stefan Sperling writes:
> On Tue, Oct 27, 2015 at 04:21:28PM +0100, Vadim Zhukov wrote:
> > Since we're already talking about "s==NULL" case, stating it again is
> > extraneous. IMHO, better would be:
> > 
> >  .Fa pwc
> > -is completely ignored.
> > +is ignored.
> > 
> > >  .It pwc == NULL
> > >  .Fn mbtowc
> > >  executes the conversion as if
> > >  .Fa pwc
> > > -is non-null, but a result of the conversion is discarded.
> > > +was not
> > > +.Dv NULL ,
> > > +but the result of the conversion is discarded.
> > 
> > IMHO, this should clarify if this would modify internal state.
> 
> Thanks. New diff including off-list feedback from jmc.
> 
> This is looking much better now, I think.
> 
> (@bentley, I would be grateful if you could give this another
> look to see if it clarifies your questions)

Yes, this is much better. One tweak below:

> Index: mbtowc.3
> ===
> RCS file: /cvs/src/lib/libc/locale/mbtowc.3,v
> retrieving revision 1.4
> diff -u -p -r1.4 mbtowc.3
> --- mbtowc.3  5 Jun 2013 03:39:22 -   1.4
> +++ mbtowc.3  27 Oct 2015 16:00:28 -
> @@ -40,27 +40,15 @@
>  .Sh DESCRIPTION
>  The
>  .Fn mbtowc
> -usually converts the multibyte character pointed to by
> +function converts the multibyte character pointed to by
>  .Fa s
>  to a wide character, and stores it in the wchar_t object pointed to by
> -.Fa pwc
> -if
> -.Fa pwc
> -is non-null and
> -.Fa s
> -points to a valid character.
> -This function may inspect at most n bytes of the array beginning from
> +.Fa pwc .
> +This function may inspect at most
> +.Fa n
> +bytes of the array pointed to by
>  .Fa s .
>  .Pp
> -In state-dependent encodings,
> -.Fa s
> -may point to the special sequence bytes to change the shift-state.
> -Although such sequence bytes correspond to no individual
> -wide-character code,
> -.Fn mbtowc
> -changes its own state by the sequence bytes and treats them
> -as if they are a part of the subsequence multibyte character.
> -.Pp
>  Unlike
>  .Xr mbrtowc 3 ,
>  the first
> @@ -68,52 +56,74 @@ the first
>  bytes pointed to by
>  .Fa s
>  need to form an entire multibyte character.
> -Otherwise, this function causes an error.
> +Otherwise, this function returns an error and the internal state will
> +be undefined.
> +.Pp
> +If a call to
> +.Fn mbtowc
> +resulted in an undefined internal state,
> +.Fn mbtowc
> +must be called with
> +.Ar s
> +set to
> +.Dv NULL
> +to reset the internal state before being used again for other purposes.

Maybe this should be "...before it can safely be used again."
Either way, ok bentley@



Re: utf8 hack for ls

2015-10-26 Thread Anthony J. Bentley
Stefan Sperling writes:
> On Mon, Oct 26, 2015 at 03:58:58PM -0600, Anthony J. Bentley wrote:
> > "Ted Unangst" writes:
> > > it only gets deeper and thicker...
> > 
> > Indeed.
> > 
> > Here's a shorter implementation. Like colorls(1), it uses wide
> > characters (only within the putname() function) but is slightly cleaned
> > up and simplified.
> 
> Is it really shorter if you follow the libc code paths this is calling?

No, it's not. But that's not inherent to wchar_t, only to the Citrus
stuff that infests our libc. As Citrus gets cleaned up, this works
better instantly. And if we instead come up with better functions for
doing this kind of thing:

> The utilities in Ted's diff would eventually be split off into a library.

There are a number of directions a hypothetical UTF-8 library could go.
mbwidth(), for example, would fit quite cleanly in the code below--and
this code style is *very* common, because these are the standard
functions for this stuff, so such an API would get a lot of use.

New version of the patch--Ted pointed out max column widths were
derived from byte lengths instead of character widths.


Index: extern.h
===
RCS file: /cvs/src/bin/ls/extern.h,v
retrieving revision 1.9
diff -u -p -r1.9 extern.h
--- extern.h2 Jun 2003 23:32:08 -   1.9
+++ extern.h27 Oct 2015 00:07:54 -
@@ -51,4 +51,5 @@ void   printacol(DISPLAY *);
 voidprintlong(DISPLAY *);
 voidprintscol(DISPLAY *);
 voidprintstream(DISPLAY *);
+size_t  strwidth(char *);
 voidusage(void);
Index: ls.c
===
RCS file: /cvs/src/bin/ls/ls.c,v
retrieving revision 1.43
diff -u -p -r1.43 ls.c
--- ls.c9 Oct 2015 01:37:06 -   1.43
+++ ls.c27 Oct 2015 00:07:54 -
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "ls.h"
@@ -103,6 +104,8 @@ ls_main(int argc, char *argv[])
int kflag = 0, width = 0;
char *p;
 
+   setlocale(LC_CTYPE, "");
+
/* Terminal defaults to -Cq, non-terminal defaults to -1. */
if (isatty(STDOUT_FILENO)) {
if ((p = getenv("COLUMNS")) != NULL)
@@ -474,8 +477,8 @@ display(FTSENT *p, FTSENT *list)
continue;
}
}
-   if (cur->fts_namelen > maxlen)
-   maxlen = cur->fts_namelen;
+   if (strwidth(cur->fts_name) > maxlen)
+   maxlen = strwidth(cur->fts_name);
if (needstats) {
sp = cur->fts_statp;
if (sp->st_blocks > maxblock)
Index: print.c
===
RCS file: /cvs/src/bin/ls/print.c,v
retrieving revision 1.34
diff -u -p -r1.34 print.c
--- print.c 15 Mar 2015 00:41:27 -  1.34
+++ print.c 27 Oct 2015 00:07:54 -
@@ -310,7 +310,8 @@ printstream(DISPLAY *dp)
continue;
if (col > 0) {
(void)putchar(','), col++;
-   if (col + 1 + extwidth + p->fts_namelen >= termwidth)
+   if (col + 1 + extwidth + strwidth(p->fts_name) >=
+   termwidth)
(void)putchar('\n'), col = 0;
else
(void)putchar(' '), col++;
Index: util.c
===
RCS file: /cvs/src/bin/ls/util.c,v
retrieving revision 1.16
diff -u -p -r1.16 util.c
--- util.c  21 Nov 2013 15:54:45 -  1.16
+++ util.c  27 Oct 2015 00:07:54 -
@@ -41,10 +41,13 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "ls.h"
 #include "extern.h"
 
+#ifdef SMALL
 int
 putname(char *name)
 {
@@ -54,6 +57,62 @@ putname(char *name)
putchar((!isprint((unsigned char)*name) && f_nonprint) ? '?' : 
*name);
return len;
 }
+
+size_t
+strwidth(char *s)
+{
+   return strlen(s);
+}
+#else
+int
+putname(char *name)
+{
+   int width, n;
+   wchar_t wc;
+
+   width = 0;
+   while ((n = mbtowc(, name, MB_LEN_MAX)) != 0) {
+   if (n == -1) {
+   width++;
+   name++;
+   putchar('?');
+   } else if (iswprint(wc)) {
+   width += wcwidth(wc);
+   name += n;
+   printf("%lc", wc);
+   } else {
+   width++;
+   name += n;
+   putchar('?');
+   }
+   }
+
+   return width;
+}
+
+size_t
+strwidth(char 

Re: utf8 hack for ls

2015-10-26 Thread Anthony J. Bentley
"Ted Unangst" writes:
> it only gets deeper and thicker...

Indeed.

Here's a shorter implementation. Like colorls(1), it uses wide
characters (only within the putname() function) but is slightly cleaned
up and simplified.


Index: ls.c
===
RCS file: /cvs/src/bin/ls/ls.c,v
retrieving revision 1.43
diff -u -p -r1.43 ls.c
--- ls.c9 Oct 2015 01:37:06 -   1.43
+++ ls.c26 Oct 2015 21:53:40 -
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "ls.h"
@@ -102,6 +103,8 @@ ls_main(int argc, char *argv[])
int ch, fts_options, notused;
int kflag = 0, width = 0;
char *p;
+
+   setlocale(LC_CTYPE, "");
 
/* Terminal defaults to -Cq, non-terminal defaults to -1. */
if (isatty(STDOUT_FILENO)) {
Index: util.c
===
RCS file: /cvs/src/bin/ls/util.c,v
retrieving revision 1.16
diff -u -p -r1.16 util.c
--- util.c  21 Nov 2013 15:54:45 -  1.16
+++ util.c  26 Oct 2015 21:53:40 -
@@ -41,10 +41,13 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "ls.h"
 #include "extern.h"
 
+#ifdef SMALL
 int
 putname(char *name)
 {
@@ -54,6 +57,33 @@ putname(char *name)
putchar((!isprint((unsigned char)*name) && f_nonprint) ? '?' : 
*name);
return len;
 }
+#else
+int
+putname(char *name)
+{
+   int width, n;
+   wchar_t wc;
+
+   width = 0;
+   while ((n = mbtowc(, name, MB_CUR_MAX)) != 0) {
+   if (n == -1) {
+   width++;
+   name++;
+   putchar('?');
+   } else if (iswprint(wc)) {
+   width += wcwidth(wc);
+   name += n;
+   printf("%lc", wc);
+   } else {
+   width++;
+   name += n;
+   putchar('?');
+   }
+   }
+
+   return width;
+}
+#endif
 
 void
 usage(void)



documenting multiple standards

2015-10-25 Thread Anthony J. Bentley
>From wcrtomb(3):

 The wcrtomb() function conforms to ISO/IEC 9899/AMD1:1995 (``ISO C90,
 Amendment 1'').  The restrict qualifier is added at ISO/IEC 9899/1999
 (``ISO C99'').

This wording is confusing. Is it implying that we don't use a restrict
qualifier? (We do.)

If a standard changes, do we have to document how the old standard
differs from what we currently follow? That seems awfully complicated.
Can we just document the latest standard, or "the earliest standard
that doesn't appreciably differ from the latest standard"?

What's the guiding practice here?



STANDARDS for nl_langinfo(3)

2015-10-24 Thread Anthony J. Bentley
ok?

Index: nl_langinfo.3
===
RCS file: /cvs/src/lib/libc/locale/nl_langinfo.3,v
retrieving revision 1.10
diff -u -p -r1.10 nl_langinfo.3
--- nl_langinfo.3   21 Jan 2014 03:15:45 -  1.10
+++ nl_langinfo.3   24 Oct 2015 13:02:04 -
@@ -30,3 +30,8 @@ returns a pointer to an empty string if
 is invalid.
 .Sh SEE ALSO
 .Xr setlocale 3
+.Sh STANDARDS
+The
+.Fn nl_langinfo
+function conforms to
+.St -p1003.1-2008 .



Re: Invalid HTML entities in upgrade57.html

2015-09-25 Thread Anthony J. Bentley
Kevin Zhang writes:
> Using >, & in raw text is invalid HTML.

You're right about &, but > does not need to be escaped.

-- 
Anthony J. Bentley



Re: [patch] ports.7 macro fixes

2015-08-24 Thread Anthony J. Bentley
Michael Reed writes:
 Hi,
 
 This is in the same vein as [1], which replaced the usage of `Ar' with
 `Cm' where applicable.  Besides that, I unindented line 134 because
 `-offset indent' is already being used, but that's it.
 
 Regards,
 Michael
 
 [1]: https://marc.info/?l=openbsd-techm=143778713715847w=2

Thanks, I've reviewed and committed this diff.



Re: Cleanup meta tags

2015-07-01 Thread Anthony J. Bentley
Pavel Plamenov writes:
 Updated patch.

Thanks, I've reviewed and committed this. Your mailer is still adding
extra whitespace to the patch, though... please figure out why that's
happening and fix it.



Re: Remove links to www@

2015-06-25 Thread Anthony J. Bentley
Pavel Plamenov writes:
 There are some leftover links to www@, which is gone.

Your patch seems to have gotten broken somehow, by adding extra
space to the beginning of lines. I removed those and committed it;
thanks for sending.



isblank(3) STANDARDS

2015-06-23 Thread Anthony J. Bentley
ok?

Index: lib/libc/gen/isblank.3
===
RCS file: /cvs/src/lib/libc/gen/isblank.3,v
retrieving revision 1.11
diff -u -p -r1.11 isblank.3
--- lib/libc/gen/isblank.3  6 Jul 2013 17:31:20 -   1.11
+++ lib/libc/gen/isblank.3  23 Jun 2015 06:33:52 -
@@ -80,6 +80,11 @@ non-zero if the character tests true.
 .Xr tolower 3 ,
 .Xr toupper 3 ,
 .Xr ascii 7
+.Sh STANDARDS
+The
+.Fn isblank
+function conforms to
+.St -isoC-99 .
 .Sh CAVEATS
 The argument to
 .Fn isblank



Re: patch/ mg(1) include time.h for struct timespec

2015-06-21 Thread Anthony J. Bentley
Brian Callahan writes:
 
 
 On 06/21/15 19:56, Kamil Rytarowski wrote:
  On 22.06.2015 01:55, Brian Callahan wrote:
  This is quite obviously the wrong place to put any headers.
 
  
  It's odd, otherwise then the code should be refactored and the following
  struct perhaps moved away, together with struct buffer?
  
  /*
   * Previously from sysdef.h
   * Only used in struct buffer.
   */
  struct fileinfo {
  uid_t   fi_uid;
  gid_t   fi_gid;
  mode_t  fi_mode;
  struct timespec fi_mtime;   /* Last modified time */
  };
  
  Are there better ideas?
  
 
 I did some digging.
 signal.h-sys/signal.h-sys/siginfo.h-sys/time.h
 
 sys/time.h has the timespec definition. So this appears to be an issue
 specific to NetBSD. Or, at least, not an issue on OpenBSD.

Maybe better to refer to POSIX directly, which states:

   The signal.h header shall define the timespec structure as
   described in time.h.

-- 
Anthony J. Bentley



Re: syslogd in foreground

2015-06-12 Thread Anthony J. Bentley
Todd C. Miller writes:
  @@ -85,6 +85,8 @@ and do not disassociate from the control
   Specify the pathname of an alternate configuration file;
   the default is
   .Pa /etc/syslog.conf .
  +.It Fl F
  +Do not daemonize and stay in foreground.
 
 Since daemonize is not a word, how about something like:
 
 Run in the foreground instead of disassociating from the controlling
 terminal and running as a background daemon.

True, daemonize is not a word, but it is used very frequently in
our documentation, and the meaning is pretty clear.

$ grep daemonize /usr/share/man/man8/* | wc -l
  27

-- 
Anthony J. Bentley



Re: vi.1: angle brackets vs. `...' in the UTF-8 locale

2015-03-17 Thread Anthony J. Bentley
Theo Buehler writes:
 This is related to the thread `Aq macro' on tech@ from before the
 release lock (Feb 15):
 
 https://marc.info/?t=14239912901r=1w=2
 
 In the UTF-8 locale `.Aq', `\(la' and `\(ra' are rendered as
 mathematical angle brackets, not as less-than and greater-than signs.
 This is kind of confusing in the vi(1) manual, hence I suggest to alter
 the wording explaining the `key name' notation in the manual slightly
 so as to apply to all locales.
 
 Also, using `\(la' and `\(ra' leads to an incorrect display of the regex
 word boundaries `\' and `\' in the UTF-8 locale, which surely should
 be rendered as escaped less-than and greater-than signs.

Thanks; the diff was correct so I've applied it.

-- 
Anthony J. Bentley



Re: Aq macro

2015-02-15 Thread Anthony J. Bentley
Anthony J. Bentley writes:
 Ted Unangst writes:
  spamd(8) quotes the
  spamd pf table name. compress(3) quotes the zconf.h path.
 
 IMO, these are bugs in the manuals. spamd(8) should be using  directly.
 compress(3) should drop the angle quotes and just use Pa. Or wrap Pa in
  if people really think it's needed.

Replying to myself, there's already a simpler and more semantic macro
for include files: In. mdoc(7) only seems to document its usage in
SYNOPSIS, but that could just be unclear wording. It is already widely
used in non-SYNOPSIS situations.

ok?


Index: lib/libarch/i386/i386_get_ldt.2
===
RCS file: /cvs/src/lib/libarch/i386/i386_get_ldt.2,v
retrieving revision 1.16
diff -u -p -u -p -r1.16 i386_get_ldt.2
--- lib/libarch/i386/i386_get_ldt.2 31 May 2007 19:19:27 -  1.16
+++ lib/libarch/i386/i386_get_ldt.2 15 Feb 2015 12:52:50 -
@@ -64,7 +64,7 @@ Each entry in the
 .Fa descs
 array can be either a segment_descriptor or a gate_descriptor,
 as defined in
-.Aq Pa i386/segments.h .
+.In i386/segments.h .
 These structures are defined by the architecture
 as disjoint bit-fields, so care must be taken in constructing them.
 .Pp
Index: lib/libz/compress.3
===
RCS file: /cvs/src/lib/libz/compress.3,v
retrieving revision 1.14
diff -u -p -u -p -r1.14 compress.3
--- lib/libz/compress.3 16 Jul 2013 15:21:11 -  1.14
+++ lib/libz/compress.3 15 Feb 2015 12:52:50 -
@@ -229,7 +229,7 @@ and
 for consistency.
 If the first character differs, the library code actually used is
 not compatible with the
-.Aq Pa zlib.h
+.In zlib.h
 header file used by the application.
 This check is automatically made by
 .Fn deflateInit
@@ -889,7 +889,7 @@ memLevel=1 uses minimum memory but is sl
 memLevel=9 uses maximum memory for optimal speed.
 The default value is 8.
 See
-.Aq Pa zconf.h
+.In zconf.h
 for total memory usage as a function of
 .Fa windowBits
 and
@@ -2588,7 +2588,7 @@ and
 must be able to allocate exactly 65536 bytes,
 but will not be required to allocate more than this if the symbol MAXSEG_64K
 is defined (see
-.Aq Pa zconf.h ) .
+.In zconf.h ) .
 .Pp
 WARNING: On MSDOS, pointers returned by
 .Fa zalloc
@@ -2598,7 +2598,7 @@ The default allocation function provided
 To reduce memory requirements and avoid any allocation of 64K objects,
 at the expense of compression ratio,
 compile the library with -DMAX_WBITS=14 (see
-.Aq Pa zconf.h ) .
+.In zconf.h ) .
 .Pp
 The fields
 .Fa total_in
@@ -2739,7 +2739,7 @@ version and the compiler's view of
 .Re
 .Sh HISTORY
 This manual page is based on an HTML version of
-.Aq Pa zlib.h
+.In zlib.h
 converted by
 .An piaip Aq Mt pi...@csie.ntu.edu.tw
 and was converted to mdoc format by the
Index: sbin/pflogd/pflogd.8
===
RCS file: /cvs/src/sbin/pflogd/pflogd.8,v
retrieving revision 1.46
diff -u -p -u -p -r1.46 pflogd.8
--- sbin/pflogd/pflogd.821 Jan 2014 03:15:45 -  1.46
+++ sbin/pflogd/pflogd.815 Feb 2015 12:52:50 -
@@ -137,7 +137,7 @@ Selects which packets will be dumped, us
 .Xr tcpdump 8 .
 Tcpdump has been extended to be able to filter on the pfloghdr
 structure defined in
-.Aq Ar net/if_pflog.h .
+.In net/if_pflog.h .
 It can restrict the output
 to packets logged on a specified interface, a rule number, a reason,
 a direction, an IP family or an action.
Index: share/man/man4/speaker.4
===
RCS file: /cvs/src/share/man/man4/speaker.4,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 speaker.4
--- share/man/man4/speaker.416 Jul 2013 16:05:49 -  1.7
+++ share/man/man4/speaker.415 Feb 2015 12:52:50 -
@@ -72,7 +72,7 @@ on a speaker file descriptor to control 
 definitions for the
 .Fn ioctl
 interface are in
-.Aq Pa dev/isa/spkrio.h .
+.In dev/isa/spkrio.h .
 The
 .Li tone_t
 structure used in these calls has two fields,
Index: share/man/man4/usb.4
===
RCS file: /cvs/src/share/man/man4/usb.4,v
retrieving revision 1.162
diff -u -p -u -p -r1.162 usb.4
--- share/man/man4/usb.46 Feb 2015 23:46:30 -   1.162
+++ share/man/man4/usb.415 Feb 2015 12:52:50 -
@@ -651,7 +651,7 @@ field contains the actual length transfe
 .El
 .Pp
 The include file
-.Aq Pa dev/usb/usb.h
+.In dev/usb/usb.h
 contains definitions for the types used by the various
 .Xr ioctl 2
 calls.
@@ -672,7 +672,7 @@ and
 macros to handle byte order and alignment properly.
 .Pp
 The include file
-.Aq Pa dev/usb/usbhid.h
+.In dev/usb/usbhid.h
 similarly contains the definitions for
 Human Interface Devices
 .Pq Tn HID .
Index: share/man/man4/wsdisplay.4
===
RCS file: /cvs/src/share/man/man4/wsdisplay.4,v
retrieving revision 1.46
diff -u -p -u -p

Re: Aq macro

2015-02-15 Thread Anthony J. Bentley
Ted Unangst writes:
 spamd(8) quotes the
 spamd pf table name. compress(3) quotes the zconf.h path.

IMO, these are bugs in the manuals. spamd(8) should be using  directly.
compress(3) should drop the angle quotes and just use Pa. Or wrap Pa in
 if people really think it's needed.

 The mandoc chars.in though says that for unicode, it should output these fanc
 y
 mathematical left angle bracket and mathematical right angle bracket
 characters. Two problems. First, they look like kind of silly because most
 fonts use a different glyph.

Well, if it's a matter of aesthetics, I happen to like it. So we're at
an impasse!

More importantly, though, it matches groff. I don't think it can (or
should) change. When this behavior was added to mandoc, several pages
using Aq to represent HTML tags were fixed. These pages were just
overlooked.

 Two, a decent number of fonts don't include them,
 and then things look really silly.

But to get to that point you have to:

- use a UTF-8 locale (not the default);
- change the xterm fonts (all the default fonts display these characters)
- ...to something that doesn't support that character (lots of fonts do,
  what makes yours so special?)

 mandoc already special cases Aq in Mt macros to output plain brackets.

This also matches groff.

Here is a patch that corrects spamd(8). I can look at pages that use it
for headers later... a quick grep reveals less than 20.

Index: libexec/spamd/spamd.8
===
RCS file: /cvs/src/libexec/spamd/spamd.8,v
retrieving revision 1.125
diff -u -p -u -p -r1.125 spamd.8
--- libexec/spamd/spamd.8   7 Feb 2015 18:05:57 -   1.125
+++ libexec/spamd/spamd.8   15 Feb 2015 10:17:38 -
@@ -268,11 +268,11 @@ regularly scans the
 .Pa /var/db/spamd
 database and configures all whitelist addresses as the
 .Xr pf 4
-.Aq spamd-white
+spamd-white
 table,
 allowing connections to pass to the real MTA.
 Any addresses not found in
-.Aq spamd-white
+spamd-white
 are redirected to
 .Nm .
 .Pp
@@ -385,7 +385,7 @@ spamtrap address,
 it is blacklisted for 24 hours by adding the host to the
 .Nm
 blacklist
-.Aq spamd-greytrap .
+spamd-greytrap.
 Spamtrap addresses are added to the
 .Pa /var/db/spamd
 database with the following
@@ -468,7 +468,7 @@ a slightly modified
 .Xr pf.conf 5
 ruleset is required,
 redirecting any addresses found in the
-.Aq spamd
+spamd
 table to
 .Nm .
 Any other addresses
@@ -488,7 +488,7 @@ like:
 .Pp
 .Xr spamd-setup 8
 can also be used to load addresses into the
-.Aq spamd
+spamd
 table.
 It has the added benefit of being able to remove addresses from
 blacklists, and will connect to



Re: httpd: redirect to https, or www, or non-www

2014-12-24 Thread Anthony J. Bentley
Stuart Henderson writes:
  My plan was to propose a way to set the HSTS header if this proposal was
  well received, since there isn't much point having a built-in way to set
  the header if you're still having to use FCGI anyway to do the
  redirects.
 
 I think there is still point in that; even if you need FCGI for redirects,
 that would only be needed on the HTTP side, and there's little point in
 requiring FCGI to deliver a static html file plus HSTS header. Also you
 might not want to do redirects at all, just hand out an HTTPS URL to
 users and give them security against an HTTPS-HTTP downgrade attack.

There's not really any good way to prevent the case of the first time
user accesses example.com is by typing example.com instead of
https://example.com into the address bar. Firefox and Chrome attempt to
solve this with a preloaded list of domains that they use HSTS for by
default; see https://hstspreload.appspot.com/

-- 
Anthony J. Bentley



Re: vi: remove workarounds for other systems

2014-11-10 Thread Anthony J. Bentley
Martin Natano writes:
 Index: common/recover.c
 ===
 RCS file: /cvs/src/usr.bin/vi/common/recover.c,v
 retrieving revision 1.15
 diff -u -r1.15 recover.c
 --- common/recover.c  27 Oct 2009 23:59:47 -  1.15
 +++ common/recover.c  10 Nov 2014 17:10:05 -
 @@ -339,15 +339,6 @@
   int fd;
   char *dp, *p, *t, buf[4096], mpath[MAXPATHLEN];
   char *t1, *t2, *t3;
 -
 - /*
 -  * XXX
 -  * MAXHOSTNAMELEN is in various places on various systems, including
 -  * netdb.h and sys/socket.h.  If not found, use a large default.
 -  */
 -#ifndef MAXHOSTNAMELEN
 -#define  MAXHOSTNAMELEN  1024
 -#endif
   char host[MAXHOSTNAMELEN];
  
   gp = sp-gp;

FreeBSD nvi uses sysconf for this. If that's the right thing to do, we
should probably synchronize with them...

-- 
Anthony J. Bentley



Re: native UTF-8 and ISO-8859-1 *input* support for mandoc(1)

2014-10-27 Thread Anthony J. Bentley
Hi Ingo,

Ingo Schwarze writes:
 In ports land, many manual pages contain occasional non-ASCII
 characters - even though i don't consider that a particularly smart
 idea, but let's face it, those characters *are* out there.

I agree that this is appropriate for mandoc to try to handle for a
common, very limited subset of encodings.

 Since this is a somewhat bigger and user-visible change, i'm
 asking whether there are any concerns or comments before committing.

After applying this diff, mandoc -Tutf8 shows U+FFFD anywhere there's a
\ in the source... very obvious in the mdoc(7) page.

 +If not specified, autodetection uses the first match:
 +.Bl -tag -width iso-8859-1
 +.It Cm utf-8
 +if the first three bytes of the input file
 +are the UTF-8 byte order mark (BOM, 0xefbbbf)
 +.It Ar encoding
 +if the first or second line of the input file matches the
 +.Sy emacs
 +mode line format
 +.Pp
 +.D1 .\e -*- Oo ...; Oc coding: Ar encoding ; No -*-
 +.It Cm utf-8
 +if the first non-ASCII byte in the file introduces a valid UTF-8 sequence
 +.It Cm iso-8859-1
 +otherwise
 +.El

I agree with this logic as well. I would be uncomfortable if it got any
more complicated.

-- 
Anthony J. Bentley



Re: PATCH: add more malloc.conf details to malloc.3

2014-07-11 Thread Anthony J. Bentley
On Fri, Jul 11, 2014 at 12:50 AM, Jason McIntyre j...@kerhand.co.uk wrote:
 On Fri, Jul 11, 2014 at 05:46:15AM +, Doug Hogan wrote:
  .It Cm j
  .Dq Don't Junk .
  By default, small chunks are always junked, and the first part of pages
 @@ -297,6 +303,7 @@ This can substantially aid in compacting
  .\Consult the source for this one.
  .It Cm S
  Enable all options suitable for security auditing.
 +This currently enables flags 'UJG' and sets the free cache page size to 0.
  .It Cm U
  .Dq Free unmap .
  Enable use after free protection for larger allocations.

In addition to what jmc said, if you document these flags they need to
be marked up with the Cm macro instead of ASCII single quotes.

-- 
Anthony J. Bentley



Re: man.conf mandoc -Tlocale

2014-02-14 Thread Anthony J. Bentley
On Thu, Feb 13, 2014 at 7:22 PM, Ted Unangst t...@tedunangst.com wrote:
 mandoc fortunately has an option -Tlocale, which will pick between
 ascii and utf8 based on environment. Perfect! Let's use it.

 Tested to work as expected in uxterm. Tested to change nothing in a
 regular xterm by default (no LC_CTYPE set).

I've been using this exact man.conf (with LC_CTYPE=en_US.UTF-8) since
December 2012. It would be nice to have as the default. OK here...



STANDARDS for isakmpd.8

2013-11-12 Thread Anthony J. Bentley
ok?

Index: sbin/isakmpd//isakmpd.8
===
RCS file: /cvs/src/sbin/isakmpd/isakmpd.8,v
retrieving revision 1.112
diff -u -p -u -p -r1.112 isakmpd.8
--- sbin/isakmpd//isakmpd.8 14 Jul 2013 16:37:41 -  1.112
+++ sbin/isakmpd//isakmpd.8 12 Nov 2013 08:13:26 -
@@ -811,6 +811,41 @@ command is issued in the command FIFO.
 .Xr sasyncd 8 ,
 .Xr ssl 8 ,
 .Xr tcpdump 8
+.Sh STANDARDS
+.Rs
+.%A D. Piper
+.%D November 1998
+.%R RFC 2407
+.%T The Internet IP Security Domain of Interpretation for ISAKMP
+.Re
+.Pp
+.Rs
+.%A D. Maughan
+.%A M. Schertler
+.%A M. Schneider
+.%A J. Turner
+.%D November 1998
+.%R RFC 2408
+.%T Internet Security Association and Key Management Protocol (ISAKMP)
+.Re
+.Pp
+.Rs
+.%A D. Harkins
+.%A D. Carrel
+.%D November 1998
+.%R RFC 2409
+.%T The Internet Key Exchange (IKE)
+.Re
+.Pp
+.Rs
+.%A T. Kivinen
+.%A B. Swander
+.%A A. Huttunen
+.%A V. Volpe
+.%D January 2005
+.%R RFC 3947
+.%T Negotiation of NAT-Traversal in the IKE
+.Re
 .Sh HISTORY
 The ISAKMP/Oakley key management protocol is described in
 RFC 2407, RFC 2408, and RFC 2409.



STANDARDS for fingerd.8

2013-11-12 Thread Anthony J. Bentley
ok?

Index: libexec/fingerd/fingerd.8
===
RCS file: /cvs/src/libexec/fingerd/fingerd.8,v
retrieving revision 1.18
diff -u -p -u -p -r1.18 fingerd.8
--- libexec/fingerd/fingerd.8   25 Sep 2007 06:28:13 -  1.18
+++ libexec/fingerd/fingerd.8   12 Nov 2013 08:26:35 -
@@ -154,6 +154,13 @@ Queries without a user name are rejected
 .Sh SEE ALSO
 .Xr finger 1 ,
 .Xr inetd 8
+.Sh STANDARDS
+.Rs
+.%A D. Zimmerman
+.%D December 1991
+.%R RFC 1288
+.%T The Finger User Information Protocol
+.Re
 .Sh HISTORY
 The
 .Nm



Re: tar -J to extract xz archives

2012-05-29 Thread Anthony J. Bentley
Gabriel Linder writes:
I see more and more tar.xz archives, and thought it would be nice to 
have tar able to extract them directly as with gzip/bzip2.

-J is what GNU and FreeBSD use, so I used it too. Based on what was done 
to add bzip2 support.

This has been discussed on the list before. I think the conclusion was
that xz won't make it into base, and adding new tar flags for stuff not
in base is a bad idea (although we already have -j for bzip2).

--
Anthony J. Bentley



Re: enable aucat by default

2011-10-11 Thread Anthony J. Bentley
Hi Alexandre,

On Mon, Oct 10, 2011 at 11:29 AM, Alexandre Ratchov a...@caoua.org wrote:
 On Mon, Oct 10, 2011 at 11:16:21AM -0600, Anthony J. Bentley wrote:
 My only issue with aucat is a noticeable lag for real-time
 applications like games, even when running with a small buffer size as
 per FAQ 13.5.


 This should be fixed by the cleanup diff I posted few days ago,
 isn't it?

 If you can't test the diff, could you quickly check that the following
 invocation (as root) solves your latency problems?

 B  B  B  B aucat -b 960 -z 480 other options if any

On second look, I think it was user error. I had been specifying -b
after -f instead of before.

I did test your diff, though, and things seem to work all right.

--
Anthony J. Bentley



Re: tar -J for xz

2011-10-04 Thread Anthony J. Bentley
On Tue, Oct 4, 2011 at 4:32 PM, Nicholas Marriott
nicholas.marri...@gmail.com wrote:
 I agree.

 Or if we must have compression flags just have one flag and let tar
 figure out the right tool to use. Having -Z -z -J -j etc etc is silly.

GNU tar no longer needs those flags... their tar xf foo works just
fine whether foo is .tar, .tar.gz, or .tar.bz2.


 On Tue, Oct 04, 2011 at 11:41:39PM +0200, Matthias Kilian wrote:
 On Tue, Oct 04, 2011 at 09:43:53PM +0200, Antoine Jacoutot wrote:
this diff adds a -J flag to tar that calls xz for compress/decompress.
Requires you to install the xz package on your system.
  
   No way.
  
   Base never depends on external things.
 
  Well pval added support for bzip2 years ago in a similar way...

 And i don't see the point in all those special flags for special
 (de)compression tools, not even for gzip.

 gzip -cd bla.tgz | tar tf -

 Same for other tools. Why add flags to tar for this?



the SMCWUSB-N2 is an otus(4)

2011-03-16 Thread Anthony J. Bentley
Sent from a SMCWUSB-N2:
otus0 at uhub0 port 3 ATHER USB2.0 WLAN rev 2.00/1.06 addr 2
otus0: MAC/BBP AR9170, RF AR9102, MIMO 2T2R, address 00:22:2d:c0:30:b3

Index: otus.4
===
RCS file: /cvs/src/share/man/man4/otus.4,v
retrieving revision 1.17
diff -u otus.4
--- otus.4  6 Jan 2011 19:47:46 -   1.17
+++ otus.4  16 Mar 2011 19:11:38 -
@@ -100,6 +100,7 @@
 .It Netgear WNDA3100
 .It Netgear WN111 v2
 .It Planex GW-US300
+.It SMC Networks SMCWUSB-N2
 .It TP-Link TL-WN821N
 .It Ubiquiti SR71 USB
 .It Unex DNUA-81



ISO-8859-1 character in manpage

2011-03-16 Thread Anthony J. Bentley
$ mandoc -Tlint /usr/src/share/man/man4/udl.4  
/usr/src/share/man/man4/udl.4:42:6: ERROR: skipping bad character: ignoring byte

The o with diaeresis should be replaced with the \(:o escape.
(See mandoc_char(7).)

Would send a patch, but I've never had luck sending high-bit files
to the list.

--
Anthony J. Bentley



typos in error message

2011-03-06 Thread Anthony J. Bentley
continguous - contiguous. Or perhaps it was meant to be continuous.

Index: usr.sbin/bgpd/kroute.c
===
RCS file: /cvs/src/usr.sbin/bgpd/kroute.c,v
retrieving revision 1.186
diff -u usr.sbin/bgpd/kroute.c
--- usr.sbin/bgpd/kroute.c  11 Oct 2010 11:45:57 -  1.186
+++ usr.sbin/bgpd/kroute.c  7 Mar 2011 06:23:44 -
@@ -2379,7 +2379,7 @@
case 0x00:
return (l);
default:
-   fatalx(non continguous inet6 netmask);
+   fatalx(non contiguous inet6 netmask);
}
}
 
Index: usr.sbin/ospf6ctl/parser.c
===
RCS file: /cvs/src/usr.sbin/ospf6ctl/parser.c,v
retrieving revision 1.10
diff -u usr.sbin/ospf6ctl/parser.c
--- usr.sbin/ospf6ctl/parser.c  4 Sep 2010 21:31:04 -   1.10
+++ usr.sbin/ospf6ctl/parser.c  7 Mar 2011 06:23:46 -
@@ -385,7 +385,7 @@
case 0x00:
return (l);
default:
-   errx(1, non continguous inet6 netmask);
+   errx(1, non contiguous inet6 netmask);
}
}
 
Index: usr.sbin/ospf6d/kroute.c
===
RCS file: /cvs/src/usr.sbin/ospf6d/kroute.c,v
retrieving revision 1.29
diff -u usr.sbin/ospf6d/kroute.c
--- usr.sbin/ospf6d/kroute.c14 Oct 2010 07:38:05 -  1.29
+++ usr.sbin/ospf6d/kroute.c7 Mar 2011 06:23:46 -
@@ -734,7 +734,7 @@
case 0x00:
return (l);
default:
-   fatalx(non continguous inet6 netmask);
+   fatalx(non contiguous inet6 netmask);
}
}
 
Index: usr.sbin/snmpd/kroute.c
===
RCS file: /cvs/src/usr.sbin/snmpd/kroute.c,v
retrieving revision 1.15
diff -u usr.sbin/snmpd/kroute.c
--- usr.sbin/snmpd/kroute.c 15 Oct 2010 09:27:03 -  1.15
+++ usr.sbin/snmpd/kroute.c 7 Mar 2011 06:23:47 -
@@ -780,7 +780,7 @@
case 0x00:
return (l);
default:
-   fatalx(non continguous inet6 netmask);
+   fatalx(non contiguous inet6 netmask);
}
}



Re: suspend/resume woes on MSI Wind U-100

2010-07-18 Thread Anthony J. Bentley
  On Sat, 17 Jul 2010 17:28:30 +0200
  David Coppa dco...@gmail.com wrote:
  
   Hi,
   
   I've put the latest snapshot on a MSI Wind U-100 netbook.
   
   ACPI suspend and resume would work great, even from X, but
   unfortunately after resume keyboard and mouse don't work anymore.
   
  
  The same happens on my system.

Similar results on my MSI Wind U-123 netbook. On resume mouse and
keyboard either don't work, or are unusably slow/stuttering (one
keypress resulting in 20 letters on screen, for example).

From /var/log/messages:
Jul 18 14:55:11 ponderosa apmd: system resumed from APM sleep
Jul 18 14:55:11 ponderosa /bsd: Realtek 8187SE rev 0x22 at pci2 dev 0 
function 0 not configured
Jul 18 14:55:12 ponderosa /bsd: pckbc: command timeout
Jul 18 14:55:12 ponderosa /bsd: umass0 at uhub0
Jul 18 14:55:12 ponderosa /bsd:  port 6 configuration 1 interface 0 Generic 
USB2.0-CRW rev 2.00/58.87 addr 2
Jul 18 14:55:12 ponderosa /bsd: umass0: using SCSI over Bulk-Only
Jul 18 14:55:12 ponderosa /bsd: scsibus0 at umass0: 2 targets, initiator 0
Jul 18 14:55:12 ponderosa /bsd: sd0 at scsibus0 targ 1 lun 0: Generic-, 
Multi-Card, 1.00 SCSI0 0/direct removable
Jul 18 14:55:12 ponderosa /bsd: sd0: drive offline
Jul 18 14:55:14 ponderosa /bsd: pckbc: command timeout


dmesg:
OpenBSD 4.7-current (GENERIC.MP) #189: Sat Jul 10 00:42:57 MDT 2010
dera...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC.MP
cpu0: Intel(R) Atom(TM) CPU N280 @ 1.66GHz (GenuineIntel 686-class) 1.67 GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,EST,TM2,SSSE3,xTPR,PDCM,MOVBE
real mem  = 1062502400 (1013MB)
avail mem = 1035116544 (987MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 02/08/08, SMBIOS rev. 2.4 @ 0x3f607010 
(45 entries)
bios0: vendor American Megatrends Inc. version 4.6.3 date 02/23/2009
bios0: MICRO-STAR INTERNATIONAL CO., LTD MS-N033
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP APIC SSDT SSDT SSDT
acpi0: wakeup devices P0P2(S4) PEGP(S4) USB0(S1) USB1(S1) USB2(S1) USB3(S1) 
EHCI(S1) MC97(S4) P0P1(S4) P0P4(S4) P0P5(S4) P0P6(S4) P0P7(S4) P0P8(S4) P0P9(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: apic clock running at 166MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Atom(TM) CPU N280 @ 1.66GHz (GenuineIntel 686-class) 1.67 GHz
cpu1: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,EST,TM2,SSSE3,xTPR,PDCM,MOVBE
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 24 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (P0P2)
acpiprt2 at acpi0: bus 1 (P0P4)
acpiprt3 at acpi0: bus -1 (P0P5)
acpiprt4 at acpi0: bus 2 (P0P6)
acpiprt5 at acpi0: bus -1 (P0P7)
acpiprt6 at acpi0: bus -1 (P0P8)
acpiprt7 at acpi0: bus -1 (P0P9)
acpiec0 at acpi0
acpicpu0 at acpi0: C3, C2, C1, PSS
acpicpu1 at acpi0: C3, C2, C1, PSS
acpitz0 at acpi0: critical temperature 100 degC
acpiac0 at acpi0: AC unit online
acpibat0 at acpi0: BAT1 model MS-N033
 serial 
 type LION
 oem MSI Corp.

acpibtn0 at acpi0: LID0
acpibtn1 at acpi0: PWRB
acpibtn2 at acpi0: SLPB
acpivideo0 at acpi0: IGD_
acpivout0 at acpivideo0: CRT_
acpivout1 at acpivideo0: LCD_
bios0: ROM list: 0xc/0xea00! 0xcf000/0x1000
cpu0: Enhanced SpeedStep 1667 MHz: speeds: 1333, 1067, 800 MHz
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 Intel 82945GME Host rev 0x03
vga1 at pci0 dev 2 function 0 Intel 82945GME Video rev 0x03
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
intagp0 at vga1
agp0 at intagp0: aperture at 0xc000, size 0x1000
inteldrm0 at vga1: apic 2 int 16 (irq 11)
drm0 at inteldrm0
Intel 82945GM Video rev 0x03 at pci0 dev 2 function 1 not configured
azalia0 at pci0 dev 27 function 0 Intel 82801GB HD Audio rev 0x02: apic 2 int 
16 (irq 11)
azalia0: codecs: Realtek ALC888
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 Intel 82801GB PCIE rev 0x02: apic 2 int 16 
(irq 11)
pci1 at ppb0 bus 1
re0 at pci1 dev 0 function 0 Realtek 8101E rev 0x02: RTL8102E (0x3480), apic 
2 int 16 (irq 11), address 00:24:21:62:f5:5d
rlphy0 at re0 phy 7: RTL8201L 10/100 PHY, rev. 1
ppb1 at pci0 dev 28 function 2 Intel 82801GB PCIE rev 0x02: apic 2 int 18 
(irq 10)
pci2 at ppb1 bus 2
Realtek 8187SE rev 0x22 at pci2 dev 0 function 0 not configured
uhci0 at pci0 dev 29 function 0 Intel 82801GB USB rev 0x02: apic 2 int 23 
(irq 5)
uhci1 at pci0 dev 29 function 1 Intel 82801GB USB rev 0x02: apic 2 int 19 
(irq 3)
uhci2 at pci0 dev 29 function 2 Intel 82801GB USB rev 0x02: apic 2 int 18 
(irq 10)
uhci3 at pci0 dev 29 function 3 Intel 82801GB USB rev 0x02: apic 2 int 16 
(irq 11)
ehci0 at pci0 dev 29 function 7 Intel 82801GB USB rev 0x02: apic 2 int 23 
(irq 5)
usb0 at ehci0: USB revision 2.0