| 1098 | // local implementations |
| 1099 | namespace { |
| 1100 | bool parseTime(const std::string& ts, int64_t& time) { |
| 1101 | std::string hstr; |
| 1102 | std::string mstr; |
| 1103 | std::string sstr; |
| 1104 | auto cts = new char[ts.length() + 1]; |
| 1105 | strcpy(cts, ts.c_str()); |
| 1106 | auto tmp = ::strtok(cts, ":"); |
| 1107 | if (tmp) |
| 1108 | hstr = tmp; |
| 1109 | tmp = ::strtok(nullptr, ":"); |
| 1110 | if (tmp) |
| 1111 | mstr = tmp; |
| 1112 | tmp = ::strtok(nullptr, ":"); |
| 1113 | if (tmp) |
| 1114 | sstr = tmp; |
| 1115 | delete[] cts; |
| 1116 | |
| 1117 | int sign = 1; |
| 1118 | int64_t hh = 0; |
| 1119 | int64_t mm = 0; |
| 1120 | int64_t ss = 0; |
| 1121 | // [-]HH part |
| 1122 | if (!Util::strtol(hstr.c_str(), hh)) |
| 1123 | return false; |
| 1124 | if (hh < 0) { |
| 1125 | sign = -1; |
| 1126 | hh *= -1; |
| 1127 | } |
| 1128 | // check for the -0 special case |
| 1129 | if (hh == 0 && Exiv2::Internal::contains(hstr, '-')) |
| 1130 | sign = -1; |
| 1131 | // MM part, if there is one |
| 1132 | if (!mstr.empty()) { |
| 1133 | if (!Util::strtol(mstr.c_str(), mm)) |
| 1134 | return false; |
| 1135 | if (mm > 59) |
| 1136 | return false; |
| 1137 | if (mm < 0) |
| 1138 | return false; |
| 1139 | } |
| 1140 | // SS part, if there is one |
| 1141 | if (!sstr.empty()) { |
| 1142 | if (!Util::strtol(sstr.c_str(), ss)) |
| 1143 | return false; |
| 1144 | if (ss > 59) |
| 1145 | return false; |
| 1146 | if (ss < 0) |
| 1147 | return false; |
| 1148 | } |
| 1149 | |
| 1150 | time = sign * (hh * 3600 + mm * 60 + ss); |
| 1151 | return true; |
| 1152 | } // parseTime |
| 1153 | |
| 1154 | void printUnrecognizedArgument(const char argc, const std::string& action) { |
| 1155 | std::cerr << Params::instance().progname() << ": " << _("Unrecognized ") << action << " " << _("target") << " `" |
no test coverage detected