OLD | NEW |
1 /* | 1 /* |
2 ****************************************************************************** | 2 ****************************************************************************** |
3 * | 3 * |
4 * Copyright (C) 1999-2014, International Business Machines | 4 * Copyright (C) 1999-2015, International Business Machines |
5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
6 * | 6 * |
7 ****************************************************************************** | 7 ****************************************************************************** |
8 * file name: ubidi.c | 8 * file name: ubidi.c |
9 * encoding: US-ASCII | 9 * encoding: US-ASCII |
10 * tab size: 8 (not used) | 10 * tab size: 8 (not used) |
11 * indentation:4 | 11 * indentation:4 |
12 * | 12 * |
13 * created on: 1999jul27 | 13 * created on: 1999jul27 |
14 * created by: Markus W. Scherer, updated by Matitiahu Allouche | 14 * created by: Markus W. Scherer, updated by Matitiahu Allouche |
(...skipping 2318 matching lines...) Loading... |
2333 pBiDi->epiLength=0; | 2333 pBiDi->epiLength=0; |
2334 pBiDi->pParaBiDi=pBiDi; /* mark successful setPara */ | 2334 pBiDi->pParaBiDi=pBiDi; /* mark successful setPara */ |
2335 } | 2335 } |
2336 | 2336 |
2337 #define BIDI_MIN(x, y) ((x)<(y) ? (x) : (y)) | 2337 #define BIDI_MIN(x, y) ((x)<(y) ? (x) : (y)) |
2338 #define BIDI_ABS(x) ((x)>=0 ? (x) : (-(x))) | 2338 #define BIDI_ABS(x) ((x)>=0 ? (x) : (-(x))) |
2339 | 2339 |
2340 static void | 2340 static void |
2341 setParaRunsOnly(UBiDi *pBiDi, const UChar *text, int32_t length, | 2341 setParaRunsOnly(UBiDi *pBiDi, const UChar *text, int32_t length, |
2342 UBiDiLevel paraLevel, UErrorCode *pErrorCode) { | 2342 UBiDiLevel paraLevel, UErrorCode *pErrorCode) { |
2343 void *runsOnlyMemory; | 2343 void *runsOnlyMemory = NULL; |
2344 int32_t *visualMap; | 2344 int32_t *visualMap; |
2345 UChar *visualText; | 2345 UChar *visualText; |
2346 int32_t saveLength, saveTrailingWSStart; | 2346 int32_t saveLength, saveTrailingWSStart; |
2347 const UBiDiLevel *levels; | 2347 const UBiDiLevel *levels; |
2348 UBiDiLevel *saveLevels; | 2348 UBiDiLevel *saveLevels; |
2349 UBiDiDirection saveDirection; | 2349 UBiDiDirection saveDirection; |
2350 UBool saveMayAllocateText; | 2350 UBool saveMayAllocateText; |
2351 Run *runs; | 2351 Run *runs; |
2352 int32_t visualLength, i, j, visualStart, logicalStart, | 2352 int32_t visualLength, i, j, visualStart, logicalStart, |
2353 runCount, runLength, addedRuns, insertRemove, | 2353 runCount, runLength, addedRuns, insertRemove, |
(...skipping 153 matching lines...) Loading... |
2507 pBiDi->text=text; | 2507 pBiDi->text=text; |
2508 pBiDi->length=saveLength; | 2508 pBiDi->length=saveLength; |
2509 pBiDi->originalLength=length; | 2509 pBiDi->originalLength=length; |
2510 pBiDi->direction=saveDirection; | 2510 pBiDi->direction=saveDirection; |
2511 /* the saved levels should never excess levelsSize, but we check anyway */ | 2511 /* the saved levels should never excess levelsSize, but we check anyway */ |
2512 if(saveLength>pBiDi->levelsSize) { | 2512 if(saveLength>pBiDi->levelsSize) { |
2513 saveLength=pBiDi->levelsSize; | 2513 saveLength=pBiDi->levelsSize; |
2514 } | 2514 } |
2515 uprv_memcpy(pBiDi->levels, saveLevels, saveLength*sizeof(UBiDiLevel)); | 2515 uprv_memcpy(pBiDi->levels, saveLevels, saveLength*sizeof(UBiDiLevel)); |
2516 pBiDi->trailingWSStart=saveTrailingWSStart; | 2516 pBiDi->trailingWSStart=saveTrailingWSStart; |
2517 /* free memory for mapping table and visual text */ | |
2518 uprv_free(runsOnlyMemory); | |
2519 if(pBiDi->runCount>1) { | 2517 if(pBiDi->runCount>1) { |
2520 pBiDi->direction=UBIDI_MIXED; | 2518 pBiDi->direction=UBIDI_MIXED; |
2521 } | 2519 } |
2522 cleanup3: | 2520 cleanup3: |
| 2521 /* free memory for mapping table and visual text */ |
| 2522 uprv_free(runsOnlyMemory); |
| 2523 |
2523 pBiDi->reorderingMode=UBIDI_REORDER_RUNS_ONLY; | 2524 pBiDi->reorderingMode=UBIDI_REORDER_RUNS_ONLY; |
2524 } | 2525 } |
2525 | 2526 |
2526 /* ubidi_setPara ------------------------------------------------------------ */ | 2527 /* ubidi_setPara ------------------------------------------------------------ */ |
2527 | 2528 |
2528 U_CAPI void U_EXPORT2 | 2529 U_CAPI void U_EXPORT2 |
2529 ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length, | 2530 ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length, |
2530 UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels, | 2531 UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels, |
2531 UErrorCode *pErrorCode) { | 2532 UErrorCode *pErrorCode) { |
2532 UBiDiDirection direction; | 2533 UBiDiDirection direction; |
(...skipping 470 matching lines...) Loading... |
3003 if( pBiDi->fnClassCallback == NULL || | 3004 if( pBiDi->fnClassCallback == NULL || |
3004 (dir = (*pBiDi->fnClassCallback)(pBiDi->coClassCallback, c)) == U_BIDI_C
LASS_DEFAULT ) | 3005 (dir = (*pBiDi->fnClassCallback)(pBiDi->coClassCallback, c)) == U_BIDI_C
LASS_DEFAULT ) |
3005 { | 3006 { |
3006 dir = ubidi_getClass(pBiDi->bdp, c); | 3007 dir = ubidi_getClass(pBiDi->bdp, c); |
3007 } | 3008 } |
3008 if(dir >= U_CHAR_DIRECTION_COUNT) { | 3009 if(dir >= U_CHAR_DIRECTION_COUNT) { |
3009 dir = ON; | 3010 dir = ON; |
3010 } | 3011 } |
3011 return dir; | 3012 return dir; |
3012 } | 3013 } |
OLD | NEW |