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

Bug#165518: st_mtime conflicts with system defines



Package: apt
Version: 0.5.4
Severity: normal
Tags: patch

On some (awkwardly written) systems, 'st_mtime' is a #define macro pointing
to a more specific data type, which causes untold havoc when APT includes
these header files (which it must, to get access to the constructs it
needs). While not particularly graceful, the attached is the only way
I could come up with to resolve the problem (since st_mtime cannot be
undefined - the macro portion is, in fact, used by the same lines that get
mangled by the macro).
-- 
Joel Baker
fenton@debian.org
diff -ur apt-0.5.4.orig/ftparchive/cachedb.cc apt-0.5.4/ftparchive/cachedb.cc
--- apt-0.5.4.orig/ftparchive/cachedb.cc	2001-05-29 03:50:33.000000000 +0000
+++ apt-0.5.4/ftparchive/cachedb.cc	2002-09-23 03:26:33.000000000 +0000
@@ -91,16 +91,16 @@
    // Lookup the stat info and confirm the file is unchanged
    if (Get() == true)
    {
-      if (CurStat.st_mtime != htonl(St.st_mtime))
+      if (CurStat.my_st_mtime != htonl(St.st_mtime))
       {
-	 CurStat.st_mtime = htonl(St.st_mtime);
+	 CurStat.my_st_mtime = htonl(St.st_mtime);
 	 CurStat.Flags = 0;
 	 _error->Warning("File date has changed %s",FileName.c_str());
       }      
    }      
    else
    {
-      CurStat.st_mtime = htonl(St.st_mtime);
+      CurStat.my_st_mtime = htonl(St.st_mtime);
       CurStat.Flags = 0;
    }   
    CurStat.Flags = ntohl(CurStat.Flags);
@@ -225,7 +225,7 @@
 {
    // Optimize away some writes.
    if (CurStat.Flags == OldStat.Flags &&
-       CurStat.st_mtime == OldStat.st_mtime)
+       CurStat.my_st_mtime == OldStat.my_st_mtime)
       return true;
    
    // Write the stat information
diff -ur apt-0.5.4.orig/ftparchive/cachedb.h apt-0.5.4/ftparchive/cachedb.h
--- apt-0.5.4.orig/ftparchive/cachedb.h	2001-02-20 07:03:18.000000000 +0000
+++ apt-0.5.4/ftparchive/cachedb.h	2002-09-23 03:25:33.000000000 +0000
@@ -69,7 +69,7 @@
    enum FlagList {FlControl = (1<<0),FlMD5=(1<<1),FlContents=(1<<2)};
    struct StatStore
    {
-      uint32_t st_mtime;          
+      uint32_t my_st_mtime;          
       uint32_t Flags;
    } CurStat;
    struct StatStore OldStat;

Attachment: pgpoW1O2phAWF.pgp
Description: PGP signature


Reply to: