Esempio n. 1
0
File: def.c Progetto: Phuehvk/upb
static bool upb_isident(const char *str, size_t len, bool full, upb_status *s) {
  bool start = true;
  for (size_t i = 0; i < len; i++) {
    char c = str[i];
    if (c == '.') {
      if (start || !full) {
        upb_status_seterrf(s, "invalid name: unexpected '.' (%s)", str);
        return false;
      }
      start = true;
    } else if (start) {
      if (!upb_isletter(c)) {
        upb_status_seterrf(
            s, "invalid name: path components must start with a letter (%s)",
            str);
        return false;
      }
      start = false;
    } else {
      if (!upb_isalphanum(c)) {
        upb_status_seterrf(s, "invalid name: non-alphanumeric character (%s)",
                           str);
        return false;
      }
    }
  }
  return !start;
}
Esempio n. 2
0
static bool upb_isident(const char *str, size_t len, bool full) {
  bool start = true;
  for (size_t i = 0; i < len; i++) {
    char c = str[i];
    if (c == '.') {
      if (start || !full) return false;
      start = true;
    } else if (start) {
      if (!upb_isletter(c)) return false;
      start = false;
    } else {
      if (!upb_isalphanum(c)) return false;
    }
  }
  return !start;
}
Esempio n. 3
0
File: def.c Progetto: Phuehvk/upb
static bool upb_isalphanum(char c) {
  return upb_isletter(c) || upb_isbetween(c, '0', '9');
}