Replace S_I[RWX]{USR,GRP,OTH} macros by their values.
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 3 Aug 2010 05:11:13 +0000 (22:11 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 9 Aug 2010 17:59:05 +0000 (10:59 -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
src/data/sys-file-writer.c
src/language/data-io/data-writer.c
src/language/utilities/permissions.c

index 22656f19b3cb9699eab3cc91ec559bcb5a835ff3..9889cfd95378ed7593c1cfbb2ba9ad187427d06f 100644 (file)
@@ -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)
index 729213bf6826337ba2a73c2c6ae6ce7ed678d7da..fcb40d379660934ac187e9e369a76ff1a0341f15 100644 (file)
@@ -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)
index 85b11d4c1e553054160f8b1a57a3d1cac2704a00..f736568798f1f4a5c12db763560bb849f42159d2 100644 (file)
@@ -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 "
index fec6b4fc3034ca882d66394b94c6d615ae4c369a..03458fcef01671f4ea4b263873ff89ebe86a7a2b 100644 (file)
@@ -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))