Merge to XFA: patch from CL 738433003
authorBruce Dawson <brucedawson@google.com>
Tue, 18 Nov 2014 21:42:28 +0000 (13:42 -0800)
committerBruce Dawson <brucedawson@google.com>
Tue, 18 Nov 2014 21:42:28 +0000 (13:42 -0800)
Review URL: https://codereview.chromium.org/738433003

R=tsepez@chromium.org
TBR=tsepez@chromium.org

Review URL: https://codereview.chromium.org/741473003

core/include/fxcrt/fx_system.h
samples/pdfium_test.cc

index 36050f3..355bd74 100644 (file)
@@ -293,4 +293,35 @@ typedef base::CheckedNumeric<size_t>   FX_SAFE_SIZE_T;
 #define FX_OVERRIDE
 #endif
 #endif
+
+// To print a size_t value in a portable way:
+//   size_t size;
+//   printf("xyz: %" PRIuS, size);
+// The "u" in the macro corresponds to %u, and S is for "size".
+
+#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
+
+#if (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
+#error "inttypes.h has already been included before this header file, but "
+#error "without __STDC_FORMAT_MACROS defined."
+#endif
+
+#if !defined(__STDC_FORMAT_MACROS)
+#define __STDC_FORMAT_MACROS
+#endif
+
+#include <inttypes.h>
+
+#if !defined(PRIuS)
+#define PRIuS "zu"
+#endif
+
+#else  // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
+
+#if !defined(PRIuS)
+#define PRIuS "Iu"
+#endif
+
+#endif
+
 #endif
index f50d4d1..3c0cef4 100644 (file)
@@ -16,6 +16,7 @@
 #include "../fpdfsdk/include/fpdfformfill.h"
 #include "../fpdfsdk/include/fpdftext.h"
 #include "../fpdfsdk/include/fpdfview.h"
+#include "../core/include/fxcrt/fx_system.h"
 #include "v8/include/v8.h"
 
 #ifdef _WIN32
@@ -360,8 +361,8 @@ void RenderPdf(const char* name, const char* pBuf, size_t len,
   FPDFDOC_ExitFormFillEnvironment(form);
   FPDFAvail_Destroy(pdf_avail);
 
-  printf("Loaded, parsed and rendered %zu pages.\n", rendered_pages);
-  printf("Skipped %zu bad pages.\n", bad_pages);
+  printf("Loaded, parsed and rendered %" PRIuS " pages.\n", rendered_pages);
+  printf("Skipped %" PRIuS " bad pages.\n", bad_pages);
 }
 
 int main(int argc, const char* argv[]) {