text
stringlengths
0
2.2M
if (index != bsl::string::npos) {
(*expected)[index] = ',';
}
}
if (index != bsl::string::npos) {
bsl::string::size_type length = 0;
while (isdigit((*expected)[index + length + 1])) {
++length;
}
int precision = configuration.fractionalSecondPrecision();
if (precision > maxPrecision) {
precision = maxPrecision;
}
if (0 == precision) {
expected->erase(index, length + 1);
}
else if (precision < static_cast<int>(length)) {
expected->erase(index + precision + 1,
length - precision);
}
}
// If there aren't enough characters in 'expected', don't bother with the
// other configuration options.
const int ZONELEN = static_cast<int>(sizeof "+dd:dd") - 1;
if (expected->length() < ZONELEN
|| (!configuration.useZAbbreviationForUtc()
&& !configuration.omitColonInZoneDesignator())) {
return; // RETURN
}
// See if the tail of 'expected' has the pattern of a zone designator.
const bsl::string::size_type zdx = expected->length() - ZONELEN;
if (('+' != (*expected)[zdx] && '-' != (*expected)[zdx])
|| !isdigit(static_cast<unsigned char>((*expected)[zdx + 1]))
|| !isdigit(static_cast<unsigned char>((*expected)[zdx + 2]))
|| ':' != (*expected)[zdx + 3]
|| !isdigit(static_cast<unsigned char>((*expected)[zdx + 4]))
|| !isdigit(static_cast<unsigned char>((*expected)[zdx + 5]))) {
return; // RETURN
}
if (configuration.useZAbbreviationForUtc()) {
const bsl::string zone = expected->substr(
expected->length() - ZONELEN);
if (0 == zone.compare("+00:00")) {
expected->erase(expected->length() - ZONELEN);
expected->push_back('Z');
return; // RETURN
}
}
if (configuration.omitColonInZoneDesignator()) {
const bsl::string::size_type index = expected->find_last_of(':');
if (index != bsl::string::npos) {
expected->erase(index, 1);
}
}
}
static
bool containsOnlyDigits(const char *string)
// Return 'true' if the specified 'string' contains nothing but digits, and
// 'false' otherwise.
{
while (*string) {
if (!isdigit(*string)) {
return false; // RETURN
}
++string;
}
return true;
}
//=============================================================================
// MAIN PROGRAM
//-----------------------------------------------------------------------------
int main(int argc, char *argv[])
{
const int test = argc > 1 ? atoi(argv[1]) : 0;
const bool verbose = argc > 2;
const bool veryVerbose = argc > 3;
const bool veryVeryVerbose = argc > 4;
const bool veryVeryVeryVerbose = argc > 5;
(void)veryVeryVerbose; // eliminate unused variable warning