Rename GetLastError() shim to FXSYS_GetLastError().
Makes consistent with the other shims in fx_system.h, and avoids
the possibility of conflicting with an embedder that has done the
same thing in their own code.
Change-Id: I2d51d38ffc1d16ca2def4a23a0654e3456f2abc3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/58810
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/fx_system.cpp b/core/fxcrt/fx_system.cpp
index 73ae728..4f95b6a 100644
--- a/core/fxcrt/fx_system.cpp
+++ b/core/fxcrt/fx_system.cpp
@@ -246,14 +246,12 @@
}
return wlen;
}
-#endif // defined(OS_WIN)
-#if !defined(OS_WIN)
-void SetLastError(uint32_t err) {
+void FXSYS_SetLastError(uint32_t err) {
g_last_error = err;
}
-uint32_t GetLastError() {
+uint32_t FXSYS_GetLastError() {
return g_last_error;
}
-#endif // !defined(OS_WIN)
+#endif // defined(OS_WIN)
diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h
index 667de6e..8872c57 100644
--- a/core/fxcrt/fx_system.h
+++ b/core/fxcrt/fx_system.h
@@ -139,9 +139,9 @@
size_t maxsize,
const wchar_t* format,
const struct tm* timeptr);
-
+#define FXSYS_SetLastError SetLastError
+#define FXSYS_GetLastError GetLastError
#else // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
-
int FXSYS_GetACP();
char* FXSYS_itoa(int value, char* str, int radix);
int FXSYS_WideCharToMultiByte(uint32_t codepage,
@@ -166,6 +166,8 @@
wchar_t* FXSYS_wcsupr(wchar_t* str);
#define FXSYS_pow(a, b) (float)pow(a, b)
#define FXSYS_wcsftime wcsftime
+void FXSYS_SetLastError(uint32_t err);
+uint32_t FXSYS_GetLastError();
#endif // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
#define FXWORD_GET_LSBFIRST(p) \
@@ -220,10 +222,4 @@
#endif // _FX_PLATFORM_ != _FX_PLATFORM_WINDOWS_
-// Provide SetLastError() and GetLastError() fills for non-windows platforms.
-#if _FX_PLATFORM_ != _FX_PLATFORM_WINDOWS_
-void SetLastError(uint32_t err);
-uint32_t GetLastError();
-#endif
-
#endif // CORE_FXCRT_FX_SYSTEM_H_
diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp
index 1d7690f..3687f70 100644
--- a/fpdfsdk/cpdfsdk_helpers.cpp
+++ b/fpdfsdk/cpdfsdk_helpers.cpp
@@ -420,5 +420,5 @@
err_code = FPDF_ERR_SECURITY;
break;
}
- SetLastError(err_code);
+ FXSYS_SetLastError(err_code);
}
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index b87fcc1..d724330 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -742,7 +742,7 @@
}
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetLastError() {
- return GetLastError();
+ return FXSYS_GetLastError();
}
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_DeviceToPage(FPDF_PAGE page,
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index 9884b1e..349cc5d 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -103,13 +103,13 @@
m_pXFADoc =
CXFA_FFDoc::CreateAndOpen(m_pXFAApp.get(), &m_DocEnv, m_pPDFDoc.Get());
if (!m_pXFADoc) {
- SetLastError(FPDF_ERR_XFALOAD);
+ FXSYS_SetLastError(FPDF_ERR_XFALOAD);
return false;
}
CJS_Runtime* actual_runtime = GetCJSRuntime(); // Null if a stub.
if (!actual_runtime) {
- SetLastError(FPDF_ERR_XFALOAD);
+ FXSYS_SetLastError(FPDF_ERR_XFALOAD);
return false;
}
@@ -122,7 +122,7 @@
m_pXFADocView = m_pXFADoc->CreateDocView();
if (m_pXFADocView->StartLayout() < 0) {
CloseXFADoc();
- SetLastError(FPDF_ERR_XFALAYOUT);
+ FXSYS_SetLastError(FPDF_ERR_XFALAYOUT);
return false;
}