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

Diff of /m4/src/freeze.c

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

revision 1.31 by gary, Fri Jun 20 15:43:20 2003 UTC revision 1.32 by gary, Thu Jun 26 14:57:32 2003 UTC
# Line 26  Line 26 
26  static  int   decode_char          (FILE *in);  static  int   decode_char          (FILE *in);
27  static  void  issue_expect_message (int expected);  static  void  issue_expect_message (int expected);
28  static  int   produce_char_dump    (char *buf, int ch);  static  int   produce_char_dump    (char *buf, int ch);
29  static  void  produce_syntax_dump  (FILE *file, char ch, int mask);  static  void  produce_syntax_dump  (FILE *file, m4_syntax_table *syntax,
30                                        char ch, int mask);
31  static  void  produce_module_dump  (FILE *file, lt_dlhandle handle);  static  void  produce_module_dump  (FILE *file, lt_dlhandle handle);
32  static  void  produce_symbol_dump  (m4 *context, FILE *file,  static  void  produce_symbol_dump  (m4 *context, FILE *file,
33                                      m4_symtab *symtab);                                      m4_symbol_table *symtab);
34  static  void *dump_symbol_CB       (m4_symtab *symtab, const char *symbol_name,  static  void *dump_symbol_CB       (m4_symbol_table *symtab,
35                                      m4_symbol *symbol, void *userdata);                                      const char *symbol_name, m4_symbol *symbol,
36                                        void *userdata);
37    
38    
39  /* Produce a frozen state to the given file NAME. */  /* Produce a frozen state to the given file NAME. */
# Line 77  produce_char_dump (char *buf, int ch) Line 79  produce_char_dump (char *buf, int ch)
79  #define MAX_CHAR_LENGTH 4       /* '\377' -> 4 characters */  #define MAX_CHAR_LENGTH 4       /* '\377' -> 4 characters */
80    
81  static void  static void
82  produce_syntax_dump (FILE *file, char ch, int mask)  produce_syntax_dump (FILE *file, m4_syntax_table *syntax, char ch, int mask)
83  {  {
84    char buf[1+ MAX_CHAR_LENGTH * sizeof (m4_syntax_table)];    char buf[1+ MAX_CHAR_LENGTH * sizeof (m4_syntax_table)];
85    int code = m4_syntax_code (ch);    int code = m4_syntax_code (ch);
# Line 86  produce_syntax_dump (FILE *file, char ch Line 88  produce_syntax_dump (FILE *file, char ch
88    int i;    int i;
89    
90    /* FIXME:  Can't set the syntax of '\000' since that character marks    /* FIXME:  Can't set the syntax of '\000' since that character marks
91               the end of a string, and when passed to `set_syntax', tells               the end of a string, and when passed to `m4_set_syntax', tells
92               it to set the syntax of every table entry. */               it to set the syntax of every table entry. */
93    
94    for (i = 1; i < 256; ++i)    for (i = 1; i < 256; ++i)
95      {      {
96        if ((mask && ((m4_syntax_table[i] & mask) == code))        if ((mask && ((syntax->table[i] & mask) == code))
97            || (!mask && ((m4_syntax_table[i] & code) == code)))            || (!mask && ((syntax->table[i] & code) == code)))
98          {          {
99            offset += produce_char_dump (buf + offset, i);            offset += produce_char_dump (buf + offset, i);
100            ++count;            ++count;
# Line 125  produce_module_dump (FILE *file, lt_dlha Line 127  produce_module_dump (FILE *file, lt_dlha
127     This order ensures that, at reload time, pushdef's will be     This order ensures that, at reload time, pushdef's will be
128     executed with the oldest definitions first.  */     executed with the oldest definitions first.  */
129  void  void
130  produce_symbol_dump (m4 *context, FILE *file, m4_symtab *symtab)  produce_symbol_dump (m4 *context, FILE *file, m4_symbol_table *symtab)
131  {  {
132    const char *errormsg = m4_symtab_apply (symtab, dump_symbol_CB, file);    const char *errormsg = m4_symtab_apply (symtab, dump_symbol_CB, file);
133    
# Line 137  produce_symbol_dump (m4 *context, FILE * Line 139  produce_symbol_dump (m4 *context, FILE *
139  }  }
140    
141  static void *  static void *
142  dump_symbol_CB (m4_symtab *symtab, const char *symbol_name, m4_symbol *symbol,  dump_symbol_CB (m4_symbol_table *symtab, const char *symbol_name, m4_symbol *symbol,
143                  void *userdata)                  void *userdata)
144  {  {
145    lt_dlhandle   handle          = SYMBOL_HANDLE (symbol);    lt_dlhandle   handle          = SYMBOL_HANDLE (symbol);
# Line 208  produce_frozen_state (m4 *context, const Line 210  produce_frozen_state (m4 *context, const
210    
211    /* Dump quote delimiters.  */    /* Dump quote delimiters.  */
212    
213    if (strcmp (lquote.string, DEF_LQUOTE)    if (strcmp (m4_get_syntax_lquote (M4SYNTAX), DEF_LQUOTE)
214        || strcmp (rquote.string, DEF_RQUOTE))        || strcmp (m4_get_syntax_rquote (M4SYNTAX), DEF_RQUOTE))
215      {      {
216        fprintf (file, "Q%lu,%lu\n",        fprintf (file, "Q%lu,%lu\n",
217                 (unsigned long) lquote.length,                 (unsigned long) context->syntax->lquote.length,
218                 (unsigned long) rquote.length);                 (unsigned long) context->syntax->rquote.length);
219        fputs (lquote.string, file);        fputs (context->syntax->lquote.string, file);
220        fputs (rquote.string, file);        fputs (context->syntax->rquote.string, file);
221        fputc ('\n', file);        fputc ('\n', file);
222      }      }
223    
224    /* Dump comment delimiters.  */    /* Dump comment delimiters.  */
225    
226    if (strcmp (bcomm.string, DEF_BCOMM) || strcmp (ecomm.string, DEF_ECOMM))    if (strcmp (m4_get_syntax_bcomm (M4SYNTAX), DEF_BCOMM)
227          || strcmp (m4_get_syntax_ecomm (M4SYNTAX), DEF_ECOMM))
228      {      {
229        fprintf (file, "C%lu,%lu\n",        fprintf (file, "C%lu,%lu\n",
230                 (unsigned long) bcomm.length,                 (unsigned long) context->syntax->bcomm.length,
231                 (unsigned long) ecomm.length);                 (unsigned long) context->syntax->ecomm.length);
232        fputs (bcomm.string, file);        fputs (context->syntax->bcomm.string, file);
233        fputs (ecomm.string, file);        fputs (context->syntax->ecomm.string, file);
234        fputc ('\n', file);        fputc ('\n', file);
235      }      }
236    
237    /* Dump syntax table. */    /* Dump syntax table. */
238    
239    produce_syntax_dump (file, 'I', M4_SYNTAX_VALUE);    produce_syntax_dump (file, M4SYNTAX, 'I', M4_SYNTAX_VALUE);
240    produce_syntax_dump (file, 'S', M4_SYNTAX_VALUE);    produce_syntax_dump (file, M4SYNTAX, 'S', M4_SYNTAX_VALUE);
241    produce_syntax_dump (file, '(', M4_SYNTAX_VALUE);    produce_syntax_dump (file, M4SYNTAX, '(', M4_SYNTAX_VALUE);
242    produce_syntax_dump (file, ')', M4_SYNTAX_VALUE);    produce_syntax_dump (file, M4SYNTAX, ')', M4_SYNTAX_VALUE);
243    produce_syntax_dump (file, ',', M4_SYNTAX_VALUE);    produce_syntax_dump (file, M4SYNTAX, ',', M4_SYNTAX_VALUE);
244    produce_syntax_dump (file, '$', M4_SYNTAX_VALUE);    produce_syntax_dump (file, M4SYNTAX, '$', M4_SYNTAX_VALUE);
245    produce_syntax_dump (file, 'A', M4_SYNTAX_VALUE);    produce_syntax_dump (file, M4SYNTAX, 'A', M4_SYNTAX_VALUE);
246    produce_syntax_dump (file, '@', M4_SYNTAX_VALUE);    produce_syntax_dump (file, M4SYNTAX, '@', M4_SYNTAX_VALUE);
247    produce_syntax_dump (file, 'O', M4_SYNTAX_VALUE);    produce_syntax_dump (file, M4SYNTAX, 'O', M4_SYNTAX_VALUE);
248    
249    produce_syntax_dump (file, 'W', M4_SYNTAX_VALUE);    produce_syntax_dump (file, M4SYNTAX, 'W', M4_SYNTAX_VALUE);
250    produce_syntax_dump (file, 'D', M4_SYNTAX_VALUE);    produce_syntax_dump (file, M4SYNTAX, 'D', M4_SYNTAX_VALUE);
251    
252    produce_syntax_dump (file, 'L', 0);    produce_syntax_dump (file, M4SYNTAX, 'L', 0);
253    produce_syntax_dump (file, 'R', 0);    produce_syntax_dump (file, M4SYNTAX, 'R', 0);
254    produce_syntax_dump (file, 'B', 0);    produce_syntax_dump (file, M4SYNTAX, 'B', 0);
255    produce_syntax_dump (file, 'E', 0);    produce_syntax_dump (file, M4SYNTAX, 'E', 0);
256    
257    /* Dump all loaded modules.  */    /* Dump all loaded modules.  */
258    produce_module_dump (file, lt_dlhandle_next (0));    produce_module_dump (file, lt_dlhandle_next (0));
# Line 550  reload_frozen_state (m4 *context, const Line 553  reload_frozen_state (m4 *context, const
553            }            }
554          string[0][number[0]] = '\0';          string[0][number[0]] = '\0';
555    
556          m4_set_syntax (context, syntax, string[0]);          if ((m4_set_syntax (context->syntax, syntax, string[0]) < 0)
557                && (syntax != '\0'))
558              {
559                M4ERROR ((m4_get_warning_status_opt (context), 0,
560                          _("Undefined syntax code %c"), syntax));
561              }
562          break;          break;
563    
564        case 'C':        case 'C':
# Line 590  reload_frozen_state (m4 *context, const Line 598  reload_frozen_state (m4 *context, const
598    
599              /* Change comment strings.  */              /* Change comment strings.  */
600    
601              m4_set_comment (string[0], string[1]);              m4_set_comment (M4SYNTAX, string[0], string[1]);
602              break;              break;
603    
604            case 'D':            case 'D':
# Line 606  reload_frozen_state (m4 *context, const Line 614  reload_frozen_state (m4 *context, const
614    
615              /* Change quote strings.  */              /* Change quote strings.  */
616    
617              m4_set_quotes (string[0], string[1]);              m4_set_quotes (M4SYNTAX, string[0], string[1]);
618              break;              break;
619    
620            default:            default:

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32

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