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

Side by Side Diff: core/src/fxcrt/fx_basic_util.cpp

Issue 1077903002: Better fix for snprintf non-termination on windows. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Implement Bruce's suggestion about void returns. Created 5 years, 8 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
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 "../../include/fxcrt/fx_basic.h" 7 #include "../../include/fxcrt/fx_basic.h"
8 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 8 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <dirent.h> 10 #include <dirent.h>
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 value += fraction_scales[scale] * (str[cc] - '0'); 162 value += fraction_scales[scale] * (str[cc] - '0');
163 scale ++; 163 scale ++;
164 if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) { 164 if (scale == sizeof fraction_scales / sizeof(FX_FLOAT)) {
165 break; 165 break;
166 } 166 }
167 cc ++; 167 cc ++;
168 } 168 }
169 } 169 }
170 return bNegative ? -value : value; 170 return bNegative ? -value : value;
171 } 171 }
172 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
173 void FXSYS_snprintf(char *str, size_t size, const char* fmt, ...)
174 {
175 va_list ap;
176 va_start(ap, fmt);
177 FXSYS_vsnprintf(str, size, fmt, ap);
178 va_end(ap);
179 }
180 void FXSYS_vsnprintf(char *str, size_t size, const char* fmt, va_list ap)
181 {
182 _vsnprintf(str, size, fmt, ap);
brucedawson 2015/04/10 18:03:02 Consider a comment explaining why the void return
Tom Sepez 2015/04/10 18:23:40 Updated comment in the .h file.
183 if (size) {
184 str[size - 1] = 0;
185 }
186 }
187 #endif // _FXM_PLATFORM_WINDOWS_
172 static FX_BOOL FX_IsDigit(FX_BYTE ch) 188 static FX_BOOL FX_IsDigit(FX_BYTE ch)
173 { 189 {
174 return (ch >= '0' && ch <= '9') ? TRUE : FALSE; 190 return (ch >= '0' && ch <= '9') ? TRUE : FALSE;
175 } 191 }
176 static FX_BOOL FX_IsXDigit(FX_BYTE ch) 192 static FX_BOOL FX_IsXDigit(FX_BYTE ch)
177 { 193 {
178 return (FX_IsDigit(ch) || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f ')) ? TRUE : FALSE; 194 return (FX_IsDigit(ch) || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f ')) ? TRUE : FALSE;
179 } 195 }
180 static FX_BYTE FX_MakeUpper(FX_BYTE ch) 196 static FX_BYTE FX_MakeUpper(FX_BYTE ch)
181 { 197 {
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 } 494 }
479 495
480 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1 &v) 496 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1 &v)
481 { 497 {
482 return CFX_Vector_3by1( 498 return CFX_Vector_3by1(
483 a * v.a + b * v.b + c * v.c, 499 a * v.a + b * v.b + c * v.c,
484 d * v.a + e * v.b + f * v.c, 500 d * v.a + e * v.b + f * v.c,
485 g * v.a + h * v.b + i * v.c 501 g * v.a + h * v.b + i * v.c
486 ); 502 );
487 } 503 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698