txlyre 12 ore în urmă
părinte
comite
5bd2ec4bc4
1 a modificat fișierele cu 13 adăugiri și 1 ștergeri
  1. 13 1
      qirt.c

+ 13 - 1
qirt.c

@@ -2516,6 +2516,12 @@ qi_value_t *qi_add(qi_state_t *state, qi_value_t *a, qi_value_t *b) {
     strcat(string, b->value.string);
 
     return qi_make_string(state, string);
+  } else if (a->type == QI_STRING && b->type == QI_NUMBER && *a->value.string && !a->value.string[1]) {
+    char buf[2];
+    buf[0] = *a->value.string + b->value.number;
+    buf[1] = 0;
+
+    return qi_make_string_copy(state, buf);
   } else if (a->type == QI_BYTES && b->type == QI_BYTES) {
     if (a->value.bytes->size == 0 && b->value.bytes->size == 0)
       return state->empty_bytes;
@@ -2608,7 +2614,13 @@ qi_value_t *qi_sub(qi_state_t *state, qi_value_t *a, qi_value_t *b) {
   if (fail)
     goto leave;
 
-  if (a->type == QI_NUMBER && b->type == QI_NUMBER)
+  if (a->type == QI_STRING && b->type == QI_NUMBER && *a->value.string && !a->value.string[1]) {
+    char buf[2];
+    buf[0] = *a->value.string - b->value.number;
+    buf[1] = 0;
+
+    return qi_make_string_copy(state, buf);
+  } else if (a->type == QI_NUMBER && b->type == QI_NUMBER)
     return qi_make_number(state, a->value.number - b->value.number);
 
 leave: