/* * Flips the text buffer, according to max level, and * all higher levels * * Input: * from: text buffer, on which to apply flipping * level: resolved levels buffer * max: the maximum level found in this line (should be unsigned char) * count: line size in wchar_t */ void flipThisRun(BLOCKTYPE from, unsigned char* level, int max, int count, int * v2l) { int i, j, rcount, tlevel, tempInt; CHARTYPE temp; j = i = 0; while(i<count && j<count) { /* find the start of the run of level=max */ tlevel = max; i = j = findIndexOfRun(level, i, count, max); /* find the end of the run */ while((tlevel <= level[i]) && (i < count)) { i++; } rcount = i-j; for(; rcount>((i-j)/2); rcount--) { temp = GETCHAR(from, j+rcount-1); GETCHAR(from, j+rcount-1) = GETCHAR(from, i-rcount); GETCHAR(from, i-rcount) = temp; if(v2l) { tempInt = v2l[j+rcount-1]; v2l[j+rcount-1] = v2l[i-rcount]; v2l[i-rcount] = tempInt; } } } }
/* * Flips the text buffer, according to max level, and * all higher levels * * Input: * from: text buffer, on which to apply flipping * level: resolved levels buffer * max: the maximum level found in this line (should be uchar) * count: line size in bidi_char */ static void flipThisRun(bidi_char * from, uchar * level, int max, int count) { int i, j, k, tlevel; bidi_char temp; j = i = 0; while (i < count && j < count) { /* find the start of the run of level=max */ tlevel = max; i = j = findIndexOfRun(level, i, count, max); /* find the end of the run */ while (i < count && tlevel <= level[i]) { i++; } for (k = i - 1; k > j; k--, j++) { temp = from[k]; from[k] = from[j]; from[j] = temp; } } }