[CMake] Is HAVE_LOCALE_H patch correct?
Kent Boortz
kent at mysql.com
Thu Mar 1 20:58:46 EST 2007
Hi,
I could not compile released "cmake-2.4.6" on several platforms
Fedora Core 4 x86
FreeBSD 6 x86 and x86_64
Red Hat RHAS 4 x86 and x86_64
SuSE SLES9 x86 and x86_64
SuSE 7.3 x86
The error message is
Source/CursesDialog/form/fty_num.c: In function `Check_Numeric_Field':
Source/CursesDialog/form/fty_num.c:124: error: `L' undeclared (first use in this function)
Source/CursesDialog/form/fty_num.c:124: error: (Each undeclared identifier is reported only once
Source/CursesDialog/form/fty_num.c:124: error: for each function it appears in.)
Source/CursesDialog/form/fty_num.c: In function `Check_Numeric_Character':
Source/CursesDialog/form/fty_num.c:170: error: `L' undeclared (first use in this function)
To me it looks like incomplete coding when HAVE_LOCALE_H is set. Could
you please confirm that the following patch is correct?
--- Source/CursesDialog/form/fty_num.c.ORIG 2007-03-02 02:28:33.065531923 +0100
+++ Source/CursesDialog/form/fty_num.c 2007-03-02 02:32:55.095895314 +0100
@@ -23,7 +23,9 @@
int precision;
double low;
double high;
+#if HAVE_LOCALE_H
struct lconv* L;
+#endif
} numericARG;
/*---------------------------------------------------------------------------
@@ -45,8 +47,6 @@
argn->high = va_arg(*ap,double);
#if HAVE_LOCALE_H
argn->L = localeconv();
-#else
- argn->L = NULL;
#endif
}
return (void *)argn;
@@ -104,6 +104,9 @@
double low = argn->low;
double high = argn->high;
int prec = argn->precision;
+#if HAVE_LOCALE_H
+ struct lconv* L = argn->L;
+#endif
unsigned char *bp = (unsigned char *)field_buffer(field,0);
char *s = (char *)bp;
double val = 0.0;
@@ -161,7 +164,12 @@
+--------------------------------------------------------------------------*/
static bool Check_Numeric_Character(int c, const void * argp)
{
+#if HAVE_LOCALE_H
+ const numericARG *argn = (const numericARG *)argp;
+ struct lconv* L = argn->L;
+#else
argp=0; /* Silence unused parameter warning. */
+#endif
return (isdigit(c) ||
c == '+' ||
c == '-' ||
If the symbol HAVE_LOCALE_H can be undefined I would also avoid using
"#if HAVE_LOCALE_H" and instead use "#ifdef HAVE_LOCALE_H". Using
plain "#if" works with most compilers, but not all.
Thank you for the good work with CMake! I have used it on Windows
earlier and it is so clean and makes setting up a build so easy
compared to other methods. At least for me that is an Unix geek :-)
kent
--
Kent Boortz, Senior Software Developer
MySQL AB, www.mysql.com
Office: +46 18 174400 ext. 4450 (VoIP)
Office: +46 19 182931
Mobile: +46 70 2791171
More information about the CMake
mailing list