changeset 21913:c0604bba8da1

provide wrappers for fseeko and ftello * liboctave/wrappers/filepos-wrappers.c, liboctave/wrappers/filepos-wrappers.h: New files. * liboctave/wrappers/module.mk: Update. * c-file-ptr-stream.cc: Use new wrapper functions.
author John W. Eaton <jwe@octave.org>
date Wed, 15 Jun 2016 14:29:17 -0400
parents d92dcbcd7691
children b42b28d47f31
files libinterp/corefcn/c-file-ptr-stream.cc liboctave/wrappers/filepos-wrappers.c liboctave/wrappers/filepos-wrappers.h liboctave/wrappers/module.mk
diffstat 4 files changed, 102 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/c-file-ptr-stream.cc	Wed Jun 15 12:59:43 2016 -0400
+++ b/libinterp/corefcn/c-file-ptr-stream.cc	Wed Jun 15 14:29:17 2016 -0400
@@ -26,6 +26,8 @@
 
 #include <iostream>
 
+#include "filepos-wrappers.h"
+
 #include "c-file-ptr-stream.h"
 
 #if ! defined (SEEK_SET)
@@ -113,9 +115,9 @@
 {
   if (f)
     {
-      gnulib::fseeko (f, offset, seekdir_to_whence (dir));
+      octave_fseeko_wrapper (f, offset, seekdir_to_whence (dir));
 
-      return gnulib::ftello (f);
+      return octave_ftello_wrapper (f);
     }
   else
     return 0;
@@ -126,9 +128,9 @@
 {
   if (f)
     {
-      gnulib::fseeko (f, offset, SEEK_SET);
+      octave_fseeko_wrapper (f, offset, SEEK_SET);
 
-      return gnulib::ftello (f);
+      return octave_ftello_wrapper (f);
     }
   else
     return 0;
@@ -167,13 +169,13 @@
 int
 c_file_ptr_buf::seek (off_t offset, int origin)
 {
-  return f ? gnulib::fseeko (f, offset, origin) : -1;
+  return f ? octave_fseeko_wrapper (f, offset, origin) : -1;
 }
 
 off_t
 c_file_ptr_buf::tell (void)
 {
-  return f ? gnulib::ftello (f) : -1;
+  return f ? octave_ftello_wrapper (f) : -1;
 }
 
 int
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/wrappers/filepos-wrappers.c	Wed Jun 15 14:29:17 2016 -0400
@@ -0,0 +1,46 @@
+/*
+
+Copyright (C) 2016 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+// ftello and fseeko may be provided by gnulib.  We don't include gnulib
+// headers directly in Octave's C++ source files to avoid problems that
+// may be caused by the way that gnulib overrides standard library
+// functions.
+
+#if defined (HAVE_CONFIG_H)
+#  include "config.h"
+#endif
+
+#include <stdio.h>
+
+#include "filepos-wrappers.h"
+
+int
+octave_fseeko_wrapper (FILE *fp, off_t offset, int whence)
+{
+  return fseeko (fp, offset, whence);
+}
+
+off_t
+octave_ftello_wrapper (FILE *fp)
+{
+  return ftello (fp);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/wrappers/filepos-wrappers.h	Wed Jun 15 14:29:17 2016 -0400
@@ -0,0 +1,46 @@
+/*
+
+Copyright (C) 2016 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if ! defined (octave_filepos_wrappers_h)
+#define octave_filepos_wrappers_h 1
+
+#include <sys/types.h>
+
+#if defined __cplusplus
+#  include <cstdio>
+#else
+#  include <stdio.h>
+#endif
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+extern int octave_fseeko_wrapper (FILE *fp, off_t offset, int whence);
+
+extern off_t octave_ftello_wrapper (FILE *fp);
+
+#if defined __cplusplus
+}
+#endif
+
+#endif
--- a/liboctave/wrappers/module.mk	Wed Jun 15 12:59:43 2016 -0400
+++ b/liboctave/wrappers/module.mk	Wed Jun 15 14:29:17 2016 -0400
@@ -3,6 +3,7 @@
   liboctave/wrappers/base64-wrappers.h \
   liboctave/wrappers/canonicalize-file-name-wrapper.h \
   liboctave/wrappers/fcntl-wrappers.h \
+  liboctave/wrappers/filepos-wrappers.h \
   liboctave/wrappers/fpucw-wrapper.h \
   liboctave/wrappers/gen-tempname-wrapper.h \
   liboctave/wrappers/hash-wrappers.h \
@@ -27,6 +28,7 @@
   liboctave/wrappers/base64-wrappers.c \
   liboctave/wrappers/canonicalize-file-name-wrapper.c \
   liboctave/wrappers/fcntl-wrappers.c \
+  liboctave/wrappers/filepos-wrappers.c \
   liboctave/wrappers/fpucw-wrapper.c \
   liboctave/wrappers/gen-tempname-wrapper.c \
   liboctave/wrappers/hash-wrappers.c \