From c6cfd6450334cc09d3a984d710e3fcc26b809f0f Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 21 Jun 2019 18:38:03 -0400 Subject: [PATCH] Rename QUtil::strcasecmp to QUtil::str_compare_nocase (fixes #242) --- ChangeLog | 9 +++++++++ TODO | 3 --- include/qpdf/QUtil.hh | 5 ++++- libqpdf/QUtil.cc | 4 ++-- qpdf/qpdf.cc | 3 ++- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b94b5c5..49a3c614 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2019-06-21 Jay Berkenbilt + + * 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 * Enable compilation with additional warnings for integer diff --git a/TODO b/TODO index a04be5c9..bf400c33 100644 --- a/TODO +++ b/TODO @@ -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. diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh index afdd2033..9f76f738 100644 --- a/include/qpdf/QUtil.hh +++ b/include/qpdf/QUtil.hh @@ -305,8 +305,11 @@ namespace QUtil QPDF_DLL std::list 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 diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index 607c28f7..ddfc0cdb 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -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 } diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index 4200903b..cbda36a1 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -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) + "-";