#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
-#include "message.h"
+#include <libpspp/assertion.h>
+#include <libpspp/message.h>
#include "file-handle-def.h"
-#include "filename.h"
+#include "file-name.h"
#include "por-file-writer.h"
#include "sys-file-writer.h"
-#include "str.h"
+#include <libpspp/str.h>
#include "scratch-writer.h"
#include "xalloc.h"
struct any_writer *writer;
char *extension;
- extension = fn_extension (fh_get_filename (handle));
+ extension = fn_extension (fh_get_file_name (handle));
str_lowercase (extension);
if (!strcmp (extension, ".por"))
dict));
}
- abort ();
+ NOT_REACHED ();
}
/* If PRIVATE is non-null, creates and returns a new any_writer,
case SCRATCH_FILE:
return scratch_writer_write_case (writer->private, c);
}
- abort ();
+ NOT_REACHED ();
}
/* Returns true if an I/O error has occurred on WRITER, false
case SCRATCH_FILE:
return scratch_writer_error (writer->private);
}
- abort ();
+ NOT_REACHED ();
}
/* Closes WRITER.
bool
any_writer_close (struct any_writer *writer)
{
+ bool ok;
+
if (writer == NULL)
return true;
switch (writer->type)
{
case SYSTEM_FILE:
- return sfm_close_writer (writer->private);
+ ok = sfm_close_writer (writer->private);
+ break;
case PORTABLE_FILE:
- return pfm_close_writer (writer->private);
+ ok = pfm_close_writer (writer->private);
+ break;
case SCRATCH_FILE:
- return scratch_writer_close (writer->private);
-
+ ok = scratch_writer_close (writer->private);
+ break;
+
default:
- abort ();
+ NOT_REACHED ();
}
+
+ free (writer);
+ return ok;
}