Ответ: CONFIG

Vladimir Dronnikov dronnikov at gmail.com
Thu Jul 17 19:44:32 UTC 2008


Agreed. Let us pass parameters to config_open(). Seems there are no
applets that would use the full flexibility of
config_read(all-the-changing-stuff). If so, there is no need to pack
min and max, let us be clear.
I'll send a patch soon.

--
Vladimir


2008/7/17, Denys Vlasenko <vda.linux at googlemail.com>:
> CC: busybox at busybox.net
>
> On Thursday 17 July 2008 21:33, Denys Vlasenko wrote:
>> On Thursday 17 July 2008 20:41, dronnikov at gmail.com wrote:
>> > 0. Recent patch by Bernhard made mdev fail testsuite. Analysis led to
>> > config_open() which should not
>> > fclose(unopened_file) and free(unalloced_memory), IMO.
>> >
>> > 1. Reduced the number of parameters. The idea is to have flags for finer
>> > "delimiting" control.
>> > Since comment is a char, I packed it to the very first char of delims.
>> > Quite elegant and intuitive IMHO.
>> >
>> > 2. Introduced PARSE_DONT_TRIM flag. The problem was: how to handle the
>> > leading and trailing delimiters
>> > when PARSE_DONT_REDUCE is set? If a delimiter is treated as
>> > non-reduceable then why on earth the leading
>> > (and trailing) delimiters are just thrown? Thus the new flag. Those who
>> > wants to deal with every delimiter
>> > should set both PARSE_DONT_TRIM and PARSE_DONT_REDUCE flags.
>> >
>> > 3. When config_read() returns 0 there NOTHING has been parsed! So using
>> > tokens[0] segfaults. Thus changed the
>> > failure return value from -1 to 0 (no need to know whether there were no
>> > lines, or all lines were empty, IMO)
>> > and conditions in applets.
>> >
>> > Please comment and consider applying.
>>
>> This surely looks confusing and too long:
>>
>> +		while (config_read(parser, tokens, config_params(0, 4, 3), "# \t") > 0)
>> {
>>
>> I propose either doing this in libbb.h:
>>
>> #define config_read(parser, tokens, flags, min, max, str) \
>> 	config_read(parser, tokens, (flags) | (((min) & 0xFF) << 8) | ((max) &
>> 0xFF)), str)
>>
>> or giving these flags, min, max, str params to config_open(),
>> or even both, but leaving it as is the patch does not look good.
>> --
>> vda
>



More information about the busybox mailing list