@@ -112,6 +112,7 @@ bool Library::load(const tinyxml2::XMLDocument &doc)
112112 bool notuninit = false ;
113113 bool formatstr = false ;
114114 bool strz = false ;
115+ std::string valid;
115116 for (const tinyxml2::XMLElement *argnode = functionnode->FirstChildElement (); argnode; argnode = argnode->NextSiblingElement ()) {
116117 if (strcmp (argnode->Name (), " not-null" ) == 0 )
117118 notnull = true ;
@@ -121,13 +122,33 @@ bool Library::load(const tinyxml2::XMLDocument &doc)
121122 formatstr = true ;
122123 else if (strcmp (argnode->Name (), " strz" ) == 0 )
123124 strz = true ;
125+ else if (strcmp (argnode->Name (), " valid" ) == 0 ) {
126+ // Validate the validation expression
127+ const char *p = argnode->GetText ();
128+ if (!std::isdigit (*p))
129+ return false ;
130+ for (; *p; p++) {
131+ if (std::isdigit (*p))
132+ continue ;
133+ if (*p == ' -' && std::isdigit (*(p-1 )))
134+ continue ;
135+ if (*p == ' ,' && *(p+1 ) != ' ,' )
136+ continue ;
137+ return false ;
138+ }
139+
140+ // Set validation expression
141+ valid = argnode->GetText ();
142+ }
143+
124144 else
125145 return false ;
126146 }
127- argumentChecks[name][nr].notnull = notnull;
147+ argumentChecks[name][nr].notnull = notnull;
128148 argumentChecks[name][nr].notuninit = notuninit;
129149 argumentChecks[name][nr].formatstr = formatstr;
130- argumentChecks[name][nr].strz = strz;
150+ argumentChecks[name][nr].strz = strz;
151+ argumentChecks[name][nr].valid = valid;
131152 } else if (strcmp (functionnode->Name (), " ignorefunction" ) == 0 ) {
132153 _ignorefunction[name] = (strcmp (functionnode->GetText (), " true" ) == 0 );
133154 } else
0 commit comments