[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 1dddc6d46dbf6f3611cf0979e27547d06f9549c3
Author: Guillem Jover guil...@debian.org
Date:   Wed Sep 8 03:57:10 2010 +0200

dpkg: Rename unlinkorrmdir() to secure_remove()

Maps better to the system remove(2) function name.

diff --git a/src/archives.c b/src/archives.c
index d1daed4..fdfad13 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -311,24 +311,27 @@ void setupfnamevbs(const char *filename) {
 fnamevb.buf, fnametmpvb.buf, fnamenewvb.buf);
 }
 
-int unlinkorrmdir(const char *filename) {
+int
+secure_remove(const char *filename)
+{
   /* Returns 0 on success or -1 on failure, just like unlink  rmdir */
   int r, e;
   
   if (!rmdir(filename)) {
-debug(dbg_eachfiledetail,unlinkorrmdir `%s' rmdir OK,filename);
+debug(dbg_eachfiledetail, secure_remove '%s' rmdir OK, filename);
 return 0;
   }
   
   if (errno != ENOTDIR) {
 e= errno;
-debug(dbg_eachfiledetail,unlinkorrmdir `%s' rmdir 
%s,filename,strerror(e));
+debug(dbg_eachfiledetail, secure_remove '%s' rmdir %s, filename,
+  strerror(e));
 errno= e; return -1;
   }
   
   r = secure_unlink(filename);
   e = errno;
-  debug(dbg_eachfiledetail,unlinkorrmdir `%s' unlink %s,
+  debug(dbg_eachfiledetail, secure_remove '%s' unlink %s,
 filename, r ? strerror(e) : OK);
   errno= e; return r;
 }
diff --git a/src/archives.h b/src/archives.h
index 9f47aa2..0150086 100644
--- a/src/archives.h
+++ b/src/archives.h
@@ -62,7 +62,8 @@ void cu_prermdeconfigure(int argc, void **argv);
 void ok_prermdeconfigure(int argc, void **argv);
 
 void setupfnamevbs(const char *filename);
-int unlinkorrmdir(const char *filename);
+
+int secure_remove(const char *filename);
 
 int tarobject(void *ctx, struct tar_entry *ti);
 int tarfileread(void *ud, char *buf, int len);
diff --git a/src/cleanup.c b/src/cleanup.c
index e31ee9d..484232d 100644
--- a/src/cleanup.c
+++ b/src/cleanup.c
@@ -81,7 +81,7 @@ void cu_installnew(int argc, void **argv) {
* link to the new version we may have created.
*/
   debug(dbg_eachfiledetail,cu_installnew restoring nonatomic);
-  if (unlinkorrmdir(fnamevb.buf)  errno != ENOENT  errno != ENOTDIR)
+  if (secure_remove(fnamevb.buf)  errno != ENOENT  errno != ENOTDIR)
 ohshite(_(unable to remove newly-installed version of `%.250s' to 
allow
  reinstallation of backup copy),namenode-name);
 } else {
@@ -96,14 +96,14 @@ void cu_installnew(int argc, void **argv) {
   ohshite(_(unable to remove backup copy of '%.250s'), namenode-name);
   } else if (namenode-flags  fnnf_placed_on_disk) {
 debug(dbg_eachfiledetail,cu_installnew removing new file);
-if (unlinkorrmdir(fnamevb.buf)  errno != ENOENT  errno != ENOTDIR)
+if (secure_remove(fnamevb.buf)  errno != ENOENT  errno != ENOTDIR)
   ohshite(_(unable to remove newly-installed version of `%.250s'),
  namenode-name);
   } else {
 debug(dbg_eachfiledetail,cu_installnew not restoring);
   }
   /* Whatever, we delete foo.dpkg-new now, if it still exists. */
-  if (unlinkorrmdir(fnamenewvb.buf)  errno != ENOENT  errno != ENOTDIR)
+  if (secure_remove(fnamenewvb.buf)  errno != ENOENT  errno != ENOTDIR)
 ohshite(_(unable to remove newly-extracted version of 
`%.250s'),namenode-name);
 
   cleanup_pkg_failed--; cleanup_conflictor_failed--;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 4ff39dabad2cd8e384f26f3212a55b5adbeb71d9
Author: Guillem Jover guil...@debian.org
Date:   Sat Sep 11 06:20:37 2010 +0200

Update TODO list

diff --git a/TODO b/TODO
index c4f5cb6..038f575 100644
--- a/TODO
+++ b/TODO
@@ -23,9 +23,12 @@ TODO
(1.x = 2.x) while minor version bump will be used for backwards
compatible extension (e.g. new fields).
 
- * Make dpkg bootstrappable.
+ * Build:
+   - Make dpkg bootstrappable.
+   - Check availability of warning flags at configure time.
+   - Handle missing lstat at configure time by erroring out.
 
- * Code cleanup:
+ * Code cleanup / bug fixes:
- Get rid of static variables inside functions.
- Coalesce admindir / infodir / foodir generation.
- Get rid of setjmp (at least in the general case, keep for dpkg itself?)
@@ -45,8 +48,21 @@ TODO
- Replace raw write and read calls with safe variants (signals etc).
- Make deb build version a version instead of doing checks over a string.
- Use enums for currently hardcoded literals (tdus, dependtry, etc).
-
- * Cleanup libcompat:
+   - Namespace pkg_db funcs.
+   - Do not use nfmalloc (and friends) for non in-core db memory.
+   - Call nffreeall on exit (need to detangle nfmalloc from non-db first).
+   - Add a size parameter to the buffer api to avoid some useless
+ pipe+fork+copy.
+   - Handle instdir '/' separator consistently.
+   - Check if caching selinux context for second call is possible.
+   - Refactor parse_warn/parse_error.
+   - Make parse_warn use warning().
+   - Add missing newlines in --version output.
+   - Fix leak on tar_extract (name, linkname).
+   - Handle symlinks in statcmd.c statdb_node_apply().
+   - Fix dpkg termination on SIGPIPE from status-fd.
+
+ * libcompat cleanup:
- Add fnmatch, IRIX5 doesn't have it.
 
  * Man pages:
@@ -62,6 +78,7 @@ TODO
- Fix «.  ».
 
  * L10n:
+   - Check dpkg-divert strings for new and fixable ones.
- Standardize translated error messages in the perl code to avoid useless
  work for translators.
- Check http://d-i.alioth.debian.org/spellcheck/level5/index.html

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 6a7e76a292d865e3abeff4fdd086780dda3f49d8
Author: Guillem Jover guil...@debian.org
Date:   Sat Sep 11 06:19:17 2010 +0200

libdpkg: Remove unused stream_md5 macro

diff --git a/lib/dpkg/buffer.h b/lib/dpkg/buffer.h
index 54f084f..4321bbd 100644
--- a/lib/dpkg/buffer.h
+++ b/lib/dpkg/buffer.h
@@ -54,9 +54,6 @@ struct buffer_data {
 # define fd_md5(fd, hash, limit, ...) \
buffer_copy_IntPtr(fd, BUFFER_READ_FD, hash, BUFFER_WRITE_MD5, \
   limit, __VA_ARGS__)
-# define stream_md5(file, hash, limit, ...) \
-   buffer_copy_PtrPtr(file, BUFFER_READ_STREAM, hash, BUFFER_WRITE_MD5, \
-  limit, __VA_ARGS__)
 # define fd_fd_copy(fd1, fd2, limit, ...) \
buffer_copy_IntInt(fd1, BUFFER_READ_FD, fd2, BUFFER_WRITE_FD, \
   limit, __VA_ARGS__)

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 0cb6f131d85f48f0dc8a90ca1329af84c6f6ebc1
Author: Guillem Jover guil...@debian.org
Date:   Sun Sep 12 07:22:21 2010 +0200

libdpkg: Refactor file locking error message handling

Pass only the description of the resource being locked, and move generic
error strings inside the file lock funtions. Instead of changing locking
behaviour depending on the error strings passed, pass an explicit enum to
select it.

diff --git a/lib/dpkg/dbmodify.c b/lib/dpkg/dbmodify.c
index fb2aeb2..0366ce4 100644
--- a/lib/dpkg/dbmodify.c
+++ b/lib/dpkg/dbmodify.c
@@ -195,9 +195,7 @@ modstatdb_lock(const char *admindir)
 }
   }
 
-  file_lock(dblockfd, dblockfile,
-_(unable to lock dpkg status database),
-_(status database area is locked by another process));
+  file_lock(dblockfd, FILE_LOCK_NOWAIT, dblockfile, _(dpkg status 
database));
 
   free(dblockfile);
 }
diff --git a/lib/dpkg/file.c b/lib/dpkg/file.c
index 40fbbea..3c817ee 100644
--- a/lib/dpkg/file.c
+++ b/lib/dpkg/file.c
@@ -67,6 +67,7 @@ static void
 file_unlock_cleanup(int argc, void **argv)
 {
int lockfd = *(int*)argv[0];
+   const char *lock_desc = argv[1];
struct flock fl;
 
assert(lockfd = 0);
@@ -74,7 +75,7 @@ file_unlock_cleanup(int argc, void **argv)
file_lock_setup(fl, F_UNLCK);
 
if (fcntl(lockfd, F_SETLK, fl) == -1)
-   ohshite(_(unable to unlock dpkg status database));
+   ohshite(_(unable to unlock %s), lock_desc);
 }
 
 void
@@ -108,21 +109,28 @@ file_is_locked(int lockfd, const char *filename)
 /* lockfd must be allocated statically as its addresses is passed to
  * a cleanup handler. */
 void
-file_lock(int *lockfd, const char *filename,
-  const char *emsg, const char *emsg_eagain)
+file_lock(int *lockfd, enum file_lock_flags flags, const char *filename,
+  const char *desc)
 {
struct flock fl;
+   int lock_cmd;
 
setcloexec(*lockfd, filename);
 
file_lock_setup(fl, F_WRLCK);
 
-   if (fcntl(*lockfd, emsg_eagain ? F_SETLK : F_SETLKW, fl) == -1) {
-   if (emsg_eagain  (errno == EACCES || errno == EAGAIN))
-   ohshit(emsg_eagain);
-   ohshite(emsg);
+   if (flags == FILE_LOCK_WAIT)
+   lock_cmd = F_SETLKW;
+   else
+   lock_cmd = F_SETLK;
+
+   if (fcntl(*lockfd, lock_cmd, fl) == -1) {
+   if (errno == EACCES || errno == EAGAIN)
+   ohshit(_(%s is locked by another process), desc);
+   else
+   ohshite(_(unable to lock %s), desc);
}
 
-   push_cleanup(file_unlock_cleanup, ~0, NULL, 0, 1, lockfd);
+   push_cleanup(file_unlock_cleanup, ~0, NULL, 0, 2, lockfd, desc);
 }
 
diff --git a/lib/dpkg/file.h b/lib/dpkg/file.h
index 24dca2c..ce16c04 100644
--- a/lib/dpkg/file.h
+++ b/lib/dpkg/file.h
@@ -32,9 +32,14 @@ DPKG_BEGIN_DECLS
  */
 void file_copy_perms(const char *src, const char *dst);
 
+enum file_lock_flags {
+   FILE_LOCK_NOWAIT,
+   FILE_LOCK_WAIT,
+};
+
 bool file_is_locked(int lockfd, const char *filename);
-void file_lock(int *lockfd, const char *filename,
-   const char *emsg, const char *emsg_eagain);
+void file_lock(int *lockfd, enum file_lock_flags flags, const char *filename,
+   const char *desc);
 void file_unlock(void);
 
 DPKG_END_DECLS
diff --git a/lib/dpkg/trigdeferred.l b/lib/dpkg/trigdeferred.l
index 3be1e83..7bd4e91 100644
--- a/lib/dpkg/trigdeferred.l
+++ b/lib/dpkg/trigdeferred.l
@@ -126,8 +126,7 @@ trigdef_update_start(enum trigdef_updateflags uf, const 
char *admindir)
}
}
 
-   file_lock(lock_fd, fn.buf, _(unable to lock triggers area),
- NULL);
+   file_lock(lock_fd, FILE_LOCK_WAIT, fn.buf, _(triggers area));
} else {
/* Dummy for pop_cleanups. */
push_cleanup(NULL, 0, NULL, 0, 0);

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit ceb07b08dad4d5eead630064f45c7e7ded00a341
Author: Guillem Jover guil...@debian.org
Date:   Thu Sep 16 19:52:41 2010 +0200

Refactor file_stat code

Create a new file_stat struct, and use it instead of the
filestatoverride one.

diff --git a/lib/dpkg/file.h b/lib/dpkg/file.h
index ce16c04..f9360d7 100644
--- a/lib/dpkg/file.h
+++ b/lib/dpkg/file.h
@@ -2,7 +2,7 @@
  * libdpkg - Debian packaging suite library routines
  * file.h - file handling routines
  *
- * Copyright © 2008 Guillem Jover guil...@debian.org
+ * Copyright © 2008-2010 Guillem Jover guil...@debian.org
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,12 +21,21 @@
 #ifndef LIBDPKG_FILE_H
 #define LIBDPKG_FILE_H
 
+#include sys/types.h
+
 #include stdbool.h
 
 #include dpkg/macros.h
 
 DPKG_BEGIN_DECLS
 
+struct file_stat {
+   uid_t uid;
+   gid_t gid;
+   mode_t mode;
+   time_t mtime;
+};
+
 /*
  * Copy file ownership and permissions from one file to another.
  */
diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c
index c5b598d..dd22e20 100644
--- a/lib/dpkg/tarfn.c
+++ b/lib/dpkg/tarfn.c
@@ -180,10 +180,10 @@ DecodeTarHeader(char *block, struct tar_entry *d)
else
d-name = StoC(h-Name, sizeof(h-Name));
d-linkname = StoC(h-LinkName, sizeof(h-LinkName));
-   d-mode = get_unix_mode(h);
+   d-stat.mode = get_unix_mode(h);
d-size = (size_t)OtoL(h-Size, sizeof(h-Size));
-   d-mtime = (time_t)OtoL(h-ModificationTime,
-   sizeof(h-ModificationTime));
+   d-stat.mtime = (time_t)OtoL(h-ModificationTime,
+sizeof(h-ModificationTime));
d-dev = ((OtoL(h-MajorDevice,
sizeof(h-MajorDevice))  0xff)  8) |
 (OtoL(h-MinorDevice, sizeof(h-MinorDevice))  0xff);
@@ -191,16 +191,16 @@ DecodeTarHeader(char *block, struct tar_entry *d)
if (*h-UserName)
passwd = getpwnam(h-UserName);
if (passwd)
-   d-uid = passwd-pw_uid;
+   d-stat.uid = passwd-pw_uid;
else
-   d-uid = (uid_t)OtoL(h-UserID, sizeof(h-UserID));
+   d-stat.uid = (uid_t)OtoL(h-UserID, sizeof(h-UserID));
 
if (*h-GroupName)
group = getgrnam(h-GroupName);
if (group)
-   d-gid = group-gr_gid;
+   d-stat.gid = group-gr_gid;
else
-   d-gid = (gid_t)OtoL(h-GroupID, sizeof(h-GroupID));
+   d-stat.gid = (gid_t)OtoL(h-GroupID, sizeof(h-GroupID));
 
checksum = OtoL(h-Checksum, sizeof(h-Checksum));
 
diff --git a/lib/dpkg/tarfn.h b/lib/dpkg/tarfn.h
index 0401cb0..2e6a3b4 100644
--- a/lib/dpkg/tarfn.h
+++ b/lib/dpkg/tarfn.h
@@ -3,6 +3,7 @@
  * tarfn.h - tar archive extraction functions
  *
  * Copyright © 1995 Bruce Perens
+ * Copyright © 2009-2010 Guillem Jover guil...@debian.org
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,6 +27,8 @@
 #include unistd.h
 #include stdlib.h
 
+#include dpkg/file.h
+
 #define TARBLKSZ   512
 
 enum tar_format {
@@ -54,11 +57,9 @@ struct tar_entry {
char *name; /* File name */
char *linkname; /* Name for symbolic and hard links */
size_t size;/* Size of file */
-   time_t mtime;   /* Last-modified time */
-   mode_t mode;/* Unix mode, including device bits. */
-   uid_t uid;  /* Numeric UID */
-   gid_t gid;  /* Numeric GID */
dev_t dev;  /* Special device for mknod() */
+
+   struct file_stat stat;
 };
 
 typedef int (*tar_read_func)(void *ctx, char *buffer, int length);
diff --git a/src/archives.c b/src/archives.c
index fdfad13..5103a94 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -4,6 +4,7 @@
  *
  * Copyright © 1994,1995 Ian Jackson i...@chiark.greenend.org.uk
  * Copyright © 2000 Wichert Akkerman wakke...@debian.org
+ * Copyright © 2007-2010 Guillem Jover guil...@debian.org
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -46,6 +47,7 @@
 #include dpkg/buffer.h
 #include dpkg/subproc.h
 #include dpkg/command.h
+#include dpkg/file.h
 #include dpkg/tarfn.h
 #include dpkg/myopt.h
 #include dpkg/triglib.h
@@ -231,26 +233,23 @@ does_replace(struct pkginfo *newpigp, struct 
pkginfoperfile *newpifp,
 }
 
 static void
-newtarobject_utime(const char *path, struct tar_entry *ti)
+newtarobject_utime(const char *path, struct file_stat *st)
 {
   struct utimbuf utb;
   utb.actime= currenttime;
-  utb.modtime = ti-mtime;
+  utb.modtime = st-mtime;
   if (utime(path,utb))
-ohshite(_(error setting timestamps of 

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 2a71e444e863a4bf28b7dd39e621c44ab771db99
Author: Guillem Jover guil...@debian.org
Date:   Sat Sep 11 06:21:36 2010 +0200

dpkg-deb: Remove unused safe_fflush function

This function was used to fix a problem with undefined behaviour on
input streams, which does not apply anymore as it's not used.

diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index 91fc89a..004d798 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -122,24 +122,6 @@ parseheaderlength(const char *inh, size_t len,
   return (size_t)r;
 }
 
-static void
-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];

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 6e5d5c1f05edbe0ce2213a6658b438668fe48cba
Author: Guillem Jover guil...@debian.org
Date:   Wed Oct 6 11:53:36 2010 +0200

libdpkg: Move ehandle declarations to its own header file

diff --git a/lib/dpkg/dpkg.h b/lib/dpkg/dpkg.h
index 3e39ccb..97950e9 100644
--- a/lib/dpkg/dpkg.h
+++ b/lib/dpkg/dpkg.h
@@ -24,9 +24,7 @@
 
 #include sys/types.h
 
-#include setjmp.h
 #include stddef.h
-#include stdarg.h
 #include stdio.h
 
 #include dpkg/macros.h
@@ -104,7 +102,7 @@ DPKG_BEGIN_DECLS
 
 #define FIND_EXPRSTARTCHARS -(),!
 
-extern const char thisname[]; /* defined separately in each program */
+#include dpkg/ehandle.h
 
 /*** from startup.c ***/
 
@@ -121,35 +119,6 @@ extern const char thisname[]; /* defined separately in 
each program */
   error_unwind(ehflag_normaltidy);\
 } while (0)
 
-/*** from ehandle.c ***/
-
-extern volatile int onerr_abort;
-
-typedef void error_printer(const char *emsg, const char *contextstring);
-
-void push_error_handler(jmp_buf *jbufp, error_printer *printerror,
-const char *contextstring);
-void set_error_display(error_printer *printerror, const char *contextstring);
-void print_error_fatal(const char *emsg, const char *contextstring);
-void error_unwind(int flagset);
-void push_cleanup(void (*f1)(int argc, void **argv), int flagmask1,
-  void (*f2)(int argc, void **argv), int flagmask2,
-  unsigned int nargs, ...);
-void push_checkpoint(int mask, int value);
-void pop_cleanup(int flagset);
-enum { ehflag_normaltidy=01, ehflag_bombout=02, ehflag_recursiveerror=04 };
-
-void do_internerr(const char *file, int line, const char *fmt, ...)
-   DPKG_ATTR_NORET DPKG_ATTR_PRINTF(3);
-#define internerr(...) do_internerr(__FILE__, __LINE__, __VA_ARGS__)
-
-void ohshit(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
-void ohshitv(const char *fmt, va_list args)
-   DPKG_ATTR_NORET DPKG_ATTR_VPRINTF(1);
-void ohshite(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
-void werr(const char *what) DPKG_ATTR_NORET;
-void warning(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
-
 /*** log.c ***/
 
 extern const char *log_file;
diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 84838b7..7345b27 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -31,7 +31,7 @@
 
 #include dpkg/macros.h
 #include dpkg/i18n.h
-#include dpkg/dpkg.h
+#include dpkg/ehandle.h
 
 static const char *errmsg; /* points to errmsgbuf or malloc'd */
 static char errmsgbuf[4096];
diff --git a/lib/dpkg/ehandle.h b/lib/dpkg/ehandle.h
new file mode 100644
index 000..856cd19
--- /dev/null
+++ b/lib/dpkg/ehandle.h
@@ -0,0 +1,73 @@
+/*
+ * libdpkg - Debian packaging suite library routines
+ * ehandle.h - error handling
+ *
+ * Copyright © 1994,1995 Ian Jackson i...@chiark.greenend.org.uk
+ * Copyright © 2000,2001 Wichert Akkerman wich...@debian.org
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef LIBDPKG_EHANDLE_H
+#define LIBDPKG_EHANDLE_H
+
+#include setjmp.h
+#include stddef.h
+#include stdarg.h
+
+#include dpkg/macros.h
+
+DPKG_BEGIN_DECLS
+
+extern const char thisname[]; /* defined separately in each program */
+
+extern volatile int onerr_abort;
+
+enum {
+   ehflag_normaltidy = 01,
+   ehflag_bombout = 02,
+   ehflag_recursiveerror = 04
+};
+
+typedef void error_printer(const char *emsg, const char *contextstring);
+
+void print_error_fatal(const char *emsg, const char *contextstring);
+
+void push_error_handler(jmp_buf *jbufp, error_printer *printerror,
+const char *contextstring);
+void error_unwind(int flagset);
+void set_error_display(error_printer *printerror, const char *contextstring);
+
+void push_cleanup(void (*f1)(int argc, void **argv), int flagmask1,
+  void (*f2)(int argc, void **argv), int flagmask2,
+  unsigned int nargs, ...);
+void push_checkpoint(int mask, int value);
+void pop_cleanup(int flagset);
+
+void warning(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
+
+void ohshitv(const char *fmt, va_list args)
+   DPKG_ATTR_NORET DPKG_ATTR_VPRINTF(1);
+void ohshit(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
+void ohshite(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);
+
+void werr(const char *what) DPKG_ATTR_NORET;
+
+void do_internerr(const char *file, 

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit e8079c0ee34d4b3309ffbbd500b16525e9ec1b22
Author: Guillem Jover guil...@debian.org
Date:   Tue Nov 2 08:16:56 2010 +0100

libdpkg: Switch test.h from including dpkg/dpkg.h to dpkg/ehandle.h

This reduces the exposed declarations for each test program.

diff --git a/lib/dpkg/test.h b/lib/dpkg/test.h
index 5e8f1ad..eb18f17 100644
--- a/lib/dpkg/test.h
+++ b/lib/dpkg/test.h
@@ -25,7 +25,7 @@
 #include string.h
 
 #ifndef TEST_MAIN_PROVIDED
-#include dpkg/dpkg.h
+#include dpkg/ehandle.h
 #endif
 
 /* XXX: Using assert is problematic with NDEBUG. */

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit a67107c05153db3fde51301450439761e1916a80
Author: Guillem Jover guil...@debian.org
Date:   Wed Oct 6 20:10:47 2010 +0200

Use ACTION macros instead of ad-hoc action function handling

This makes the code uniform with the rest of the code base, removes
the possibility of mismatched entries from cmdinfos and dofunctions
arrays, and reduces the scope of the action pointer to main().

diff --git a/dpkg-deb/dpkg-deb.h b/dpkg-deb/dpkg-deb.h
index 4f302c1..acadbc5 100644
--- a/dpkg-deb/dpkg-deb.h
+++ b/dpkg-deb/dpkg-deb.h
@@ -28,7 +28,6 @@ dofunction do_info, do_field, do_extract, do_vextract, 
do_fsystarfile;
 
 extern int debugflag, nocheckflag, oldformatflag;
 extern const struct cmdinfo *cipaction;
-extern dofunction *action;
 
 void extracthalf(const char *debar, const char *directory,
  const char *taroption, int admininfo);
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c
index 319e715..cef1ed9 100644
--- a/dpkg-deb/main.c
+++ b/dpkg-deb/main.c
@@ -135,7 +135,6 @@ int debugflag=0, nocheckflag=0, 
oldformatflag=BUILDOLDPKGFORMAT;
 struct compressor *compressor = compressor_gzip;
 int compress_level = -1;
 const struct cmdinfo *cipaction = NULL;
-dofunction *action = NULL;
 
 static void setaction(const struct cmdinfo *cip, const char *value);
 static void setcompresstype(const struct cmdinfo *cip, const char *value);
@@ -156,31 +155,20 @@ set_compress_level(const struct cmdinfo *cip, const char 
*value)
   compress_level = level;
 }
 
-static dofunction *const dofunctions[]= {
-  do_build,
-  do_contents,
-  do_control,
-  do_info,
-  do_field,
-  do_extract,
-  do_vextract,
-  do_fsystarfile,
-  do_showinfo
-};
+#define ACTION(longopt, shortopt, code, function) \
+ { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (voidfnp)function }
 
-/* NB: the entries using setaction must appear first and be in the
- * same order as dofunctions:
- */
 static const struct cmdinfo cmdinfos[]= {
-  { build, 'b', 0, NULL,   NULL, setaction},
-  { contents,  'c', 0, NULL,   NULL, setaction},
-  { control,   'e', 0, NULL,   NULL, setaction},
-  { info,  'I', 0, NULL,   NULL, setaction},
-  { field, 'f', 0, NULL,   NULL, setaction},
-  { extract,   'x', 0, NULL,   NULL, setaction},
-  { vextract,  'X', 0, NULL,   NULL, setaction},
-  { fsys-tarfile,  0,   0, NULL,   NULL, setaction},
-  { show,  'W', 0, NULL,   NULL, setaction},
+  ACTION(build, 'b', 0, do_build),
+  ACTION(contents,  'c', 0, do_contents),
+  ACTION(control,   'e', 0, do_control),
+  ACTION(info,  'I', 0, do_info),
+  ACTION(field, 'f', 0, do_field),
+  ACTION(extract,   'x', 0, do_extract),
+  ACTION(vextract,  'X', 0, do_vextract),
+  ACTION(fsys-tarfile,  0,   0, do_fsystarfile),
+  ACTION(show,  'W', 0, do_showinfo),
+
   { new,   0,   0, oldformatflag, NULL, NULL,  0 },
   { old,   0,   0, oldformatflag, NULL, NULL,  1 },
   { debug, 'D', 0, debugflag, NULL, NULL,  1 },
@@ -198,8 +186,6 @@ static void setaction(const struct cmdinfo *cip, const char 
*value) {
 badusage(_(conflicting actions -%c (--%s) and -%c (--%s)),
  cip-oshort, cip-olong, cipaction-oshort, cipaction-olong);
   cipaction= cip;
-  assert((int)(cip - cmdinfos)  (int)(array_count(dofunctions)));
-  action= dofunctions[cip-cmdinfos];
 }
 
 static void setcompresstype(const struct cmdinfo *cip, const char *value) {
@@ -210,6 +196,7 @@ static void setcompresstype(const struct cmdinfo *cip, 
const char *value) {
 
 int main(int argc, const char *const *argv) {
   jmp_buf ejbuf;
+  dofunction *action;
 
   setlocale(LC_NUMERIC, POSIX);
   setlocale(LC_ALL, );
@@ -222,6 +209,7 @@ int main(int argc, const char *const *argv) {
   if (!cipaction) badusage(_(need an action option));
 
   unsetenv(GZIP);
+  action = (dofunction *)cipaction-farg;
   action(argv);
   standard_shutdown();
   exit(0);
diff --git a/dpkg-split/dpkg-split.h b/dpkg-split/dpkg-split.h
index 4fd0bf7..12830c0 100644
--- a/dpkg-split/dpkg-split.h
+++ b/dpkg-split/dpkg-split.h
@@ -49,7 +49,6 @@ struct partqueue {
*/
 };
 
-extern dofunction *action;
 extern const struct cmdinfo *cipaction;
 extern struct partqueue *queue;
 
diff --git a/dpkg-split/main.c b/dpkg-split/main.c
index a143eb0..773f2ca 100644
--- a/dpkg-split/main.c
+++ b/dpkg-split/main.c
@@ -96,7 +96,6 @@ usage(const struct cmdinfo *cip, const char *value)
 const char thisname[]= SPLITTER;
 const char printforhelp[]= N_(Type dpkg-split --help for help.);
 
-dofunction *action=NULL;
 const struct cmdinfo *cipaction=NULL;
 struct partqueue *queue= NULL;
 
@@ 

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit c9b7af92e5de0cc9ea40fad53c0e5aa5c93690cd
Author: Guillem Jover guil...@debian.org
Date:   Thu Oct 7 09:49:26 2010 +0200

Move action and obsolete related functionality to the myopt module

Reduce repeated code, and localize it where it belongs.

diff --git a/TODO b/TODO
index 038f575..ad1a1bd 100644
--- a/TODO
+++ b/TODO
@@ -44,7 +44,6 @@ TODO
- Get rid of unuseful unsigned modifiers.
- Use internerr instead of assert, and print more meaninful messages.
- Make actionfunction return int, and avoid global exitcode variables.
-   - Move ACTION and OBSOLETE, etc to ‘myopt.h’.
- Replace raw write and read calls with safe variants (signals etc).
- Make deb build version a version instead of doing checks over a string.
- Use enums for currently hardcoded literals (tdus, dependtry, etc).
diff --git a/dpkg-deb/dpkg-deb.h b/dpkg-deb/dpkg-deb.h
index acadbc5..f3a1d1b 100644
--- a/dpkg-deb/dpkg-deb.h
+++ b/dpkg-deb/dpkg-deb.h
@@ -27,7 +27,6 @@ dofunction do_contents, do_control, do_showinfo;
 dofunction do_info, do_field, do_extract, do_vextract, do_fsystarfile;
 
 extern int debugflag, nocheckflag, oldformatflag;
-extern const struct cmdinfo *cipaction;
 
 void extracthalf(const char *debar, const char *directory,
  const char *taroption, int admininfo);
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c
index cef1ed9..a909e39 100644
--- a/dpkg-deb/main.c
+++ b/dpkg-deb/main.c
@@ -134,9 +134,7 @@ const char printforhelp[]=
 int debugflag=0, nocheckflag=0, oldformatflag=BUILDOLDPKGFORMAT;
 struct compressor *compressor = compressor_gzip;
 int compress_level = -1;
-const struct cmdinfo *cipaction = NULL;
 
-static void setaction(const struct cmdinfo *cip, const char *value);
 static void setcompresstype(const struct cmdinfo *cip, const char *value);
 
 static void
@@ -155,9 +153,6 @@ set_compress_level(const struct cmdinfo *cip, const char 
*value)
   compress_level = level;
 }
 
-#define ACTION(longopt, shortopt, code, function) \
- { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (voidfnp)function }
-
 static const struct cmdinfo cmdinfos[]= {
   ACTION(build, 'b', 0, do_build),
   ACTION(contents,  'c', 0, do_contents),
@@ -181,13 +176,6 @@ static const struct cmdinfo cmdinfos[]= {
   {  NULL,   0,   0, NULL,   NULL, NULL }
 };
 
-static void setaction(const struct cmdinfo *cip, const char *value) {
-  if (cipaction)
-badusage(_(conflicting actions -%c (--%s) and -%c (--%s)),
- cip-oshort, cip-olong, cipaction-oshort, cipaction-olong);
-  cipaction= cip;
-}
-
 static void setcompresstype(const struct cmdinfo *cip, const char *value) {
   compressor = compressor_find_by_name(value);
   if (compressor == NULL)
diff --git a/dpkg-split/dpkg-split.h b/dpkg-split/dpkg-split.h
index 12830c0..5d102ea 100644
--- a/dpkg-split/dpkg-split.h
+++ b/dpkg-split/dpkg-split.h
@@ -49,7 +49,6 @@ struct partqueue {
*/
 };
 
-extern const struct cmdinfo *cipaction;
 extern struct partqueue *queue;
 
 extern long opt_maxpartsize;
diff --git a/dpkg-split/main.c b/dpkg-split/main.c
index 773f2ca..8f33ab2 100644
--- a/dpkg-split/main.c
+++ b/dpkg-split/main.c
@@ -96,7 +96,6 @@ usage(const struct cmdinfo *cip, const char *value)
 const char thisname[]= SPLITTER;
 const char printforhelp[]= N_(Type dpkg-split --help for help.);
 
-const struct cmdinfo *cipaction=NULL;
 struct partqueue *queue= NULL;
 
 long opt_maxpartsize = SPLITPARTDEFMAX;
@@ -114,8 +113,6 @@ void rerreof(FILE *f, const char *fn) {
   ohshit(_(unexpected end of file in %.250s),fn);
 }
 
-static void setaction(const struct cmdinfo *cip, const char *value);
-
 static void setpartsize(const struct cmdinfo *cip, const char *value) {
   long newpartsize;
   char *endp;
@@ -132,9 +129,6 @@ static void setpartsize(const struct cmdinfo *cip, const 
char *value) {
  (HEADERALLOWANCE  10) + 1);
 }
 
-#define ACTION(longopt, shortopt, code, function) \
-{ longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (voidfnp)function }
-
 static const struct cmdinfo cmdinfos[]= {
   ACTION(split,   's',  0,  do_split),
   ACTION(join,'j',  0,  do_join),
@@ -153,13 +147,6 @@ static const struct cmdinfo cmdinfos[]= {
   {  NULL,  0  }
 };
 
-static void setaction(const struct cmdinfo *cip, const char *value) {
-  if (cipaction)
-badusage(_(conflicting actions -%c (--%s) and -%c (--%s)),
- cip-oshort, cip-olong, cipaction-oshort, cipaction-olong);
-  cipaction= cip;
-}
-
 int main(int argc, const char *const *argv) {
   jmp_buf ejbuf;
   int l;
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index 6d6ca1b..be9ba22 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -124,6 +124,9 @@ LIBDPKG_PRIVATE {
badusage;
# printforhelp; # XXX variable, do not 

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit ca92c5d2bf45984c11cf2b5f355b5cad48bf7259
Author: Guillem Jover guil...@debian.org
Date:   Thu Oct 7 09:58:18 2010 +0200

libdpkg: Rename function argument to func in ACTION macro

diff --git a/lib/dpkg/myopt.h b/lib/dpkg/myopt.h
index e36ddaf..b3a6783 100644
--- a/lib/dpkg/myopt.h
+++ b/lib/dpkg/myopt.h
@@ -57,8 +57,8 @@ extern const struct cmdinfo *cipaction;
 void setaction(const struct cmdinfo *cip, const char *value);
 void setobsolete(const struct cmdinfo *cip, const char *value);
 
-#define ACTION(longopt, shortopt, code, function) \
- { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (voidfnp)function }
+#define ACTION(longopt, shortopt, code, func) \
+ { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (voidfnp)func }
 #define OBSOLETE(longopt, shortopt) \
  { longopt, shortopt, 0, NULL, NULL, setobsolete, 0, NULL, NULL }
 

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 9d6a9e43756d2256473935429d9c2f00ad20fb0e
Author: Guillem Jover guil...@debian.org
Date:   Thu Oct 7 10:16:16 2010 +0200

Do not make function typedefs pointers

diff --git a/lib/dpkg/myopt.h b/lib/dpkg/myopt.h
index 6c3fb0f..23fcd5f 100644
--- a/lib/dpkg/myopt.h
+++ b/lib/dpkg/myopt.h
@@ -25,7 +25,7 @@
 
 DPKG_BEGIN_DECLS
 
-typedef void (*void_func)(void);
+typedef void void_func(void);
 
 struct cmdinfo {
   const char *olong;
@@ -36,7 +36,7 @@ struct cmdinfo {
   void (*call)(const struct cmdinfo*, const char *value);
   int arg;
   void *parg;
-  void_func farg;
+  void_func *farg;
 };
 
 extern const char printforhelp[];
@@ -58,7 +58,7 @@ void setaction(const struct cmdinfo *cip, const char *value);
 void setobsolete(const struct cmdinfo *cip, const char *value);
 
 #define ACTION(longopt, shortopt, code, func) \
- { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (void_func)func }
+ { longopt, shortopt, 0, NULL, NULL, setaction, code, NULL, (void_func *)func }
 #define OBSOLETE(longopt, shortopt) \
  { longopt, shortopt, 0, NULL, NULL, setobsolete, 0, NULL, NULL }
 
diff --git a/lib/dpkg/tarfn.h b/lib/dpkg/tarfn.h
index 2e6a3b4..00c87b3 100644
--- a/lib/dpkg/tarfn.h
+++ b/lib/dpkg/tarfn.h
@@ -62,17 +62,17 @@ struct tar_entry {
struct file_stat stat;
 };
 
-typedef int (*tar_read_func)(void *ctx, char *buffer, int length);
-typedef int (*tar_func)(void *ctx, struct tar_entry *h);
+typedef int tar_read_func(void *ctx, char *buffer, int length);
+typedef int tar_func(void *ctx, struct tar_entry *h);
 
 struct tar_operations {
-   tar_read_func read;
+   tar_read_func *read;
 
-   tar_func extract_file;
-   tar_func link;
-   tar_func symlink;
-   tar_func mkdir;
-   tar_func mknod;
+   tar_func *extract_file;
+   tar_func *link;
+   tar_func *symlink;
+   tar_func *mkdir;
+   tar_func *mknod;
 };
 
 int tar_extractor(void *ctx, const struct tar_operations *ops);
diff --git a/src/main.c b/src/main.c
index 7113b36..79324ef 100644
--- a/src/main.c
+++ b/src/main.c
@@ -453,7 +453,7 @@ static const struct cmdinfo cmdinfos[]= {
* have a very similar structure.
*/
 #define ACTIONBACKEND(longopt, shortopt, backend) \
- { longopt, shortopt, 0, NULL, NULL, setaction, 0, (void *)backend, 
(void_func)execbackend }
+ { longopt, shortopt, 0, NULL, NULL, setaction, 0, (void *)backend, (void_func 
*)execbackend }
 
   ACTION( install,'i', act_install,  
archivefiles),
   ACTION( unpack,  0,  act_unpack,   
archivefiles),

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 90ef059f7155bfc7fb45505c21030e2cc9791ce3
Author: Guillem Jover guil...@debian.org
Date:   Fri Oct 8 11:48:36 2010 +0200

Add a comment for translators to 'dpkg-query -l' header string

Reported-by: Ask Hjorth Larsen asklar...@gmail.com

diff --git a/src/querycmd.c b/src/querycmd.c
index 4968b03..bb7b942 100644
--- a/src/querycmd.c
+++ b/src/querycmd.c
@@ -109,6 +109,12 @@ list1package(struct pkginfo *pkg, bool *head, struct 
pkg_array *array)
   }
 
   if (!*head) {
+/* TRANSLATORS: This is the header that appears on 'dpkg-query -l'. The
+ * string should remain under 80 characters. The uppercase letters in
+ * the state values denote the abbreviated letter that will appear on
+ * the first three columns, which should ideally match the English one
+ * (e.g. Remove → supRimeix), see dpkg-query(1) for further details. The
+ * translated message can use additional lines if needed. */
 fputs(_(\
 Desired=Unknown/Install/Remove/Purge/Hold\n\
 | 
Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend\n\

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit ec53fd98f3d10274e2da5722c63fd7f6588b3eaf
Author: Guillem Jover guil...@debian.org
Date:   Tue Nov 2 20:39:08 2010 +0100

libdpkg: Rename print_error_fatal() to print_fatal_error()

diff --git a/dselect/main.cc b/dselect/main.cc
index 0510823..38df1c5 100644
--- a/dselect/main.cc
+++ b/dselect/main.cc
@@ -509,7 +509,7 @@ int main(int, const char *const *argv) {
 cursesoff();
 catch_fatal_error();
   }
-  push_error_handler(ejbuf,print_error_fatal,0);
+  push_error_handler(ejbuf, print_fatal_error, 0);
 
   loadcfgfile(DSELECT, cmdinfos);
   myopt(argv,cmdinfos);
diff --git a/lib/dpkg/dpkg.h b/lib/dpkg/dpkg.h
index 8a8bbff..0a66a13 100644
--- a/lib/dpkg/dpkg.h
+++ b/lib/dpkg/dpkg.h
@@ -110,7 +110,7 @@ DPKG_BEGIN_DECLS
   if (setjmp(*ejbuf)) { /* expect warning about possible clobbering of argv */\
 catch_fatal_error(); \
   }\
-  push_error_handler(ejbuf, print_error_fatal, NULL); \
+  push_error_handler(ejbuf, print_fatal_error, NULL); \
   umask(022); /* Make sure all our status databases are readable. */\
 } while (0)
 
diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 8d85f79..4543d33 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -272,7 +272,9 @@ catch_fatal_error(void)
   exit(2);
 }
 
-void print_error_fatal(const char *emsg, const char *contextstring) {
+void
+print_fatal_error(const char *emsg, const char *contextstring)
+{
   fprintf(stderr, %s: %s\n,thisname,emsg);
 }
 
diff --git a/lib/dpkg/ehandle.h b/lib/dpkg/ehandle.h
index 96ad86d..d86ccaf 100644
--- a/lib/dpkg/ehandle.h
+++ b/lib/dpkg/ehandle.h
@@ -42,7 +42,7 @@ enum {
 
 typedef void error_printer(const char *emsg, const char *contextstring);
 
-void print_error_fatal(const char *emsg, const char *contextstring);
+void print_fatal_error(const char *emsg, const char *contextstring);
 void catch_fatal_error(void);
 
 void push_error_handler(jmp_buf *jbufp, error_printer *printerror,
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index cf460c4..1e9a25d 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -10,7 +10,7 @@ local:
 LIBDPKG_PRIVATE {
# Error handling
set_error_display;
-   print_error_fatal;
+   print_fatal_error;
catch_fatal_error;
push_error_handler;
push_checkpoint;
diff --git a/lib/dpkg/test.h b/lib/dpkg/test.h
index 9a48332..98695e2 100644
--- a/lib/dpkg/test.h
+++ b/lib/dpkg/test.h
@@ -49,7 +49,7 @@ main(int argc, char **argv)
if (setjmp(ejbuf)) {
catch_fatal_error();
}
-   push_error_handler(ejbuf, print_error_fatal, NULL);
+   push_error_handler(ejbuf, print_fatal_error, NULL);
 
test();
 
diff --git a/src/main.c b/src/main.c
index b04a636..704e1e8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -595,7 +595,7 @@ void commandfd(const char *const *argv) {
 bool mode = false;
 int argc= 1;
 lno= 0;
-push_error_handler(ejbuf, print_error_fatal, NULL);
+push_error_handler(ejbuf, print_fatal_error, NULL);
 
 do { c= getc(in); if (c == '\n') lno++; } while (c != EOF  isspace(c));
 if (c == EOF) break;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit e1b2a73e7723126e0cf2109c9e44a793e39ac243
Author: Guillem Jover guil...@debian.org
Date:   Tue Nov 2 20:40:13 2010 +0100

libdpkg: Rename print_error_cleanup() to print_cleanup_error()

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 4543d33..61ddeb1 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -119,7 +119,9 @@ void push_error_handler(jmp_buf *jbufp,
   onerr_abort= 0;
 }
 
-static void print_error_cleanup(const char *emsg, const char *contextstring) {
+static void
+print_cleanup_error(const char *emsg, const char *contextstring)
+{
   fprintf(stderr, _(%s: error while cleaning up:\n %s\n),thisname,emsg);
 }
 
@@ -151,7 +153,7 @@ static void run_cleanups(struct errorcontext *econ, int 
flagsetin) {
   recurserr.jbufp= recurejbuf;
   recurserr.cleanups= NULL;
   recurserr.next= NULL;
-  recurserr.printerror= print_error_cleanup;
+  recurserr.printerror = print_cleanup_error;
   recurserr.contextstring= NULL;
   econtext= recurserr;
   cep-calls[i].call(cep-argc,cep-argv);

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 7ae5af538e0d7b72f1b181922a1401bc16dc44be
Author: Guillem Jover guil...@debian.org
Date:   Mon Oct 11 19:28:34 2010 +0200

libdpkg: Rename jmp_buf variables to jump

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 61ddeb1..08adf1c 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -62,7 +62,7 @@ struct cleanupentry {
 
 struct errorcontext {
   struct errorcontext *next;
-  jmp_buf *jbufp;
+  jmp_buf *jump;
   struct cleanupentry *cleanups;
   void (*printerror)(const char *emsg, const char *contextstring);
   const char *contextstring;
@@ -92,13 +92,14 @@ run_error_handler(void)
 thisname, errmsg);
 exit(2);
   } else {
-longjmp(*econtext-jbufp, 1);
+longjmp(*econtext-jump, 1);
   }
 }
 
-void push_error_handler(jmp_buf *jbufp,
-error_printer *printerror,
-const char *contextstring) {
+void
+push_error_handler(jmp_buf *jump, error_printer *printerror,
+   const char *contextstring)
+{
   struct errorcontext *necp;
   necp= malloc(sizeof(struct errorcontext));
   if (!necp) {
@@ -111,7 +112,7 @@ void push_error_handler(jmp_buf *jbufp,
 fprintf(stderr, %s: %s\n, thisname, errmsgbuf); exit(2);
   }
   necp-next= econtext;
-  necp-jbufp= jbufp;
+  necp-jump = jump;
   necp-cleanups= NULL;
   necp-printerror= printerror;
   necp-contextstring= contextstring;
@@ -130,7 +131,7 @@ static void run_cleanups(struct errorcontext *econ, int 
flagsetin) {
   struct cleanupentry *volatile cep;
   struct cleanupentry *ncep;
   struct errorcontext recurserr, *oldecontext;
-  jmp_buf recurejbuf;
+  jmp_buf recurse_jump;
   volatile int i, flagset;
 
   if (econ-printerror) econ-printerror(errmsg,econ-contextstring);
@@ -147,10 +148,10 @@ static void run_cleanups(struct errorcontext *econ, int 
flagsetin) {
   while (cep) {
 for (i=0; iNCALLS; i++) {
   if (cep-calls[i].call  cep-calls[i].mask  flagset) {
-if (setjmp(recurejbuf)) {
+if (setjmp(recurse_jump)) {
   run_cleanups(recurserr, ehflag_bombout | ehflag_recursiveerror);
 } else {
-  recurserr.jbufp= recurejbuf;
+  recurserr.jump = recurse_jump;
   recurserr.cleanups= NULL;
   recurserr.next= NULL;
   recurserr.printerror = print_cleanup_error;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 160be818013039931cc06443c523fc57a7779937
Author: Guillem Jover guil...@debian.org
Date:   Sat Oct 16 06:52:02 2010 +0200

libdpkg: Rename struct cleanupentry to cleanup_entry

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 08adf1c..bcf6731 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -49,8 +49,8 @@ volatile int onerr_abort = 0;
 
 #define NCALLS 2
 
-struct cleanupentry {
-  struct cleanupentry *next;
+struct cleanup_entry {
+  struct cleanup_entry *next;
   struct {
 int mask;
 void (*call)(int argc, void **argv);
@@ -63,13 +63,16 @@ struct cleanupentry {
 struct errorcontext {
   struct errorcontext *next;
   jmp_buf *jump;
-  struct cleanupentry *cleanups;
+  struct cleanup_entry *cleanups;
   void (*printerror)(const char *emsg, const char *contextstring);
   const char *contextstring;
 };
 
 static struct errorcontext *volatile econtext= NULL;
-static struct { struct cleanupentry ce; void *args[20]; } emergency;
+static struct {
+  struct cleanup_entry ce;
+  void *args[20];
+} emergency;
 
 void set_error_display(error_printer *printerror,
const char *contextstring) {
@@ -128,8 +131,8 @@ print_cleanup_error(const char *emsg, const char 
*contextstring)
 
 static void run_cleanups(struct errorcontext *econ, int flagsetin) {
   static volatile int preventrecurse= 0;
-  struct cleanupentry *volatile cep;
-  struct cleanupentry *ncep;
+  struct cleanup_entry *volatile cep;
+  struct cleanup_entry *ncep;
   struct errorcontext recurserr, *oldecontext;
   jmp_buf recurse_jump;
   volatile int i, flagset;
@@ -187,10 +190,10 @@ void push_checkpoint(int mask, int value) {
* where original_flagset is the argument to error_unwind
* (as modified by any checkpoint which was pushed later).
*/
-  struct cleanupentry *cep;
+  struct cleanup_entry *cep;
   int i;
   
-  cep = malloc(sizeof(struct cleanupentry) + sizeof(char *));
+  cep = malloc(sizeof(struct cleanup_entry) + sizeof(char *));
   if (cep == NULL) {
 onerr_abort++;
 ohshite(_(out of memory for new cleanup entry));
@@ -206,14 +209,14 @@ void push_checkpoint(int mask, int value) {
 void push_cleanup(void (*call1)(int argc, void **argv), int mask1,
   void (*call2)(int argc, void **argv), int mask2,
   unsigned int nargs, ...) {
-  struct cleanupentry *cep;
+  struct cleanup_entry *cep;
   void **argv;
   int e = 0;
   va_list args;
 
   onerr_abort++;
   
-  cep= malloc(sizeof(struct cleanupentry) + sizeof(char*)*(nargs+1));
+  cep = malloc(sizeof(struct cleanup_entry) + sizeof(char *) * (nargs + 1));
   if (!cep) {
 if (nargs  array_count(emergency.args))
   ohshite(_(out of memory for new cleanup entry with many arguments));
@@ -239,7 +242,7 @@ void push_cleanup(void (*call1)(int argc, void **argv), int 
mask1,
 }
 
 void pop_cleanup(int flagset) {
-  struct cleanupentry *cep;
+  struct cleanup_entry *cep;
   int i;
 
   cep= econtext-cleanups;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit b571373cd2e62782c3bb2b8e0bef585c4215b967
Author: Guillem Jover guil...@debian.org
Date:   Sat Oct 16 20:47:20 2010 +0200

libdpkg: Refactor error display setter into a static function

Create a new function that takes an error context argument and sets
the error printer function. This allows using the new setter for
other error_context than econtext.

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 79b19eb..09b1a77 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -74,11 +74,14 @@ static struct {
   void *args[20];
 } emergency;
 
+static void set_error_printer(struct error_context *ec,
+  error_printer *printerror,
+  const char *contextstring);
+
 void set_error_display(error_printer *printerror,
const char *contextstring) {
   assert(econtext);
-  econtext-printerror= printerror;
-  econtext-contextstring= contextstring;
+  set_error_printer(econtext, printerror, contextstring);
 }
 
 static void DPKG_ATTR_NORET
@@ -121,6 +124,14 @@ error_context_new(void)
   return necp;
 }
 
+static void
+set_error_printer(struct error_context *ec, error_printer *printerror,
+  const char *contextstring)
+{
+  ec-printerror = printerror;
+  ec-contextstring = contextstring;
+}
+
 void
 push_error_handler(jmp_buf *jump, error_printer *printerror,
const char *contextstring)
@@ -128,8 +139,7 @@ push_error_handler(jmp_buf *jump, error_printer *printerror,
   struct error_context *ec;
 
   ec = error_context_new();
-  ec-printerror = printerror;
-  ec-contextstring = contextstring;
+  set_error_printer(ec, printerror, contextstring);
   ec-jump = jump;
   onerr_abort = 0;
 }
@@ -170,8 +180,7 @@ run_cleanups(struct error_context *econ, int flagsetin)
   recurserr.jump = recurse_jump;
   recurserr.cleanups= NULL;
   recurserr.next= NULL;
-  recurserr.printerror = print_cleanup_error;
-  recurserr.contextstring= NULL;
+  set_error_printer(recurserr, print_cleanup_error, NULL);
   econtext= recurserr;
   cep-calls[i].call(cep-argc,cep-argv);
 }

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 43789e59f08dae79b07feb004c0fa1b5d357b47d
Author: Guillem Jover guil...@debian.org
Date:   Sat Oct 16 05:55:33 2010 +0200

libdpkg: Make run_error_handler cope with NULL econtext gracefully

This could happen if the context has not been initialized, or if it has
been unwinded more than necessary.

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 09b1a77..093e6f6 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -97,6 +97,12 @@ run_error_handler(void)
 fprintf(stderr, _(%s: unrecoverable fatal error, aborting:\n %s\n),
 thisname, errmsg);
 exit(2);
+  }
+
+  if (econtext == NULL) {
+fprintf(stderr, _(%s: outside error context, aborting:\n %s\n),
+thisname, errmsg);
+exit(2);
   } else {
 longjmp(*econtext-jump, 1);
   }

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 521f32450d91fabaa81725b1ad89f9fafb8c82e3
Author: Guillem Jover guil...@debian.org
Date:   Sat Oct 16 06:03:12 2010 +0200

libdpkg: Use ohshite in error_context_new instead of ad-hoc code

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 093e6f6..a5c4349 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -114,15 +114,8 @@ error_context_new(void)
   struct error_context *necp;
 
   necp = malloc(sizeof(struct error_context));
-  if (!necp) {
-int e= errno;
-snprintf(errmsgbuf, sizeof(errmsgbuf), %s%s, 
-   _(out of memory pushing error handler: ), strerror(e));
-errmsg= errmsgbuf;
-if (econtext)
-  run_error_handler();
-fprintf(stderr, %s: %s\n, thisname, errmsgbuf); exit(2);
-  }
+  if (!necp)
+ohshite(_(out of memory pushing error handler));
   necp-next= econtext;
   necp-cleanups= NULL;
   econtext= necp;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit fd84ba8969bf305d97c225b44858965e53a0cb66
Author: Guillem Jover guil...@debian.org
Date:   Sat Oct 16 07:35:27 2010 +0200

Use thisname variable instead of hard-coded 'dpkg' string

This corrects the current program name printed by other tools.

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index a5c4349..b630bf5 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -163,7 +163,8 @@ run_cleanups(struct error_context *econ, int flagsetin)
  
   if (++preventrecurse  3) {
 onerr_abort++;
-fprintf(stderr, _(dpkg: too many nested errors during error recovery 
!!\n));
+fprintf(stderr, _(%s: too many nested errors during error recovery!!\n),
+thisname);
 flagset= 0;
   } else {
 flagset= flagsetin;
diff --git a/src/errors.c b/src/errors.c
index 88c2210..3b4ceac 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -58,13 +58,15 @@ void print_error_perpackage(const char *emsg, const char 
*arg) {
   struct error_report *nr;
   
   fprintf(stderr, _(%s: error processing %s (--%s):\n %s\n),
-  DPKG, arg, cipaction-olong, emsg);
+  thisname, arg, cipaction-olong, emsg);
 
   statusfd_send(status: %s : %s : %s, arg, error, emsg);
 
   nr= malloc(sizeof(struct error_report));
   if (!nr) {
-perror(_(dpkg: failed to allocate memory for new entry in list of failed 
packages.));
+fprintf(stderr,
+_(%s: failed to allocate memory for new entry in list of failed 
packages: %s),
+thisname, strerror(errno));
 abort_processing = true;
 nr= emergency;
   }
@@ -74,7 +76,7 @@ void print_error_perpackage(const char *emsg, const char 
*arg) {
   lastreport= nr-next;
 
   if (nerrs++  errabort) return;
-  fprintf(stderr, _(dpkg: too many errors, stopping\n));
+  fprintf(stderr, _(%s: too many errors, stopping\n), thisname);
   abort_processing = true;
 }
 
diff --git a/src/querycmd.c b/src/querycmd.c
index bb7b942..4558ccf 100644
--- a/src/querycmd.c
+++ b/src/querycmd.c
@@ -289,7 +289,7 @@ searchfiles(const char *const *argv)
   iterfileend(it);
 }
 if (!found) {
-  fprintf(stderr,_(dpkg: %s not found.\n),thisarg);
+  fprintf(stderr, _(%s: %s not found.\n), thisname, thisarg);
   failures++;
   m_output(stderr, _(standard error));
 } else {
diff --git a/src/trigproc.c b/src/trigproc.c
index 833fb28..1490d61 100644
--- a/src/trigproc.c
+++ b/src/trigproc.c
@@ -245,7 +245,7 @@ check_trigger_cycle(struct pkginfo *processing_now)
/* Oh dear. hare is a superset of tortoise. We are making no progress. 
*/
fprintf(stderr, _(%s: cycle found while processing triggers:\n chain 
of
 packages whose triggers are or may be responsible:\n),
-   DPKG);
+   thisname);
sep =   ;
for (tcn = tortoise; tcn; tcn = tcn-next) {
fprintf(stderr, %s%s, sep, tcn-then_processed-name);

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit bf1455085899a5203373eff34741cd7ea3d64774
Author: Guillem Jover guil...@debian.org
Date:   Sat Oct 16 19:04:13 2010 +0200

libdpkg: Add error context function handler support

This allows the code to use a function instead of a jump buffer to
handle the errors, which happen to be possible for the general case,
when it does not need to continue processing in an upper stack frame.
Thus reducing the preceived complexity of simple code, and avoids
exposing setjmp machinery to the casual user.

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index b630bf5..9e15161 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -62,7 +62,17 @@ struct cleanup_entry {
 
 struct error_context {
   struct error_context *next;
-  jmp_buf *jump;
+
+  enum {
+handler_type_func,
+handler_type_jump,
+  } handler_type;
+
+  union {
+error_handler *func;
+jmp_buf *jump;
+  } handler;
+
   struct cleanup_entry *cleanups;
   void (*printerror)(const char *emsg, const char *contextstring);
   const char *contextstring;
@@ -103,8 +113,13 @@ run_error_handler(void)
 fprintf(stderr, _(%s: outside error context, aborting:\n %s\n),
 thisname, errmsg);
 exit(2);
+  } else if (econtext-handler_type == handler_type_func) {
+econtext-handler.func();
+internerr(error handler returned unexpectedly!);
+  } else if (econtext-handler_type == handler_type_jump) {
+longjmp(*econtext-handler.jump, 1);
   } else {
-longjmp(*econtext-jump, 1);
+internerr(unknown error handler type %d!, econtext-handler_type);
   }
 }
 
@@ -131,15 +146,41 @@ set_error_printer(struct error_context *ec, error_printer 
*printerror,
   ec-contextstring = contextstring;
 }
 
+static void
+set_func_handler(struct error_context *ec, error_handler *func)
+{
+  ec-handler_type = handler_type_func;
+  ec-handler.func = func;
+}
+
+static void
+set_jump_handler(struct error_context *ec, jmp_buf *jump)
+{
+  ec-handler_type = handler_type_jump;
+  ec-handler.jump = jump;
+}
+
+void
+push_error_context_func(error_handler *func, error_printer *printerror,
+const char *contextstring)
+{
+  struct error_context *ec;
+
+  ec = error_context_new();
+  set_error_printer(ec, printerror, contextstring);
+  set_func_handler(ec, func);
+  onerr_abort = 0;
+}
+
 void
-push_error_handler(jmp_buf *jump, error_printer *printerror,
-   const char *contextstring)
+push_error_context_jump(jmp_buf *jump, error_printer *printerror,
+const char *contextstring)
 {
   struct error_context *ec;
 
   ec = error_context_new();
   set_error_printer(ec, printerror, contextstring);
-  ec-jump = jump;
+  set_jump_handler(ec, jump);
   onerr_abort = 0;
 }
 
@@ -177,10 +218,10 @@ run_cleanups(struct error_context *econ, int flagsetin)
 if (setjmp(recurse_jump)) {
   run_cleanups(recurserr, ehflag_bombout | ehflag_recursiveerror);
 } else {
-  recurserr.jump = recurse_jump;
   recurserr.cleanups= NULL;
   recurserr.next= NULL;
   set_error_printer(recurserr, print_cleanup_error, NULL);
+  set_jump_handler(recurserr, recurse_jump);
   econtext= recurserr;
   cep-calls[i].call(cep-argc,cep-argv);
 }
diff --git a/lib/dpkg/ehandle.h b/lib/dpkg/ehandle.h
index d86ccaf..1b72700 100644
--- a/lib/dpkg/ehandle.h
+++ b/lib/dpkg/ehandle.h
@@ -40,13 +40,18 @@ enum {
ehflag_recursiveerror = 04
 };
 
+typedef void error_handler(void);
 typedef void error_printer(const char *emsg, const char *contextstring);
 
 void print_fatal_error(const char *emsg, const char *contextstring);
 void catch_fatal_error(void);
 
-void push_error_handler(jmp_buf *jbufp, error_printer *printerror,
-const char *contextstring);
+#define push_error_handler push_error_context_jump
+
+void push_error_context_jump(jmp_buf *jbufp, error_printer *printerror,
+ const char *contextstring);
+void push_error_context_func(error_handler *func, error_printer *printerror,
+ const char *contextstring);
 void error_unwind(int flagset);
 void set_error_display(error_printer *printerror, const char *contextstring);
 
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index 1e9a25d..0850328 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -9,10 +9,11 @@ local:
 
 LIBDPKG_PRIVATE {
# Error handling
+   push_error_context_jump;
+   push_error_context_func;
set_error_display;
print_fatal_error;
catch_fatal_error;
-   push_error_handler;
push_checkpoint;
push_cleanup;
pop_cleanup;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 2272d4116924caad96816871040a8c1ae16f87e9
Author: Guillem Jover guil...@debian.org
Date:   Sat Oct 16 19:10:42 2010 +0200

Move error context display handler reset to error_unwind()

Never print an error message when doing normal cleanup, as this is
something we always want to do.

diff --git a/lib/dpkg/dpkg.h b/lib/dpkg/dpkg.h
index 0a66a13..7a06b53 100644
--- a/lib/dpkg/dpkg.h
+++ b/lib/dpkg/dpkg.h
@@ -115,7 +115,6 @@ DPKG_BEGIN_DECLS
 } while (0)
 
 #define standard_shutdown() do { \
-  set_error_display(NULL, NULL); \
   error_unwind(ehflag_normaltidy);\
 } while (0)
 
diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 9e15161..61bf5eb 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -242,6 +242,10 @@ void error_unwind(int flagset) {
 
   tecp= econtext;
   econtext= tecp-next;
+
+  /* If we are cleaning up normally, do not print anything. */
+  if (flagset  ehflag_normaltidy)
+set_error_printer(tecp, NULL, NULL);
   run_cleanups(tecp,flagset);
   free(tecp);
 }
diff --git a/lib/dpkg/test.h b/lib/dpkg/test.h
index 98695e2..670001b 100644
--- a/lib/dpkg/test.h
+++ b/lib/dpkg/test.h
@@ -54,7 +54,6 @@ main(int argc, char **argv)
test();
 
/* Shutdown. */
-   set_error_display(NULL, NULL);
error_unwind(ehflag_normaltidy);
 
return 0;
diff --git a/src/archives.c b/src/archives.c
index 5103a94..ef51896 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -1258,7 +1258,7 @@ void archivefiles(const char *const *argv) {
 m_output(stdout, _(standard output));
 m_output(stderr, _(standard error));
 onerr_abort--;
-set_error_display(NULL, NULL);
+
 error_unwind(ehflag_normaltidy);
   }
 
diff --git a/src/main.c b/src/main.c
index a504794..8558d56 100644
--- a/src/main.c
+++ b/src/main.c
@@ -658,7 +658,7 @@ void commandfd(const char *const *argv) {
 
 actionfunction= (void (*)(const char* const*))cipaction-farg;
 actionfunction(newargs);
-set_error_display(NULL, NULL);
+
 error_unwind(ehflag_normaltidy);
   }
 }
diff --git a/src/packages.c b/src/packages.c
index 71cb50e..cfdde66 100644
--- a/src/packages.c
+++ b/src/packages.c
@@ -248,7 +248,7 @@ void process_queue(void) {
 }
 m_output(stdout, _(standard output));
 m_output(stderr, _(standard error));
-set_error_display(NULL, NULL);
+
 error_unwind(ehflag_normaltidy);
   }
   assert(!queue.length);
diff --git a/src/trigproc.c b/src/trigproc.c
index 1490d61..b1151fd 100644
--- a/src/trigproc.c
+++ b/src/trigproc.c
@@ -122,7 +122,6 @@ trigproc_run_deferred(void)
pkg-clientdata-trigprocdeferred = NULL;
trigproc(pkg);
 
-   set_error_display(NULL, NULL);
error_unwind(ehflag_normaltidy);
}
 }

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 29f4ab41c95abf9639b81918d9b7aa1ca8edbe81
Author: Guillem Jover guil...@debian.org
Date:   Sat Oct 16 19:16:50 2010 +0200

libdpkg: Create a new error context in subproc_fork

Instead of changing the current error display handler and pushing a
cleanup handler that exits immediately to avoid calling previously
set cleanup handlers, just push a new error context which will work
as a cleanup barrier. This also is a more natural way of using the
current interface.

diff --git a/lib/dpkg/subproc.c b/lib/dpkg/subproc.c
index 26bd074..7a48979 100644
--- a/lib/dpkg/subproc.c
+++ b/lib/dpkg/subproc.c
@@ -77,14 +77,6 @@ print_subproc_error(const char *emsg, const char 
*contextstring)
fprintf(stderr, _(%s (subprocess): %s\n), thisname, emsg);
 }
 
-static void DPKG_ATTR_NORET
-subproc_fork_cleanup(int argc, void **argv)
-{
-   /* Don't do the other cleanups, because they'll be done by/in the
-* parent process. */
-   exit(2);
-}
-
 pid_t
 subproc_fork(void)
 {
@@ -98,8 +90,9 @@ subproc_fork(void)
if (r  0)
return r;
 
-   push_cleanup(subproc_fork_cleanup, ~0, NULL, 0, 0);
-   set_error_display(print_subproc_error, NULL);
+   /* Push a new error context, so that we don't do the other cleanups,
+* because they'll be done by/in the parent process. */
+   push_error_context_func(catch_fatal_error, print_subproc_error, NULL);
 
return r;
 }

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit de42418d9c0a255cec4440b5f99e764654440159
Author: Guillem Jover guil...@debian.org
Date:   Sat Oct 16 20:59:07 2010 +0200

libdpkg: Remove set_error_display()

If the code needs to set a different error printer then it should push
a new error context instead.

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 61bf5eb..81d61ac 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -84,16 +84,6 @@ static struct {
   void *args[20];
 } emergency;
 
-static void set_error_printer(struct error_context *ec,
-  error_printer *printerror,
-  const char *contextstring);
-
-void set_error_display(error_printer *printerror,
-   const char *contextstring) {
-  assert(econtext);
-  set_error_printer(econtext, printerror, contextstring);
-}
-
 static void DPKG_ATTR_NORET
 run_error_handler(void)
 {
diff --git a/lib/dpkg/ehandle.h b/lib/dpkg/ehandle.h
index 1b72700..4483e20 100644
--- a/lib/dpkg/ehandle.h
+++ b/lib/dpkg/ehandle.h
@@ -53,7 +53,6 @@ void push_error_context_jump(jmp_buf *jbufp, error_printer 
*printerror,
 void push_error_context_func(error_handler *func, error_printer *printerror,
  const char *contextstring);
 void error_unwind(int flagset);
-void set_error_display(error_printer *printerror, const char *contextstring);
 
 void push_cleanup(void (*f1)(int argc, void **argv), int flagmask1,
   void (*f2)(int argc, void **argv), int flagmask2,
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index 0850328..e70a0e5 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -11,7 +11,6 @@ LIBDPKG_PRIVATE {
# Error handling
push_error_context_jump;
push_error_context_func;
-   set_error_display;
print_fatal_error;
catch_fatal_error;
push_checkpoint;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 841f42173e5d0a97bbc9f184d781d2b2e6f9f974
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 17 05:47:34 2010 +0200

libdpkg: Add new push_error_context() function

This new function pushes a default error context.

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 81d61ac..8f2a038 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -174,6 +174,12 @@ push_error_context_jump(jmp_buf *jump, error_printer 
*printerror,
   onerr_abort = 0;
 }
 
+void
+push_error_context(void)
+{
+  push_error_context_func(catch_fatal_error, print_fatal_error, NULL);
+}
+
 static void
 print_cleanup_error(const char *emsg, const char *contextstring)
 {
diff --git a/lib/dpkg/ehandle.h b/lib/dpkg/ehandle.h
index 4483e20..f498df2 100644
--- a/lib/dpkg/ehandle.h
+++ b/lib/dpkg/ehandle.h
@@ -52,6 +52,7 @@ void push_error_context_jump(jmp_buf *jbufp, error_printer 
*printerror,
  const char *contextstring);
 void push_error_context_func(error_handler *func, error_printer *printerror,
  const char *contextstring);
+void push_error_context(void);
 void error_unwind(int flagset);
 
 void push_cleanup(void (*f1)(int argc, void **argv), int flagmask1,
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index e70a0e5..06b3a31 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -11,6 +11,7 @@ LIBDPKG_PRIVATE {
# Error handling
push_error_context_jump;
push_error_context_func;
+   push_error_context;
print_fatal_error;
catch_fatal_error;
push_checkpoint;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit b94d25d09f8bf55a68e17379581fb2ba71ae26aa
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 17 05:50:02 2010 +0200

Use push_error_context() instead of ad-hoc code

diff --git a/TODO b/TODO
index ad1a1bd..d31ef5d 100644
--- a/TODO
+++ b/TODO
@@ -31,7 +31,6 @@ TODO
  * Code cleanup / bug fixes:
- Get rid of static variables inside functions.
- Coalesce admindir / infodir / foodir generation.
-   - Get rid of setjmp (at least in the general case, keep for dpkg itself?)
- Coalesce hash and checksum functions.
- Split modstatdb_rw into mode and flags.
- Move fd function out of mlib.
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c
index a909e39..ef01bc6 100644
--- a/dpkg-deb/main.c
+++ b/dpkg-deb/main.c
@@ -183,7 +183,6 @@ static void setcompresstype(const struct cmdinfo *cip, 
const char *value) {
 }
 
 int main(int argc, const char *const *argv) {
-  jmp_buf ejbuf;
   dofunction *action;
 
   setlocale(LC_NUMERIC, POSIX);
@@ -191,7 +190,7 @@ int main(int argc, const char *const *argv) {
   bindtextdomain(PACKAGE, LOCALEDIR);
   textdomain(PACKAGE);
 
-  standard_startup(ejbuf);
+  standard_startup();
   myopt(argv, cmdinfos);
 
   if (!cipaction) badusage(_(need an action option));
diff --git a/dpkg-split/main.c b/dpkg-split/main.c
index 8f33ab2..9901263 100644
--- a/dpkg-split/main.c
+++ b/dpkg-split/main.c
@@ -148,7 +148,6 @@ static const struct cmdinfo cmdinfos[]= {
 };
 
 int main(int argc, const char *const *argv) {
-  jmp_buf ejbuf;
   int l;
   char *p;
   dofunction *action;
@@ -157,7 +156,7 @@ int main(int argc, const char *const *argv) {
   bindtextdomain(PACKAGE, LOCALEDIR);
   textdomain(PACKAGE);
 
-  standard_startup(ejbuf);
+  standard_startup();
   myopt(argv, cmdinfos);
 
   if (!cipaction) badusage(_(need an action option));
diff --git a/lib/dpkg/dpkg.h b/lib/dpkg/dpkg.h
index 7a06b53..7e62fc6 100644
--- a/lib/dpkg/dpkg.h
+++ b/lib/dpkg/dpkg.h
@@ -106,11 +106,8 @@ DPKG_BEGIN_DECLS
 
 /*** from startup.c ***/
 
-#define standard_startup(ejbuf) do {\
-  if (setjmp(*ejbuf)) { /* expect warning about possible clobbering of argv */\
-catch_fatal_error(); \
-  }\
-  push_error_handler(ejbuf, print_fatal_error, NULL); \
+#define standard_startup() do { \
+  push_error_context(); \
   umask(022); /* Make sure all our status databases are readable. */\
 } while (0)
 
diff --git a/lib/dpkg/test.h b/lib/dpkg/test.h
index 670001b..a1d0fa7 100644
--- a/lib/dpkg/test.h
+++ b/lib/dpkg/test.h
@@ -43,13 +43,7 @@ const char thisname[] = test;
 int
 main(int argc, char **argv)
 {
-   jmp_buf ejbuf;
-
-   /* Initialize environment. */
-   if (setjmp(ejbuf)) {
-   catch_fatal_error();
-   }
-   push_error_handler(ejbuf, print_fatal_error, NULL);
+   push_error_context();
 
test();
 
diff --git a/src/divertcmd.c b/src/divertcmd.c
index aeeb5e8..94fd085 100644
--- a/src/divertcmd.c
+++ b/src/divertcmd.c
@@ -704,7 +704,6 @@ static const struct cmdinfo cmdinfos[] = {
 int
 main(int argc, const char * const *argv)
 {
-   jmp_buf ejbuf;
const char *env_pkgname;
int (*actionfunction)(const char *const *argv);
int ret;
@@ -713,7 +712,7 @@ main(int argc, const char * const *argv)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
 
-   standard_startup(ejbuf);
+   standard_startup();
myopt(argv, cmdinfos);
 
env_pkgname = getenv(MAINTSCRIPTPKGENVVAR);
diff --git a/src/main.c b/src/main.c
index 8558d56..2972f14 100644
--- a/src/main.c
+++ b/src/main.c
@@ -564,7 +564,6 @@ void execbackend(const char *const *argv) {
 }
 
 void commandfd(const char *const *argv) {
-  jmp_buf ejbuf;
   struct varbuf linevb = VARBUF_INIT;
   const char * pipein;
   const char **newargs = NULL;
@@ -587,15 +586,12 @@ void commandfd(const char *const *argv) {
   if ((in= fdopen(infd, r)) == NULL)
 ohshite(_(couldn't open `%i' for stream), (int) infd);
 
-  if (setjmp(ejbuf)) { /* expect warning about possible clobbering of argv */
-catch_fatal_error();
-  }
-
   for (;;) {
 bool mode = false;
 int argc= 1;
 lno= 0;
-push_error_handler(ejbuf, print_fatal_error, NULL);
+
+push_error_context();
 
 do { c= getc(in); if (c == '\n') lno++; } while (c != EOF  isspace(c));
 if (c == EOF) break;
@@ -665,14 +661,13 @@ void commandfd(const char *const *argv) {
 
 
 int main(int argc, const char *const *argv) {
-  jmp_buf ejbuf;
   void (*actionfunction)(const char *const *argv);
 
   setlocale(LC_ALL, );
   bindtextdomain(PACKAGE, LOCALEDIR);
   textdomain(PACKAGE);
 
-  standard_startup(ejbuf);
+  standard_startup();
   loadcfgfile(DPKG, cmdinfos);
   myopt(argv, cmdinfos);
 
diff --git a/src/querycmd.c b/src/querycmd.c
index 78a0fb0..77cb381 100644
--- a/src/querycmd.c
+++ b/src/querycmd.c
@@ -672,7 +672,6 @@ static const struct cmdinfo cmdinfos[]= {
 };
 
 int main(int argc, const char *const *argv) {
-  

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 051423d23c9d5580aaecf0a7c41c854566d40d76
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 17 05:57:45 2010 +0200

dselect: Use a function instead of a jump error handler

diff --git a/dselect/main.cc b/dselect/main.cc
index 38df1c5..601f40c 100644
--- a/dselect/main.cc
+++ b/dselect/main.cc
@@ -498,18 +498,21 @@ urqresult urq_quit(void) {
   return urqr_quitmenu;
 }
 
-int main(int, const char *const *argv) {
-  jmp_buf ejbuf;
+static void
+dselect_catch_fatal_error()
+{
+  cursesoff();
+  catch_fatal_error();
+}
 
+int
+main(int, const char *const *argv)
+{
   setlocale(LC_ALL, );
   bindtextdomain(DSELECT, LOCALEDIR);
   textdomain(DSELECT);
 
-  if (setjmp(ejbuf)) { /* expect warning about possible clobbering of argv */
-cursesoff();
-catch_fatal_error();
-  }
-  push_error_handler(ejbuf, print_fatal_error, 0);
+  push_error_context_func(dselect_catch_fatal_error, print_fatal_error, 0);
 
   loadcfgfile(DSELECT, cmdinfos);
   myopt(argv,cmdinfos);

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 2a92bb81186b6098ec2a6b77242690d11402faad
Author: Guillem Jover guil...@debian.org
Date:   Sat Oct 23 05:16:46 2010 +0200

libdpkg: Rename error_unwind() to pop_error_context()

diff --git a/lib/dpkg/dpkg.h b/lib/dpkg/dpkg.h
index 7e62fc6..867a142 100644
--- a/lib/dpkg/dpkg.h
+++ b/lib/dpkg/dpkg.h
@@ -112,7 +112,7 @@ DPKG_BEGIN_DECLS
 } while (0)
 
 #define standard_shutdown() do { \
-  error_unwind(ehflag_normaltidy);\
+  pop_error_context(ehflag_normaltidy); \
 } while (0)
 
 /*** log.c ***/
diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 8f2a038..0b6255a 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -233,7 +233,12 @@ run_cleanups(struct error_context *econ, int flagsetin)
   preventrecurse--;
 }
 
-void error_unwind(int flagset) {
+/**
+ * Unwind the current error context by running its registered cleanups.
+ */
+void
+pop_error_context(int flagset)
+{
   struct error_context *tecp;
 
   tecp= econtext;
@@ -247,10 +252,10 @@ void error_unwind(int flagset) {
 }
 
 void push_checkpoint(int mask, int value) {
-  /* This will arrange that when error_unwind() is called,
+  /* This will arrange that when pop_error_context() is called,
* all previous cleanups will be executed with
*  flagset= (original_flagset  mask) | value
-   * where original_flagset is the argument to error_unwind
+   * where original_flagset is the argument to pop_error_context()
* (as modified by any checkpoint which was pushed later).
*/
   struct cleanup_entry *cep;
@@ -337,7 +342,7 @@ void ohshit(const char *fmt, ...) {
 void
 catch_fatal_error(void)
 {
-  error_unwind(ehflag_bombout);
+  pop_error_context(ehflag_bombout);
   exit(2);
 }
 
diff --git a/lib/dpkg/ehandle.h b/lib/dpkg/ehandle.h
index f498df2..7fd1689 100644
--- a/lib/dpkg/ehandle.h
+++ b/lib/dpkg/ehandle.h
@@ -53,7 +53,7 @@ void push_error_context_jump(jmp_buf *jbufp, error_printer 
*printerror,
 void push_error_context_func(error_handler *func, error_printer *printerror,
  const char *contextstring);
 void push_error_context(void);
-void error_unwind(int flagset);
+void pop_error_context(int flagset);
 
 void push_cleanup(void (*f1)(int argc, void **argv), int flagmask1,
   void (*f2)(int argc, void **argv), int flagmask2,
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index 06b3a31..ca94428 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -12,12 +12,12 @@ LIBDPKG_PRIVATE {
push_error_context_jump;
push_error_context_func;
push_error_context;
+   pop_error_context;
print_fatal_error;
catch_fatal_error;
push_checkpoint;
push_cleanup;
pop_cleanup;
-   error_unwind;
onerr_abort;# XXX variable, do not export
ohshitv;
ohshite;
diff --git a/lib/dpkg/test.h b/lib/dpkg/test.h
index a1d0fa7..664e4ae 100644
--- a/lib/dpkg/test.h
+++ b/lib/dpkg/test.h
@@ -47,8 +47,7 @@ main(int argc, char **argv)
 
test();
 
-   /* Shutdown. */
-   error_unwind(ehflag_normaltidy);
+   pop_error_context(ehflag_normaltidy);
 
return 0;
 }
diff --git a/src/archives.c b/src/archives.c
index ef51896..4691908 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -1247,7 +1247,7 @@ void archivefiles(const char *const *argv) {
   
   while ((thisarg = *argp++) != NULL) {
 if (setjmp(ejbuf)) {
-  error_unwind(ehflag_bombout);
+  pop_error_context(ehflag_bombout);
   if (abort_processing)
 break;
   continue;
@@ -1259,7 +1259,7 @@ void archivefiles(const char *const *argv) {
 m_output(stderr, _(standard error));
 onerr_abort--;
 
-error_unwind(ehflag_normaltidy);
+pop_error_context(ehflag_normaltidy);
   }
 
   switch (cipaction-arg) {
diff --git a/src/main.c b/src/main.c
index 2972f14..6694497 100644
--- a/src/main.c
+++ b/src/main.c
@@ -655,7 +655,7 @@ void commandfd(const char *const *argv) {
 actionfunction= (void (*)(const char* const*))cipaction-farg;
 actionfunction(newargs);
 
-error_unwind(ehflag_normaltidy);
+pop_error_context(ehflag_normaltidy);
   }
 }
 
diff --git a/src/packages.c b/src/packages.c
index cfdde66..10c8ed1 100644
--- a/src/packages.c
+++ b/src/packages.c
@@ -215,7 +215,8 @@ void process_queue(void) {
 if (setjmp(ejbuf)) {
   /* give up on it from the point of view of other packages, ie reset 
istobe */
   pkg-clientdata-istobe= itb_normal;
-  error_unwind(ehflag_bombout);
+
+  pop_error_context(ehflag_bombout);
   if (abort_processing)
 return;
   continue;
@@ -249,7 +250,7 @@ void process_queue(void) {
 m_output(stdout, _(standard output));
 m_output(stderr, _(standard error));
 
-error_unwind(ehflag_normaltidy);
+pop_error_context(ehflag_normaltidy);
   }
   assert(!queue.length);
 }
diff --git a/src/trigproc.c b/src/trigproc.c
index 

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit cc49169cdc596e33f036e9d9300e915a74e8baf0
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 24 02:53:27 2010 +0200

dpkg-trigger: Remove duplicate command name from error messages

diff --git a/src/trigcmd.c b/src/trigcmd.c
index d0ff3d1..a0645b8 100644
--- a/src/trigcmd.c
+++ b/src/trigcmd.c
@@ -206,12 +206,12 @@ main(int argc, const char *const *argv)
if (!bypackage) {
bypackage = getenv(MAINTSCRIPTPKGENVVAR);
if (!bypackage)
-   ohshit(_(dpkg-trigger must be called from a maintainer 
script
-   (or with a --by-package option)));
+   ohshit(_(must be called from a maintainer script
+ (or with a --by-package option)));
}
if (strcmp(bypackage, -) 
(badname = illegal_packagename(bypackage, NULL)))
-   ohshit(_(dpkg-trigger: illegal awaited package name `%.250s': 
%.250s),
+   ohshit(_(illegal awaited package name '%.250s': %.250s),
   bypackage, badname);
 
activate = argv[0];

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit a6066a13aa23b28036b692b570f280a70efcf971
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 24 02:55:55 2010 +0200

libdpkg: Rename illegal_triggername to trig_name_is_illegal

diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index 47fc811..5a61cca 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -492,7 +492,7 @@ f_trigpend(struct pkginfo *pend, struct pkginfoperfile 
*pifp,
   this context));
 
   while ((word = scan_word(value))) {
-emsg = illegal_triggername(word);
+emsg = trig_name_is_illegal(word);
 if (emsg)
   parse_error(ps, pend,
   _(illegal pending trigger name `%.255s': %s), word, emsg);
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index b7d5103..52503c4 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -223,7 +223,7 @@ LIBDPKG_PRIVATE {
modstatdb_shutdown;
 
# Triggers support
-   illegal_triggername;
+   trig_name_is_illegal;
trigdef_set_methods;
trigdef_update_start;
trigdef_update_printf;
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 2869c8c..50bd6b5 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -40,7 +40,7 @@
 #include dpkg/triglib.h
 
 const char *
-illegal_triggername(const char *p)
+trig_name_is_illegal(const char *p)
 {
int c;
 
@@ -678,7 +678,7 @@ parse_ci_call(const char *file, const char *cmd, 
trig_parse_cicb *cb,
 {
const char *emsg;
 
-   emsg = illegal_triggername(trig);
+   emsg = trig_name_is_illegal(trig);
if (emsg)
ohshit(_(triggers ci file `%.250s' contains illegal trigger 
 syntax in trigger name `%.250s': %.250s),
diff --git a/lib/dpkg/triglib.h b/lib/dpkg/triglib.h
index 0be5178..1cbeba9 100644
--- a/lib/dpkg/triglib.h
+++ b/lib/dpkg/triglib.h
@@ -36,7 +36,7 @@ DPKG_BEGIN_DECLS
  * we're actually doing real package management work.
  */
 
-const char *illegal_triggername(const char *p);
+const char *trig_name_is_illegal(const char *p);
 
 struct trigfileint {
struct pkginfo *pkg;
diff --git a/src/trigcmd.c b/src/trigcmd.c
index a0645b8..4dfdca6 100644
--- a/src/trigcmd.c
+++ b/src/trigcmd.c
@@ -215,7 +215,8 @@ main(int argc, const char *const *argv)
   bypackage, badname);
 
activate = argv[0];
-   if ((badname = illegal_triggername(activate)))
+   badname = trig_name_is_illegal(activate);
+   if (badname)
badusage(_(invalid trigger name `%.250s': %.250s),
 activate, badname);
 

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 9db4a822bb62b739e71c0a59c5ba46a27d121e32
Author: Guillem Jover guil...@debian.org
Date:   Sat Oct 23 05:37:33 2010 +0200

libdpkg: Namespace package database functions with pkg_db_ prefix

diff --git a/TODO b/TODO
index d31ef5d..5027dd3 100644
--- a/TODO
+++ b/TODO
@@ -46,7 +46,6 @@ TODO
- Replace raw write and read calls with safe variants (signals etc).
- Make deb build version a version instead of doing checks over a string.
- Use enums for currently hardcoded literals (tdus, dependtry, etc).
-   - Namespace pkg_db funcs.
- Do not use nfmalloc (and friends) for non in-core db memory.
- Call nffreeall on exit (need to detangle nfmalloc from non-db first).
- Add a size parameter to the buffer api to avoid some useless
diff --git a/dselect/main.cc b/dselect/main.cc
index 601f40c..73ede2b 100644
--- a/dselect/main.cc
+++ b/dselect/main.cc
@@ -365,7 +365,7 @@ urqresult urq_list(void) {
   delete l;
 
   modstatdb_shutdown();
-  resetpackages();
+  pkg_db_reset();
   return urqr_normal;
 }
 
diff --git a/dselect/pkglist.cc b/dselect/pkglist.cc
index ea9b15a..ed25ac4 100644
--- a/dselect/pkglist.cc
+++ b/dselect/pkglist.cc
@@ -356,7 +356,7 @@ void packagelist::initialsetup() {
   if (debug)
 fprintf(debug,packagelist[%p]::initialsetup()\n,this);
 
-  int allpackages= countpackages();
+  int allpackages = pkg_db_count();
   datatable= new struct perpackagestate[allpackages];
 
   nallocated= allpackages+150; // will realloc if necessary, so 150 not 
critical
@@ -386,8 +386,9 @@ packagelist::packagelist(keybindings *kb) : baselist(kb) {
   struct pkginfo *pkg;
   
   nitems = 0;
-  iter = iterpkgstart();
-  while ((pkg = iterpkgnext(iter))) {
+
+  iter = pkg_db_iter_new();
+  while ((pkg = pkg_db_iter_next(iter))) {
 struct perpackagestate *state= datatable[nitems];
 state-pkg= pkg;
 if (pkg-status == pkginfo::stat_notinstalled 
@@ -415,7 +416,7 @@ packagelist::packagelist(keybindings *kb) : baselist(kb) {
 table[nitems]= state;
 nitems++;
   }
-  iterpkgend(iter);
+  pkg_db_iter_free(iter);
 
   if (!nitems)
 ohshit(_(There are no packages.));
diff --git a/lib/dpkg/database.c b/lib/dpkg/database.c
index c5282cc..866c8b0 100644
--- a/lib/dpkg/database.c
+++ b/lib/dpkg/database.c
@@ -120,7 +120,9 @@ informative(struct pkginfo *pkg, struct pkginfoperfile 
*info)
   return false;
 }
 
-struct pkginfo *findpackage(const char *inname) {
+struct pkginfo *
+pkg_db_find(const char *inname)
+{
   struct pkginfo **pointerp, *newpkg;
   char *name = m_strdup(inname), *p;
 
@@ -143,7 +145,9 @@ struct pkginfo *findpackage(const char *inname) {
   return newpkg;
 }
 
-int countpackages(void) {
+int
+pkg_db_count(void)
+{
   return npackages;
 }
 
@@ -152,7 +156,9 @@ struct pkgiterator {
   int nbinn;
 };
 
-struct pkgiterator *iterpkgstart(void) {
+struct pkgiterator *
+pkg_db_iter_new(void)
+{
   struct pkgiterator *i;
   i= m_malloc(sizeof(struct pkgiterator));
   i-pigp= NULL;
@@ -160,7 +166,9 @@ struct pkgiterator *iterpkgstart(void) {
   return i;
 }
 
-struct pkginfo *iterpkgnext(struct pkgiterator *i) {
+struct pkginfo *
+pkg_db_iter_next(struct pkgiterator *i)
+{
   struct pkginfo *r;
   while (!i-pigp) {
 if (i-nbinn = BINS) return NULL;
@@ -169,11 +177,15 @@ struct pkginfo *iterpkgnext(struct pkgiterator *i) {
   r= i-pigp; i-pigp= r-next; return r;
 }
 
-void iterpkgend(struct pkgiterator *i) {
+void
+pkg_db_iter_free(struct pkgiterator *i)
+{
   free(i);
 }
 
-void resetpackages(void) {
+void
+pkg_db_reset(void)
+{
   int i;
   nffreeall();
   npackages= 0;
diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index 89f6da1..9cc5533 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -213,17 +213,18 @@ const char *pkgadminfile(struct pkginfo *pkg, const char 
*whichfile);
 
 /*** from database.c ***/
 
-struct pkginfo *findpackage(const char *name);
 void blankpackage(struct pkginfo *pp);
 void blankpackageperfile(struct pkginfoperfile *pifp);
 void blankversion(struct versionrevision*);
 bool informative(struct pkginfo *pkg, struct pkginfoperfile *info);
-int countpackages(void);
-void resetpackages(void);
 
-struct pkgiterator *iterpkgstart(void);
-struct pkginfo *iterpkgnext(struct pkgiterator*);
-void iterpkgend(struct pkgiterator*);
+struct pkginfo *pkg_db_find(const char *name);
+int pkg_db_count(void);
+void pkg_db_reset(void);
+
+struct pkgiterator *pkg_db_iter_new(void);
+struct pkginfo *pkg_db_iter_next(struct pkgiterator *iter);
+void pkg_db_iter_free(struct pkgiterator *iter);
 
 void hashreport(FILE*);
 
diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c
index 448737c..0d3a587 100644
--- a/lib/dpkg/dump.c
+++ b/lib/dpkg/dump.c
@@ -382,8 +382,8 @@ writedb(const char *filename, bool available, bool mustsync)
   if (setvbuf(file,writebuf,_IOFBF,sizeof(writebuf)))
 ohshite(_(unable to set buffering on %s database file), which);
 
-  it= iterpkgstart();
-  while ((pigp= 

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit f74dfc666ea193a85de5e5f26b079506b289843f
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 24 03:13:58 2010 +0200

libdpkg: Rename illegal_packagename to pkg_name_is_illegal

diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index 9cc5533..decd5e5 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -241,7 +241,7 @@ enum parsedbflags {
   pdb_lax_parser=040,
 };
 
-const char *illegal_packagename(const char *p, const char **ep);
+const char *pkg_name_is_illegal(const char *p, const char **ep);
 int parsedb(const char *filename, enum parsedbflags, struct pkginfo **donep,
 FILE *warnto, int *warncount);
 void copy_dependency_links(struct pkginfo *pkg,
diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index 5a61cca..c6bf15d 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -71,7 +71,9 @@ f_name(struct pkginfo *pigp, struct pkginfoperfile *pifp,
const char *value, const struct fieldinfo *fip)
 {
   const char *e;
-  if ((e= illegal_packagename(value,NULL)) != NULL)
+
+  e = pkg_name_is_illegal(value, NULL);
+  if (e != NULL)
 parse_error(ps, pigp, _(invalid package name (%.250s)), e);
   /* We use the new name, as pkg_db_find() may have done a tolower for us. */
   pigp-name = pkg_db_find(value)-name;
@@ -322,7 +324,7 @@ void f_dependency(struct pkginfo *pigp, struct 
pkginfoperfile *pifp,
 parse_error(ps, pigp,
 _(`%s' field, missing package name, or garbage where 
   package name expected), fip-name);
-  emsg = illegal_packagename(depname.buf, NULL);
+  emsg = pkg_name_is_illegal(depname.buf, NULL);
   if (emsg)
 parse_error(ps, pigp,
 _(`%s' field, invalid package name `%.255s': %s),
@@ -517,7 +519,7 @@ f_trigaw(struct pkginfo *aw, struct pkginfoperfile *pifp,
   this context));
 
   while ((word = scan_word(value))) {
-emsg = illegal_packagename(word, NULL);
+emsg = pkg_name_is_illegal(word, NULL);
 if (emsg)
   parse_error(ps, aw,
   _(illegal package name in awaited trigger `%.255s': %s),
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index 52503c4..5a5329e 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -165,7 +165,7 @@ LIBDPKG_PRIVATE {
# Package struct handling
blankpackage;
blankpackageperfile;
-   illegal_packagename;
+   pkg_name_is_illegal;
informative;
copy_dependency_links;
pkg_sorter_by_name;
diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c
index b401ee4..ded2f5e 100644
--- a/lib/dpkg/parsehelp.c
+++ b/lib/dpkg/parsehelp.c
@@ -127,7 +127,9 @@ const struct namevalue wantinfos[] = {
   { .name = NULL }
 };
 
-const char *illegal_packagename(const char *p, const char **ep) {
+const char *
+pkg_name_is_illegal(const char *p, const char **ep)
+{
   static const char alsoallowed[]= -+._; /* _ is deprecated */
   static char buf[150];
   int c;
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 50bd6b5..d45d146 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -272,7 +272,7 @@ trig_classify_byname(const char *name)
return tki_file;
}
 
-   if (!illegal_packagename(name, NULL)  !strchr(name, '_'))
+   if (!pkg_name_is_illegal(name, NULL)  !strchr(name, '_'))
return tki_explicit;
 
 invalid:
@@ -386,7 +386,8 @@ trk_explicit_activate_awaiter(struct pkginfo *aw)
trk_explicit_fn.buf);
 
while (trk_explicit_fgets(buf, sizeof(buf)) = 0) {
-   if ((emsg = illegal_packagename(buf, NULL)))
+   emsg = pkg_name_is_illegal(buf, NULL);
+   if (emsg)
ohshit(_(trigger interest file `%.250s' syntax error; 
 illegal package name `%.250s': %.250s),
   trk_explicit_fn.buf, buf, emsg);
@@ -580,7 +581,9 @@ trig_file_interests_ensure(void)
ohshit(_(syntax error in file triggers file `%.250s'),
   triggersfilefile);
*space++ = '\0';
-   if ((emsg = illegal_packagename(space, NULL)))
+
+   emsg = pkg_name_is_illegal(space, NULL);
+   if (emsg)
ohshit(_(file triggers record mentions illegal 
 package name `%.250s' (for interest in file 
 `%.250s'): %.250s), space, linebuf, emsg);
diff --git a/src/main.c b/src/main.c
index cf4029d..18581fb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -281,7 +281,7 @@ static void ignoredepends(const struct cmdinfo *cip, const 
char *value) {
   }
   p= copy;
   while (*p) {
-pnerr = illegal_packagename(p, NULL);
+pnerr = pkg_name_is_illegal(p, NULL);
 if (pnerr) ohshite(_(--ignore-depends requires a legal package 

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit a3dd7c610183c6f5515d69178b8a848ea1d82b87
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 24 03:16:00 2010 +0200

libdpkg: Rename informative to pkg_is_informative

diff --git a/dselect/pkgdepcon.cc b/dselect/pkgdepcon.cc
index ca69ec7..267dfaa 100644
--- a/dselect/pkgdepcon.cc
+++ b/dselect/pkgdepcon.cc
@@ -38,7 +38,7 @@ packagelist::useavailable(pkginfo *pkg)
 {
   if (pkg-clientdata 
   pkg-clientdata-selected == pkginfo::want_install 
-  informative(pkg,pkg-available) 
+  pkg_is_informative(pkg, pkg-available) 
   (!(pkg-status == pkginfo::stat_installed ||
  pkg-status == pkginfo::stat_triggersawaited ||
  pkg-status == pkginfo::stat_triggerspending) ||
@@ -133,10 +133,12 @@ static int dep_update_best_to_change_stop(perpackagestate 
* best, pkginfo *tryt
   if (!best) goto yes;
 
   // If only one of the packages is available, use that one
-  if (!informative(trythis,trythis-available) 
-  informative(best-pkg,best-pkg-available)) return 0;
-  if (informative(trythis,trythis-available) 
-  !informative(best-pkg,best-pkg-available)) goto yes;
+  if (!pkg_is_informative(trythis, trythis-available) 
+  pkg_is_informative(best-pkg, best-pkg-available))
+return 0;
+  if (pkg_is_informative(trythis, trythis-available) 
+  !pkg_is_informative(best-pkg, best-pkg-available))
+goto yes;
   
   // Select the package with the lowest priority (ie, the one of whom
   // we were least sure we wanted it deselected).
diff --git a/lib/dpkg/database.c b/lib/dpkg/database.c
index 866c8b0..188132a 100644
--- a/lib/dpkg/database.c
+++ b/lib/dpkg/database.c
@@ -93,7 +93,7 @@ void blankpackageperfile(struct pkginfoperfile *pifp) {
 static int nes(const char *s) { return s  *s; }
 
 bool
-informative(struct pkginfo *pkg, struct pkginfoperfile *info)
+pkg_is_informative(struct pkginfo *pkg, struct pkginfoperfile *info)
 {
   /* Used by dselect and dpkg query options as an aid to decide
* whether to display things, and by dump to decide whether to write them
diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index decd5e5..ee0878b 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -216,7 +216,7 @@ const char *pkgadminfile(struct pkginfo *pkg, const char 
*whichfile);
 void blankpackage(struct pkginfo *pp);
 void blankpackageperfile(struct pkginfoperfile *pifp);
 void blankversion(struct versionrevision*);
-bool informative(struct pkginfo *pkg, struct pkginfoperfile *info);
+bool pkg_is_informative(struct pkginfo *pkg, struct pkginfoperfile *info);
 
 struct pkginfo *pkg_db_find(const char *name);
 int pkg_db_count(void);
diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c
index 0d3a587..7980dc1 100644
--- a/lib/dpkg/dump.c
+++ b/lib/dpkg/dump.c
@@ -386,7 +386,8 @@ writedb(const char *filename, bool available, bool mustsync)
   while ((pigp = pkg_db_iter_next(it)) != NULL) {
 pifp= available ? pigp-available : pigp-installed;
 /* Don't dump records which have no useful content. */
-if (!informative(pigp,pifp)) continue;
+if (!pkg_is_informative(pigp, pifp))
+  continue;
 varbufrecord(vb,pigp,pifp);
 varbufaddc(vb,'\n'); varbufaddc(vb,0);
 if (fputs(vb.buf,file)  0)
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index 5a5329e..af1e299 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -166,7 +166,7 @@ LIBDPKG_PRIVATE {
blankpackage;
blankpackageperfile;
pkg_name_is_illegal;
-   informative;
+   pkg_is_informative;
copy_dependency_links;
pkg_sorter_by_name;
pkg_summary;
diff --git a/lib/dpkg/test/t-pkginfo.c b/lib/dpkg/test/t-pkginfo.c
index dbb3098..3fab78e 100644
--- a/lib/dpkg/test/t-pkginfo.c
+++ b/lib/dpkg/test/t-pkginfo.c
@@ -30,14 +30,14 @@ test_pkginfo_informative(void)
struct pkginfo pkg;
 
blankpackage(pkg);
-   test_fail(informative(pkg, pkg.installed));
+   test_fail(pkg_is_informative(pkg, pkg.installed));
 
pkg.want = want_purge;
-   test_pass(informative(pkg, pkg.installed));
+   test_pass(pkg_is_informative(pkg, pkg.installed));
 
blankpackage(pkg);
pkg.installed.description = test description;
-   test_pass(informative(pkg, pkg.installed));
+   test_pass(pkg_is_informative(pkg, pkg.installed));
 
/* FIXME: Complete. */
 }
diff --git a/src/querycmd.c b/src/querycmd.c
index 8a5a71b..8bd9077 100644
--- a/src/querycmd.c
+++ b/src/querycmd.c
@@ -332,7 +332,7 @@ enqperpackage(const char *const *argv)
   !(pkg-section  *pkg-section) 
   !pkg-files 
   pkg-want == want_unknown 
-  !informative(pkg,pkg-installed)) {
+  !pkg_is_informative(pkg, pkg-installed)) {
 fprintf(stderr,_(Package `%s' is not installed and no info is 
available.\n),pkg-name);
 failures++;
   } else {
@@ -341,7 +341,7 @@ enqperpackage(const char 

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 8c234c5698645a759f6153fd1be4d7b90059bb88
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 24 03:28:55 2010 +0200

libdpkg: Move namevalue declarations to its own header file

diff --git a/lib/dpkg/Makefile.am b/lib/dpkg/Makefile.am
index c366251..1604549 100644
--- a/lib/dpkg/Makefile.am
+++ b/lib/dpkg/Makefile.am
@@ -74,6 +74,7 @@ pkginclude_HEADERS = \
glob.h \
macros.h \
myopt.h \
+   namevalue.h \
parsedump.h \
path.h \
pkg.h \
diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index cd4bc53..d54d93b 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -251,10 +251,7 @@ void copy_dependency_links(struct pkginfo *pkg,
 
 /*** from parsehelp.c ***/
 
-struct namevalue {
-  const char *name;
-  int value, length;
-};
+#include dpkg/namevalue.h
 
 extern const struct namevalue booleaninfos[];
 extern const struct namevalue priorityinfos[];
diff --git a/lib/dpkg/test/t-macros.c b/lib/dpkg/namevalue.h
similarity index 66%
copy from lib/dpkg/test/t-macros.c
copy to lib/dpkg/namevalue.h
index 1616a9e..a512a4e 100644
--- a/lib/dpkg/test/t-macros.c
+++ b/lib/dpkg/namevalue.h
@@ -1,7 +1,8 @@
 /*
  * libdpkg - Debian packaging suite library routines
- * t-macros.c - test C support macros
+ * namevalue.h - name value structure handling
  *
+ * Copyright © 1994,1995 Ian Jackson i...@chiark.greenend.org.uk
  * Copyright © 2009 Guillem Jover guil...@debian.org
  *
  * This is free software; you can redistribute it and/or modify
@@ -18,23 +19,22 @@
  * along with this program.  If not, see http://www.gnu.org/licenses/.
  */
 
-#include config.h
-#include compat.h
+#ifndef LIBDPKG_NAMEVALUE_H
+#define LIBDPKG_NAMEVALUE_H
 
-#include dpkg/test.h
 #include dpkg/macros.h
 
-static void
-test(void)
-{
-   test_pass(min(10, 30) == 10);
-   test_pass(min(30, 10) == 10);
-   test_pass(min(0, 10) == 0);
-   test_pass(min(-10, 0) == -10);
+DPKG_BEGIN_DECLS
 
-   test_pass(max(10, 30) == 30);
-   test_pass(max(30, 10) == 30);
-   test_pass(max(0, 10) == 10);
-   test_pass(max(-10, 0) == 0);
-}
+struct namevalue {
+   const char *name;
+   int value;
+   int length;
+};
 
+#define NAMEVALUE_DEF(n, v) \
+   [v] = { .name = n, .value = v, .length = sizeof(n) - 1 }
+
+DPKG_END_DECLS
+
+#endif /* LIBDPKG_NAMEVALUE_H */
diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c
index ded2f5e..853a25d 100644
--- a/lib/dpkg/parsehelp.c
+++ b/lib/dpkg/parsehelp.c
@@ -80,9 +80,6 @@ parse_warn(struct parsedb_state *ps,
   va_end(args);
 }
 
-#define NAMEVALUE_DEF(n, v) \
-   [v] = { .name = n, .value = v, .length = sizeof(n) - 1 }
-
 const struct namevalue booleaninfos[] = {
   NAMEVALUE_DEF(no,  false),
   NAMEVALUE_DEF(yes, true),

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit e66836854ef51b5b5ce0b95a61adbf13f8dcd660
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 24 03:49:22 2010 +0200

libdpkg: Add new namevalue_find_by_name function

diff --git a/lib/dpkg/Makefile.am b/lib/dpkg/Makefile.am
index 1604549..9f20125 100644
--- a/lib/dpkg/Makefile.am
+++ b/lib/dpkg/Makefile.am
@@ -41,6 +41,7 @@ libdpkg_a_SOURCES = \
md5.c md5.h \
mlib.c \
myopt.c \
+   namevalue.c \
nfmalloc.c \
parse.c \
parsehelp.c \
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index 319d895..8bffb37 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -77,6 +77,9 @@ LIBDPKG_PRIVATE {
glob_list_prepend;
glob_list_free;
 
+   # Data structure functions
+   namevalue_find_by_name;
+
# Buffer I/O functions
buffer_init;
buffer_read;
diff --git a/lib/dpkg/dir.h b/lib/dpkg/namevalue.c
similarity index 66%
copy from lib/dpkg/dir.h
copy to lib/dpkg/namevalue.c
index 560abf8..f425c4c 100644
--- a/lib/dpkg/dir.h
+++ b/lib/dpkg/namevalue.c
@@ -1,6 +1,6 @@
 /*
  * libdpkg - Debian packaging suite library routines
- * dir.h - directory handling routines
+ * namevalue.c - name value structure handling
  *
  * Copyright © 2010 Guillem Jover guil...@debian.org
  *
@@ -18,20 +18,21 @@
  * along with this program.  If not, see http://www.gnu.org/licenses/.
  */
 
-#ifndef LIBDPKG_DIR_H
-#define LIBDPKG_DIR_H
+#include config.h
+#include compat.h
 
-#include dpkg/macros.h
+#include stddef.h
 
-#include dirent.h
+#include dpkg/namevalue.h
 
-DPKG_BEGIN_DECLS
+const struct namevalue *
+namevalue_find_by_name(const struct namevalue *head, const char *str)
+{
+   const struct namevalue *nv;
 
-void dir_sync(DIR *dir, const char *path);
-void dir_sync_path(const char *path);
-void dir_sync_path_parent(const char *path);
-void dir_sync_contents(const char *path);
+   for (nv = head; nv-name; nv++)
+   if (strncasecmp(str, nv-name, nv-length) == 0)
+   return nv;
 
-DPKG_END_DECLS
-
-#endif /* LIBDPKG_DIR_H */
+   return NULL;
+}
diff --git a/lib/dpkg/namevalue.h b/lib/dpkg/namevalue.h
index a512a4e..c896e3e 100644
--- a/lib/dpkg/namevalue.h
+++ b/lib/dpkg/namevalue.h
@@ -3,7 +3,7 @@
  * namevalue.h - name value structure handling
  *
  * Copyright © 1994,1995 Ian Jackson i...@chiark.greenend.org.uk
- * Copyright © 2009 Guillem Jover guil...@debian.org
+ * Copyright © 2009-2010 Guillem Jover guil...@debian.org
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -35,6 +35,9 @@ struct namevalue {
 #define NAMEVALUE_DEF(n, v) \
[v] = { .name = n, .value = v, .length = sizeof(n) - 1 }
 
+const struct namevalue *namevalue_find_by_name(const struct namevalue *head,
+   const char *str);
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_NAMEVALUE_H */

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 4afc4d0239d7f4e60bc68a79a07aef576c8a3ebe
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 24 03:55:58 2010 +0200

libdpkg: Reorded convert_string arguments

diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index fdc9f74..ed9e5a3 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -34,10 +34,9 @@
 #include dpkg/triglib.h
 
 static int
-convert_string(struct parsedb_state *ps, const char *what, int otherwise,
-   const struct pkginfo *pigp,
-   const char *startp, const struct namevalue *ivip,
-   const char **endpp)
+convert_string(struct parsedb_state *ps, const struct pkginfo *pigp,
+   const char *what, const struct namevalue *ivip,
+   const char *startp, const char **endpp, int otherwise)
 {
   const char *ep;
   const struct namevalue *nvip;
@@ -131,8 +130,8 @@ void f_boolean(struct pkginfo *pigp, struct pkginfoperfile 
*pifp,
   if (!*value)
 return;
 
-  boolean = convert_string(ps, _(yes/no in boolean field),
-   -1, pigp, value, booleaninfos, NULL);
+  boolean = convert_string(ps, pigp, _(yes/no in boolean field),
+   booleaninfos, value, NULL, -1);
   PKGPFIELD(pifp, fip-integer, bool) = boolean;
 }
 
@@ -147,8 +146,8 @@ void f_priority(struct pkginfo *pigp, struct pkginfoperfile 
*pifp,
 struct parsedb_state *ps,
 const char *value, const struct fieldinfo *fip) {
   if (!*value) return;
-  pigp-priority = convert_string(ps, _(word in `priority' field),
-  pri_other, pigp, value, priorityinfos, NULL);
+  pigp-priority = convert_string(ps, pigp, _(word in `priority' field),
+  priorityinfos, value, NULL, pri_other);
   if (pigp-priority == pri_other) pigp-otherpriority= nfstrsave(value);
 }
 
@@ -163,12 +162,15 @@ void f_status(struct pkginfo *pigp, struct pkginfoperfile 
*pifp,
   if (ps-flags  pdb_recordavailable)
 return;
   
-  pigp-want = convert_string(ps, _(first (want) word in `status' field),
-  -1, pigp, value, wantinfos, ep);
-  pigp-eflag = convert_string(ps, _(second (error) word in `status' field),
-   -1, pigp, ep, eflaginfos, ep);
-  pigp-status = convert_string(ps, _(third (status) word in `status' field),
--1, pigp, ep, statusinfos, NULL);
+  pigp-want = convert_string(ps, pigp,
+  _(first (want) word in `status' field),
+  wantinfos, value, ep, -1);
+  pigp-eflag = convert_string(ps, pigp,
+   _(second (error) word in `status' field),
+   eflaginfos, ep, ep, -1);
+  pigp-status = convert_string(ps, pigp,
+_(third (status) word in `status' field),
+statusinfos, ep, NULL, -1);
 }
 
 void f_version(struct pkginfo *pigp, struct pkginfoperfile *pifp,

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit fcd428d0b05f84ee1dbc4910a011d75bf6d02171
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 31 03:27:29 2010 +0100

build: Unify and fix AC_ARG_ENABLE usage

The current code was executing code in the action arguments, instead
of just setting boolean flags and processing them afterwards. This
poses several problems, it implies jugling code around in case the the
default changes, it might also duplicate code, and it might leave the
ACTION-IF-NOT-GIVEN argument empty which could turn into an empty
“then fi” shell block which is a syntax error on POSIX shell. Leaving
the ACTION-IF-GIVEN argument empty is fine as it's always used by
autoconf to set $enableval to the specific enable variable, and setting
that variable from $enableval is redundant and might be wrong depending
on the order they are set, which could empty it.

Reported-by: Michael Schmidt michael.schmidt.dan...@gmail.com

diff --git a/m4/dpkg-compiler.m4 b/m4/dpkg-compiler.m4
index e885af4..3a38601 100644
--- a/m4/dpkg-compiler.m4
+++ b/m4/dpkg-compiler.m4
@@ -8,7 +8,7 @@ AC_DEFUN([DPKG_COMPILER_WARNINGS],
 [AC_ARG_ENABLE(compiler-warnings,
AS_HELP_STRING([--disable-compiler-warnings],
   [Disable additional compiler warnings]),
-   [enable_compiler_warnings=$enableval],
+   [],
[enable_compiler_warnings=yes])
 
 WFLAGS=-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers \
@@ -35,9 +35,12 @@ AC_DEFUN([DPKG_COMPILER_OPTIMISATIONS],
 [AC_ARG_ENABLE(compiler-optimisations,
AS_HELP_STRING([--disable-compiler-optimisations],
   [Disable compiler optimisations]),
-[if test x$enable_compiler_optimisations = xno; then
-   [CFLAGS=$(echo $CFLAGS | sed -e s/ -O[[1-9]]*\b/ -O0/g)]
-fi])dnl
+   [],
+   [enable_compiler_optimisations=yes])
+
+  AS_IF([test x$enable_compiler_optimisations = xno], [
+CFLAGS=$(echo $CFLAGS | sed -e s/ -O[[1-9]]*\b/ -O0/g)
+  ])
 ])
 
 # DPKG_TRY_C99([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
diff --git a/m4/dpkg-funcs.m4 b/m4/dpkg-funcs.m4
index d374986..45c0e3c 100644
--- a/m4/dpkg-funcs.m4
+++ b/m4/dpkg-funcs.m4
@@ -76,12 +76,13 @@ AC_DEFUN([DPKG_MMAP],
   AC_ARG_ENABLE([mmap],
 AS_HELP_STRING([--enable-mmap],
[enable usage of unrealiable mmap if available]),
-[
-  AC_CHECK_FUNCS([mmap])
-  AC_DEFINE(USE_MMAP, 1, [Use unreliable mmap support])
-],
-[]
-  )
+[],
+[enable_mmap=no])
+
+  AS_IF([test x$enable_mmap = xyes], [
+AC_CHECK_FUNCS([mmap])
+AC_DEFINE(USE_MMAP, 1, [Use unreliable mmap support])
+  ])
 ])
 
 # DPKG_FUNC_ASYNC_SYNC
diff --git a/m4/dpkg-linker.m4 b/m4/dpkg-linker.m4
index bff4d22..2fdaae5 100644
--- a/m4/dpkg-linker.m4
+++ b/m4/dpkg-linker.m4
@@ -7,9 +7,12 @@ AC_DEFUN([DPKG_LINKER_OPTIMISATIONS],
 [AC_ARG_ENABLE(linker-optimisations,
AS_HELP_STRING([--disable-linker-optimisations],
   [Disable linker optimisations]),
-[if test x$enable_linker_optimisations = xno; then
-   [LDFLAGS=$(echo $LDFLAGS | sed -e s/ -Wl,-O[[0-9]]*\b//g)]
-else
-   [LDFLAGS=$LDFLAGS -Wl,-O1]
-fi], [LDFLAGS=$LDFLAGS -Wl,-O1])dnl
+[],
+[enable_linker_optimisations=yes])
+
+  AS_IF([test x$enable_linker_optimisations = xno], [
+LDFLAGS=$(echo $LDFLAGS | sed -e s/ -Wl,-O[[0-9]]*\b//g)
+  ], [
+LDFLAGS=$LDFLAGS -Wl,-O1
+  ])
 ])

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 631338a5e54d5ecd861f26440deef37a891d1f30
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 31 03:40:04 2010 +0100

dselect: Remove shadowing variable definitions from pkgtop

The variables i and p are always initialized before each different loop
use, and they are actually used for the same purpose, just in different
places in the code.

diff --git a/dselect/pkgtop.cc b/dselect/pkgtop.cc
index 826877c..89b70bd 100644
--- a/dselect/pkgtop.cc
+++ b/dselect/pkgtop.cc
@@ -187,8 +187,6 @@ void packagelist::redraw1itemsel(int index, int selected) {
   wmove(listpad, screenline, priority_column - 1);
   waddch(listpad, ' ');
   if (pkg-priority == pkginfo::pri_other) {
-int i;
-const char *p;
 for (i=priority_width, p=pkg-otherpriority;
  i  0  *p;
  i--, p++)

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 7d4d1007c4f7ca8d40a5374f1305426b8c1e2e54
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 31 04:05:19 2010 +0100

libdpkg: Add PURE, MALLOC, NONNULL and REQRET compiler attributes

diff --git a/lib/dpkg/macros.h b/lib/dpkg/macros.h
index 76f2de7..a9f8612 100644
--- a/lib/dpkg/macros.h
+++ b/lib/dpkg/macros.h
@@ -30,17 +30,30 @@
 #if defined(__GNUC__)  (__GNUC__ = 3)
 #define DPKG_ATTR_UNUSED   __attribute__((unused))
 #define DPKG_ATTR_CONST__attribute__((const))
+#define DPKG_ATTR_PURE __attribute__((pure))
+#define DPKG_ATTR_MALLOC   __attribute__((malloc))
 #define DPKG_ATTR_NORET__attribute__((noreturn))
 #define DPKG_ATTR_PRINTF(n)__attribute__((format(printf, n, n + 1)))
 #define DPKG_ATTR_VPRINTF(n)   __attribute__((format(printf, n, 0)))
 #else
 #define DPKG_ATTR_UNUSED
 #define DPKG_ATTR_CONST
+#define DPKG_ATTR_PURE
+#define DPKG_ATTR_MALLOC
 #define DPKG_ATTR_NORET
 #define DPKG_ATTR_PRINTF(n)
 #define DPKG_ATTR_VPRINTF(n)
 #endif
 
+#if defined(__GNUC__)  \
+((__GNUC__ == 3  __GNUC_MINOR__  2) || __GNUC__ = 4)
+#define DPKG_ATTR_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
+#define DPKG_ATTR_REQRET   __attribute__((warn_unused_result))
+#else
+#define DPKG_ATTR_NONNULL(...)
+#define DPKG_ATTR_REQRET
+#endif
+
 #if defined(__GNUC__)  (__GNUC__ = 4)
 #define DPKG_ATTR_SENTINEL __attribute__((sentinel))
 #else

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 180e2e0e477145df4ccf8a71220773c0b093091e
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 31 04:09:59 2010 +0100

libdpkg: Add new warningv() function and make warning() use it

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 0b6255a..7fa5061 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -378,16 +378,22 @@ void ohshite(const char *fmt, ...) {
 }
 
 void
+warningv(const char *fmt, va_list args)
+{
+  char buf[1024];
+
+  vsnprintf(buf, sizeof(buf), fmt, args);
+  fprintf(stderr, _(%s: warning: %s\n), thisname, buf);
+}
+
+void
 warning(const char *fmt, ...)
 {
   va_list args;
-  char buf[1024];
 
   va_start(args, fmt);
-  vsnprintf(buf, sizeof(buf), fmt, args);
+  warningv(fmt, args);
   va_end(args);
-
-  fprintf(stderr, _(%s: warning: %s\n), thisname, buf);
 }
 
 void werr(const char *fn) {
diff --git a/lib/dpkg/ehandle.h b/lib/dpkg/ehandle.h
index 650a816..e5be8fc 100644
--- a/lib/dpkg/ehandle.h
+++ b/lib/dpkg/ehandle.h
@@ -59,6 +59,7 @@ void push_cleanup(void (*f1)(int argc, void **argv), int 
flagmask1,
 void push_checkpoint(int mask, int value);
 void pop_cleanup(int flagset);
 
+void warningv(const char *fmt, va_list args) DPKG_ATTR_VPRINTF(1);
 void warning(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
 
 void ohshitv(const char *fmt, va_list args)
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index 8bffb37..e5b6a5c 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -24,6 +24,7 @@ LIBDPKG_PRIVATE {
ohshit;
werr;   # XXX: remove
do_internerr;
+   warningv;
warning;
 
# Generic cleanup

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 141b8a46fae0a80313ca1968f55f45124ce70428
Author: Guillem Jover guil...@debian.org
Date:   Sun Oct 31 07:55:47 2010 +0100

libdpkg: Make str_escape_fmt buffer overflow safe

Make sure we do not write more to the destination buffer than it can
hold.

diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c
index 70a4f8c..a2ed77b 100644
--- a/lib/dpkg/parsehelp.c
+++ b/lib/dpkg/parsehelp.c
@@ -52,7 +52,7 @@ parse_error(struct parsedb_state *ps,
   char buf1[768], buf2[1000], *q;
 
   parse_error_msg(ps, pigp, _(parse error), buf1);
-  q = str_escape_fmt(buf2, buf1);
+  q = str_escape_fmt(buf2, buf1, sizeof(buf2));
   strcat(q,fmt);
 
   va_start(args, fmt);
@@ -67,7 +67,7 @@ parse_warn(struct parsedb_state *ps,
   char buf1[768], buf2[1000], *q;
 
   parse_error_msg(ps, pigp, _(warning), buf1);
-  q = str_escape_fmt(buf2, buf1);
+  q = str_escape_fmt(buf2, buf1, sizeof(buf2));
   strcat(q, fmt);
 
   va_start(args, fmt);
diff --git a/lib/dpkg/string.c b/lib/dpkg/string.c
index 2a3fb63..cf53f4f 100644
--- a/lib/dpkg/string.c
+++ b/lib/dpkg/string.c
@@ -27,14 +27,22 @@
 #include dpkg/string.h
 
 char *
-str_escape_fmt(char *dst, const char *src)
+str_escape_fmt(char *dst, const char *src, size_t n)
 {
char *d = dst;
const char *s = src;
 
+   if (n == 0)
+   return d;
+
while (*s) {
-   if (*s == '%')
+   if (*s == '%') {
+   if (n-- = 2)
+   break;
*d++ = '%';
+   }
+   if (n-- = 1)
+   break;
*d++ = *s++;
}
 
diff --git a/lib/dpkg/string.h b/lib/dpkg/string.h
index e158356..af879e8 100644
--- a/lib/dpkg/string.h
+++ b/lib/dpkg/string.h
@@ -25,7 +25,7 @@
 
 DPKG_BEGIN_DECLS
 
-char *str_escape_fmt(char *dest, const char *src);
+char *str_escape_fmt(char *dest, const char *src, size_t n);
 char *str_strip_quotes(char *str);
 
 DPKG_END_DECLS
diff --git a/lib/dpkg/test/t-string.c b/lib/dpkg/test/t-string.c
index eb651f1..689f387 100644
--- a/lib/dpkg/test/t-string.c
+++ b/lib/dpkg/test/t-string.c
@@ -32,24 +32,35 @@ test_str_escape_fmt(void)
char buf[1024], *q;
 
memset(buf, 'a', sizeof(buf));
-   q = str_escape_fmt(buf, );
+   q = str_escape_fmt(buf, , sizeof(buf));
strcpy(q,  end);
test_str(buf, ==,  end);
 
memset(buf, 'a', sizeof(buf));
-   q = str_escape_fmt(buf, %);
+   q = str_escape_fmt(buf, %, sizeof(buf));
strcpy(q,  end);
test_str(buf, ==, %% end);
 
memset(buf, 'a', sizeof(buf));
-   q = str_escape_fmt(buf, %%%);
+   q = str_escape_fmt(buf, %%%, sizeof(buf));
strcpy(q,  end);
test_str(buf, ==, %% end);
 
memset(buf, 'a', sizeof(buf));
-   q = str_escape_fmt(buf, %b%b%c%c%%);
+   q = str_escape_fmt(buf, %b%b%c%c%%, sizeof(buf));
strcpy(q,  end);
test_str(buf, ==, %%b%%b%%c%%c end);
+
+   /* Test delimited buffer. */
+   memset(buf, 'a', sizeof(buf));
+   q = str_escape_fmt(buf, %%%, 5);
+   strcpy(q,  end);
+   test_str(buf, ==,  end);
+
+   memset(buf, 'a', sizeof(buf));
+   q = str_escape_fmt(buf, %%%, 4);
+   strcpy(q,  end);
+   test_str(buf, ==, %% end);
 }
 
 static void

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 58a9ff2596fa722f230eee97bfa65c5d6218f479
Author: Guillem Jover guil...@debian.org
Date:   Mon Nov 1 20:30:53 2010 +0100

libdpkg: Rename TarChecksumOffset to checksum_offset

diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c
index 658324c..3d61502 100644
--- a/lib/dpkg/tarfn.c
+++ b/lib/dpkg/tarfn.c
@@ -59,7 +59,7 @@ struct tar_header {
char prefix[155];
 };
 
-static const size_t TarChecksumOffset = offsetof(struct tar_header, checksum);
+static const size_t checksum_offset = offsetof(struct tar_header, checksum);
 
 /**
  * Convert an ASCII octal string to a long.
@@ -210,12 +210,11 @@ DecodeTarHeader(char *block, struct tar_entry *d)
 
/* Treat checksum field as all blank. */
sum = ' ' * sizeof(h-checksum);
-   for (i = TarChecksumOffset; i  0; i--)
+   for (i = checksum_offset; i  0; i--)
sum += *s++;
/* Skip the real checksum field. */
s += sizeof(h-checksum);
-   for (i = (TARBLKSZ - TarChecksumOffset - sizeof(h-checksum));
-i  0; i--)
+   for (i = TARBLKSZ - checksum_offset - sizeof(h-checksum); i  0; i--)
sum += *s++;
 
return (sum == checksum);

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 3b717d8231e3251fe7b2ac09db44481a40092c58
Author: Guillem Jover guil...@debian.org
Date:   Mon Nov 1 20:28:34 2010 +0100

libdpkg: Rename and lower-case TarHeader members

diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c
index 92a8edb..4cd134b 100644
--- a/lib/dpkg/tarfn.c
+++ b/lib/dpkg/tarfn.c
@@ -40,26 +40,26 @@
 #define TAR_MAGIC_GNU   ustar\0
 
 struct TarHeader {
-   char Name[100];
-   char Mode[8];
-   char UserID[8];
-   char GroupID[8];
-   char Size[12];
-   char ModificationTime[12];
-   char Checksum[8];
-   char LinkFlag;
-   char LinkName[100];
-   char MagicNumber[8];
-   char UserName[32];
-   char GroupName[32];
-   char MajorDevice[8];
-   char MinorDevice[8];
+   char name[100];
+   char mode[8];
+   char uid[8];
+   char gid[8];
+   char size[12];
+   char mtime[12];
+   char checksum[8];
+   char linkflag;
+   char linkname[100];
+   char magic[8];
+   char user[32];
+   char group[32];
+   char devmajor[8];
+   char devminor[8];
 
/* Only valid on ustar. */
-   char Prefix[155];
+   char prefix[155];
 };
 
-static const size_t TarChecksumOffset = offsetof(struct TarHeader, Checksum);
+static const size_t TarChecksumOffset = offsetof(struct TarHeader, checksum);
 
 /**
  * Convert an ASCII octal string to a long.
@@ -106,8 +106,8 @@ get_prefix_name(struct TarHeader *h)
/* The size is not going to be bigger than that. */
s = m_malloc(257);
 
-   prefix = StoC(h-Prefix, sizeof(h-Prefix));
-   name = StoC(h-Name, sizeof(h-Name));
+   prefix = StoC(h-prefix, sizeof(h-prefix));
+   name = StoC(h-name, sizeof(h-name));
 
strcpy(s, prefix);
strcat(s, /);
@@ -125,7 +125,7 @@ get_unix_mode(struct TarHeader *h)
mode_t mode;
enum tar_filetype type;
 
-   type = (enum tar_filetype)h-LinkFlag;
+   type = (enum tar_filetype)h-linkflag;
 
switch (type) {
case tar_filetype_file0:
@@ -153,7 +153,7 @@ get_unix_mode(struct TarHeader *h)
break;
}
 
-   mode |= OtoL(h-Mode, sizeof(h-Mode));
+   mode |= OtoL(h-mode, sizeof(h-mode));
 
return mode;
 }
@@ -169,54 +169,52 @@ DecodeTarHeader(char *block, struct tar_entry *d)
long sum;
long checksum;
 
-   if (memcmp(h-MagicNumber, TAR_MAGIC_GNU, 6) == 0)
+   if (memcmp(h-magic, TAR_MAGIC_GNU, 6) == 0)
d-format = tar_format_gnu;
-   else if (memcmp(h-MagicNumber, TAR_MAGIC_USTAR, 6) == 0)
+   else if (memcmp(h-magic, TAR_MAGIC_USTAR, 6) == 0)
d-format = tar_format_ustar;
else
d-format = tar_format_old;
 
-   d-type = (enum tar_filetype)h-LinkFlag;
+   d-type = (enum tar_filetype)h-linkflag;
if (d-type == tar_filetype_file0)
d-type = tar_filetype_file;
 
/* Concatenate prefix and name to support ustar style long names. */
-   if (d-format == tar_format_ustar  h-Prefix[0] != '\0')
+   if (d-format == tar_format_ustar  h-prefix[0] != '\0')
d-name = get_prefix_name(h);
else
-   d-name = StoC(h-Name, sizeof(h-Name));
-   d-linkname = StoC(h-LinkName, sizeof(h-LinkName));
+   d-name = StoC(h-name, sizeof(h-name));
+   d-linkname = StoC(h-linkname, sizeof(h-linkname));
d-stat.mode = get_unix_mode(h);
-   d-size = (size_t)OtoL(h-Size, sizeof(h-Size));
-   d-stat.mtime = (time_t)OtoL(h-ModificationTime,
-sizeof(h-ModificationTime));
-   d-dev = ((OtoL(h-MajorDevice,
-   sizeof(h-MajorDevice))  0xff)  8) |
-(OtoL(h-MinorDevice, sizeof(h-MinorDevice))  0xff);
-
-   if (*h-UserName)
-   passwd = getpwnam(h-UserName);
+   d-size = (size_t)OtoL(h-size, sizeof(h-size));
+   d-stat.mtime = (time_t)OtoL(h-mtime, sizeof(h-mtime));
+   d-dev = ((OtoL(h-devmajor, sizeof(h-devmajor))  0xff)  8) |
+(OtoL(h-devminor, sizeof(h-devminor))  0xff);
+
+   if (*h-user)
+   passwd = getpwnam(h-user);
if (passwd)
d-stat.uid = passwd-pw_uid;
else
-   d-stat.uid = (uid_t)OtoL(h-UserID, sizeof(h-UserID));
+   d-stat.uid = (uid_t)OtoL(h-uid, sizeof(h-uid));
 
-   if (*h-GroupName)
-   group = getgrnam(h-GroupName);
+   if (*h-group)
+   group = getgrnam(h-group);
if (group)
d-stat.gid = group-gr_gid;
else
-   d-stat.gid = (gid_t)OtoL(h-GroupID, sizeof(h-GroupID));
+   d-stat.gid = (gid_t)OtoL(h-gid, sizeof(h-gid));
 
-   checksum = OtoL(h-Checksum, sizeof(h-Checksum));
+   checksum = OtoL(h-checksum, sizeof(h-checksum));
 
/* Treat checksum field as all blank. */
-   sum = 

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 835741f632e884ccd973d87e128c9846dd3e1d4c
Author: Guillem Jover guil...@debian.org
Date:   Mon Nov 1 20:50:58 2010 +0100

libdpkg: Move checksum_offset into tar_header_checksum()

diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c
index 3595528..55c0495 100644
--- a/lib/dpkg/tarfn.c
+++ b/lib/dpkg/tarfn.c
@@ -59,8 +59,6 @@ struct tar_header {
char prefix[155];
 };
 
-static const size_t checksum_offset = offsetof(struct tar_header, checksum);
-
 /**
  * Convert an ASCII octal string to a long.
  */
@@ -163,6 +161,7 @@ tar_header_checksum(struct tar_header *h)
 {
unsigned char *s = (unsigned char *)h;
unsigned int i;
+   const size_t checksum_offset = offsetof(struct tar_header, checksum);
long checksum;
long sum;
 

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit ebe392c61526b520bb7033fa49af8bd2faa39001
Author: Guillem Jover guil...@debian.org
Date:   Mon Nov 1 21:01:05 2010 +0100

libdpkg: Switch tar_header_decode() to take a struct tar_header

Instead of passing it a 'char *' argument to be casted later on to a
tar_header, just pass the latter directly.

diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c
index 55c0495..e7bccf7 100644
--- a/lib/dpkg/tarfn.c
+++ b/lib/dpkg/tarfn.c
@@ -183,9 +183,8 @@ tar_header_checksum(struct tar_header *h)
 }
 
 static int
-tar_header_decode(char *block, struct tar_entry *d)
+tar_header_decode(struct tar_header *h, struct tar_entry *d)
 {
-   struct tar_header *h = (struct tar_header *)block;
struct passwd *passwd = NULL;
struct group *group = NULL;
 
@@ -257,7 +256,7 @@ tar_extractor(void *ctx, const struct tar_operations *ops)
while ((status = ops-read(ctx, buffer, TARBLKSZ)) == TARBLKSZ) {
int name_len;
 
-   if (!tar_header_decode(buffer, h)) {
+   if (!tar_header_decode((struct tar_header *)buffer, h)) {
if (h.name[0] == '\0') {
/* End of tape. */
status = 0;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 326d7b43ffd8b6c8e1bf4dcd5c5495ee5129631f
Author: Guillem Jover guil...@debian.org
Date:   Mon Nov 1 21:41:46 2010 +0100

libdpkg: Refactor tar_gnu_long() out from tar_extractor()

diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c
index e7bccf7..564b4ee 100644
--- a/lib/dpkg/tarfn.c
+++ b/lib/dpkg/tarfn.c
@@ -228,6 +228,54 @@ tar_header_decode(struct tar_header *h, struct tar_entry 
*d)
return tar_header_checksum(h);
 }
 
+/**
+ * Decode a GNU longlink or longname from the tar archive.
+ *
+ * The way the GNU long{link,name} stuff works is like this:
+ *
+ * - The first header is a “dummy” header that contains the size of the
+ *   filename.
+ * - The next N headers contain the filename.
+ * - After the headers with the filename comes the “real” header with a
+ *   bogus name or link.
+ */
+static int
+tar_gnu_long(void *ctx, const struct tar_operations *ops, struct tar_entry *te,
+ char **longp)
+{
+   char buf[TARBLKSZ];
+   char *bp;
+   int status = 0;
+   int long_read;
+
+   free(*longp);
+   *longp = bp = m_malloc(te-size);
+
+   for (long_read = te-size; long_read  0; long_read -= TARBLKSZ) {
+   int copysize;
+
+   status = ops-read(ctx, buf, TARBLKSZ);
+   if (status == TARBLKSZ)
+   status = 0;
+   else {
+   /* Read partial header record? */
+   if (status  0) {
+   errno = 0;
+   status = -1;
+   }
+
+   /* If we didn't get TARBLKSZ bytes read, punt. */
+   break;
+   }
+
+   copysize = min(long_read, TARBLKSZ);
+   memcpy(bp, buf, copysize);
+   bp += copysize;
+   };
+
+   return status;
+}
+
 struct symlinkList {
struct symlinkList *next;
struct tar_entry h;
@@ -241,9 +289,6 @@ tar_extractor(void *ctx, const struct tar_operations *ops)
struct tar_entry h;
 
char *next_long_name, *next_long_link;
-   char *bp;
-   char **longp;
-   int long_read;
struct symlinkList *symlink_head, *symlink_tail, *symlink_node;
 
next_long_name = NULL;
@@ -326,55 +371,10 @@ tar_extractor(void *ctx, const struct tar_operations *ops)
status = ops-mknod(ctx, h);
break;
case tar_filetype_gnu_longlink:
+   status = tar_gnu_long(ctx, ops, h, next_long_link);
+   break;
case tar_filetype_gnu_longname:
-   /* Set longp to the location of the long filename or
-* link we're trying to deal with. */
-   longp = ((h.type == tar_filetype_gnu_longname) ?
-next_long_name :
-next_long_link);
-
-   if (*longp)
-   free(*longp);
-
-   *longp = m_malloc(h.size);
-   bp = *longp;
-
-   /* The way the GNU long{link,name} stuff works is like
-* this:
-*
-* The first header is a “dummy” header that contains
-*   the size of the filename.
-* The next N headers contain the filename.
-* After the headers with the filename comes the
-*   “real” header with a bogus name or link. */
-   for (long_read = h.size;
-long_read  0;
-long_read -= TARBLKSZ) {
-   int copysize;
-
-   status = ops-read(ctx, buffer, TARBLKSZ);
-   /* If we didn't get TARBLKSZ bytes read, punt. 
*/
-   if (status != TARBLKSZ) {
-/* Read partial header record? */
-   if (status  0) {
-   errno = 0;
-   status = -1;
-   }
-   break;
-   }
-   copysize = min(long_read, TARBLKSZ);
-   memcpy (bp, buffer, copysize);
-   bp += copysize;
-   };
-
-   /* In case of error do not overwrite status with 0. */
-   if (status  0)
-   break;
-
-   /* This decode function expects status to be 0 after
-* the case statement if we successfully decoded. I
-   

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit d3de9d66d6c4e735e7f9d2821549b9fc8e235d7d
Author: Guillem Jover guil...@debian.org
Date:   Tue Nov 2 08:06:52 2010 +0100

libdpkg: Slightly optimize order() checks

Reorganize code to first do checks on most commonly expected character.
First digits, then alphabetical, then the tilde, followed by any non NUL
character and finally the NUL character.

diff --git a/lib/dpkg/vercmp.c b/lib/dpkg/vercmp.c
index e111e11..779 100644
--- a/lib/dpkg/vercmp.c
+++ b/lib/dpkg/vercmp.c
@@ -43,16 +43,16 @@ epochsdiffer(const struct versionrevision *a,
 static int
 order(int c)
 {
-  if (c == '~')
-return -1;
-  else if (cisdigit(c))
-return 0;
-  else if (!c)
+  if (cisdigit(c))
 return 0;
   else if (cisalpha(c))
 return c;
-  else
+  else if (c == '~')
+return -1;
+  else if (c)
 return c + 256;
+  else
+return 0;
 }
 
 static int verrevcmp(const char *val, const char *ref) {

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit ac65897081f5f20fda853beed79c28559fe33aea
Author: Guillem Jover guil...@debian.org
Date:   Wed Nov 3 07:36:16 2010 +0100

libdpkg: Fix version_strict_check() to not allow '-' in revision

The revision cannot possibly have a '-' in it, so do not allow it. This
is innocuous in the current code as the parser makes sure the versions
are split on last '-', which implies the revision will never have one,
but it could happen that a manually constructed versionrevision could
contain one.

diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c
index 8f18367..662c011 100644
--- a/lib/dpkg/parsehelp.c
+++ b/lib/dpkg/parsehelp.c
@@ -271,7 +271,7 @@ version_strict_check(struct versionrevision *rversion)
   return _(invalid character in version number);
   }
   for (ptr = rversion-revision; *ptr; ptr++) {
-if (!cisdigit(*ptr)  !cisalpha(*ptr)  strchr(.-+~, *ptr) == NULL)
+if (!cisdigit(*ptr)  !cisalpha(*ptr)  strchr(.+~, *ptr) == NULL)
   return _(invalid character in revision number);
   }
 

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 04eaf265a0b219ed8689607196405fdff9a4a432
Author: Guillem Jover guil...@debian.org
Date:   Wed Nov 3 08:24:54 2010 +0100

libdpkg: Disallow versions starting with non-digits

Fail on strict parsing, and warn otherwise.

diff --git a/debian/changelog b/debian/changelog
index 791ce33..bd63a16 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,8 @@ dpkg (1.16.0) UNRELEASED; urgency=low
   * Fix realloc usage on compat scandir() implementation.
   * Use DPKG_MAINTSCRIPT_PACKAGE environment variable as package name on
 dpkg-divert when no --package or --local options have been specified.
+  * Do not allow versions starting with non-digit when doing strict parsing,
+warn otherwise.
 
   [ Raphaël Hertzog ]
   * Fail properly when debian/source/format is empty. Closes: #600854
diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c
index 662c011..d9132bd 100644
--- a/lib/dpkg/parsehelp.c
+++ b/lib/dpkg/parsehelp.c
@@ -266,7 +266,10 @@ version_strict_check(struct versionrevision *rversion)
   const char *ptr;
 
   /* XXX: Would be faster to use something like cisversion and cisrevision. */
-  for (ptr = rversion-version; *ptr; ptr++) {
+  ptr = rversion-version;
+  if (*ptr  !cisdigit(*ptr++))
+return _(version number does not start with digit);
+  for (; *ptr; ptr++) {
 if (!cisdigit(*ptr)  !cisalpha(*ptr)  strchr(.-+~:, *ptr) == NULL)
   return _(invalid character in version number);
   }
diff --git a/lib/dpkg/test/t-version.c b/lib/dpkg/test/t-version.c
index cae1c89..2e52781 100644
--- a/lib/dpkg/test/t-version.c
+++ b/lib/dpkg/test/t-version.c
@@ -128,8 +128,8 @@ test_version_parse(void)
test_pass(versioncompare(a, b) == 0);
 
/* Test valid characters in upstream version. */
-   b = version(0, azAZ09.-+~:, 0);
-   test_pass(parseversion(a, 0:azAZ09.-+~:-0) == NULL);
+   b = version(0, 09azAZ.-+~:, 0);
+   test_pass(parseversion(a, 0:09azAZ.-+~:-0) == NULL);
test_pass(versioncompare(a, b) == 0);
 
/* Test valid characters in revision. */
diff --git a/scripts/t/100_Dpkg_Version.t b/scripts/t/100_Dpkg_Version.t
index ae38364..de0cd22 100644
--- a/scripts/t/100_Dpkg_Version.t
+++ b/scripts/t/100_Dpkg_Version.t
@@ -127,28 +127,28 @@ __DATA__
 1 0:1 0
 0 0:0-0 0
 2:2.5 1:7.5 1
-1:foo foo 1
-0:foo foo 0
-foo foo 0
-foo- foo 0
-foo- foo-0 0
-foo fo 1
-foo- foo+ -1
-foo~1 foo -1
-foo~foo+Bar foo~foo+bar -1
-foo~~ foo~ -1
+1:0foo 0foo 1
+0:0foo 0foo 0
+0foo 0foo 0
+0foo- 0foo 0
+0foo- 0foo-0 0
+0foo 0fo 1
+0foo- 0foo+ -1
+0foo~1 0foo -1
+0foo~foo+Bar 0foo~foo+bar -1
+0foo~~ 0foo~ -1
 1~ 1 -1
 12345+that-really-is-some-ver-0 12345+that-really-is-some-ver-10 -1
-foo-0 foo-01 -1
-foo.bar foobar 1
-foo.bar foo1bar 1
-foo.bar foo0bar 1
-1foo-1 foo-1 -1
-foo2.0 foo2 1
-foo2.0.0 foo2.10.0 -1
-foo2.0 foo2.0.0 -1
-foo2.0 foo2.10 -1
-foo2.1 foo2.10 -1
+0foo-0 0foo-01 -1
+0foo.bar 0foobar 1
+0foo.bar 0foo1bar 1
+0foo.bar 0foo0bar 1
+0foo1bar-1 0foobar-1 -1
+0foo2.0 0foo2 1
+0foo2.0.0 0foo2.10.0 -1
+0foo2.0 0foo2.0.0 -1
+0foo2.0 0foo2.10 -1
+0foo2.1 0foo2.10 -1
 1.09 1.9 0
 1.0.8+nmu1 1.0.8 1
 3.11 3.10+nmu1 1

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 65969bfbccaf387c69df284215b6aefea7496f41
Author: Guillem Jover guil...@debian.org
Date:   Wed Nov 3 10:46:28 2010 +0100

Use new enum for dependency found status

Instead of cryptic literal integers use named enums.

diff --git a/src/packages.c b/src/packages.c
index 416fe70..ec48e54 100644
--- a/src/packages.c
+++ b/src/packages.c
@@ -295,6 +295,13 @@ void process_queue(void) {
  * and breaking.
  */
 
+enum found_status {
+  found_none = 0,
+  found_defer = 1,
+  found_forced = 2,
+  found_ok = 3,
+};
+
 /*
  * Return values:
  *   0: cannot be satisfied.
@@ -306,22 +313,20 @@ void process_queue(void) {
  *  (*interestingwarnings = 0 on exit? caller is to print oemsgs).
  *   3: satisfied now.
  */
-static int deppossi_ok_found(struct pkginfo *possdependee,
- struct pkginfo *requiredby,
- struct pkginfo *removing,
- struct pkginfo *providing,
- struct pkginfo **fixbytrig,
- bool *matched,
- struct deppossi *checkversion,
- int *interestingwarnings,
- struct varbuf *oemsgs) {
-  int thisf;
+static enum found_status
+deppossi_ok_found(struct pkginfo *possdependee, struct pkginfo *requiredby,
+  struct pkginfo *removing, struct pkginfo *providing,
+  struct pkginfo **fixbytrig,
+  bool *matched, struct deppossi *checkversion,
+  int *interestingwarnings, struct varbuf *oemsgs)
+{
+  enum found_status thisf;
 
   if (ignore_depends(possdependee)) {
 debug(dbg_depcondetail,  ignoring depended package so ok and found);
-return 3;
+return found_ok;
   }
-  thisf= 0;
+  thisf = found_none;
   if (possdependee == removing) {
 if (providing) {
   varbufprintf(oemsgs,
@@ -333,7 +338,8 @@ static int deppossi_ok_found(struct pkginfo *possdependee,
 }
 
 *matched = true;
-if (fc_depends) thisf= (dependtry = 4) ? 2 : 1;
+if (fc_depends)
+  thisf = (dependtry = 4) ? found_forced : found_defer;
 debug(dbg_depcondetail,  removing possdependee, returning %d,thisf);
 return thisf;
   }
@@ -349,7 +355,8 @@ static int deppossi_ok_found(struct pkginfo *possdependee,
   versiondescribe(possdependee-installed.version,
   vdew_nonambig));
   assert(checkversion-verrel != dvr_none);
-  if (fc_depends || fc_dependsversion) thisf= (dependtry = 3) ? 2 : 1;
+  if (fc_depends || fc_dependsversion)
+thisf = (dependtry = 3) ? found_forced : found_defer;
   debug(dbg_depcondetail,  bad version, returning %d,thisf);
   (*interestingwarnings)++;
   return thisf;
@@ -357,7 +364,7 @@ static int deppossi_ok_found(struct pkginfo *possdependee,
 if (possdependee-status == stat_installed ||
 possdependee-status == stat_triggerspending) {
   debug(dbg_depcondetail,  is installed, ok and found);
-  return 3;
+  return found_ok;
 }
 if (possdependee-status == stat_triggersawaited) {
   assert(possdependee-trigaw.head);
@@ -387,21 +394,23 @@ static int deppossi_ok_found(struct pkginfo *possdependee,
* but then fails to go on to update the awaiters.) */
   *fixbytrig = possdependee-trigaw.head-pend;
   debug(dbg_depcondetail,
-  triggers-awaited, fixbytrig `%s', returning 1,
+  triggers-awaited, fixbytrig '%s', defer,
 (*fixbytrig)-name);
-  return 1;
+  return found_defer;
 }
 if (possdependee-clientdata 
 possdependee-clientdata-istobe == itb_installnew) {
   debug(dbg_depcondetail,  unpacked/halfconfigured, defer);
-  return 1;
+  return found_defer;
 } else if (!removing  fc_configureany 
!skip_due_to_hold(possdependee) 
!(possdependee-status == stat_halfconfigured)) {
   fprintf(stderr,
   _(dpkg: also configuring `%s' (required by `%s')\n),
   possdependee-name, requiredby-name);
-  add_to_queue(possdependee); sincenothing=0; return 1;
+  add_to_queue(possdependee);
+  sincenothing = 0;
+  return found_defer;
 } else {
   if (providing) {
varbufprintf(oemsgs,
@@ -432,7 +441,7 @@ static int deppossi_ok_found(struct pkginfo *possdependee,
 
 unsuitable:
   if (fc_depends)
-thisf = (dependtry = 4) ? 2 : 1;
+thisf = (dependtry = 4) ? found_forced : found_defer;
 
   debug(dbg_depcondetail, returning %d, thisf);
   (*interestingwarnings)++;
@@ -525,7 +534,7 @@ dependencies_ok(struct pkginfo *pkg, struct pkginfo 
*removing,
   /* Valid values: 2 = ok, 1 = defer, 0 = halt. */
   enum dep_check ok;
   /* Valid values: 0 = none, 1 = defer, 2 = withwarning, 3 = ok. */
-  int found, thisf;
+  enum 

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 94e25a0380033654d2140ebf8149268b9bf446f8
Author: Guillem Jover guil...@debian.org
Date:   Thu Nov 4 06:39:28 2010 +0100

Refactor setpipe() into statusfd_add() to stop exposing status_pipes

diff --git a/lib/dpkg/dpkg.h b/lib/dpkg/dpkg.h
index 0c0fb44..71b60d1 100644
--- a/lib/dpkg/dpkg.h
+++ b/lib/dpkg/dpkg.h
@@ -121,13 +121,7 @@ DPKG_BEGIN_DECLS
 extern const char *log_file;
 void log_message(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
 
-/* FIXME: pipef and status_pipes should not be publicly exposed. */
-struct pipef {
-  int fd;
-  struct pipef *next;
-};
-extern struct pipef *status_pipes;
-
+void statusfd_add(int fd);
 void statusfd_send(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
 
 /*** cleanup.c ***/
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index 92ab7d5..3c1401d 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -139,7 +139,7 @@ LIBDPKG_PRIVATE {
log_message;
 
# Action logging
-   status_pipes;   # XXX variable, do not export
+   statusfd_add;
statusfd_send;
 
# Progress report support
diff --git a/lib/dpkg/log.c b/lib/dpkg/log.c
index 8efb7bc..a6a056c 100644
--- a/lib/dpkg/log.c
+++ b/lib/dpkg/log.c
@@ -70,7 +70,25 @@ log_message(const char *fmt, ...)
fprintf(logfd, %s %s\n, time_str, log.buf);
 }
 
-struct pipef *status_pipes = NULL;
+struct pipef {
+   struct pipef *next;
+   int fd;
+};
+
+static struct pipef *status_pipes = NULL;
+
+void
+statusfd_add(int fd)
+{
+   struct pipef *pipe_new;
+
+   setcloexec(fd, _(package status and progress file descriptor));
+
+   pipe_new = nfmalloc(sizeof(struct pipef));
+   pipe_new-fd = fd;
+   pipe_new-next = status_pipes;
+   status_pipes = pipe_new;
+}
 
 void
 statusfd_send(const char *fmt, ...)
diff --git a/src/main.c b/src/main.c
index 9df3e75..8b5f5fd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -306,8 +306,6 @@ static void setinteger(const struct cmdinfo *cip, const 
char *value) {
 }
 
 static void setpipe(const struct cmdinfo *cip, const char *value) {
-  struct pipef **pipe_head = cip-parg;
-  struct pipef *pipe_new;
   unsigned long v;
   char *ep;
 
@@ -315,12 +313,7 @@ static void setpipe(const struct cmdinfo *cip, const char 
*value) {
   if (value == ep || *ep || v  INT_MAX)
 badusage(_(invalid integer for --%s: `%.250s'),cip-olong,value);
 
-  setcloexec(v, _(package status and progress file descriptor));
-
-  pipe_new = nfmalloc(sizeof(struct pipef));
-  pipe_new-fd = v;
-  pipe_new-next = *pipe_head;
-  *pipe_head = pipe_new;
+  statusfd_add(v);
 }
 
 static bool
@@ -494,7 +487,7 @@ static const struct cmdinfo cmdinfos[]= {
   { post-invoke,   0,   1, NULL,  NULL,  set_invoke_hook, 0, 
post_invoke_hooks_tail },
   { path-exclude,  0,   1, NULL,  NULL,  setfilter, 0 },
   { path-include,  0,   1, NULL,  NULL,  setfilter, 1 },
-  { status-fd, 0,   1, NULL,  NULL,  setpipe, 0, 
status_pipes },
+  { status-fd, 0,   1, NULL,  NULL,  setpipe, 0 },
   { log,   0,   1, NULL,  log_file, NULL,0 },
   { pending,   'a', 0, f_pending,NULL,  NULL,1 },
   { recursive, 'R', 0, f_recursive,  NULL,  NULL,1 },

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 2819f4cc4639d59f7b6017f118e92dc5d9994299
Author: Guillem Jover guil...@debian.org
Date:   Fri Nov 5 06:56:06 2010 +0100

u-a: Refactor common code into new alternative_commit_operations_free

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index c76865f..38fd236 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -684,10 +684,21 @@ alternative_choices_free(struct alternative *a)
 }
 
 static void
+alternative_commit_operations_free(struct alternative *a)
+{
+   struct commit_operation *op;
+
+   while (a-commit_ops) {
+   op = a-commit_ops;
+   a-commit_ops = op-next;
+   commit_operation_free(op);
+   }
+}
+
+static void
 alternative_reset(struct alternative *alt)
 {
struct slave_link *slave;
-   struct commit_operation *commit_op;
 
free(alt-master_link);
alt-master_link = NULL;
@@ -697,11 +708,7 @@ alternative_reset(struct alternative *alt)
slave_link_free(slave);
}
alternative_choices_free(alt);
-   while (alt-commit_ops) {
-   commit_op = alt-commit_ops;
-   alt-commit_ops = commit_op-next;
-   commit_operation_free(commit_op);
-   }
+   alternative_commit_operations_free(alt);
alt-modified = false;
 }
 
@@ -1544,11 +1551,7 @@ alternative_commit(struct alternative *a)
}
}
 
-   while (a-commit_ops) {
-   op = a-commit_ops;
-   a-commit_ops = op-next;
-   commit_operation_free(op);
-   }
+   alternative_commit_operations_free(a);
 }
 
 static void

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit f7547316a11da5968a62094f789583428ce78ac3
Author: Guillem Jover guil...@debian.org
Date:   Sun Nov 7 08:58:11 2010 +0100

u-a: Change alternative_save() to take care of atomic file write

Instead of leaving the job of doing a proper atomic write, move the code
inside alternative_save() so that other possible callers will benefit.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 38fd236..f14979f 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1224,11 +1224,12 @@ alternative_load(struct alternative *a, bool 
must_not_die)
 }
 
 static void
-alternative_save(struct alternative *a, const char *file)
+alternative_save(struct alternative *a)
 {
struct altdb_context ctx;
struct slave_link *sl, *sl_prev;
struct fileset *fs;
+   char *filenew, *file;
 
/* Cleanup unused slaves before writing admin file. */
sl_prev = NULL;
@@ -1264,10 +1265,13 @@ alternative_save(struct alternative *a, const char 
*file)
alternative_sort_choices(a);
 
/* Write admin file. */
-   ctx.filename = xstrdup(file);
-   ctx.fh = fopen(file, w);
+   xasprintf(file, %s/%s, admdir, a-master_name);
+   xasprintf(filenew, %s DPKG_TMP_EXT, file);
+
+   ctx.filename = filenew;
+   ctx.fh = fopen(ctx.filename, w);
if (ctx.fh == NULL)
-   error(_(cannot write %s: %s), file, strerror(errno));
+   error(_(cannot write %s: %s), ctx.filename, strerror(errno));
 
altdb_print_line(ctx, alternative_status_string(a-status));
altdb_print_line(ctx, a-master_link);
@@ -1299,6 +1303,12 @@ alternative_save(struct alternative *a, const char *file)
/* Close database file */
if (fclose(ctx.fh))
error(_(unable to close %s: %s), ctx.filename, 
strerror(errno));
+
+   /* Put in place atomically. */
+   checked_mv(filenew, file);
+
+   free(filenew);
+   free(file);
 }
 
 static struct fileset *
@@ -2438,17 +2448,8 @@ main(int argc, char **argv)
 
/* Save administrative file if needed. */
if (a-modified) {
-   char *fntmp, *fn;
-
-   xasprintf(fntmp, %s/%s DPKG_TMP_EXT, admdir, a-master_name);
-   xasprintf(fn, %s/%s, admdir, a-master_name);
-
debug(%s is modified and will be saved, a-master_name);
-   alternative_save(a, fntmp);
-   checked_mv(fntmp, fn);
-
-   free(fntmp);
-   free(fn);
+   alternative_save(a);
}
 
/* Replace all symlinks in one pass. */

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit abcde2189e74065b2807b3984031ef33fe64742b
Author: Guillem Jover guil...@debian.org
Date:   Sun Nov 7 09:05:36 2010 +0100

u-a: Create new xvasprintf() and use it instead of ad-hoc code

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index f14979f..7e9d817 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -285,6 +285,18 @@ xreadlink(const char *linkname, bool error_out)
return buf;
 }
 
+static int DPKG_ATTR_VPRINTF(2)
+xvasprintf(char **strp, const char *fmt, va_list args)
+{
+   int ret;
+
+   ret = vasprintf(strp, fmt, args);
+   if (ret  0)
+   error(_(failed to allocate memory));
+
+   return ret;
+}
+
 static int DPKG_ATTR_PRINTF(2)
 xasprintf(char **strp, const char *fmt, ...)
 {
@@ -292,10 +304,8 @@ xasprintf(char **strp, const char *fmt, ...)
int ret;
 
va_start(args, fmt);
-   ret = vasprintf(strp, fmt, args);
+   ret = xvasprintf(strp, fmt, args);
va_end(args);
-   if (ret  0)
-   error(_(failed to allocate memory));
 
return ret;
 }
@@ -1028,10 +1038,8 @@ altdb_parse_error(struct altdb_context *ctx, const char 
*format, ...)
int ret;
 
va_start(args, format);
-   ret = vasprintf(msg, format, args);
+   ret = xvasprintf(msg, format, args);
va_end(args);
-   if (ret  0)
-   error(_(failed to allocate memory));
 
error(_(%s corrupt: %s), ctx-filename, msg);
 }

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit befa6d21586273f86e911b97aa1c80bde8380f3c
Author: Guillem Jover guil...@debian.org
Date:   Sun Nov 7 09:11:52 2010 +0100

u-a: Simplify an unify string in alternative_display_query()

Unify the common string, and always call free() as it handles NULL just
fine.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 1b7eb6a..ffa4a0a 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1392,12 +1392,8 @@ alternative_display_query(struct alternative *a)
if (best)
pr(Best: %s, best-master_file);
current = alternative_get_current(a);
-   if (current) {
-   pr(Value: %s, current);
-   free(current);
-   } else {
-   pr(Value: none);
-   }
+   pr(Value: %s, current ? current : none);
+   free(current);
 
for (fs = a-choices; fs; fs = fs-next) {
printf(\n);

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 47a45689c3f395b4a1b86067fd795bbbcab29c6f
Author: Guillem Jover guil...@debian.org
Date:   Sun Nov 7 09:16:44 2010 +0100

u-a: Avoid unneeded string allocations

Instead of using temporaries with xasprintf(), just modify the original
string by merging the needed literal strings and pass the additional
arguments.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index ffa4a0a..3d81e55 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2184,12 +2184,9 @@ main(int argc, char **argv)
 inst_alt-master_name);
if (found  strcmp(found-master_name,
inst_alt-master_name) != 0) {
-   char *msg;
-
-   xasprintf(msg, _(it is a slave of %s),
- found-master_name);
-   error(_(alternative %s can't be master: %s),
- inst_alt-master_name, msg);
+   error(_(alternative %s can't be master: 
+   it is a slave of %s),
+ inst_alt-master_name, found-master_name);
}
 
found = alternative_map_find(alt_map_links,
@@ -2227,8 +2224,7 @@ main(int argc, char **argv)
char *msg;
 
if (strcmp(found-master_name, sl-name) == 0)
-   xasprintf(msg, %s,
- _(it is a master 
alternative.));
+   msg = _(it is a master alternative.);
else
xasprintf(msg, _(it is a slave of 
%s),
  found-master_name);
@@ -2311,21 +2307,18 @@ main(int argc, char **argv)
/* Detect manually modified alternative, switch to manual. */
if (!alternative_has_choice(a, current_choice)) {
struct stat st;
-   char *altlink;
 
-   xasprintf(altlink, %s/%s, altdir, a-master_name);
if (stat(current_choice, st) == -1 
errno == ENOENT) {
-   warning(_(%s is dangling, it will be updated 
- with best choice.), altlink);
+   warning(_(%s/%s is dangling, it will be 
updated 
+ with best choice.), altdir, 
a-master_name);
alternative_set_status(a, ALT_ST_AUTO);
} else if (a-status != ALT_ST_MANUAL) {
-   warning(_(%s has been changed (manually or by 
+   warning(_(%s/%s has been changed (manually or 
by 
  a script). Switching to manual 
- updates only.), altlink);
+ updates only.), altdir, 
a-master_name);
alternative_set_status(a, ALT_ST_MANUAL);
}
-   free(altlink);
}
} else {
/* Lack of alternative link = automatic mode. */
@@ -2400,15 +2393,11 @@ main(int argc, char **argv)
if (a-status == ALT_ST_AUTO) {
new_choice = alternative_get_best(a)-master_file;
} else {
-   char *fn;
-
-   xasprintf(fn, %s/%s, altdir, a-master_name);
-   verbose(_(automatic updates of %s are disabled, 
- leaving it alone.), fn);
+   verbose(_(automatic updates of %s/%s are disabled, 
+ leaving it alone.), altdir, a-master_name);
verbose(_(to return to automatic updates use 
  `update-alternatives --auto %s'.),
a-master_name);
-   free(fn);
}
}
 

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit f9c5414ea39c07cbd6a1b580a6a5df1381de39b4
Author: Guillem Jover guil...@debian.org
Date:   Sun Nov 7 23:03:54 2010 +0100

u-a: Reduce scope of current pointer in main()

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 3d81e55..e2c646a 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2261,9 +2261,10 @@ main(int argc, char **argv)
exit(0);
} else if (strcmp(action, get-selections) == 0) {
struct alternative_map *am;
-   char *current;
 
for (am = alt_map_obj; am  am-item; am = am-next) {
+   char *current;
+
current = alternative_get_current(am-item);
printf(%-30s %-8s %s\n, am-key,
   alternative_status_string(am-item-status),

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 898ad6a9d5900b6a46dc2b7c742edb00fc116c3c
Author: Guillem Jover guil...@debian.org
Date:   Sun Nov 7 23:11:03 2010 +0100

u-a: Add missing space in --set-selections output

This was lost during the rewrite in C.

diff --git a/debian/changelog b/debian/changelog
index 738a4d5..b8f4bfa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,7 @@ dpkg (1.16.0) UNRELEASED; urgency=low
   * Add a new --status-logger option to dpkg, similar to --status-fd but
 instead invoke the command ourselves and feed the status information
 to its standard input. Suggested by Raphaël Hertzog.
+  * Add missing space in update-alternative --set-selections output.
 
   [ Raphaël Hertzog ]
   * Fail properly when debian/source/format is empty. Closes: #600854
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index e2c646a..58a88bf 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1864,7 +1864,7 @@ alternative_set_selection(struct alternative_map *all, 
const char *name,
 static void
 alternative_set_selections(struct alternative_map *all, FILE* input, const 
char *desc)
 {
-   const char *prefix = [ PROGNAME --set-selections] ;
+   const char *prefix = [ PROGNAME  --set-selections] ;
 
for (;;) {
char line[1024], *res, *name, *status, *choice;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 1f75b16ea5c48bfb26ead6aa3248b717ab8aa5fc
Author: Guillem Jover guil...@debian.org
Date:   Mon Nov 8 08:00:16 2010 +0100

u-a: Unify similar strings

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 0d4fc3b..7f327bf 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1089,7 +1089,7 @@ alternative_parse_slave(struct alternative *a, struct 
altdb_context *ctx)
if (alternative_has_slave(a, name)) {
sl = alternative_get_slave(a, name);
free(name);
-   ctx-bad_format(ctx, _(duplicate slave %s), sl-name);
+   ctx-bad_format(ctx, _(duplicate slave name %s), sl-name);
}
 
linkname = altdb_get_line(ctx, _(slave link));
@@ -1203,7 +1203,7 @@ alternative_load(struct alternative *a, bool must_not_die)
if (errno == ENOENT)
return false;
else
-   error(_(unable to stat %s: %s), ctx.filename,
+   error(_(cannot stat %s: %s), ctx.filename,
  strerror(errno));
}
if (st.st_size == 0) {
@@ -2093,14 +2093,14 @@ main(int argc, char **argv)
badusage(_(link %s is both primary and slave),
 slink);
if (alternative_has_slave(inst_alt, sname))
-   badusage(_(slave name %s duplicated), sname);
+   badusage(_(duplicate slave name %s), sname);
 
for (sl = inst_alt-slaves; sl; sl = sl-next) {
const char *linkname = sl-link;
if (linkname == NULL)
linkname = ;
if (strcmp(linkname, slink) == 0)
-   badusage(_(slave link %s duplicated),
+   badusage(_(duplicate slave link %s),
  slink);
}
 

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 438df89ef1888c77d9bfc74720392ed9ef580332
Author: Guillem Jover guil...@debian.org
Date:   Sun Nov 7 23:20:25 2010 +0100

u-a: Use PROGNAME as format argument instead of concatenated to literals

This reduced the amount of duplicated string literals in the output
object reducing slightly the binary image.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 58a88bf..0d4fc3b 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -137,7 +137,7 @@ error(char const *fmt, ...)
 {
va_list args;
 
-   fprintf(stderr, PROGNAME : %s: , _(error));
+   fprintf(stderr, %s: %s: , PROGNAME, _(error));
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
@@ -150,7 +150,7 @@ badusage(char const *fmt, ...)
 {
va_list args;
 
-   fprintf(stderr, PROGNAME : );
+   fprintf(stderr, %s: , PROGNAME);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
@@ -167,7 +167,7 @@ warning(char const *fmt, ...)
if (opt_verbose  0)
return;
 
-   fprintf(stderr, PROGNAME : %s: , _(warning));
+   fprintf(stderr, %s: %s: , PROGNAME, _(warning));
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
@@ -196,7 +196,7 @@ verbose(char const *fmt, ...)
if (opt_verbose  1)
return;
 
-   printf(PROGNAME : );
+   printf(%s: , PROGNAME);
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
@@ -211,7 +211,7 @@ info(char const *fmt, ...)
if (opt_verbose  0)
return;
 
-   printf(PROGNAME : );
+   printf(%s: , PROGNAME);
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
@@ -338,7 +338,7 @@ log_msg(const char *fmt, ...)
time(now);
strftime(timestamp, sizeof(timestamp), %Y-%m-%d %H:%M:%S,
 localtime(now));
-   fprintf(fh_log, %s  PROGNAME : , timestamp);
+   fprintf(fh_log, %s %s: , PROGNAME, timestamp);
va_start(args, fmt);
vfprintf(fh_log, fmt, args);
va_end(args);
@@ -1842,12 +1842,12 @@ alternative_set_selection(struct alternative_map *all, 
const char *name,
char *cmd;
 
if (strcmp(status, auto) == 0) {
-   xasprintf(cmd, PROGNAME  --auto %s, name);
+   xasprintf(cmd, %s --auto %s, PROGNAME, name);
pr(_(Call %s.), cmd);
free(cmd);
subcall(prog_path, --auto, name, NULL);
} else if (alternative_has_choice(a, choice)) {
-   xasprintf(cmd, PROGNAME  --set %s %s,
+   xasprintf(cmd, %s --set %s %s, PROGNAME,
  name, choice);
pr(_(Call %s.), cmd);
free(cmd);
@@ -1864,8 +1864,6 @@ alternative_set_selection(struct alternative_map *all, 
const char *name,
 static void
 alternative_set_selections(struct alternative_map *all, FILE* input, const 
char *desc)
 {
-   const char *prefix = [ PROGNAME  --set-selections] ;
-
for (;;) {
char line[1024], *res, *name, *status, *choice;
size_t len, i;
@@ -1894,7 +1892,7 @@ alternative_set_selections(struct alternative_map *all, 
FILE* input, const char
while (i  len  !isblank(line[i]))
i++;
if (i = len) {
-   printf(%s, prefix);
+   printf([%s %s] , PROGNAME, --set-selections);
pr(_(Skip invalid line: %s), line);
continue;
}
@@ -1907,7 +1905,7 @@ alternative_set_selections(struct alternative_map *all, 
FILE* input, const char
while (i  len  !isblank(line[i]))
i++;
if (i = len) {
-   printf(%s, prefix);
+   printf([%s %s] , PROGNAME, --set-selections);
pr(_(Skip invalid line: %s), line);
continue;
}
@@ -1917,13 +1915,13 @@ alternative_set_selections(struct alternative_map *all, 
FILE* input, const char
 
/* Delimit choice string in the line */
if (i = len) {
-   printf(%s, prefix);
+   printf([%s %s] , PROGNAME, --set-selections);
pr(_(Skip invalid line: %s), line);
continue;
}
choice = line + i;
 
-   printf(%s, prefix);
+   printf([%s %s] , PROGNAME, --set-selections);
alternative_set_selection(all, name, status, choice);
}
 }
@@ -2397,8 +2395,7 @@ main(int 

[SCM] dpkg's main repository branch, master, updated. 1.15.8.5-132-gf0266cd

2010-11-18 Thread Guillem Jover
The following commit has been merged in the master branch:
commit f0266cd69c61fdab75691818ef40c64e66adbe26
Author: Guillem Jover guil...@debian.org
Date:   Mon Nov 8 08:02:30 2010 +0100

u-a: Add missing options to --help output

Document --get-selections, --set-selections, --log and --force.
Split the huge string into smaller pieces to ease translators work.

diff --git a/debian/changelog b/debian/changelog
index b8f4bfa..e14a0f0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,7 @@ dpkg (1.16.0) UNRELEASED; urgency=low
 instead invoke the command ourselves and feed the status information
 to its standard input. Suggested by Raphaël Hertzog.
   * Add missing space in update-alternative --set-selections output.
+  * Add missing options to update-alternative --help output.
 
   [ Raphaël Hertzog ]
   * Fail properly when debian/source/format is empty. Closes: #600854
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 7f327bf..1f039bc 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -95,7 +95,9 @@ usage(void)
 {
printf(_(
 Usage: %s [option ...] command\n
-\n
+\n), PROGNAME);
+
+   printf(_(
 Commands:\n
   --install link name path priority\n
 [--slave link name path] ...\n
@@ -106,11 +108,15 @@ usage(void)
   --display name display information about the name group.\n
   --query name   machine parseable version of --display name.\n
   --list namedisplay all targets of the name group.\n
+  --get-selections list master alternative names and their status.\n
+  --set-selections read alternative status from standard input.\n
   --config name  show alternatives for the name group and ask 
the\n
user to select which one to use.\n
   --set name path  set path as alternative for name.\n
   --allcall --config on all alternatives.\n
-\n
+\n));
+
+   printf(_(
 link is the symlink pointing to %s/name.\n
   (e.g. /usr/bin/pager)\n
 name is the master name for this link group.\n
@@ -119,17 +125,21 @@ usage(void)
   (e.g. /usr/bin/less)\n
 priority is an integer; options with higher numbers have higher priority 
in\n
   automatic mode.\n
-\n
+\n), altdir);
+
+   printf(_(
 Options:\n
   --altdir directory change the alternatives directory.\n
   --admindir directory   change the administrative directory.\n
+  --log file change the log file.\n
+  --force  allow replacing files with alternative links.\n
   --skip-auto  skip prompt for alternatives correctly 
configured\n
in automatic mode (relevant for --config only)\n
   --verboseverbose operation, more output.\n
   --quiet  quiet operation, minimal output.\n
   --help   show this help message.\n
   --versionshow the version.\n
-), PROGNAME, altdir);
+));
 }
 
 static void DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1)

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org