← Back to team overview

kicad-developers team mailing list archive

Re: StrNumCmp

 


Am 04.12.2016 um 13:33 schrieb jp charras:
It is similar to a string comparison (for string sorting) but unlike the usual strncmp() or
strncasecmp() functions, when digits are encountered in a string, they are converted to a number and
this is the number value which is taken in account for comparison.

This is especially useful to sort component references or value.
For instance:
when the 2 strings U12 and U2 are compared by ASCII value:
In usual comparison (from ASCII value), U120 is sorted before U20
In StrNumCmp:
120 is read as a integer value
20  is read as a integer value
and comparisons are between U<120> and U<20> where <120> and <20> are integers, not chars.

and U120 is sorted after U20

Hello Jean-Pierre,

thank you for the information.
So a numeric character range is to be treated as one character position whose value its the parsed number, right? Is the aLength parameter designed to mean raw character counts, or character/number positions? Would "U12" compare smaller to "U2" at aLength == 2? Cases like "U12A4A3" vs. "U12A4A4" are also specified where the latter would compare "greater", yes?

Michael



Follow ups

References