/[m4]/m4/src/input.c
ViewVC logotype

Diff of /m4/src/input.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1.2.1 by gary, Thu Sep 9 20:20:17 2004 UTC revision 1.1.1.1.2.2 by gary, Fri Feb 4 13:03:11 2005 UTC
# Line 1  Line 1 
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
# Line 622  set_comment (const char *bc, const char Line 622  set_comment (const char *bc, const char
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      {      {
# Line 634  set_word_regexp (const char *regexp) Line 644  set_word_regexp (const char *regexp)
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      {      {
# Line 645  set_word_regexp (const char *regexp) Line 656  set_word_regexp (const char *regexp)
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    

Legend:
Removed from v.1.1.1.1.2.1  
changed lines
  Added in v.1.1.1.1.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26