Re: [PATCH V2 6/6] scripts/kconfig/nconf: trunc too long string display in menu

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

 



On Wed, Aug 31, 2011 at 1:53 AM, Nir Tzachar <nir.tzachar@xxxxxxxxx> wrote:
> Hi.
>
> On Wed, Aug 31, 2011 at 10:46 AM, Cheng Renquan <crquan@xxxxxxxxx> wrote:
>> When the string is too long, only show the first COLS/2 bytes wide,
>> to make sure there is some space to show the menu prompt.
>>
>> Signed-off-by: Cheng Renquan <crquan@xxxxxxxxx>
>> ---
>>  scripts/kconfig/nconf.c |    8 +++++++-
>>  1 files changed, 7 insertions(+), 1 deletions(-)
>>
>> diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
>> index 4248759..4997ebf 100644
>> --- a/scripts/kconfig/nconf.c
>> +++ b/scripts/kconfig/nconf.c
>> @@ -887,8 +887,14 @@ static void build_conf(struct menu *menu)
>>                                break;
>>                        default:
>>                                tmp = 2 + strlen(sym_get_string_value(sym));
>> -                               item_make(menu, 's', "    (%s)",
>> +                               if (tmp < COLS/2)
>> +                                       item_make(menu, 's', "    (%s)",
>>                                                sym_get_string_value(sym));
>> +                               else {
>> +                                       char *s = strndupa(sym_get_string_value(sym), COLS/2);
>> +                                       strcpy(s + COLS/2 - 5, " ...");
>> +                                       item_make(menu, 's', "    (%s)", s);
>> +                               }
>>                                tmp = indent - tmp + 4;
>>                                if (tmp < 0)
>>                                        tmp = 0;
>> --
>> 1.7.6
>>
>>
>
> Nack.
>
> I see several problems with this approach:
> 1) I do not like the use of strdupa.
Then strdup ? OK, strdupa may be glibc only but strdup should be generic,

> 2) I think it would be better to put this behavior in item_make(), as
> it will then be applied to all items, in all code paths. However, I a
> not sure that using COLS/2 is the best approach. Moreover, I think
> that this should be implemented inside the ncurses menu library and
> not worked around. Care to create a patch for ncurses?

In item_make it doesn't know if it will be followed by item_add_str,
but here our issue is sym value part too long, only in outside item_make
(the build_conf) it is aware about subsequent item_add_str, only there
we could reserve some space for menu prompt to pass to item_add_str;

but how much space do we better to reserve? the COLS/2 is just a
guessed value by me,

Even in patch for ncurses it can only truncate the string tail, no
help for our issue;

>
> Cheers,
> Nir.
��.n��������+%������w��{.n�����{��F���{ay�ʇڙ���f���h������_�(�階�ݢj"��������G����?���&��



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux