Re: standardize and simplify GitHub submodule handling in ports?

2023-08-07 Thread Brian Callahan
On 8/7/2023 1:59 PM, Stuart Henderson wrote:
> On 2023/08/07 12:44, Thomas Frohwein wrote:
>> I tested this with the about 30 ports I could identify that use GitHub
>> submodules, by adjusting the Makefile to use GH_SUBMODULES. Here a few
>> points from what I've observed:
> ..
>>
>> The full table of what I tested and the result up to if the port still
>> packages is here: https://thfr.info/tmp/github-submodule-ports.txt
> 
> I haven't looked at other ports, but asterisk, vim and vmm-firmware do
> not use git submodules.
> 

I don't want to change the DMD build process. It matches what upstream
does, and has been helpful for debugging the process with them in the past.

~Brian



Enable Apollo Lake audio

2023-02-20 Thread Brian Callahan
Hello tech --

I recently found a ~5 year old laptop sitting in storage. It is
an Apollo Lake machine. I think I put it in storage because it
did not have working audio. I tried a -current kernel from today
and found that it still did not have audio. The audio device
does not attach.

There is a one-line fix to enable audio. With this, the audio
device attaches and the laptop is playing audio just fine.

OK?

~Brian

Index: dev/pci/azalia.c
===
RCS file: /cvs/src/sys/dev/pci/azalia.c,v
retrieving revision 1.282
diff -u -p -r1.282 azalia.c
--- dev/pci/azalia.c5 Feb 2023 02:26:02 -   1.282
+++ dev/pci/azalia.c20 Feb 2023 20:53:35 -
@@ -492,6 +492,7 @@ const struct pci_matchid azalia_pci_devi
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_500SERIES_HDA },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_500SERIES_LP_HDA },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_600SERIES_LP_HDA },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_APOLLOLAKE_HDA },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_GLK_HDA },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_JSL_HDA },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_EHL_HDA },



Re: iwm(4) A-MSDU support

2021-03-29 Thread Brian Callahan
Hi Stefan --

> Stefan Sperling writes:
>
> > This patch attempts to add support for receiving A-MSDUs to iwm(4).
> >
> > If you are using iwm(4) then please run with this patch and let me
> >
> > know if it causes regressions. Thanks!
>

All is good on my machine as well.

iwm0 at pci4 dev 0 function 0 "Intel Dual Band Wireless AC 7260" rev 0xbb, msi
iwm0: hw rev 0x140, fw ver 17.3216344376.0, address ac:fd:ce:09:87:97

Thanks!

~Brian



Re: iwm(4) WPA2 crypto hardware offload

2019-08-02 Thread Brian Callahan




On 8/2/19 7:13 AM, Stefan Sperling wrote:

This diff enables HW offload for WPA2 CCMP (AES) encrypted unicast
frames in iwm(4). This is in preparation for Tx aggregation support.

WEP and WPA1/TKIP ciphers are still handled in software, which mirrors
what the older iwn(4) driver is doing. We don't enable 11n at all with
those ciphers (see ieee80211_ht_negotiate()), and we won't aggregate
non-encrypted frames (see ieee80211_can_use_ampdu()).

Based on an initial diff by procter@ and some code from iwn(4).

Tested on 7260, 7265, 8260, and 8265 in bsd.rd upgrade and with pkg_add -u.


Works on my 3165 with pkg_add -u.

~Brian


ok?

diff refs/heads/master refs/heads/iwm-hwcrypt
blob - 7add1e9e682ef5e22169ec1e89a182cda1af7e2a
blob + 839c0a0f8b3a62115ba6d5e15adfa63158475c86
--- sys/dev/pci/if_iwm.c
+++ sys/dev/pci/if_iwm.c
@@ -367,6 +367,8 @@ int iwm_get_signal_strength(struct iwm_softc *, struct
  void  iwm_rx_rx_phy_cmd(struct iwm_softc *, struct iwm_rx_packet *,
struct iwm_rx_data *);
  int   iwm_get_noise(const struct iwm_statistics_rx_non_phy *);
+intiwm_ccmp_decap(struct iwm_softc *, struct mbuf *,
+   struct ieee80211_node *);
  void  iwm_rx_rx_mpdu(struct iwm_softc *, struct iwm_rx_packet *,
struct iwm_rx_data *);
  void  iwm_enable_ht_cck_fallback(struct iwm_softc *, struct iwm_node *);
@@ -448,6 +450,10 @@ intiwm_disassoc(struct iwm_softc *);
  int   iwm_run(struct iwm_softc *);
  int   iwm_run_stop(struct iwm_softc *);
  struct ieee80211_node *iwm_node_alloc(struct ieee80211com *);
+intiwm_set_key(struct ieee80211com *, struct ieee80211_node *,
+   struct ieee80211_key *);
+void   iwm_delete_key(struct ieee80211com *,
+   struct ieee80211_node *, struct ieee80211_key *);
  void  iwm_calib_timeout(void *);
  int   iwm_media_change(struct ifnet *);
  void  iwm_newstate_task(void *);
@@ -3429,11 +3435,91 @@ iwm_get_noise(const struct iwm_statistics_rx_non_phy *
return (nbant == 0) ? -127 : (total / nbant) - 107;
  }
  
+int

+iwm_ccmp_decap(struct iwm_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
+{
+   struct ieee80211com *ic = >sc_ic;
+   struct ieee80211_key *k = >ni_pairwise_key;
+   struct ieee80211_frame *wh;
+   struct ieee80211_rx_ba *ba;
+   uint64_t pn, *prsc;
+   uint8_t *ivp;
+   uint8_t tid;
+   int hdrlen, hasqos;
+
+   wh = mtod(m, struct ieee80211_frame *);
+   hdrlen = ieee80211_get_hdrlen(wh);
+   ivp = (uint8_t *)wh + hdrlen;
+
+   /* Check that ExtIV bit is be set. */
+   if (!(ivp[3] & IEEE80211_WEP_EXTIV)) {
+   DPRINTF(("CCMP decap ExtIV not set\n"));
+   return 1;
+   }
+   hasqos = ieee80211_has_qos(wh);
+   tid = hasqos ? ieee80211_get_qos(wh) & IEEE80211_QOS_TID : 0;
+   ba = hasqos ? >ni_rx_ba[tid] : NULL;
+   prsc = >k_rsc[tid];
+
+   /* Extract the 48-bit PN from the CCMP header. */
+   pn = (uint64_t)ivp[0]   |
+(uint64_t)ivp[1] <<  8 |
+(uint64_t)ivp[4] << 16 |
+(uint64_t)ivp[5] << 24 |
+(uint64_t)ivp[6] << 32 |
+(uint64_t)ivp[7] << 40;
+   if (pn <= *prsc) {
+   if (hasqos && ba->ba_state == IEEE80211_BA_AGREED) {
+   /*
+* This is an A-MPDU subframe.
+* Such frames may be received out of order due to
+* legitimate retransmissions of failed subframes
+* in previous A-MPDUs. Duplicates will be handled
+* in ieee80211_input() as part of A-MPDU reordering.
+*/
+   } else if (ieee80211_has_seq(wh)) {
+   /*
+* Not necessarily a replayed frame since we did not
+* check the sequence number of the 802.11 header yet.
+*/
+   int nrxseq, orxseq;
+
+   nrxseq = letoh16(*(u_int16_t *)wh->i_seq) >>
+   IEEE80211_SEQ_SEQ_SHIFT;
+   if (hasqos)
+   orxseq = ni->ni_qos_rxseqs[tid];
+   else
+   orxseq = ni->ni_rxseq;
+   if (nrxseq < orxseq) {
+   DPRINTF(("CCMP replayed (n=%d < o=%d)\n",
+   nrxseq, orxseq));
+   ic->ic_stats.is_ccmp_replays++;
+   return 1;
+   }
+   } else {
+   DPRINTF(("CCMP replayed\n"));
+   ic->ic_stats.is_ccmp_replays++;
+   return 1;
+   }
+   }
+   /* Update last seen packet number. */
+   *prsc = pn;
+
+   /* Clear Protected bit and strip IV. */
+   wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED;
+   memmove(mtod(m, 

Add #include to ksh/io.c

2019-07-24 Thread Brian Callahan
Hi tech --

ksh/io.c uses mkstemp but does not include stdlib.h.
It has been getting by with the legacy definition in unistd.h

Originally spotted by m...@netbsd.org

OK?

~Brian

Index: io.c
===
RCS file: /cvs/src/bin/ksh/io.c,v
retrieving revision 1.37
diff -u -p -r1.37 io.c
--- io.c28 Jun 2019 13:34:59 -  1.37
+++ io.c24 Jul 2019 14:05:41 -
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 



Re: usr.bin/getconf: Add reporting LONG_BIT

2019-05-28 Thread Brian Callahan



On 5/28/19 8:21 AM, Jeremie Courreges-Anglas wrote:

On Mon, May 27 2019, Philip Guenther  wrote:

On Mon, May 27, 2019 at 3:43 PM Brian Callahan  wrote:


Below is a small diff in response to some configuration attempts
found in ports land.
lang/ponyc uses $(shell getconf LONG_BIT) in its Makefile to
determine whether or not we're on a 64-bit platform.


It needs to know that at the scripting level, outside of the C code itself
where it can directly test LONG_BIT (or perhaps better, _LP64)?  Huh.




However, our getconf(1) doesn't support reporting LONG_BIT.
This diff enables it. GNU/FreeBSD/DragonFly/MacOS getconf reports
LONG_BIT, but NetBSD getconf does not.
Desirable? OK?


That's the way to do it, I just have this vague "what tempting lunacy has
led them to this?" lurking in my mind.

I'll let Brian confirm but this got me curious.  Here's the dance
I found in the Makefile for ponyc:

--8<--
# Default settings (silent release build).
config ?= release
arch ?= native
tune ?= generic
cpu ?= $(arch)
fpu ?=
bits ?= $(shell getconf LONG_BIT)
[...]
# Determine pointer size in bits.
BITS := $(bits)
UNAME_M := $(shell uname -m)

ifeq ($(BITS),64)
   ifeq ($(UNAME_M),x86_64)
 ifeq (,$(filter $(arch), armv8-a))
   BUILD_FLAGS += -mcx16
   LINKER_FLAGS += -mcx16
 endif
   endif
endif
-->8--

So IIUC the build tries to use -mcx16 on amd64, except if the target
architecture is armv8-a.  This looks bogus, I guess what upstream wants
is to use -mcx16 only when doing a build *targetting* amd64.  The value
of LONG_BIT on the build machine doesn't seem relevant to achieve that,
but I may be missing something.

Welcome to ports...



I can confirm with upstream, but I read it as they want to avoid adding 
the flag if you're using the x32 ABI... but I agree with you in that 
using the build machine info to understand something about the target 
machine isn't the right way to go about it.



~Brian



Re: usr.bin/getconf: Add reporting LONG_BIT

2019-05-28 Thread Brian Callahan




On 5/28/19 7:24 AM, Christian Weisgerber wrote:

Brian Callahan:


lang/ponyc uses $(shell getconf LONG_BIT) in its Makefile to
determine whether or not we're on a 64-bit platform.
However, our getconf(1) doesn't support reporting LONG_BIT.
This diff enables it. GNU/FreeBSD/DragonFly/MacOS getconf reports
LONG_BIT, but NetBSD getconf does not.

It appears to be part of a larger extension that adds all numerical
limits from POSIX :

$ ssh freebsd-box
$ getconf LONG_MIN
-9223372036854775808
$ getconf LONG_MAX
9223372036854775807
$ getconf LONG_BIT
64

If we add any of this, shouldn't we add all of it?



Sure; I cherry picked what I needed since I wasn't sure if this was a 
direction we wanted to go in but I can make it more complete.


Or, if there's a better way to do what I need (get a GNU Makefile to 
figure out whether or not its on a 64-bit or 32-bit platform) then I'll 
just withdraw this diff in favor of amending the port.


~Brian



usr.bin/getconf: Add reporting LONG_BIT

2019-05-27 Thread Brian Callahan
Hi tech --

Below is a small diff in response to some configuration attempts
found in ports land.
lang/ponyc uses $(shell getconf LONG_BIT) in its Makefile to
determine whether or not we're on a 64-bit platform.
However, our getconf(1) doesn't support reporting LONG_BIT.
This diff enables it. GNU/FreeBSD/DragonFly/MacOS getconf reports
LONG_BIT, but NetBSD getconf does not.
Desirable? OK?

~Brian

Index: getconf.c
===
RCS file: /cvs/src/usr.bin/getconf/getconf.c,v
retrieving revision 1.20
diff -u -p -r1.20 getconf.c
--- getconf.c   26 Oct 2018 17:11:32 -  1.20
+++ getconf.c   27 May 2019 21:06:01 -
@@ -163,6 +163,7 @@ const struct conf_variable conf_table[] 
   constant_row(_XOPEN_IOV_MAX)
   constant_row(_XOPEN_NAME_MAX)
   constant_row(_XOPEN_PATH_MAX)
+  constant_row(LONG_BIT)
 
   /* Extensions */
   sysconf_row(PHYS_PAGES)



Re: ld.so speedup (part 2)

2019-04-28 Thread Brian Callahan




On 4/28/19 6:01 AM, Matthieu Herrb wrote:

On Sun, Apr 28, 2019 at 08:55:16AM +0100, Stuart Henderson wrote:

On Sat, Apr 27, 2019 at 09:55:33PM +0800, Nathanael Rensen wrote:

The diff below speeds up ld.so library intialisation where the

dependency

tree is broad and deep, such as samba's smbd which links over 100

libraries.

Past experience with ld.so changes suggests it would be good to have
test reports from multiple arches, *especially* hppa.

The regress test seem to pass here on hppa.



Pass here too on hppa and macppc and armv7.

~Brian



Re: Sync calendars.judaic with reality

2018-11-12 Thread Brian Callahan




On 11/12/18 1:13 PM, John Long wrote:

On Mon, 2018-11-12 at 12:38 -0500, Brian Callahan wrote:

On 11/12/18 11:20 AM, John Long wrote:

On Mon, 2018-11-12 at 06:57 +, Jason McIntyre wrote:

On Sun, Nov 11, 2018 at 07:36:55PM -0500, Brian Callahan wrote:

Hi tech --

Reminded by the recent email to tech@ about
calendar.christian, I
took a look at syncing calendar.judaic.

This diff does the following:
1. Sync the holiday days that are not connected to Pesach,
which
on
our calendar is Chanukah, Fast of 10 Tevet, and Yom
Yerushalayim.

I am not sure what this means. All of the Jewish holidays move on
the
civil calendar year to year. However, since every time the
calendar
includes an additional month (a second Adar) the month is inserted
before Pesach; therefore the holidays which fall after that time
do
not move *relative to Pesach* but they do move on the civil
calendar.

What are you talking about? This is in reference to the code in
calendar(1) that sets the dates for the Judaic calendar. If you
think
there's something wrong there, I await your patch to
usr.bin/calendar/pesach.c


I haven't seen the code. I responded to the comment that "days are not
connected to Pesach." All Jewish holidays are connected to Pesach, it
is one of the points from which years are calculated. And my statement
above and the explanation how it works is correct as I wrote it.

So what are you talking about? Exactly what did I write that you are
disputing here?


If you haven't read pesach.c or the calendar.judaic code, then you can't 
be helped because it is obvious from a quick glance at the code that 
some of the dates on calendar.judaic are listed as Westernized dates 
(aka the ones my diff changes) and others are dates in the form of 
Pesach+/-n. I'll be moving forward with the oks I have and without your 
opinion on everything else below because you can go be a shanda 
somewhere else and not on this list, as this list is no place for your 
nonsense diatribe as to what counts as Judaism or not.


~Brian




Yes, I know how the Hebrew calendar works. mickey@'s calculation is
actually quite nice IMO.

2. Add the holidays that are explicitly mentioned on the
Wikipedia
page of Jewish holidays, which adds Tu B'Shevat to our
calendar.
3. Replace the year marker on Rosh Hashana with the current
Jewish
year (5741 => 5779). This calendar has to be updated yearly as
it
is anyway, so it seems odd to me not to put the current year
if
we're going to list a year in connection with Rosh Hashanah.

It looks like mickey@ removed Yom HaAtzmaut some years ago due
to
the understanding that this be a religious and not secular
calendar. Which is a perfectly legitimate stance, as there is
no
universal yes or no as to whether or not the Israeli
rememberance
holidays are religious holidays, both in Israel and in the
dispora.

There is. Yom Hatzmaut, Yom HaShoah, Yom Hazikaron, Yom
Yerushalayim
are all Israeli (civil) holidays not connected to the Jewish
religion.


Reform Judaism and Conservative Judaism (in the US, at least) both
treat
Yom HaShoah as a religious holiday, with both crafting prayers
specifically for the holiday and with Conservative Judaism writing a
new
liturgy for the day.

If the calendar we are talking about is supposed to be representative
of mainstream Jewish belief and practice which has remained the same
for the past 3,500 years then those demominations will need their own
calendars.


This is considered so "common knowledge" that Wikipedia has a whole
section on it:


https://en.wikipedia.org/wiki/Yom_HaShoah#Religious_observances_and_liturgy

This is no proof of anything except activism which isn't
representative of the Jewish religion.


Additionally, there is no reason that calendar.judaic cannot be both
a
religious and secular calendar. mickey@ clearly had reasons for
preferring to it to be religious only but I can't go ask him his
reasoning for it. So my question is whether or not people prefer
one
over the other. I slightly prefer it to be both religious and
secular
but I care more about the dates being maintained so am willing to
go
either way.

I have no preference either, since I don't use it, rather I use
calendars from reliable sources and I have also written my own which
aligns with those. Again, I was responding to what Jason wrote.

Regardless, some of the holidays mentioned are Jewish, some are
Israeli. There is no overlap.


So we either need to remove Yom Yerushalayim for the same
reason,
or add back Yom HaAtzmaut, and add Yom HaShoah and Yom
Hazikaron.
Doesn't matter to me either way. It might be nice to include
Yom
HaShoah in either event, as it is likely to become a universal
Jewish religious holiday within our lifetimes.

That is absolutely not true. No major religious authority has ever
recognized any of the Israeli civil holidays.


This again is so not true that Wikipedia has a section on it:


https://en.wikipedia.org/wiki/Yom_HaShoah#Religious_observances_and_lit

Re: Sync calendars.judaic with reality

2018-11-12 Thread Brian Callahan




On 11/12/18 11:20 AM, John Long wrote:

On Mon, 2018-11-12 at 06:57 +, Jason McIntyre wrote:

On Sun, Nov 11, 2018 at 07:36:55PM -0500, Brian Callahan wrote:

Hi tech --

Reminded by the recent email to tech@ about calendar.christian, I
took a look at syncing calendar.judaic.

This diff does the following:
1. Sync the holiday days that are not connected to Pesach, which
on
our calendar is Chanukah, Fast of 10 Tevet, and Yom Yerushalayim.

I am not sure what this means. All of the Jewish holidays move on the
civil calendar year to year. However, since every time the calendar
includes an additional month (a second Adar) the month is inserted
before Pesach; therefore the holidays which fall after that time do
not move *relative to Pesach* but they do move on the civil calendar.


What are you talking about? This is in reference to the code in 
calendar(1) that sets the dates for the Judaic calendar. If you think 
there's something wrong there, I await your patch to 
usr.bin/calendar/pesach.c


Yes, I know how the Hebrew calendar works. mickey@'s calculation is 
actually quite nice IMO.



2. Add the holidays that are explicitly mentioned on the Wikipedia
page of Jewish holidays, which adds Tu B'Shevat to our calendar.
3. Replace the year marker on Rosh Hashana with the current Jewish
year (5741 => 5779). This calendar has to be updated yearly as it
is anyway, so it seems odd to me not to put the current year if
we're going to list a year in connection with Rosh Hashanah.

It looks like mickey@ removed Yom HaAtzmaut some years ago due to
the understanding that this be a religious and not secular
calendar. Which is a perfectly legitimate stance, as there is no
universal yes or no as to whether or not the Israeli rememberance
holidays are religious holidays, both in Israel and in the
dispora.

There is. Yom Hatzmaut, Yom HaShoah, Yom Hazikaron, Yom Yerushalayim
are all Israeli (civil) holidays not connected to the Jewish religion.



Reform Judaism and Conservative Judaism (in the US, at least) both treat 
Yom HaShoah as a religious holiday, with both crafting prayers 
specifically for the holiday and with Conservative Judaism writing a new 
liturgy for the day.


This is considered so "common knowledge" that Wikipedia has a whole 
section on it: 
https://en.wikipedia.org/wiki/Yom_HaShoah#Religious_observances_and_liturgy


Additionally, there is no reason that calendar.judaic cannot be both a 
religious and secular calendar. mickey@ clearly had reasons for 
preferring to it to be religious only but I can't go ask him his 
reasoning for it. So my question is whether or not people prefer one 
over the other. I slightly prefer it to be both religious and secular 
but I care more about the dates being maintained so am willing to go 
either way.



So we either need to remove Yom Yerushalayim for the same reason,
or add back Yom HaAtzmaut, and add Yom HaShoah and Yom Hazikaron.
Doesn't matter to me either way. It might be nice to include Yom
HaShoah in either event, as it is likely to become a universal
Jewish religious holiday within our lifetimes.

That is absolutely not true. No major religious authority has ever
recognized any of the Israeli civil holidays.



This again is so not true that Wikipedia has a section on it: 
https://en.wikipedia.org/wiki/Yom_HaShoah#Religious_observances_and_liturgy


But again, we can make the calendar religious and secular.

You may disagree with the Reform and Conservative movement, but both are 
major religious authorities and normative Judaism.



  Whatever is decided
having Yom Yerushalayim by itself is the strangest of all worlds.

And I'll volunteer to keep this calendar synced since I might be
the only one who cares about it.

OK?

~Brian


morning.

if you're willing to do the work, i say go for it. i don;t have
enough
knowledge about dates/holidays to provide any useful feedback.

if you have any opinion on the .christian diff, please do reply. i'm
about to as well, but again i just don;t have the knowledge to deal
with this.

I can help with this. Contact me offline with any questions.

In the diff below I see some conflicts in terms of transliteration.
There are two main communities of Jews and the transliterations below
do not align with either one in all cases.


Honestly, the transliterations are fine. I'll write them all in Yiddish 
though if you have concerns.


~Brian


/jl



jmc


Index: calendar.judaic
==
=
RCS file: /cvs/src/usr.bin/calendar/calendars/calendar.judaic,v
retrieving revision 1.5
diff -u -p -r1.5 calendar.judaic
--- calendar.judaic 6 Sep 2005 23:42:59 -   1.5
+++ calendar.judaic 12 Nov 2018 00:11:04 -
@@ -7,7 +7,7 @@
  #ifndef _calendar_judaic_
  #define _calendar_judaic_
  
-Pesach+163	First Day of Rosh Hashanah (Jewish Lunar New Year;

5741 == 1980;
+Pesach+163 First Day of Rosh Hashanah (Jewish Lunar New Year;
5779 == 2018;
 

Sync calendars.judaic with reality

2018-11-11 Thread Brian Callahan
Hi tech --

Reminded by the recent email to tech@ about calendar.christian, I
took a look at syncing calendar.judaic.

This diff does the following:
1. Sync the holiday days that are not connected to Pesach, which on
our calendar is Chanukah, Fast of 10 Tevet, and Yom Yerushalayim.
2. Add the holidays that are explicitly mentioned on the Wikipedia
page of Jewish holidays, which adds Tu B'Shevat to our calendar.
3. Replace the year marker on Rosh Hashana with the current Jewish
year (5741 => 5779). This calendar has to be updated yearly as it
is anyway, so it seems odd to me not to put the current year if
we're going to list a year in connection with Rosh Hashanah.

It looks like mickey@ removed Yom HaAtzmaut some years ago due to
the understanding that this be a religious and not secular
calendar. Which is a perfectly legitimate stance, as there is no
universal yes or no as to whether or not the Israeli rememberance
holidays are religious holidays, both in Israel and in the dispora.

So we either need to remove Yom Yerushalayim for the same reason,
or add back Yom HaAtzmaut, and add Yom HaShoah and Yom Hazikaron.
Doesn't matter to me either way. It might be nice to include Yom
HaShoah in either event, as it is likely to become a universal
Jewish religious holiday within our lifetimes. Whatever is decided
having Yom Yerushalayim by itself is the strangest of all worlds.

And I'll volunteer to keep this calendar synced since I might be
the only one who cares about it.

OK?

~Brian

Index: calendar.judaic
===
RCS file: /cvs/src/usr.bin/calendar/calendars/calendar.judaic,v
retrieving revision 1.5
diff -u -p -r1.5 calendar.judaic
--- calendar.judaic 6 Sep 2005 23:42:59 -   1.5
+++ calendar.judaic 12 Nov 2018 00:11:04 -
@@ -7,7 +7,7 @@
 #ifndef _calendar_judaic_
 #define _calendar_judaic_
 
-Pesach+163 First Day of Rosh Hashanah (Jewish Lunar New Year; 5741 == 1980;
+Pesach+163 First Day of Rosh Hashanah (Jewish Lunar New Year; 5779 == 2018;
sabbatical)
 Pesach+164 Rosh Hashanah (sabbatical)
 Pesach+166 Fast of Gedalya (Murder of Gedalya and subsequent Exile; fast 
day)
@@ -17,8 +17,9 @@ Pesach+179Succot (sabbatical)
 Pesach+184 Hoshanah Rabba (7th day of Succos)
 Pesach+185 Shmini Atzeres (8th Day of Gathering; sabbatical)
 Pesach+186 Shmini Atzeres/Simchas Torah (Rejoicing of the Law; sabbatical)
-12/12* First Day of Chanukah
-12/27* Fast of Asara B'Tevet (Babylonians put siege on Jerusalem; fast day)
+12/03* First Day of Chanukah
+12/18* Fast of Asara B'Tevet (Babylonians put siege on Jerusalem; fast day)
+01/20* Tu B'Shevat (New Year of the Trees)
 Pesach-31  Fast of Esther (Battle of Purim; fast day)
 Pesach-30  Purim (Feast of Lots)
 Pesach-29  Purim (Feast of Lots)
@@ -27,10 +28,10 @@ Pesach+1Pesach (sabbatical)
 Pesach+6   Pesach (sabbatical)
 Pesach+7   Pesach (Last Day of Passover; 8th day of Pesach; sabbatical)
 Pesach+34  Lag Ba`omer (Commemoration of the Great Rebellion)
-05/22* Yom Yerushalayim (Reunification of Jerusalem)
+06/01* Yom Yerushalayim (Reunification of Jerusalem)
 Pesach+50  Shavuot (Festival of Weeks; sabbatical)
 Pesach+51  Shavuot (Festival of Weeks; sabbatical)
-07/10* Fast of Shiv'a Asar B'Tammuz (Romans breach Wall of Jerusalem; fast day)
+07/21* Fast of Shiv'a Asar B'Tammuz (Romans breach Wall of Jerusalem; fast day)
 Pesach+81  Fast of Tish'a B'Av (Babylon destroys Holy Temple; fast day)
 
 #endif /* !_calendar_judaic_ */



Re: [Patch] mg(1) set column-number-mode on by default

2018-05-26 Thread Brian Callahan
Hi Florian --

On 5/26/2018 3:49 PM, Florian Obser wrote:
> Not OK.
>
> With column-number-mode on mg has to redraw the modeline (maybe even
> the whole window?) on every cursor move. Try it on a 9600 serial
> console.
>
> With line-number-mode on the redraw is only necessary when a cursor
> move changes the line number. Happens considerably less often.
>
> Also note how this is in line with what emacs does.
>
> The tutorial should be fixed.

I already suggested exactly this:
https://marc.info/?l=openbsd-tech=152727379111353=2

~Brian

> On Sat, May 26, 2018 at 08:03:24PM +0300, Leonid Bobrov wrote:
>> From https://marc.info/?t=15272488061=1=2
>>
>> If line-number-mode is on by default, I don't get what is
>> the problem with these "slow serial lines", plus without
>> this patch below we have confusing tutorial for new users:
>>
>> Index: display.c
>> ===
>> RCS file: /cvs/src/usr.bin/mg/display.c,v
>> retrieving revision 1.48
>> diff -u -p -r1.48 display.c
>> --- display.c6 Jul 2017 19:27:37 -   1.48
>> +++ display.c26 May 2018 13:27:35 -
>> @@ -91,7 +91,7 @@ struct video blanks;   /* Blank line im
>>  struct score *score;/* [NROW * NROW] */
>>  
>>  static int   linenos = TRUE;
>> -static int   colnos = FALSE;
>> +static int   colnos = TRUE;
>>  
>>  /* Is macro recording enabled? */
>>  extern int macrodef;
>>



Re: [Patch] mg(1) tutorial: no columns :(

2018-05-25 Thread Brian Callahan



On 05/25/18 10:25, Leonid Bobrov wrote:

Mentioning would be nice.

display.c's 1.39 revision log says "off by default
to not kill slow serial lines" -_-



Then why not write that diff?
Something like the below, maybe? I'm not totally sold that we need it, but am 
not unsold either. I could go either way, depending on what others think.

~Brian

Index: tutorial
===
RCS file: /cvs/src/usr.bin/mg/tutorial,v
retrieving revision 1.17
diff -u -p -r1.17 tutorial
--- tutorial    30 May 2017 07:11:40 -    1.17
+++ tutorial    25 May 2018 18:34:32 -
@@ -218,10 +218,11 @@ you're editing a file named "tutorial".
 saved it, it should have a "**" to the left of those words. If this file is
 read-only, you should see a "%%" to the left of those words.

-To the right of the status line, you should see L followed by digits and C
-followed by some more digits. These indicate the line number and column number
-of the file that your cursor is currently on. If you move the cursor around,
-you should see the line and column number change.
+To the right of the status line, you should see L followed by digits and, if
+column-number-mode is enabled, C followed by some more digits. These indicate
+the line number and column number of the file that your cursor is currently
+on. If you move the cursor around, you should see the line and column number
+change.

 In the middle of the screen, you should see the word "(fundamental)" which
 indicates that the current editing mode is "fundamental-mode". The mg editor



Re: mg: have Insert key toggle overwrite mode by default

2017-12-17 Thread Brian Callahan

Committed, thanks.

On 12/17/17 05:11, Florian Obser wrote:

OK

On Sat, Dec 16, 2017 at 10:06:59PM +, Lari Rasku wrote:

There's a fairly strong convention among text editors that the Insert
key should toggle overwrite mode.  This is admittedly far more common
among GUI editors, but could mg adopt it as a default anyway?

diff --git usr.bin/mg/ttykbd.c usr.bin/mg/ttykbd.c
index 67bc8e4bd..485291a77 100644
--- usr.bin/mg/ttykbd.c
+++ usr.bin/mg/ttykbd.c
@@ -52,6 +52,8 @@ ttykeymapinit(void)
dobindkey(fundamental_map, "scroll-up", key_npage);
if (key_ppage)
dobindkey(fundamental_map, "scroll-down", key_ppage);
+   if (key_ic)
+   dobindkey(fundamental_map, "overwrite-mode", key_ic);
if (key_dc)
dobindkey(fundamental_map, "delete-char", key_dc);
  





Re: mg: have Insert key toggle overwrite mode by default

2017-12-16 Thread Brian Callahan


On 12/16/17 17:06, Lari Rasku wrote:

There's a fairly strong convention among text editors that the Insert
key should toggle overwrite mode.  This is admittedly far more common
among GUI editors, but could mg adopt it as a default anyway?


I'm inclined to agree with at least the general direction, as GNU Emacs 
even in terminal mode does this.


~Brian


diff --git usr.bin/mg/ttykbd.c usr.bin/mg/ttykbd.c
index 67bc8e4bd..485291a77 100644
--- usr.bin/mg/ttykbd.c
+++ usr.bin/mg/ttykbd.c
@@ -52,6 +52,8 @@ ttykeymapinit(void)
dobindkey(fundamental_map, "scroll-up", key_npage);
if (key_ppage)
dobindkey(fundamental_map, "scroll-down", key_ppage);
+   if (key_ic)
+   dobindkey(fundamental_map, "overwrite-mode", key_ic);
if (key_dc)
dobindkey(fundamental_map, "delete-char", key_dc);
  





Re: Include hostname in shell prompts by default

2017-12-09 Thread Brian Callahan


On 12/9/2017 1:28 PM, Bryan Steele wrote:
> On Sat, Dec 09, 2017 at 06:44:44PM +0100, Theo Buehler wrote:
>> This was discussed in a smaller circle and has been in snaps for two
>> days, but I'd like to show this to a wider audience.
>>
>> Theo asked me to make sure that all our shells print a prompt including
>> the hostname by default. The reasoning is roughly as follows:
>>
>> With tmux, ssh and vmd, we tend to open shells on many different hosts
>> simultaneously and the default prompts '$ ' and '# ' for {,k}sh as well
>> as  '% ' and '# ' for csh become dangerous: it's very easy to issue a
>> command on the wrong host.
>>
>> This can easily be avoided by displaying the hostname in the prompt.
>> Everything beyond "hostname{$,#,%} " is going to be a matter of taste,
>> so we left it at that. If you use an FQDN, only the first part (the
>> output of 'hostname -s') will be printed.
>>
>> Since not everybody makes use of the config files in /etc/skel or runs
>> only login shells, it is not really possible to handle this with config
>> files. Thus, we decided to hardcode it in the shells. We are aware that
>> POSIX says that PS1 defaults to '$ ' or '# ' for sh(1).
>>
>> The simplest case is ksh: rely on the already existing shell escapes.
>> For sh we can easily fall back to these (the diff to ksh/lex.c).  For
>> csh, I decided to implement the "%m" prompt escape which is standard in
>> c-type shells, so I don't expect this to cause surprises.
>>
>> In single user mode and the early installer, gethostname() returns the
>> empty string, so the familiar prompts will be displayed there.
> I think we should go ahead with this for the reasons mentioned, the
> default configuration should make things easier for the people using it,
> which means developers doing release builds, spinning up vms, etc.
>
> People can go on and on about standards compliance, but if it means
> someone is less likely to reboot the wrong machine, or worse, then
> POSIX be damned.
>
> ok brynet@

I'm with brynet@ and the others on this. Was a nice surprise when I
installed a new snap last night, already proved itself to be useful.

ok bcallah@, fwiw

>> Index: bin/csh/const.c
>> ===
>> RCS file: /var/cvs/src/bin/csh/const.c,v
>> retrieving revision 1.8
>> diff -u -p -r1.8 const.c
>> --- bin/csh/const.c  26 Oct 2015 16:27:04 -  1.8
>> +++ bin/csh/const.c  8 Dec 2017 12:15:26 -
>> @@ -114,6 +114,8 @@ Char STRprintexitvalue[] = { 'p', 'r', '
>>  'a', 'l', 'u', 'e', '\0' };
>>  Char STRprompt[]= { 'p', 'r', 'o', 'm', 'p', 't', '\0' };
>>  Char STRprompt2[]   = { 'p', 'r', 'o', 'm', 'p', 't', '2', '\0' };
>> +Char STRpromptroot[]= { '%', 'm', '#', ' ', '\0' };
>> +Char STRpromptuser[]= { '%', 'm', '%', ' ', '\0' };
>>  Char STRpushdsilent[]   = { 'p', 'u', 's', 'h', 'd', 's', 'i', 'l', 
>> 'e', 'n',
>>  't', '\0' };
>>  Char STRret[]   = { '\n', '\0' };
>> @@ -138,8 +140,6 @@ Char STRspor2sp[]= { ' ', '|', '|', ' '
>>  Char STRsporsp[]= { ' ', '|', ' ', '\0' };
>>  Char STRstar[]  = { '*', '\0' };
>>  Char STRstatus[]= { 's', 't', 'a', 't', 'u', 's', '\0' };
>> -Char STRsymcent[]   = { '%', ' ', '\0' };
>> -Char STRsymhash[]   = { '#', ' ', '\0' };
>>  Char STRterm[]  = { 't', 'e', 'r', 'm', '\0' };
>>  Char STRthen[]  = { 't', 'h', 'e', 'n', '\0' };
>>  Char STRtilde[] = { '~', '\0' };
>> Index: bin/csh/csh.c
>> ===
>> RCS file: /var/cvs/src/bin/csh/csh.c,v
>> retrieving revision 1.41
>> diff -u -p -r1.41 csh.c
>> --- bin/csh/csh.c30 Aug 2017 06:42:21 -  1.41
>> +++ bin/csh/csh.c8 Dec 2017 12:16:00 -
>> @@ -401,7 +401,7 @@ main(int argc, char *argv[])
>>   * Set up the prompt.
>>   */
>>  if (prompt) {
>> -set(STRprompt, Strsave(uid == 0 ? STRsymhash : STRsymcent));
>> +set(STRprompt, Strsave(uid == 0 ? STRpromptroot : STRpromptuser));
>>  /* that's a meta-questionmark */
>>  set(STRprompt2, Strsave(STRmquestion));
>>  }
>> @@ -1283,7 +1283,16 @@ printprompt(void)
>>  for (cp = value(STRprompt); *cp; cp++)
>>  if (*cp == HIST)
>>  (void) fprintf(cshout, "%d", eventno + 1);
>> -else {
>> +else if (*cp == '%' && *(cp + 1) == 'm') {
>> +char hostname[HOST_NAME_MAX + 1];
>> +char *p;
>> +
>> +gethostname(hostname, sizeof hostname);
>> +if ((p = strchr(hostname, '.')) != NULL)
>> +*p = '\0';
>> +fprintf(cshout, "%s", hostname);
>> +cp++;
>> +} else {
>>  if (*cp == '\\' && cp[1] == HIST)
>>  cp++;
>>  (void) vis_fputc(*cp | QUOTE, cshout);
>> Index: bin/ksh/lex.c
>> ===
>> 

Re: mg: fix line numbering bug

2017-09-09 Thread Brian Callahan

ok bcallah@


On 9/9/2017 6:51 AM, Florian Obser wrote:

Nice catch!

OK florian@ if someone wants to commit. Alternatively I take OKs :)

On Sat, Sep 09, 2017 at 05:24:41AM +0200, Martin Wanvik wrote:

When inserting a newline, only increment dotline for windows that are
displaying the same buffer as the current one.

Index: usr.bin/mg/line.c
===
RCS file: /cvs/src/usr.bin/mg/line.c,v
retrieving revision 1.58
diff -u -p -u -r1.58 line.c
--- usr.bin/mg/line.c   11 Dec 2015 20:21:23 -  1.58
+++ usr.bin/mg/line.c   9 Sep 2017 01:36:02 -
@@ -264,7 +264,8 @@ lnewline_at(struct line *lp1, int doto)
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {
if (wp->w_linep == lp1)
wp->w_linep = lp2;
-   if (wp->w_dotline >= tcurwpdotline)
+   if (wp->w_dotline >= tcurwpdotline &&
+   wp->w_bufp == curwp->w_bufp)
wp->w_dotline++;
}
undo_add_boundary(FFRAND, 1);
@@ -292,7 +293,8 @@ lnewline_at(struct line *lp1, int doto)
wp->w_dotp = lp2;
wp->w_doto -= doto;
wp->w_dotline++;
-   } else if (wp->w_dotline > tcurwpdotline)
+   } else if (wp->w_dotline > tcurwpdotline &&
+   wp->w_bufp == curwp->w_bufp)
wp->w_dotline++;
if (wp->w_markp == lp1 && wp->w_marko >= doto) {
wp->w_markp = lp2;







Re: mg: print default choice before colon in echo line prompts

2017-08-05 Thread Brian Callahan



On 08/05/17 18:23, Brian Callahan wrote:


On 8/5/2017 5:15 PM, Scott Cheloha wrote:

1 week bump, any other feedback on this?

I can't commit this right now but I'm also ok with it. If no one commits
it by the time I get home later tonight, I'll do it.

~Brian


Committed now--thanks!

~Brian


--
Scott Cheloha


On Jul 30, 2017, at 2:05 AM, Florian Obser <flor...@narrans.de> wrote:

OK florian@

[...]




Re: mg: print default choice before colon in echo line prompts

2017-08-05 Thread Brian Callahan


On 8/5/2017 5:15 PM, Scott Cheloha wrote:
> 1 week bump, any other feedback on this?

I can't commit this right now but I'm also ok with it. If no one commits
it by the time I get home later tonight, I'll do it.

~Brian

> --
> Scott Cheloha
>
>> On Jul 30, 2017, at 2:05 AM, Florian Obser  wrote:
>>
>> OK florian@
>>
>> [...]



m4(1): Don't need to link with -ly

2017-06-16 Thread Brian Callahan
Hi tech --

m4 links with -ly, presumably for the yyerror() function.
But there already is a yyerror() in usr.bin/m4/expr.c, which is
written specifically for m4. So we don't need -ly.

OK?

~Brian

Index: Makefile
===
RCS file: /cvs/src/usr.bin/m4/Makefile,v
retrieving revision 1.13
diff -u -p -u -p -r1.13 Makefile
--- Makefile12 May 2014 19:11:19 -  1.13
+++ Makefile16 Jun 2017 20:11:21 -
@@ -8,8 +8,8 @@ CFLAGS+=-DEXTENDED -I.
 CDIAGFLAGS=-W -Wall -Wstrict-prototypes -pedantic \
-Wno-unused -Wno-char-subscripts -Wno-sign-compare
 
-LDADD= -ly -ll -lm -lutil
-DPADD= ${LIBY} ${LIBL} ${LIBM} ${LIBUTIL}
+LDADD= -ll -lm -lutil
+DPADD= ${LIBL} ${LIBM} ${LIBUTIL}
 
 SRCS=  eval.c expr.c look.c main.c misc.c gnum4.c trace.c tokenizer.l parser.y
 MAN=   m4.1



Re: m4(1): add -e flag support

2017-06-14 Thread Brian Callahan


On 6/14/2017 10:18 AM, marc espie wrote:
> on wed, jun 14, 2017 at 09:58:54am -0400, brian callahan wrote:
>> hi marc --
>>
>> how's this version?
>> also includes a slight tweak to the single -e flag regress test.
>>
>> ~brian
> comment nit, otherwise good.
>
>> +extern int error_warns; /* make warnings cause exit_code > 0 */
> exit_code = 1, why > 0 when you actually specify the result everywhere ?

Hmm... it's just supposed to be non-zero. Guess that morphed into > 0 in
my head. No reason to not just specify it since that's what the code does.



Re: m4(1): add -E flag support

2017-06-14 Thread Brian Callahan
Hi Marc --

How's this version?
Also includes a slight tweak to the single -E flag regress test.

~Brian

Index: usr.bin/m4/eval.c
===
RCS file: /cvs/src/usr.bin/m4/eval.c,v
retrieving revision 1.74
diff -u -p -u -p -r1.74 eval.c
--- usr.bin/m4/eval.c   5 Feb 2015 12:59:57 -   1.74
+++ usr.bin/m4/eval.c   14 Jun 2017 13:50:07 -
@@ -269,6 +269,10 @@ expand_builtin(const char *argv[], int a
warn("%s at line %lu: include(%s)",
CURRENT_NAME, CURRENT_LINE, 
argv[2]);
exit_code = 1;
+   if (fatal_warns) {
+   killdiv();
+   exit(exit_code);
+   }
} else
err(1, "%s at line %lu: include(%s)",
CURRENT_NAME, CURRENT_LINE, 
argv[2]);
Index: usr.bin/m4/extern.h
===
RCS file: /cvs/src/usr.bin/m4/extern.h,v
retrieving revision 1.54
diff -u -p -u -p -r1.54 extern.h
--- usr.bin/m4/extern.h 12 May 2014 19:11:19 -  1.54
+++ usr.bin/m4/extern.h 14 Jun 2017 13:50:07 -
@@ -58,6 +58,8 @@ extern void doesyscmd(const char *);
 extern void getdivfile(const char *);
 extern void doformat(const char *[], int);
 
+extern void m4_warnx(const char *, ...);
+
 /* look.c */
 
 #define FLAG_UNTRACED 0
@@ -175,4 +177,6 @@ extern int  synch_lines;/* line synchro
 
 extern int mimic_gnu;  /* behaves like gnu-m4 */
 extern int prefix_builtins;/* prefix builtin macros with m4_ */
+extern int error_warns;/* make warnings cause exit_code > 0 */
+extern int fatal_warns;/* make warnings fatal */
 
Index: usr.bin/m4/gnum4.c
===
RCS file: /cvs/src/usr.bin/m4/gnum4.c,v
retrieving revision 1.50
diff -u -p -u -p -r1.50 gnum4.c
--- usr.bin/m4/gnum4.c  29 Apr 2015 00:13:26 -  1.50
+++ usr.bin/m4/gnum4.c  14 Jun 2017 13:50:07 -
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -234,7 +235,7 @@ addchar(int c)
 }
 
 static char *
-getstring()
+getstring(void)
 {
addchar('\0');
current = 0;
@@ -255,11 +256,29 @@ exit_regerror(int er, regex_t *re, const
m4errx(1, "regular expression error in %s: %s.", source, errbuf);
 }
 
+/* warnx() plus check to see if we need to change exit code or exit.
+ * -E flag functionality.
+ */
+void
+m4_warnx(const char *fmt, ...)
+{
+   va_list ap;
+
+   va_start(ap, fmt);
+   vwarnx(fmt, ap);
+   va_end(ap);
+
+   if (fatal_warns)
+   exit(1);
+   if (error_warns)
+   exit_code = 1;
+}
+
 static void
 add_sub(int n, const char *string, regex_t *re, regmatch_t *pm)
 {
if (n > re->re_nsub)
-   warnx("No subexpression %d", n);
+   m4_warnx("No subexpression %d", n);
/* Subexpressions that did not match are
 * not an error.  */
else if (pm[n].rm_so != -1 &&
@@ -442,7 +461,7 @@ void
 dopatsubst(const char *argv[], int argc)
 {
if (argc <= 3) {
-   warnx("Too few arguments to patsubst");
+   m4_warnx("Too few arguments to patsubst");
return;
}
/* special case: empty regexp */
@@ -494,7 +513,7 @@ doregexp(const char *argv[], int argc)
const char *source;
 
if (argc <= 3) {
-   warnx("Too few arguments to regexp");
+   m4_warnx("Too few arguments to regexp");
return;
}
/* special gnu case */
Index: usr.bin/m4/m4.1
===
RCS file: /cvs/src/usr.bin/m4/m4.1,v
retrieving revision 1.63
diff -u -p -u -p -r1.63 m4.1
--- usr.bin/m4/m4.1 14 Sep 2015 20:06:58 -  1.63
+++ usr.bin/m4/m4.1 14 Jun 2017 13:50:07 -
@@ -38,7 +38,7 @@
 .Nd macro language processor
 .Sh SYNOPSIS
 .Nm
-.Op Fl gPs
+.Op Fl EgPs
 .Oo
 .Sm off
 .Fl D Ar name Op No = Ar value
@@ -127,6 +127,19 @@ turn on all options.
 .Pp
 By default, trace is set to
 .Qq eq .
+.It Fl E
+Set warnings to be fatal.
+When a single
+.Fl E
+flag is specified, if warnings are issued, execution continues but
+.Nm
+will exit with a non-zero exit status.
+When multiple
+.Fl E
+flags are specified, execution will halt upon issuing the first warning and
+.Nm
+will exit with a non-zero exit status.
+This behaviour matches GNU-m4 1.4.9 and later.
 .It Fl g
 Activate GNU-m4 compatibility mode.
 In this mode, translit handles simple character
@@ -434,7 +447,9 @@ Returns the current file's name.
 .Pp
 But note that the
 .Ic m4exit
-macro can modify the exit 

Re: m4(1): add -E flag support

2017-06-13 Thread Brian Callahan
Hi --

Whoops, that was unintentional. Fixed.

~Brian

Index: usr.bin/m4/eval.c
===
RCS file: /cvs/src/usr.bin/m4/eval.c,v
retrieving revision 1.74
diff -u -p -u -p -r1.74 eval.c
--- usr.bin/m4/eval.c   5 Feb 2015 12:59:57 -   1.74
+++ usr.bin/m4/eval.c   13 Jun 2017 21:03:15 -
@@ -269,6 +269,12 @@ expand_builtin(const char *argv[], int a
warn("%s at line %lu: include(%s)",
CURRENT_NAME, CURRENT_LINE, 
argv[2]);
exit_code = 1;
+   /* exit immediately if multiple -E flags
+*/
+   if (fatal_warns == 2) {
+   killdiv();
+   exit(exit_code);
+   }
} else
err(1, "%s at line %lu: include(%s)",
CURRENT_NAME, CURRENT_LINE, 
argv[2]);
Index: usr.bin/m4/extern.h
===
RCS file: /cvs/src/usr.bin/m4/extern.h,v
retrieving revision 1.54
diff -u -p -u -p -r1.54 extern.h
--- usr.bin/m4/extern.h 12 May 2014 19:11:19 -  1.54
+++ usr.bin/m4/extern.h 13 Jun 2017 21:03:15 -
@@ -58,6 +58,8 @@ extern void doesyscmd(const char *);
 extern void getdivfile(const char *);
 extern void doformat(const char *[], int);
 
+extern void m4_warnx(const char *, ...);
+
 /* look.c */
 
 #define FLAG_UNTRACED 0
@@ -175,4 +177,5 @@ extern int  synch_lines;/* line synchro
 
 extern int mimic_gnu;  /* behaves like gnu-m4 */
 extern int prefix_builtins;/* prefix builtin macros with m4_ */
+extern int fatal_warns;/* make warnings fatal */
 
Index: usr.bin/m4/gnum4.c
===
RCS file: /cvs/src/usr.bin/m4/gnum4.c,v
retrieving revision 1.50
diff -u -p -u -p -r1.50 gnum4.c
--- usr.bin/m4/gnum4.c  29 Apr 2015 00:13:26 -  1.50
+++ usr.bin/m4/gnum4.c  13 Jun 2017 21:03:15 -
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -234,7 +235,7 @@ addchar(int c)
 }
 
 static char *
-getstring()
+getstring(void)
 {
addchar('\0');
current = 0;
@@ -255,11 +256,35 @@ exit_regerror(int er, regex_t *re, const
m4errx(1, "regular expression error in %s: %s.", source, errbuf);
 }
 
+/* warnx() plus check to see if we need to change exit code or exit.
+ * -E flag functionality.
+ */
+void
+m4_warnx(const char *fmt, ...)
+{
+   va_list ap;
+
+   va_start(ap, fmt);
+   vwarnx(fmt, ap);
+   va_end(ap);
+
+   /* Do nothing if no -E flags, set exit_code > 0 but keep going
+* if one -E flag, exit immediately with exit status > 0 if
+* two or more -E flags.
+*/
+   if (fatal_warns == 0)
+   return;
+   else if (fatal_warns == 1)
+   exit_code = 1;
+   else
+   exit(1);
+}
+
 static void
 add_sub(int n, const char *string, regex_t *re, regmatch_t *pm)
 {
if (n > re->re_nsub)
-   warnx("No subexpression %d", n);
+   m4_warnx("No subexpression %d", n);
/* Subexpressions that did not match are
 * not an error.  */
else if (pm[n].rm_so != -1 &&
@@ -442,7 +467,7 @@ void
 dopatsubst(const char *argv[], int argc)
 {
if (argc <= 3) {
-   warnx("Too few arguments to patsubst");
+   m4_warnx("Too few arguments to patsubst");
return;
}
/* special case: empty regexp */
@@ -494,7 +519,7 @@ doregexp(const char *argv[], int argc)
const char *source;
 
if (argc <= 3) {
-   warnx("Too few arguments to regexp");
+   m4_warnx("Too few arguments to regexp");
return;
}
/* special gnu case */
Index: usr.bin/m4/m4.1
===
RCS file: /cvs/src/usr.bin/m4/m4.1,v
retrieving revision 1.63
diff -u -p -u -p -r1.63 m4.1
--- usr.bin/m4/m4.1 14 Sep 2015 20:06:58 -  1.63
+++ usr.bin/m4/m4.1 13 Jun 2017 21:03:15 -
@@ -38,7 +38,7 @@
 .Nd macro language processor
 .Sh SYNOPSIS
 .Nm
-.Op Fl gPs
+.Op Fl EgPs
 .Oo
 .Sm off
 .Fl D Ar name Op No = Ar value
@@ -127,6 +127,19 @@ turn on all options.
 .Pp
 By default, trace is set to
 .Qq eq .
+.It Fl E
+Set warnings to be fatal.
+When a single
+.Fl E
+flag is specified, if warnings are issued, execution continues but
+.Nm
+will exit with a non-zero exit status.
+When multiple
+.Fl E
+flags are specified, execution will halt upon issuing the first warning and
+.Nm
+will exit with a non-zero exit status.
+This behaviour matches 

Re: m4(1): add -E flag support

2017-06-13 Thread Brian Callahan
Hi --

Updated diff attached. Wrapped everything up in an m4_warnx() call
and added a regress test for single -E. Thanks!

The one fatal_warns check in eval.c seems like a special case, so
I left that one as it was.

~Brian

Index: usr.bin/m4/eval.c
===
RCS file: /cvs/src/usr.bin/m4/eval.c,v
retrieving revision 1.74
diff -u -p -u -p -r1.74 eval.c
--- usr.bin/m4/eval.c   5 Feb 2015 12:59:57 -   1.74
+++ usr.bin/m4/eval.c   13 Jun 2017 20:22:09 -
@@ -269,6 +269,12 @@ expand_builtin(const char *argv[], int a
warn("%s at line %lu: include(%s)",
CURRENT_NAME, CURRENT_LINE, 
argv[2]);
exit_code = 1;
+   /* exit immediately if multiple -E flags
+*/
+   if (fatal_warns == 2) {
+   killdiv();
+   exit(exit_code);
+   }
} else
err(1, "%s at line %lu: include(%s)",
CURRENT_NAME, CURRENT_LINE, 
argv[2]);
Index: usr.bin/m4/extern.h
===
RCS file: /cvs/src/usr.bin/m4/extern.h,v
retrieving revision 1.54
diff -u -p -u -p -r1.54 extern.h
--- usr.bin/m4/extern.h 12 May 2014 19:11:19 -  1.54
+++ usr.bin/m4/extern.h 13 Jun 2017 20:22:09 -
@@ -58,6 +58,8 @@ extern void doesyscmd(const char *);
 extern void getdivfile(const char *);
 extern void doformat(const char *[], int);
 
+extern void m4_warnx(const char *, ...);
+
 /* look.c */
 
 #define FLAG_UNTRACED 0
@@ -175,4 +177,5 @@ extern int  synch_lines;/* line synchro
 
 extern int mimic_gnu;  /* behaves like gnu-m4 */
 extern int prefix_builtins;/* prefix builtin macros with m4_ */
+extern int fatal_warns;/* make warnings fatal */
 
Index: usr.bin/m4/gnum4.c
===
RCS file: /cvs/src/usr.bin/m4/gnum4.c,v
retrieving revision 1.50
diff -u -p -u -p -r1.50 gnum4.c
--- usr.bin/m4/gnum4.c  29 Apr 2015 00:13:26 -  1.50
+++ usr.bin/m4/gnum4.c  13 Jun 2017 20:22:09 -
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -234,7 +235,7 @@ addchar(int c)
 }
 
 static char *
-getstring()
+getstring(void)
 {
addchar('\0');
current = 0;
@@ -255,11 +256,35 @@ exit_regerror(int er, regex_t *re, const
m4errx(1, "regular expression error in %s: %s.", source, errbuf);
 }
 
+/* warnx() plus check to see if we need to change exit code or exit.
+ * -E flag functionality.
+ */
+void
+m4_warnx(const char *fmt, ...)
+{
+   va_list ap;
+
+   va_start(ap, fmt);
+   vwarnx(fmt, ap);
+   va_end(ap);
+
+   /* Do nothing if no -E flags, set exit_code > 0 but keep going
+* if one -E flag, exit immediately with exit status > 0 if
+* two or more -E flags.
+*/
+   if (fatal_warns == 0)
+   return;
+   else if (fatal_warns == 1)
+   exit_code = 1;
+   else
+   exit(1);
+}
+
 static void
 add_sub(int n, const char *string, regex_t *re, regmatch_t *pm)
 {
if (n > re->re_nsub)
-   warnx("No subexpression %d", n);
+   m4_warnx("No subexpression %d", n);
/* Subexpressions that did not match are
 * not an error.  */
else if (pm[n].rm_so != -1 &&
@@ -442,7 +467,7 @@ void
 dopatsubst(const char *argv[], int argc)
 {
if (argc <= 3) {
-   warnx("Too few arguments to patsubst");
+   m4_warnx("Too few arguments to patsubst");
return;
}
/* special case: empty regexp */
@@ -494,7 +519,7 @@ doregexp(const char *argv[], int argc)
const char *source;
 
if (argc <= 3) {
-   warnx("Too few arguments to regexp");
+   m4_warnx("Too few arguments to regexp");
return;
}
/* special gnu case */
Index: usr.bin/m4/m4.1
===
RCS file: /cvs/src/usr.bin/m4/m4.1,v
retrieving revision 1.63
diff -u -p -u -p -r1.63 m4.1
--- usr.bin/m4/m4.1 14 Sep 2015 20:06:58 -  1.63
+++ usr.bin/m4/m4.1 13 Jun 2017 20:22:09 -
@@ -38,7 +38,7 @@
 .Nd macro language processor
 .Sh SYNOPSIS
 .Nm
-.Op Fl gPs
+.Op Fl EgPs
 .Oo
 .Sm off
 .Fl D Ar name Op No = Ar value
@@ -127,6 +127,19 @@ turn on all options.
 .Pp
 By default, trace is set to
 .Qq eq .
+.It Fl E
+Set warnings to be fatal.
+When a single
+.Fl E
+flag is specified, if warnings are issued, execution continues but
+.Nm
+will exit with a non-zero exit status.

m4(1): add -E flag support

2017-06-13 Thread Brian Callahan
Hi tech --

I've shared this with a few developers, and have been advised to
share now with a wider audience.

This diff adds -E flag functionality to m4(1). I wrote this diff
after noticing a patch in ports/devel/scons by jasper@ with the
comment:
XXX: OpenBSD's m4(1) lacks the -E option (needs to be implemented though).

The -E flag causes warnings to become fatal. It appears to be a
GNU extension. Unfortunately, the GNU people have multiple
definitions of what fatal is, so I will outline the situation and
my approach to this diff.

The -E flag was first introduced to GNU m4 in 1994, version 1.2.
The flag, when set, caused m4 to exit with an exit status > 0
immediately upon issuing its first warning.

In GNU m4 1.4.9, released in 2007, this behavior was changed to
do the following:
1. If a single -E flag is given, still change the exit status of
   m4 to be > 0, but otherwise continue as normal.
2. If 2 or more -E flags are given, do the old -E behavior, that
   is, exit with an exit status > 0 immediately upon issuing the
   first warning.
This is the current behavior of all later GNU m4 releases.

I have chosen the 1.4.9 and later behavior for our m4, as it has
been now 10 years since the new behavior was introduced.

I also looked to see if there is an upstream for m4. There is not
as far as I can tell. So we are our own upstream. In fact, we are
upstream for other projects as well.

Here's that situation:
1. FreeBSD (and DragonFly) sync their m4(1) to ours. They do not
   have an -E flag because we don't.
2. NetBSD added -E flag support in January 2016. However, NetBSD
   opted to implement the old pre-GNU m4 1.4.9 -E flag behavior.
   Additionally, NetBSD's implementation does not error out for
   all warnings: only warnings for functions contained within
   gm4.c got the -E flag treatment. Therefore, it is possible to
   run NetBSD's m4(1) with the -E flag, receive a warning, and
   not error out (and the -E flag does absolutely nothing in the
   NetBSD implementation if the -g flag is not also given).
   My implementation was written entirely independently from the
   NetBSD implementation, as I did not even know they had added
   -E flag support until this diff was written and sent off for
   early review.
3. Solaris and AIX implementations of m4(1) don't have -E flag
   support.
4. Mac OS X (tested on 10.12.5) has GNU m4 1.4.6 as the version
   that comes with the base system, meaning that anyone who
   uses that version will get the old pre-1.4.9 behavior.

This diff comes with man page additions explaining the new flag,
as well as a regress test for -E -E behavior. I could not figure
out how to write a regress test that checks for exit status, so
there is no test for single -E behavior.

Comments appreciated.

~Brian

Index: usr.bin/m4/eval.c
===
RCS file: /cvs/src/usr.bin/m4/eval.c,v
retrieving revision 1.74
diff -u -p -u -p -r1.74 eval.c
--- usr.bin/m4/eval.c   5 Feb 2015 12:59:57 -   1.74
+++ usr.bin/m4/eval.c   11 Jun 2017 22:52:08 -
@@ -269,6 +269,12 @@ expand_builtin(const char *argv[], int a
warn("%s at line %lu: include(%s)",
CURRENT_NAME, CURRENT_LINE, 
argv[2]);
exit_code = 1;
+   /* exit immediately if multiple -E flags
+*/
+   if (fatal_warns == 2) {
+   killdiv();
+   exit(exit_code);
+   }
} else
err(1, "%s at line %lu: include(%s)",
CURRENT_NAME, CURRENT_LINE, 
argv[2]);
Index: usr.bin/m4/extern.h
===
RCS file: /cvs/src/usr.bin/m4/extern.h,v
retrieving revision 1.54
diff -u -p -u -p -r1.54 extern.h
--- usr.bin/m4/extern.h 12 May 2014 19:11:19 -  1.54
+++ usr.bin/m4/extern.h 11 Jun 2017 22:52:08 -
@@ -58,6 +58,8 @@ extern void doesyscmd(const char *);
 extern void getdivfile(const char *);
 extern void doformat(const char *[], int);
 
+extern void check_fatal_warns(void);
+
 /* look.c */
 
 #define FLAG_UNTRACED 0
@@ -175,4 +177,5 @@ extern int  synch_lines;/* line synchro
 
 extern int mimic_gnu;  /* behaves like gnu-m4 */
 extern int prefix_builtins;/* prefix builtin macros with m4_ */
+extern int fatal_warns;/* make warnings fatal */
 
Index: usr.bin/m4/gnum4.c
===
RCS file: /cvs/src/usr.bin/m4/gnum4.c,v
retrieving revision 1.50
diff -u -p -u -p -r1.50 gnum4.c
--- usr.bin/m4/gnum4.c  29 Apr 2015 00:13:26 -  1.50
+++ usr.bin/m4/gnum4.c  11 Jun 2017 22:52:08 

Silence some warnings in tftp(1)

2017-05-29 Thread Brian Callahan
Hi tech --

Silence some warnings in tftp(1) found by WARNINGS=yes.

~Brian

Index: main.c
===
RCS file: /cvs/src/usr.bin/tftp/main.c,v
retrieving revision 1.41
diff -u -p -u -p -r1.41 main.c
--- main.c  21 Jan 2017 11:32:04 -  1.41
+++ main.c  30 May 2017 01:38:56 -
@@ -458,15 +458,15 @@ get(int argc, char *argv[])
if (src == NULL)
src = argv[n];
else {
-   char *cp;
+   char *cpy;
 
*src++ = 0;
-   cp = argv[n];
-   if (cp[0] == '[' && cp[strlen(cp) - 1] == ']') {
-   cp[strlen(cp) - 1] = '\0';
-   cp++;
+   cpy = argv[n];
+   if (cpy[0] == '[' && cpy[strlen(cpy) - 1] == ']') {
+   cpy[strlen(cpy) - 1] = '\0';
+   cpy++;
}
-   setpeer(cp, NULL);
+   setpeer(cpy, NULL);
if (!connected)
continue;
}
Index: tftp.c
===
RCS file: /cvs/src/usr.bin/tftp/tftp.c,v
retrieving revision 1.24
diff -u -p -u -p -r1.24 tftp.c
--- tftp.c  21 Oct 2014 06:15:16 -  1.24
+++ tftp.c  30 May 2017 01:38:56 -
@@ -506,7 +506,7 @@ nak(int error, struct sockaddr *peer)
 static void
 tpacket(const char *s, struct tftphdr *tp, int n)
 {
-   char*cp, *file;
+   char*cp, *ofile;
static char *opcodes[] =
{ "#0", "RRQ", "WRQ", "DATA", "ACK", "ERROR", "OACK" };
 
@@ -521,9 +521,9 @@ tpacket(const char *s, struct tftphdr *t
case RRQ:
case WRQ:
n -= 2;
-   file = cp = tp->th_stuff;
+   ofile = cp = tp->th_stuff;
cp = strchr(cp, '\0');
-   

Silence some warnings in top(1)

2017-05-29 Thread Brian Callahan
Hi tech --

Silence some warnings in top(1) found by WARNINGS=yes.

~Brian

Index: machine.c
===
RCS file: /cvs/src/usr.bin/top/machine.c,v
retrieving revision 1.88
diff -u -p -u -p -r1.88 machine.c
--- machine.c   15 Mar 2017 04:24:14 -  1.88
+++ machine.c   30 May 2017 01:29:45 -
@@ -159,14 +159,14 @@ int
 getncpu(void)
 {
int mib[] = { CTL_HW, HW_NCPU };
-   int ncpu;
-   size_t size = sizeof(ncpu);
+   int numcpu;
+   size_t size = sizeof(numcpu);
 
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
-   , , NULL, 0) == -1)
+   , , NULL, 0) == -1)
return (-1);
 
-   return (ncpu);
+   return (numcpu);
 }
 
 int
@@ -545,7 +545,7 @@ format_comm(struct kinfo_proc *kp)
 }
 
 char *
-format_next_process(caddr_t handle, char *(*get_userid)(uid_t), pid_t *pid,
+format_next_process(caddr_t hndl, char *(*get_userid)(uid_t), pid_t *pid,
 int show_threads)
 {
char *p_wait;
@@ -556,7 +556,7 @@ format_next_process(caddr_t handle, char
char buf[16];
 
/* find and remember the next proc structure */
-   hp = (struct handle *) handle;
+   hp = (struct handle *) hndl;
pp = *(hp->next_proc++);
hp->remaining--;
 



Silence some warnings in calendar(1)

2017-05-29 Thread Brian Callahan
Hi tech --

Fix some warnings found with WARNINGS=yes. I believe setting
ev1 = NULL in io.c is a false positive by cc but I fixed it anyway.

~Brian

Index: day.c
===
RCS file: /cvs/src/usr.bin/calendar/day.c,v
retrieving revision 1.34
diff -u -p -u -p -r1.34 day.c
--- day.c   14 Sep 2016 15:09:46 -  1.34
+++ day.c   30 May 2017 01:11:39 -
@@ -77,7 +77,9 @@ static struct fixs ndays[8];  /*
 static struct fixs fnmonths[13];  /* full national months names */
 static struct fixs nmonths[13];   /* short national month names */
 
-void
+static void fill_print_date(struct match *, struct tm *);
+
+static void
 fill_print_date(struct match *m, struct tm *tm)
 {
if (strftime(m->print_date, sizeof(m->print_date),
@@ -616,19 +618,19 @@ getday(char *s)
 int
 getdayvar(char *s)
 {
-   int offset;
+   int d_offset;
 
 
-   offset = strlen(s);
+   d_offset = strlen(s);
 
/* Sun+1 or Wednesday-2
 *^  ^   */
 
-   /* printf ("x: %s %s %d\n", s, s + offset - 2, offset); */
-   switch(*(s + offset - 2)) {
+   /* printf ("x: %s %s %d\n", s, s + d_offset - 2, d_offset); */
+   switch(*(s + d_offset - 2)) {
case '-':
case '+':
-   return(atoi(s + offset - 2));
+   return(atoi(s + d_offset - 2));
break;
}
 
@@ -637,15 +639,15 @@ getdayvar(char *s)
 */
 
/* last */
-   if  (offset > 4 && !strcasecmp(s + offset - 4, "last"))
+   if  (d_offset > 4 && !strcasecmp(s + d_offset - 4, "last"))
return(-1);
-   else if (offset > 5 && !strcasecmp(s + offset - 5, "first"))
+   else if (d_offset > 5 && !strcasecmp(s + d_offset - 5, "first"))
return(+1);
-   else if (offset > 6 && !strcasecmp(s + offset - 6, "second"))
+   else if (d_offset > 6 && !strcasecmp(s + d_offset - 6, "second"))
return(+2);
-   else if (offset > 5 && !strcasecmp(s + offset - 5, "third"))
+   else if (d_offset > 5 && !strcasecmp(s + d_offset - 5, "third"))
return(+3);
-   else if (offset > 6 && !strcasecmp(s + offset - 6, "fourth"))
+   else if (d_offset > 6 && !strcasecmp(s + d_offset - 6, "fourth"))
return(+4);
 
/* no offset detected */
@@ -667,13 +669,13 @@ void
 variable_weekday(int *day, int month, int year)
 {
int v1, v2;
-   int *cumdays;
+   int *cumuldays;
int day1;
 
if (isleap(year))
-   cumdays = daytab[1];
+   cumuldays = daytab[1];
else
-   cumdays = daytab[0];
+   cumuldays = daytab[0];
day1 = foy(year);
/* negative offset; last, -4 .. -1 */
if (*day < 0) {
@@ -681,10 +683,10 @@ variable_weekday(int *day, int month, in
*day = 10 + (*day % 10);/* day 1 ... 7 */
 
/* which weekday the end of the month is (1-7) */
-   v2 = (cumdays[month + 1] + day1) % 7 + 1;
+   v2 = (cumuldays[month + 1] + day1) % 7 + 1;
 
/* and subtract enough days */
-   *day = cumdays[month + 1] - cumdays[month] +
+   *day = cumuldays[month + 1] - cumuldays[month] +
(v1 + 1) * 7 - (v2 - *day + 7) % 7;
 #if DEBUG
fprintf(stderr, "\nMonth %d ends on weekday %d\n", month, v2);
@@ -697,7 +699,7 @@ variable_weekday(int *day, int month, in
*day = *day % 10;
 
/* which weekday the first of the month is (1-7) */
-   v2 = (cumdays[month] + 1 + day1) % 7 + 1;
+   v2 = (cumuldays[month] + 1 + day1) % 7 + 1;
 
/* and add enough days */
*day = 1 + (v1 - 1) * 7 + (*day - v2 + 7) % 7;
Index: io.c
===
RCS file: /cvs/src/usr.bin/calendar/io.c,v
retrieving revision 1.44
diff -u -p -u -p -r1.44 io.c
--- io.c31 Aug 2016 09:38:47 -  1.44
+++ io.c30 May 2017 01:11:39 -
@@ -74,6 +74,7 @@ cal(void)
 
events = NULL;
cur_evt = NULL;
+   ev1 = NULL;
if ((fp = opencal()) == NULL)
return;
for (printing = 0; fgets(buf, sizeof(buf), stdin) != NULL;) {



Silence a hexdump(1) warning

2017-05-29 Thread Brian Callahan
Hi tech --

Silence a -Wshadow warning found with WARNINGS=yes.

~Brian

Index: odsyntax.c
===
RCS file: /cvs/src/usr.bin/hexdump/odsyntax.c,v
retrieving revision 1.27
diff -u -p -u -p -r1.27 odsyntax.c
--- odsyntax.c  15 Mar 2016 04:19:13 -  1.27
+++ odsyntax.c  30 May 2017 00:57:15 -
@@ -403,12 +403,12 @@ odoffset(int argc, char ***argvp)
 }
 
 static void
-odadd(const char *fmt)
+odadd(const char *format)
 {
static int needpad;
 
if (needpad)
add("\""PADDING"\"");
-   add(fmt);
+   add(format);
needpad = 1;
 }



Fix vmstat(8) warnings

2017-05-29 Thread Brian Callahan
Hi tech --

Silence a pair of -Wshadow warnings caught by WARNINGS=yes.

~Brian

Index: dkstats.c
===
RCS file: /cvs/src/usr.bin/vmstat/dkstats.c,v
retrieving revision 1.39
diff -u -p -u -p -r1.39 dkstats.c
--- dkstats.c   4 Sep 2016 14:21:05 -   1.39
+++ dkstats.c   29 May 2017 21:20:26 -
@@ -201,9 +201,9 @@ dkreadstats(void)
(name = strsep(, ",")) != NULL; i++)
dk_name[i] = name;
for (i = 0; i < dk_ndrive; i++) {
-   char *p = strchr(dk_name[i], ':');
-   if (p)
-   *p = '\0';
+   char *ep = strchr(dk_name[i], ':');
+   if (ep)
+   *ep = '\0';
}
disknames = cur.dk_name[0]; /* To free old names. */
 
@@ -534,9 +534,9 @@ dkinit(int sel)
cur.dk_select[i] = sel;
}
for (i = 0; i < dk_ndrive; i++) {
-   char *p = strchr(cur.dk_name[i], ':');
-   if (p)
-   *p = '\0';
+   char *ep = strchr(cur.dk_name[i], ':');
+   if (ep)
+   *ep = '\0';
}
} else {
 #if !defined(NOKVM)



Re: Fix some ps(1) warnings

2017-05-29 Thread Brian Callahan
Hi Ingo --

On 5/29/2017 5:30 PM, Ingo Schwarze wrote:
> Hi Brian,
>
> Brian Callahan wrote on Mon, May 29, 2017 at 04:44:01PM -0400:
>
>> This diff fixes some warnings for ps(1) found with WARNINGS=yes.
>> mbwsprint() was missing a prototype in utf8.c, so add it to
>> extern.h with every other function. This lets us remove the
>> prototype from print.c
> I intentionally designed that as it is.
>
> The function mbswprint() is not intended to be called from just
> anywhere, but only from print.c.  So it should *not* be in extern.h.
>
> The file utf8.c is not intended to call just anything, but only
> to provide mbswprint().  So it should *not* include ps.h.
>
> Sure, the file utf8.c could simply be part of print.c and the function
> could be static.  But UTF-8 is such an odd beast that i deemed it
> better for it to have its own file to rear its ugly head in.
>
> Another header "utf8.h" for just one prototype seemed excessive.
>
> If people think the warning ought to be fixed, i'll simply add
> a copy of the prototype to utf8.c, like this:
>
>   int mbswprint(const char *, int, int);  /* for use by print.c */
>
> Yours,
>   Ingo

Thanks for the explanation!

~Brian

>
>> Index: extern.h
>> ===
>> RCS file: /cvs/src/bin/ps/extern.h,v
>> retrieving revision 1.20
>> diff -u -p -u -p -r1.20 extern.h
>> --- extern.h 8 Sep 2016 15:11:29 -   1.20
>> +++ extern.h 29 May 2017 19:44:43 -
>> @@ -56,6 +56,7 @@ voidlogname(const struct kinfo_proc *,
>>  void longtname(const struct kinfo_proc *, VARENT *);
>>  void lstarted(const struct kinfo_proc *, VARENT *);
>>  void maxrss(const struct kinfo_proc *, VARENT *);
>> +int  mbswprint(const char *, int, int);
>>  void nlisterr(struct nlist *);
>>  void p_rssize(const struct kinfo_proc *, VARENT *);
>>  void pagein(const struct kinfo_proc *, VARENT *);
>> Index: print.c
>> ===
>> RCS file: /cvs/src/bin/ps/print.c,v
>> retrieving revision 1.69
>> diff -u -p -u -p -r1.69 print.c
>> --- print.c  8 Sep 2016 15:11:29 -   1.69
>> +++ print.c  29 May 2017 19:44:43 -
>> @@ -55,8 +55,6 @@
>>  extern kvm_t *kd;
>>  extern int needenv, needcomm, neednlist, commandonly;
>>  
>> -int mbswprint(const char *, int, int);  /* utf8.c */
>> -
>>  static char *cmdpart(char *);
>>  
>>  #define min(a,b)((a) < (b) ? (a) : (b))
>> Index: utf8.c
>> ===
>> RCS file: /cvs/src/bin/ps/utf8.c,v
>> retrieving revision 1.1
>> diff -u -p -u -p -r1.1 utf8.c
>> --- utf8.c   10 Jan 2016 14:04:16 -  1.1
>> +++ utf8.c   29 May 2017 19:44:43 -
>> @@ -23,6 +23,8 @@
>>  #include 
>>  #include 
>>  
>> +#include "ps.h"
>> +
>>  int
>>  mbswprint(const char *mbs, int maxwidth, int trail)
>>  {



Fix some w(1) warnings, remove bin/ps/fmt.c

2017-05-29 Thread Brian Callahan
Hi tech --

While building w(1) with WARNINGS=yes, clang complained that there
were missing prototypes for the functions fmt_putc and fmt_puts.
w(1) is doing a reacharound to ps(1) for these functions. And
while putting the prototypes in bin/ps/extern.h silenced the
warnings, that seemed strange.

A grep of the tree shows that the only place these two functions
are used is in usr.bin/w/w.c so I put them in there and made them
static. This lets us finally remove bin/ps/fmt.c since ps(1) was
upgraded by Ingo to be utf8.

~Brian

Index: bin/ps/fmt.c
===
RCS file: bin/ps/fmt.c
diff -N bin/ps/fmt.c
--- bin/ps/fmt.c10 Jan 2016 21:08:01 -  1.15
+++ /dev/null   1 Jan 1970 00:00:00 -
@@ -1,82 +0,0 @@
-/* $OpenBSD: fmt.c,v 1.15 2016/01/10 21:08:01 schwarze Exp $   */
-
-/*-
- * Copyright (c) 1990, 1993, 1994
- * The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *may be used to endorse or promote products derived from this software
- *without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include "ps.h"
-
-void
-fmt_puts(const char *s, int *leftp)
-{
-   static char *v = NULL;
-   static size_t maxlen = 0;
-   size_t len;
-
-   if (*leftp == 0)
-   return;
-   len = strlen(s) * 4 + 1;
-   if (len > maxlen) {
-   free(v);
-   maxlen = 0;
-   if (len < getpagesize())
-   len = getpagesize();
-   v = malloc(len);
-   if (v == NULL)
-   return;
-   maxlen = len;
-   }
-   strvis(v, s, VIS_TAB | VIS_NL | VIS_CSTYLE);
-   if (*leftp != -1) {
-   len = strlen(v);
-   if (len > *leftp) {
-   v[*leftp] = '\0';
-   *leftp = 0;
-   } else
-   *leftp -= len;
-   }
-   printf("%s", v);
-}
-
-void
-fmt_putc(int c, int *leftp)
-{
-
-   if (*leftp == 0)
-   return;
-   if (*leftp != -1)
-   *leftp -= 1;
-   putchar(c);
-}
Index: usr.bin/w/Makefile
===
RCS file: /cvs/src/usr.bin/w/Makefile,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 Makefile
--- usr.bin/w/Makefile  16 Jul 2014 20:06:27 -  1.7
+++ usr.bin/w/Makefile  29 May 2017 20:33:35 -
@@ -1,12 +1,10 @@
 #  $OpenBSD: Makefile,v 1.7 2014/07/16 20:06:27 okan Exp $
 
 PROG=  w
-SRCS=  fmt.c pr_time.c proc_compare.c w.c
+SRCS=  pr_time.c proc_compare.c w.c
 MAN=   w.1 uptime.1
 DPADD= ${LIBKVM}
 LDADD= -lkvm
 LINKS= ${BINDIR}/w ${BINDIR}/uptime
-
-.PATH: ${.CURDIR}/../../bin/ps
 
 .include 
Index: usr.bin/w/extern.h
===
RCS file: /cvs/src/usr.bin/w/extern.h,v
retrieving revision 1.9
diff -u -p -u -p -r1.9 extern.h
--- usr.bin/w/extern.h  15 Mar 2015 00:41:28 -  1.9
+++ usr.bin/w/extern.h  29 May 2017 20:33:35 -
@@ -32,8 +32,6 @@
  */
 
 struct kinfo_proc;
-void   fmt_puts(const char *, int *);
-void   fmt_putc(int, int *);
 void   pr_attime(time_t *, time_t *);
 void   pr_idle(time_t);
 intproc_compare(const struct kinfo_proc *, const struct kinfo_proc *);
Index: usr.bin/w/w.c
===
RCS file: /cvs/src/usr.bin/w/w.c,v
retrieving revision 1.61
diff -u -p -u -p -r1.61 w.c
--- usr.bin/w/w.c   19 Mar 2016 00:11:49 

Fix some ps(1) warnings

2017-05-29 Thread Brian Callahan
Hi tech --

This diff fixes some warnings for ps(1) found with WARNINGS=yes.
mbwsprint() was missing a prototype in utf8.c, so add it to
extern.h with every other function. This lets us remove the
prototype from print.c

~Brian

Index: extern.h
===
RCS file: /cvs/src/bin/ps/extern.h,v
retrieving revision 1.20
diff -u -p -u -p -r1.20 extern.h
--- extern.h8 Sep 2016 15:11:29 -   1.20
+++ extern.h29 May 2017 19:44:43 -
@@ -56,6 +56,7 @@ void   logname(const struct kinfo_proc *,
 voidlongtname(const struct kinfo_proc *, VARENT *);
 voidlstarted(const struct kinfo_proc *, VARENT *);
 voidmaxrss(const struct kinfo_proc *, VARENT *);
+int mbswprint(const char *, int, int);
 voidnlisterr(struct nlist *);
 voidp_rssize(const struct kinfo_proc *, VARENT *);
 voidpagein(const struct kinfo_proc *, VARENT *);
Index: print.c
===
RCS file: /cvs/src/bin/ps/print.c,v
retrieving revision 1.69
diff -u -p -u -p -r1.69 print.c
--- print.c 8 Sep 2016 15:11:29 -   1.69
+++ print.c 29 May 2017 19:44:43 -
@@ -55,8 +55,6 @@
 extern kvm_t *kd;
 extern int needenv, needcomm, neednlist, commandonly;
 
-int mbswprint(const char *, int, int);  /* utf8.c */
-
 static char *cmdpart(char *);
 
 #definemin(a,b)((a) < (b) ? (a) : (b))
Index: utf8.c
===
RCS file: /cvs/src/bin/ps/utf8.c,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 utf8.c
--- utf8.c  10 Jan 2016 14:04:16 -  1.1
+++ utf8.c  29 May 2017 19:44:43 -
@@ -23,6 +23,8 @@
 #include 
 #include 
 
+#include "ps.h"
+
 int
 mbswprint(const char *mbs, int maxwidth, int trail)
 {



Fix some mg(1) warnings

2017-05-29 Thread Brian Callahan
Hi tech --

This diff cleans up some warnings found with WARNINGS=yes and
compiling with both cc and clang. I ignored the -Wsign-compare
and -Wmissing-prototypes warnings.

~Brian

Index: dir.c
===
RCS file: /cvs/src/usr.bin/mg/dir.c,v
retrieving revision 1.29
diff -u -p -u -p -r1.29 dir.c
--- dir.c   12 Sep 2016 18:32:54 -  1.29
+++ dir.c   29 May 2017 19:08:39 -
@@ -117,7 +117,7 @@ do_makedir(char *path)
 {
struct stat  sb;
int  finished, ishere;
-   mode_t   dir_mode, mode, oumask;
+   mode_t   dir_mode, f_mode, oumask;
char*slash;
 
if ((path = adjustname(path, TRUE)) == NULL)
@@ -131,8 +131,8 @@ do_makedir(char *path)
slash = path;
 
oumask = umask(0);
-   mode = 0777 & ~oumask;
-   dir_mode = mode | S_IWUSR | S_IXUSR;
+   f_mode = 0777 & ~oumask;
+   dir_mode = f_mode | S_IWUSR | S_IXUSR;
 
for (;;) {
slash += strspn(slash, "/");
@@ -152,8 +152,8 @@ do_makedir(char *path)
continue;
}
 
-   if (mkdir(path, finished ? mode : dir_mode) == 0) {
-   if (mode > 0777 && chmod(path, mode) < 0) {
+   if (mkdir(path, finished ? f_mode : dir_mode) == 0) {
+   if (f_mode > 0777 && chmod(path, f_mode) < 0) {
umask(oumask);
return (ABORT);
}
Index: fileio.c
===
RCS file: /cvs/src/usr.bin/mg/fileio.c,v
retrieving revision 1.103
diff -u -p -u -p -r1.103 fileio.c
--- fileio.c28 Jul 2016 21:40:25 -  1.103
+++ fileio.c29 May 2017 19:08:39 -
@@ -215,6 +215,7 @@ int
 fbackupfile(const char *fn)
 {
struct stat  sb;
+   struct timespec  new_times[2];
int  from, to, serrno;
ssize_t  nread;
char buf[BUFSIZ];
@@ -268,7 +269,6 @@ fbackupfile(const char *fn)
(void) fchmod(to, (sb.st_mode & 0777));
 
/* copy the mtime to the backupfile */
-   struct timespec new_times[2];
new_times[0] = sb.st_atim;
new_times[1] = sb.st_mtim;
futimens(to, new_times);
Index: modes.c
===
RCS file: /cvs/src/usr.bin/mg/modes.c,v
retrieving revision 1.20
diff -u -p -u -p -r1.20 modes.c
--- modes.c 19 Mar 2015 21:22:15 -  1.20
+++ modes.c 29 May 2017 19:08:39 -
@@ -23,14 +23,14 @@ struct maps_s   *defb_modes[PBMODES] = { &
 int defb_flag = 0;
 
 int
-changemode(int f, int n, char *mode)
+changemode(int f, int n, char *newmode)
 {
int  i;
struct maps_s   *m;
 
-   if ((m = name_mode(mode)) == NULL) {
+   if ((m = name_mode(newmode)) == NULL) {
dobeep();
-   ewprintf("Can't find mode %s", mode);
+   ewprintf("Can't find mode %s", newmode);
return (FALSE);
}
if (!(f & FFARG)) {
Index: re_search.c
===
RCS file: /cvs/src/usr.bin/mg/re_search.c,v
retrieving revision 1.31
diff -u -p -u -p -r1.31 re_search.c
--- re_search.c 19 Mar 2015 21:22:15 -  1.31
+++ re_search.c 29 May 2017 19:08:40 -
@@ -420,17 +420,17 @@ re_backsrch(void)
  * some do-it-yourself control expansion.
  */
 static int
-re_readpattern(char *prompt)
+re_readpattern(char *re_prompt)
 {
static int  dofree = 0;
int flags, error, s;
chartpat[NPAT], *rep;
 
if (re_pat[0] == '\0')
-   rep = eread("%s: ", tpat, NPAT, EFNEW | EFCR, prompt);
+   rep = eread("%s: ", tpat, NPAT, EFNEW | EFCR, re_prompt);
else
rep = eread("%s: (default %s) ", tpat, NPAT,
-   EFNUL | EFNEW | EFCR, prompt, re_pat);
+   EFNUL | EFNEW | EFCR, re_prompt, re_pat);
if (rep == NULL)
return (ABORT);
if (rep[0] != '\0') {
Index: search.c
===
RCS file: /cvs/src/usr.bin/mg/search.c,v
retrieving revision 1.44
diff -u -p -u -p -r1.44 search.c
--- search.c19 Mar 2015 21:22:15 -  1.44
+++ search.c29 May 2017 19:08:40 -
@@ -542,16 +542,16 @@ is_prompt(int dir, int flag, int success
 }
 
 /*
- * Prompt writing routine for the incremental search.  The "prompt" is just
+ * Prompt writing routine for the incremental search.  The "i_prompt" is just
  * a string. The "flag" determines whether pat should be printed.
  */
 static void
-is_dspl(char *prompt, int flag)
+is_dspl(char *i_prompt, int flag)
 {
if (flag != FALSE)
-   ewprintf("%s: ", prompt);
+   ewprintf("%s: ", i_prompt);

Remove unused function from compress(1)

2017-05-23 Thread Brian Callahan
Hi tech --

clang says zclose is an unused function. Seems to check out.

~Brian

Index: zopen.c
===
RCS file: /cvs/src/usr.bin/compress/zopen.c,v
retrieving revision 1.21
diff -u -p -u -p -r1.21 zopen.c
--- zopen.c 3 Sep 2016 11:41:10 -   1.21
+++ zopen.c 23 May 2017 03:31:05 -
@@ -343,12 +343,6 @@ z_close(void *cookie, struct z_info *inf
return (rval);
 }
 
-static int
-zclose(void *cookie)
-{
-   return z_close(cookie, NULL, NULL, NULL);
-}
-
 /*-
  * Output the given code.
  * Inputs:



Fix warnings and unifdef talk(1)

2017-05-23 Thread Brian Callahan
Hi tech --

Turned on WARNINGS=yes for talk(1). Found a few things. The nready
assignment is a false positive from gcc but I fixed it anyway.

Then I ran unifdef on talk(1). It unconditionally pulls in curses.h
from talk.h so there's no need to have those #ifdefs. Similar deal
with MSG_EOR, those files already pull in sys/socket.h so it's
always defined.

~Brian

Index: ctl_transact.c
===
RCS file: /cvs/src/usr.bin/talk/ctl_transact.c,v
retrieving revision 1.13
diff -u -p -u -p -r1.13 ctl_transact.c
--- ctl_transact.c  1 Feb 2016 07:29:25 -   1.13
+++ ctl_transact.c  23 May 2017 15:23:42 -
@@ -47,12 +47,12 @@
  * of time
  */
 void
-ctl_transact(struct in_addr target, CTL_MSG msg, int type, CTL_RESPONSE *rp)
+ctl_transact(struct in_addr target, CTL_MSG mesg, int type, CTL_RESPONSE *rp)
 {
struct pollfd pfd[1];
-   int nready, cc;
+   int nready = 0, cc;
 
-   msg.type = type;
+   mesg.type = type;
daemon_addr.sin_addr = target;
daemon_addr.sin_port = daemon_port;
pfd[0].fd = ctl_sockt;
@@ -65,10 +65,10 @@ ctl_transact(struct in_addr target, CTL_
do {
/* resend message until a response is obtained */
do {
-   cc = sendto(ctl_sockt, (char *), sizeof (msg), 0,
+   cc = sendto(ctl_sockt, (char *), sizeof(mesg), 0,
(struct sockaddr *)_addr,
-   sizeof (daemon_addr));
-   if (cc != sizeof (msg)) {
+   sizeof(daemon_addr));
+   if (cc != sizeof(mesg)) {
if (errno == EINTR)
continue;
quit("Error on write to talk daemon", 1);
@@ -86,7 +86,7 @@ ctl_transact(struct in_addr target, CTL_
 * request/acknowledgements being sent)
 */
do {
-   cc = recv(ctl_sockt, (char *)rp, sizeof (*rp), 0);
+   cc = recv(ctl_sockt, (char *)rp, sizeof(*rp), 0);
if (cc < 0) {
if (errno == EINTR)
continue;
Index: display.c
===
RCS file: /cvs/src/usr.bin/talk/display.c,v
retrieving revision 1.18
diff -u -p -u -p -r1.18 display.c
--- display.c   1 Feb 2016 07:29:25 -   1.18
+++ display.c   23 May 2017 15:23:42 -
@@ -95,7 +95,7 @@ display(xwin_t *win, char *text, int siz
 * the line.
 */
if (*text == win->werase) {
-   int endcol, xcol, i, c;
+   int endcol, xcol, j, c;
 
endcol = win->x_col;
xcol = endcol - 1;
@@ -112,7 +112,7 @@ display(xwin_t *win, char *text, int siz
xcol--;
}
wmove(win->x_win, win->x_line, xcol + 1);
-   for (i = xcol + 1; i < endcol; i++)
+   for (j = xcol + 1; j < endcol; j++)
waddch(win->x_win, ' ');
wmove(win->x_win, win->x_line, xcol + 1);
getyx(win->x_win, win->x_line, win->x_col);
Index: init_disp.c
===
RCS file: /cvs/src/usr.bin/talk/init_disp.c,v
retrieving revision 1.22
diff -u -p -u -p -r1.22 init_disp.c
--- init_disp.c 1 Feb 2016 07:29:25 -   1.22
+++ init_disp.c 23 May 2017 15:23:42 -
@@ -81,11 +81,7 @@ init_display(void)
wclear(his_win.x_win);
 
line_win = newwin(1, COLS, my_win.x_nlines, 0);
-#if defined(NCURSES_VERSION) || defined(whline)
whline(line_win, '-', COLS);
-#else
-   box(line_win, '-', '-');
-#endif
wrefresh(line_win);
/* let them know we are working on it */
current_state = "No connection yet";
@@ -192,12 +188,7 @@ resize_display(void)
 
wresize(line_win, 1, COLS);
mvwin(line_win, my_win.x_nlines, 0);
-#if defined(NCURSES_VERSION) || defined(whline)
whline(line_win, '-', COLS);
-#else
-   wmove(line_win, my_win.x_nlines, 0);
-   box(line_win, '-', '-');
-#endif
 
/* Now redraw the screen. */
wrefresh(his_win.x_win);
Index: invite.c
===
RCS file: /cvs/src/usr.bin/talk/invite.c,v
retrieving revision 1.17
diff -u -p -u -p -r1.17 invite.c
--- invite.c16 Mar 2016 15:41:11 -  1.17
+++ invite.c23 May 2017 15:23:42 -
@@ -75,13 +75,9 @@ invite_remote(void)
itimer.it_interval = itimer.it_value;
if (listen(sockt, 5) != 0)
quit("Error on attempt to listen for caller", 1);
-#ifdef MSG_EOR
/* copy new 

Fix yacc(1) warnings

2017-05-22 Thread Brian Callahan
Hi tech --

I attemped to build a DEBUG version of yacc. gcc gave warnings and
clang errored out, so I turned on WARNINGS=yes and fixed all the
warnings.

OpenBSD seems to be upstream for this version of byacc, as the
other BSDs follow Thomas Dickey's byacc.

~Brian

Index: closure.c
===
RCS file: /cvs/src/usr.bin/yacc/closure.c,v
retrieving revision 1.14
diff -u -p -u -p -r1.14 closure.c
--- closure.c   2 Dec 2014 15:56:22 -   1.14
+++ closure.c   15 May 2017 16:56:56 -
@@ -43,7 +43,76 @@ static unsigned *first_derives;
 static unsigned *EFF;
 
 
-void
+#ifdef DEBUG
+
+static void
+print_closure(int n)
+{
+   short *isp;
+
+   printf("\n\nn = %d\n\n", n);
+   for (isp = itemset; isp < itemsetend; isp++)
+   printf("   %d\n", *isp);
+}
+
+static void
+print_EFF(void)
+{
+   int i, j;
+   unsigned int *rowp;
+   unsigned int k, word;
+
+   printf("\n\nEpsilon Free Firsts\n");
+
+   for (i = start_symbol; i < nsyms; i++) {
+   printf("\n%s", symbol_name[i]);
+   rowp = EFF + ((i - start_symbol) * WORDSIZE(nvars));
+   word = *rowp++;
+
+   k = BITS_PER_WORD;
+   for (j = 0; j < nvars; k++, j++) {
+   if (k >= BITS_PER_WORD) {
+   word = *rowp++;
+   k = 0;
+   }
+
+   if (word & (1 << k))
+   printf("  %s", symbol_name[start_symbol + j]);
+   }
+   }
+}
+
+static void
+print_first_derives(void)
+{
+   int i, j;
+   unsigned int *rp;
+   unsigned int k, cword = 0;
+
+   printf("\n\n\nFirst Derives\n");
+
+   for (i = start_symbol; i < nsyms; i++) {
+   printf("\n%s derives\n", symbol_name[i]);
+   rp = first_derives + i * WORDSIZE(nrules);
+   k = BITS_PER_WORD;
+   for (j = 0; j <= nrules; k++, j++) {
+   if (k >= BITS_PER_WORD) {
+   cword = *rp++;
+   k = 0;
+   }
+
+   if (cword & (1 << k))
+   printf("   %d\n", j);
+   }
+   }
+
+   fflush(stdout);
+}
+
+#endif
+
+
+static void
 set_EFF(void)
 {
unsigned int *row;
@@ -177,72 +246,3 @@ finalize_closure(void)
free(ruleset);
free(first_derives + ntokens * WORDSIZE(nrules));
 }
-
-
-#ifdef DEBUG
-
-void
-print_closure(int n)
-{
-   short *isp;
-
-   printf("\n\nn = %d\n\n", n);
-   for (isp = itemset; isp < itemsetend; isp++)
-   printf("   %d\n", *isp);
-}
-
-void
-print_EFF(void)
-{
-   int i, j;
-   unsigned int *rowp;
-   unsigned int k, word;
-
-   printf("\n\nEpsilon Free Firsts\n");
-
-   for (i = start_symbol; i < nsyms; i++) {
-   printf("\n%s", symbol_name[i]);
-   rowp = EFF + ((i - start_symbol) * WORDSIZE(nvars));
-   word = *rowp++;
-
-   k = BITS_PER_WORD;
-   for (j = 0; j < nvars; k++, j++) {
-   if (k >= BITS_PER_WORD) {
-   word = *rowp++;
-   k = 0;
-   }
-
-   if (word & (1 << k))
-   printf("  %s", symbol_name[start_symbol + j]);
-   }
-   }
-}
-
-void
-print_first_derives(void)
-{
-   int i, j;
-   unsigned int *rp;
-   unsigned int k, cword = 0;
-
-   printf("\n\n\nFirst Derives\n");
-
-   for (i = start_symbol; i < nsyms; i++) {
-   printf("\n%s derives\n", symbol_name[i]);
-   rp = first_derives + i * WORDSIZE(nrules);
-   k = BITS_PER_WORD;
-   for (j = 0; j <= nrules; k++, j++) {
-   if (k >= BITS_PER_WORD) {
-   cword = *rp++;
-   k = 0;
-   }
-
-   if (cword & (1 << k))
-   printf("   %d\n", j);
-   }
-   }
-
-   fflush(stdout);
-}
-
-#endif
Index: lalr.c
===
RCS file: /cvs/src/usr.bin/yacc/lalr.c,v
retrieving revision 1.18
diff -u -p -u -p -r1.18 lalr.c
--- lalr.c  11 Dec 2015 20:25:47 -  1.18
+++ lalr.c  15 May 2017 16:56:56 -
@@ -52,7 +52,7 @@ short *goto_map;
 short *from_state;
 short *to_state;
 
-short **transpose();
+short **transpose(short **, int);
 void set_state_table(void);
 void set_accessing_symbol(void);
 void set_shift_table(void);
@@ -448,7 +448,7 @@ add_lookback_edge(int stateno, int rulen
 
 
 short **
-transpose(short **R, int n)
+transpose(short **old_R, int n)
 {
short **new_R, **temp_R, *nedges, *sp;
int i, k;
@@ -456,7 +456,7 @@ 

Re: sed -i

2015-07-17 Thread Brian Callahan


On 07/17/15 12:10, Jasper Lievisse Adriaanse wrote:
 Hi,
 
 Here's a diff to add the '-i' flag to sed to do inplace edits. It's mostly
 from FreeBSD with some adjustments to prevent a race with unlink() and fopen()
 during the tempfile creation.
 
 It's been tested in a full ports bulk (thanks aja), and went through a build
 of base and xenocara.
 Regress tests will also be added for this.
 
 This diff is already OK millert@. Any more OKs?
 

Cool. This saves me having to install coreutils just to work on some
school projects.

ok bcallah@, fwiw.

 Index: defs.h
 ===
 RCS file: /cvs/src/usr.bin/sed/defs.h,v
 retrieving revision 1.5
 diff -u -p -r1.5 defs.h
 --- defs.h19 Jan 2015 15:30:52 -  1.5
 +++ defs.h16 Jul 2015 18:45:58 -
 @@ -128,6 +128,7 @@ typedef struct {
   char *space;/* Current space pointer. */
   size_t len; /* Current length. */
   int deleted;/* If deleted. */
 + int append_newline; /* If originally terminated by \n. */
   char *back; /* Backing memory. */
   size_t blen;/* Backing memory length. */
  } SPACE;
 Index: extern.h
 ===
 RCS file: /cvs/src/usr.bin/sed/extern.h,v
 retrieving revision 1.9
 diff -u -p -r1.9 extern.h
 --- extern.h  13 Apr 2015 05:11:23 -  1.9
 +++ extern.h  16 Jul 2015 00:23:57 -
 @@ -40,17 +40,19 @@ extern regmatch_t *match;
  extern size_t maxnsub;
  extern u_long linenum;
  extern size_t appendnum;
 -extern int lastline;
  extern int Eflag, aflag, eflag, nflag;
 -extern char *fname;
 +extern const char *fname, *outfname;
 +extern FILE *infile, *outfile;
  
  void  cfclose(struct s_command *, struct s_command *);
  void  compile(void);
 -void  cspace(SPACE *, char *, size_t, enum e_spflag);
 +void  cspace(SPACE *, const char *, size_t, enum e_spflag);
  char *cu_fgets(char **, size_t *);
  void  err(int, const char *, ...);
  int   mf_fgets(SPACE *, enum e_spflag);
 +int   lastline(void);
  void  process(void);
 +void  resetranges(void);
  char *strregerror(int, regex_t *);
  void *xmalloc(size_t);
  void *xreallocarray(void *, size_t, size_t);
 Index: main.c
 ===
 RCS file: /cvs/src/usr.bin/sed/main.c,v
 retrieving revision 1.18
 diff -u -p -r1.18 main.c
 --- main.c26 Nov 2014 18:34:51 -  1.18
 +++ main.c16 Jul 2015 19:21:16 -
 @@ -34,6 +34,7 @@
   */
  
  #include sys/types.h
 +#include sys/stat.h
  
  #include ctype.h
  #include errno.h
 @@ -45,6 +46,7 @@
  #include stdlib.h
  #include string.h
  #include unistd.h
 +#include libgen.h
  
  #include defs.h
  #include extern.h
 @@ -78,15 +80,23 @@ struct s_flist {
   */
  static struct s_flist *files, **fl_nextp = files;
  
 +FILE *infile;/* Current input file */
 +FILE *outfile;   /* Current output file */
 +
  int Eflag, aflag, eflag, nflag;
 +static int rval; /* Exit status */
  
  /*
   * Current file and line number; line numbers restart across compilation
 - * units, but span across input files.
 + * units, but span across input files.  The latter is optional if editing
 + * in place.
   */
 -char *fname; /* File name. */
 +const char *fname;   /* File name. */
 +const char *outfname;/* Output file name */
 +static char oldfname[PATH_MAX];  /* Old file name (for in-place editing) 
 */
 +static char tmpfname[PATH_MAX];  /* Temporary file name (for in-place 
 editing) */
 +char *inplace;   /* Inplace edit file extension */
  u_long linenum;
 -int lastline;/* TRUE on the last line of the last 
 file */
  
  static void add_compunit(enum e_cut, char *);
  static void add_file(char *);
 @@ -97,7 +107,8 @@ main(int argc, char *argv[])
   int c, fflag;
  
   fflag = 0;
 - while ((c = getopt(argc, argv, Eae:f:nru)) != -1)
 + inplace = NULL;
 + while ((c = getopt(argc, argv, Eae:f:i::nru)) != -1)
   switch (c) {
   case 'E':
   case 'r':
 @@ -114,6 +125,9 @@ main(int argc, char *argv[])
   fflag = 1;
   add_compunit(CU_FILE, optarg);
   break;
 + case 'i':
 + inplace = optarg ? optarg : ;
 + break;
   case 'n':
   nflag = 1;
   break;
 @@ -123,8 +137,8 @@ main(int argc, char *argv[])
   default:
   case '?':
   (void)fprintf(stderr,
 - usage: sed [-aEnru] command [file ...]\n
 -sed [-aEnru] [-e command] [-f command_file] 
 [file ...]\n);
 + usage: sed [-aEnru] [-i [extension]] command [file 
 ...]\n
 +

Re: sed -i

2015-07-17 Thread Brian Callahan


On 07/17/15 13:51, Antoine Jacoutot wrote:
 On Fri, Jul 17, 2015 at 12:57:12PM -0400, Brian Callahan wrote:


 On 07/17/15 12:10, Jasper Lievisse Adriaanse wrote:
 Hi,

 Here's a diff to add the '-i' flag to sed to do inplace edits. It's mostly
 from FreeBSD with some adjustments to prevent a race with unlink() and 
 fopen()
 during the tempfile creation.

 It's been tested in a full ports bulk (thanks aja), and went through a build
 of base and xenocara.
 Regress tests will also be added for this.

 This diff is already OK millert@. Any more OKs?


 Cool. This saves me having to install coreutils just to work on some
 school projects.
 
 You mean gsed right?
 

Oh, heh. Yes. I mean gsed.
Either way, it's one less package I have to remember. (and clearly I'm
not so good at remembering them in the first place!)

 
 ok bcallah@, fwiw.

 Index: defs.h
 ===
 RCS file: /cvs/src/usr.bin/sed/defs.h,v
 retrieving revision 1.5
 diff -u -p -r1.5 defs.h
 --- defs.h  19 Jan 2015 15:30:52 -  1.5
 +++ defs.h  16 Jul 2015 18:45:58 -
 @@ -128,6 +128,7 @@ typedef struct {
 char *space;/* Current space pointer. */
 size_t len; /* Current length. */
 int deleted;/* If deleted. */
 +   int append_newline; /* If originally terminated by \n. */
 char *back; /* Backing memory. */
 size_t blen;/* Backing memory length. */
  } SPACE;
 Index: extern.h
 ===
 RCS file: /cvs/src/usr.bin/sed/extern.h,v
 retrieving revision 1.9
 diff -u -p -r1.9 extern.h
 --- extern.h13 Apr 2015 05:11:23 -  1.9
 +++ extern.h16 Jul 2015 00:23:57 -
 @@ -40,17 +40,19 @@ extern regmatch_t *match;
  extern size_t maxnsub;
  extern u_long linenum;
  extern size_t appendnum;
 -extern int lastline;
  extern int Eflag, aflag, eflag, nflag;
 -extern char *fname;
 +extern const char *fname, *outfname;
 +extern FILE *infile, *outfile;
  
  voidcfclose(struct s_command *, struct s_command *);
  voidcompile(void);
 -voidcspace(SPACE *, char *, size_t, enum e_spflag);
 +voidcspace(SPACE *, const char *, size_t, enum e_spflag);
  char   *cu_fgets(char **, size_t *);
  voiderr(int, const char *, ...);
  int mf_fgets(SPACE *, enum e_spflag);
 +int lastline(void);
  voidprocess(void);
 +voidresetranges(void);
  char   *strregerror(int, regex_t *);
  void   *xmalloc(size_t);
  void   *xreallocarray(void *, size_t, size_t);
 Index: main.c
 ===
 RCS file: /cvs/src/usr.bin/sed/main.c,v
 retrieving revision 1.18
 diff -u -p -r1.18 main.c
 --- main.c  26 Nov 2014 18:34:51 -  1.18
 +++ main.c  16 Jul 2015 19:21:16 -
 @@ -34,6 +34,7 @@
   */
  
  #include sys/types.h
 +#include sys/stat.h
  
  #include ctype.h
  #include errno.h
 @@ -45,6 +46,7 @@
  #include stdlib.h
  #include string.h
  #include unistd.h
 +#include libgen.h
  
  #include defs.h
  #include extern.h
 @@ -78,15 +80,23 @@ struct s_flist {
   */
  static struct s_flist *files, **fl_nextp = files;
  
 +FILE *infile;  /* Current input file */
 +FILE *outfile; /* Current output file */
 +
  int Eflag, aflag, eflag, nflag;
 +static int rval;   /* Exit status */
  
  /*
   * Current file and line number; line numbers restart across compilation
 - * units, but span across input files.
 + * units, but span across input files.  The latter is optional if editing
 + * in place.
   */
 -char *fname;   /* File name. */
 +const char *fname; /* File name. */
 +const char *outfname;  /* Output file name */
 +static char oldfname[PATH_MAX];/* Old file name (for in-place editing) 
 */
 +static char tmpfname[PATH_MAX];/* Temporary file name (for in-place 
 editing) */
 +char *inplace; /* Inplace edit file extension */
  u_long linenum;
 -int lastline;  /* TRUE on the last line of the last 
 file */
  
  static void add_compunit(enum e_cut, char *);
  static void add_file(char *);
 @@ -97,7 +107,8 @@ main(int argc, char *argv[])
 int c, fflag;
  
 fflag = 0;
 -   while ((c = getopt(argc, argv, Eae:f:nru)) != -1)
 +   inplace = NULL;
 +   while ((c = getopt(argc, argv, Eae:f:i::nru)) != -1)
 switch (c) {
 case 'E':
 case 'r':
 @@ -114,6 +125,9 @@ main(int argc, char *argv[])
 fflag = 1;
 add_compunit(CU_FILE, optarg);
 break;
 +   case 'i':
 +   inplace = optarg ? optarg : ;
 +   break;
 case 'n':
 nflag = 1;
 break;
 @@ -123,8 +137,8 @@ main(int argc, char *argv[])
 default:
 case

mg: remove redundant include

2015-06-21 Thread Brian Callahan
Hi --

Kill a redundant include as chrdef.h is included in def.h

OK?

~Brian

Index: extend.c
===
RCS file: /cvs/src/usr.bin/mg/extend.c,v
retrieving revision 1.62
diff -u -p -r1.62 extend.c
--- extend.c12 Apr 2015 21:42:18 -  1.62
+++ extend.c22 Jun 2015 01:33:34 -
@@ -15,7 +15,6 @@
 #include stdlib.h
 #include string.h
 
-#include chrdef.h
 #include def.h
 #include funmap.h
 #include kbd.h



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

2015-06-21 Thread Brian Callahan


On 06/21/15 21:21, Anthony J. Bentley wrote:
 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.
 

Even better, thanks! :-)



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

2015-06-21 Thread Brian Callahan
This is quite obviously the wrong place to put any headers.

On 06/21/15 19:41, Kamil Rytarowski wrote:
 Caught on NetBSD.
 
 Index: def.h 
 ===

 
RCS file: /cvs/src/usr.bin/mg/def.h,v
 retrieving revision 1.147 diff -u -r1.147 def.h --- def.h 3 Jun
 2015 23:40:01 -   1.147 +++ def.h 21 Jun 2015 23:43:23 - @@
 -10,6 +10,8 @@ * per-terminal definitions are in special header
 files. */
 
 +#include time.h + #include chrdef.h
 
 typedef int   (*PF)(int, int);/* generally useful type */
 



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

2015-06-21 Thread Brian Callahan


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.

~Brian



Mg: remove unused defines and functions

2015-06-02 Thread Brian Callahan
Hi tech@ --

The diff below removes unused defines and functions in mg.
I went through everything in def.h one by one, so hopefully this
removes everything unused.

OK?

~Brian

Index: def.h
===
RCS file: /cvs/src/usr.bin/mg/def.h,v
retrieving revision 1.146
diff -u -p -r1.146 def.h
--- def.h   8 May 2015 12:35:08 -   1.146
+++ def.h   3 Jun 2015 02:57:05 -
@@ -21,13 +21,13 @@ typedef int (*PF)(int, int);/* generall
 #define NBUFN  NFILEN  /* Length, buffer name.  */
 #define NLINE  256 /* Length, line. */
 #define PBMODES 4  /* modes per buffer  */
-#define NKBDM  256 /* Length, keyboard macro.   */
 #define NPAT   80  /* Length, pattern.  */
 #define HUGE   1000/* A rather large number.*/
 #define NSRCH  128 /* Undoable search commands. */
 #define NXNAME 64  /* Length, extended command. */
 #define NKNAME 20  /* Length, key names.*/
 #define NTIME  50  /* Length, timestamp string. */
+
 /*
  * Universal.
  */
@@ -61,13 +61,6 @@ typedef int  (*PF)(int, int);/* generall
 #define FIODIR 5   /* File is a directory   */
 
 /*
- * Directory I/O.
- */
-#define DIOSUC 0   /* Success.  */
-#define DIOEOF 1   /* End of file.  */
-#define DIOERR 2   /* Error.*/
-
-/*
  * Display colors.
  */
 #define CNONE  0   /* Unknown color.*/
@@ -388,7 +381,6 @@ struct line *lalloc(int);
 int lrealloc(struct line *, int);
 voidlfree(struct line *);
 voidlchange(int);
-int linsert_str(const char *, int);
 int linsert(int, int);
 int lnewline_at(struct line *, int);
 int lnewline(void);
@@ -408,7 +400,6 @@ int  yank(int, int);
 
 /* window.c X */
 struct mgwin   *new_window(struct buffer *);
-voidfree_window(struct mgwin *);
 int reposition(int, int);
 int redraw(int, int);
 int do_redraw(int, int, int);
@@ -654,7 +645,6 @@ int  executemacro(int, int);
 /* modes.c X */
 int indentmode(int, int);
 int fillmode(int, int);
-int blinkparen(int, int);
 #ifdef NOTAB
 int notabmode(int, int);
 #endif /* NOTAB */
Index: line.c
===
RCS file: /cvs/src/usr.bin/mg/line.c,v
retrieving revision 1.55
diff -u -p -r1.55 line.c
--- line.c  19 Mar 2015 21:22:15 -  1.55
+++ line.c  3 Jun 2015 02:57:05 -
@@ -131,100 +131,6 @@ lchange(int flag)
 }
 
 /*
- * Insert n bytes from s at the current location of dot.
- * In the easy case all that happens is the text is stored in the line.
- * In the hard case, the line has to be reallocated.  When the window list
- * is updated, take special care; I screwed it up once.  You always update
- * dot in the current window.  You update mark and a dot in another window
- * if it is greater than the place where you did the insert. Return TRUE
- * if all is well, and FALSE on errors.
- */
-int
-linsert_str(const char *s, int n)
-{
-   struct line *lp1;
-   struct mgwin*wp;
-   RSIZEi;
-   int  doto, k;
-
-   if ((k = checkdirty(curbp)) != TRUE)
-   return (k);
-
-   if (curbp-b_flag  BFREADONLY) {
-   dobeep();
-   ewprintf(Buffer is read only);
-   return (FALSE);
-   }
-
-   if (!n)
-   return (TRUE);
-
-   lchange(WFFULL);
-
-   /* current line */
-   lp1 = curwp-w_dotp;
-
-   /* special case for the end */
-   if (lp1 == curbp-b_headp) {
-   struct line *lp2, *lp3;
-
-   /* now should only happen in empty buffer */
-   if (curwp-w_doto != 0)
-   panic(bug: linsert_str);
-   /* allocate a new line */
-   if ((lp2 = lalloc(n)) == NULL)
-   return (FALSE);
-   /* previous line */
-   lp3 = lp1-l_bp;
-   /* link in */
-   lp3-l_fp = lp2;
-   lp2-l_fp = lp1;
-   lp1-l_bp = lp2;
-   lp2-l_bp = lp3;
-   for (i = 0; i  n; ++i)
-   lp2-l_text[i] = s[i];
-   for (wp = wheadp; wp != NULL; wp = wp-w_wndp) {
-   if (wp-w_linep == lp1)
-   wp-w_linep = lp2;
-   if (wp-w_dotp == lp1)
-   wp-w_dotp = lp2;
-   if (wp-w_markp == lp1)
-   wp-w_markp = lp2;
-   }
-   undo_add_insert(lp2, 0, n);
-   

mg: remove some unused #defines from def.h

2015-05-15 Thread Brian Callahan
Hey tech@ --

Let's get rid of some more #defines that aren't being used.
Someone should also look at the list of prototypes and make sure
all are being used. I can do this eventually, but probably not for
a few weeks in case someone else wants to beat me to it.

OK?

~Brian

Index: def.h
===
RCS file: /cvs/src/usr.bin/mg/def.h,v
retrieving revision 1.145
diff -u -p -r1.145 def.h
--- def.h   25 Mar 2015 20:53:31 -  1.145
+++ def.h   16 May 2015 01:35:52 -
@@ -21,7 +21,6 @@ typedef int   (*PF)(int, int);/* generall
 #define NBUFN  NFILEN  /* Length, buffer name.  */
 #define NLINE  256 /* Length, line. */
 #define PBMODES 4  /* modes per buffer  */
-#define NKBDM  256 /* Length, keyboard macro.   */
 #define NPAT   80  /* Length, pattern.  */
 #define HUGE   1000/* A rather large number.*/
 #define NSRCH  128 /* Undoable search commands. */
@@ -59,13 +58,6 @@ typedef int  (*PF)(int, int);/* generall
 #define FIOERR 3   /* Error.*/
 #define FIOLONG 4  /* long line partially read  */
 #define FIODIR 5   /* File is a directory   */
-
-/*
- * Directory I/O.
- */
-#define DIOSUC 0   /* Success.  */
-#define DIOEOF 1   /* End of file.  */
-#define DIOERR 2   /* Error.*/
 
 /*
  * Display colors.



mg: remove ereply

2015-05-06 Thread Brian Callahan
Hi --

eprely isn't used anymore.
OK?

~Brian

Index: def.h
===
RCS file: /cvs/src/usr.bin/mg/def.h,v
retrieving revision 1.145
diff -u -p -r1.145 def.h
--- def.h   25 Mar 2015 20:53:31 -  1.145
+++ def.h   7 May 2015 04:02:50 -
@@ -460,7 +460,6 @@ int  eyorn(const char *);
 int eynorr(const char *);
 int eyesno(const char *);
 voidewprintf(const char *fmt, ...);
-char   *ereply(const char *, char *, size_t, ...);
 char   *eread(const char *, char *, size_t, int, ...);
 int getxtra(struct list *, struct list *, int, int);
 voidfree_file_list(struct list *);
Index: echo.c
===
RCS file: /cvs/src/usr.bin/mg/echo.c,v
retrieving revision 1.58
diff -u -p -r1.58 echo.c
--- echo.c  19 Mar 2015 21:22:15 -  1.58
+++ echo.c  7 May 2015 04:02:50 -
@@ -821,9 +821,9 @@ ewprintf(const char *fmt, ...)
 }
 
 /*
- * Printf style formatting. This is called by both ewprintf and ereply
- * to provide formatting services to their clients.  The move to the start
- * of the echo line, and the erase to the end of the echo line, is done by
+ * Printf style formatting. This is called by ewprintf to provide
+ * formatting services to its clients.  The move to the start of the
+ * echo line, and the erase to the end of the echo line, is done by
  * the caller. 
  * %c prints the name of the supplied character.
  * %k prints the name of the current key (and takes no arguments).



Document -D flag in pkg_info

2015-04-04 Thread Brian Callahan
Hi tech --

The -D flag in pkg_info is undocumented. So document it.
Please doublecheck to make sure it's correct because I'm not sure.

Also fix a whitespace error while here.

OK?

~Brian

Index: pkg_info.1
===
RCS file: /cvs/src/usr.sbin/pkg_add/pkg_info.1,v
retrieving revision 1.50
diff -u -p -r1.50 pkg_info.1
--- pkg_info.1  8 Sep 2014 01:27:55 -   1.50
+++ pkg_info.1  4 Apr 2015 14:03:38 -
@@ -25,6 +25,7 @@
 .Nm pkg_info
 .Bk -words
 .Op Fl AaCcdfIKLMmPqRSstUv
+.Op Fl D Ar nolock
 .Op Fl E Ar filename
 .Op Fl e Ar pkg-name
 .Op Fl l Ar str
@@ -75,6 +76,8 @@ Show certificate information for signed 
 Show the one-line comment field for each package.
 .It Fl d
 Show the long-description field for each package.
+.It Fl D Ar nolock
+Do not lock the package database during run.
 .It Fl E Ar filename
 Look for the package(s) that contains the given
 .Ar filename .
Index: OpenBSD/PkgInfo.pm
===
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm,v
retrieving revision 1.33
diff -u -p -r1.33 PkgInfo.pm
--- OpenBSD/PkgInfo.pm  18 Jul 2014 16:57:41 -  1.33
+++ OpenBSD/PkgInfo.pm  4 Apr 2015 14:03:38 -
@@ -527,7 +527,7 @@ sub parse_and_run
};
$state-{no_exports} = 1;
$state-handle_options('cCdfF:hIKLmPQ:qr:RsSUe:E:Ml:aAt',
-   '[-AaCcdfIKLMmPqRSstUv] [-D nolock][-E filename] [-e pkg-name] ',
+   '[-AaCcdfIKLMmPqRSstUv] [-D nolock] [-E filename] [-e pkg-name] ',
'[-l str] [-Q query] [-r pkgspec] [pkg-name] [...]');
 
if ($state-opt('r')) {



Small Port Testing Guide tweak

2015-03-31 Thread Brian Callahan
Brought to my attention in a private conversation:
Is there any reason this shouldn't be port-lib-depends-check?
bsd.port.mk(5) prefers port-lib-depends-check. Also,
lib-depends-check can't be run before package whereas
port-lib-depends-check can.

OK?

~Brian

Index: testing.html
===
RCS file: /cvs/www/faq/ports/testing.html,v
retrieving revision 1.21
diff -u -p -r1.21 testing.html
--- testing.html1 Dec 2014 09:59:33 -   1.21
+++ testing.html31 Mar 2015 21:43:32 -
@@ -199,7 +199,7 @@ $ bfor ms in $(make show=MASTER_SITES)
  and permissions.
 /ul
 
-  liilib-depends-check/i
+  liiport-lib-depends-check/i
 ul
  liThis will check whether all libraries on which the port depends
  can be reached through either ttLIB_DEPENDS/tt or 
ttWANTLIB/tt.



unifdef fun with vi

2015-03-28 Thread Brian Callahan
Hi again tech@ --

Some more unifdef fun with vi:
1. SA_INTERRUPT is a SunOS extension. I don't think we need to care
   if vi is portable there anymore. vi doesn't build if defined the
   other way.
2. There is a HISTORIC_PRACTICE and a HISTORICAL_PRACTICE define.
   We don't appear to be using either so get rid of them.
3. We have mvchgat via curses.h so don't need to check for it.
   The declarations within that #ifndef block weren't being used.

OK?

~Brian

Index: cl/cl_funcs.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_funcs.c,v
retrieving revision 1.17
diff -u -p -r1.17 cl_funcs.c
--- cl/cl_funcs.c   12 Nov 2014 16:29:04 -  1.17
+++ cl/cl_funcs.c   28 Mar 2015 18:35:43 -
@@ -261,10 +261,6 @@ cl_cursor(SCR *sp, size_t *yp, size_t *x
 int
 cl_deleteln(SCR *sp)
 {
-#ifndef mvchgat
-   CHAR_T ch;
-   size_t col, lno, spcnt;
-#endif
size_t oldy, oldx;
 
/*
Index: cl/cl_main.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_main.c,v
retrieving revision 1.25
diff -u -p -r1.25 cl_main.c
--- cl/cl_main.c19 Nov 2014 03:42:40 -  1.25
+++ cl/cl_main.c28 Mar 2015 18:35:43 -
@@ -319,21 +319,12 @@ setsig(int signo, struct sigaction *oact
 * Use sigaction(2), not signal(3), since we don't always want to
 * restart system calls.  The example is when waiting for a command
 * mode keystroke and SIGWINCH arrives.  Besides, you can't portably
-* restart system calls (thanks, POSIX!).  On the other hand, you
-* can't portably NOT restart system calls (thanks, Sun!).  SunOS
-* used SA_INTERRUPT as their extension to NOT restart read calls.
-* We sure hope nobody else used it for anything else.  Mom told me
-* there'd be days like this.  She just never told me that there'd
-* be so many.
+* restart system calls (thanks, POSIX!).
 */
act.sa_handler = handler;
sigemptyset(act.sa_mask);
 
-#ifdef SA_INTERRUPT
-   act.sa_flags = SA_INTERRUPT;
-#else
act.sa_flags = 0;
-#endif
return (sigaction(signo, act, oactp));
 }
 
Index: ex/ex_z.c
===
RCS file: /cvs/src/usr.bin/vi/ex/ex_z.c,v
retrieving revision 1.7
diff -u -p -r1.7 ex_z.c
--- ex/ex_z.c   12 Nov 2014 04:28:41 -  1.7
+++ ex/ex_z.c   28 Mar 2015 18:35:43 -
@@ -51,11 +51,7 @@ ex_z(SCR *sp, EXCMD *cmdp)
if (FL_ISSET(cmdp-iflags, E_C_COUNT))
cnt = cmdp-count;
else
-#ifdef HISTORIC_PRACTICE
-   cnt = O_VAL(sp, O_SCROLL) * 2;
-#else
cnt = O_VAL(sp, O_WINDOW) - 1;
-#endif
 
equals = 0;
eofcheck = 0;
Index: vi/v_mark.c
===
RCS file: /cvs/src/usr.bin/vi/vi/v_mark.c,v
retrieving revision 1.9
diff -u -p -r1.9 v_mark.c
--- vi/v_mark.c 12 Nov 2014 04:28:41 -  1.9
+++ vi/v_mark.c 28 Mar 2015 18:35:43 -
@@ -170,22 +170,7 @@ mark(SCR *sp, VICMD *vp, enum which cmd)
 * Delete cursor motion was always to the start of the text region,
 * regardless.  Ignore other motion commands.
 */
-#ifdef HISTORICAL_PRACTICE
-   if (ISCMD(vp-rkp, 'y')) {
-   if ((cmd == BQMARK ||
-   cmd == FQMARK  vp-m_start.lno != vp-m_stop.lno) 
-   (vp-m_start.lno  vp-m_stop.lno ||
-   vp-m_start.lno == vp-m_stop.lno 
-   vp-m_start.cno  vp-m_stop.cno))
-   vp-m_final = vp-m_stop;
-   } else if (ISCMD(vp-rkp, 'd'))
-   if (vp-m_start.lno  vp-m_stop.lno ||
-   vp-m_start.lno == vp-m_stop.lno 
-   vp-m_start.cno  vp-m_stop.cno)
-   vp-m_final = vp-m_stop;
-#else
vp-m_final = vp-m_start;
-#endif
 
/*
 * Forward marks are always line oriented, and it's set in the



Use a single, consistent isblank in vi

2015-03-27 Thread Brian Callahan
Hi tech@ --

Noticed this yesterday reviewing brynet@'s vi diff.
We have the appropriate isblank(3) in ctype.h but the header
wasn't being included in all the files that used it so vi was
falling back to a #define in common/key.h for one set of files and
using isblank(3) from ctype.h in other files.

This diff removes the #define from common/key.h and adds the header
to the .c files that need it.

OK?

~Brian

Index: common/key.h
===
RCS file: /cvs/src/usr.bin/vi/common/key.h,v
retrieving revision 1.4
diff -u -p -r1.4 key.h
--- common/key.h8 Jan 2006 21:05:39 -   1.4
+++ common/key.h28 Mar 2015 04:10:46 -
@@ -136,19 +136,6 @@ extern KEYLIST keylist[];
(KEYS_WAITING(sp) \
F_ISSET((sp)-gp-i_event[(sp)-gp-i_next].e_ch, CH_MAPPED))
 
-/*
- * Ex/vi commands are generally separated by whitespace characters.  We
- * can't use the standard isspace(3) macro because it returns true for
- * characters like ^K in the ASCII character set.  The 4.4BSD isblank(3)
- * macro does exactly what we want, but it's not portable yet.
- *
- * XXX
- * Note side effect, ch is evaluated multiple times.
- */
-#ifndef isblank
-#defineisblank(ch) ((ch) == ' ' || (ch) == '\t')
-#endif
-
 /* The standard tab width, for displaying things to users. */
 #defineSTANDARD_TAB6
 
Index: common/util.c
===
RCS file: /cvs/src/usr.bin/vi/common/util.c,v
retrieving revision 1.10
diff -u -p -r1.10 util.c
--- common/util.c   16 Jan 2015 06:40:14 -  1.10
+++ common/util.c   28 Mar 2015 04:10:46 -
@@ -14,6 +14,7 @@
 #include sys/queue.h
 
 #include bitstring.h
+#include ctype.h
 #include errno.h
 #include limits.h
 #include stdio.h
Index: ex/ex_shell.c
===
RCS file: /cvs/src/usr.bin/vi/ex/ex_shell.c,v
retrieving revision 1.14
diff -u -p -r1.14 ex_shell.c
--- ex/ex_shell.c   16 Jan 2015 06:40:14 -  1.14
+++ ex/ex_shell.c   28 Mar 2015 04:10:46 -
@@ -15,6 +15,7 @@
 #include sys/wait.h
 
 #include bitstring.h
+#include ctype.h
 #include errno.h
 #include limits.h
 #include signal.h
Index: vi/v_match.c
===
RCS file: /cvs/src/usr.bin/vi/vi/v_match.c,v
retrieving revision 1.7
diff -u -p -r1.7 v_match.c
--- vi/v_match.c12 Nov 2014 04:28:41 -  1.7
+++ vi/v_match.c28 Mar 2015 04:10:46 -
@@ -16,6 +16,7 @@
 #include sys/time.h
 
 #include bitstring.h
+#include ctype.h
 #include limits.h
 #include stdio.h
 #include string.h



Re: mg(1): refactor sysdef.h?

2015-03-15 Thread Brian Callahan

On 03/15/15 19:24, Kamil Rytarowski wrote:
 Hello, Currently sysdef.h includes C headers for little purpose, as
 the same headers are already pulled in appropriate .c files. In the
 result the headers listed in sysdef.h are pulled in twice. I propose
 to move the remaining content (literally 11 lines-of-code) to def.h or
 a better place. I think that back in time all system includes were
 pulled in from sysdef.h, today I see no need for it any more.

I'm not sure you've tried doing that. There's a warning to include those
files in order for a reason.

However, there are some files that have redundant includes. Below is a
diff to remove those.

OK?

~Brian

Index: dired.c
===
RCS file: /cvs/src/usr.bin/mg/dired.c,v
retrieving revision 1.69
diff -u -p -r1.69 dired.c
--- dired.c30 Dec 2014 22:05:32 -1.69
+++ dired.c15 Mar 2015 23:44:45 -
@@ -10,7 +10,6 @@
 #include funmap.h
 #include kbd.h
 
-#include sys/types.h
 #include sys/stat.h
 #include sys/time.h
 #include sys/resource.h
Index: extend.c
===
RCS file: /cvs/src/usr.bin/mg/extend.c,v
retrieving revision 1.58
diff -u -p -r1.58 extend.c
--- extend.c6 Dec 2014 23:20:17 -1.58
+++ extend.c15 Mar 2015 23:44:45 -
@@ -10,7 +10,6 @@
 #include kbd.h
 #include funmap.h
 
-#include sys/types.h
 #include ctype.h
 #include limits.h
 
Index: fileio.c
===
RCS file: /cvs/src/usr.bin/mg/fileio.c,v
retrieving revision 1.98
diff -u -p -r1.98 fileio.c
--- fileio.c16 Nov 2014 04:16:41 -1.98
+++ fileio.c15 Mar 2015 23:44:45 -
@@ -7,7 +7,6 @@
  */
 #include def.h
 
-#include sys/types.h
 #include sys/stat.h
 #include sys/time.h
 #include sys/resource.h
Index: grep.c
===
RCS file: /cvs/src/usr.bin/mg/grep.c,v
retrieving revision 1.42
diff -u -p -r1.42 grep.c
--- grep.c16 Nov 2014 04:16:41 -1.42
+++ grep.c15 Mar 2015 23:44:45 -
@@ -6,11 +6,9 @@
 #include kbd.h
 #include funmap.h
 
-#include sys/types.h
 #include ctype.h
 #include libgen.h
 #include limits.h
-#include time.h
 
 int globalwd = FALSE;
 static int compile_goto_error(int, int);
Index: line.c
===
RCS file: /cvs/src/usr.bin/mg/line.c,v
retrieving revision 1.54
diff -u -p -r1.54 line.c
--- line.c16 Nov 2014 04:16:41 -1.54
+++ line.c15 Mar 2015 23:44:45 -
@@ -20,8 +20,6 @@
 #include def.h
 
 #include limits.h
-#include stdlib.h
-#include string.h
 
 /*
  * Allocate a new line of size `used'.  lrealloc() can be called if the
line
Index: re_search.c
===
RCS file: /cvs/src/usr.bin/mg/re_search.c,v
retrieving revision 1.30
diff -u -p -r1.30 re_search.c
--- re_search.c20 Mar 2014 07:47:29 -1.30
+++ re_search.c15 Mar 2015 23:44:45 -
@@ -16,7 +16,6 @@
 #ifdef REGEX
 #include def.h
 
-#include sys/types.h
 #include regex.h
 
 #include macro.h
Index: region.c
===
RCS file: /cvs/src/usr.bin/mg/region.c,v
retrieving revision 1.34
diff -u -p -r1.34 region.c
--- region.c20 Mar 2014 07:47:29 -1.34
+++ region.c15 Mar 2015 23:44:45 -
@@ -9,12 +9,10 @@
  * internal use.
  */
 
-#include sys/types.h
 #include sys/socket.h
 
 #include fcntl.h
 #include poll.h
-#include string.h
 #include unistd.h
 
 #include def.h
Index: tags.c
===
RCS file: /cvs/src/usr.bin/mg/tags.c,v
retrieving revision 1.10
diff -u -p -r1.10 tags.c
--- tags.c16 Nov 2014 00:59:25 -1.10
+++ tags.c15 Mar 2015 23:44:45 -
@@ -6,16 +6,11 @@
  * Author: Sunil Nimmagadda su...@sunilnimmagadda.com
  */
 
-#include sys/queue.h
 #include sys/stat.h
 #include sys/tree.h
-#include sys/types.h
 
 #include ctype.h
 #include err.h
-#include stdlib.h
-#include string.h
-#include stdio.h
 #include util.h
 
 #include def.h
Index: tty.c
===
RCS file: /cvs/src/usr.bin/mg/tty.c,v
retrieving revision 1.32
diff -u -p -r1.32 tty.c
--- tty.c16 Nov 2014 00:50:00 -1.32
+++ tty.c15 Mar 2015 23:44:45 -
@@ -29,7 +29,6 @@
 
 #include def.h
 
-#include sys/types.h
 #include sys/time.h
 #include sys/ioctl.h
 
Index: ttyio.c
===
RCS file: /cvs/src/usr.bin/mg/ttyio.c,v
retrieving revision 1.35
diff -u -p -r1.35 ttyio.c
--- ttyio.c20 Mar 2014 07:47:29 -1.35
+++ ttyio.c15 Mar 2015 23:44:45 -
@@ -11,7 +11,6 @@
  */
 #include def.h
 
-#include sys/types.h
 #include sys/time.h
 #include sys/ioctl.h
 #include fcntl.h
Index: yank.c

Re: mg(1): refactor sysdef.h?

2015-03-15 Thread Brian Callahan

On 03/15/15 21:01, Kamil Rytarowski wrote:
 Brian Callahan wrote:
 On 03/15/15 19:24, Kamil Rytarowski wrote:
 Hello, Currently sysdef.h includes C headers for little purpose, as
 the same headers are already pulled in appropriate .c files. In the
 result the headers listed in sysdef.h are pulled in twice. I propose
 to move the remaining content (literally 11 lines-of-code) to def.h or
 a better place. I think that back in time all system includes were
 pulled in from sysdef.h, today I see no need for it any more.
 I'm not sure you've tried doing that. There's a warning to include those
 files in order for a reason.

 However, there are some files that have redundant includes. Below is a
 diff to remove those.

 OK?

 Thank you, this is another approach. OK from me!

No no. When I say OK? I'm asking another developer to look at it and
say whether or not I can commit it.

Anyhow I've talked to Theo about this and I will be bringing mg in line
with the rest of how OpenBSD handles includes.

~Brian



Re: (patch) mg(1) reallocarray cleanup

2015-02-16 Thread Brian Callahan

On 02/16/15 17:24, Kamil Rytarowski wrote:
 Me wrote:
 I'm attaching a patch.
 Ooops, wrong file. New attached.

OK for me.



Re: (patch) mg(1) reallocarray cleanup

2015-02-16 Thread Brian Callahan

On 02/16/15 17:12, Kamil Rytarowski wrote:
 Hello,

 I'm attaching a patch.

 Regards,

It's obvious that you didn't try to build mg with your own patch.

~Brian



mg: remove contp variable from cmode.c

2015-01-12 Thread Brian Callahan
Hi everyone --

In mg's cmode.c getindent() it looks like there's a contp
variable that gets initialized and we set it back and forth
between FALSE and TRUE a few times. But we never actually do
anything with it. This diff removes it.

OK?

~Brian

Index: cmode.c
===
RCS file: /cvs/src/usr.bin/mg/cmode.c,v
retrieving revision 1.11
diff -u -p -r1.11 cmode.c
--- cmode.c 2 Jan 2015 11:43:15 -   1.11
+++ cmode.c 13 Jan 2015 05:14:53 -
@@ -225,7 +225,6 @@ getindent(const struct line *lp, int *cu
int nparen = 0; /* paren count */
int obrace = 0; /* open brace count */
int cbrace = 0; /* close brace count */
-   int contp = FALSE;  /* Continue? */
int firstnwsp = FALSE;  /* First nonspace encountered? */
int colonp = FALSE; /* Did we see a colon? */
int questionp = FALSE;  /* Did we see a question mark? */
@@ -260,7 +259,6 @@ getindent(const struct line *lp, int *cu
c = lgetc(lp, co);
/* We have a non-whitespace char */
if (!firstnwsp  !isspace(c)) {
-   contp = TRUE;
if (c == '#')
cppp = TRUE;
firstnwsp = TRUE; 
@@ -283,7 +281,6 @@ getindent(const struct line *lp, int *cu
} else if (c == '{') {
obrace++;
firstnwsp = FALSE;
-   contp = FALSE;
} else if (c == '}') {
cbrace++;
} else if (c == '?') {
@@ -292,9 +289,6 @@ getindent(const struct line *lp, int *cu
/* ignore (foo ? bar : baz) construct */
if (!questionp)
colonp = TRUE;
-   } else if (c == ';') {
-   if (nparen  0)
-   contp = FALSE;
} else if (c == '/') {
/* first nonwhitespace? - indent */
if (firstnwsp) {



mg: remove some more warnings

2014-12-27 Thread Brian Callahan
Hi tech --

A very recent clang says:

/home/brian/llvm/build-build/bin/clang -O2 -pipe  -Wall -DFKEYS -DREGEX -DXKEYS 
-Werror-implicit-function-declaration  -c /usr/src/usr.bin/mg/dired.c
/usr/src/usr.bin/mg/dired.c:216:13: warning: address of array 'curbp-b_fname' 
will always evaluate to 'true' [-Wpointer-bool-conversion]
if (curbp-b_fname  curbp-b_fname[0] != '\0') {
~~~^~~ ~~
/usr/src/usr.bin/mg/dired.c:246:13: warning: address of array 'curbp-b_fname' 
will always evaluate to 'true' [-Wpointer-bool-conversion]
if (curbp-b_fname  curbp-b_fname[0] != '\0') {
~~~^~~ ~~
2 warnings generated.

Diff below to kill the warnings.

OK?

~Brian

Index: dired.c
===
RCS file: /cvs/src/usr.bin/mg/dired.c,v
retrieving revision 1.68
diff -u -p -r1.68 dired.c
--- dired.c 16 Nov 2014 04:16:41 -  1.68
+++ dired.c 27 Dec 2014 22:07:52 -
@@ -213,7 +213,7 @@ dired(int f, int n)
char dname[NFILEN], *bufp, *slash;
struct buffer   *bp;
 
-   if (curbp-b_fname  curbp-b_fname[0] != '\0') {
+   if (curbp-b_fname[0] != '\0') {
(void)strlcpy(dname, curbp-b_fname, sizeof(dname));
if ((slash = strrchr(dname, '/')) != NULL) {
*(slash + 1) = '\0';
@@ -243,7 +243,7 @@ d_otherwindow(int f, int n)
struct buffer   *bp;
struct mgwin*wp;
 
-   if (curbp-b_fname  curbp-b_fname[0] != '\0') {
+   if (curbp-b_fname[0] != '\0') {
(void)strlcpy(dname, curbp-b_fname, sizeof(dname));
if ((slash = strrchr(dname, '/')) != NULL) {
*(slash + 1) = '\0';



mg: add bounce matching for [] and {}

2014-08-13 Thread Brian Callahan

Hi tech --

Diff below adds the bounce matching for [] and {} in mg like it does for ().
I miss having that from GNU Emacs, anyone else?

OK?

~Brian

Index: keymap.c
===
RCS file: /cvs/src/usr.bin/mg/keymap.c,v
retrieving revision 1.51
diff -u -p -r1.51 keymap.c
--- keymap.c22 May 2013 19:23:45 -1.51
+++ keymap.c13 Aug 2014 22:49:08 -
@@ -388,16 +388,16 @@ static PF fund_del[] = {
 };

 static PF fund_cb[] = {
-showmatch/* )  */
+showmatch/* ) ] }  */
 };

 #ifndefFUND_XMAPS
 #define NFUND_XMAPS0/* extra map sections after normal ones */
 #endif

-static struct KEYMAPE (6 + NFUND_XMAPS + IMAPEXT) fundmap = {
-6 + NFUND_XMAPS,
-6 + NFUND_XMAPS + IMAPEXT,
+static struct KEYMAPE (8 + NFUND_XMAPS + IMAPEXT) fundmap = {
+8 + NFUND_XMAPS,
+8 + NFUND_XMAPS + IMAPEXT,
 selfinsert,
 {
 {
@@ -414,6 +414,12 @@ static struct KEYMAPE (6 + NFUND_XMAPS +
 },
 {
 ')', ')', fund_cb, NULL
+},
+{
+']', ']', fund_cb, NULL
+},
+{
+'}', '}', fund_cb, NULL
 },
 {
 CCHR('?'), CCHR('?'), fund_del, NULL



Re: lynx: disable old protocols

2014-07-10 Thread Brian Callahan


On 07/10/14 23:17, Daniel Dickman wrote:

For some urls, lynx will invoke an external command. Turn off telnet,
rlogin and tn3270 urls by defining them to false(1) as documented in the
lynx manual.

Gopher and NNTP are actually still being used (the former a bit
sparsely, but there are a few servers here and there). The rest I don't
mind seeing disappear (we don't ship the telnet and rlogin programs
anymore AFAIK, I've never heard of bibp, and we have a finger program as
an alternative to the functionality in lynx).

this support does not need to be in base.


I very much use lynx for its gopher support. I would be sad to see it go.


Finally, turn off the file editor which can be accessed with g.enter
using the --disable-dired switch.

I don't see a good reason to get rid of this. What is the rationale?


I want a text browser not a file manager.





port-modules.5 small fix

2014-07-08 Thread Brian Callahan

Hi everyone --

port-modules.5 is missing an If to make a complete sentence.
OK?

~Brian

Index: port-modules.5
===
RCS file: /cvs/src/share/man/man5/port-modules.5,v
retrieving revision 1.172
diff -u -p -r1.172 port-modules.5
--- port-modules.5  2 Apr 2014 15:00:27 -   1.172
+++ port-modules.5  9 Jul 2014 01:37:23 -
@@ -1184,6 +1184,7 @@ is appended to
 .Ev MODGNOME_RUN_DEPENDS
 and a link to /usr/bin/true is created under
 .Pa ${WRKDIR}/bin/desktop-file-validate .
+If
 .Ev MODGNOME_TOOLS
 is set to docbook,
 .Pa textproc/docbook-xsl



Kill a warning building mg with clang

2014-06-11 Thread Brian Callahan

Hi tech@ --

Clang points this out when building mg:

clang -O2 -pipe  -Wall -DFKEYS -DREGEX -DXKEYS   -c /home/brian/mg/buffer.c
/home/brian/mg/buffer.c:461:11: warning: comparison of array 
'bp-b_fname' not equal to a null pointer is always true 
[-Wtautological-pointer-compare]

if (bp-b_fname != NULL  *(bp-b_fname) != '\0' 
^~~
1 warning generated.

Diff below to kill the warning.

OK?

~Brian

Index: buffer.c
===
RCS file: /cvs/src/usr.bin/mg/buffer.c,v
retrieving revision 1.93
diff -u -p -r1.93 buffer.c
--- buffer.c20 Mar 2014 07:47:29 -  1.93
+++ buffer.c12 Jun 2014 03:33:34 -
@@ -458,7 +458,7 @@ anycb(int f)
char pbuf[NFILEN + 11];

for (bp = bheadp; bp != NULL; bp = bp-b_bufp) {
-   if (bp-b_fname != NULL  *(bp-b_fname) != '\0' 
+   if (*(bp-b_fname) != '\0' 
(bp-b_flag  BFCHG) != 0) {
ret = snprintf(pbuf, sizeof(pbuf), Save file %s,
bp-b_fname);



Another small mg tweak

2014-03-30 Thread Brian Callahan

Hi tech --

In cmode.c, line 455 has slashp=FALSE, but then it is defined again 
about 12 lines later, also to slashp=FALSE. It doesn't look like we need 
to do that twice.


I removed the first one, because the second one has a comment about it.

OK?

~Brian

Index: cmode.c
===
RCS file: /cvs/src/usr.bin/mg/cmode.c,v
retrieving revision 1.8
diff -u -p -r1.8 cmode.c
--- cmode.c18 May 2012 02:13:44 -1.8
+++ cmode.c30 Mar 2014 17:04:29 -
@@ -452,7 +452,6 @@ findnonblank(struct line *lp)

 while (lback(lp) != curbp-b_headp  (commentp || !nonblankp)) {
 lp = lback(lp);
-slashp = FALSE;
 astp = FALSE;

 /* Potential nonblank? */



Fix sendbug(1) link

2014-03-23 Thread Brian Callahan

Hi tech@ --

About a week and a half ago, this commit:

http://marc.info/?l=openbsd-cvsm=139452134505276w=2

removed the query-pr.html page.

sendbug(1) needs updating to reflect this, diff below.

OK?

~Brian

Index: sendbug.1
===
RCS file: /cvs/src/usr.bin/sendbug/sendbug.1,v
retrieving revision 1.23
diff -u -p -r1.23 sendbug.1
--- sendbug.116 Jul 2013 00:07:52 -1.23
+++ sendbug.123 Mar 2014 22:06:15 -
@@ -56,7 +56,7 @@ should keep the same mail subject.
 The status of bug reports can be followed by checking the
 .Mt b...@openbsd.org
 mailing list archive available at
-.Lk http://www.openbsd.org/query-pr.html .
+.Lk http://www.openbsd.org/mail.html .
 .Pp
 The options are as follows:
 .Bl -tag -width Ds



Re: Add HISTORY section to locale.1

2013-12-26 Thread Brian Callahan

On 12/26/2013 7:59 AM, Ingo Schwarze wrote:

Hi Brian,

Brian Callahan wrote on Wed, Dec 25, 2013 at 11:55:43PM -0700:


A user asked me earlier today when our locale(1) appeared.
Do we want to put that in the man page?


Definitely.

However, i'd suggest to reserve the wording (first) appeared in
for original inventions in the operating system and version cited.
Yes i know we didn't stick to that in the past and there is much
to clean up, but i don't see the point in adding yet more ambiguity
by continuing to use the same wording for vastly different things.

I suggest to be as specific as possible in the HISTORY and AUTHORS
sections.  That way, we provide more information without that much
additional effort.  The earlier it is done, the simpler to get it
right.  The ordeal Cynthia Livingston had to go through for the
4.3BSD-Reno and 4.4BSD releases, and the large number of errors
that inevitably resulted, may well serve as a warning.

See below for an example of how i'd like to see it done.

If anybody knows where this abomination originally came from,
i'd like to put something like this:



The earliest mention I can find for locale(1) is in the SUSv2 docs from 
1997. But it must be from earlier.



   .Sh HISTORY
   A
   .Nm
   utility first appeared in FooOS 0.9 (1995).
   It was rewritten from scratch for
   .Ox 5.4
   during the 2013 Toronto hackathon.
   .Sh AUTHORS
   The original version was written by
   .An Joe F. Corporatecoder
   and
   .An Nelly G. Bloat .
   .Pp
   The OpenBSD version was written by
   ...

Yours,
   Ingo


Index: locale.1
===
RCS file: /cvs/src/usr.bin/locale/locale.1,v
retrieving revision 1.2
diff -u -r1.2 locale.1
--- locale.13 Jun 2013 17:06:29 -   1.2
+++ locale.126 Dec 2013 12:44:28 -
@@ -61,5 +61,17 @@
  .Nm
  utility implements a subset of the specification given in
  .St -p1003.1-2008 .
+.Sh HISTORY
+The
+.Nm
+utility was rewritten from scratch for
+.Ox 5.4
+during the 2013 Toronto hackathon.
+.Sh AUTHORS
+.An Stefan Sperling Aq Mt s...@openbsd.org
+with contributions from
+.An Philip Guenther Aq Mt guent...@openbsd.org
+and
+.An Jeremie Courreges-Anglas Aq Mt j...@openbsd.org .
  .Sh BUGS
  The list of supported locales is perpetually incomplete.



Regardless, I think this should be committed.

~Brian




Index: locale.1
===
RCS file: /cvs/src/usr.bin/locale/locale.1,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 locale.1
--- locale.13 Jun 2013 17:06:29 -   1.2
+++ locale.126 Dec 2013 06:53:18 -
@@ -61,5 +61,10 @@ The
  .Nm
  utility implements a subset of the specification given in
  .St -p1003.1-2008 .
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Ox 5.4 .
  .Sh BUGS
  The list of supported locales is perpetually incomplete.







Add HISTORY section to locale.1

2013-12-25 Thread Brian Callahan
Hi tech --

A user asked me earlier today when our locale(1) appeared.
Do we want to put that in the man page?

OK?

~Brian

Index: locale.1
===
RCS file: /cvs/src/usr.bin/locale/locale.1,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 locale.1
--- locale.13 Jun 2013 17:06:29 -   1.2
+++ locale.126 Dec 2013 06:53:18 -
@@ -61,5 +61,10 @@ The
 .Nm
 utility implements a subset of the specification given in
 .St -p1003.1-2008 .
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Ox 5.4 .
 .Sh BUGS
 The list of supported locales is perpetually incomplete.



Re: octcf(4/octeon): switch disksort() to bufqs

2013-10-31 Thread Brian Callahan

On 10/31/2013 2:33 AM, David Gwynne wrote:

jmatthew@ tells me this compiles, but we dont have hardware to test
with.

tests? oks? go for its?



I'll run a test on my CAM-0100 later today.


cheers,
dlg

Index: octcf.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/octcf.c,v
retrieving revision 1.12
diff -u -p -r1.12 octcf.c
--- octcf.c 11 Jun 2013 16:42:10 -  1.12
+++ octcf.c 31 Oct 2013 06:32:11 -
@@ -111,7 +111,7 @@ struct octcf_softc {
/* General disk infos */
struct device sc_dev;
struct disk sc_dk;
-   struct buf sc_q;
+   struct bufq sc_bufq;
struct buf *sc_bp;
struct ataparams sc_params;/* drive characteristics found */
int sc_flags;
@@ -260,6 +260,7 @@ octcfattach(struct device *parent, struc
 * Initialize disk structures.
 */
wd-sc_dk.dk_name = wd-sc_dev.dv_xname;
+   bufq_init(wd-sc_bufq, BUFQ_DEFAULT);

/* Attach disk. */
disk_attach(wd-sc_dev, wd-sc_dk);
@@ -326,9 +327,11 @@ octcfstrategy(struct buf *bp)
goto bad;
}

+   /* Queue the I/O */
+   bufq_queue(wd-sc_bufq, bp);
+
/* Queue transfer on drive, activate drive and controller if idle. */
s = splbio();
-   disksort(wd-sc_q, bp);
octcfstart(wd);
splx(s);
device_unref(wd-sc_dev);
@@ -352,18 +355,11 @@ void
  octcfstart(void *arg)
  {
struct octcf_softc *wd = arg;
-   struct buf *dp, *bp;
+   struct buf *bp;

OCTCFDEBUG_PRINT((%s %s\n, __func__, wd-sc_dev.dv_xname),
DEBUG_XFERS);
-   while (1) {
-   /* Remove the next buffer from the queue or stop. */
-   dp = wd-sc_q;
-   bp = dp-b_actf;
-   if (bp == NULL)
-   return;
-   dp-b_actf = bp-b_actf;
-
+   while ((bp = bufq_dequeue(wd-sc_bufq)) != NULL) {
/* Transfer this buffer now. */
_octcfstart(wd, bp);
}





Re: octcf(4/octeon): switch disksort() to bufqs

2013-10-31 Thread Brian Callahan

On 10/31/2013 10:49 AM, Brian Callahan wrote:

On 10/31/2013 2:33 AM, David Gwynne wrote:

jmatthew@ tells me this compiles, but we dont have hardware to test
with.

tests? oks? go for its?



I'll run a test on my CAM-0100 later today.



tests good. ok.


cheers,
dlg

Index: octcf.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/octcf.c,v
retrieving revision 1.12
diff -u -p -r1.12 octcf.c
--- octcf.c11 Jun 2013 16:42:10 -1.12
+++ octcf.c31 Oct 2013 06:32:11 -
@@ -111,7 +111,7 @@ struct octcf_softc {
  /* General disk infos */
  struct device sc_dev;
  struct disk sc_dk;
-struct buf sc_q;
+struct bufq sc_bufq;
  struct buf *sc_bp;
  struct ataparams sc_params;/* drive characteristics found */
  int sc_flags;
@@ -260,6 +260,7 @@ octcfattach(struct device *parent, struc
   * Initialize disk structures.
   */
  wd-sc_dk.dk_name = wd-sc_dev.dv_xname;
+bufq_init(wd-sc_bufq, BUFQ_DEFAULT);

  /* Attach disk. */
  disk_attach(wd-sc_dev, wd-sc_dk);
@@ -326,9 +327,11 @@ octcfstrategy(struct buf *bp)
  goto bad;
  }

+/* Queue the I/O */
+bufq_queue(wd-sc_bufq, bp);
+
  /* Queue transfer on drive, activate drive and controller if
idle. */
  s = splbio();
-disksort(wd-sc_q, bp);
  octcfstart(wd);
  splx(s);
  device_unref(wd-sc_dev);
@@ -352,18 +355,11 @@ void
  octcfstart(void *arg)
  {
  struct octcf_softc *wd = arg;
-struct buf *dp, *bp;
+struct buf *bp;

  OCTCFDEBUG_PRINT((%s %s\n, __func__, wd-sc_dev.dv_xname),
  DEBUG_XFERS);
-while (1) {
-/* Remove the next buffer from the queue or stop. */
-dp = wd-sc_q;
-bp = dp-b_actf;
-if (bp == NULL)
-return;
-dp-b_actf = bp-b_actf;
-
+while ((bp = bufq_dequeue(wd-sc_bufq)) != NULL) {
  /* Transfer this buffer now. */
  _octcfstart(wd, bp);
  }







Remove octeon backwards compat calls

2013-10-21 Thread Brian Callahan
Hi tech --

Here's a diff to replace some backwards compat calls with their
new calls. The rest were long replaced; I'm assuming these went
unnoticed because they're both under an
#ifdef OCTEON_ETH_DEBUG

This was pointed out by William Orr will AT worrbase ! com in a
private email.

OK?

~Brian

Index: cn30xxgmx.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/cn30xxgmx.c,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 cn30xxgmx.c
--- cn30xxgmx.c 19 Sep 2013 00:15:59 -  1.7
+++ cn30xxgmx.c 21 Oct 2013 16:32:04 -
@@ -1431,7 +1431,7 @@ cn30xxgmx_intr_rml_gmx1(void)
 int
 cn30xxgmx_intr_drop(void *arg)
 {
-   octeon_write_csr(CIU_INT0_SUM0, CIU_INTX_SUM0_GMX_DRP);
+   octeon_xkphys_write_8(CIU_INT0_SUM0, CIU_INTX_SUM0_GMX_DRP);
cn30xxgmx_intr_drop_evcnt.ev_count++;
return (1);
 }
Index: cn30xxipd.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/cn30xxipd.c,v
retrieving revision 1.2
diff -u -p -u -p -r1.2 cn30xxipd.c
--- cn30xxipd.c 5 Dec 2012 23:20:14 -   1.2
+++ cn30xxipd.c 21 Oct 2013 16:32:04 -
@@ -312,7 +312,7 @@ cn30xxipd_int_summary(struct cn30xxipd_s
 int
 cn30xxipd_intr_drop(void *arg)
 {
-   octeon_write_csr(CIU_INT0_SUM0, CIU_INTX_SUM0_IPD_DRP);
+   octeon_xkphys_write_8(CIU_INT0_SUM0, CIU_INTX_SUM0_IPD_DRP);
cn30xxipd_intr_drop_evcnt.ev_count++;
return (1);
 }



Re: edgerouter lite ethernet

2013-09-17 Thread Brian Callahan

On 9/17/2013 12:45 AM, Brian Callahan wrote:

On 09/16/13 19:29, Jonathan Matthew wrote:

Here's the rest of the changes required to get ethernet working on the
edgerouter lite, which makes it possible to boot off nfsroot and do
exciting
stuff like build kernels.

- add atphy(4) to configs
- allow separate rx and tx clock settings
- add phy mapping for erl
- add tx/rx clock settings for erl

ok?



No. This breaks the RAMDISK (tested on CAM-0100). Log at the bottom of
this email from the CAM-0100 (and attached as a tarball too because I
don't trust Thunderbird). Note that everything else works except for the
RAMDISK. The GENERIC kernel works great on the CAM-0100 and ERL and
everything works as expected on both machines with GENERIC.

Also, the panic still occurs if you remove the atphy* line from RAMDISK.

Can someone else who has a CAM-0100 double check to make sure it's not
just me, since I'd love to have this go in.



I double and triple checked this today: turns out the first RAMDISK was 
built incorrectly somehow. The second and third check RAMDISKs work fine 
so I retract everything I said before and this is ok me.


~Brian


~Brian


Copyright (c) 1982, 1986, 1989, 1991, 1993
 The Regents of the University of California.  All rights
reserved.
Copyright (c) 1995-2013 OpenBSD. All rights reserved.
http://www.OpenBSD.org

OpenBSD 5.4-current (GENERIC) #29: Tue Sep 17 08:07:14 EST 2013
 r...@cantrip.eait.uq.edu.au:/usr/src/sys/arch/octeon/compile/GENERIC
real mem = 247922688 (236MB)
avail mem = 245612544 (234MB)
mainbus0 at root
cpu0 at mainbus0: Cavium OCTEON CPU rev 0.1 500 MHz, Software FP
emulation
cpu0: cache L1-I 32KB D 16KB 4 way, L2 128KB direct
clock0 at mainbus0: int 5
iobus0 at mainbus0
octcf at iobus0 base 0x1d000800 irq 0 not configured
pcibus at iobus0 irq 0 not configured
cn30xxgmx0 at iobus0 base 0x118000800 irq 48
cnmac0 at cn30xxgmx0 address=0x000118000800: RGMII, address
dc:9f:db:29:40:2f
atphy0 at cnmac0 phy 7: F1 10/100/1000 PHY, rev. 2
cnmac1 at cn30xxgmx0 address=0x000118000800: RGMII, address
dc:9f:db:29:40:30
atphy1 at cnmac1 phy 6: F1 10/100/1000 PHY, rev. 2
cnmac2 at cn30xxgmx0 address=0x000118000800: RGMII, address
dc:9f:db:29:40:31
atphy2 at cnmac2 phy 5: F1 10/100/1000 PHY, rev. 2
uar: ns16550, no working fifo
com0: console
com1 at uartbus0 base 0x118000c00 irq 35: ns16550, no working fifo
/dev/ksyms: Symbol table not valid.
vscsi0 at root
scsibus0 at vscsi0: 256 targets
softraid0 at root
scsibus1 at softraid0: 256 targets
root device: cnmac0
nfs_boot: using interface cnmac0, with revarp  bootparams
cnmac0: link up (1000baseT-FDX)
cnmac0: link down
cnmac0: link up (1000baseT-FDX)
nfs_boot: client_addr=192.168.1.2
nfs_boot: server_addr=192.168.1.22 hostname=erl
root on 192.168.1.22:/srv/octeon-nfsroot
WARNING: No TOD clock, believing file system.
WARNING: CHECK AND RESET THE DATE!
swap on 192.168.1.22:/srv/octeon-nfsswap



Index: arch/octeon/conf/GENERIC
===
RCS file: /cvs/src/sys/arch/octeon/conf/GENERIC,v
retrieving revision 1.9
diff -u -p -r1.9 GENERIC
--- arch/octeon/conf/GENERIC24 Jun 2011 02:18:17 -1.9
+++ arch/octeon/conf/GENERIC16 Sep 2013 22:50:31 -
@@ -44,6 +44,7 @@ cnmac*at cn30xxgmx?
  rgephy*at mii?
  ukphy*at mii?
+atphy*at mii?
  # IDE Controller
  pciide*at pci? flags 0x
Index: arch/octeon/conf/RAMDISK
===
RCS file: /cvs/src/sys/arch/octeon/conf/RAMDISK,v
retrieving revision 1.11
diff -u -p -r1.11 RAMDISK
--- arch/octeon/conf/RAMDISK26 Mar 2013 14:23:19 -1.11
+++ arch/octeon/conf/RAMDISK16 Sep 2013 22:50:31 -
@@ -64,6 +64,7 @@ cnmac*at cn30xxgmx?
  rgephy*at mii?
  ukphy*at mii?
+atphy*at mii?
  pseudo-deviceloop1# network loopback
  pseudo-devicebpfilter1# packet filter
Index: arch/octeon/dev/cn30xxasx.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/cn30xxasx.c,v
retrieving revision 1.3
diff -u -p -r1.3 cn30xxasx.c
--- arch/octeon/dev/cn30xxasx.c5 Dec 2012 23:20:14 -1.3
+++ arch/octeon/dev/cn30xxasx.c16 Sep 2013 22:50:31 -
@@ -175,10 +175,10 @@ cn30xxasx_enable_intr(struct cn30xxasx_s
  #endif
  int
-cn30xxasx_clk_set(struct cn30xxasx_softc *sc, int setting)
+cn30xxasx_clk_set(struct cn30xxasx_softc *sc, int tx_setting, int
rx_setting)
  {
-_ASX_WR8(sc, ASX0_TX_CLK_SET0_OFFSET + 8 * sc-sc_port, setting);
-_ASX_WR8(sc, ASX0_RX_CLK_SET0_OFFSET + 8 * sc-sc_port, setting);
+_ASX_WR8(sc, ASX0_TX_CLK_SET0_OFFSET + 8 * sc-sc_port, tx_setting);
+_ASX_WR8(sc, ASX0_RX_CLK_SET0_OFFSET + 8 * sc-sc_port, rx_setting);
  return 0;
  }
Index: arch/octeon/dev/cn30xxasxvar.h
===
RCS file: /cvs/src/sys/arch

Re: edgerouter lite ethernet

2013-09-16 Thread Brian Callahan

On 09/16/13 19:29, Jonathan Matthew wrote:

Here's the rest of the changes required to get ethernet working on the
edgerouter lite, which makes it possible to boot off nfsroot and do exciting
stuff like build kernels.

- add atphy(4) to configs
- allow separate rx and tx clock settings
- add phy mapping for erl
- add tx/rx clock settings for erl

ok?



No. This breaks the RAMDISK (tested on CAM-0100). Log at the bottom of 
this email from the CAM-0100 (and attached as a tarball too because I 
don't trust Thunderbird). Note that everything else works except for the 
RAMDISK. The GENERIC kernel works great on the CAM-0100 and ERL and 
everything works as expected on both machines with GENERIC.


Also, the panic still occurs if you remove the atphy* line from RAMDISK.

Can someone else who has a CAM-0100 double check to make sure it's not 
just me, since I'd love to have this go in.


~Brian


Copyright (c) 1982, 1986, 1989, 1991, 1993
 The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2013 OpenBSD. All rights reserved.  http://www.OpenBSD.org

OpenBSD 5.4-current (GENERIC) #29: Tue Sep 17 08:07:14 EST 2013
 r...@cantrip.eait.uq.edu.au:/usr/src/sys/arch/octeon/compile/GENERIC
real mem = 247922688 (236MB)
avail mem = 245612544 (234MB)
mainbus0 at root
cpu0 at mainbus0: Cavium OCTEON CPU rev 0.1 500 MHz, Software FP emulation
cpu0: cache L1-I 32KB D 16KB 4 way, L2 128KB direct
clock0 at mainbus0: int 5
iobus0 at mainbus0
octcf at iobus0 base 0x1d000800 irq 0 not configured
pcibus at iobus0 irq 0 not configured
cn30xxgmx0 at iobus0 base 0x118000800 irq 48
cnmac0 at cn30xxgmx0 address=0x000118000800: RGMII, address 
dc:9f:db:29:40:2f
atphy0 at cnmac0 phy 7: F1 10/100/1000 PHY, rev. 2
cnmac1 at cn30xxgmx0 address=0x000118000800: RGMII, address 
dc:9f:db:29:40:30
atphy1 at cnmac1 phy 6: F1 10/100/1000 PHY, rev. 2
cnmac2 at cn30xxgmx0 address=0x000118000800: RGMII, address 
dc:9f:db:29:40:31
atphy2 at cnmac2 phy 5: F1 10/100/1000 PHY, rev. 2
uar: ns16550, no working fifo
com0: console
com1 at uartbus0 base 0x118000c00 irq 35: ns16550, no working fifo
/dev/ksyms: Symbol table not valid.
vscsi0 at root
scsibus0 at vscsi0: 256 targets
softraid0 at root
scsibus1 at softraid0: 256 targets
root device: cnmac0
nfs_boot: using interface cnmac0, with revarp  bootparams
cnmac0: link up (1000baseT-FDX)
cnmac0: link down
cnmac0: link up (1000baseT-FDX)
nfs_boot: client_addr=192.168.1.2
nfs_boot: server_addr=192.168.1.22 hostname=erl
root on 192.168.1.22:/srv/octeon-nfsroot
WARNING: No TOD clock, believing file system.
WARNING: CHECK AND RESET THE DATE!
swap on 192.168.1.22:/srv/octeon-nfsswap



Index: arch/octeon/conf/GENERIC
===
RCS file: /cvs/src/sys/arch/octeon/conf/GENERIC,v
retrieving revision 1.9
diff -u -p -r1.9 GENERIC
--- arch/octeon/conf/GENERIC24 Jun 2011 02:18:17 -  1.9
+++ arch/octeon/conf/GENERIC16 Sep 2013 22:50:31 -
@@ -44,6 +44,7 @@ cnmac*at cn30xxgmx?
  
  rgephy*		at mii?

  ukphy*at mii?
+atphy* at mii?
  
  # IDE Controller

  pciide*   at pci? flags 0x
Index: arch/octeon/conf/RAMDISK
===
RCS file: /cvs/src/sys/arch/octeon/conf/RAMDISK,v
retrieving revision 1.11
diff -u -p -r1.11 RAMDISK
--- arch/octeon/conf/RAMDISK26 Mar 2013 14:23:19 -  1.11
+++ arch/octeon/conf/RAMDISK16 Sep 2013 22:50:31 -
@@ -64,6 +64,7 @@ cnmac*at cn30xxgmx?
  
  rgephy*		at mii?

  ukphy*at mii?
+atphy* at mii?
  
  pseudo-device	loop		1	# network loopback

  pseudo-device bpfilter1   # packet filter
Index: arch/octeon/dev/cn30xxasx.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/cn30xxasx.c,v
retrieving revision 1.3
diff -u -p -r1.3 cn30xxasx.c
--- arch/octeon/dev/cn30xxasx.c 5 Dec 2012 23:20:14 -   1.3
+++ arch/octeon/dev/cn30xxasx.c 16 Sep 2013 22:50:31 -
@@ -175,10 +175,10 @@ cn30xxasx_enable_intr(struct cn30xxasx_s
  #endif
  
  int

-cn30xxasx_clk_set(struct cn30xxasx_softc *sc, int setting)
+cn30xxasx_clk_set(struct cn30xxasx_softc *sc, int tx_setting, int rx_setting)
  {
-   _ASX_WR8(sc, ASX0_TX_CLK_SET0_OFFSET + 8 * sc-sc_port, setting);
-   _ASX_WR8(sc, ASX0_RX_CLK_SET0_OFFSET + 8 * sc-sc_port, setting);
+   _ASX_WR8(sc, ASX0_TX_CLK_SET0_OFFSET + 8 * sc-sc_port, tx_setting);
+   _ASX_WR8(sc, ASX0_RX_CLK_SET0_OFFSET + 8 * sc-sc_port, rx_setting);
return 0;
  }
  
Index: arch/octeon/dev/cn30xxasxvar.h

===
RCS file: /cvs/src/sys/arch/octeon/dev/cn30xxasxvar.h,v
retrieving revision 1.1
diff -u -p -r1.1 cn30xxasxvar.h
--- arch/octeon/dev/cn30xxasxvar.h  16 Jun 2011 11:22:30 -  1.1
+++ arch/octeon/dev/cn30xxasxvar.h   

Re: octeon cnmac phy addresses

2013-09-15 Thread Brian Callahan


On 09/15/13 01:53, David Gwynne wrote:

makes a lot of sense to me, ok. you need oks from people other than me though.

dlg


I've been running this for the last 12 hours or so without problems on 
my CAM-0100, so ok for me.


~Brian


On 14/09/2013, at 8:34 PM, Jonathan Matthew jmatt...@openbsd.org wrote:


The network interfaces on the ubiquiti edgerouter lite don't work yet.
Here's the first step towards fixing that:

Mapping port numbers to phy addresses in the mii read/write functions
hides the phy addresses unnecessarily.  Instead, we should figure out
the phy address when setting up the port and pass it to mii_attach.

I don't have an octeon system that works with the existing code, so all
I can say is this doesn't make any difference on the edgerouter lite.
It uses different phy addresses, which I'll add a mapping for later.

ok?

Index: arch/octeon/dev/cn30xxgmx.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/cn30xxgmx.c,v
retrieving revision 1.5
diff -u -p -r1.5 cn30xxgmx.c
--- arch/octeon/dev/cn30xxgmx.c 5 Dec 2012 23:20:14 -   1.5
+++ arch/octeon/dev/cn30xxgmx.c 14 Sep 2013 09:35:40 -
@@ -146,6 +146,11 @@ struct cn30xxgmx_port_ops *cn30xxgmx_por
[GMX_SPI42_PORT] = cn30xxgmx_port_ops_spi42
};

+/* this apparently works for the portwell cam-0100 */
+int octeon_eth_phy_table[] = {
+   0x02, 0x03, 0x22
+};
+
#ifdef OCTEON_ETH_DEBUG
static void *cn30xxgmx_intr_drop_ih;
struct evcntcn30xxgmx_intr_drop_evcnt =
@@ -178,6 +183,14 @@ cn30xxgmx_match(struct device *parent, v
return 1;
}

+static int
+cn30xxgmx_port_phy_addr(int port)
+{
+   if (port = nitems(octeon_eth_phy_table))
+   return -1;
+   return octeon_eth_phy_table[port];
+}
+
static void
cn30xxgmx_attach(struct device *parent, struct device *self, void *aux)
{
@@ -223,6 +236,9 @@ cn30xxgmx_attach(struct device *parent,
gmx_aa.ga_port_type = sc-sc_port_types[i];
gmx_aa.ga_gmx = sc;
gmx_aa.ga_gmx_port = port_sc;
+   gmx_aa.ga_phy_addr = cn30xxgmx_port_phy_addr(i);
+   if (gmx_aa.ga_phy_addr == -1)
+   panic(: don't know phy address for port %d, i);

config_found_sm(self, gmx_aa,
cn30xxgmx_print, cn30xxgmx_submatch);
Index: arch/octeon/dev/cn30xxgmxvar.h
===
RCS file: /cvs/src/sys/arch/octeon/dev/cn30xxgmxvar.h,v
retrieving revision 1.1
diff -u -p -r1.1 cn30xxgmxvar.h
--- arch/octeon/dev/cn30xxgmxvar.h  16 Jun 2011 11:22:30 -  1.1
+++ arch/octeon/dev/cn30xxgmxvar.h  14 Sep 2013 09:35:40 -
@@ -136,6 +136,7 @@ struct cn30xxgmx_attach_args {
const char  *ga_name;
int ga_portno;
int ga_port_type;
+   int ga_phy_addr;

struct cn30xxgmx_softc *ga_gmx;
struct cn30xxgmx_port_softc
Index: arch/octeon/dev/if_cnmac.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/if_cnmac.c,v
retrieving revision 1.11
diff -u -p -r1.11 if_cnmac.c
--- arch/octeon/dev/if_cnmac.c  17 Aug 2013 10:00:09 -  1.11
+++ arch/octeon/dev/if_cnmac.c  14 Sep 2013 09:35:40 -
@@ -259,15 +259,6 @@ static const struct octeon_evcnt_entry o
};
#endif

-/* XXX board-specific */
-static const int   octeon_eth_phy_table[] = {
-#if defined __seil5__
-   0x04, 0x01, 0x02
-#else
-   0x02, 0x03, 0x22
-#endif
-};
-
/*  buffer management */

static const struct octeon_eth_pool_param {
@@ -338,6 +329,7 @@ octeon_eth_attach(struct device *parent,
sc-sc_port_type = ga-ga_port_type;
sc-sc_gmx = ga-ga_gmx;
sc-sc_gmx_port = ga-ga_gmx_port;
+   sc-sc_phy_addr = ga-ga_phy_addr;

sc-sc_init_flag = 0;

@@ -549,30 +541,14 @@ static int
octeon_eth_mii_readreg(struct device *self, int phy_no, int reg)
{
struct octeon_eth_softc *sc = (struct octeon_eth_softc *)self;
-   int phy_addr = octeon_eth_phy_table[phy_no];
-
-   if (sc-sc_port = (int)nitems(octeon_eth_phy_table) ||
-   phy_no != sc-sc_port) {
-   log(LOG_ERR,
-   mii read address mismatch, phy number %d.\n, phy_no);
-   return -1;
-   }
-   return cn30xxsmi_read(sc-sc_smi, phy_addr, reg);
+   return cn30xxsmi_read(sc-sc_smi, phy_no, reg);
}

static void
octeon_eth_mii_writereg(struct device *self, int phy_no, int reg, int value)
{
struct octeon_eth_softc *sc = (struct octeon_eth_softc *)self;
-   int phy_addr = octeon_eth_phy_table[phy_no];
-
-   if (sc-sc_port = (int)nitems(octeon_eth_phy_table) ||
-   phy_no != sc-sc_port) {
-   log(LOG_ERR,
-   mii write address mismatch, phy number %d.\n, phy_no);
-   return;
-   }
-   

Re: include netinet/in_var.h in arch/dev

2013-08-16 Thread Brian Callahan

On 8/16/2013 7:44 PM, Alexander Bluhm wrote:

On Wed, Aug 07, 2013 at 03:39:59AM +0200, Alexander Bluhm wrote:

Hi,

I have just removed a bunch of useless include netinet/in_var.h
from the machine independent drivers.  I suspect that they are also
not needed in the architecture specific network drivers.  Unfortunately
I don't have any of these machines.  So if you have access to one
of

 macppc mvme68k octeon sgi sparc vax

could you please test if this diff compiles.


These architectures are still not tested:

 mvme68k octeon sgi sparc

Could you please compile this diff, if you posses one of these
machines?



This compiles on octeon. ok.

~Brian


bluhm

Index: arch/mvme68k/dev/if_ie.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/mvme68k/dev/if_ie.c,v
retrieving revision 1.40
diff -u -p -u -p -r1.40 if_ie.c
--- arch/mvme68k/dev/if_ie.c10 Oct 2012 04:52:16 -  1.40
+++ arch/mvme68k/dev/if_ie.c16 Aug 2013 23:27:02 -
@@ -120,7 +120,6 @@ Mode of operation:
  #ifdef INET
  #include netinet/in.h
  #include netinet/in_systm.h
-#include netinet/in_var.h
  #include netinet/ip.h
  #include netinet/if_ether.h
  #endif
Index: arch/mvme88k/dev/if_ie.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/mvme88k/dev/if_ie.c,v
retrieving revision 1.45
diff -u -p -u -p -r1.45 if_ie.c
--- arch/mvme88k/dev/if_ie.c10 Oct 2012 04:52:16 -  1.45
+++ arch/mvme88k/dev/if_ie.c16 Aug 2013 23:27:02 -
@@ -119,7 +119,6 @@ Mode of operation:
  #ifdef INET
  #include netinet/in.h
  #include netinet/in_systm.h
-#include netinet/in_var.h
  #include netinet/ip.h
  #include netinet/if_ether.h
  #endif
Index: arch/octeon/dev/if_cnmac.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/octeon/dev/if_cnmac.c,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 if_cnmac.c
--- arch/octeon/dev/if_cnmac.c  12 Apr 2013 15:22:26 -  1.10
+++ arch/octeon/dev/if_cnmac.c  16 Aug 2013 23:27:02 -
@@ -66,7 +66,6 @@

  #include netinet/in.h
  #include netinet/in_systm.h
-#include netinet/in_var.h
  #include netinet/ip.h

  #include machine/bus.h
Index: arch/sgi/dev/if_iec.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/sgi/dev/if_iec.c,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 if_iec.c
--- arch/sgi/dev/if_iec.c   22 May 2012 19:24:59 -  1.8
+++ arch/sgi/dev/if_iec.c   16 Aug 2013 23:27:02 -
@@ -101,7 +101,6 @@
  #ifdef INET
  #include netinet/in.h
  #include netinet/in_systm.h
-#include netinet/in_var.h
  #include netinet/ip.h
  #endif

Index: arch/sgi/dev/if_mec.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/sgi/dev/if_mec.c,v
retrieving revision 1.25
diff -u -p -u -p -r1.25 if_mec.c
--- arch/sgi/dev/if_mec.c   3 Oct 2012 22:46:09 -   1.25
+++ arch/sgi/dev/if_mec.c   16 Aug 2013 23:27:02 -
@@ -85,7 +85,6 @@
  #ifdef INET
  #include netinet/in.h
  #include netinet/in_systm.h
-#include netinet/in_var.h
  #include netinet/ip.h
  #endif

Index: arch/sgi/hpc/if_sq.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/sgi/hpc/if_sq.c,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 if_sq.c
--- arch/sgi/hpc/if_sq.c28 May 2012 17:03:35 -  1.8
+++ arch/sgi/hpc/if_sq.c16 Aug 2013 23:27:02 -
@@ -57,7 +57,6 @@
  #ifdef INET
  #include netinet/in.h
  #include netinet/in_systm.h
-#include netinet/in_var.h
  #include netinet/ip.h
  #endif

Index: arch/sparc/dev/be.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/sparc/dev/be.c,v
retrieving revision 1.43
diff -u -p -u -p -r1.43 be.c
--- arch/sparc/dev/be.c 28 Nov 2008 02:44:17 -  1.43
+++ arch/sparc/dev/be.c 16 Aug 2013 23:27:02 -
@@ -46,7 +46,6 @@
  #ifdef INET
  #include netinet/in.h
  #include netinet/in_systm.h
-#include netinet/in_var.h
  #include netinet/ip.h
  #include netinet/if_ether.h
  #endif
Index: arch/sparc/dev/hme.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/sparc/dev/hme.c,v
retrieving revision 1.62
diff -u -p -u -p -r1.62 hme.c
--- arch/sparc/dev/hme.c13 Aug 2009 17:01:31 -  1.62
+++ arch/sparc/dev/hme.c16 Aug 2013 23:27:02 -
@@ -59,7 +59,6 @@
  #ifdef INET
  #include netinet/in.h
  #include netinet/in_systm.h
-#include netinet/in_var.h
  #include netinet/ip.h
  #include netinet/if_ether.h
  #include netinet/tcp.h
Index: arch/sparc/dev/if_gem_sbus.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/sparc/dev/if_gem_sbus.c,v

Re: binary integer constants in gcc

2013-06-21 Thread Brian Callahan

On 6/21/2013 7:03 AM, Stuart Henderson wrote:


ICE with base gcc (lacking info about arch etc)

audio/mscore




For completeness, the ICE was on amd64:
[ 11%] Building CXX object 
singleapp/src/CMakeFiles/qtsingleapp.dir/moc_qtsingleapplication.cxx.o

command-line:0: internal compiler error: Segmentation fault

But I had trouble compiling on powerpc without gcc-4.6 too iirc.

~Brian



Re: Small binutils tweak

2013-04-21 Thread Brian Callahan

On 04/21/13 03:21, Jonathan Gray wrote:

On Sat, Mar 02, 2013 at 10:36:50AM -0500, Brian Callahan wrote:

Hi tech --

While doing some ports testing with clang, I came across the
binutils bug mentioned here:
http://lists.gnu.org/archive/html/bug-binutils/2004-07/msg0.html

Below is a backport of the commit mentioned later in the thread. It
fixes the issue.
I was able to rebuild working kernels and do a full 'make build' on
amd64, loongson, and macppc with this patch. But since it affects
all archs, testing on the archs I don't have access to will be
needed.

OK?

This patch does not apply, it seems your mail client is wrapping lines.




Below. Also attached as a tarball, in case Thunderbird really just hates me.

miod told me about a month and a half ago to focus on moving to 
binutils-2.17 and not backport things to 2.15 so I never bothered to 
ping this.


~Brian

Index: elf-bfd.h
===
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elf-bfd.h,v
retrieving revision 1.8
diff -u -p -r1.8 elf-bfd.h
--- elf-bfd.h2 Nov 2004 20:45:06 -1.8
+++ elf-bfd.h21 Apr 2013 14:31:06 -
@@ -1055,8 +1055,8 @@ struct bfd_elf_section_data
 #define elf_discarded_section(sec)\
   (!bfd_is_abs_section (sec)\
 bfd_is_abs_section ((sec)-output_section) \
-sec-sec_info_type != ELF_INFO_TYPE_MERGE \
-sec-sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
+(sec)-sec_info_type != ELF_INFO_TYPE_MERGE \
+(sec)-sec_info_type != ELF_INFO_TYPE_JUST_SYMS)

 #define get_elf_backend_data(abfd) \
   ((const struct elf_backend_data *) (abfd)-xvec-backend_data)
Index: elflink.c
===
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elflink.c,v
retrieving revision 1.9
diff -u -p -r1.9 elflink.c
--- elflink.c24 Nov 2004 16:55:31 -1.9
+++ elflink.c21 Apr 2013 14:31:07 -
@@ -6239,6 +6239,9 @@ elf_link_output_extsym (struct elf_link_
   return TRUE;
 }

+/* Return TRUE if special handling is done for relocs in SEC against
+   symbols defined in discarded sections.  */
+
 static bfd_boolean
 elf_section_ignore_discarded_relocs (asection *sec)
 {
@@ -6261,6 +6264,26 @@ elf_section_ignore_discarded_relocs (ase
   return FALSE;
 }

+/* Return TRUE if we should complain about a reloc in SEC against a
+   symbol defined in a discarded section.  */
+
+static bfd_boolean
+elf_section_complain_discarded (asection *sec)
+{
+  if (strncmp (.stab, sec-name, 5) == 0
+   (!sec-name[5] ||
+ (sec-name[5] == '.'  ISDIGIT (sec-name[6]
+return FALSE;
+
+  if (strcmp (.eh_frame, sec-name) == 0)
+return FALSE;
+
+  if (strcmp (.gcc_except_table, sec-name) == 0)
+return FALSE;
+
+  return TRUE;
+}
+
 /* Link an input file into the linker output file.  This function
handles all the sections and relocations of the input file at once.
This is so that we only have to read the local symbols once, and
@@ -6532,13 +6555,16 @@ elf_link_input_bfd (struct elf_final_lin
   if (!elf_section_ignore_discarded_relocs (o))
 {
   Elf_Internal_Rela *rel, *relend;
+  bfd_boolean complain = elf_section_complain_discarded 
(o);


   rel = internal_relocs;
   relend = rel + o-reloc_count * bed-s-int_rels_per_ext_rel;
   for ( ; rel  relend; rel++)
 {
   unsigned long r_symndx = rel-r_info  r_sym_shift;
-  asection *sec;
+  asection **ps, *sec;
+  struct elf_link_hash_entry *h = NULL;
+  const char *sym_name;

   if (r_symndx = locsymcount
   || (elf_bad_symtab (input_bfd)
@@ -6551,79 +6577,70 @@ elf_link_input_bfd (struct elf_final_lin
  || h-root.type == bfd_link_hash_warning)
 h = (struct elf_link_hash_entry *) h-root.u.i.link;

-  /* Complain if the definition comes from a
- discarded section.  */
-  sec = h-root.u.def.section;
-  if ((h-root.type == bfd_link_hash_defined
-   || h-root.type == bfd_link_hash_defweak)
-   elf_discarded_section (sec))
-{
-  if ((o-flags  SEC_DEBUGGING) != 0)
-{
-  BFD_ASSERT (r_symndx != 0);
-  /* Try to preserve debug information.  */
-  if ((o-flags  SEC_DEBUGGING) != 0
-   sec-kept_section != NULL
-   sec-_raw_size == sec-kept_section-_raw_size)
-h-root.u.def.section
-  = sec-kept_section;
-  else
-memset (rel, 0, sizeof (*rel));
-}
-  else
-finfo-info-callbacks-error_handler
-  (LD_DEFINITION_IN_DISCARDED_SECTION,
-   _(%T: discarded in section `%s' from %s\n),
-   h

Re: Another manpage grammar tweak (ath.4)

2013-04-12 Thread Brian Callahan

On 4/12/2013 3:08 AM, Alexander Hall wrote:

On 04/12/13 08:40, Jason McIntyre wrote:

On Fri, Apr 12, 2013 at 08:30:16AM +0200, Alexander Hall wrote:

  .It AR5212
  These devices support 802.11a, 802.11b, and 802.11g operation with
  transmit speeds as above for 802.11a, 802.11b, and 802.11g operation
-(802.11g speeds are the same as for 802.11a speeds).
+(802.11g speeds are the same as 802.11a speeds).
  .El
  .Pp
  All chips also support an Atheros Turbo Mode (TM) that operates
in the



hmm. i don;t think this is grammatically incorrect at all. it might
sound strange to some ears, i guess. but wrong? why is it wrong?


Cause the 802.11a speeds don't have speeds? Admittedly I'm not a native
speaker, but I'd agree with the OP.



it's not saying that. it says, in essence, that 11g speeds are the same
as for (the) 11a speeds (listed above). it is omitting parts that
can be left out because the intent should be fairly obvious.


11g speeds are the same as for the 11a speeds listed above is still 
awkward due to its wordiness. You can just say 11g and 11a speeds are 
the same. And the for still really bothers my ears in that sentence.




The omitted parts didn't bother me, it's the for that doesn't make
sense in my head, as that makes me read I have the same number of socks
as your socks [do], implying that the socks have socks, instead of I
have the same number of socks as you [do].

Anyway, this isn't a bikeshed I'm very attached to. Just emptying my
pockets of pennies.


i guess we can reword it if folks think it sounds odd (or wrong ;) but
if i had to do that, i'd say it'd sound better as the same as those
for
802.11a.




We can go this route. ok for me too. Like Alex, I'm not attached to 
this. Just pointing out my thoughts.


~Brian



Another manpage grammar tweak (ath.4)

2013-04-11 Thread Brian Callahan

Hi tech --

Here's another small fix to correct a grammatically incorrect sentence 
in ath.4


OK?

~Brian

Index: ath.4
===
RCS file: /cvs/src/share/man/man4/ath.4,v
retrieving revision 1.55
diff -u -p -r1.55 ath.4
--- ath.414 Feb 2013 07:40:42 -1.55
+++ ath.412 Apr 2013 02:54:45 -
@@ -78,7 +78,7 @@ transmit speeds as above for 802.11a and
 .It AR5212
 These devices support 802.11a, 802.11b, and 802.11g operation with
 transmit speeds as above for 802.11a, 802.11b, and 802.11g operation
-(802.11g speeds are the same as for 802.11a speeds).
+(802.11g speeds are the same as 802.11a speeds).
 .El
 .Pp
 All chips also support an Atheros Turbo Mode (TM) that operates in the



Add alternate power changed event to acpithinkpad.c

2013-03-31 Thread Brian Callahan

Hi tech --

I just discovered that my Thinkpad (Edge E420) sends a 0x6040 event when 
the power cable is connected or removed.


Patch below handles it, works for me.

OK?

~Brian

Index: acpithinkpad.c
===
RCS file: /cvs/src/sys/dev/acpi/acpithinkpad.c,v
retrieving revision 1.29
diff -u -p -r1.29 acpithinkpad.c
--- acpithinkpad.c  22 Mar 2013 22:15:01 -  1.29
+++ acpithinkpad.c  31 Mar 2013 16:36:17 -
@@ -74,6 +74,7 @@
 #defineTHINKPAD_TABLET_PEN_INSERTED0x500b
 #defineTHINKPAD_TABLET_PEN_REMOVED 0x500c
 #defineTHINKPAD_POWER_CHANGED  0x6030
+#defineTHINKPAD_POWER_CHANGED_ALT  0x6040
 #defineTHINKPAD_BACKLIGHT_CHANGED  0x6050
 #defineTHINKPAD_SWITCH_WIRELESS0x7000

@@ -346,6 +347,7 @@ thinkpad_hotkey(struct aml_node *node, i
handled = 1;
break;
case THINKPAD_POWER_CHANGED:
+   case THINKPAD_POWER_CHANGED_ALT:
case THINKPAD_BACKLIGHT_CHANGED:
handled = 1;
break;



Small binutils tweak

2013-03-02 Thread Brian Callahan

Hi tech --

While doing some ports testing with clang, I came across the binutils 
bug mentioned here:

http://lists.gnu.org/archive/html/bug-binutils/2004-07/msg0.html

Below is a backport of the commit mentioned later in the thread. It 
fixes the issue.
I was able to rebuild working kernels and do a full 'make build' on 
amd64, loongson, and macppc with this patch. But since it affects all 
archs, testing on the archs I don't have access to will be needed.


OK?

~Brian

Index: elf-bfd.h
===
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elf-bfd.h,v
retrieving revision 1.8
diff -u -p -r1.8 elf-bfd.h
--- elf-bfd.h2 Nov 2004 20:45:06 -1.8
+++ elf-bfd.h16 Feb 2013 22:43:53 -
@@ -1055,8 +1055,8 @@ struct bfd_elf_section_data
 #define elf_discarded_section(sec)\
   (!bfd_is_abs_section (sec)\
 bfd_is_abs_section ((sec)-output_section) \
-sec-sec_info_type != ELF_INFO_TYPE_MERGE \
-sec-sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
+(sec)-sec_info_type != ELF_INFO_TYPE_MERGE  \
+(sec)-sec_info_type != ELF_INFO_TYPE_JUST_SYMS)

 #define get_elf_backend_data(abfd) \
   ((const struct elf_backend_data *) (abfd)-xvec-backend_data)
Index: elflink.c
===
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elflink.c,v
retrieving revision 1.9
diff -u -p -r1.9 elflink.c
--- elflink.c24 Nov 2004 16:55:31 -1.9
+++ elflink.c16 Feb 2013 22:43:56 -
@@ -6239,6 +6239,9 @@ elf_link_output_extsym (struct elf_link_
   return TRUE;
 }

+/* Return TRUE if special handling is done for relocs in SEC against
+   symbols defined in discarded sections.  */
+
 static bfd_boolean
 elf_section_ignore_discarded_relocs (asection *sec)
 {
@@ -6261,6 +6264,26 @@ elf_section_ignore_discarded_relocs (ase
   return FALSE;
 }

+/* Return TRUE if we should complain about a reloc in SEC against a
+   symbol defined in a discarded section.  */
+
+static bfd_boolean
+elf_section_complain_discarded (asection *sec)
+{
+  if (strncmp (.stab, sec-name, 5) == 0
+   (!sec-name[5] ||
+ (sec-name[5] == '.'  ISDIGIT (sec-name[6]
+return FALSE;
+
+  if (strcmp (.eh_frame, sec-name) == 0)
+return FALSE;
+
+  if (strcmp (.gcc_except_table, sec-name) == 0)
+return FALSE;
+
+  return TRUE;
+}
+
 /* Link an input file into the linker output file.  This function
handles all the sections and relocations of the input file at once.
This is so that we only have to read the local symbols once, and
@@ -6532,13 +6555,16 @@ elf_link_input_bfd (struct elf_final_lin
   if (!elf_section_ignore_discarded_relocs (o))
 {
   Elf_Internal_Rela *rel, *relend;
+  bfd_boolean complain = elf_section_complain_discarded (o);

   rel = internal_relocs;
   relend = rel + o-reloc_count * bed-s-int_rels_per_ext_rel;
   for ( ; rel  relend; rel++)
 {
   unsigned long r_symndx = rel-r_info  r_sym_shift;
-  asection *sec;
+  asection **ps, *sec;
+  struct elf_link_hash_entry *h = NULL;
+  const char *sym_name;

   if (r_symndx = locsymcount
   || (elf_bad_symtab (input_bfd)
@@ -6551,79 +6577,70 @@ elf_link_input_bfd (struct elf_final_lin
  || h-root.type == bfd_link_hash_warning)
 h = (struct elf_link_hash_entry *) h-root.u.i.link;

-  /* Complain if the definition comes from a
- discarded section.  */
-  sec = h-root.u.def.section;
-  if ((h-root.type == bfd_link_hash_defined
-   || h-root.type == bfd_link_hash_defweak)
-   elf_discarded_section (sec))
-{
-  if ((o-flags  SEC_DEBUGGING) != 0)
-{
-  BFD_ASSERT (r_symndx != 0);
-  /* Try to preserve debug information.  */
-  if ((o-flags  SEC_DEBUGGING) != 0
-   sec-kept_section != NULL
-   sec-_raw_size == sec-kept_section-_raw_size)
-h-root.u.def.section
-  = sec-kept_section;
-  else
-memset (rel, 0, sizeof (*rel));
-}
-  else
-finfo-info-callbacks-error_handler
-  (LD_DEFINITION_IN_DISCARDED_SECTION,
-   _(%T: discarded in section `%s' from %s\n),
-   h-root.root.string,
-   h-root.root.string,
-   h-root.u.def.section-name,
-   bfd_archive_filename (h-root.u.def.section-owner));
-}
-}
-  else
-{
-  sec = finfo-sections[r_symndx];
-
-  if (sec != NULL  elf_discarded_section (sec))
-{
-  if ((o-flags  SEC_DEBUGGING) != 0
-  

Re: Small binutils tweak

2013-03-02 Thread Brian Callahan

On 3/2/2013 10:36 AM, Brian Callahan wrote:

Hi tech --

While doing some ports testing with clang, I came across the binutils
bug mentioned here:
http://lists.gnu.org/archive/html/bug-binutils/2004-07/msg0.html

Below is a backport of the commit mentioned later in the thread. It
fixes the issue.
I was able to rebuild working kernels and do a full 'make build' on
amd64, loongson, and macppc with this patch. But since it affects all
archs, testing on the archs I don't have access to will be needed.

OK?



To clear up any confusion, this code is taken from the 2.16 time frame. 
It is GPLv2 code. The fix in question is already in the binutils-2.17 
code we have in our tree.



~Brian

Index: elf-bfd.h
===
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elf-bfd.h,v
retrieving revision 1.8
diff -u -p -r1.8 elf-bfd.h
--- elf-bfd.h2 Nov 2004 20:45:06 -1.8
+++ elf-bfd.h16 Feb 2013 22:43:53 -
@@ -1055,8 +1055,8 @@ struct bfd_elf_section_data
  #define elf_discarded_section(sec)\
(!bfd_is_abs_section (sec)\
  bfd_is_abs_section ((sec)-output_section) \
-sec-sec_info_type != ELF_INFO_TYPE_MERGE \
-sec-sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
+(sec)-sec_info_type != ELF_INFO_TYPE_MERGE  \
+(sec)-sec_info_type != ELF_INFO_TYPE_JUST_SYMS)

  #define get_elf_backend_data(abfd) \
((const struct elf_backend_data *) (abfd)-xvec-backend_data)
Index: elflink.c
===
RCS file: /cvs/src/gnu/usr.bin/binutils/bfd/elflink.c,v
retrieving revision 1.9
diff -u -p -r1.9 elflink.c
--- elflink.c24 Nov 2004 16:55:31 -1.9
+++ elflink.c16 Feb 2013 22:43:56 -
@@ -6239,6 +6239,9 @@ elf_link_output_extsym (struct elf_link_
return TRUE;
  }

+/* Return TRUE if special handling is done for relocs in SEC against
+   symbols defined in discarded sections.  */
+
  static bfd_boolean
  elf_section_ignore_discarded_relocs (asection *sec)
  {
@@ -6261,6 +6264,26 @@ elf_section_ignore_discarded_relocs (ase
return FALSE;
  }

+/* Return TRUE if we should complain about a reloc in SEC against a
+   symbol defined in a discarded section.  */
+
+static bfd_boolean
+elf_section_complain_discarded (asection *sec)
+{
+  if (strncmp (.stab, sec-name, 5) == 0
+   (!sec-name[5] ||
+ (sec-name[5] == '.'  ISDIGIT (sec-name[6]
+return FALSE;
+
+  if (strcmp (.eh_frame, sec-name) == 0)
+return FALSE;
+
+  if (strcmp (.gcc_except_table, sec-name) == 0)
+return FALSE;
+
+  return TRUE;
+}
+
  /* Link an input file into the linker output file.  This function
 handles all the sections and relocations of the input file at once.
 This is so that we only have to read the local symbols once, and
@@ -6532,13 +6555,16 @@ elf_link_input_bfd (struct elf_final_lin
if (!elf_section_ignore_discarded_relocs (o))
  {
Elf_Internal_Rela *rel, *relend;
+  bfd_boolean complain = elf_section_complain_discarded (o);

rel = internal_relocs;
relend = rel + o-reloc_count * bed-s-int_rels_per_ext_rel;
for ( ; rel  relend; rel++)
  {
unsigned long r_symndx = rel-r_info  r_sym_shift;
-  asection *sec;
+  asection **ps, *sec;
+  struct elf_link_hash_entry *h = NULL;
+  const char *sym_name;

if (r_symndx = locsymcount
|| (elf_bad_symtab (input_bfd)
@@ -6551,79 +6577,70 @@ elf_link_input_bfd (struct elf_final_lin
   || h-root.type == bfd_link_hash_warning)
  h = (struct elf_link_hash_entry *) h-root.u.i.link;

-  /* Complain if the definition comes from a
- discarded section.  */
-  sec = h-root.u.def.section;
-  if ((h-root.type == bfd_link_hash_defined
-   || h-root.type == bfd_link_hash_defweak)
-   elf_discarded_section (sec))
-{
-  if ((o-flags  SEC_DEBUGGING) != 0)
-{
-  BFD_ASSERT (r_symndx != 0);
-  /* Try to preserve debug information.  */
-  if ((o-flags  SEC_DEBUGGING) != 0
-   sec-kept_section != NULL
-   sec-_raw_size == sec-kept_section-_raw_size)
-h-root.u.def.section
-  = sec-kept_section;
-  else
-memset (rel, 0, sizeof (*rel));
-}
-  else
-finfo-info-callbacks-error_handler
-  (LD_DEFINITION_IN_DISCARDED_SECTION,
-   _(%T: discarded in section `%s' from %s\n),
-   h-root.root.string,
-   h-root.root.string,
-   h-root.u.def.section-name,
-   bfd_archive_filename (h-root.u.def.section-owner

Re: OpenBSD/hppa port B1000 PCI bug during load of existing cardbus adapter driver

2013-02-17 Thread Brian Callahan

On 2/17/2013 5:29 AM, Ivan Solonin wrote:

Hello.

 I've tested 2 different PCI PCMCIA/CardBus adapters known to
OpenBSD with the latest snapshot GENERIC kernel but no one of them has
reached operational state. Both adapters work on i386 machines.



Is this related to the hppa page stating that
pcmcia(4) PCMCIA adapters.
as an unsupported peripheral?

~Brian