From: Ben Pfaff Date: Tue, 3 Aug 2010 05:11:13 +0000 (-0700) Subject: Replace S_I[RWX]{USR,GRP,OTH} macros by their values. X-Git-Tag: sav-api~120 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33c65b85425187f4cb06f7c8302e49d571c4c3a7;p=pspp Replace S_I[RWX]{USR,GRP,OTH} macros by their values. 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. --- diff --git a/src/data/por-file-writer.c b/src/data/por-file-writer.c index 22656f19b3..9889cfd953 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 729213bf68..fcb40d3796 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 85b11d4c1e..f736568798 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 fec6b4fc30..03458fcef0 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))