svn commit: r268491 - head/usr.bin/users

Ed Schouten ed at 80386.nl
Thu Jul 10 15:04:57 UTC 2014


Hi there,

On 10 July 2014 14:15, Pietro Cerutti <gahr at freebsd.org> wrote:
>   Reimplements users(1) in C++.
>
>   This reduces the lines of code by roughly 50% (not counting the COPYRIGHT
>   header) and makes it more readable by using standard algorithms.

Interesting. More C++ in our base system. :-)

> Modified: head/usr.bin/users/Makefile
> ==============================================================================
> --- head/usr.bin/users/Makefile Thu Jul 10 11:20:24 2014        (r268490)
> +++ head/usr.bin/users/Makefile Thu Jul 10 12:15:02 2014        (r268491)
> @@ -1,6 +1,7 @@
>  #      @(#)Makefile    8.1 (Berkeley) 6/6/93
>  # $FreeBSD$
>
> -PROG=  users
> +WARNS=         3
> +PROG_CXX=      users
>
>  .include <bsd.prog.mk>

Why does this require WARNS to be set to 3? For brand new code, I
would have expected that it would just build with WARNS=6.

> +using namespace std;

Out of curiosity, do we have any style guidelines w.r.t. C++? For
example, I would personally not use things like "using namespace std".
It becomes hard to figure out where symbols come from.

> +       sort(begin(names), end(names));
> +       vector<string>::iterator last(unique(begin(names), end(names)));

This could also just be a std::set, right?

Even though I actually think C++ is a lot nicer than C, do we really
think it is actually worth proactively replacing already existent
tools? This specific tool has now become three times as big as the
previous version (7128 -> 23840 bytes).

-- 
Ed Schouten <ed at 80386.nl>


More information about the svn-src-head mailing list