Get rid of src/libpspp/debug-print.h and all its users. (There were
[pspp-builds.git] / src / data / filename.c
index 728585df11d93ab6b810e75a6990c7b833965fab..cbfc04ceab3ebf351477708d09048c4108b2e42b 100644 (file)
@@ -35,8 +35,6 @@
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
-#include <libpspp/debug-print.h>
-
 /* PORTME: Everything in this file is system dependent. */
 
 #ifdef unix
@@ -78,12 +76,15 @@ fn_init (void)
 */
 void 
 fn_interp_vars (struct string *target, 
-                  const char *(*getenv) (const char *))
+               const char *(*getenv) (const char *))
 {
+  char *input ;
+  char *s ;
+
   assert (target);
 
-  char *input = xmalloc(ds_length(target) + 1);
-  char *s = input;
+  input = xmalloc(ds_length(target) + 1);
+  s = input;
 
   strcpy(input, ds_c_str(target));
 
@@ -141,6 +142,7 @@ fn_interp_vars (struct string *target,
              if (stop && *s == stop)
                s++;
            }
+         break;
 
        default:
          ds_putc (target, *s++);
@@ -592,10 +594,10 @@ fn_get_cwd (void)
   int size = 2;
   char *buffer = xmalloc (size);
   if ( buffer) 
-  {
-    buffer[0]='.';
-    buffer[1]='\0';
-  }
+    {
+      buffer[0]='.';
+      buffer[1]='\0';
+    }
 
   return buffer;
      
@@ -778,121 +780,14 @@ fn_close (const char *fn, FILE *f)
   else
     return fclose (f);
 }
-\f
-/* More extensive file handling. */
-
-/* File open routine that extends fn_open().  Opens or reopens a
-   file according to the contents of file_ext F.  Returns nonzero on
-   success.  If 0 is returned, errno is set to a sensible value. */
-int
-fn_open_ext (struct file_ext *f)
-{
-  char *p;
-
-  p = strstr (f->filename, "%d");
-  if (p)
-    {
-      char *s = local_alloc (strlen (f->filename)
-                             + INT_STRLEN_BOUND (int) - 1);
-      char *cp;
-
-      memcpy (s, f->filename, p - f->filename);
-      cp = spprintf (&s[p - f->filename], "%d", *f->sequence_no);
-      strcpy (cp, &p[2]);
-
-      if (f->file)
-       {
-         int error = 0;
-
-         if (f->preclose)
-           if (f->preclose (f) == 0)
-             error = errno;
-
-         if (EOF == fn_close (f->filename, f->file) || error)
-           {
-             f->file = NULL;
-             local_free (s);
-
-             if (error)
-               errno = error;
-
-             return 0;
-           }
-
-         f->file = NULL;
-       }
-
-      f->file = fn_open (s, f->mode);
-      local_free (s);
-
-      if (f->file && f->postopen)
-       if (f->postopen (f) == 0)
-         {
-           int error = errno;
-           fn_close (f->filename, f->file);
-           errno = error;
-
-           return 0;
-         }
-
-      return (f->file != NULL);
-    }
-  else if (f->file)
-    return 1;
-  else
-    {
-      f->file = fn_open (f->filename, f->mode);
-
-      if (f->file && f->postopen)
-       if (f->postopen (f) == 0)
-         {
-           int error = errno;
-           fn_close (f->filename, f->file);
-           errno = error;
-
-           return 0;
-         }
-
-      return (f->file != NULL);
-    }
-}
-
-/* Properly closes the file associated with file_ext F, if any.
-   Return nonzero on success.  If zero is returned, errno is set to a
-   sensible value. */
-int
-fn_close_ext (struct file_ext *f)
-{
-  if (f->file)
-    {
-      int error = 0;
-
-      if (f->preclose)
-       if (f->preclose (f) == 0)
-         error = errno;
-
-      if (EOF == fn_close (f->filename, f->file) || error)
-       {
-         f->file = NULL;
-
-         if (error)
-           errno = error;
-
-         return 0;
-       }
-
-      f->file = NULL;
-    }
-  return 1;
-}
 
 #ifdef unix
 /* A file's identity. */
 struct file_identity 
-  {
-    dev_t device;               /* Device number. */
-    ino_t inode;                /* Inode number. */
-  };
+{
+  dev_t device;               /* Device number. */
+  ino_t inode;                /* Inode number. */
+};
 
 /* Returns a pointer to a dynamically allocated structure whose
    value can be used to tell whether two files are actually the
@@ -938,9 +833,9 @@ fn_compare_file_identities (const struct file_identity *a,
 #else /* not unix */
 /* A file's identity. */
 struct file_identity 
-  {
-    char *normalized_filename;  /* File's normalized name. */
-  };
+{
+  char *normalized_filename;  /* File's normalized name. */
+};
 
 /* Returns a pointer to a dynamically allocated structure whose
    value can be used to tell whether two files are actually the