| OLD | NEW |
| 1 /***************************************************************************/ | 1 /***************************************************************************/ |
| 2 /* */ | 2 /* */ |
| 3 /* psconv.c */ | 3 /* psconv.c */ |
| 4 /* */ | 4 /* */ |
| 5 /* Some convenience conversions (body). */ | 5 /* Some convenience conversions (body). */ |
| 6 /* */ | 6 /* */ |
| 7 /* Copyright 2006, 2008, 2009 by */ | 7 /* Copyright 2006, 2008, 2009, 2012 by */ |
| 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 9 /* */ | 9 /* */ |
| 10 /* This file is part of the FreeType project, and may only be used, */ | 10 /* This file is part of the FreeType project, and may only be used, */ |
| 11 /* modified, and distributed under the terms of the FreeType project */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
| 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
| 14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
| 15 /* */ | 15 /* */ |
| 16 /***************************************************************************/ | 16 /***************************************************************************/ |
| 17 | 17 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 FT_LOCAL_DEF( FT_Int ) | 72 FT_LOCAL_DEF( FT_Int ) |
| 73 PS_Conv_Strtol( FT_Byte** cursor, | 73 PS_Conv_Strtol( FT_Byte** cursor, |
| 74 FT_Byte* limit, | 74 FT_Byte* limit, |
| 75 FT_Int base ) | 75 FT_Int base ) |
| 76 { | 76 { |
| 77 FT_Byte* p = *cursor; | 77 FT_Byte* p = *cursor; |
| 78 FT_Int num = 0; | 78 FT_Int num = 0; |
| 79 FT_Bool sign = 0; | 79 FT_Bool sign = 0; |
| 80 | 80 |
| 81 | 81 |
| 82 if ( p == limit || base < 2 || base > 36 ) | 82 if ( p >= limit || base < 2 || base > 36 ) |
| 83 return 0; | 83 return 0; |
| 84 | 84 |
| 85 if ( *p == '-' || *p == '+' ) | 85 if ( *p == '-' || *p == '+' ) |
| 86 { | 86 { |
| 87 sign = FT_BOOL( *p == '-' ); | 87 sign = FT_BOOL( *p == '-' ); |
| 88 | 88 |
| 89 p++; | 89 p++; |
| 90 if ( p == limit ) | 90 if ( p == limit ) |
| 91 return 0; | 91 return 0; |
| 92 } | 92 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 PS_Conv_ToFixed( FT_Byte** cursor, | 143 PS_Conv_ToFixed( FT_Byte** cursor, |
| 144 FT_Byte* limit, | 144 FT_Byte* limit, |
| 145 FT_Int power_ten ) | 145 FT_Int power_ten ) |
| 146 { | 146 { |
| 147 FT_Byte* p = *cursor; | 147 FT_Byte* p = *cursor; |
| 148 FT_Fixed integral; | 148 FT_Fixed integral; |
| 149 FT_Long decimal = 0, divider = 1; | 149 FT_Long decimal = 0, divider = 1; |
| 150 FT_Bool sign = 0; | 150 FT_Bool sign = 0; |
| 151 | 151 |
| 152 | 152 |
| 153 if ( p == limit ) | 153 if ( p >= limit ) |
| 154 return 0; | 154 return 0; |
| 155 | 155 |
| 156 if ( *p == '-' || *p == '+' ) | 156 if ( *p == '-' || *p == '+' ) |
| 157 { | 157 { |
| 158 sign = FT_BOOL( *p == '-' ); | 158 sign = FT_BOOL( *p == '-' ); |
| 159 | 159 |
| 160 p++; | 160 p++; |
| 161 if ( p == limit ) | 161 if ( p == limit ) |
| 162 return 0; | 162 return 0; |
| 163 } | 163 } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 FT_Byte* p; | 339 FT_Byte* p; |
| 340 FT_UInt r = 0; | 340 FT_UInt r = 0; |
| 341 FT_UInt w = 0; | 341 FT_UInt w = 0; |
| 342 FT_UInt pad = 0x01; | 342 FT_UInt pad = 0x01; |
| 343 | 343 |
| 344 | 344 |
| 345 n *= 2; | 345 n *= 2; |
| 346 | 346 |
| 347 #if 1 | 347 #if 1 |
| 348 | 348 |
| 349 p = *cursor; | 349 p = *cursor; |
| 350 |
| 351 if ( p >= limit ) |
| 352 return 0; |
| 353 |
| 350 if ( n > (FT_UInt)( limit - p ) ) | 354 if ( n > (FT_UInt)( limit - p ) ) |
| 351 n = (FT_UInt)( limit - p ); | 355 n = (FT_UInt)( limit - p ); |
| 352 | 356 |
| 353 /* we try to process two nibbles at a time to be as fast as possible */ | 357 /* we try to process two nibbles at a time to be as fast as possible */ |
| 354 for ( ; r < n; r++ ) | 358 for ( ; r < n; r++ ) |
| 355 { | 359 { |
| 356 FT_UInt c = p[r]; | 360 FT_UInt c = p[r]; |
| 357 | 361 |
| 358 | 362 |
| 359 if ( IS_PS_SPACE( c ) ) | 363 if ( IS_PS_SPACE( c ) ) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 FT_UShort* seed ) | 431 FT_UShort* seed ) |
| 428 { | 432 { |
| 429 FT_Byte* p; | 433 FT_Byte* p; |
| 430 FT_UInt r; | 434 FT_UInt r; |
| 431 FT_UInt s = *seed; | 435 FT_UInt s = *seed; |
| 432 | 436 |
| 433 | 437 |
| 434 #if 1 | 438 #if 1 |
| 435 | 439 |
| 436 p = *cursor; | 440 p = *cursor; |
| 441 |
| 442 if ( p >= limit ) |
| 443 return 0; |
| 444 |
| 437 if ( n > (FT_UInt)(limit - p) ) | 445 if ( n > (FT_UInt)(limit - p) ) |
| 438 n = (FT_UInt)(limit - p); | 446 n = (FT_UInt)(limit - p); |
| 439 | 447 |
| 440 for ( r = 0; r < n; r++ ) | 448 for ( r = 0; r < n; r++ ) |
| 441 { | 449 { |
| 442 FT_UInt val = p[r]; | 450 FT_UInt val = p[r]; |
| 443 FT_UInt b = ( val ^ ( s >> 8 ) ); | 451 FT_UInt b = ( val ^ ( s >> 8 ) ); |
| 444 | 452 |
| 445 | 453 |
| 446 s = ( (val + s)*52845U + 22719 ) & 0xFFFFU; | 454 s = ( (val + s)*52845U + 22719 ) & 0xFFFFU; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 463 *cursor = p; | 471 *cursor = p; |
| 464 *seed = s; | 472 *seed = s; |
| 465 | 473 |
| 466 #endif /* 0 */ | 474 #endif /* 0 */ |
| 467 | 475 |
| 468 return r; | 476 return r; |
| 469 } | 477 } |
| 470 | 478 |
| 471 | 479 |
| 472 /* END */ | 480 /* END */ |
| OLD | NEW |