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


> 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 -0000       1.20
> +++ extern.h  29 May 2017 19:44:43 -0000
> @@ -56,6 +56,7 @@ void         logname(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 -0000       1.69
> +++ print.c   29 May 2017 19:44:43 -0000
> @@ -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 -0000      1.1
> +++ utf8.c    29 May 2017 19:44:43 -0000
> @@ -23,6 +23,8 @@
>  #include <vis.h>
>  #include <wchar.h>
>  
> +#include "ps.h"
> +
>  int
>  mbswprint(const char *mbs, int maxwidth, int trail)
>  {

Reply via email to