Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: core/src/fxcodec/codec/fx_codec_png.cpp

Issue 1577503002: Merge to XFA: Switch most min/max macros to std::min/max. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fpdftext/fpdf_text_int.cpp ('k') | core/src/fxcodec/lbmp/fx_bmp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <algorithm>
8
7 #include "core/include/fxcodec/fx_codec.h" 9 #include "core/include/fxcodec/fx_codec.h"
8 #include "core/include/fxge/fx_dib.h" 10 #include "core/include/fxge/fx_dib.h"
9 #include "codec_int.h" 11 #include "codec_int.h"
10 12
11 extern "C" { 13 extern "C" {
12 #undef FAR 14 #undef FAR
13 #include "third_party/lpng_v163/png.h" 15 #include "third_party/lpng_v163/png.h"
14 } 16 }
15 17
16 static void _png_error_data(png_structp png_ptr, png_const_charp error_msg) { 18 static void _png_error_data(png_structp png_ptr, png_const_charp error_msg) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime)); 57 FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime));
56 FXSYS_snprintf((FX_CHAR*)pAttribute->m_strTime, 58 FXSYS_snprintf((FX_CHAR*)pAttribute->m_strTime,
57 sizeof(pAttribute->m_strTime), "%4d:%2d:%2d %2d:%2d:%2d", 59 sizeof(pAttribute->m_strTime), "%4d:%2d:%2d %2d:%2d:%2d",
58 t->year, t->month, t->day, t->hour, t->minute, t->second); 60 t->year, t->month, t->day, t->hour, t->minute, t->second);
59 pAttribute->m_strTime[sizeof(pAttribute->m_strTime) - 1] = 0; 61 pAttribute->m_strTime[sizeof(pAttribute->m_strTime) - 1] = 0;
60 bTime = 1; 62 bTime = 1;
61 } 63 }
62 #endif 64 #endif
63 #if defined(PNG_TEXT_SUPPORTED) 65 #if defined(PNG_TEXT_SUPPORTED)
64 int i; 66 int i;
65 FX_DWORD len; 67 FX_STRSIZE len;
66 const FX_CHAR* buf; 68 const FX_CHAR* buf;
67 int num_text; 69 int num_text;
68 png_textp text = NULL; 70 png_textp text = NULL;
69 png_get_text(png_ptr, info_ptr, &text, &num_text); 71 png_get_text(png_ptr, info_ptr, &text, &num_text);
70 for (i = 0; i < num_text; i++) { 72 for (i = 0; i < num_text; i++) {
71 len = (FX_DWORD)FXSYS_strlen(text[i].key); 73 len = FXSYS_strlen(text[i].key);
72 buf = "Time"; 74 buf = "Time";
73 if (!FXSYS_memcmp(buf, text[i].key, FX_MIN(len, FXSYS_strlen(buf)))) { 75 if (!FXSYS_memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) {
74 if (!bTime) { 76 if (!bTime) {
75 FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime)); 77 FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime));
76 FXSYS_memcpy( 78 FXSYS_memcpy(
77 pAttribute->m_strTime, text[i].text, 79 pAttribute->m_strTime, text[i].text,
78 FX_MIN(sizeof(pAttribute->m_strTime) - 1, text[i].text_length)); 80 std::min(sizeof(pAttribute->m_strTime) - 1, text[i].text_length));
79 } 81 }
80 } else { 82 } else {
81 buf = "Author"; 83 buf = "Author";
82 if (!FXSYS_memcmp(buf, text[i].key, FX_MIN(len, FXSYS_strlen(buf)))) { 84 if (!FXSYS_memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) {
83 pAttribute->m_strAuthor.Empty(); 85 pAttribute->m_strAuthor.Empty();
84 pAttribute->m_strAuthor.Load((uint8_t*)text[i].text, 86 pAttribute->m_strAuthor.Load((uint8_t*)text[i].text,
85 (FX_STRSIZE)text[i].text_length); 87 (FX_STRSIZE)text[i].text_length);
86 } 88 }
87 } 89 }
88 } 90 }
89 #endif 91 #endif
90 } 92 }
91 } 93 }
92 struct FXPNG_Context { 94 struct FXPNG_Context {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 if (setjmp(png_jmpbuf(p->png_ptr))) { 247 if (setjmp(png_jmpbuf(p->png_ptr))) {
246 if (pAttribute && 248 if (pAttribute &&
247 0 == FXSYS_strcmp(m_szLastError, "Read Header Callback Error")) { 249 0 == FXSYS_strcmp(m_szLastError, "Read Header Callback Error")) {
248 _png_load_bmp_attribute(p->png_ptr, p->info_ptr, pAttribute); 250 _png_load_bmp_attribute(p->png_ptr, p->info_ptr, pAttribute);
249 } 251 }
250 return FALSE; 252 return FALSE;
251 } 253 }
252 png_process_data(p->png_ptr, p->info_ptr, (uint8_t*)src_buf, src_size); 254 png_process_data(p->png_ptr, p->info_ptr, (uint8_t*)src_buf, src_size);
253 return TRUE; 255 return TRUE;
254 } 256 }
OLDNEW
« no previous file with comments | « core/src/fpdftext/fpdf_text_int.cpp ('k') | core/src/fxcodec/lbmp/fx_bmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698