jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=24417ff1a5885f9de89107e180aa273cab8567d0

commit 24417ff1a5885f9de89107e180aa273cab8567d0
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Tue Jan 19 14:14:44 2016 +0900

    elua: Fix use of eina_file_mkstemp after previous patch
    
    The API (that didn't work in the first place) was used wrongly
    as it was assumed its behaviour was the same as mkstemp (duh!).
    It turns out eina's version doesn't replace the input string but
    returns a tmpstr instead.
    
    @fix
---
 src/lib/elua/cache.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/lib/elua/cache.c b/src/lib/elua/cache.c
index 67268a4..fe6825f 100644
--- a/src/lib/elua/cache.c
+++ b/src/lib/elua/cache.c
@@ -59,19 +59,14 @@ writef(lua_State *L EINA_UNUSED, const void *p, size_t 
size, void *ud)
 static FILE *
 bc_tmp_open(const char *fname, char *buf, size_t buflen)
 {
+   Eina_Tmpstr *tmp_file;
    int fd;
-   /* FIXME: use ecore_file_file_get() ? */
-   char *fs = strrchr(fname, '/'), *bs = strrchr(fname, '\\');
-   if (!fs && !bs)
-     snprintf(buf, buflen, "./XXXXXX.cache");
-   else
-     {
-        char *ss = (fs > bs) ? fs : bs;
-        snprintf(buf, buflen, "%.*sXXXXXX.cache", (int)(ss - fname + 1), 
fname);
-     }
-   fd = eina_file_mkstemp(buf, NULL);
+   snprintf(buf, buflen, "%s.XXXXXX.cache", fname);
+   fd = eina_file_mkstemp(buf, &tmp_file);
    if (fd < 0)
      return NULL;
+   eina_strlcpy(buf, tmp_file, buflen);
+   eina_tmpstr_del(tmp_file);
    return fdopen(fd, "wb");
 }
 
@@ -88,6 +83,7 @@ write_bc(lua_State *L, const char *fname)
              fclose(f);
              /* there really is nothing to handle here */
              (void)!!remove(buf);
+             return;
           }
         else fclose(f);
         snprintf(buf2, sizeof(buf2), "%sc", fname);

-- 


Reply via email to