/[pspp]/pspp/src/error.c
ViewVC logotype

Diff of /pspp/src/error.c

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

revision 1.11 by jmd, Fri Nov 19 06:06:22 2004 UTC revision 1.12 by blp, Tue Mar 1 08:16:15 2005 UTC
# Line 26  Line 26 
26  #include "alloc.h"  #include "alloc.h"
27  #include "command.h"  #include "command.h"
28  #include "getline.h"  #include "getline.h"
29    #include "glob.h"
30    #include "lexer.h"
31  #include "main.h"  #include "main.h"
32  #include "output.h"  #include "output.h"
33  #include "settings.h"  #include "settings.h"
# Line 51  static int nfile_loc, mfile_loc; Line 53  static int nfile_loc, mfile_loc;
53  void  void
54  tmsg (int class, const char *title, const char *format, ...)  tmsg (int class, const char *title, const char *format, ...)
55  {  {
56    char buf[1024];    struct error e;
57        va_list args;
   /* Format the message into BUF. */  
   {  
     va_list args;  
   
     va_start (args, format);  
     vsnprintf (buf, 1024, format, args);  
     va_end (args);  
   }  
     
   /* Output the message. */  
   {  
     struct error e;  
58    
59      e.class = class;    e.class = class;
60      err_location (&e.where);    err_location (&e.where);
61      e.title = title;    e.title = title;
62      e.text = buf;  
63      err_vmsg (&e);    va_start (args, format);
64    }    err_vmsg (&e, format, args);
65      va_end (args);
66  }  }
67    
68  /* Writes error message in CLASS, with text FORMAT, formatted with  /* Writes error message in CLASS, with text FORMAT, formatted with
# Line 79  tmsg (int class, const char *title, cons Line 70  tmsg (int class, const char *title, cons
70  void  void
71  msg (int class, const char *format, ...)  msg (int class, const char *format, ...)
72  {  {
73    struct string buf;    struct error e;
74        va_list args;
   ds_init (&buf, 1024);  
   
   /* Format the message into BUF. */  
   {  
     va_list args;  
   
     va_start (args, format);  
     ds_vprintf (&buf, format, args);  
     va_end (args);  
   }  
     
   /* Output the message. */  
   {  
     struct error e;  
   
     e.class = class;  
     err_location (&e.where);  
     e.title = NULL;  
     e.text = buf.string;  
     err_vmsg (&e);  
   }  
75    
76    ds_destroy (&buf);    e.class = class;
77      err_location (&e.where);
78      e.title = NULL;
79    
80      va_start (args, format);
81      err_vmsg (&e, format, args);
82      va_end (args);
83  }  }
84    
85  /* Terminate due to fatal error in input. */  /* Terminate due to fatal error in input. */
# Line 239  static void dump_message (char *errbuf, Line 215  static void dump_message (char *errbuf,
215                            void (*func) (const char *), unsigned width);                            void (*func) (const char *), unsigned width);
216    
217  void  void
218  err_vmsg (const struct error *e)  err_vmsg (const struct error *e, const char *format, va_list args)
219  {  {
220    /* Class flags. */    /* Class flags. */
221    enum    enum
# Line 285  err_vmsg (const struct error *e) Line 261  err_vmsg (const struct error *e)
261    class &= ERR_CLASS_MASK;    class &= ERR_CLASS_MASK;
262        
263    assert (class >= 0 && class < ERR_CLASS_COUNT);    assert (class >= 0 && class < ERR_CLASS_COUNT);
264    assert (e->text != NULL);    assert (format != NULL);
265        
266    ds_init (&msg, 64);    ds_init (&msg, 64);
267    if (e->where.filename && (error_classes[class].flags & ERR_WITH_FILE))    if (e->where.filename && (error_classes[class].flags & ERR_WITH_FILE))
# Line 310  err_vmsg (const struct error *e) Line 286  err_vmsg (const struct error *e)
286    if (e->title)    if (e->title)
287      ds_puts (&msg, e->title);      ds_puts (&msg, e->title);
288    
289    ds_puts (&msg, e->text);    ds_vprintf (&msg, format, args);
290    
291    /* FIXME: Check set_messages and set_errors to determine where to    /* FIXME: Check set_messages and set_errors to determine where to
292       send errors and messages.       send errors and messages.
# Line 504  dump_message (char *msg, unsigned indent Line 480  dump_message (char *msg, unsigned indent
480        memset (buf, ' ', indent);        memset (buf, ' ', indent);
481        memcpy (&buf[indent], cp, cp2 - cp);        memcpy (&buf[indent], cp, cp2 - cp);
482    
       if ( hard_break)  
         {  
           buf[indent + idx + cp2 - cp] = '\n';  
           ++idx;  
         }  
483        buf[indent + idx + cp2 - cp] = '\0';        buf[indent + idx + cp2 - cp] = '\0';
484        func (buf);        func (buf);
485        cp = cp2;        cp = cp2;

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