← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Rewrite test for valid characters in names

 

Hi,

> I agree that the assignment is non-standard and probably should be
> updated.  However, if we're going to re-write this, would you be up for
> doing it with std:: algorithms?

I've thought about this too, but as this function looks at each character
in isolation, we'd end up with a fairly backwards "is this character part
of the string" check, run once for each character.

I've dropped the illegal characters that are covered by the "printable
character" rule already, leaving two unconditionally forbidden characters,
and two that are dependent on the name type.

I can make the code a bit more readable probably by

    bool const colon_allowed = ( aType == ID_ALIAS );
    bool const space_allowed = ( aType != ID_SCH );

instead of the nested switch statement, but this is only an improvement if
these conditions are close to the actual rationale for allowing/disallowing
these characters, which I'm not entirely sure about.

The alternative would be to replace our hand-rolled iteration over the
characters and use some existing "find_first_of" like thing over the entire
string, but I was angling for a minimal change.

   Simon


Follow ups

References