[TRE-general] Bug report on TRE 0.7.4
Hung-chi Lihn
hlihn at Brocade.COM
Wed Sep 6 05:15:46 EEST 2006
Hi,
When I compile TRE 0.7.4 on Windows platform using a C compiler, I found
the following coding bugs:
1. In tre-match-utils.h, the following statements need to be added
to the beginning of the file:
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */
It will allow the inline definition to work in a C compiler environment.
The 2 inline functions probably need a better protection to prevent them
from being defined multiple times in a C compiler environment if this
header file is included in multiple files. So far, it only has been
included in one file.
2. In config.h, it is not clear that TRE_REGEX_T_FIELD needs to be
defined as value, i.e.,
#define TRE_REGEX_T_FIELD value
After defining this field, the compiler stops complaining
TRE_REGEX_T_FIELD not defined in a few tre_tnfa related files.
3. In tre-parse.c, the statements #ifdef tre_isascii and #ifdef
tre_isblank in struct tre_ctype_map[] should be removed. Otherwise, it
will not include bothe [:ascii:] and [:blank:] classes if both
HAVE_ISASCII and HAVE_ISBLANK are not defined (e.g., my system does not
have isascii() and isblank(), so I can't define them). The code should
look like
struct {
char *name;
int (*func)(tre_cint_t);
} tre_ctype_map[] = {
{ "alnum", &tre_isalnum_func },
{ "alpha", &tre_isalpha_func },
//#ifdef tre_isascii
{ "ascii", &tre_isascii_func },
//#endif /* tre_isascii */
//#ifdef tre_isblank
{ "blank", &tre_isblank_func },
//#endif /* tre_isblank */
{ "cntrl", &tre_iscntrl_func },
{ "digit", &tre_isdigit_func },
{ "graph", &tre_isgraph_func },
{ "lower", &tre_islower_func },
{ "print", &tre_isprint_func },
{ "punct", &tre_ispunct_func },
{ "space", &tre_isspace_func },
{ "upper", &tre_isupper_func },
{ "xdigit", &tre_isxdigit_func },
{ NULL, NULL}
};
This should be safe since the following statements in the same
file protect them:
#ifdef tre_isascii
int tre_isascii_func(tre_cint_t c) { return tre_isascii(c); }
#else /* !tre_isascii */
int tre_isascii_func(tre_cint_t c) { return !(c >> 7); }
#endif /* !tre_isascii */
#ifdef tre_isblank
int tre_isblank_func(tre_cint_t c) { return tre_isblank(c); }
#else /* !tre_isblank */
int tre_isblank_func(tre_cint_t c) { return ((c == ' ') || (c == '\t'));
}
#endif /* !tre_isblank */
After fixing these three bugs, my compilation went smoothly. The code
is working nicely.
Thanks,
Hung-chi Lihn.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://laurikari.net/pipermail/tre-general/attachments/20060906/a145dea4/attachment.html
More information about the TRE-general
mailing list