Skip to content

Commit 3b559de

Browse files
committed
Interpret "abc9 -lut" as lut string only if [0-9:]
1 parent f52c6ef commit 3b559de

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

passes/techmap/abc9.cc

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -981,29 +981,28 @@ struct Abc9Pass : public Pass {
981981
//}
982982
if (arg == "-lut" && argidx+1 < args.size()) {
983983
string arg = args[++argidx];
984-
size_t pos = arg.find_first_of(':');
985-
int lut_mode = 0, lut_mode2 = 0;
986-
if (pos != string::npos) {
987-
lut_mode = atoi(arg.substr(0, pos).c_str());
988-
lut_mode2 = atoi(arg.substr(pos+1).c_str());
989-
} else {
990-
pos = arg.find_first_of('.');
984+
if (arg.find_first_not_of("0123456789:") == std::string::npos) {
985+
size_t pos = arg.find_first_of(':');
986+
int lut_mode = 0, lut_mode2 = 0;
991987
if (pos != string::npos) {
992-
lut_file = arg;
993-
rewrite_filename(lut_file);
994-
if (!lut_file.empty() && !is_absolute_path(lut_file))
995-
lut_file = std::string(pwd) + "/" + lut_file;
996-
}
997-
else {
988+
lut_mode = atoi(arg.substr(0, pos).c_str());
989+
lut_mode2 = atoi(arg.substr(pos+1).c_str());
990+
} else {
998991
lut_mode = atoi(arg.c_str());
999992
lut_mode2 = lut_mode;
1000993
}
994+
lut_costs.clear();
995+
for (int i = 0; i < lut_mode; i++)
996+
lut_costs.push_back(1);
997+
for (int i = lut_mode; i < lut_mode2; i++)
998+
lut_costs.push_back(2 << (i - lut_mode));
999+
}
1000+
else {
1001+
lut_file = arg;
1002+
rewrite_filename(lut_file);
1003+
if (!lut_file.empty() && !is_absolute_path(lut_file) && lut_file[0] != '+')
1004+
lut_file = std::string(pwd) + "/" + lut_file;
10011005
}
1002-
lut_costs.clear();
1003-
for (int i = 0; i < lut_mode; i++)
1004-
lut_costs.push_back(1);
1005-
for (int i = lut_mode; i < lut_mode2; i++)
1006-
lut_costs.push_back(2 << (i - lut_mode));
10071006
continue;
10081007
}
10091008
if (arg == "-luts" && argidx+1 < args.size()) {
@@ -1072,7 +1071,7 @@ struct Abc9Pass : public Pass {
10721071
box_file = "+/dummy.box";
10731072

10741073
rewrite_filename(box_file);
1075-
if (!box_file.empty() && !is_absolute_path(box_file))
1074+
if (!box_file.empty() && !is_absolute_path(box_file) && box_file[0] != '+')
10761075
box_file = std::string(pwd) + "/" + box_file;
10771076

10781077
dict<int,IdString> box_lookup;

0 commit comments

Comments
 (0)