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

Bug#219902: anna: cuts off the last character in the udeb description



On Mon, Nov 10, 2003 at 04:00:12AM +0100, Steinar H. Gunderson wrote:
> In the list of modules to fetch, anna seems to cut off the last
> character from some of the descriptions. This might be a bit confusing
> to the user. :-)

Actually this seems to be a libd-i bug. src/package_parser.c:312 and out
reads

  temp = memchr (value->string, '\n', value->size);
  if (temp)
  {
    p->short_description = di_stradup (value->string, temp - value->string - 1);
    p->description = di_stradup (temp, (value->string + value->size) - temp - 1);
  }
  else
    p->short_description = di_stradup (value->string, value->size);

As the second parameter to di_stradup() is the number of characters
(excluding the terminating zero), "temp - value->string" is exactly the
length of the string excluding the newline, and the -1 subtracts one too
much.

I'm a bit unsure if I should remove the "- 1" for the second line too,
though, since I'm unable to understand what it's actually supposed to be
doing. Is the long description supposed to start with an "\n", as it does
now? Why the () around "value->string + value->size"? It looks like the code
fragment is trying to find the end of the string, subtract temp from that
(thus finding the length, _including_ both the final and initial newlines),
and finally subtracting one to remove the final newline. Should just "temp"
be changed to "temp+1" here? Or should there be a "- 2" instead of "- 1",
actually?

/* Steinar */
-- 
Homepage: http://www.sesse.net/



Reply to: