"Fossies" - the Fresh Open Source Software Archive

Member "xterm-379/unicode/precompose.c.tail" (22 May 2016, 644 Bytes) of package /linux/misc/xterm-379.tgz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 };
    2 
    3 #define UNICODE_SHIFT 21
    4 
    5 int do_precomposition(int base, int comb) {
    6   int min = 0;
    7   int max = sizeof(precompositions) / sizeof(precompositions[0]) - 1;
    8   unsigned long sought = ((unsigned) base << UNICODE_SHIFT) | (unsigned) comb;
    9 
   10   /* binary search */
   11   while (max >= min) {
   12     int mid = (min + max) / 2;
   13     unsigned long that = ((unsigned long) precompositions[mid].base << UNICODE_SHIFT) | ((unsigned) precompositions[mid].comb);
   14     if (that < sought) {
   15       min = mid + 1;
   16     } else if (that > sought) {
   17       max = mid - 1;
   18     } else {
   19       return precompositions[mid].replacement;
   20     }
   21   }
   22   /* no match */
   23   return -1;
   24 }