File tree 1 file changed +4
-10
lines changed
1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change 21
21
#include < unordered_set>
22
22
#include < cctype> // std::isdigit
23
23
#include < algorithm>
24
+ #include < regex>
24
25
25
26
#include " blifparse.hpp"
26
27
#include " atom_netlist.h"
@@ -720,22 +721,15 @@ bool is_binary_param(const std::string& param) {
720
721
}
721
722
722
723
bool is_real_param (const std::string& param) {
723
- const std::string real_chars = " 0123456789." ;
724
724
725
725
/* Must be non-empty */
726
726
if (param.empty ()) {
727
727
return false ;
728
728
}
729
729
730
- /* The string mustn't contain any other chars that the expected ones */
731
- for (size_t i = 0 ; i < param.length (); ++i) {
732
- if (real_chars.find (param[i]) == std::string::npos) {
733
- return false ;
734
- }
735
- }
736
-
737
- /* There must only be a single dot */
738
- if (std::count (param.begin (), param.end (), ' .' ) != 1 ) {
730
+ /* The string must match the regular expression */
731
+ static const std::regex real_number_expr (" [+-]?([0-9]*\\ .[0-9]+)|([0-9]+\\ .[0-9]*)" );
732
+ if (!std::regex_match (param, real_number_expr)) {
739
733
return false ;
740
734
}
741
735
You can’t perform that action at this time.
0 commit comments