From: Amos Jeffries Date: Sat, 6 Jan 2024 21:51:16 +0000 (+0000) Subject: Windows: Fix symbol collisions (#1385) X-Git-Tag: SQUID_7_0_1~243 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=405f850ae4c3f643d60e1613d683bb41e3bad022;p=thirdparty%2Fsquid.git Windows: Fix symbol collisions (#1385) 'near' is a macro defined by the Windows API. We cannot use it for anything. --- diff --git a/src/errorpage.cc b/src/errorpage.cc index 5dd96beaf5..a56998dd72 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -114,7 +114,12 @@ public: class BuildErrorPrinter { public: - BuildErrorPrinter(const SBuf &anInputLocation, int aPage, const char *aMsg, const char *aNear): inputLocation(anInputLocation), page_id(aPage), msg(aMsg), near(aNear) {} + BuildErrorPrinter(const SBuf &anInputLocation, int aPage, const char *aMsg, const char *anErrorLocation): + inputLocation(anInputLocation), + page_id(aPage), + msg(aMsg), + errorLocation(anErrorLocation) + {} /// reports error details (for admin-visible exceptions and debugging) std::ostream &print(std::ostream &) const; @@ -126,7 +131,7 @@ public: const SBuf &inputLocation; const int page_id; const char *msg; - const char *near; + const char *errorLocation; }; static inline std::ostream & @@ -1431,13 +1436,13 @@ ErrorState::compile(const char *input, bool building_deny_info_url, bool allowRe /// react to a compile() error /// \param msg description of what went wrong -/// \param near approximate start of the problematic input +/// \param errorLocation approximate start of the problematic input /// \param forceBypass whether detection of this error was introduced late, /// after old configurations containing this error could have been /// successfully validated and deployed (i.e. the admin may not be /// able to fix this newly detected but old problem quickly) void -ErrorState::noteBuildError_(const char *msg, const char *near, const bool forceBypass) +ErrorState::noteBuildError_(const char *const msg, const char * const errorLocation, const bool forceBypass) { using ErrorPage::BuildErrorPrinter; const auto runtime = !starting_up; @@ -1458,9 +1463,9 @@ ErrorState::noteBuildError_(const char *msg, const char *near, const bool forceB if (starting_up && seenErrors <= 10) debugs(4, debugLevel, "WARNING: The following configuration error will be fatal in future Squid versions"); - debugs(4, debugLevel, "ERROR: " << BuildErrorPrinter(inputLocation, page_id, msg, near)); + debugs(4, debugLevel, "ERROR: " << BuildErrorPrinter(inputLocation, page_id, msg, errorLocation)); } else { - throw TexcHere(ToSBuf(BuildErrorPrinter(inputLocation, page_id, msg, near))); + throw TexcHere(ToSBuf(BuildErrorPrinter(inputLocation, page_id, msg, errorLocation))); } } @@ -1486,11 +1491,11 @@ ErrorPage::BuildErrorPrinter::print(std::ostream &os) const { // TODO: Add support for prefix printing to Raw const size_t maxContextLength = 15; // plus "..." - if (strlen(near) > maxContextLength) { - os.write(near, maxContextLength); + if (strlen(errorLocation) > maxContextLength) { + os.write(errorLocation, maxContextLength); os << "..."; } else { - os << near; + os << errorLocation; } // XXX: We should not be converting (inner) exception to text if we are diff --git a/src/errorpage.h b/src/errorpage.h index 8eb295f8ff..1f09b6eefb 100644 --- a/src/errorpage.h +++ b/src/errorpage.h @@ -145,18 +145,18 @@ private: /// React to a compile() error, throwing if buildContext allows. /// \param msg description of what went wrong - /// \param near approximate start of the problematic input - void noteBuildError(const char *msg, const char *near) { - noteBuildError_(msg, near, false); + /// \param errorLocation approximate start of the problematic input + void noteBuildError(const char *const msg, const char * const errorLocation) { + noteBuildError_(msg, errorLocation, false); } /// Note a compile() error but do not throw for backwards /// compatibility with older configurations that may have such errors. /// Should eventually be replaced with noteBuildError(). /// \param msg description of what went wrong - /// \param near approximate start of the problematic input - void bypassBuildErrorXXX(const char *msg, const char *near) { - noteBuildError_(msg, near, true); + /// \param errorLocation approximate start of the problematic input + void bypassBuildErrorXXX(const char *const msg, const char * const errorLocation) { + noteBuildError_(msg, errorLocation, true); } /** @@ -207,7 +207,7 @@ public: HttpReplyPointer response_; private: - void noteBuildError_(const char *msg, const char *near, const bool forceBypass); + void noteBuildError_(const char *msg, const char *errorLocation, bool forceBypass); static const SBuf LogformatMagic; ///< marks each embedded logformat entry };