Reduce platform dependence.
authorBen Pfaff <blp@gnu.org>
Mon, 12 Feb 2007 02:10:54 +0000 (02:10 +0000)
committerBen Pfaff <blp@gnu.org>
Mon, 12 Feb 2007 02:10:54 +0000 (02:10 +0000)
This helps with build on mingw32 (and probably other platforms).
Patch #5731.

19 files changed:
ChangeLog
Makefile.am
Smake
configure.ac
doc/configuring.texi
src/data/ChangeLog
src/data/data-out.h
src/data/file-name.c
src/data/file-name.h
src/data/por-file-writer.c
src/data/sys-file-writer.c
src/language/ChangeLog
src/language/command.c
src/language/utilities/permissions.c
src/output/ChangeLog
src/output/html.c
src/ui/gui/glade-register.c
src/ui/terminal/ChangeLog
src/ui/terminal/read-line.c

index e50320c42c20e30e3965462ee5418dd7bf5a0528..b5000702ee792bcb58c1067cfe23fcb72f0e8543 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+Thu Feb  8 14:56:18 2007  Ben Pfaff  <blp@gnu.org>
+
+       Reduce platform dependence.
+
+       * Makefile.am: Don't add -Dunix or -D__MSDOS__ to compiler command
+       line.  Add $(top_builddir)/intl to include path to fix building
+       with the included libintl.
+
+       * Smake (GNULIB_MODULES): Add `canonicalize', `sys_stat',
+       `mkstemp' modules.  Remove `stat-macros' module, which is no
+       longer what we want, because what we want is provided by sys_stat
+       now, and remove its inclusions.  Remove `strstr' module, which is
+       no longer in gnulib.  Remove `readlink', `xreadlink', because we
+       no longer use either function.
+
+       * configure.ac: Move gl_EARLY before AC_PROG_CC, where the gnulib
+       manual says it should be.  Check for presence of execl, fork,
+       and popen.  Drop check for unix versus msdos as host OS.
+
 Sat Nov  4 15:59:31 2006  Ben Pfaff  <blp@gnu.org>
 
        * configure.ac: Check for the "round" function added in C99.
 Sat Nov  4 15:59:31 2006  Ben Pfaff  <blp@gnu.org>
 
        * configure.ac: Check for the "round" function added in C99.
index ad84db7deda6b2ea93c89adfdaa0a295495292f0..0b37ce974ff650919c615d478e3a8033d71d3be5 100644 (file)
@@ -6,7 +6,8 @@ SUBDIRS = intl gl po
 DISTCLEANFILES = ./intl/plural.c ./po/stamp-po
 BUILT_SOURCES =
 
 DISTCLEANFILES = ./intl/plural.c ./po/stamp-po
 BUILT_SOURCES =
 
-AM_CPPFLAGS=-I$(top_srcdir)/intl -I$(top_srcdir)/gl -I$(top_builddir)/gl
+AM_CPPFLAGS=-I$(top_srcdir)/intl -I$(top_builddir)/intl \
+       -I$(top_srcdir)/gl -I$(top_builddir)/gl
 
 AM_CFLAGS=
 
 
 AM_CFLAGS=
 
@@ -15,14 +16,6 @@ AM_CFLAGS+=-Wall -W -Wwrite-strings -Wstrict-prototypes \
 -Wpointer-arith -Wno-sign-compare -Wmissing-prototypes
 endif
 
 -Wpointer-arith -Wno-sign-compare -Wmissing-prototypes
 endif
 
-if unix
-AM_CFLAGS+=-Dunix
-endif
-
-if msdos
-AM_CFLAGS+=-D__MSDOS__
-endif
-
 .q.c:
        @$(top_srcdir)/mkinstalldirs  `dirname $@`
        ./src/language/lexer/q2c $< $@
 .q.c:
        @$(top_srcdir)/mkinstalldirs  `dirname $@`
        ./src/language/lexer/q2c $< $@
diff --git a/Smake b/Smake
index 74202e999efb4e2302890cbc94c54bb017a8a8f3..00d64d2ff1dae4c48b551e43517efed8698cfd78 100644 (file)
--- a/Smake
+++ b/Smake
@@ -9,6 +9,7 @@ GNULIB_MODULES = \
        alloca-opt \
        assert \
        byteswap \
        alloca-opt \
        assert \
        byteswap \
+       canonicalize \
        c-ctype \
        c-strtod \
        exit \
        c-ctype \
        c-strtod \
        exit \
@@ -30,10 +31,9 @@ GNULIB_MODULES = \
        memmove \
        mempcpy \
        memset \
        memmove \
        mempcpy \
        memset \
+       mkstemp \
        progname \
        progname \
-       readlink \
        snprintf \
        snprintf \
-       stat-macros \
        stdarg \
        stdbool \
        stdint \
        stdarg \
        stdbool \
        stdint \
@@ -43,17 +43,16 @@ GNULIB_MODULES = \
        strerror \
        strftime \
        strsep \
        strerror \
        strftime \
        strsep \
-       strstr \
        strtod \
        strtok_r \
        strtol \
        strtoul \
        strtod \
        strtok_r \
        strtol \
        strtoul \
+       sys_stat \
        unistd \
        unlocked-io \
        vsnprintf \
        xalloc \
        xalloc-die \
        unistd \
        unlocked-io \
        vsnprintf \
        xalloc \
        xalloc-die \
-       xreadlink \
        xsize \
        xstrndup \
        xvasprintf
        xsize \
        xstrndup \
        xvasprintf
index 47c0e7e00dac1ff500c305d81dd6e6823ebae13d..9e9835e83691de5cdf8a5ee2c8154ba4b678ab91 100644 (file)
@@ -42,10 +42,10 @@ fi
 AM_CONDITIONAL(WITHGUI, test x"$with_gui" != x"no")
 
 AC_ARG_WITH(gui_tools, [  --with-gui-tools          build the gui developer tools])
 AM_CONDITIONAL(WITHGUI, test x"$with_gui" != x"no")
 
 AC_ARG_WITH(gui_tools, [  --with-gui-tools          build the gui developer tools])
-if test x"$with_gui_tools" == x"yes" ; then 
+if test x"$with_gui_tools" = x"yes" ; then 
        PKG_CHECK_MODULES(GLADE_UI, libgladeui-1.0)
 fi
        PKG_CHECK_MODULES(GLADE_UI, libgladeui-1.0)
 fi
-AM_CONDITIONAL(WITH_GUI_TOOLS, test x"$with_gui_tools" == x"yes")
+AM_CONDITIONAL(WITH_GUI_TOOLS, test x"$with_gui_tools" = x"yes")
 
 PSPP_OFF_T
 
 
 PSPP_OFF_T
 
@@ -80,14 +80,10 @@ AC_DEFINE(FPREP_IEEE754, 1,
 AC_C_BIGENDIAN
 
 AC_FUNC_VPRINTF
 AC_C_BIGENDIAN
 
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([__setfpucw isinf isnan finite getpid feholdexcept round trunc])
+AC_CHECK_FUNCS([__setfpucw execl fork isinf isnan finite getpid feholdexcept popen round trunc])
 
 AC_PROG_LN_S
 
 
 AC_PROG_LN_S
 
-
-AM_CONDITIONAL(unix, test x"$host_os" != x"msdos" )
-AM_CONDITIONAL(msdos, test x"$host_os" = x"msdos" )
-
 dnl This is needed otherwise --with-included-gettext fails
 AH_BOTTOM([#include <locale.h>])
 
 dnl This is needed otherwise --with-included-gettext fails
 AH_BOTTOM([#include <locale.h>])
 
index 49f4ccdfc15c719706687413ae297e719a1ba18e..833840b31ff388af1c513ef40a5843b29de80347 100644 (file)
@@ -22,7 +22,7 @@ This chapter describe how to configure PSPP for your system.
 
 PSPP searches each directory in the configuration file path for most
 configuration files.  The default configuration file path searches first
 
 PSPP searches each directory in the configuration file path for most
 configuration files.  The default configuration file path searches first
-@file{~/.pspp}, then the package system configuration directory (usually
+@file{$HOME/.pspp}, then the package system configuration directory (usually
 @file{/usr/local/etc/pspp} or @file{/etc/pspp}).  The value of
 environment variable @env{PSPP_CONFIG_PATH}, if defined, overrides this
 default path.  Finally, @samp{-B @var{path}} or
 @file{/usr/local/etc/pspp} or @file{/etc/pspp}).  The value of
 environment variable @env{PSPP_CONFIG_PATH}, if defined, overrides this
 default path.  Finally, @samp{-B @var{path}} or
@@ -836,7 +836,7 @@ across operating systems:
 @file{.}
 
 @item
 @file{.}
 
 @item
-@file{~/.pspp/include}
+@file{$HOME/.pspp/include}
 
 @item
 @file{/usr/local/lib/pspp/include}
 
 @item
 @file{/usr/local/lib/pspp/include}
index 67f571dbfd8498cc610497a9ae864a49ed208330..0f82351bf573d68664fadd9a1b0eceafcbe279f8 100644 (file)
@@ -1,3 +1,22 @@
+Thu Feb  8 14:59:05 2007  Ben Pfaff  <blp@gnu.org>
+       Reduce platform dependence.
+       * file-name.c (fn_tilde_expand): Removed, and removed calls to it.
+       Everywhere we using this, we really should have just depended on
+       the shell to expand tildes.
+       (fn_search_path): Simplify, given that we don't do tilde expansion
+       any longer.
+       (fn_normalize): Removed.  Caller changed to use the canonicalize
+       module from gnulib.
+       (fn_get_cwd): Removed.  Only user was fn_normalize.
+       (fn_is_absolute): Really only test for absolute names.
+       (fn_is_special): Use pipe files if HAVE_POPEN, not if we're in
+       unix.
+       (fn_readlink): Removed, as it was only used fn_normalize.
+       (fn_exists): Assume the stat function is available; gnulib does.
+       (fn_open): Use pipe files if HAVE_POPEN, not if we're in unix.
 Sat Feb  3 21:52:17 2007  Ben Pfaff  <blp@gnu.org>
 
        * dictionary.c (dict_create_vector_assert): New function.
 Sat Feb  3 21:52:17 2007  Ben Pfaff  <blp@gnu.org>
 
        * dictionary.c (dict_create_vector_assert): New function.
index 68ad53a9810edfb696d59168ac87bc0af2e4c788..d9b6883126f81a9786647cc484c623e653b86c95 100644 (file)
@@ -20,6 +20,7 @@
 #define DATA_OUT_H 1
 
 #include <stdbool.h>
 #define DATA_OUT_H 1
 
 #include <stdbool.h>
+#include <libpspp/float-format.h>
 #include <libpspp/integer-format.h>
 
 struct fmt_spec;
 #include <libpspp/integer-format.h>
 
 struct fmt_spec;
index f937592636c1cf45453820f3b18ef60f4058aae8..acf27c3ce882e67a7e549354d026d547c602fa31 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "canonicalize.h"
 #include "intprops.h"
 #include "minmax.h"
 #include "settings.h"
 #include "intprops.h"
 #include "minmax.h"
 #include "settings.h"
-#include "xreadlink.h"
 
 #include <libpspp/alloc.h>
 #include <libpspp/message.h>
 
 #include <libpspp/alloc.h>
 #include <libpspp/message.h>
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
-/* PORTME: Everything in this file is system dependent. */
-
-#ifdef unix
-#include <pwd.h>
 #include <unistd.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <sys/stat.h>
-#include "stat-macros.h"
-#endif
-
-#ifdef __WIN32__
-#define NOGDI
-#define NOUSER
-#define NONLS
-#include <win32/windows.h>
-#endif
-
-#if __DJGPP__
-#include <sys/stat.h>
-#endif
 \f
 /* Initialization. */
 
 \f
 /* Initialization. */
 
@@ -118,60 +101,8 @@ fn_interp_vars (struct substring src, const char *(*getenv) (const char *),
   ds_destroy (&dst);
 }
 
   ds_destroy (&dst);
 }
 
-#ifdef unix
-/* Expands csh tilde notation from the path INPUT into a malloc()'d
-   returned string. */
-char *
-fn_tilde_expand (const char *input)
-{
-  struct string output = DS_EMPTY_INITIALIZER;
-  if (input[0] == '~')
-    {
-      const char *home = NULL;
-      const char *remainder = NULL;
-      if (input[1] == '/' || input[1] == '\0')
-        {
-          home = fn_getenv ("HOME");
-          remainder = input + 1; 
-        }
-      else
-        {
-          struct string user_name = DS_EMPTY_INITIALIZER;
-          struct passwd *pwd;
-
-          ds_assign_substring (&user_name,
-                               ss_buffer (input + 1,
-                                          strcspn (input + 1, "/")));
-          pwd = getpwnam (ds_cstr (&user_name));
-          if (pwd != NULL && pwd->pw_dir[0] != '\0')
-            {
-              home = xstrdup (pwd->pw_dir);
-              remainder = input + 1 + ds_length (&user_name);
-            }
-          ds_destroy (&user_name);
-        }
-
-      if (home != NULL) 
-        {
-          ds_put_cstr (&output, home);
-          if (*remainder != '\0')
-            ds_put_cstr (&output, remainder);
-        }
-    }
-  if (ds_is_empty (&output))
-    ds_put_cstr (&output, input);
-  return ds_cstr (&output);
-}
-#else /* !unix */
-char *
-fn_tilde_expand (const char *input)
-{
-  return xstrdup (input);
-}
-#endif /* !unix */
-
 /* Searches for a configuration file with name NAME in the path
 /* Searches for a configuration file with name NAME in the path
-   given by PATH, which is tilde- and environment-interpolated.
+   given by PATH, which is environment-interpolated.
    Directories in PATH are delimited by ':'.  Returns the
    malloc'd full name of the first file found, or NULL if none is
    found. */
    Directories in PATH are delimited by ':'.  Returns the
    malloc'd full name of the first file found, or NULL if none is
    found. */
@@ -179,12 +110,12 @@ char *
 fn_search_path (const char *base_name, const char *path_)
 {
   struct string path;
 fn_search_path (const char *base_name, const char *path_)
 {
   struct string path;
-  struct substring dir_;
+  struct substring dir;
   struct string file = DS_EMPTY_INITIALIZER;
   size_t save_idx = 0;
 
   if (fn_is_absolute (base_name))
   struct string file = DS_EMPTY_INITIALIZER;
   size_t save_idx = 0;
 
   if (fn_is_absolute (base_name))
-    return fn_tilde_expand (base_name);
+    return xstrdup (base_name);
 
   /* Interpolate environment variables. */
   ds_init_cstr (&path, path_);
 
   /* Interpolate environment variables. */
   ds_init_cstr (&path, path_);
@@ -192,26 +123,14 @@ fn_search_path (const char *base_name, const char *path_)
 
   verbose_msg (2, _("searching for \"%s\" in path \"%s\""),
                base_name, ds_cstr (&path));
 
   verbose_msg (2, _("searching for \"%s\" in path \"%s\""),
                base_name, ds_cstr (&path));
-  while (ds_separate (&path, ss_cstr (":"), &save_idx, &dir_))
+  while (ds_separate (&path, ss_cstr (":"), &save_idx, &dir))
     {
     {
-      struct string dir;
-
-      /* Do tilde expansion. */
-      ds_init_substring (&dir, dir_);
-      if (ds_first (&dir) == '~') 
-        {
-          char *tmp_str = fn_tilde_expand (ds_cstr (&dir));
-          ds_assign_cstr (&dir, tmp_str);
-          free (tmp_str); 
-        }
-
       /* Construct file name. */
       ds_clear (&file);
       /* Construct file name. */
       ds_clear (&file);
-      ds_put_cstr (&file, ds_cstr (&dir));
+      ds_put_substring (&file, dir);
       if (!ds_is_empty (&file) && ds_last (&file) != '/')
        ds_put_char (&file, '/');
       ds_put_cstr (&file, base_name);
       if (!ds_is_empty (&file) && ds_last (&file) != '/')
        ds_put_char (&file, '/');
       ds_put_cstr (&file, base_name);
-      ds_destroy (&dir);
 
       /* Check whether file exists. */
       if (fn_exists (ds_cstr (&file)))
 
       /* Check whether file exists. */
       if (fn_exists (ds_cstr (&file)))
@@ -229,183 +148,6 @@ fn_search_path (const char *base_name, const char *path_)
   return NULL;
 }
 
   return NULL;
 }
 
-/* fn_normalize(): This very OS-dependent routine canonicalizes
-   file name FN1.  The file name should not need to be the name of an
-   existing file.  Returns a malloc()'d copy of the canonical name.
-   This function must always succeed; if it needs to bail out then it
-   should return xstrdup(FN1).  */
-#ifdef unix
-char *
-fn_normalize (const char *file_name)
-{
-  const char *src;
-  char *fn1, *fn2, *dest;
-  int maxlen;
-
-  if (fn_is_special (file_name))
-    return xstrdup (file_name);
-  
-  fn1 = fn_tilde_expand (file_name);
-
-  /* Follow symbolic links. */
-  for (;;)
-    {
-      fn2 = fn1;
-      fn1 = fn_readlink (fn1);
-      if (!fn1)
-       {
-         fn1 = fn2;
-         break;
-       }
-      free (fn2);
-    }
-
-  maxlen = strlen (fn1) * 2;
-  if (maxlen < 31)
-    maxlen = 31;
-  dest = fn2 = xmalloc (maxlen + 1);
-  src = fn1;
-
-  if (*src == '/')
-    *dest++ = *src++;
-  else
-    {
-      errno = 0;
-      while (getcwd (dest, maxlen - (dest - fn2)) == NULL && errno == ERANGE)
-       {
-         maxlen *= 2;
-         dest = fn2 = xrealloc (fn2, maxlen + 1);
-         errno = 0;
-       }
-      if (errno)
-       {
-         free (fn1);
-         free (fn2);
-         return NULL;
-       }
-      dest = strchr (fn2, '\0');
-      if (dest - fn2 >= maxlen)
-       {
-         int ofs = dest - fn2;
-         maxlen *= 2;
-         fn2 = xrealloc (fn2, maxlen + 1);
-         dest = fn2 + ofs;
-       }
-      if (dest[-1] != '/')
-       *dest++ = '/';
-    }
-
-  for (;;)
-    {
-      int c, f;
-
-      c = *src++;
-
-      f = 0;
-      if (c == '/' || c == 0)
-       {
-         /* remove `./', `../' from directory */
-         if (dest[-1] == '.' && dest[-2] == '/')
-           dest--;
-         else if (dest[-1] == '.' && dest[-2] == '.' && dest[-3] == '/')
-           {
-             dest -= 3;
-             if (dest == fn2)
-               dest++;
-             while (dest[-1] != '/')
-               dest--;
-           }
-         else if (dest[-1] != '/')     /* remove extra slashes */
-           f = 1;
-
-         if (c == 0)
-           {
-             if (dest[-1] == '/' && dest > fn2 + 1)
-               dest--;
-             *dest = 0;
-             free (fn1);
-
-             return xrealloc (fn2, strlen (fn2) + 1);
-           }
-       }
-      else
-       f = 1;
-
-      if (f)
-       {
-         if (dest - fn2 >= maxlen)
-           {
-             int ofs = dest - fn2;
-             maxlen *= 2;
-             fn2 = xrealloc (fn2, maxlen + 1);
-             dest = fn2 + ofs;
-           }
-         *dest++ = c;
-       }
-    }
-}
-#elif defined (__WIN32__)
-char *
-fn_normalize (const char *fn1)
-{
-  DWORD len;
-  DWORD success;
-  char *fn2;
-
-  /* Don't change special file names. */
-  if (fn_is_special (file_name))
-    return xstrdup (file_name);
-
-  /* First find the required buffer length. */
-  len = GetFullPathName (fn1, 0, NULL, NULL);
-  if (!len)
-    {
-      fn2 = xstrdup (fn1);
-      return fn2;
-    }
-
-  /* Then make a buffer that big. */
-  fn2 = xmalloc (len);
-  success = GetFullPathName (fn1, len, fn2, NULL);
-  if (success >= len || success == 0)
-    {
-      free (fn2);
-      fn2 = xstrdup (fn1);
-      return fn2;
-    }
-  return fn2;
-}
-#elif __BORLANDC__
-char *
-fn_normalize (const char *fn1)
-{
-  char *fn2 = _fullpath (NULL, fn1, 0);
-  if (fn2)
-    {
-      char *cp;
-      for (cp = fn2; *cp; cp++)
-       *cp = toupper ((unsigned char) (*cp));
-      return fn2;
-    }
-  return xstrdup (fn1);
-}
-#elif __DJGPP__
-char *
-fn_normalize (const char *fn1)
-{
-  char *fn2 = xmalloc (1024);
-  _fixpath (fn1, fn2);
-  fn2 = xrealloc (fn2, strlen (fn2) + 1);
-  return fn2;
-}
-#else /* not Lose32, Unix, or DJGPP */
-char *
-fn_normalize (const char *fn)
-{
-  return xstrdup (fn);
-}
-#endif /* not Lose32, Unix, or DJGPP */
-
 /* Returns the directory part of FILE_NAME, as a malloc()'d
    string. */
 char *
 /* Returns the directory part of FILE_NAME, as a malloc()'d
    string. */
 char *
@@ -444,66 +186,15 @@ fn_extension (const char *file_name)
   return xstrdup (extension);
 }
 \f
   return xstrdup (extension);
 }
 \f
-#if unix
-/* Returns the current working directory, as a malloc()'d string.
-   From libc.info. */
-char *
-fn_get_cwd (void)
-{
-  int size = 100;
-  char *buffer = xmalloc (size);
-     
-  for (;;)
-    {
-      char *value = getcwd (buffer, size);
-      if (value != 0)
-       return buffer;
-
-      size *= 2;
-      free (buffer);
-      buffer = xmalloc (size);
-    }
-}
-#else
-char *
-fn_get_cwd (void)
-{
-  int size = 2;
-  char *buffer = xmalloc (size);
-  if ( buffer) 
-    {
-      buffer[0]='.';
-      buffer[1]='\0';
-    }
-
-  return buffer;
-     
-}
-#endif
-\f
 /* Find out information about files. */
 
 /* Returns true iff NAME specifies an absolute file name. */
 bool
 fn_is_absolute (const char *name)
 {
 /* Find out information about files. */
 
 /* Returns true iff NAME specifies an absolute file name. */
 bool
 fn_is_absolute (const char *name)
 {
-#ifdef unix
-  if (name[0] == '/'
-      || !strncmp (name, "./", 2)
-      || !strncmp (name, "../", 3)
-      || name[0] == '~')
-    return true;
-#elif defined (__MSDOS__)
-  if (name[0] == '\\'
-      || !strncmp (name, ".\\", 2)
-      || !strncmp (name, "..\\", 3)
-      || (name[0] && name[1] == ':'))
-    return true;
-#endif
-  
-  return false;
+  return name[0] == '/';
 }
 }
-  
+
 /* Returns true if FILE_NAME is a virtual file that doesn't
    really exist on disk, false if it's a real file name. */
 bool
 /* Returns true if FILE_NAME is a virtual file that doesn't
    really exist on disk, false if it's a real file name. */
 bool
@@ -511,7 +202,7 @@ fn_is_special (const char *file_name)
 {
   if (!strcmp (file_name, "-") || !strcmp (file_name, "stdin")
       || !strcmp (file_name, "stdout") || !strcmp (file_name, "stderr")
 {
   if (!strcmp (file_name, "-") || !strcmp (file_name, "stdin")
       || !strcmp (file_name, "stdout") || !strcmp (file_name, "stderr")
-#ifdef unix
+#ifdef HAVE_POPEN
       || file_name[0] == '|'
       || (*file_name && file_name[strlen (file_name) - 1] == '|')
 #endif
       || file_name[0] == '|'
       || (*file_name && file_name[strlen (file_name) - 1] == '|')
 #endif
@@ -525,25 +216,8 @@ fn_is_special (const char *file_name)
 bool
 fn_exists (const char *name)
 {
 bool
 fn_exists (const char *name)
 {
-#ifdef unix
   struct stat temp;
   struct stat temp;
-
   return stat (name, &temp) == 0;
   return stat (name, &temp) == 0;
-#else
-  FILE *f = fopen (name, "r");
-  if (!f)
-    return false;
-  fclose (f);
-  return true;
-#endif
-}
-
-/* Returns the symbolic link value for FILE_NAME as a dynamically
-   allocated buffer, or a null pointer on failure. */
-char *
-fn_readlink (const char *file_name)
-{
-  return xreadlink (file_name, 32);
 }
 \f
 /* Environment variables. */
 }
 \f
 /* Environment variables. */
@@ -570,6 +244,7 @@ fn_getenv_default (const char *key, const char *def)
 \f
 /* Basic file handling. */
 
 \f
 /* Basic file handling. */
 
+#if HAVE_POPEN
 /* Used for giving an error message on a set_safer security
    violation. */
 static FILE *
 /* Used for giving an error message on a set_safer security
    violation. */
 static FILE *
@@ -579,6 +254,7 @@ safety_violation (const char *fn)
   errno = EPERM;
   return NULL;
 }
   errno = EPERM;
   return NULL;
 }
+#endif
 
 /* As a general comment on the following routines, a `sensible value'
    for errno includes 0 if there is no associated system error.  The
 
 /* As a general comment on the following routines, a `sensible value'
    for errno includes 0 if there is no associated system error.  The
@@ -601,7 +277,7 @@ fn_open (const char *fn, const char *mode)
   else if (mode[0] == 'w' && !strcmp (fn, "stderr"))
     return stderr;
   
   else if (mode[0] == 'w' && !strcmp (fn, "stderr"))
     return stderr;
   
-#ifdef unix
+#if HAVE_POPEN
   if (fn[0] == '|')
     {
       if (get_safer_mode ())
   if (fn[0] == '|')
     {
       if (get_safer_mode ())
@@ -647,7 +323,7 @@ fn_close (const char *fn, FILE *f)
 {
   if (!strcmp (fn, "-"))
     return 0;
 {
   if (!strcmp (fn, "-"))
     return 0;
-#ifdef unix
+#if HAVE_POPEN
   else if (fn[0] == '|' || (*fn && fn[strlen (fn) - 1] == '|'))
     {
       pclose (f);
   else if (fn[0] == '|' || (*fn && fn[strlen (fn) - 1] == '|'))
     {
       pclose (f);
@@ -724,7 +400,10 @@ struct file_identity *
 fn_get_identity (const char *file_name) 
 {
   struct file_identity *identity = xmalloc (sizeof *identity);
 fn_get_identity (const char *file_name) 
 {
   struct file_identity *identity = xmalloc (sizeof *identity);
-  identity->normalized_file_name = fn_normalize (file_name);
+  char *cname = canonicalize_filename_mode (file_name, CAN_MISSING);
+  if (cname == NULL)
+    cname = xstrdup (file_name);
+  identity->normalized_file_name = cname;
   return identity;
 }
 
   return identity;
 }
 
index a5f62776647e1c2e8ba114d181b0b71cb1d1aeec..edd70f2fac90649663f8bbcdf562e562fbac7e03 100644 (file)
 
 #include <stdio.h>
 #include <stdbool.h>
 
 #include <stdio.h>
 #include <stdbool.h>
+#include <libpspp/str.h>
 
 /* Search path for configuration files. */
 extern const char *config_path;
 
 void fn_init (void);
 
 
 /* Search path for configuration files. */
 extern const char *config_path;
 
 void fn_init (void);
 
-struct string;
-struct substring;
 void fn_interp_vars (struct substring src, 
                      const char *(*getenv) (const char *),
                      struct string *dst);
 void fn_interp_vars (struct substring src, 
                      const char *(*getenv) (const char *),
                      struct string *dst);
-char *fn_tilde_expand (const char *fn);
 char *fn_search_path (const char *base_name, const char *path);
 char *fn_search_path (const char *base_name, const char *path);
-char *fn_normalize (const char *fn);
 char *fn_dir_name (const char *fn);
 char *fn_extension (const char *fn);
 
 char *fn_dir_name (const char *fn);
 char *fn_extension (const char *fn);
 
-char *fn_get_cwd (void);
-
 bool fn_is_absolute (const char *fn);
 bool fn_is_special (const char *fn);
 bool fn_exists (const char *fn);
 bool fn_is_absolute (const char *fn);
 bool fn_is_special (const char *fn);
 bool fn_exists (const char *fn);
-char *fn_readlink (const char *fn);
 
 const char *fn_getenv (const char *variable);
 const char *fn_getenv_default (const char *variable, const char *def);
 
 const char *fn_getenv (const char *variable);
 const char *fn_getenv_default (const char *variable, const char *def);
index f6ebb73a2bad6df1bfc077ce465992ea674383ec..d9f16ef41e9d296768f0b319b56820df6861a12f 100644 (file)
@@ -35,7 +35,6 @@
 #include "file-handle-def.h"
 #include "format.h"
 #include "missing-values.h"
 #include "file-handle-def.h"
 #include "format.h"
 #include "missing-values.h"
-#include "stat-macros.h"
 #include "value-labels.h"
 #include "variable.h"
 
 #include "value-labels.h"
 #include "variable.h"
 
index f82cafad32d5e92d879985790005a15da38cae9a..34f59d332d1544abf2bdd67497d228ab6f88ee45 100644 (file)
@@ -46,7 +46,6 @@
 #include "value-labels.h"
 #include "variable.h"
 
 #include "value-labels.h"
 #include "variable.h"
 
-#include "stat-macros.h"
 #include "minmax.h"
 
 #include "gettext.h"
 #include "minmax.h"
 
 #include "gettext.h"
index afe8195abe59e39c6a352e1e54ff5ee8aba870a1..33dbf2c6c7bb71816777e35203df4dc5b351b3a6 100644 (file)
@@ -1,3 +1,13 @@
+Thu Feb  8 15:04:42 2007  Ben Pfaff  <blp@gnu.org>
+
+       Reduce platform dependence.
+
+       * command.c (shell): Always define this function, instead of only
+       in unix, but make it a stub when fork or execl is not available.
+       (run_command): Move parsing code into cmd_host.
+       (cmd_host): Drop unix dependence now that the shell function is
+       always defined. 
+
 Sun Jan 21 15:31:52 WST 2007 John Darrington <john@darrington.wattle.id.au>
 
        * command.c command.h: Renamed cmd_parse to cmd_parse_in_state.
 Sun Jan 21 15:31:52 WST 2007 John Darrington <john@darrington.wattle.id.au>
 
        * command.c command.h: Renamed cmd_parse to cmd_parse_in_state.
index 2284deedc8324a51c05bad47f9ea6a4b90e506de..70d5b02e747416e9f08554d4c57868196aef3812 100644 (file)
@@ -718,9 +718,9 @@ cmd_erase (struct lexer *lexer, struct dataset *ds UNUSED)
   return CMD_SUCCESS;
 }
 
   return CMD_SUCCESS;
 }
 
-#ifdef unix
-/* Spawn a shell process. */
-static int
+#if HAVE_FORK && HAVE_EXECL
+/* Spawn an interactive shell process. */
+static bool
 shell (void)
 {
   int pid;
 shell (void)
 {
   int pid;
@@ -761,69 +761,48 @@ shell (void)
 
     case -1:
       msg (SE, _("Couldn't fork: %s."), strerror (errno));
 
     case -1:
       msg (SE, _("Couldn't fork: %s."), strerror (errno));
-      return 0;
+      return false;
 
     default:
       assert (pid > 0);
       while (wait (NULL) != pid)
        ;
 
     default:
       assert (pid > 0);
       while (wait (NULL) != pid)
        ;
-      return 1;
+      return true;
     }
 }
     }
 }
-#endif /* unix */
-
-/* Parses the HOST command argument and executes the specified
-   command.  Returns a suitable command return code. */
-static int
-run_command (struct lexer *lexer)
+#else /* !(HAVE_FORK && HAVE_EXECL) */
+/* Don't know how to spawn an interactive shell. */
+static bool
+shell (void)
 {
 {
-  const char *cmd;
-  int string;
-
-  /* Handle either a string argument or a full-line argument. */
-  {
-    int c = lex_look_ahead (lexer);
+  msg (SE, _("Interactive shell not supported on this platform."));
+  return false;
+}
+#endif
 
 
-    if (c == '\'' || c == '"')
-      {
-       lex_get (lexer);
-       if (!lex_force_string (lexer))
-         return CMD_FAILURE;
-       cmd = ds_cstr (lex_tokstr (lexer));
-       string = 1;
-      }
-    else
-      {
-       cmd = lex_rest_of_line (lexer, NULL);
-        lex_discard_line (lexer);
-       string = 0;
-      }
-  }
+/* Executes the specified COMMAND in a subshell.  Returns true if
+   successful, false otherwise. */
+static bool
+run_command (const char *command)
+{
+  if (system (NULL) == 0) 
+    {
+      msg (SE, _("Command shell not supported on this platform."));
+      return false;
+    }
 
   /* Execute the command. */
 
   /* Execute the command. */
-  if (system (cmd) == -1)
+  if (system (command) == -1)
     msg (SE, _("Error executing command: %s."), strerror (errno));
 
     msg (SE, _("Error executing command: %s."), strerror (errno));
 
-  /* Finish parsing. */
-  if (string)
-    {
-      lex_get (lexer);
-
-      if (lex_token (lexer) != '.')
-       {
-         lex_error (lexer, _("expecting end of command"));
-         return CMD_FAILURE;
-       }
-    }
-
-  return CMD_SUCCESS;
+  return true;
 }
 
 /* Parses, performs the HOST command. */
 int
 cmd_host (struct lexer *lexer, struct dataset *ds UNUSED)
 {
 }
 
 /* Parses, performs the HOST command. */
 int
 cmd_host (struct lexer *lexer, struct dataset *ds UNUSED)
 {
-  int code;
+  int look_ahead;
 
   if (get_safer_mode ()) 
     { 
 
   if (get_safer_mode ()) 
     { 
@@ -831,29 +810,30 @@ cmd_host (struct lexer *lexer, struct dataset *ds UNUSED)
       return CMD_FAILURE; 
     } 
 
       return CMD_FAILURE; 
     } 
 
-#ifdef unix
-  /* Figure out whether to invoke an interactive shell or to execute a
-     single shell command. */
-  if (lex_look_ahead (lexer) == '.')
+  look_ahead = lex_look_ahead (lexer);
+  if (look_ahead == '.') 
     {
       lex_get (lexer);
     {
       lex_get (lexer);
-      code = shell () ? CMD_FAILURE : CMD_SUCCESS;
+      return shell () ? CMD_SUCCESS : CMD_FAILURE;
     }
     }
-  else
-    code = run_command (lexer);
-#else /* !unix */
-  /* Make sure that the system has a command interpreter, then run a
-     command. */
-  if (system (NULL) != 0)
-    code = run_command (lexer);
-  else
+  else if (look_ahead == '\'' || look_ahead == '"')
     {
     {
-      msg (SE, _("No operating system support for this command."));
-      code = CMD_FAILURE;
-    }
-#endif /* !unix */
+      bool ok;
+      
+      lex_get (lexer);
+      if (!lex_force_string (lexer))
+        NOT_REACHED ();
+      ok = run_command (ds_cstr (lex_tokstr (lexer)));
 
 
-  return code;
+      lex_get (lexer);
+      return ok ? lex_end_of_command (lexer) : CMD_FAILURE;
+    }
+  else 
+    {
+      bool ok = run_command (lex_rest_of_line (lexer, NULL));
+      lex_discard_line (lexer);
+      return ok ? CMD_SUCCESS : CMD_FAILURE;
+    }
 }
 
 /* Parses, performs the NEW FILE command. */
 }
 
 /* Parses, performs the NEW FILE command. */
index 15a89c5c64106b2e1ed4d96aa178985049e89eac..b7b0c064a0d67e69a8cee02a6ec734ef45b65720 100644 (file)
@@ -28,7 +28,6 @@
 #include <libpspp/message.h>
 #include <language/lexer/lexer.h>
 #include <libpspp/misc.h>
 #include <libpspp/message.h>
 #include <language/lexer/lexer.h>
 #include <libpspp/misc.h>
-#include "stat-macros.h"
 #include <libpspp/str.h>
 
 #include "gettext.h"
 #include <libpspp/str.h>
 
 #include "gettext.h"
index 336fbd505318a933bf499e129d1463bf914e79d3..60bfc43e38c9e7195f4cbd9aa17a525ddd011897 100644 (file)
@@ -1,3 +1,8 @@
+Sun Feb 11 17:59:30 2007  Ben Pfaff  <blp@gnu.org>
+
+       * html.c (html_initialise_chart): Mark `this' parameter UNUSED to
+       account for NO_CHARTS case.
+
 Sat Feb  3 21:56:46 2007  Ben Pfaff  <blp@gnu.org>
 
        * table.c (tab_hline): Allow t->nr as y argument, so that we can
 Sat Feb  3 21:56:46 2007  Ben Pfaff  <blp@gnu.org>
 
        * table.c (tab_hline): Allow t->nr as y argument, so that we can
index caaaacb7318c4d42b85eed3109442184d285b72f..d71ba0c20d20efbee687c69af769909d405a29a1 100644 (file)
@@ -360,7 +360,7 @@ output_tab_table (struct outp_driver *this, struct tab_table *t)
 }
 
 static void
 }
 
 static void
-html_initialise_chart (struct outp_driver *this, struct chart *ch)
+html_initialise_chart (struct outp_driver *this UNUSED, struct chart *ch)
 {
 #ifdef NO_CHARTS
   ch->lp = NULL;
 {
 #ifdef NO_CHARTS
   ch->lp = NULL;
index 5fd23da69a45926c200b74818271f884b3808587..40d3a6b80938baba9dfa19460bf5c6138dd126d4 100644 (file)
@@ -1,5 +1,7 @@
 #include <config.h>
 
 #include <config.h>
 
+#include <string.h>
+
 #include <glade/glade-build.h>
 #include "psppire-dialog.h"
 #include "psppire-buttonbox.h"
 #include <glade/glade-build.h>
 #include "psppire-dialog.h"
 #include "psppire-buttonbox.h"
index 5dda93b72313fc8538876dd10e2ebaab7d3ff675..29b9bba1de9e9e6d70a61de545f3d3371d07b86e 100644 (file)
@@ -1,3 +1,11 @@
+Thu Feb  8 15:07:04 2007  Ben Pfaff  <blp@gnu.org>
+
+       * read-line.c (readln_initialize): Instead of only supporting
+       history in unix, always support history, and only support a
+       history file when $HOME is defined.
+       (readln_uninitialize): Ditto.
+       (welcome) Call readln_initialize instead of duplicating code.
+
 Sun Dec 10 11:13:53 2006  Ben Pfaff  <blp@gnu.org>
 
        * command-line.c (pre_syntax_message): Use term "syntax" instead
 Sun Dec 10 11:13:53 2006  Ben Pfaff  <blp@gnu.org>
 
        * command-line.c (pre_syntax_message): Use term "syntax" instead
index 41e270f28ec7b0cd6118ee697f712e076cfaafcc..f28fb6fe3912a989a1df8ef74d234ffc402474c4 100644 (file)
@@ -70,16 +70,18 @@ readln_initialize (void)
 
 #if HAVE_READLINE
   rl_basic_word_break_characters = "\n";
 
 #if HAVE_READLINE
   rl_basic_word_break_characters = "\n";
-#ifdef unix
+  using_history ();
+  stifle_history (500);
   if (history_file == NULL)
     {
   if (history_file == NULL)
     {
-      history_file = tilde_expand ("~/.pspp_history");
-      using_history ();
-      read_history (history_file);
-      stifle_history (500);
+      const char *home_dir = getenv ("HOME");
+      if (home_dir != NULL) 
+        {
+          history_file = xasprintf ("%s/.pspp_history", home_dir);
+          read_history (history_file); 
+        }
     }
 #endif
     }
 #endif
-#endif
 }
 
 /* Close getl. */
 }
 
 /* Close getl. */
@@ -88,7 +90,7 @@ readln_uninitialize (void)
 {
   initialised = false;
 
 {
   initialised = false;
 
-#if HAVE_READLINE && unix
+#if HAVE_READLINE
   if (history_file != NULL && false == get_testing_mode() )
     write_history (history_file);
   clear_history ();
   if (history_file != NULL && false == get_testing_mode() )
     write_history (history_file);
   clear_history ();
@@ -127,23 +129,9 @@ welcome (void)
         "conditions.\nThere is ABSOLUTELY NO WARRANTY for PSPP; type \"show "
         "warranty.\" for details.\n", stdout);
   puts (stat_version);
         "conditions.\nThere is ABSOLUTELY NO WARRANTY for PSPP; type \"show "
         "warranty.\" for details.\n", stdout);
   puts (stat_version);
-
-#if HAVE_READLINE && unix
-  if (history_file == NULL)
-    {
-      history_file = tilde_expand ("~/.pspp_history");
-      using_history ();
-      read_history (history_file);
-      stifle_history (500);
-    }
-#endif
+  readln_initialize ();
 }
 
 }
 
-
-
-
-
-
 /* Gets a line from the user and stores it into LINE.
    Prompts the user with PROMPT.
    Returns true if successful, false at end of file.
 /* Gets a line from the user and stores it into LINE.
    Prompts the user with PROMPT.
    Returns true if successful, false at end of file.