/[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.11 by gary, Sat Sep 1 16:10:41 2001 UTC revision 1.12 by gary, Sat Sep 1 20:05:27 2001 UTC
# Line 33  static void  issue_expect_message (int e Line 33  static void  issue_expect_message (int e
33  static  int   produce_char_dump    (char *buf, int ch);  static  int   produce_char_dump    (char *buf, int ch);
34  static  void  produce_syntax_dump  (FILE *file, char ch, int mask);  static  void  produce_syntax_dump  (FILE *file, char ch, int mask);
35  static  void  produce_module_dump  (FILE *file, lt_dlhandle handle);  static  void  produce_module_dump  (FILE *file, lt_dlhandle handle);
36  static  void  produce_symbol_dump  (FILE *file, const m4_symbol *bucke);  static  void  produce_symbol_dump  (FILE *file, m4_hash *hash);
37    
38    
39  /* Produce a frozen state to the given file NAME. */  /* Produce a frozen state to the given file NAME. */
# Line 117  produce_module_dump (FILE *file, lt_dlha Line 117  produce_module_dump (FILE *file, lt_dlha
117    handle = lt_dlhandle_next (handle);    handle = lt_dlhandle_next (handle);
118    if (handle)    if (handle)
119      produce_module_dump (file, handle);      produce_module_dump (file, handle);
120      
121    fprintf (file, "M%lu\n", (unsigned long) strlen (name));    fprintf (file, "M%lu\n", (unsigned long) strlen (name));
122    fputs (name, file);    fputs (name, file);
123    fputc ('\n', file);    fputc ('\n', file);
# Line 127  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 (FILE *file, const m4_symbol *bucket)  produce_symbol_dump (FILE *file, m4_hash *hash)
131  {  {
132    const m4_symbol *pending = bucket;    m4_hash_iterator *place       = 0;
   lt_dlhandle   handle          = M4_SYMBOL_HANDLE (pending);  
   const char   *symbol_name     = M4_SYMBOL_NAME (pending);  
   const char   *module_name     = handle ? m4_module_name (handle) : NULL;  
   const m4_builtin *bp;  
133    
134    bucket = M4_SYMBOL_NEXT (bucket);    while ((place = m4_hash_iterator_next (hash, place)))
   if (bucket)  
     produce_symbol_dump (file, bucket);  
     
   switch (M4_SYMBOL_TYPE (pending))  
135      {      {
136      case M4_TOKEN_TEXT:        const char   *symbol_name = m4_hash_iterator_key (place);
137        fprintf (file, "T%lu,%lu",        m4_symbol    *symbol      = m4_hash_iterator_value (place);
138                 (unsigned long) strlen (symbol_name),        lt_dlhandle   handle      = M4_SYMBOL_HANDLE (symbol);
139                 (unsigned long) strlen (M4_SYMBOL_TEXT (pending)));        const char   *module_name = handle ? m4_module_name (handle) : NULL;
140        if (handle)        const m4_builtin *bp;
         fprintf (file, ",%lu", (unsigned long) strlen (module_name));  
       fputc ('\n', file);  
   
       fputs (symbol_name, file);  
       fputs (M4_SYMBOL_TEXT (pending), file);  
       if (handle)  
         fputs (module_name, file);  
       fputc ('\n', file);  
       break;  
141    
142      case M4_TOKEN_FUNC:        switch (M4_SYMBOL_TYPE (symbol))
       bp = m4_builtin_find_by_func (m4_module_builtins(M4_SYMBOL_HANDLE(pending)),  
                                     M4_SYMBOL_FUNC (pending));  
       if (bp == NULL)  
143          {          {
144            M4ERROR ((warning_status, 0,          case M4_TOKEN_TEXT:
145                      _("INTERNAL ERROR: Builtin not found in builtin table!")));            fprintf (file, "T%lu,%lu",
146            abort ();                     (unsigned long) strlen (symbol_name),
147          }                     (unsigned long) strlen (M4_SYMBOL_TEXT (symbol)));
148              if (handle)
149                fprintf (file, ",%lu", (unsigned long) strlen (module_name));
150              fputc ('\n', file);
151    
152              fputs (symbol_name, file);
153              fputs (M4_SYMBOL_TEXT (symbol), file);
154              if (handle)
155                fputs (module_name, file);
156              fputc ('\n', file);
157              break;
158    
159        fprintf (file, "F%lu,%lu",          case M4_TOKEN_FUNC:
160                 (unsigned long) strlen (symbol_name),            bp = m4_builtin_find_by_func
161                 (unsigned long) strlen (bp->name));                  (m4_module_builtins (M4_SYMBOL_HANDLE(symbol)),
162                     M4_SYMBOL_FUNC (symbol));
       if (handle)  
         fprintf (file, ",%lu",  
                  (unsigned long) strlen (module_name));  
       fputc ('\n', file);  
163    
164        fputs (symbol_name, file);            if (bp == NULL)
165        fputs (bp->name, file);              {
166        if (handle)                M4ERROR ((warning_status, 0, _("\
167          fputs (module_name, file);  INTERNAL ERROR: Builtin not found in builtin table!")));
168        fputc ('\n', file);                abort ();
169        break;              }
170    
171      default:            fprintf (file, "F%lu,%lu",
172        M4ERROR ((warning_status, 0, _("\                     (unsigned long) strlen (symbol_name),
173                       (unsigned long) strlen (bp->name));
174    
175              if (handle)
176                fprintf (file, ",%lu",
177                         (unsigned long) strlen (module_name));
178              fputc ('\n', file);
179    
180              fputs (symbol_name, file);
181              fputs (bp->name, file);
182              if (handle)
183                fputs (module_name, file);
184              fputc ('\n', file);
185              break;
186    
187            default:
188              M4ERROR ((warning_status, 0, _("\
189  INTERNAL ERROR: Bad token data type in produce_symbol_dump ()")));  INTERNAL ERROR: Bad token data type in produce_symbol_dump ()")));
190        abort ();            abort ();
191        break;            break;
192            }
193      }      }
194  }  }
195    
# Line 194  void Line 197  void
197  produce_frozen_state (const char *name)  produce_frozen_state (const char *name)
198  {  {
199    FILE *file;    FILE *file;
   int h;  
200    
201    if (file = fopen (name, "w"), !file)    if (file = fopen (name, "w"), !file)
202      {      {
# Line 257  produce_frozen_state (const char *name) Line 259  produce_frozen_state (const char *name)
259    produce_module_dump (file, lt_dlhandle_next (0));    produce_module_dump (file, lt_dlhandle_next (0));
260    
261    /* Dump all symbols.  */    /* Dump all symbols.  */
262    for (h = 0; h < hash_table_size; h++)    produce_symbol_dump (file, m4_symtab);
     if (m4_symtab[h])  
       produce_symbol_dump (file, m4_symtab[h]);  
263    
264    /* Let diversions be issued from output.c module, its cleaner to have this    /* Let diversions be issued from output.c module, its cleaner to have this
265       piece of code there.  */       piece of code there.  */
   
266    m4_freeze_diversions (file);    m4_freeze_diversions (file);
267    
268    /* All done.  */    /* All done.  */
# Line 480  reload_frozen_state (const char *name) Line 479  reload_frozen_state (const char *name)
479            if (bp)            if (bp)
480              m4_builtin_define (handle, string[0], bp, M4_SYMBOL_PUSHDEF, 0);              m4_builtin_define (handle, string[0], bp, M4_SYMBOL_PUSHDEF, 0);
481            else            else
482              M4ERROR ((warning_status, 0,              M4ERROR ((warning_status, 0,
483                        _("`%s' from frozen file not found in builtin table!"),                        _("`%s' from frozen file not found in builtin table!"),
484                        string[0]));                        string[0]));
485          }          }

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

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