pspp-dev
[Top][All Lists]
Advanced

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

[csv 02/10] Replace S_I[RWX]{USR,GRP,OTH} macros by their values.


From: Ben Pfaff
Subject: [csv 02/10] Replace S_I[RWX]{USR,GRP,OTH} macros by their values.
Date: Sun, 8 Aug 2010 10:17:44 -0700

POSIX 2008 guarantees that these macros have their traditional Unix values,
so it should no be longer necessary to use the macros for portability's
sake.  Personally, I find the values easier to read, especially when
several of them are OR'd together.
---
 src/data/por-file-writer.c           |    6 +++---
 src/data/sys-file-writer.c           |    4 ++--
 src/language/data-io/data-writer.c   |    7 +++----
 src/language/utilities/permissions.c |    6 +++---
 4 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/data/por-file-writer.c b/src/data/por-file-writer.c
index 22656f1..9889cfd 100644
--- a/src/data/por-file-writer.c
+++ b/src/data/por-file-writer.c
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2009, 2010 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -150,9 +150,9 @@ pfm_open_writer (struct file_handle *fh, struct dictionary 
*dict,
     goto error;
 
   /* Create file. */
-  mode = S_IRUSR | S_IRGRP | S_IROTH;
+  mode = 0444;
   if (opts.create_writeable)
-    mode |= S_IWUSR | S_IWGRP | S_IWOTH;
+    mode |= 0222;
   w->rf = replace_file_start (fh_get_file_name (fh), "w", mode,
                               &w->file, NULL);
   if (w->rf == NULL)
diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c
index 729213b..fcb40d3 100644
--- a/src/data/sys-file-writer.c
+++ b/src/data/sys-file-writer.c
@@ -209,9 +209,9 @@ sfm_open_writer (struct file_handle *fh, struct dictionary 
*d,
     goto error;
 
   /* Create the file on disk. */
-  mode = S_IRUSR | S_IRGRP | S_IROTH;
+  mode = 0444;
   if (opts.create_writeable)
-    mode |= S_IWUSR | S_IWGRP | S_IWOTH;
+    mode |= 0222;
   w->rf = replace_file_start (fh_get_file_name (fh), "wb", mode,
                               &w->file, NULL);
   if (w->rf == NULL)
diff --git a/src/language/data-io/data-writer.c 
b/src/language/data-io/data-writer.c
index 85b11d4..f736568 100644
--- a/src/language/data-io/data-writer.c
+++ b/src/language/data-io/data-writer.c
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1997-2004, 2006, 2010 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -66,9 +66,8 @@ dfm_open_writer (struct file_handle *fh)
   w = xmalloc (sizeof *w);
   w->fh = fh_ref (fh);
   w->lock = lock;
-  w->rf = replace_file_start (fh_get_file_name (w->fh), "wb",
-                              (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
-                               | S_IROTH | S_IWOTH), &w->file, NULL);
+  w->rf = replace_file_start (fh_get_file_name (w->fh), "wb", 0666,
+                              &w->file, NULL);
   if (w->rf == NULL)
     {
       msg (ME, _("An error occurred while opening \"%s\" for writing "
diff --git a/src/language/utilities/permissions.c 
b/src/language/utilities/permissions.c
index fec6b4f..03458fc 100644
--- a/src/language/utilities/permissions.c
+++ b/src/language/utilities/permissions.c
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2010 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -108,9 +108,9 @@ change_permissions (const char *file_name, enum PER per)
     }
 
   if ( per == PER_RW )
-    mode = buf.st_mode | S_IWUSR ;
+    mode = buf.st_mode | 0200;
   else
-    mode = buf.st_mode & ~( S_IWOTH | S_IWUSR | S_IWGRP );
+    mode = buf.st_mode & ~0222;
 
   if ( -1 == chmod(file_name, mode))
 
-- 
1.7.1




reply via email to

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