if(CCMAP_FLAG(aCCMap) & CCMAP_SURROGATE_FLAG) {
if(l != 0 && CCMAP_FLAG(aCCMap) & CCMAP_SURROGATE_FLAG) {
NextNonEmptyCCMapPage(const PRUint16* aCCMap, PRUint32 *aPageStart){  int i, j, l;  int planeend = 0;  int planestart = 0;  unsigned int k;  const PRUint16* ccmap;  PRUint32 pagestart = *aPageStart;  if(CCMAP_FLAG(aCCMap) & CCMAP_SURROGATE_FLAG) {    // for SURROGATE    planeend = EXTENDED_UNICODE_PLANES;  }  if(pagestart != CCMAP_BEGIN_AT_START_OF_MAP) {    planestart = CCMAP_PLANE(pagestart);  }  // checking each plane  for(l=planestart; l<=planeend; l++, pagestart = CCMAP_BEGIN_AT_START_OF_MAP) {    if(CCMAP_FLAG(aCCMap) & CCMAP_SURROGATE_FLAG) {      // for SURROGATE - get ccmap per plane      ccmap = CCMAP_FOR_PLANE_EXT(aCCMap, l);    } else {      // only BMP      ccmap = aCCMap;    }    //    // Point to the next page    //    unsigned int upper_index;    unsigned int mid_index;    if (pagestart == CCMAP_BEGIN_AT_START_OF_MAP) {      upper_index = 0;      mid_index   = 0;    } else {      upper_index = CCMAP_UPPER_INDEX(pagestart & 0xffff);      mid_index   = CCMAP_MID_INDEX(pagestart & 0xffff) + 1;    }    // walk thru the upper pointers    const PRUint16 *upper = &ccmap[0];    for (i=upper_index; i<CCMAP_NUM_UPPER_POINTERS; i++, mid_index=0) {      if (upper[i] == CCMAP_EMPTY_MID) {        continue;      }      // walk the mid array      const PRUint16 *mid = &ccmap[upper[i]];      for (j=mid_index; j<CCMAP_NUM_MID_POINTERS; j++) {        if (mid[j] == CCMAP_EMPTY_PAGE)          continue;          // walk the page        const ALU_TYPE *page = (ALU_TYPE*)&ccmap[mid[j]];        for (k=0; k<CCMAP_NUM_ALUS_PER_PAGE; k++) {          if (page[k] != 0) {            PRUint32 base = (i*CCMAP_NUM_UCHARS_PER_MID) + (j*CCMAP_NUM_UCHARS_PER_PAGE);            NS_ASSERTION(base<NUM_UNICODE_CHARS, "invalid page address");            // return exact UCS4 code point, plane number + base            *aPageStart = (((PRUint32)l)<<16)+base;            return PR_TRUE;          }        }      }    }  }  return PR_FALSE;}