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

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

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 6 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/fxcrt/fx_basic_utf.cpp ('k') | core/src/fxcrt/fx_basic_wstring.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 "../../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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 void FXSYS_vsnprintf(char *str, size_t size, const char* fmt, va_list ap) 181 void FXSYS_vsnprintf(char *str, size_t size, const char* fmt, va_list ap)
182 { 182 {
183 (void) _vsnprintf(str, size, fmt, ap); 183 (void) _vsnprintf(str, size, fmt, ap);
184 if (size) { 184 if (size) {
185 str[size - 1] = 0; 185 str[size - 1] = 0;
186 } 186 }
187 } 187 }
188 #endif // _FXM_PLATFORM_WINDOWS_ && _MSC_VER < 1900 188 #endif // _FXM_PLATFORM_WINDOWS_ && _MSC_VER < 1900
189 189
190 static FX_BOOL FX_IsDigit(FX_BYTE ch) 190 static FX_BOOL FX_IsDigit(uint8_t ch)
191 { 191 {
192 return (ch >= '0' && ch <= '9') ? TRUE : FALSE; 192 return (ch >= '0' && ch <= '9') ? TRUE : FALSE;
193 } 193 }
194 static FX_BOOL FX_IsXDigit(FX_BYTE ch) 194 static FX_BOOL FX_IsXDigit(uint8_t ch)
195 { 195 {
196 return (FX_IsDigit(ch) || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f ')) ? TRUE : FALSE; 196 return (FX_IsDigit(ch) || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f ')) ? TRUE : FALSE;
197 } 197 }
198 static FX_BYTE FX_MakeUpper(FX_BYTE ch) 198 static uint8_t FX_MakeUpper(uint8_t ch)
199 { 199 {
200 if (ch < 'a' || ch > 'z') { 200 if (ch < 'a' || ch > 'z') {
201 return ch; 201 return ch;
202 } 202 }
203 return ch - 32; 203 return ch - 32;
204 } 204 }
205 static int FX_HexToI(FX_BYTE ch) 205 static int FX_HexToI(uint8_t ch)
206 { 206 {
207 ch = FX_MakeUpper(ch); 207 ch = FX_MakeUpper(ch);
208 return FX_IsDigit(ch) ? (ch - '0') : (ch - 55); 208 return FX_IsDigit(ch) ? (ch - '0') : (ch - 55);
209 } 209 }
210 static const unsigned char url_encodeTable[128] = { 210 static const unsigned char url_encodeTable[128] = {
211 1, 1, 1, 1, 1, 1, 1, 1, 211 1, 1, 1, 1, 1, 1, 1, 1,
212 1, 1, 1, 1, 1, 1, 1, 1, 212 1, 1, 1, 1, 1, 1, 1, 1,
213 1, 1, 1, 1, 1, 1, 1, 1, 213 1, 1, 1, 1, 1, 1, 1, 1,
214 1, 1, 1, 1, 1, 1, 1, 1, 214 1, 1, 1, 1, 1, 1, 1, 1,
215 1, 0, 1, 1, 0, 1, 0, 0, 215 1, 0, 1, 1, 0, 1, 0, 0,
(...skipping 14 matching lines...) Expand all
230 const char arDigits[] = "0123456789ABCDEF"; 230 const char arDigits[] = "0123456789ABCDEF";
231 CFX_ByteString rUrl; 231 CFX_ByteString rUrl;
232 int nLength = wsUrl.GetLength(); 232 int nLength = wsUrl.GetLength();
233 for (int i = 0; i < nLength; i++) { 233 for (int i = 0; i < nLength; i++) {
234 FX_DWORD word = wsUrl.GetAt(i); 234 FX_DWORD word = wsUrl.GetAt(i);
235 if (word > 0x7F || url_encodeTable[word] == 1) { 235 if (word > 0x7F || url_encodeTable[word] == 1) {
236 CFX_ByteString bsUri = CFX_ByteString::FromUnicode((FX_WORD)word); 236 CFX_ByteString bsUri = CFX_ByteString::FromUnicode((FX_WORD)word);
237 int nByte = bsUri.GetLength(); 237 int nByte = bsUri.GetLength();
238 for (int j = 0; j < nByte; j++) { 238 for (int j = 0; j < nByte; j++) {
239 rUrl += '%'; 239 rUrl += '%';
240 FX_BYTE code = bsUri.GetAt(j); 240 uint8_t code = bsUri.GetAt(j);
241 rUrl += arDigits[code >> 4]; 241 rUrl += arDigits[code >> 4];
242 rUrl += arDigits[code & 0x0F]; 242 rUrl += arDigits[code & 0x0F];
243 } 243 }
244 } else { 244 } else {
245 rUrl += CFX_ByteString::FromUnicode((FX_WORD)word); 245 rUrl += CFX_ByteString::FromUnicode((FX_WORD)word);
246 } 246 }
247 } 247 }
248 return rUrl; 248 return rUrl;
249 } 249 }
250 CFX_WideString FX_UrlDecode(const CFX_ByteString& bsUrl) 250 CFX_WideString FX_UrlDecode(const CFX_ByteString& bsUrl)
(...skipping 10 matching lines...) Expand all
261 } 261 }
262 return CFX_WideString::FromLocal(rUrl); 262 return CFX_WideString::FromLocal(rUrl);
263 } 263 }
264 CFX_ByteString FX_EncodeURI(const CFX_WideString& wsURI) 264 CFX_ByteString FX_EncodeURI(const CFX_WideString& wsURI)
265 { 265 {
266 const char arDigits[] = "0123456789ABCDEF"; 266 const char arDigits[] = "0123456789ABCDEF";
267 CFX_ByteString rURI; 267 CFX_ByteString rURI;
268 CFX_ByteString bsUri = wsURI.UTF8Encode(); 268 CFX_ByteString bsUri = wsURI.UTF8Encode();
269 int nLength = bsUri.GetLength(); 269 int nLength = bsUri.GetLength();
270 for (int i = 0; i < nLength; i++) { 270 for (int i = 0; i < nLength; i++) {
271 FX_BYTE code = bsUri.GetAt(i); 271 uint8_t code = bsUri.GetAt(i);
272 if (code > 0x7F || url_encodeTable[code] == 1) { 272 if (code > 0x7F || url_encodeTable[code] == 1) {
273 rURI += '%'; 273 rURI += '%';
274 rURI += arDigits[code >> 4]; 274 rURI += arDigits[code >> 4];
275 rURI += arDigits[code & 0x0F]; 275 rURI += arDigits[code & 0x0F];
276 } else { 276 } else {
277 rURI += code; 277 rURI += code;
278 } 278 }
279 } 279 }
280 return rURI; 280 return rURI;
281 } 281 }
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } 496 }
497 497
498 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1 &v) 498 CFX_Vector_3by1 CFX_Matrix_3by3::TransformVector(const CFX_Vector_3by1 &v)
499 { 499 {
500 return CFX_Vector_3by1( 500 return CFX_Vector_3by1(
501 a * v.a + b * v.b + c * v.c, 501 a * v.a + b * v.b + c * v.c,
502 d * v.a + e * v.b + f * v.c, 502 d * v.a + e * v.b + f * v.c,
503 g * v.a + h * v.b + i * v.c 503 g * v.a + h * v.b + i * v.c
504 ); 504 );
505 } 505 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_utf.cpp ('k') | core/src/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698