summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2011-10-12 18:50:11 +0000
committerVincent Torri <vincent.torri@gmail.com>2011-10-12 18:50:11 +0000
commit3859b0ea96076da5cacf380e17e53922c0f35010 (patch)
treeb35e6ae0f0e6b27029ef7b88c6e6e9e4f470d1c0
parent4d5b4b2f2433f6b0af141c92705a66330359e8fc (diff)
Evil: simplify evil_wchar_to_char()
SVN revision: 64023
-rw-r--r--legacy/evil/ChangeLog5
-rw-r--r--legacy/evil/src/lib/evil_util.c16
2 files changed, 12 insertions, 9 deletions
diff --git a/legacy/evil/ChangeLog b/legacy/evil/ChangeLog
index a0943d290c..325b1766de 100644
--- a/legacy/evil/ChangeLog
+++ b/legacy/evil/ChangeLog
@@ -1,3 +1,8 @@
12011-10-12 Vincent Torri <doursse at users dot sf dot net>
2
3 * src/lib/evil_util.c:
4 simplify evil_wchar_to_char()
5
12011-10-05 Vincent Torri <doursse at users dot sf dot net> 62011-10-05 Vincent Torri <doursse at users dot sf dot net>
2 7
3 * src/lib/evil_inet.c: 8 * src/lib/evil_inet.c:
diff --git a/legacy/evil/src/lib/evil_util.c b/legacy/evil/src/lib/evil_util.c
index 30f52ac997..59c386ac11 100644
--- a/legacy/evil/src/lib/evil_util.c
+++ b/legacy/evil/src/lib/evil_util.c
@@ -38,21 +38,19 @@ char *
38evil_wchar_to_char(const wchar_t *text) 38evil_wchar_to_char(const wchar_t *text)
39{ 39{
40 char *atext; 40 char *atext;
41 size_t size;
42 int asize; 41 int asize;
43 42
44 size = wcslen(text) + 1; 43 asize = WideCharToMultiByte(CP_ACP, 0, text, -1, NULL, 0, NULL, NULL);
45
46 asize = WideCharToMultiByte(CP_ACP, 0, text, (int)size, NULL, 0, NULL, NULL);
47 if (asize == 0) 44 if (asize == 0)
48 return NULL; 45 return NULL;
49 46
50 atext = (char*)malloc((asize + 1) * sizeof(char)); 47 atext = (char*)malloc(asize * sizeof(char));
48 if (!atext)
49 return NULL;
51 50
52 if (atext) 51 asize = WideCharToMultiByte(CP_ACP, 0, text, -1, atext, asize, NULL, NULL);
53 if (!WideCharToMultiByte(CP_ACP, 0, text, (int)size, atext, asize, NULL, NULL)) 52 if (asize == 0)
54 return NULL; 53 return NULL;
55 atext[asize] = '\0';
56 54
57 return atext; 55 return atext;
58} 56}