pdf-devel
[Top][All Lists]
Advanced

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

[pdf-devel] [PATCH] Fix compilation on Open/FreeBSD


From: Zac Brown
Subject: [pdf-devel] [PATCH] Fix compilation on Open/FreeBSD
Date: Tue, 02 Sep 2008 17:52:11 -0400
User-agent: Thunderbird 2.0.0.16 (X11/20080724)

I spent a little time over the three day weekend fixing compilation on Open/FreeBSD. NetBSD still isn't working, it seems to be an issue with linking to libiconv.

Not sure yet how to fix it but if there are any NetBSD experts lurking about, please shoot me an email.

Highlights for this patch include:

* Fix time function init to use struct tm rather than the linux-only "daylight/timezone" global variables. As a side note, using those was setting it incorrectly anyway with regard to daylight savings time and GMT offsets.

* Include sys/param.h which will allow us to discern between a BSD system and something like Linux as well as adding a PDF_HOST_BSD macro to indicate BSD systems.

* Change use of statvfs to statfs since Net/OpenBSD don't have a concept of statvfs. It appears FreeBSD has statvfs, but statfs is on all the platforms.

All the tests pass with this patch on Linux, FreeBSD and OpenBSD.

Next up is NetBSD and Solaris :)
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: address@hidden
# target_branch: http://bzr.savannah.gnu.org/r/pdf/libgnupdf/branches\
#   /trunk/
# testament_sha1: 3e2bd20123c2c00b7e76ab83eed076c6fd2ae181
# timestamp: 2008-09-02 16:25:48 -0400
# base_revision_id: address@hidden
# 
# Begin patch
=== modified file 'ChangeLog'
--- ChangeLog   2008-08-28 23:56:07 +0000
+++ ChangeLog   2008-09-02 20:25:41 +0000
@@ -1,3 +1,15 @@
+2008-09-02  Zac Brown  <address@hidden>
+       * src/base/pdf-fsys-disk.c: Change statvfs to statfs to facilitate
+       portability across unixes.
+
+       * src/base/pdf-time-context.c (pdf_time_context_init): Change
+       pdf_time_context_init to use struct tm for getting GMT offset and
+       DST settings.
+
+       * src/base/pdf-types.h: Add PDF host type for BSD operating
+       systems and include sys/param.h to get specific OS details to
+       determine whether to set PDF_HOST_BSD.
+
 2008-08-29  Jose E. Marchesi  <address@hidden>
 
        * doc/gnupdf-hg.texi (Syntax Check): New section.

=== modified file 'src/base/pdf-fsys-disk.c'
--- src/base/pdf-fsys-disk.c    2008-08-28 20:43:19 +0000
+++ src/base/pdf-fsys-disk.c    2008-09-02 20:25:41 +0000
@@ -38,7 +38,12 @@
 #include <pdf-fsys-disk.h>
 
 #ifndef PDF_HOST_WIN32
-#include <sys/statvfs.h>
+ #ifndef PDF_HOST_BSD
+  #include <sys/statfs.h>
+ #else
+  #include <sys/param.h>
+  #include <sys/mount.h>
+ #endif
 #else
 #include <windows.h>
 #endif /* !PDF_HOST_WIN32 */
@@ -72,7 +77,7 @@
   DWORD bytes_per_sector;
   DWORD dummy;
 #else
-  struct statvfs fs_stats;
+  struct statfs fs_stats;
 #endif /* !PDF_HOST_WIN32 */
   pdf_size_t result;
 
@@ -126,7 +131,7 @@
             * free_clusters); 
  
 #else /* Non-windows plattform */
-  if (statvfs ((const char *) host_path, &fs_stats) != 0)
+  if (statfs ((const char *) host_path, &fs_stats) != 0)
     {
       /* Cleanup */
       pdf_dealloc (host_path);

=== modified file 'src/base/pdf-time-context.c'
--- src/base/pdf-time-context.c 2008-07-28 20:28:04 +0000
+++ src/base/pdf-time-context.c 2008-09-02 20:25:41 +0000
@@ -48,21 +48,25 @@
 pdf_time_context_init(void)
 {
   extern pdf_time_context_t time_context;
-  
-  tzset();
-  
+  time_t tloc;
+  struct tm* time_struct;
+
+  time(&tloc);
+  time_struct = localtime(&tloc);
+
   /* Set GMT offset */
-  time_context.local_time_gmt_offset = timezone;
+  time_context.local_time_gmt_offset = time_struct->tm_gmtoff;
 
   /* Set flag to indicate if Daylight saving times are applied in the system
    * if needed */
-  time_context.local_time_daylight_save = (daylight == 0) ? PDF_FALSE : 
PDF_TRUE;
+  time_context.local_time_daylight_save = (time_struct->tm_isdst == 0) ? 
PDF_FALSE : PDF_TRUE;
   
   PDF_DEBUG_BASE("Initializing Time module...");
   PDF_DEBUG_BASE("GMT offset: %d secs", time_context.local_time_gmt_offset);
   PDF_DEBUG_BASE("Daylight saving? %s",time_context.local_time_daylight_save ? 
\
                  "yes":"no");
-    
+
+  free(time_struct);
   return PDF_OK;
 }
 

=== modified file 'src/base/pdf-types.h'
--- src/base/pdf-types.h        2008-07-26 16:16:22 +0000
+++ src/base/pdf-types.h        2008-09-02 20:25:41 +0000
@@ -33,6 +33,7 @@
 #include <sys/types.h> /* for off_t */
 #include <stdint.h> /* for uint32_t and others, from gnulib */
 
+#include <sys/param.h> /* for determining system types (mostly BSD) */
 
 #ifdef HAVE_INLINE
 #define INLINE inline
@@ -417,6 +418,9 @@
  #include <windows.h>
 #endif
 
+#if defined(BSD)
+ #define PDF_HOST_BSD
+#endif
 
 
 /* END PUBLIC */

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWR684eAAA/ZfgAgweXf////G
3hC////wYAevvWrapKACY2hrVGmaw0CUTSU9oyQo/RTyehMp7U1PRM1PUHo01GR6j1MRoOMmTJiM
TACZMEyAGjCMAQwHGTJkxGJgBMmCZADRhGAIYBIigmEVP1PVN+pkxpIGRo9U9pqJ6jAA0AHGTJkx
GJgBMmCZADRhGAIYBJEBBME00RkTEmaFPT1E9NT9EhiDZR6R6hgMqnZw3G+tM0FXHY6imtUw7xz4
BKyFg50WnudFE5Y7j0voPPpO2SdDKrdnbk9s5TQKKhVM7lbZEcmUg5qF8a4QXMNS5qe3K/Zh0dtu
jmRUGdNsG202RMt/URv+k90XPFau8H3wd4azrIo7qkaSiRZbQeBNMz5nO9mzGGFakr6cHpfGNGhs
DddkYwlS2bI6n0o+t19ske/6fv34Y4Vt/ptLUr4NYy/S3W2KWjF89ck0M9zM3KgEAqncxOkjjJzF
boxhkzdFvJ0zNaq1Zj21qYJ9AS41WP59QKDdCEaF5RpsyvzmBFkwEvJj06onHZg3v4LG06tr8g9H
AckZK4IJBQ6AuiOn8jIqanYcwqd7LdmRfWGQ06bL9rYx04MG5hnP+Emha9QuRW9l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