Commit 5c62ed4b authored by Kipp Cannon's avatar Kipp Cannon
Browse files

clean up metaio.c now that zlib is no longer optional

parent 6443e087
......@@ -43,6 +43,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <zlib.h>
#include "config.h"
#include "metaio.h"
......@@ -57,13 +58,6 @@
#define DEBUGMSG2(s,d)
#endif /* DEBUG */
#ifdef HAVE_LIBZ
#include <zlib.h>
#define gzclose(fp) gzclose((gzFile)(fp))
#define gzgetc(fp) gzgetc((gzFile)(fp))
#define gzungetc(c,fp) gzungetc(c,(gzFile)(fp))
/*
* Warning: This is not a fully implemented scanf routine!
* Warning: Only a single conversion to a numeric type is supported!
......@@ -155,38 +149,6 @@ static int geterrno( gzFile file, const char **msg )
return errnum;
}
#else /* HAVE_LIBZ */
#define gzopen(path,mode) fopen(path,mode)
#define gzclose(fp) fclose(fp)
#define gzgetc(fp) fgetc(fp)
#define gzungetc(c,fp) ungetc(c,fp)
#define gzscanf fscanf
static int geterrno( FILE *file, const char **msg )
{
int errnum;
if(ferror(file))
{
/* there was an error, use errno and retrieve appropriate message */
*msg = strerror(errno);
errnum = errno;
}
else
{
/* no error */
*msg = NULL;
if(feof(file))
/* EOF probably doesn't overlap with any errno constants */
errnum = EOF;
else
errnum = 0;
}
return errnum;
}
#endif /* HAVE_LIBZ */
enum Token {
CLOSE_COLUMN,
......@@ -597,7 +559,7 @@ int destroy_parse_env(MetaioParseEnv const env)
{
if ( env->file->mode == 'r' )
{
ret = gzclose(env->file->fp);
ret = gzclose((gzFile) env->file->fp);
if ( ret == -3 )
/* XXX hack put in due to bug in zlib 1.2.2 XXX */
/* XXX this is not necessary in 1.2.3 and should XXX */
......@@ -671,7 +633,7 @@ int character_entity(const char* const s)
static
int get_char(MetaioParseEnv env)
{
int c = gzgetc(env->file->fp);
int c = gzgetc((gzFile) env->file->fp);
if(c < 0)
{
......@@ -709,7 +671,7 @@ int unget_char(MetaioParseEnv env, int c)
if (c == '\n')
env->file->lineno--;
return gzungetc(c, env->file->fp);
return gzungetc(c, (gzFile) env->file->fp);
}
/*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment