From 53d16a5a1f456b5e6e3387a27ebe7dfc807e64e7 Mon Sep 17 00:00:00 2001 From: obarun <eric@obarun.org> Date: Sat, 18 May 2024 23:49:06 +1100 Subject: [PATCH] use stack instead of sastr with version_store --- src/lib66/utils/version.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib66/utils/version.c b/src/lib66/utils/version.c index 57bae082..8dc09dc3 100644 --- a/src/lib66/utils/version.c +++ b/src/lib66/utils/version.c @@ -19,7 +19,6 @@ #include <oblibs/stack.h> #include <skalibs/types.h> -#include <skalibs/stralloc.h> int version_compare(char const *a, char const *b, uint8_t ndot) { @@ -50,7 +49,7 @@ int version_compare(char const *a, char const *b, uint8_t ndot) return 0 ; } -int version_store(stralloc *sa, char const *str, uint8_t ndot) +int version_store(stack *stk, char const *str, uint8_t ndot) { log_flow() ; @@ -60,7 +59,7 @@ int version_store(stralloc *sa, char const *str, uint8_t ndot) size_t slen = strlen(str) ; char snum[slen + 1] ; auto_strings(snum,str) ; - sa->len = 0 ; + stack_reset(stk) ; while(dot < ndot + 1) { size_t len = strlen(snum) ; @@ -69,13 +68,14 @@ int version_store(stralloc *sa, char const *str, uint8_t ndot) char tmp[len + 1] ; auto_strings(tmp,snum + r + 1) ; if (!uint0_scan(tmp,&num)) return 0 ; - if (!stralloc_inserts(sa,0,tmp)) return -1 ; + if (!stack_insert(stk,0,tmp)) return -1 ; if (dot < ndot) - if (!stralloc_inserts(sa,0,".")) return -1 ; + if (!stack_insert(stk,0,".")) return -1 ; dot++ ; snum[r] = 0 ; } - if (!stralloc_0(sa)) return -1 ; - sa->len-- ; + if (!stack_close(stk)) + return -1 ; + return 1 ; } -- GitLab