1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4
5 #ifdef _WIN32
6 # include <evil_private.h> /* nl_langinfo */
7 #endif
8
9 #include <Elementary.h>
10
11 #include "elm_priv.h"
12
13 char *
_str_ncpy(char * dest,const char * src,size_t count)14 _str_ncpy(char *dest, const char *src, size_t count)
15 {
16 if ((!dest) || (!src)) return NULL;
17 return strncpy(dest, src, count);
18 }
19
20 char *
_str_append(char * str,const char * txt,int * len,int * alloc)21 _str_append(char *str, const char *txt, int *len, int *alloc)
22 {
23 int txt_len = strlen(txt);
24
25 if (txt_len <= 0) return str;
26 if ((*len + txt_len) >= *alloc)
27 {
28 char *str2;
29 int alloc2;
30
31 alloc2 = *alloc + txt_len + 128;
32 str2 = realloc(str, alloc2);
33 if (!str2) return str;
34 *alloc = alloc2;
35 str = str2;
36 }
37 strcpy(str + *len, txt);
38 *len += txt_len;
39 return str;
40 }
41
42 char *
_elm_util_mkup_to_text(const char * mkup)43 _elm_util_mkup_to_text(const char *mkup)
44 {
45 return evas_textblock_text_markup_to_utf8(NULL, mkup);
46 }
47
48 char *
_elm_util_text_to_mkup(const char * text)49 _elm_util_text_to_mkup(const char *text)
50 {
51 return evas_textblock_text_utf8_to_markup(NULL, text);
52 }
53
54 double
_elm_atof(const char * s)55 _elm_atof(const char *s)
56 {
57 char *cradix, *buf, *p;
58
59 if ((!s) || (!s[0])) return 0.0;
60 cradix = nl_langinfo(RADIXCHAR);
61 if (!cradix) return atof(s);
62 buf = alloca(strlen(s) + 1);
63 strcpy(buf, s);
64 for (p = buf; *p; p++)
65 {
66 if (*p == '.') *p = *cradix;
67 }
68 return atof(buf);
69 }
70