[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New issue with PSPP-Master when cross-compiling
From: |
Ben Pfaff |
Subject: |
Re: New issue with PSPP-Master when cross-compiling |
Date: |
Thu, 11 Feb 2010 21:54:12 -0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
John Darrington <address@hidden> writes:
> Sure it's not really necessary, but it's a feature which has
> already been implemented, and is at least to some extent useful.
>
> I'd prefer that we test for the existence of pwd.h with autoconf
> and then use #if HAVE_PWD_H
OK, done. I pushed this:
commit 16c70c9f2e041d4ff21f57c29be37e60be40c089
Author: Ben Pfaff <address@hidden>
Date: Thu Feb 11 21:53:38 2010 -0800
odt: Restore writing creator metadata.
Commit 4d7a2ed5 "odt: Remove dependency on <pwd.h> because mingw32 does
not have it" stopped writing creator metadata to ODT output files. This
commit adds it back, but only on systems that have <pwd.h>.
This commit also adds avoids a null pointer dereference if getpwuid()
returns NULL. That should happen only rarely, but it is best to handle it
properly.
At John Darrington's request.
diff --git a/configure.ac b/configure.ac
index e5eb13a..55bb24e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,7 +194,7 @@ fi
PSPP_READLINE
dnl Checks for header files.
-AC_CHECK_HEADERS([sys/wait.h fpu_control.h ieeefp.h fenv.h])
+AC_CHECK_HEADERS([sys/wait.h fpu_control.h ieeefp.h fenv.h pwd.h])
# For gnulib.
gl_INIT
diff --git a/src/output/odt.c b/src/output/odt.c
index 66e986b..99f5e60 100644
--- a/src/output/odt.c
+++ b/src/output/odt.c
@@ -21,6 +21,9 @@
#include <errno.h>
#include <libgen.h>
#include <libxml/xmlwriter.h>
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
@@ -268,6 +271,22 @@ write_meta_data (struct odt_driver *odt)
xmlTextWriterEndElement (w);
}
+#ifdef HAVE_PWD_H
+ {
+ struct passwd *pw = getpwuid (getuid ());
+ if (pw != NULL)
+ {
+ xmlTextWriterStartElement (w, _xml ("meta:initial-creator"));
+ xmlTextWriterWriteString (w, _xml (strtok (pw->pw_gecos, ",")));
+ xmlTextWriterEndElement (w);
+
+ xmlTextWriterStartElement (w, _xml ("dc:creator"));
+ xmlTextWriterWriteString (w, _xml (strtok (pw->pw_gecos, ",")));
+ xmlTextWriterEndElement (w);
+ }
+ }
+#endif
+
xmlTextWriterEndElement (w);
xmlTextWriterEndElement (w);
xmlTextWriterEndDocument (w);
--
Ben Pfaff
http://benpfaff.org