157f1bf3415dfbdfc34f7fd30dca1968387c32ad
[platform/core/uifw/ise-engine-unikey.git] / ukengine / diff / convert.cpp.diff
1 --- orginal/convert.cpp 2009-04-14 00:16:33.000000000 +0700
2 +++ convert.cpp 2009-06-12 14:00:32.000000000 +0700
3 @@ -20,7 +20,6 @@
4  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
5  --------------------------------------------------------------------------------*/
6  
7 -#include "stdafx.h"
8  #include "charset.h"
9  #include <stdio.h>
10  #include <stdlib.h>
11 @@ -118,7 +117,7 @@
12         FILE *inf = NULL;
13         FILE *outf = NULL;
14         int ret = 0;
15 -       char *tmpName = NULL;
16 +       char tmpName[32];
17  
18         if (inFile == NULL) {
19                 inf = stdin;
20 @@ -152,9 +151,10 @@
21                 else
22                         *p = 0;
23  
24 -               tmpName = tempnam(outDir, NULL);
25 +               strcpy(tmpName, outDir);
26 +        strcat(tmpName, "XXXXXX");
27  
28 -               if (tmpName == NULL) {
29 +               if (mkstemp(tmpName) == -1) {
30                         fclose(inf);
31                         ret = VNCONV_ERR_OUTPUT_FILE;
32                         goto end;
33 @@ -163,7 +163,6 @@
34  
35                 if (outf == NULL) {
36                         fclose(inf);
37 -                       free(tmpName);
38                         ret = VNCONV_ERR_OUTPUT_FILE; 
39                         goto end;
40                 }
41 @@ -182,11 +181,10 @@
42  #if !defined(_WIN32)
43                         char cmd[256];
44                         sprintf(cmd, "mv %s %s", tmpName, outFile);
45 -                       system(cmd);
46 +                       int tmp = system(cmd);
47  #else
48                         if (rename(tmpName, outFile) != 0) {
49                                 remove(tmpName);
50 -                               free(tmpName);
51                                 ret = VNCONV_ERR_OUTPUT_FILE;
52                                 goto end;
53                         }
54 @@ -194,7 +192,6 @@
55                 }
56                 else 
57                         remove(tmpName);
58 -               free(tmpName);
59         }
60  
61  end:
62 @@ -235,7 +232,7 @@
63         return genConvert(*pInCharset, *pOutCharset, is, os);
64  }
65  
66 -char *ErrTable[VNCONV_LAST_ERROR] = 
67 +const char *ErrTable[VNCONV_LAST_ERROR] = 
68  {"No error",
69   "Unknown error",
70   "Invalid charset",