/[m4]/m4/m4/debug.c
ViewVC logotype

Diff of /m4/m4/debug.c

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

revision 1.2 by akim, Tue Aug 7 10:41:11 2001 UTC revision 1.3 by gary, Sun Aug 19 10:53:56 2001 UTC
# Line 36  static struct obstack trace; Line 36  static struct obstack trace;
36    
37  static void m4_debug_set_file M4_PARAMS((FILE *));  static void m4_debug_set_file M4_PARAMS((FILE *));
38    
39  /*----------------------------------.  /* Initialise the debugging module.  */
 | Initialise the debugging module.  |  
 `----------------------------------*/  
   
40  void  void
41  m4_debug_init (void)  m4_debug_init (void)
42  {  {
43    m4_debug_set_file (stderr);    m4_debug_set_file (stderr);
44    obstack_init (&trace);    obstack_init (&trace);
45  }  }
46    
47    
 /*-----------------------------------------------------------------.  
 | Function to decode the debugging flags OPTS.  Used by main while |  
 | processing option -d, and by the builtin debugmode ().           |  
 `-----------------------------------------------------------------*/  
48    
49    /* Function to decode the debugging flags OPTS.  Used by main while
50       processing option -d, and by the builtin debugmode ().  */
51  int  int
52  m4_debug_decode (const char *opts)  m4_debug_decode (const char *opts)
53  {  {
# Line 123  m4_debug_decode (const char *opts) Line 119  m4_debug_decode (const char *opts)
119    return level;    return level;
120  }  }
121    
122  /*------------------------------------------------------------------------.  /* Change the debug output stream to FP.  If the underlying file is the
123  | Change the debug output stream to FP.  If the underlying file is the    |     same as stdout, use stdout instead so that debug messages appear in the
124  | same as stdout, use stdout instead so that debug messages appear in the |     correct relative position.  */
 | correct relative position.                                              |  
 `------------------------------------------------------------------------*/  
   
125  static void  static void
126  m4_debug_set_file (FILE *fp)  m4_debug_set_file (FILE *fp)
127  {  {
# Line 155  m4_debug_set_file (FILE *fp) Line 148  m4_debug_set_file (FILE *fp)
148      }      }
149  }  }
150    
151  /*-----------------------------------------------------------.  /* Serialize files.  Used before executing a system command.  */
 | Serialize files.  Used before executing a system command.  |  
 `-----------------------------------------------------------*/  
   
152  void  void
153  m4_debug_flush_files (void)  m4_debug_flush_files (void)
154  {  {
# Line 168  m4_debug_flush_files (void) Line 158  m4_debug_flush_files (void)
158      fflush (m4_debug);      fflush (m4_debug);
159  }  }
160    
161  /*-------------------------------------------------------------------------.  /* Change the debug output to file NAME.  If NAME is NULL, debug output is
162  | Change the debug output to file NAME.  If NAME is NULL, debug output is  |     reverted to stderr, and if empty debug output is discarded.  Return TRUE
163  | reverted to stderr, and if empty debug output is discarded.  Return TRUE |     iff the output stream was changed.  */
 | iff the output stream was changed.                                       |  
 `-------------------------------------------------------------------------*/  
   
164  boolean  boolean
165  m4_debug_set_output (const char *name)  m4_debug_set_output (const char *name)
166  {  {
# Line 194  m4_debug_set_output (const char *name) Line 181  m4_debug_set_output (const char *name)
181    return TRUE;    return TRUE;
182  }  }
183    
184  /*-----------------------------------------------------------------------.  /* Print the header of a one-line debug message, starting by "m4 debug".  */
 | Print the header of a one-line debug message, starting by "m4 debug".  |  
 `-----------------------------------------------------------------------*/  
   
185  void  void
186  m4_debug_message_prefix (void)  m4_debug_message_prefix (void)
187  {  {
# Line 208  m4_debug_message_prefix (void) Line 192  m4_debug_message_prefix (void)
192      fprintf (m4_debug, "%d: ", m4_current_line);      fprintf (m4_debug, "%d: ", m4_current_line);
193  }  }
194    
195    
196  /* The rest of this file contains the functions for macro tracing output.  /* The rest of this file contains the functions for macro tracing output.
197     All tracing output for a macro call is collected on an obstack TRACE,     All tracing output for a macro call is collected on an obstack TRACE,
198     and printed whenever the line is complete.  This prevents tracing     and printed whenever the line is complete.  This prevents tracing
199     output from interfering with other debug messages generated by the     output from interfering with other debug messages generated by the
200     various builtins.  */     various builtins.  */
201    
202  /*---------------------------------------------------------------------.  /* Tracing output is formatted here, by a simplified printf-to-obstack
203  | Tracing output is formatted here, by a simplified printf-to-obstack  |    function trace_format ().  Understands only %S, %s, %d, %l (optional
204  | function trace_format ().  Understands only %S, %s, %d, %l (optional |    left quote) and %r (optional right quote).  */
 | left quote) and %r (optional right quote).                           |  
 `---------------------------------------------------------------------*/  
   
205  #if (defined __STDC__ && __STDC__) || defined PROTOTYPES  #if (defined __STDC__ && __STDC__) || defined PROTOTYPES
206  static void  static void
207  m4_trace_format (const char *fmt, ...)  m4_trace_format (const char *fmt, ...)
# Line 299  m4_trace_format (va_alist) Line 281  m4_trace_format (va_alist)
281    va_end (args);    va_end (args);
282  }  }
283    
284  /*------------------------------------------------------------------.  /* Format the standard header attached to all tracing output lines.  */
 | Format the standard header attached to all tracing output lines.  |  
 `------------------------------------------------------------------*/  
   
285  static void  static void
286  m4_trace_header (int id)  m4_trace_header (int id)
287  {  {
# Line 316  m4_trace_header (int id) Line 295  m4_trace_header (int id)
295      m4_trace_format ("id %d: ", id);      m4_trace_format ("id %d: ", id);
296  }  }
297    
298  /*----------------------------------------------------.  /* Print current tracing line, and clear the obstack.  */
 | Print current tracing line, and clear the obstack.  |  
 `----------------------------------------------------*/  
   
299  static void  static void
300  m4_trace_flush (void)  m4_trace_flush (void)
301  {  {
# Line 331  m4_trace_flush (void) Line 307  m4_trace_flush (void)
307    obstack_free (&trace, line);    obstack_free (&trace, line);
308  }  }
309    
310  /*-------------------------------------------------------------.  /* Do pre-argument-collction tracing for macro NAME.  Used from
311  | Do pre-argument-collction tracing for macro NAME.  Used from |     expand_macro ().  */
 | expand_macro ().                                             |  
 `-------------------------------------------------------------*/  
   
312  void  void
313  m4_trace_prepre (const char *name, int id)  m4_trace_prepre (const char *name, int id)
314  {  {
# Line 344  m4_trace_prepre (const char *name, int i Line 317  m4_trace_prepre (const char *name, int i
317    m4_trace_flush ();    m4_trace_flush ();
318  }  }
319    
320  /*-----------------------------------------------------------------------.  /* Format the parts of a trace line, that can be made before the macro is
321  | Format the parts of a trace line, that can be made before the macro is |     actually expanded.  Used from expand_macro ().  */
 | actually expanded.  Used from expand_macro ().                         |  
 `-----------------------------------------------------------------------*/  
   
322  void  void
323  m4_trace_pre (const char *name, int id, int argc, m4_token_data **argv)  m4_trace_pre (const char *name, int id, int argc, m4_token_data **argv)
324  {  {
# Line 401  INTERNAL ERROR: Bad token data type (m4_ Line 371  INTERNAL ERROR: Bad token data type (m4_
371      }      }
372  }  }
373    
374  /*-------------------------------------------------------------------.  /* Format the final part of a trace line and print it all.  Used from
375  | Format the final part of a trace line and print it all.  Used from |     expand_macro ().  */
 | expand_macro ().                                                   |  
 `-------------------------------------------------------------------*/  
   
376  void  void
377  m4_trace_post (const char *name, int id, int argc, m4_token_data **argv,  m4_trace_post (const char *name, int id, int argc, m4_token_data **argv,
378              const char *expanded)              const char *expanded)

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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