1 |
/* GNU m4 -- A simple macro processor |
/* GNU m4 -- A simple macro processor |
2 |
Copyright (C) 1989, 90, 91, 92, 93, 94, 04 Free Software Foundation, Inc. |
Copyright (C) 1989, 90, 91, 92, 93, 94, 04, 05 Free Software Foundation, Inc. |
3 |
|
|
4 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
622 |
#ifdef ENABLE_CHANGEWORD |
#ifdef ENABLE_CHANGEWORD |
623 |
|
|
624 |
void |
void |
625 |
|
init_pattern_buffer (struct re_pattern_buffer *buf) |
626 |
|
{ |
627 |
|
buf->translate = 0; |
628 |
|
buf->fastmap = 0; |
629 |
|
buf->buffer = 0; |
630 |
|
buf->allocated = 0; |
631 |
|
} |
632 |
|
|
633 |
|
void |
634 |
set_word_regexp (const char *regexp) |
set_word_regexp (const char *regexp) |
635 |
{ |
{ |
636 |
int i; |
int i; |
637 |
char test[2]; |
char test[2]; |
638 |
const char *msg; |
const char *msg; |
639 |
|
struct re_pattern_buffer new_word_regexp; |
640 |
|
|
641 |
if (!strcmp (regexp, DEFAULT_WORD_REGEXP)) |
if (!strcmp (regexp, DEFAULT_WORD_REGEXP)) |
642 |
{ |
{ |
644 |
return; |
return; |
645 |
} |
} |
646 |
|
|
647 |
default_word_regexp = FALSE; |
/* Dry run to see whether the new expression is compilable. */ |
648 |
|
init_pattern_buffer (&new_word_regexp); |
649 |
msg = re_compile_pattern (regexp, strlen (regexp), &word_regexp); |
msg = re_compile_pattern (regexp, strlen (regexp), &new_word_regexp); |
650 |
|
regfree (&new_word_regexp); |
651 |
|
|
652 |
if (msg != NULL) |
if (msg != NULL) |
653 |
{ |
{ |
656 |
return; |
return; |
657 |
} |
} |
658 |
|
|
659 |
|
/* If compilation worked, retry using the word_regexp struct. |
660 |
|
Can't rely on struct assigns working, so redo the compilation. */ |
661 |
|
msg = re_compile_pattern (regexp, strlen (regexp), &word_regexp); |
662 |
|
|
663 |
|
if (msg != NULL) |
664 |
|
{ |
665 |
|
M4ERROR ((EXIT_FAILURE, 0, |
666 |
|
"Internal error: Expression recompilation `%s': %s", |
667 |
|
regexp, msg)); |
668 |
|
} |
669 |
|
|
670 |
|
default_word_regexp = FALSE; |
671 |
|
|
672 |
if (word_start == NULL) |
if (word_start == NULL) |
673 |
word_start = xmalloc (256); |
word_start = xmalloc (256); |
674 |
|
|