Пример #1
0
static int
processUcsCharOperands (DataFile *file, void *data) {
  TextTableData *ttd = data;
  DataOperand string;

  if (getDataOperand(file, &string, "character string")) {
    if (string.length == 1) {
      DataOperand representation;

      if (getDataOperand(file, &representation, "braille representation")) {
        if (representation.length == 1) {
          unsigned char dots;

          if (testBrailleRepresentation(file, representation.characters[0], &dots)) {
            if (!setTextTableCharacter(ttd, string.characters[0], dots)) return 0;
          }
        } else {
          reportDataError(file, "multi-cell braille representation not supported");
        }
      }
    } else {
      reportDataError(file, "multi-character string not supported");
    }
  }

  return 1;
}
Пример #2
0
static int
getUnicodeCharacter (DataFile *file, wchar_t *character, const char *description) {
  DataOperand string;

  if (getDataOperand(file, &string, description)) {
    if (string.length > 2) {
      if ((string.characters[0] == WC_C('U')) &&
          (string.characters[1] == WC_C('+'))) {
        const wchar_t *digit = &string.characters[2];
        int length = string.length - 2;

        *character = 0;
        while (length) {
          int value;
          int shift;
          if (!isHexadecimalDigit(*digit++, &value, &shift)) break;

          *character <<= shift;
          *character |= value;
          length -= 1;
        }
        if (!length) return 1;
      }
    }

    reportDataError(file, "invalid Unicode character: %.*" PRIws,
                    string.length, string.characters);
  }

  return 0;
}
Пример #3
0
static DATA_OPERANDS_PROCESSOR(processDelegateOperands) {
  DataOperand type;

  if (getDataOperand(file, &type, "delegate type")) {
    if (isKeyword(WS_C("FILE"), type.characters, type.length)) {
      DataOperand name;

      if (getDataOperand(file, &name, "file name")) {
        return includeDataFile(file, name.characters, name.length);
      }
    } else {
      return includeDataFile(file, type.characters, type.length);
    }
  }

  return 1;
}
Пример #4
0
static int
processDelegateOperands (DataFile *file, void *data) {
  DataOperand type;

  if (getDataOperand(file, &type, "delegate type")) {
    if (isKeyword(WS_C("FILE"), type.characters, type.length)) {
      DataOperand name;

      if (getDataOperand(file, &name, "file name")) {
        return includeDataFile(file, name.characters, name.length);
      }
    } else {
      return includeDataFile(file, type.characters, type.length);
    }
  }

  return 1;
}
Пример #5
0
static DATA_OPERANDS_PROCESSOR(processEncodingOperands) {
  DataOperand encoding;

  if (getDataOperand(file, &encoding, "character encoding name")) {
    if (!isKeyword(WS_C("UTF-8"), encoding.characters, encoding.length)) {
      reportDataError(file, "unsupported character encoding: %.*" PRIws,
                      encoding.length, encoding.characters);
    }
  }

  return 1;
}
Пример #6
0
static int
processEncodingOperands (DataFile *file, void *data) {
  DataOperand encoding;

  if (getDataOperand(file, &encoding, "character encoding name")) {
    if (!isKeyword(WS_C("UTF-8"), encoding.characters, encoding.length)) {
      reportDataError(file, "unsupported character encoding: %.*" PRIws,
                      encoding.length, encoding.characters);
    }
  }

  return 1;
}
Пример #7
0
static DATA_OPERANDS_PROCESSOR(processUcsBlockOperands) {
  DataOperand action;

  if (getDataOperand(file, &action, "UCS block action")) {
    const wchar_t *expected = inUcsBlock? WS_C("END"): WS_C("START");

    if (isKeyword(expected, action.characters, action.length)) {
      inUcsBlock = !inUcsBlock;
    } else {
      reportDataError(file, "unexpected UCS block action: %.*" PRIws " (expecting %" PRIws ")",
                      action.length, action.characters, expected);
    }
  }

  return 1;
}