pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp src/ui/terminal/read-line.c src/ui/termina...


From: Ben Pfaff
Subject: [Pspp-cvs] pspp src/ui/terminal/read-line.c src/ui/termina...
Date: Mon, 12 Feb 2007 02:10:55 +0000

CVSROOT:        /cvsroot/pspp
Module name:    pspp
Changes by:     Ben Pfaff <blp> 07/02/12 02:10:55

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

Log message:
        Reduce platform dependence.
        This helps with build on mingw32 (and probably other platforms).
        Patch #5731.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/read-line.c?cvsroot=pspp&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/ChangeLog?cvsroot=pspp&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/glade-register.c?cvsroot=pspp&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/html.c?cvsroot=pspp&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/ChangeLog?cvsroot=pspp&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/utilities/permissions.c?cvsroot=pspp&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/command.c?cvsroot=pspp&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/ChangeLog?cvsroot=pspp&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/sys-file-writer.c?cvsroot=pspp&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/por-file-writer.c?cvsroot=pspp&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/file-name.h?cvsroot=pspp&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/file-name.c?cvsroot=pspp&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/data-out.h?cvsroot=pspp&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/ChangeLog?cvsroot=pspp&r1=1.103&r2=1.104
http://cvs.savannah.gnu.org/viewcvs/pspp/doc/configuring.texi?cvsroot=pspp&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/pspp/configure.ac?cvsroot=pspp&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/pspp/Smake?cvsroot=pspp&r1=1.45&r2=1.46
http://cvs.savannah.gnu.org/viewcvs/pspp/Makefile.am?cvsroot=pspp&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/pspp/ChangeLog?cvsroot=pspp&r1=1.66&r2=1.67

Patches:
Index: src/ui/terminal/read-line.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/terminal/read-line.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- src/ui/terminal/read-line.c 15 Dec 2006 00:16:03 -0000      1.12
+++ src/ui/terminal/read-line.c 12 Feb 2007 02:10:54 -0000      1.13
@@ -70,15 +70,17 @@
 
 #if HAVE_READLINE
   rl_basic_word_break_characters = "\n";
-#ifdef unix
+  using_history ();
+  stifle_history (500);
   if (history_file == NULL)
     {
-      history_file = tilde_expand ("~/.pspp_history");
-      using_history ();
+      const char *home_dir = getenv ("HOME");
+      if (home_dir != NULL) 
+        {
+          history_file = xasprintf ("%s/.pspp_history", home_dir);
       read_history (history_file);
-      stifle_history (500);
     }
-#endif
+    }
 #endif
 }
 
@@ -88,7 +90,7 @@
 {
   initialised = false;
 
-#if HAVE_READLINE && unix
+#if HAVE_READLINE
   if (history_file != NULL && false == get_testing_mode() )
     write_history (history_file);
   clear_history ();
@@ -127,23 +129,9 @@
         "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.

Index: src/ui/terminal/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/terminal/ChangeLog,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- src/ui/terminal/ChangeLog   10 Dec 2006 19:14:37 -0000      1.19
+++ src/ui/terminal/ChangeLog   12 Feb 2007 02:10:54 -0000      1.20
@@ -1,3 +1,11 @@
+Thu Feb  8 15:07:04 2007  Ben Pfaff  <address@hidden>
+
+       * 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  <address@hidden>
 
        * command-line.c (pre_syntax_message): Use term "syntax" instead

Index: src/ui/gui/glade-register.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/glade-register.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- src/ui/gui/glade-register.c 9 Feb 2007 15:06:28 -0000       1.3
+++ src/ui/gui/glade-register.c 12 Feb 2007 02:10:54 -0000      1.4
@@ -1,5 +1,7 @@
 #include <config.h>
 
+#include <string.h>
+
 #include <glade/glade-build.h>
 #include "psppire-dialog.h"
 #include "psppire-buttonbox.h"

Index: src/output/html.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/output/html.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- src/output/html.c   9 Feb 2007 05:19:09 -0000       1.17
+++ src/output/html.c   12 Feb 2007 02:10:54 -0000      1.18
@@ -360,7 +360,7 @@
 }
 
 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;

Index: src/output/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/output/ChangeLog,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- src/output/ChangeLog        9 Feb 2007 05:28:21 -0000       1.18
+++ src/output/ChangeLog        12 Feb 2007 02:10:54 -0000      1.19
@@ -1,3 +1,8 @@
+Sun Feb 11 17:59:30 2007  Ben Pfaff  <address@hidden>
+
+       * html.c (html_initialise_chart): Mark `this' parameter UNUSED to
+       account for NO_CHARTS case.
+
 Sat Feb  3 21:56:46 2007  Ben Pfaff  <address@hidden>
 
        * table.c (tab_hline): Allow t->nr as y argument, so that we can

Index: src/language/utilities/permissions.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/utilities/permissions.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- src/language/utilities/permissions.c        16 Dec 2006 04:26:42 -0000      
1.8
+++ src/language/utilities/permissions.c        12 Feb 2007 02:10:54 -0000      
1.9
@@ -28,7 +28,6 @@
 #include <libpspp/message.h>
 #include <language/lexer/lexer.h>
 #include <libpspp/misc.h>
-#include "stat-macros.h"
 #include <libpspp/str.h>
 
 #include "gettext.h"

Index: src/language/command.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/command.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- src/language/command.c      24 Jan 2007 08:30:22 -0000      1.22
+++ src/language/command.c      12 Feb 2007 02:10:54 -0000      1.23
@@ -718,9 +718,9 @@
   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;
@@ -761,69 +761,48 @@
 
     case -1:
       msg (SE, _("Couldn't fork: %s."), strerror (errno));
-      return 0;
+      return false;
 
     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
+/* Executes the specified COMMAND in a subshell.  Returns true if
+   successful, false otherwise. */
+static bool
+run_command (const char *command)
+{
+  if (system (NULL) == 0) 
       {
-       cmd = lex_rest_of_line (lexer, NULL);
-        lex_discard_line (lexer);
-       string = 0;
-      }
+      msg (SE, _("Command shell not supported on this platform."));
+      return false;
   }
 
   /* Execute the command. */
-  if (system (cmd) == -1)
+  if (system (command) == -1)
     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)
 {
-  int code;
+  int look_ahead;
 
   if (get_safer_mode ()) 
     { 
@@ -831,29 +810,30 @@
       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);
-      code = shell () ? CMD_FAILURE : CMD_SUCCESS;
+      return shell () ? CMD_SUCCESS : CMD_FAILURE;
+    }
+  else if (look_ahead == '\'' || look_ahead == '"')
+    {
+      bool ok;
+      
+      lex_get (lexer);
+      if (!lex_force_string (lexer))
+        NOT_REACHED ();
+      ok = run_command (ds_cstr (lex_tokstr (lexer)));
+
+      lex_get (lexer);
+      return ok ? lex_end_of_command (lexer) : 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
     {
-      msg (SE, _("No operating system support for this command."));
-      code = CMD_FAILURE;
+      bool ok = run_command (lex_rest_of_line (lexer, NULL));
+      lex_discard_line (lexer);
+      return ok ? CMD_SUCCESS : CMD_FAILURE;
     }
-#endif /* !unix */
-
-  return code;
 }
 
 /* Parses, performs the NEW FILE command. */

Index: src/language/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/ChangeLog,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- src/language/ChangeLog      24 Jan 2007 08:30:22 -0000      1.19
+++ src/language/ChangeLog      12 Feb 2007 02:10:54 -0000      1.20
@@ -1,3 +1,13 @@
+Thu Feb  8 15:04:42 2007  Ben Pfaff  <address@hidden>
+
+       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 <address@hidden>
 
        * command.c command.h: Renamed cmd_parse to cmd_parse_in_state.

Index: src/data/sys-file-writer.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/sys-file-writer.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- src/data/sys-file-writer.c  16 Dec 2006 22:11:08 -0000      1.21
+++ src/data/sys-file-writer.c  12 Feb 2007 02:10:55 -0000      1.22
@@ -46,7 +46,6 @@
 #include "value-labels.h"
 #include "variable.h"
 
-#include "stat-macros.h"
 #include "minmax.h"
 
 #include "gettext.h"

Index: src/data/por-file-writer.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/por-file-writer.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- src/data/por-file-writer.c  15 Dec 2006 00:16:02 -0000      1.8
+++ src/data/por-file-writer.c  12 Feb 2007 02:10:55 -0000      1.9
@@ -35,7 +35,6 @@
 #include "file-handle-def.h"
 #include "format.h"
 #include "missing-values.h"
-#include "stat-macros.h"
 #include "value-labels.h"
 #include "variable.h"
 

Index: src/data/file-name.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/file-name.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- src/data/file-name.h        15 Dec 2006 00:16:02 -0000      1.7
+++ src/data/file-name.h        12 Feb 2007 02:10:55 -0000      1.8
@@ -21,29 +21,23 @@
 
 #include <stdio.h>
 #include <stdbool.h>
+#include <libpspp/str.h>
 
 /* 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);
-char *fn_tilde_expand (const char *fn);
 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_get_cwd (void);
-
 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);

Index: src/data/file-name.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/file-name.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- src/data/file-name.c        8 Feb 2007 05:26:42 -0000       1.10
+++ src/data/file-name.c        12 Feb 2007 02:10:55 -0000      1.11
@@ -25,10 +25,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "canonicalize.h"
 #include "intprops.h"
 #include "minmax.h"
 #include "settings.h"
-#include "xreadlink.h"
 
 #include <libpspp/alloc.h>
 #include <libpspp/message.h>
@@ -40,25 +40,8 @@
 #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 "stat-macros.h"
-#endif
-
-#ifdef __WIN32__
-#define NOGDI
-#define NOUSER
-#define NONLS
-#include <win32/windows.h>
-#endif
-
-#if __DJGPP__
-#include <sys/stat.h>
-#endif
 
 /* Initialization. */
 
@@ -118,60 +101,8 @@
   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
-   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. */
@@ -179,12 +110,12 @@
 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))
-    return fn_tilde_expand (base_name);
+    return xstrdup (base_name);
 
   /* Interpolate environment variables. */
   ds_init_cstr (&path, path_);
@@ -192,26 +123,14 @@
 
   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);
-      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);
-      ds_destroy (&dir);
 
       /* Check whether file exists. */
       if (fn_exists (ds_cstr (&file)))
@@ -229,183 +148,6 @@
   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 *
@@ -444,64 +186,13 @@
   return xstrdup (extension);
 }
 
-#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
-
 /* 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
@@ -511,7 +202,7 @@
 {
   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
@@ -525,25 +216,8 @@
 bool
 fn_exists (const char *name)
 {
-#ifdef unix
   struct stat temp;
-
   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);
 }
 
 /* Environment variables. */
@@ -570,6 +244,7 @@
 
 /* Basic file handling. */
 
+#if HAVE_POPEN
 /* Used for giving an error message on a set_safer security
    violation. */
 static FILE *
@@ -579,6 +254,7 @@
   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
@@ -601,7 +277,7 @@
   else if (mode[0] == 'w' && !strcmp (fn, "stderr"))
     return stderr;
   
-#ifdef unix
+#if HAVE_POPEN
   if (fn[0] == '|')
     {
       if (get_safer_mode ())
@@ -647,7 +323,7 @@
 {
   if (!strcmp (fn, "-"))
     return 0;
-#ifdef unix
+#if HAVE_POPEN
   else if (fn[0] == '|' || (*fn && fn[strlen (fn) - 1] == '|'))
     {
       pclose (f);
@@ -724,7 +400,10 @@
 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;
 }
 

Index: src/data/data-out.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/data-out.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- src/data/data-out.h 15 Dec 2006 00:16:02 -0000      1.2
+++ src/data/data-out.h 12 Feb 2007 02:10:55 -0000      1.3
@@ -20,6 +20,7 @@
 #define DATA_OUT_H 1
 
 #include <stdbool.h>
+#include <libpspp/float-format.h>
 #include <libpspp/integer-format.h>
 
 struct fmt_spec;

Index: src/data/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/ChangeLog,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -b -r1.103 -r1.104
--- src/data/ChangeLog  9 Feb 2007 05:28:21 -0000       1.103
+++ src/data/ChangeLog  12 Feb 2007 02:10:55 -0000      1.104
@@ -1,3 +1,22 @@
+Thu Feb  8 14:59:05 2007  Ben Pfaff  <address@hidden>
+ 
+       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  <address@hidden>
 
        * dictionary.c (dict_create_vector_assert): New function.

Index: doc/configuring.texi
===================================================================
RCS file: /cvsroot/pspp/pspp/doc/configuring.texi,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- doc/configuring.texi        3 Jul 2006 17:39:07 -0000       1.9
+++ doc/configuring.texi        12 Feb 2007 02:10:55 -0000      1.10
@@ -22,7 +22,7 @@
 
 PSPP searches each directory in the configuration file path for most
 configuration files.  The default configuration file path searches first
address@hidden/.pspp}, then the package system configuration directory (usually
address@hidden/.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
@@ -836,7 +836,7 @@
 @file{.}
 
 @item
address@hidden/.pspp/include}
address@hidden/.pspp/include}
 
 @item
 @file{/usr/local/lib/pspp/include}

Index: configure.ac
===================================================================
RCS file: /cvsroot/pspp/pspp/configure.ac,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- configure.ac        9 Feb 2007 15:06:28 -0000       1.51
+++ configure.ac        12 Feb 2007 02:10:55 -0000      1.52
@@ -42,10 +42,10 @@
 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
-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
 
@@ -80,14 +80,10 @@
 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
 
-
-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>])
 

Index: Smake
===================================================================
RCS file: /cvsroot/pspp/pspp/Smake,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- Smake       15 Jan 2007 20:01:52 -0000      1.45
+++ Smake       12 Feb 2007 02:10:55 -0000      1.46
@@ -9,6 +9,7 @@
        alloca-opt \
        assert \
        byteswap \
+       canonicalize \
        c-ctype \
        c-strtod \
        exit \
@@ -30,10 +31,9 @@
        memmove \
        mempcpy \
        memset \
+       mkstemp \
        progname \
-       readlink \
        snprintf \
-       stat-macros \
        stdarg \
        stdbool \
        stdint \
@@ -43,17 +43,16 @@
        strerror \
        strftime \
        strsep \
-       strstr \
        strtod \
        strtok_r \
        strtol \
        strtoul \
+       sys_stat \
        unistd \
        unlocked-io \
        vsnprintf \
        xalloc \
        xalloc-die \
-       xreadlink \
        xsize \
        xstrndup \
        xvasprintf

Index: Makefile.am
===================================================================
RCS file: /cvsroot/pspp/pspp/Makefile.am,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- Makefile.am 4 Jan 2007 08:15:26 -0000       1.18
+++ Makefile.am 12 Feb 2007 02:10:55 -0000      1.19
@@ -6,7 +6,8 @@
 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=
 
@@ -15,14 +16,6 @@
 -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 address@hidden
        ./src/language/lexer/q2c $< $@

Index: ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/ChangeLog,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- ChangeLog   5 Nov 2006 05:20:52 -0000       1.66
+++ ChangeLog   12 Feb 2007 02:10:55 -0000      1.67
@@ -1,3 +1,22 @@
+Thu Feb  8 14:56:18 2007  Ben Pfaff  <address@hidden>
+
+       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  <address@hidden>
 
        * configure.ac: Check for the "round" function added in C99.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]