Jacek Caban : jscript: Use _ltow_s instead of int_to_string.

Alexandre Julliard julliard at winehq.org
Thu Oct 31 17:39:29 CDT 2019


Module: wine
Branch: master
Commit: a20555ea5f29d998f39ea35c12e052cd2a1634ed
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a20555ea5f29d998f39ea35c12e052cd2a1634ed

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Oct 31 19:00:07 2019 +0100

jscript: Use _ltow_s instead of int_to_string.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/jscript/jsutils.c | 34 +++-------------------------------
 1 file changed, 3 insertions(+), 31 deletions(-)

diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c
index 79971f7f07..bb35ed7df5 100644
--- a/dlls/jscript/jsutils.c
+++ b/dlls/jscript/jsutils.c
@@ -690,36 +690,6 @@ HRESULT to_uint32(script_ctx_t *ctx, jsval_t val, UINT32 *ret)
     return hres;
 }
 
-static jsstr_t *int_to_string(int i)
-{
-    WCHAR buf[12], *p;
-    BOOL neg = FALSE;
-
-    if(!i) {
-        static const WCHAR zeroW[] = {'0',0};
-        return jsstr_alloc(zeroW);
-    }
-
-    if(i < 0) {
-        neg = TRUE;
-        i = -i;
-    }
-
-    p = buf + ARRAY_SIZE(buf)-1;
-    *p-- = 0;
-    while(i) {
-        *p-- = i%10 + '0';
-        i /= 10;
-    }
-
-    if(neg)
-        *p = '-';
-    else
-        p++;
-
-    return jsstr_alloc(p);
-}
-
 HRESULT double_to_string(double n, jsstr_t **str)
 {
     static const WCHAR InfinityW[] = {'-','I','n','f','i','n','i','t','y',0};
@@ -729,7 +699,9 @@ HRESULT double_to_string(double n, jsstr_t **str)
     }else if(isinf(n)) {
         *str = jsstr_alloc(n<0 ? InfinityW : InfinityW+1);
     }else if(is_int32(n)) {
-        *str = int_to_string(n);
+        WCHAR buf[12];
+        _ltow_s(n, buf, ARRAY_SIZE(buf), 10);
+        *str = jsstr_alloc(buf);
     }else {
         VARIANT strv, v;
         HRESULT hres;




More information about the wine-cvs mailing list