coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About code


From: Eric Blake
Subject: Re: About code
Date: Thu, 12 Jan 2017 16:55:58 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0

On 01/12/2017 03:53 PM, francisco dominguez wrote:
> I have a little doubt as to the gnu code, why is it so complex and long?
> Other systems facing the same problem have a much simpler implementation,
> for example the ls command in gnu:
> 
> http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/ls.c;h=556313c71ebeb853c3fe9cf3c0312639de8aded0;hb=HEAD
> 
> And in other system, for example, freebsd, is more simple:
> 
> https://github.com/freebsd/freebsd/blob/master/bin/ls/ls.c

Most likely because GNU ls has more features than FreeBSD ls.  There's
probably also some code cost for robustness issues (such as trying hard
for minimal-width columns that are always aligned, rather than being
lazy by over-spacing things or having an extra-wide column throw off
alignment of the remaining columns).

There's other things factoring into your comparison: the files you point
to show less than 1000 lines for FreeBSD ls.c, compared to more than
5000 lines for GNU ls.c, but you did not account for how many lines are
in other files that get linked together to form the final executable.
For example, a quick search of the BSD code shows a variable named
'attrs_off' which is only referenced twice in the file, so to find how
the variable is actually used you have to go browsing around for another
.c file.  So file size is a very poor measure of executable complexity.

Your question is very broad.  Is there any specific feature that you are
comparing side-by-side, and wondering what the difference is?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]