pit_type as unsigned
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Tue May 12 15:47:17 UTC 2020
Le 11/05/2020 à 23:55, Richard Kimberly Heck a écrit :
> On 5/11/20 7:00 AM, Jean-Marc Lasgouttes wrote:
>> What about the patch below? I find it ridiculous (and slow) to use
>> next() to access our random access container. I am surprised though by
>> this issue, since using 'begin() + i' in things like insert or erase
>> is supposed to be normal.
>
> Yes, that seems much cleaner.
OK, I committed it, then.
>> What do you have in TextMetrics?
> h += pm.height();
>
> dim_.des = h - dim_.asc;
>
> With h an unsigned int.
I changed it to unsigned.
> This one's a bit weirder:
>
> l_margin += bfm.signedWidth(layout.leftmargin) * 4
> / (par.getDepth() + 4);
>
> Here, l_margin is an int; getDepth() returns unsigned; so the convesion
> is actually of bfm.signedWidth. Can l_margin be negative?
signedWidth can be negative in theory. In this case l_margin would be
negative. What does the margin say? How would I get it? -Wextra?
> This is the vector sort of case I mentioned (not to do with pit_type):
>
> Row const & r = pm.rows()[row];
>
> Here row is an int but vector::size_type is unsigned long.
We could introduce an unsigned row_type for that. Or use size_t instead
of int. What would you prefer?
>>> * It is not clear that depth needs to be an int instead of a depth_type
>>>>
>>>> @@ -1635,7 +1635,7 @@ int TextMetrics::leftMargin(pit_type const pit,
>>>> pos_type const pos) const
>>>> l_margin += bfm.signedWidth(tclass.leftmargin());
>>>> }
>>>>
>>>> - int depth = par.getDepth();
>>>> + int depth = int(par.getDepth());
>>>
>>> I can change it, but then it throws a different warning here:
>>>
>>> int nestmargin = depth * nestMargin();
>>
>> Because nestMargin is naturally unsigned?
>
> I would have thought so, but I often find myself unsure whether
> something could be negative. Perhaps what I should do is just flag these
> cases for someone else to verify?
Yes. But I would need to know how to get the warnings. What compiler?
JMarc
More information about the lyx-devel
mailing list