#include "gettext.h"
#define _(msgid) gettext (msgid)
-#include <libpspp/debug-print.h>
-
/* PORTME: Everything in this file is system dependent. */
#ifdef unix
*/
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));
if (stop && *s == stop)
s++;
}
+ break;
default:
ds_putc (target, *s++);
int size = 2;
char *buffer = xmalloc (size);
if ( buffer)
- {
- buffer[0]='.';
- buffer[1]='\0';
- }
+ {
+ buffer[0]='.';
+ buffer[1]='\0';
+ }
return buffer;
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
#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