Rename QUtil::strcasecmp to QUtil::str_compare_nocase (fixes #242)

This commit is contained in:
Jay Berkenbilt 2019-06-21 18:38:03 -04:00
parent bd8918fffc
commit c6cfd64503
5 changed files with 17 additions and 7 deletions

View File

@ -1,3 +1,12 @@
2019-06-21 Jay Berkenbilt <ejb@ql.org>
* Source-level incompatibility: rename QUtil::strcasecmp to
QUtil::str_compare_nocase. This is a non-compatible change, but
QUtil::strcasecmp is hardly the most important part of qpdf's API.
The reason for this change is that strcasecmp is a macro on some
systems, and that was causing problems when QUtil.hh was included
in certain circumstances. Fixes #242.
2019-06-20 Jay Berkenbilt <ejb@ql.org>
* Enable compilation with additional warnings for integer

3
TODO
View File

@ -1,9 +1,6 @@
Next ABI
========
* Rename QUtil::strcasecmp since strcasecmp is a macro on some
platforms. See #242.
* Get rid of the version of QPDF::copyForeignObject with the bool
unused parameter.

View File

@ -305,8 +305,11 @@ namespace QUtil
QPDF_DLL
std::list<std::string> read_lines_from_file(std::istream&);
// This used to be called strcasecmp, but that is a macro on some
// platforms, so we have to give it a name that is not likely to
// be a macro anywhere.
QPDF_DLL
int strcasecmp(char const *, char const *);
int str_compare_nocase(char const *, char const *);
// These routines help the tokenizer recognize certain character
// classes without using ctype, which we avoid because of locale

View File

@ -997,14 +997,14 @@ QUtil::read_lines_from_file(std::istream& in)
}
int
QUtil::strcasecmp(char const *s1, char const *s2)
QUtil::str_compare_nocase(char const *s1, char const *s2)
{
#if defined(_WIN32) && defined(__BORLANDC__)
return stricmp(s1, s2);
#elif defined(_WIN32)
return _stricmp(s1, s2);
#else
return ::strcasecmp(s1, s2);
return strcasecmp(s1, s2);
#endif
}

View File

@ -4981,7 +4981,8 @@ static void write_outfile(QPDF& pdf, Options& o)
after = num_spot + 2;
}
else if ((len >= 4) &&
(QUtil::strcasecmp(o.outfilename + len - 4, ".pdf") == 0))
(QUtil::str_compare_nocase(
o.outfilename + len - 4, ".pdf") == 0))
{
QTC::TC("qpdf", "qpdf split-pages .pdf");
before = std::string(o.outfilename, len - 4) + "-";