[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-231-gf3a8ea5

2011-08-01 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 8561eeb48292a0495d13335d7f088fe66e8ea167
Author: Guillem Jover guil...@debian.org
Date:   Mon Jun 20 19:11:20 2011 +0200

dpkg-deb: Add new -v, --verbose option

Change --extract to honour --verbose and behave as --vextract.

Closes: #293280

diff --git a/debian/changelog b/debian/changelog
index f195a80..255790c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -175,6 +175,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
 debian/rules.
   * Use the perl interpreter found by configure to call dpkg-architecture.pl
 in the m4 DPKG_ARCHITECTURE macro.
+  * Add new --verbose option to dpkg-deb and change --extract to honour it.
+Closes: #293280
   * Fix possible segfault of dpkg in findbreakcycle(). LP: #733414
 
   [ Updated dpkg translations ]
diff --git a/dpkg-deb/dpkg-deb.h b/dpkg-deb/dpkg-deb.h
index 7ae4ccf..fb96742 100644
--- a/dpkg-deb/dpkg-deb.h
+++ b/dpkg-deb/dpkg-deb.h
@@ -31,6 +31,7 @@ action_func do_extract;
 action_func do_vextract;
 action_func do_fsystarfile;
 
+extern int opt_verbose;
 extern int debugflag, nocheckflag, oldformatflag;
 
 void extracthalf(const char *debar, const char *dir,
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index 2dde994..7e1ba96 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -377,11 +377,16 @@ do_control(const char *const *argv)
 int
 do_extract(const char *const *argv)
 {
-  return controlextractvextract(0, xp, argv);
+  if (opt_verbose)
+return controlextractvextract(0, xpv, argv);
+  else
+return controlextractvextract(0, xp, argv);
 }
 
 int
 do_vextract(const char *const *argv)
 {
-  return controlextractvextract(0, xpv, argv);
+  /* XXX: Backward compatibility. */
+  opt_verbose = 1;
+  return do_extract(argv);
 }
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c
index 49cf5e5..fb2fd06 100644
--- a/dpkg-deb/main.c
+++ b/dpkg-deb/main.c
@@ -96,6 +96,7 @@ usage(const struct cmdinfo *cip, const char *value)
   printf(_(
 Options:\n
   --showformat=formatUse alternative format for --show.\n
+  -v, --verboseEnable verbose output.\n
   -D   Enable debugging output.\n
   --old, --new Select archive format.\n
   --nocheckSuppress control file check (build bad\n
@@ -130,6 +131,7 @@ static const char printforhelp[] =
  Type dpkg --help for help about installing and deinstalling packages.);
 
 int debugflag=0, nocheckflag=0, oldformatflag=BUILDOLDPKGFORMAT;
+int opt_verbose = 0;
 struct compressor *compressor = compressor_gzip;
 int compress_level = -1;
 
@@ -171,6 +173,7 @@ static const struct cmdinfo cmdinfos[]= {
   { new,   0,   0, oldformatflag, NULL, NULL,  0 },
   { old,   0,   0, oldformatflag, NULL, NULL,  1 },
   { debug, 'D', 0, debugflag, NULL, NULL,  1 },
+  { verbose,   'v', 0, opt_verbose,   NULL, NULL,  1 },
   { nocheck,   0,   0, nocheckflag,   NULL, NULL,  1 },
   { compression,   'z', 1, NULL,   NULL, set_compress_level 
},
   { compress_type, 'Z', 1, NULL,   NULL, setcompresstype  },
diff --git a/man/dpkg-deb.1 b/man/dpkg-deb.1
index 99cdc8e..4afc326 100644
--- a/man/dpkg-deb.1
+++ b/man/dpkg-deb.1
@@ -139,7 +139,9 @@ modified to match the contents of the package.
 .BR \-X ,  \-\-vextract  \fIarchive directory\fP
 Is like
 .BR \-\-extract  ( \-x )
-but prints a listing of the files extracted as it goes.
+with
+.BR \-\-verbose  ( \-v )
+which prints a listing of the files extracted as it goes.
 .TP
 .BR \-\-fsys\-tarfile  \fIarchive\fP
 Extracts the filesystem tree data from a binary package and sends it
@@ -213,6 +215,10 @@ Inhibits
 usual checks on the proposed contents of an archive. You can build
 any archive you want, no matter how broken, this way.
 .TP
+.BR \-v ,  \-\-verbose
+Enables verbose output. This currently only affects \fB\-\-extract\fP making
+it behave like \fB\-\-vextract\fP.
+.TP
 .BR \-D ,  \-\-debug
 Enables debugging output. This is not very interesting.
 .

-- 
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.16.0.3-231-gf3a8ea5

2011-08-01 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 02c28c63a34e252d75f893cb0869f9480f603822
Author: Guillem Jover guil...@debian.org
Date:   Tue Apr 26 07:35:16 2011 +0200

dpkg-deb: Add --raw-extract option combining --control and --extract

This allows to extract the control and file system members of a .deb
into a single directory using the same layout dpkg-deb -b expects for
building a package.

Closes: #552123

diff --git a/debian/changelog b/debian/changelog
index 255790c..1b72f8e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -177,6 +177,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
 in the m4 DPKG_ARCHITECTURE macro.
   * Add new --verbose option to dpkg-deb and change --extract to honour it.
 Closes: #293280
+  * Add new --raw-extract option to dpkg-deb combining --control and
+--extract. Closes: #552123
   * Fix possible segfault of dpkg in findbreakcycle(). LP: #733414
 
   [ Updated dpkg translations ]
diff --git a/dpkg-deb/dpkg-deb.h b/dpkg-deb/dpkg-deb.h
index fb96742..1605967 100644
--- a/dpkg-deb/dpkg-deb.h
+++ b/dpkg-deb/dpkg-deb.h
@@ -29,6 +29,7 @@ action_func do_info;
 action_func do_field;
 action_func do_extract;
 action_func do_vextract;
+action_func do_raw_extract;
 action_func do_fsystarfile;
 
 extern int opt_verbose;
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index 7e1ba96..f80955e 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -390,3 +390,35 @@ do_vextract(const char *const *argv)
   opt_verbose = 1;
   return do_extract(argv);
 }
+
+int
+do_raw_extract(const char *const *argv)
+{
+  const char *debar, *dir;
+  char *control_dir;
+
+  debar = *argv++;
+  if (debar == NULL)
+badusage(_(--%s needs a .deb filename argument), cipaction-olong);
+
+  dir = *argv++;
+  if (dir == NULL)
+badusage(_(--%s needs a target directory.\n
+   Perhaps you should be using dpkg --install ?),
+ cipaction-olong);
+  else if (*argv)
+badusage(_(--%s takes at most two arguments (.deb and directory)),
+ cipaction-olong);
+
+  m_asprintf(control_dir, %s/%s, dir, EXTRACTCONTROLDIR);
+
+  if (opt_verbose)
+extracthalf(debar, dir, xpv, 0);
+  else
+extracthalf(debar, dir, xp, 0);
+  extracthalf(debar, control_dir, x, 1);
+
+  free(control_dir);
+
+  return 0;
+}
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c
index fb2fd06..88f765c 100644
--- a/dpkg-deb/main.c
+++ b/dpkg-deb/main.c
@@ -79,6 +79,8 @@ usage(const struct cmdinfo *cip, const char *value)
   -e|--control deb [directory] Extract control info.\n
   -x|--extract deb directory   Extract files.\n
   -X|--vextract deb directory  Extract  list files.\n
+  -R|--raw-extract deb directory\n
+   Extract control info and files.\n
   --fsys-tarfile deb Output filesystem tarfile.\n
 \n));
 
@@ -167,6 +169,7 @@ static const struct cmdinfo cmdinfos[]= {
   ACTION(field, 'f', 0, do_field),
   ACTION(extract,   'x', 0, do_extract),
   ACTION(vextract,  'X', 0, do_vextract),
+  ACTION(raw-extract,   'R', 0, do_raw_extract),
   ACTION(fsys-tarfile,  0,   0, do_fsystarfile),
   ACTION(show,  'W', 0, do_showinfo),
 
diff --git a/man/dpkg-deb.1 b/man/dpkg-deb.1
index 4afc326..bd13e56 100644
--- a/man/dpkg-deb.1
+++ b/man/dpkg-deb.1
@@ -143,6 +143,13 @@ with
 .BR \-\-verbose  ( \-v )
 which prints a listing of the files extracted as it goes.
 .TP
+.BR \-R ,  \-\-raw\-extract  \fIarchive directory\fP
+Extracts the filesystem tree from a package archive into a specified
+directory, and the control information files into a DEBIAN subdirectory
+of the specified directory.
+
+The target directory (but not its parents) will be created if necessary.
+.TP
 .BR \-\-fsys\-tarfile  \fIarchive\fP
 Extracts the filesystem tree data from a binary package and sends it
 to standard output in

-- 
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.16.0.3-231-gf3a8ea5

2011-08-01 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 842e66ae6790805d87b51129b560d1a6b0e526b3
Author: Guillem Jover guil...@debian.org
Date:   Tue Aug 2 04:56:00 2011 +0200

libdpkg: Remove trailing semicolons from getc_mmap and ungetc_mmap

Those are unnecessary as these are function macros which need to be
followed by semicolons on the call sites.

diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index 58b3110..898f996 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -369,8 +369,8 @@ int parsedb(const char *filename, enum parsedbflags flags,
 
   pdone= 0;
 #define EOF_mmap(dataptr, endptr)  (dataptr = endptr)
-#define getc_mmap(dataptr) *dataptr++;
-#define ungetc_mmap(c, dataptr, data)  dataptr--;
+#define getc_mmap(dataptr) *dataptr++
+#define ungetc_mmap(c, dataptr, data)  dataptr--
 
   /* Loop per package. */
   for (;;) {

-- 
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.16.0.3-231-gf3a8ea5

2011-08-01 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 3d8951fdf5cc2fe3209540bc43c489208db8c306
Author: Guillem Jover guil...@debian.org
Date:   Thu Jul 14 04:37:31 2011 +0200

libdpkg: Move dataptr and endptr from parsedb() to struct parsedb_state

diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index 3b32572..e5048f9 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -311,6 +311,10 @@ pkg_parse_copy(struct parsedb_state *ps,
   }
 }
 
+#define EOF_mmap(ps)   ((ps)-dataptr = (ps)-endptr)
+#define getc_mmap(ps)  *(ps)-dataptr++
+#define ungetc_mmap(c, ps) (ps)-dataptr--
+
 /**
  * Parse an RFC-822 style file.
  *
@@ -325,7 +329,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
   struct pkginfo *new_pkg, *db_pkg;
   struct pkgbin *new_pkgbin, *db_pkgbin;
   int pdone;
-  char *data, *dataptr, *endptr;
+  char *data;
   struct stat st;
   struct parsedb_state ps;
   struct field_state fs;
@@ -355,25 +359,22 @@ int parsedb(const char *filename, enum parsedbflags flags,
 
   if (st.st_size  0) {
 #ifdef USE_MMAP
-dataptr = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
-if (dataptr == MAP_FAILED)
+ps.dataptr = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
+if (ps.dataptr == MAP_FAILED)
   ohshite(_(can't mmap package info file `%.255s'),filename);
 #else
-dataptr = m_malloc(st.st_size);
+ps.dataptr = m_malloc(st.st_size);
 
-if (fd_read(fd, dataptr, st.st_size)  0)
+if (fd_read(fd, ps.dataptr, st.st_size)  0)
   ohshite(_(reading package info file '%.255s'), filename);
 #endif
-data= dataptr;
-endptr = dataptr + st.st_size;
+data = ps.dataptr;
+ps.endptr = ps.dataptr + st.st_size;
   } else {
-data= dataptr= endptr= NULL;
+data = ps.dataptr = ps.endptr = NULL;
   }
 
   pdone= 0;
-#define EOF_mmap(dataptr, endptr)  (dataptr = endptr)
-#define getc_mmap(dataptr) *dataptr++
-#define ungetc_mmap(c, dataptr, data)  dataptr--
 
   /* Loop per package. */
   for (;;) {
@@ -383,22 +384,26 @@ int parsedb(const char *filename, enum parsedbflags flags,
 pkg_blank(new_pkg);
 
 /* Skip adjacent new lines. */
-while(!EOF_mmap(dataptr, endptr)) {
-  c= getc_mmap(dataptr); if (c!='\n'  c!=MSDOS_EOF_CHAR ) break;
+while (!EOF_mmap(ps)) {
+  c = getc_mmap(ps);
+  if (c != '\n'  c != MSDOS_EOF_CHAR)
+break;
   ps.lno++;
 }
-if (EOF_mmap(dataptr, endptr)) break;
+if (EOF_mmap(ps))
+  break;
 
 /* Loop per field. */
 for (;;) {
   bool blank_line;
 
-  fs.fieldstart = dataptr - 1;
-  while (!EOF_mmap(dataptr, endptr)  !isspace(c)  c!=':'  
c!=MSDOS_EOF_CHAR)
-c= getc_mmap(dataptr);
-  fs.fieldlen = dataptr - fs.fieldstart - 1;
-  while (!EOF_mmap(dataptr, endptr)  c != '\n'  isspace(c)) c= 
getc_mmap(dataptr);
-  if (EOF_mmap(dataptr, endptr))
+  fs.fieldstart = ps.dataptr - 1;
+  while (!EOF_mmap(ps)  !isspace(c)  c != ':'  c != MSDOS_EOF_CHAR)
+c = getc_mmap(ps);
+  fs.fieldlen = ps.dataptr - fs.fieldstart - 1;
+  while (!EOF_mmap(ps)  c != '\n'  isspace(c))
+c = getc_mmap(ps);
+  if (EOF_mmap(ps))
 parse_error(ps,
 _(EOF after field name `%.*s'), fs.fieldlen, 
fs.fieldstart);
   if (c == '\n')
@@ -413,11 +418,11 @@ int parsedb(const char *filename, enum parsedbflags flags,
 _(field name `%.*s' must be followed by colon),
 fs.fieldlen, fs.fieldstart);
   /* Skip space after ‘:’ but before value and EOL. */
-  while(!EOF_mmap(dataptr, endptr)) {
-c= getc_mmap(dataptr);
+  while (!EOF_mmap(ps)) {
+c = getc_mmap(ps);
 if (c == '\n' || !isspace(c)) break;
   }
-  if (EOF_mmap(dataptr, endptr))
+  if (EOF_mmap(ps))
 parse_error(ps,
 _(EOF before value of field `%.*s' (missing final 
newline)),
 fs.fieldlen, fs.fieldstart);
@@ -428,7 +433,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
 
   blank_line = false;
 
-  fs.valuestart = dataptr - 1;
+  fs.valuestart = ps.dataptr - 1;
   for (;;) {
 if (c == '\n' || c == MSDOS_EOF_CHAR) {
   if (blank_line)
@@ -436,32 +441,35 @@ int parsedb(const char *filename, enum parsedbflags flags,
 _(blank line in value of field '%.*s'),
 fs.fieldlen, fs.fieldstart);
   ps.lno++;
- if (EOF_mmap(dataptr, endptr)) break;
-  c= getc_mmap(dataptr);
+  if (EOF_mmap(ps))
+break;
+  c = getc_mmap(ps);
   /* Found double EOL, or start of new field. */
-  if (EOF_mmap(dataptr, endptr) || c == '\n' || !isspace(c)) break;
-  ungetc_mmap(c,dataptr, data);
+  if (EOF_mmap(ps) || c == '\n' || !isspace(c))
+break;
+  ungetc_mmap(c, ps);
   c= '\n';
   

[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-231-gf3a8ea5

2011-08-01 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 7d06ea566bafe5d2914adbfa4820342f35829a37
Author: Guillem Jover guil...@debian.org
Date:   Thu Jul 14 17:21:55 2011 +0200

libdpkg: Refactor RFC-822 stanza parsing into new parse_stanza()

This generalizes the stanza parsing so that it can be used by other
parts of the code.

diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index e5048f9..7ddced1 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -315,6 +315,128 @@ pkg_parse_copy(struct parsedb_state *ps,
 #define getc_mmap(ps)  *(ps)-dataptr++
 #define ungetc_mmap(c, ps) (ps)-dataptr--
 
+typedef void parse_field_func(struct parsedb_state *ps, struct field_state *fs,
+  struct pkginfo *pkg, struct pkgbin *pkgbin);
+
+/**
+ * Parse an RFC-822 style stanza.
+ */
+static bool
+parse_stanza(struct parsedb_state *ps, struct field_state *fs,
+ parse_field_func *parse_field,
+ struct pkginfo *pkg, struct pkgbin *pkgbin)
+{
+  int c;
+
+  /* Skip adjacent new lines. */
+  while (!EOF_mmap(ps)) {
+c = getc_mmap(ps);
+if (c != '\n'  c != MSDOS_EOF_CHAR)
+  break;
+ps-lno++;
+  }
+
+  /* Nothing relevant parsed, bail out. */
+  if (EOF_mmap(ps))
+return false;
+
+  /* Loop per field. */
+  for (;;) {
+bool blank_line;
+
+/* Scan field name. */
+fs-fieldstart = ps-dataptr - 1;
+while (!EOF_mmap(ps)  !isspace(c)  c != ':'  c != MSDOS_EOF_CHAR)
+  c = getc_mmap(ps);
+fs-fieldlen = ps-dataptr - fs-fieldstart - 1;
+
+/* Skip spaces before ‘:’. */
+while (!EOF_mmap(ps)  c != '\n'  isspace(c))
+  c = getc_mmap(ps);
+
+/* Validate ‘:’. */
+if (EOF_mmap(ps))
+  parse_error(ps,
+  _(EOF after field name `%.*s'), fs-fieldlen, 
fs-fieldstart);
+if (c == '\n')
+  parse_error(ps,
+  _(newline in field name `%.*s'), fs-fieldlen, 
fs-fieldstart);
+if (c == MSDOS_EOF_CHAR)
+  parse_error(ps,
+  _(MSDOS EOF (^Z) in field name `%.*s'),
+  fs-fieldlen, fs-fieldstart);
+if (c != ':')
+  parse_error(ps,
+  _(field name `%.*s' must be followed by colon),
+  fs-fieldlen, fs-fieldstart);
+
+/* Skip space after ‘:’ but before value and EOL. */
+while (!EOF_mmap(ps)) {
+  c = getc_mmap(ps);
+  if (c == '\n' || !isspace(c))
+break;
+}
+if (EOF_mmap(ps))
+  parse_error(ps,
+  _(EOF before value of field `%.*s' (missing final 
newline)),
+  fs-fieldlen, fs-fieldstart);
+if (c == MSDOS_EOF_CHAR)
+  parse_error(ps,
+  _(MSDOS EOF char in value of field `%.*s' (missing 
newline?)),
+  fs-fieldlen, fs-fieldstart);
+
+blank_line = false;
+
+/* Scan field value. */
+fs-valuestart = ps-dataptr - 1;
+for (;;) {
+  if (c == '\n' || c == MSDOS_EOF_CHAR) {
+if (blank_line)
+  parse_error(ps,
+  _(blank line in value of field '%.*s'),
+  fs-fieldlen, fs-fieldstart);
+ps-lno++;
+
+if (EOF_mmap(ps))
+  break;
+c = getc_mmap(ps);
+
+/* Found double EOL, or start of new field. */
+if (EOF_mmap(ps) || c == '\n' || !isspace(c))
+  break;
+
+ungetc_mmap(c, ps);
+c = '\n';
+blank_line = true;
+  } else if (blank_line  !isspace(c)) {
+blank_line = false;
+  }
+
+  if (EOF_mmap(ps))
+parse_error(ps,
+_(EOF during value of field `%.*s' (missing final 
newline)),
+fs-fieldlen, fs-fieldstart);
+
+  c = getc_mmap(ps);
+}
+fs-valuelen = ps-dataptr - fs-valuestart - 1;
+
+/* Trim ending space on value. */
+while (fs-valuelen  isspace(*(fs-valuestart + fs-valuelen - 1)))
+  fs-valuelen--;
+
+parse_field(ps, fs, pkg, pkgbin);
+
+if (EOF_mmap(ps) || c == '\n' || c == MSDOS_EOF_CHAR)
+  break;
+  } /* Loop per field. */
+
+  if (c == '\n')
+ps-lno++;
+
+  return true;
+}
+
 /**
  * Parse an RFC-822 style file.
  *
@@ -378,100 +500,12 @@ int parsedb(const char *filename, enum parsedbflags 
flags,
 
   /* Loop per package. */
   for (;;) {
-int c;
-
 memset(fs.fieldencountered, 0, sizeof(fs.fieldencountered));
 pkg_blank(new_pkg);
 
-/* Skip adjacent new lines. */
-while (!EOF_mmap(ps)) {
-  c = getc_mmap(ps);
-  if (c != '\n'  c != MSDOS_EOF_CHAR)
-break;
-  ps.lno++;
-}
-if (EOF_mmap(ps))
+if (!parse_stanza(ps, fs, pkg_parse_field, new_pkg, new_pkgbin))
   break;
 
-/* Loop per field. */
-for (;;) {
-  bool blank_line;
-
-  fs.fieldstart = ps.dataptr - 1;
-  while (!EOF_mmap(ps)  !isspace(c)  c != ':'  c != MSDOS_EOF_CHAR)
-c = getc_mmap(ps);
-  fs.fieldlen = ps.dataptr - fs.fieldstart - 1;
-  while (!EOF_mmap(ps)  c != '\n'  isspace(c))
- 

[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-231-gf3a8ea5

2011-08-01 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 926a204c1609d35de3a6500f8e96c9db0c315de4
Author: Guillem Jover guil...@debian.org
Date:   Thu Jul 14 03:58:45 2011 +0200

libdpkg: Add pkg and pkgbin to struct parsedb_state

We are passing these variables as arguments most of the time for
parse_error() and parse_warn() calls which are not run-time frequent,
this also unties somewhat the code from the package structures.

diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index b56dc1e..124d2d4 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -34,7 +34,7 @@
 #include dpkg/triglib.h
 
 static int
-parse_nv_next(struct parsedb_state *ps, const struct pkginfo *pigp,
+parse_nv_next(struct parsedb_state *ps,
   const char *what, const struct namevalue *nv_head,
   const char **strp)
 {
@@ -42,11 +42,11 @@ parse_nv_next(struct parsedb_state *ps, const struct 
pkginfo *pigp,
   const struct namevalue *nv;
 
   if (str_start[0] == '\0')
-parse_error(ps, pigp, _(%s is missing), what);
+parse_error(ps, _(%s is missing), what);
 
   nv = namevalue_find_by_name(nv_head, str_start);
   if (nv == NULL)
-parse_error(ps, pigp, _('%.50s' is not allowed for %s), str_start, what);
+parse_error(ps, _('%.50s' is not allowed for %s), str_start, what);
 
   /* We got the fallback value, skip further string validation. */
   if (nv-length == 0) {
@@ -62,15 +62,15 @@ parse_nv_next(struct parsedb_state *ps, const struct 
pkginfo *pigp,
 }
 
 static int
-parse_nv_last(struct parsedb_state *ps, const struct pkginfo *pkg,
+parse_nv_last(struct parsedb_state *ps,
   const char *what, const struct namevalue *nv_head,
   const char *str)
 {
   int value;
 
-  value = parse_nv_next(ps, pkg, what, nv_head, str);
+  value = parse_nv_next(ps, what, nv_head, str);
   if (str != NULL  str[0] != '\0')
-parse_error(ps, pkg, _(junk after %s), what);
+parse_error(ps, _(junk after %s), what);
 
   return value;
 }
@@ -84,7 +84,7 @@ f_name(struct pkginfo *pigp, struct pkgbin *pifp,
 
   e = pkg_name_is_illegal(value, NULL);
   if (e != NULL)
-parse_error(ps, pigp, _(invalid package name (%.250s)), e);
+parse_error(ps, _(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;
 }
@@ -99,9 +99,9 @@ f_filecharf(struct pkginfo *pigp, struct pkgbin *pifp,
   int allowextend;
 
   if (!*value)
-parse_error(ps, pigp, _(empty file details field `%s'), fip-name);
+parse_error(ps, _(empty file details field `%s'), fip-name);
   if (!(ps-flags  pdb_recordavailable))
-parse_error(ps, pigp,
+parse_error(ps,
 _(file details field `%s' not allowed in status file),
fip-name);
   allowextend= !pigp-files;
@@ -114,7 +114,7 @@ f_filecharf(struct pkginfo *pigp, struct pkgbin *pifp,
 fdp= *fdpp;
 if (!fdp) {
   if (!allowextend)
-parse_error(ps, pigp,
+parse_error(ps,
 _(too many values in file details field `%s' 
   (compared to others)), fip-name);
   fdp= nfmalloc(sizeof(struct filedetails));
@@ -128,7 +128,7 @@ f_filecharf(struct pkginfo *pigp, struct pkgbin *pifp,
 cpos= space;
   }
   if (*fdpp)
-parse_error(ps, pigp,
+parse_error(ps,
 _(too few values in file details field `%s' 
   (compared to others)), fip-name);
 }
@@ -151,7 +151,7 @@ f_boolean(struct pkginfo *pigp, struct pkgbin *pifp,
   if (!*value)
 return;
 
-  boolean = parse_nv_last(ps, pigp, _(yes/no in boolean field),
+  boolean = parse_nv_last(ps, _(yes/no in boolean field),
   booleaninfos, value);
   PKGPFIELD(pifp, fip-integer, bool) = boolean;
 }
@@ -171,7 +171,7 @@ f_priority(struct pkginfo *pigp, struct pkgbin *pifp,
const char *value, const struct fieldinfo *fip)
 {
   if (!*value) return;
-  pigp-priority = parse_nv_last(ps, pigp, _(word in `priority' field),
+  pigp-priority = parse_nv_last(ps, _(word in `priority' field),
  priorityinfos, value);
   if (pigp-priority == pri_other) pigp-otherpriority= nfstrsave(value);
 }
@@ -182,18 +182,18 @@ f_status(struct pkginfo *pigp, struct pkgbin *pifp,
  const char *value, const struct fieldinfo *fip)
 {
   if (ps-flags  pdb_rejectstatus)
-parse_error(ps, pigp,
+parse_error(ps,
 _(value for `status' field not allowed in this context));
   if (ps-flags  pdb_recordavailable)
 return;
 
-  pigp-want = parse_nv_next(ps, pigp,
+  pigp-want = parse_nv_next(ps,
  _(first (want) word in `status' field),
  wantinfos, value);
-  pigp-eflag = parse_nv_next(ps, pigp,
+  pigp-eflag = parse_nv_next(ps,
   _(second (error) word in `status' field),
   eflaginfos, 

[SCM] dpkg's main repository branch, master, updated. 1.16.0.3-231-gf3a8ea5

2011-08-01 Thread Guillem Jover
The following commit has been merged in the master branch:
commit 98aea15132c085be3901956986afaa46bf0456b1
Author: Guillem Jover guil...@debian.org
Date:   Tue Aug 2 04:54:42 2011 +0200

libdpkg: Make parse_stanza() a public function

Make public also the required parse helper macros and structures. At
least parse_EOF() will be needed for other callers to get out of the
loop when parsing multi-stanza files.

diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index 491d9dd..46f3528 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -93,15 +93,6 @@ static const struct nickname nicknames[] = {
   { .nick = NULL }
 };
 
-struct field_state {
-  const char *fieldstart;
-  const char *valuestart;
-  struct varbuf value;
-  int fieldlen;
-  int valuelen;
-  int *fieldencountered;
-};
-
 /**
  * Parse the field and value into the package being constructed.
  */
@@ -311,17 +302,10 @@ pkg_parse_copy(struct parsedb_state *ps,
   }
 }
 
-#define parse_EOF(ps)  ((ps)-dataptr = (ps)-endptr)
-#define parse_getc(ps) *(ps)-dataptr++
-#define parse_ungetc(c, ps)(ps)-dataptr--
-
-typedef void parse_field_func(struct parsedb_state *ps, struct field_state *fs,
-  struct pkginfo *pkg, struct pkgbin *pkgbin);
-
 /**
  * Parse an RFC-822 style stanza.
  */
-static bool
+bool
 parse_stanza(struct parsedb_state *ps, struct field_state *fs,
  parse_field_func *parse_field,
  struct pkginfo *pkg, struct pkgbin *pkgbin)
diff --git a/lib/dpkg/parsedump.h b/lib/dpkg/parsedump.h
index 08c34cd..12eb4ca 100644
--- a/lib/dpkg/parsedump.h
+++ b/lib/dpkg/parsedump.h
@@ -34,6 +34,26 @@ struct parsedb_state {
int lno;
 };
 
+#define parse_EOF(ps)  ((ps)-dataptr = (ps)-endptr)
+#define parse_getc(ps) *(ps)-dataptr++
+#define parse_ungetc(c, ps)(ps)-dataptr--
+
+struct field_state {
+   const char *fieldstart;
+   const char *valuestart;
+   struct varbuf value;
+   int fieldlen;
+   int valuelen;
+   int *fieldencountered;
+};
+
+typedef void parse_field_func(struct parsedb_state *ps, struct field_state *fs,
+  struct pkginfo *pkg, struct pkgbin *pkgbin);
+
+bool parse_stanza(struct parsedb_state *ps, struct field_state *fs,
+  parse_field_func *parse_field,
+  struct pkginfo *pkg, struct pkgbin *pkgbin);
+
 #define PKGIFPOFF(f) (offsetof(struct pkgbin, f))
 #define PKGPFIELD(pifp,of,type) (*(type*)((char*)(pifp)+(of)))
 

-- 
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