kmx.io/kv/kv_chars.c

Branch

Thomas de Grivel f1843fc12 2022-01-03T14:06:48
quote
/*
 * kv - key value text file format
 *
 * Copyright 2022 Thomas de Grivel
*/

#include "kv.h"

int kv_is_quotable_char (int c)
{
  switch (c) {
  case '"':
  case '\\':
  case '\n':
  case '\r':
  case '\t':
  case '\v':
    return 1;
  default:
    return 0;
  }
  return 0;
}

int kv_is_reserved_char (int c)
{
  switch (c) {
  case 0:
  case '"':
  case ',':
  case ':':
  case '{':
  case '}':
    return 1;
  default:
    return kv_is_space(c);
  }
  return 0;
}

int kv_is_space (int c)
{
  switch (c) {
  case ' ':
  case '\n':
  case '\r':
  case '\t':
  case '\v':
    return 1;
  default:
    return 0;
  }
  return 0;
}
Download