Peter Wehrfritz ha scritto:
> Gustavo Sverzut Barbieri schrieb:
>
>> On Nov 23, 2007 3:45 AM, Dave <[EMAIL PROTECTED]> wrote:
>>
>>
>>> Hi all,
>>> I recently have a strange bug in the editor that prevent from saving all
>>> the file.
>>> The problem is that engrave write out an edc with all the floating numbers
>>> having the wrong separator-char ( 0,0 instead of 0.0 ).
>>> The strange think is that engrave_test seems to work well
>>> Someone else have this error?
>>> To try simply create a new group,a new rectangle and save the file.
>>> I have this error:
>>>
>>> Executing: edje_cc -v /tmp/edje_editor_tmp.edc-pQu69c "/home/dave/as"
>>> edje_cc: Error. parse error :22. , marker before ; marker
>>> Error in edje_cc, exit code: 25
>>>
>>> and in fact the tmp file have ( , ) instead of ( . ) in numbers
>>>
>>>
>>> The tmp file is generated by engrave_edc_output() that write the value
>>> with this function:
>>>
>>> static void
>>> engrave_out_data(FILE *out, char *name, char *fmt, ...)
>>> {
>>> va_list ap;
>>> char *fmt_new = (char *)calloc(strlen(fmt) + strlen(name) + level +
>>> 5, sizeof(char));
>>> char *buf = engrave_output_mk_tabs();
>>>
>>> sprintf(fmt_new, "%s%s: %s;\n", buf, name, fmt);
>>> va_start(ap, fmt);
>>> vfprintf(out, fmt_new, ap);
>>> va_end(ap);
>>> FREE(fmt_new);
>>> FREE(buf);
>>> }
>>>
>>>
>>> So seems that vfprintf() write the %.2f param wrong. Is this possible?
>>> is vfprintf() l18n?
>>>
>>>
>> yes, it is. I'm not sure how to disable it just for some functions
>> tough. A quick look at its man page says that every format would use
>> the locale to format, but maybe there is some that I missed.
>>
>>
> Don't think there is a really nice way to do this. The only way I know
> is this:
> char prev[128];
>
> strncpy(prev, setlocale(LC_NUMERIC, NULL), sizeof(prev));
>
> setlocale(LC_NUMERIC, "C");
> printf("%f\n", 123.3);
> setlocale(LC_NUMERIC, prev);
>
>
Yes thanks, this works !!
This is the patch for engrave, can I commit it?(my editor is badly broken
without) or someone know a better way?
Index: src/lib/engrave_out.c
===================================================================
RCS file: /cvs/e/e17/libs/engrave/src/lib/engrave_out.c,v
retrieving revision 1.47
diff -u -r1.47 engrave_out.c
--- src/lib/engrave_out.c 9 Nov 2007 09:15:19 -0000 1.47
+++ src/lib/engrave_out.c 24 Nov 2007 15:27:34 -0000
@@ -1,6 +1,7 @@
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
+#include <locale.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
@@ -191,6 +192,7 @@
engrave_edc_output(Engrave_File *engrave_file, const char *path)
{
FILE *out = NULL;
+ char locale[128];
if (!engrave_file) return 0;
@@ -201,6 +203,10 @@
return 0;
}
+ /* set locale posix compliant*/
+ strncpy(locale, setlocale(LC_NUMERIC, NULL), sizeof(locale));
+ setlocale(LC_NUMERIC, "C");
+
/* fonts */
engrave_out_start(out, "fonts");
engrave_file_font_foreach(engrave_file, _engrave_output_font, out);
@@ -237,6 +243,10 @@
engrave_out_end(out);
fclose(out);
+
+ /* reset locale to system default*/
+ setlocale(LC_NUMERIC, locale);
+
return 1;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel