diff --git a/src/factory/FieldCreateFactory.cpp b/src/factory/FieldCreateFactory.cpp index bcf7038..696b3a1 100644 --- a/src/factory/FieldCreateFactory.cpp +++ b/src/factory/FieldCreateFactory.cpp @@ -948,14 +948,19 @@ StructureConstPtr FieldCreate::createStructure () const } namespace { +bool xisalnum(char c) +{ + return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9'); +} + void validateFieldName(const std::string& n) { + if(n.size()==0) + throw std::invalid_argument("zero length field names not allowed"); for(size_t i=0, N=n.size(); i='a' && c<='z') {} - else if(c>='A' && c<='Z') {} - else if(c>='0' && c<='9') {} + if(xisalnum(c)) {} else { switch(c){ case '_': diff --git a/testApp/pv/testPVData.cpp b/testApp/pv/testPVData.cpp index 000d808..6d061e8 100644 --- a/testApp/pv/testPVData.cpp +++ b/testApp/pv/testPVData.cpp @@ -79,6 +79,7 @@ static void testCreatePVStructureWithInvalidName() fieldNames,pvFields); testFail("Creation of invalid field name '%s' was allowed", fieldNames[1].c_str()); } catch(std::invalid_argument& e) { + testDiag("Exception: \"%s\"", e.what()); testPass("Creation of invalid field name '%s' fails as expected", fieldNames[1].c_str()); } }