Skip to content

Commit

Permalink
allow ' for feet and " for inches
Browse files Browse the repository at this point in the history
  • Loading branch information
radj307 committed Aug 20, 2022
1 parent 204466a commit 39e42ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ckconv/conv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ namespace conv {
if (str == "rd" || s.find("rod") < s.size())
return *Imperial.ROD;
#endif // DISABLE_NUTJOB_UNITS
if (str == "in" || s == "i" || s.find("inch") < s.size())
if (str == "\"" || str == "in" || s == "i" || s.find("inch") < s.size())
return *Imperial.INCH;
if (str == "ft" || s == "f" || s.find("foot") < s.size() || s.find("feet") < s.size())
if (str == "\'" || str == "ft" || s == "f" || s.find("foot") < s.size() || s.find("feet") < s.size())
return *Imperial.FOOT;
if (str == "yd" || s.find("yard") < s.size())
return *Imperial.YARD;
Expand Down
3 changes: 1 addition & 2 deletions ckconv/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ namespace ckconv {
ss << global.csync(global.ResultColor) << outValue_s << global.csync();

if (!global.quiet)
ss
<< ' ' << global.csync(global.UnitColor) << outUnit_s << global.csync();
ss << ' ' << global.csync(global.UnitColor) << outUnit_s << global.csync();

return ss.str();
}
Expand Down
5 changes: 2 additions & 3 deletions ckconv/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@ namespace ckconv {
for (const auto& c : s) {
if (str::stdpred::isdigit(c))
digit = true;
else if (str::stdpred::isalpha(c))
else if (str::stdpred::isalpha(c) || c == '\'' || c == '\"')
alpha = true;
else if (c == '.') {
if (++decimalPointCount > 1)
throw make_exception("Input '", s, "' isn't valid! (Too many decimal places)");
}
else if (c == '-') {
if (digit)
throw make_exception("Input '", s, "' isn't valid! (Negative sign must precede number)");
if (digit) throw make_exception("Input '", s, "' isn't valid! (Negative sign must precede number)");
}
else {
invalid = true;
Expand Down

0 comments on commit 39e42ea

Please sign in to comment.