Re: [PATCH] [BUILTIN] Allow SIG* signal names.

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

 



On Mon, Jul 2, 2012 at 4:22 PM, Eric Blake <eblake@xxxxxxxxxx> wrote:
> On 07/02/2012 08:11 AM, Paul Gilmartin wrote:
>> On Jul 2, 2012, at 07:51, Eric Blake wrote:
>>>
>>> ... non-required bloat ...
>>>
>> The key phrase.  And one value of a shell lacking such
>> extensions is that it provides an excellent test bed for
>> code intended to be portable within the POSIX spec.
>
> That argues that we should drop our strcasecmp() for the much simpler
> strcmp(), in order to remove the bloat we already have.

I guess my patch has no chance to be accepted.  But I'm still curious
about what kind of "bloat" you are referring to.  I'm assuming it's not
code bloat in terms of lines of code.

If the signal name to number conversion seems too expensive (linear
search multiplied by the string lengths, wether it is case sensitive or
not), there is a much more elegant solution: perfect hashing.

Since the set of signal names to be recognized is known at compile time,
you can use a perfect hash function generator like GNU Perf [1] which
minimizes character comparisons in order to return the desired constant
assigned to a name/symbol/token/whatever-string.

Furthermore, you could even support POSIX and SIG* prefixed names,
wether they are case sensitive or not, at no additional cost.  Gperf is
a comple time dependency so the final binary can remain only linked to
libc.

Best regards.

-- 
Isaac Jurado

"The noblest pleasure is the joy of understanding"
Leonardo da Vinci
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux