Ignore:
Timestamp:
05/23/16 13:50:18 (8 years ago)
Author:
Maciej Komosinski
Message:

No trailing space in full name when last name is empty

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/model/autoname.cpp

    r348 r512  
    1111        SString t;
    1212        t = firstName(model);
    13         t += ' ';
    14         t += lastName(model);
     13        SString last=lastName(model);
     14        if (last.len()>0)
     15                {
     16                t += ' ';
     17                t += last;
     18                }
    1519        return t;
    1620}
     
    3337}
    3438
    35 SString AutoName::firstName(Model& model)
     39SString AutoName::firstName(const SString& g)
    3640{
    3741        char buf[8];
    3842        unsigned int s1 = 0, s2 = 0, s3 = 0;
    39         SString g = model.getGeno().getGene();
    4043        const char *x = g.c_str();
     44        if (*x==0) return SString();
    4145        for (; *x; x++) { s1 += *x; s2 = s2**x + *x; s3 = (s3^*x) + *x; }
    4246        char* t = buf;
     
    4650        buf[0] = (char)toupper(buf[0]);
    4751        return SString(buf);
     52}
     53
     54SString AutoName::firstName(Model& model)
     55{
     56        return firstName(model.getGeno().getGene());
    4857}
    4958
Note: See TracChangeset for help on using the changeset viewer.