pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp/src ChangeLog message.c data/ChangeLog dat...


From: Ben Pfaff
Subject: [Pspp-cvs] pspp/src ChangeLog message.c data/ChangeLog dat...
Date: Sun, 16 Apr 2006 23:08:02 +0000

CVSROOT:        /cvsroot/pspp
Module name:    pspp
Branch:         
Changes by:     Ben Pfaff <address@hidden>      06/04/16 23:08:02

Modified files:
        src            : ChangeLog message.c 
        src/data       : ChangeLog filename.c filename.h 
        src/language   : line-buffer.c 
        src/libpspp    : ChangeLog message.h 
        src/output     : output.c 
        src/ui/gui     : ChangeLog message-dialog.c 

Log message:
        Continue reforming error message support.  In this phase, we get rid
        of VM() and the other msg() support for "verbosity", replacing it by a
        new function verbose_msg().

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ChangeLog.diff?tr1=1.268&tr2=1.269&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/message.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/ChangeLog.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/filename.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/filename.h.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/language/line-buffer.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/libpspp/ChangeLog.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/libpspp/message.h.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/output/output.c.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/ChangeLog.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/message-dialog.c.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: pspp/src/ChangeLog
diff -u pspp/src/ChangeLog:1.268 pspp/src/ChangeLog:1.269
--- pspp/src/ChangeLog:1.268    Sun Apr 16 18:55:09 2006
+++ pspp/src/ChangeLog  Sun Apr 16 23:08:02 2006
@@ -1,3 +1,12 @@
+Sun Apr 16 15:58:56 2006  Ben Pfaff  <address@hidden>
+
+       Continue reforming error message support.  In this phase, we get
+       rid of VM() and the other msg() support for "verbosity", replacing
+       it by a new function verbose_msg().
+
+       * message.c: (verbose_msg) New function.
+       (err_vmsg) Remove support for verbosity levels.
+
 Sun Apr 16 11:46:51 2006  Ben Pfaff  <address@hidden>
 
        Start reforming error message support.  In this phase, we get rid
Index: pspp/src/data/ChangeLog
diff -u pspp/src/data/ChangeLog:1.13 pspp/src/data/ChangeLog:1.14
--- pspp/src/data/ChangeLog:1.13        Sun Apr 16 02:54:56 2006
+++ pspp/src/data/ChangeLog     Sun Apr 16 23:08:02 2006
@@ -1,3 +1,17 @@
+Sun Apr 16 16:05:28 2006  Ben Pfaff  <address@hidden>
+
+       Continue reforming error message support.  In this phase, we get
+       rid of VM() and the other msg() support for "verbosity", replacing
+       it by a new function verbose_msg().
+
+       * filename.c: (fn_search_path) Rewrite for cleaner code.  Also,
+       get rid of non-Unixlike version of the code, which has probably
+       never been tested.
+       (fn_prepend_dir) Removed (dead code).
+
+       * filename.h: (macro DIR_SEPARATOR_STRING) New.
+       (macro PATH_SEPARATOR_STRING) New.
+
 Sat Apr 15 19:53:19 2006  Ben Pfaff  <address@hidden>
 
        * sfm-private.h: Get rid of #defines after #error, which makes no
Index: pspp/src/data/filename.c
diff -u pspp/src/data/filename.c:1.8 pspp/src/data/filename.c:1.9
--- pspp/src/data/filename.c:1.8        Sun Apr 16 04:46:41 2006
+++ pspp/src/data/filename.c    Sun Apr 16 23:08:02 2006
@@ -223,123 +223,61 @@
    Returns the malloc'd full name of the first file found, or NULL if
    none is found.
 
-   If PREPEND is non-NULL, then it is prepended to each filename;
-   i.e., it looks like PREPEND/PATH_COMPONENT/NAME.  This is not done
+   If PREFIX is non-NULL, then it is prefixed to each filename;
+   i.e., it looks like PREFIX/PATH_COMPONENT/NAME.  This is not done
    with absolute directories in the path. */
-#if defined (unix) || defined (__MSDOS__) || defined (__WIN32__)
 char *
-fn_search_path (const char *basename, const char *path, const char *prepend)
+fn_search_path (const char *base_name, const char *path_, const char *prefix)
 {
-  char *subst_path;
-  struct string filename;
-  const char *bp;
-
-  if (fn_absolute_p (basename))
-    return fn_tilde_expand (basename);
-  
-  {
-    struct string temp;
-    ds_create(&temp, path);
-
-    fn_interp_vars(&temp, fn_getenv);
-
-    bp = subst_path = fn_tilde_expand (ds_c_str(&temp));
-
-    ds_destroy(&temp);
-  }
-
-  msg (VM (4), _("Searching for `%s'..."), basename);
-  ds_init (&filename, 64);
-
-  for (;;)
-    {
-      const char *ep;
-      if (0 == *bp)
+  struct string path;
+  struct string dir = DS_INITIALIZER;
+  struct string file = DS_INITIALIZER;
+  char *tmp_str;
+  size_t save_idx = 0;
+
+  if (fn_absolute_p (base_name))
+    return fn_tilde_expand (base_name);
+
+  /* Interpolate environment variables and do tilde-expansion. */
+  ds_create (&path, path_);
+  fn_interp_vars (&path, fn_getenv);
+
+  tmp_str = fn_tilde_expand (ds_c_str (&path));
+  ds_assign_c_str (&path, tmp_str);
+  free (tmp_str); 
+
+  verbose_msg (2, _("searching for \"%s\" in path \"%s\""),
+               base_name, ds_c_str (&path));
+  while (ds_separate (&path, &dir, PATH_DELIMITER_STRING, &save_idx))
+    {
+      /* Construct file name. */
+      ds_clear (&file);
+      if (prefix != NULL && !fn_absolute_p (ds_c_str (&dir)))
        {
-         msg (VM (4), _("Search unsuccessful!"));
-         ds_destroy (&filename);
-         free (subst_path);
-         return NULL;
+         ds_puts (&file, prefix);
+         ds_putc (&file, DIR_SEPARATOR);
        }
+      ds_puts (&file, ds_c_str (&dir));
+      if (ds_length (&dir) && ds_last (&file) != DIR_SEPARATOR)
+       ds_putc (&file, DIR_SEPARATOR);
+      ds_puts (&file, base_name);
 
-      for (ep = bp; *ep && *ep != PATH_DELIMITER; ep++)
-       ;
-
-      /* Paste together PREPEND/PATH/BASENAME. */
-      ds_clear (&filename);
-      if (prepend && !fn_absolute_p (bp))
-       {
-         ds_puts (&filename, prepend);
-         ds_putc (&filename, DIR_SEPARATOR);
-       }
-      ds_concat (&filename, bp, ep - bp);
-      if (ep - bp
-         && ds_c_str (&filename)[ds_length (&filename) - 1] != DIR_SEPARATOR)
-       ds_putc (&filename, DIR_SEPARATOR);
-      ds_puts (&filename, basename);
-      
-      msg (VM (5), " - %s", ds_c_str (&filename));
-      if (fn_exists_p (ds_c_str (&filename)))
+      /* Check whether file exists. */
+      if (fn_exists_p (ds_c_str (&file)))
        {
-         msg (VM (4), _("Found `%s'."), ds_c_str (&filename));
-         free (subst_path);
-         return ds_c_str (&filename);
+         verbose_msg (2, _("...found \"%s\""), ds_c_str (&file));
+          ds_destroy (&path);
+          ds_destroy (&dir);
+         return ds_c_str (&file);
        }
-
-      if (0 == *ep)
-       {
-         msg (VM (4), _("Search unsuccessful!"));
-         free (subst_path);
-         ds_destroy (&filename);
-         return NULL;
-       }
-      bp = ep + 1;
-    }
-}
-#else /* not unix, msdog, lose32 */
-char *
-fn_search_path (const char *basename, const char *path, const char *prepend)
-{
-  size_t size = strlen (path) + 1 + strlen (basename) + 1;
-  char *string;
-  char *cp;
-  
-  if (prepend)
-    size += strlen (prepend) + 1;
-  string = xmalloc (size);
-  
-  cp = string;
-  if (prepend)
-    {
-      cp = stpcpy (cp, prepend);
-      *cp++ = DIR_SEPARATOR;
     }
-  cp = stpcpy (cp, path);
-  *cp++ = DIR_SEPARATOR;
-  strcpy (cp, basename);
 
-  return string;
-}
-#endif /* not unix, msdog, lose32 */
-
-/* Prepends directory DIR to filename FILE and returns a malloc()'d
-   copy of it. */
-char *
-fn_prepend_dir (const char *file, const char *dir)
-{
-  char *temp;
-  char *cp;
-  
-  if (fn_absolute_p (file))
-    return xstrdup (file);
-
-  temp = xmalloc (strlen (file) + 1 + strlen (dir) + 1);
-  cp = stpcpy (temp, dir);
-  if (cp != temp && cp[-1] != DIR_SEPARATOR)
-    *cp++ = DIR_SEPARATOR;
-  cp = stpcpy (cp, file);
-
-  return temp;
+  /* Failure. */
+  verbose_msg (2, _("...not found"));
+  ds_destroy (&path);
+  ds_destroy (&dir);
+  ds_destroy (&file);
+  return NULL;
 }
 
 /* fn_normalize(): This very OS-dependent routine canonicalizes
Index: pspp/src/data/filename.h
diff -u pspp/src/data/filename.h:1.3 pspp/src/data/filename.h:1.4
--- pspp/src/data/filename.h:1.3        Sun Apr 16 02:42:39 2006
+++ pspp/src/data/filename.h    Sun Apr 16 23:08:02 2006
@@ -26,9 +26,13 @@
 #ifndef __MSDOS__
 #define DIR_SEPARATOR '/'
 #define PATH_DELIMITER ':'
+#define DIR_SEPARATOR_STRING "/"
+#define PATH_DELIMITER_STRING ":"
 #else
 #define DIR_SEPARATOR '\\'
 #define PATH_DELIMITER ';'
+#define DIR_SEPARATOR_STRING "\\"
+#define PATH_DELIMITER_STRING ";"
 #endif
 
 /* Search path for configuration files. */
@@ -40,9 +44,8 @@
 void fn_interp_vars (struct string *target, 
                        const char *(*getenv) (const char *));
 char *fn_tilde_expand (const char *fn);
-char *fn_search_path (const char *basename, const char *path,
-                     const char *prepend);
-char *fn_prepend_dir (const char *filename, const char *directory);
+char *fn_search_path (const char *base_name, const char *path,
+                     const char *prefix);
 char *fn_normalize (const char *fn);
 char *fn_dirname (const char *fn);
 char *fn_basename (const char *fn);
Index: pspp/src/language/line-buffer.c
diff -u pspp/src/language/line-buffer.c:1.3 pspp/src/language/line-buffer.c:1.4
--- pspp/src/language/line-buffer.c:1.3 Mon Apr  3 20:07:54 2006
+++ pspp/src/language/line-buffer.c     Sun Apr 16 23:08:02 2006
@@ -438,7 +438,7 @@
   /* Open file, if not yet opened. */
   if (s->u.syntax_file == NULL)
     {
-      msg (VM (1), _("%s: Opening as syntax file."), s->fn);
+      verbose_msg (1, _("opening \"%s\" as syntax file"), s->fn);
       s->u.syntax_file = fn_open (s->fn, "r");
 
       if (s->u.syntax_file == NULL)
Index: pspp/src/libpspp/ChangeLog
diff -u pspp/src/libpspp/ChangeLog:1.8 pspp/src/libpspp/ChangeLog:1.9
--- pspp/src/libpspp/ChangeLog:1.8      Sun Apr 16 18:55:09 2006
+++ pspp/src/libpspp/ChangeLog  Sun Apr 16 23:08:02 2006
@@ -1,3 +1,15 @@
+Sun Apr 16 16:05:43 2006  Ben Pfaff  <address@hidden>
+
+       Continue reforming error message support.  In this phase, we get
+       rid of VM() and the other msg() support for "verbosity", replacing
+       it by a new function verbose_msg().
+
+       * message.h: (enum ERR_CLASS_COUNT) Renamed ERR_CLASS_CNT.
+       (enum ERR_CLASS_MASK) Removed.
+       (enum ERR_VERBOSITY_SHIFT) Removed.
+       (enum ERR_VERBOSITY_MASK) Removed.
+       (macro VM) Removed.
+
 Sun Apr 16 11:48:07 2006  Ben Pfaff  <address@hidden>
 
        Start reforming error message support.  In this phase, we get rid
Index: pspp/src/libpspp/message.h
diff -u pspp/src/libpspp/message.h:1.3 pspp/src/libpspp/message.h:1.4
--- pspp/src/libpspp/message.h:1.3      Sun Apr 16 18:55:09 2006
+++ pspp/src/libpspp/message.h  Sun Apr 16 23:08:02 2006
@@ -30,16 +30,9 @@
     SE, SW, SM,                        /* Script error/warning/message. */
     DE, DW,                    /* Data-file error/warning. */
     ME, MW, MM,                        /* General error/warning/message. */
-    ERR_CLASS_COUNT,           /* Number of message classes. */
-    ERR_CLASS_MASK = 0xf,      /* Bitmask for class. */
-    ERR_VERBOSITY_SHIFT = 4,   /* Shift count for verbosity. */
-    ERR_VERBOSITY_MASK = 0xf   /* Bitmask for verbosity. */
+    MSG_CLASS_CNT,
   };
 
-/* If passed to msg() as CLASS, the return value will cause the message
-   to be displayed only if `verbosity' is at least LEVEL. */
-#define VM(LEVEL) (MM | ((LEVEL) << ERR_VERBOSITY_SHIFT))
-
 /* A file location.  */
 struct file_locator
   {
@@ -73,6 +66,9 @@
 void tmsg (int class, const char *title, const char *format, ...)
      PRINTF_FORMAT (3, 4);
 
+void verbose_msg (int level, const char *format, ...)
+     PRINTF_FORMAT (2, 3);
+
 /* File-locator stack. */
 void err_push_file_locator (const struct file_locator *);
 void err_pop_file_locator (const struct file_locator *);
Index: pspp/src/message.c
diff -u pspp/src/message.c:1.3 pspp/src/message.c:1.4
--- pspp/src/message.c:1.3      Sun Apr 16 18:55:09 2006
+++ pspp/src/message.c  Sun Apr 16 23:08:02 2006
@@ -30,6 +30,7 @@
 #include <data/settings.h>
 #include <ui/terminal/read-line.h>
 #include <libpspp/version.h>
+#include "progname.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -80,6 +81,23 @@
   va_end (args);
 }
 
+/* Writes MESSAGE formatted with printf, to stderr, if the
+   verbosity level is at least LEVEL. */
+void
+verbose_msg (int level, const char *format, ...)
+{
+  if (err_verbosity >= level)
+    {
+      va_list args;
+  
+      va_start (args, format);
+      fprintf (stderr, "%s: ", program_name);
+      vfprintf (stderr, format, args);
+      putc ('\n', stderr);
+      va_end (args);
+    }
+}
+
 /* Checks whether we've had so many errors that it's time to quit
    processing this syntax file. */
 void
@@ -138,7 +156,7 @@
       const char *banner;      /* Banner. */
     };
 
-  static const struct error_class error_classes[ERR_CLASS_COUNT] =
+  static const struct error_class error_classes[MSG_CLASS_CNT] =
     {
       {3, &err_error_count, N_("error")},      /* SE */
       {3, &err_warning_count, N_("warning")},  /* SW */
@@ -153,19 +171,12 @@
     };
 
   struct string msg;
-  int class;
 
-  /* Check verbosity level. */
-  class = e->class;
-  if (((class >> ERR_VERBOSITY_SHIFT) & ERR_VERBOSITY_MASK) > err_verbosity)
-    return;
-  class &= ERR_CLASS_MASK;
-  
-  assert (class >= 0 && class < ERR_CLASS_COUNT);
+  assert (e->class >= 0 && e->class < MSG_CLASS_CNT);
   assert (format != NULL);
   
   ds_init (&msg, 64);
-  if (e->where.filename && (error_classes[class].flags & ERR_WITH_FILE))
+  if (e->where.filename && (error_classes[e->class].flags & ERR_WITH_FILE))
     {
       ds_printf (&msg, "%s:", e->where.filename);
       if (e->where.line_number != -1)
@@ -173,15 +184,16 @@
       ds_putc (&msg, ' ');
     }
 
-  ds_printf (&msg, "%s: ", gettext (error_classes[class].banner));
+  ds_printf (&msg, "%s: ", gettext (error_classes[e->class].banner));
   
   {
-    int *count = error_classes[class].count;
+    int *count = error_classes[e->class].count;
     if (count)
       (*count)++;
   }
   
-  if (command_name != NULL && (error_classes[class].flags & ERR_IN_PROCEDURE))
+  if (command_name != NULL
+      && (error_classes[e->class].flags & ERR_IN_PROCEDURE))
     ds_printf (&msg, "%s: ", command_name);
 
   if (e->title)
Index: pspp/src/output/output.c
diff -u pspp/src/output/output.c:1.9 pspp/src/output/output.c:1.10
--- pspp/src/output/output.c:1.9        Sun Apr 16 18:55:09 2006
+++ pspp/src/output/output.c    Sun Apr 16 23:08:02 2006
@@ -291,7 +291,7 @@
   if (init_fn == NULL)
     {
       error (0, 0, _("cannot find output initialization file "
-                     "(use `-vvvvv' to view search path)"));
+                     "(use `-vv' to view search path)"));
       goto exit;
     }
 
Index: pspp/src/ui/gui/ChangeLog
diff -u pspp/src/ui/gui/ChangeLog:1.3 pspp/src/ui/gui/ChangeLog:1.4
--- pspp/src/ui/gui/ChangeLog:1.3       Sun Apr 16 18:55:10 2006
+++ pspp/src/ui/gui/ChangeLog   Sun Apr 16 23:08:02 2006
@@ -1,3 +1,13 @@
+Sun Apr 16 16:06:54 2006  Ben Pfaff  <address@hidden>
+
+       Continue reforming error message support.  In this phase, we get
+       rid of VM() and the other msg() support for "verbosity", replacing
+       it by a new function verbose_msg().
+
+       * message-dialog.c: (verbose_msg) New function.  
+       (err_cond_fail) Removed (dead code).
+       (err_failure) Removed (dead code).
+
 Sun Apr 16 11:53:25 2006  Ben Pfaff  <address@hidden>
 
        Start reforming error message support.  In this phase, we get rid
Index: pspp/src/ui/gui/message-dialog.c
diff -u pspp/src/ui/gui/message-dialog.c:1.4 
pspp/src/ui/gui/message-dialog.c:1.5
--- pspp/src/ui/gui/message-dialog.c:1.4        Sun Apr 16 18:55:10 2006
+++ pspp/src/ui/gui/message-dialog.c    Sun Apr 16 23:08:02 2006
@@ -26,6 +26,7 @@
 #include <config.h>
 #include <libpspp/message.h>
 #include "message-dialog.h"
+#include "progname.h"
 
 
 #include <gtk/gtk.h>
@@ -134,22 +135,14 @@
   msg(ME, "Assertion failed: %s:%d; (%s)\n",file,line,expr);
 }
 
-/* The GUI is always interactive.
-   So this function does nothing */
-void 
-err_cond_fail(void)
-{
-}
-
-
+/* Writes MESSAGE formatted with printf, to stderr, if the
+   verbosity level is at least LEVEL. */
 void
-err_failure(void)
+verbose_msg (int level, const char *format, ...)
 {
-  msg(ME, _("Terminating NOW due to fatal error"));
-  gtk_main_quit();
+  /* Do nothing for now. */
 }
 
-
 /* FIXME: This is a stub .
  * A temporary workaround until getl.c is rearranged
  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]