The branch, master has been updated
via fb312088e4031edc1ed1a241f8c5f4953970bec4 (commit)
via 50739385a384eeafe2ce3d213ce74512827eaed8 (commit)
via 411e1d5de68770a58aaaffc4b6c2a87bb4dffbc1 (commit)
via 71fb065e106162f9615eda31743696bcd78f18f1 (commit)
from 088b8e9a2930a2af0011d7e60d816f75158b3d14 (commit)
- Shortlog ------------------------------------------------------------
fb31208 dpkg-deb: Refactor fflush and its buggy fpos handling to safe_fflush()
5073938 libdpkg: Remove dead verrevcmp function
411e1d5 Use offsetof() instead of ad-hoc calculations
71fb065 Check for 'stddef.h' in AC_CHECK_HEADERS
Summary of changes:
ChangeLog | 24 ++++++++++++++++++++++++
configure.ac | 2 +-
dpkg-deb/extract.c | 32 ++++++++++++++++++++------------
lib/dpkg.h | 4 ++++
lib/parsedump.h | 8 +++-----
lib/tarfn.c | 3 +--
lib/vercmp.c | 36 ------------------------------------
7 files changed, 53 insertions(+), 56 deletions(-)
-----------------------------------------------------------------------
Details of changes:
commit fb312088e4031edc1ed1a241f8c5f4953970bec4
Author: Guillem Jover <[EMAIL PROTECTED]>
Date: Tue Jan 22 10:49:49 2008 +0200
dpkg-deb: Refactor fflush and its buggy fpos handling to safe_fflush()
diff --git a/ChangeLog b/ChangeLog
index 885181b..820ad55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2008-01-22 Guillem Jover <[EMAIL PROTECTED]>
+ * dpkg-deb/extract.c (extracthalf): Refactor fflush and its buggy
+ fpos handling to ...
+ (safe_fflush): ... here. New function.
+
+2008-01-22 Guillem Jover <[EMAIL PROTECTED]>
+
* lib/vercmp.c [0] (verrevcmp): Remove dead code.
2008-01-22 Guillem Jover <[EMAIL PROTECTED]>
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index 1c20a04..e98e03c 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -85,6 +85,24 @@ parseheaderlength(const char *inh, size_t len,
return (size_t)r;
}
+static int
+safe_fflush(FILE *f)
+{
+#if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ > 0)
+ /* XXX: Glibc 2.1 and some versions of Linux want to make fflush()
+ * move the current fpos. Remove this code some time. */
+ fpos_t fpos;
+
+ if (fgetpos(f, &fpos))
+ ohshit(_("failed getting the current file position"));
+ fflush(f);
+ if (fsetpos(f, &fpos))
+ ohshit(_("failed setting the current file position"));
+#else
+ fflush(f);
+#endif
+}
+
void extracthalf(const char *debar, const char *directory,
const char *taroption, int admininfo) {
char versionbuf[40];
@@ -101,9 +119,6 @@ void extracthalf(const char *debar, const char *directory,
char *cur;
struct ar_hdr arh;
int readfromfd, oldformat= 0, header_done, adminmember;
-#if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ > 0)
- fpos_t fpos;
-#endif
enum compress_type compress_type = compress_type_gzip;
ar= fopen(debar,"r"); if (!ar) ohshite(_("failed to read archive
`%.255s'"),debar);
@@ -228,15 +243,8 @@ void extracthalf(const char *debar, const char *directory,
}
-#if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ > 0)
- if (fgetpos(ar, &fpos))
- ohshit(_("failed getting the current file position"));
-#endif
- fflush(ar);
-#if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ > 0)
- if (fsetpos(ar, &fpos))
- ohshit(_("failed setting the current file position"));
-#endif
+ safe_fflush(ar);
+
if (oldformat) {
if (admininfo) {
m_pipe(p1);
commit 50739385a384eeafe2ce3d213ce74512827eaed8
Author: Guillem Jover <[EMAIL PROTECTED]>
Date: Tue Jan 22 10:35:12 2008 +0200
libdpkg: Remove dead verrevcmp function
diff --git a/ChangeLog b/ChangeLog
index 527cb67..885181b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2008-01-22 Guillem Jover <[EMAIL PROTECTED]>
+ * lib/vercmp.c [0] (verrevcmp): Remove dead code.
+
+2008-01-22 Guillem Jover <[EMAIL PROTECTED]>
+
* lib/dpkg.h [!offsetof] (offsetof): New compatibilty macro.
* lib/parsedump.h (PKGIFPOFF): Use offsetof instead of ad-hoc
calculation.
diff --git a/lib/vercmp.c b/lib/vercmp.c
index 5e9b006..2360724 100644
--- a/lib/vercmp.c
+++ b/lib/vercmp.c
@@ -65,42 +65,6 @@ static int verrevcmp(const char *val, const char *ref) {
return 0;
}
-
-#if 0
-static int verrevcmp(const char *ival, const char *iref) {
- static char empty[] = "";
- int vc, rc;
- long vl, rl;
- char *vp, *rp;
- char *val, *ref;
- memcpy(&val,&ival,sizeof(char*));
- memcpy(&ref,&iref,sizeof(char*));
-
- if (!val) val= empty;
- if (!ref) ref= empty;
- for (;;) {
- vp= val; while (*vp && !isdigit(*vp)) vp++;
- rp= ref; while (*rp && !isdigit(*rp)) rp++;
- for (;;) {
- vc= val == vp ? 0 : *val++;
- rc= ref == rp ? 0 : *ref++;
- if (!rc && !vc) break;
- if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
- if (rc && !isalpha(rc)) rc += 256;
- if (vc != rc) return vc - rc;
- }
- val= vp;
- ref= rp;
- vl=0; if (isdigit(*vp)) vl= strtol(val,&val,10);
- rl=0; if (isdigit(*rp)) rl= strtol(ref,&ref,10);
- if (vl != rl) return vl - rl;
- if (!*val && !*ref) return 0;
- if (!*val) return -1;
- if (!*ref) return +1;
- }
-}
-#endif
-
int versioncompare(const struct versionrevision *version,
const struct versionrevision *refversion) {
int r;
commit 411e1d5de68770a58aaaffc4b6c2a87bb4dffbc1
Author: Guillem Jover <[EMAIL PROTECTED]>
Date: Tue Jan 22 10:31:32 2008 +0200
Use offsetof() instead of ad-hoc calculations
diff --git a/ChangeLog b/ChangeLog
index d8d5f2e..527cb67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2008-01-22 Guillem Jover <[EMAIL PROTECTED]>
+ * lib/dpkg.h [!offsetof] (offsetof): New compatibilty macro.
+ * lib/parsedump.h (PKGIFPOFF): Use offsetof instead of ad-hoc
+ calculation.
+ (FILEFOFF): Likewise.
+ (struct fieldinfo): Change integer member type to size_t.
+ * lib/tarfn.c (TarChecksumOffset): Use offsetof instead of ad-hoc
+ calculation.
+
+2008-01-22 Guillem Jover <[EMAIL PROTECTED]>
+
* configure.ac (AC_CHECK_HEADERS): Check for 'stddef.h'.
2008-01-21 Colin Watson <[EMAIL PROTECTED]>
diff --git a/lib/dpkg.h b/lib/dpkg.h
index 8d36fc8..d0e15fe 100644
--- a/lib/dpkg.h
+++ b/lib/dpkg.h
@@ -414,6 +414,10 @@ void unsetenv(const char *x);
/*** other compatibility functions ***/
+#ifndef offsetof
+#define offsetof(st, m) ((size_t)&((st *)NULL)->m)
+#endif
+
#ifndef HAVE_STRTOUL
#define strtoul strtol
#endif
diff --git a/lib/parsedump.h b/lib/parsedump.h
index f767b29..2f7bb76 100644
--- a/lib/parsedump.h
+++ b/lib/parsedump.h
@@ -25,12 +25,10 @@
struct fieldinfo;
-#define PKGIFPOFF(f) ((char*)(&(((struct pkginfoperfile *)0x1000)->f)) - \
- (char*)(struct pkginfoperfile *)0x1000)
+#define PKGIFPOFF(f) (offsetof(struct pkginfoperfile, f))
#define PKGPFIELD(pifp,of,type) (*(type*)((char*)(pifp)+(of)))
-#define FILEFOFF(f) ((char*)(&(((struct filedetails *)0x1000)->f)) - \
- (char*)(struct filedetails *)0x1000)
+#define FILEFOFF(f) (offsetof(struct filedetails, f))
#define FILEFFIELD(filedetail,of,type) (*(type*)((char*)(filedetail)+(of)))
typedef void freadfunction(struct pkginfo *pigp, struct pkginfoperfile *pifp,
@@ -56,7 +54,7 @@ struct fieldinfo {
const char *name;
freadfunction *rcall;
fwritefunction *wcall;
- unsigned int integer;
+ size_t integer;
};
void parseerr(FILE *file, const char *filename, int lno, FILE *warnto, int
*warncount,
diff --git a/lib/tarfn.c b/lib/tarfn.c
index 0a96e75..397fedc 100644
--- a/lib/tarfn.c
+++ b/lib/tarfn.c
@@ -34,8 +34,7 @@ struct TarHeader {
};
typedef struct TarHeader TarHeader;
-static const unsigned int TarChecksumOffset
- = (unsigned int)&(((TarHeader *)NULL)->Checksum);
+static const size_t TarChecksumOffset = offsetof(TarHeader, Checksum);
/* Octal-ASCII-to-long */
static long
commit 71fb065e106162f9615eda31743696bcd78f18f1
Author: Guillem Jover <[EMAIL PROTECTED]>
Date: Tue Jan 22 10:23:41 2008 +0200
Check for 'stddef.h' in AC_CHECK_HEADERS
diff --git a/ChangeLog b/ChangeLog
index b9f03a1..d8d5f2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-01-22 Guillem Jover <[EMAIL PROTECTED]>
+
+ * configure.ac (AC_CHECK_HEADERS): Check for 'stddef.h'.
+
2008-01-21 Colin Watson <[EMAIL PROTECTED]>
* dselect/pkgkeys.cc (packagelist_korgbindings): Add 'C'.
diff --git a/configure.ac b/configure.ac
index 6454318..aaf51d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,7 +72,7 @@ fi
# Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS([error.h locale.h sys/cdefs.h kvm.h])
+AC_CHECK_HEADERS([stddef.h error.h locale.h sys/cdefs.h kvm.h])
DPKG_CHECK_DEFINE(TIOCNOTTY, [sys/ioctl.h])
# Checks for typedefs, structures, and compiler characteristics.
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]