MySQL++

Check-in [80a2d7ba1d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added a cast in FieldNames::operator[] to squish a warning about possible data loss in a condition that can't practically happen.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:80a2d7ba1df080304add10ebe50609101e156b3a01a158b48d6429dcabc69460
User & Date: tangent 2018-10-22 23:41:52
Context
2018-10-22
23:55
Removed explicit library dependency on "mysqlpp" for test_ssqls2 and ssqlsxlat: we get that from the Bakefile "programs" template we defined. Not only is it redundant, the second declaration breaks under VC++ due to the "_d" suffix in debug builds, which the program template handles for us, but our per-program dependency did not. check-in: 5719c93687 user: tangent tags: trunk
23:41
Added a cast in FieldNames::operator[] to squish a warning about possible data loss in a condition that can't practically happen. check-in: 80a2d7ba1d user: tangent tags: trunk
23:37
Squished warning C4003 for VC++: yes, we know we're passing no args to MAY_THROW(), on purpose. Thank you so much for being helpful, VC++. check-in: 6f22016ae8 user: tangent tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/field_names.cpp.

53
54
55
56
57
58
59
60






61
62
63
64
65
66
67
{
	std::string temp1(s);
	internal::str_to_lwr(temp1);
	for (const_iterator it = begin(); it != end(); ++it) {
	std::string temp2(*it);
		internal::str_to_lwr(temp2);
		if (temp2.compare(temp1) == 0) {
			return it - begin();






		}
	}

	return end() - begin();
}

} // end namespace mysqlpp







|
>
>
>
>
>
>



|



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
	std::string temp1(s);
	internal::str_to_lwr(temp1);
	for (const_iterator it = begin(); it != end(); ++it) {
	std::string temp2(*it);
		internal::str_to_lwr(temp2);
		if (temp2.compare(temp1) == 0) {
			// The cast is necessary for compilers where sizeof(int) !=
			// sizeof (void*) with sufficiently good warnings.  Yes,
			// technically this does risk data loss, but for that to
			// happen you'd have to have more than 2^(sizeof(int)*8)-1
			// fields in your table.  If you do that, you deserve to
			// lose anyway.
			return (unsigned int)(it - begin());
		}
	}

	return (unsigned int)(end() - begin());	// same as above
}

} // end namespace mysqlpp