Commit ec8159e461500140f2ec006c2bb53a1a1fd5bc2a

Thomas de Grivel 2021-12-30T14:52:54

quotable and reserved chars

diff --git a/kv.c b/kv.c
index 6b6daf5..36dd26f 100644
--- a/kv.c
+++ b/kv.c
@@ -23,6 +23,38 @@ int kv_is_space (int c)
   return 0;
 }
 
+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)
+{
+  if (kv_is_quotable_char(c))
+    return 1;
+  switch (c) {
+  case '{':
+  case '}':
+  case ':':
+  case ',':
+    return 1;
+  default:
+    return 0;
+  }
+  return 0;
+}
+
 void kv_sp (s_buffer *b)
 {
   int c = buffer_peek(b);