Przeglądaj źródła

ncd: modules: more number generation updates

ambrop7 13 lat temu
rodzic
commit
2362c0c0ab
2 zmienionych plików z 4 dodań i 11 usunięć
  1. 2 5
      ncd/modules/foreach.c
  2. 2 6
      ncd/modules/index.c

+ 2 - 5
ncd/modules/foreach.c

@@ -423,12 +423,9 @@ static int element_list_index_object_func_getvar (struct element *e, NCD_string_
         return 0;
     }
     
-    char str[64];
-    snprintf(str, sizeof(str), "%d", e->i);
-    
-    *out = NCDVal_NewString(mem, str);
+    *out = ncd_make_uintmax(mem, e->i);
     if (NCDVal_IsInvalid(*out)) {
-        ModuleLog(o->i, BLOG_ERROR, "NCDVal_NewString failed");
+        ModuleLog(o->i, BLOG_ERROR, "ncd_make_uintmax failed");
     }
     return 1;
 }

+ 2 - 6
ncd/modules/index.c

@@ -46,7 +46,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stddef.h>
-#include <stdio.h>
 
 #include <ncd/NCDModule.h>
 #include <ncd/value_utils.h>
@@ -136,12 +135,9 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     struct instance *o = vo;
     
     if (!strcmp(name, "")) {
-        char str[64];
-        snprintf(str, sizeof(str), "%zu", o->value);
-        
-        *out = NCDVal_NewString(mem, str);
+        *out = ncd_make_uintmax(mem, o->value);
         if (NCDVal_IsInvalid(*out)) {
-            ModuleLog(o->i, BLOG_ERROR, "NCDVal_NewString failed");
+            ModuleLog(o->i, BLOG_ERROR, "ncd_make_uintmax failed");
         }
         return 1;
     }