Example #1
0
File: pragma.c Project: pmprog/cc65
static void CharMapPragma (StrBuf* B)
/* Change the character map */
{
    long Index, C;

    /* Read the character index */
    if (!GetNumber (B, &Index)) {
        return;
    }
    if (Index < 0 || Index > 255) {
        Error ("Character index out of range");
        return;
    }

    /* Comma follows */
    if (!GetComma (B)) {
        return;
    }

    /* Read the character code */
    if (!GetNumber (B, &C)) {
        return;
    }
    if (C < 0 || C > 255) {
        Error ("Character code out of range");
        return;
    }

    /* Warn about remapping character code 0x00
    ** (except when remapping it back to itself).
    */
    if (Index + C != 0 && IS_Get (&WarnRemapZero)) {
        if (Index == 0) {
            Warning ("Remapping from 0 is dangerous with string functions");
        }
        else if (C == 0) {
            Warning ("Remapping to 0 can make string functions stop unexpectedly");
        }
    }

    /* Remap the character */
    TgtTranslateSet ((unsigned) Index, (unsigned char) C);
}
Example #2
0
static void CharMapPragma (StrBuf* B)
/* Change the character map */
{
    long Index, C;

    /* Read the character index */
    if (!GetNumber (B, &Index)) {
        return;
    }
    if (Index < 1 || Index > 255) {
        if (Index == 0) {
            /* For groepaz */
            Error ("Remapping 0 is not allowed");
        } else {
            Error ("Character index out of range");
        }
        return;
    }

    /* Comma follows */
    if (!GetComma (B)) {
        return;
    }

    /* Read the character code */
    if (!GetNumber (B, &C)) {
        return;
    }
    if (C < 1 || C > 255) {
        if (C == 0) {
            /* For groepaz */
            Error ("Remapping 0 is not allowed");
        } else {
            Error ("Character code out of range");
        }
        return;
    }

    /* Remap the character */
    TgtTranslateSet ((unsigned) Index, (unsigned char) C);
}