ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

static void testCharRangeByte4 ( xmlParserCtxtPtr  ctxt,
char data 
) [static]

Definition at line 430 of file testchar.c.

Referenced by testCharRanges().

                                                                  {
    int i, j, k, K, l, L;
    int len, c;
    unsigned char lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF};
    int value;

    data[4] = 0;
    for (i = 0xF0;i <= 0xFF;i++) {
    for (j = 0;j <= 0xFF;j++) {
    for (k = 0;k < 6;k++) {
    for (l = 0;l < 6;l++) {
    data[0] = i;
    data[1] = j;
    K = lows[k];
    data[2] = (char) K;
    L = lows[l];
    data[3] = (char) L;
    value = (L & 0x3F) + ((K & 0x3F) << 6) + ((j & 0x3F) << 12) +
            ((i & 0x7) << 18);
    ctxt->charset = XML_CHAR_ENCODING_UTF8;

    lastError = 0;
    c = xmlCurrentChar(ctxt, &len);

    /*
     * if fifth bit of first char is set, then the sequence would need
     * at least 5 bytes, but we give only 4 !
     */
    if ((i & 0xF8) == 0xF8) {
        if (lastError != XML_ERR_INVALID_CHAR)
        fprintf(stderr,
  "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
            i, j, K, data[3]);
    }

        /*
     * The second, third and fourth bytes must start with 10
     */
    else if (((j & 0xC0) != 0x80) || ((K & 0xC0) != 0x80) ||
             ((L & 0xC0) != 0x80)) {
        if (lastError != XML_ERR_INVALID_CHAR)
        fprintf(stderr,
    "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
            i, j, K, L);
    }

    /*
     * if using a 3 byte encoding then the value must be greater
     * than 0x10000, i.e. one of bits 3 to 0 of i must be set or
     * the 6 or 5th byte of j must be set
     */
    else if (((i & 0x7) == 0) && ((j & 0x30) == 0)) {
        if (lastError != XML_ERR_INVALID_CHAR)
        fprintf(stderr,
    "Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
            i, j, K, L);
    }

        /*
     * There are values in that range that are not allowed in XML-1.0
     */
    else if (((value > 0xD7FF) && (value <0xE000)) ||
             ((value > 0xFFFD) && (value <0x10000)) || 
         (value > 0x10FFFF)) {
        if (lastError != XML_ERR_INVALID_CHAR)
        fprintf(stderr,
"Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
            value, i, j, K, L);
    }

    /*
     * We should see no error in remaining cases
     */
    else if ((lastError != 0) || (len != 4)) {
        fprintf(stderr, 
        "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X\n",
            i, j, K);
    }

    /*
     * Finally check the value is right
     */
    else if (c != value) {
        fprintf(stderr, 
    "Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X: expect %d got %d\n",
        i, j, data[2], value, c);
    }
    }
    }
    }
    }
}

Generated on Sat May 26 2012 06:01:57 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.