This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: binutils + i18n
- To: cgen at sources dot redhat dot com, Bruno Haible <haible at ilog dot fr>
- Subject: Re: PATCH: binutils + i18n
- From: Nick Clifton <nickc at cambridge dot redhat dot com>
- Date: 09 Oct 2001 18:51:39 +0100
- Cc: binutils at sourceware dot cygnus dot com
- References: <15276.43450.573829.622772@honolulu.ilog.fr>
Hi Bruno,
> Here is the promised patch to get rid of the locale dependency of
> case conversion in regcomp/regexec calls.
>
> This is three times the same patch, to files marked as "generated by
> CGEN". It would be a good idea to apply this patch to CGEN also, but I
> don't know where its sources reside.
On the other hand I do :-) It is the file cgen-asm.in in the opcodes
directory. So here is your patch, applied to that file. I am
forwarding this patch to the cgen project so that they can approve it,
and when/if they do I will check it in, together with the regenerated
files.
So - CGEN MAINTAINERS - may I apply Bruno's patch ?
Cheers
Nick
opcodes/ChangeLog:
2001-09-22 Bruno Haible <haible@clisp.cons.org>
* cgen-asm.in (*_cgen_build_insn_regex): Generate a case sensitive
regular expression. Fix some formatting problems.
* fr30-asm.c: Regenerate.
* openrisc-asm.c: Regenerate.
* m32r-asm.c: Regenerate.
Index: cgen-asm.in
===================================================================
RCS file: /cvs/src/src/opcodes/cgen-asm.in,v
retrieving revision 1.8
diff -p -r1.8 cgen-asm.in
*** cgen-asm.in 2001/10/09 08:54:57 1.8
--- cgen-asm.in 2001/10/09 17:51:31
*************** char *
*** 74,140 ****
syn = CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc));
! /* Mnemonics come first in the syntax string */
! if (! CGEN_SYNTAX_MNEMONIC_P (* syn)) return "missing mnemonic in syntax string";
++syn;
! /* copy the literal mnemonic out of the insn */
! memset (rx, 0, CGEN_MAX_RX_ELEMENTS);
! mnem_len = strlen(mnem);
! memcpy (rx, mnem, mnem_len);
! rx += mnem_len;
! /* copy any remaining literals from the syntax string into the rx */
! for(; * syn != 0 && rx < rxbuf + (CGEN_MAX_RX_ELEMENTS - 9); ++syn, ++rx)
{
if (CGEN_SYNTAX_CHAR_P (* syn))
{
! char tmp = CGEN_SYNTAX_CHAR (* syn);
! switch (tmp)
! {
! /* escape any regex metacharacters in the syntax */
! case '.': case '[': case '\\':
! case '*': case '^': case '$':
#ifdef CGEN_ESCAPE_EXTENDED_REGEX
! case '?': case '{': case '}':
! case '(': case ')': case '*':
! case '|': case '+': case ']':
#endif
! * rx++ = '\\';
! break;
! }
! /* insert syntax char into rx */
! * rx = tmp;
}
else
{
! /* replace non-syntax fields with globs */
! * rx = '.';
! * ++rx = '*';
}
}
! /* trailing whitespace ok */
* rx++ = '[';
* rx++ = ' ';
* rx++ = '\t';
* rx++ = ']';
* rx++ = '*';
! /* but anchor it after that */
* rx++ = '$';
* rx = '\0';
CGEN_INSN_RX (insn) = xmalloc (sizeof (regex_t));
! reg_err = regcomp ((regex_t *) CGEN_INSN_RX (insn), rxbuf, REG_NOSUB|REG_ICASE);
if (reg_err == 0)
return NULL;
else
{
static char msg[80];
regerror (reg_err, (regex_t *) CGEN_INSN_RX (insn), msg, 80);
regfree ((regex_t *) CGEN_INSN_RX (insn));
free (CGEN_INSN_RX (insn));
--- 74,171 ----
syn = CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc));
! /* Mnemonics come first in the syntax string. */
! if (! CGEN_SYNTAX_MNEMONIC_P (* syn))
! return _("missing mnemonic in syntax string");
++syn;
+
+ /* Generate a case sensitive regular expression that emulates case
+ insensitive matching in the "C" locale. We cannot generate a case
+ insensitive regular expression because in Turkish locales, 'i' and 'I'
+ are not equal modulo case conversion. */
+
+ /* Copy the literal mnemonic out of the insn. */
+ for (; *mnem; mnem++)
+ {
+ char c = *mnem;
! if (ISALPHA (c))
! {
! *rx++ = '[';
! *rx++ = TOLOWER (c);
! *rx++ = TOUPPER (c);
! *rx++ = ']';
! }
! else
! *rx++ = c;
! }
! /* Copy any remaining literals from the syntax string into the rx. */
! for(; * syn != 0 && rx <= rxbuf + (CGEN_MAX_RX_ELEMENTS - 7 - 4); ++syn)
{
if (CGEN_SYNTAX_CHAR_P (* syn))
{
! char c = CGEN_SYNTAX_CHAR (* syn);
+ switch (c)
+ {
+ /* Escape any regex metacharacters in the syntax. */
+ case '.': case '[': case '\\':
+ case '*': case '^': case '$':
+
#ifdef CGEN_ESCAPE_EXTENDED_REGEX
! case '?': case '{': case '}':
! case '(': case ')': case '*':
! case '|': case '+': case ']':
#endif
+ *rx++ = '\\';
+ *rx++ = c;
+ break;
+
+ default:
+ if (ISALPHA (c))
+ {
+ *rx++ = '[';
+ *rx++ = TOLOWER (c);
+ *rx++ = TOUPPER (c);
+ *rx++ = ']';
+ }
+ else
+ *rx++ = c;
+ break;
+ }
! /* Insert syntax char into rx. */
! *rx++ = c;
}
else
{
! /* Replace non-syntax fields with globs. */
! *rx++ = '.';
! *rx++ = '*';
}
}
! /* Trailing whitespace ok. */
* rx++ = '[';
* rx++ = ' ';
* rx++ = '\t';
* rx++ = ']';
* rx++ = '*';
! /* But anchor it after that. */
* rx++ = '$';
* rx = '\0';
CGEN_INSN_RX (insn) = xmalloc (sizeof (regex_t));
! reg_err = regcomp ((regex_t *) CGEN_INSN_RX (insn), rxbuf, REG_NOSUB);
if (reg_err == 0)
return NULL;
else
{
static char msg[80];
+
regerror (reg_err, (regex_t *) CGEN_INSN_RX (insn), msg, 80);
regfree ((regex_t *) CGEN_INSN_RX (insn));
free (CGEN_INSN_RX (insn));