Bug#674836: [Dctrl-tools-devel] Bug#674836: Please review the included patch

2012-06-03 Thread Antti-Juhani Kaijanaho
On Mon, May 28, 2012 at 07:49:02PM +0300, Antti-Juhani Kaijanaho wrote:
> Please review the following patch.  I intend to release it in the next 2.22.x
> series upload.  It changes no strings but is otherwise a bit intrusive for a
> point-release patch.
> 
> From 530812104719d5e75264e60b1e854754f1bb0c1e Mon Sep 17 00:00:00 2001
> From: Antti-Juhani Kaijanaho 
> Date: Mon, 28 May 2012 19:42:40 +0300
> Subject: [PATCH] Fix #674836 (Builds with wrong CFLAGS)

I've pushed to maint-2.22 a little less ambitious version of this.
It accomplishes the main result (no build error due to mblen) without
(non-buildsystem) code chanegs and without introducing a new build dependency.
It still does upgrade the debhelper dependency.  The rest of it I plan to leave
to 2.23.

-- 
Antti-Juhani Kaijanaho, Jyväskylä, Finland
http://antti-juhani.kaijanaho.fi/newblog/
http://www.flickr.com/photos/antti-juhani/




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



Bug#674836: Please review the included patch

2012-05-28 Thread Antti-Juhani Kaijanaho
Please review the following patch.  I intend to release it in the next 2.22.x
series upload.  It changes no strings but is otherwise a bit intrusive for a
point-release patch.

From 530812104719d5e75264e60b1e854754f1bb0c1e Mon Sep 17 00:00:00 2001
From: Antti-Juhani Kaijanaho 
Date: Mon, 28 May 2012 19:42:40 +0300
Subject: [PATCH] Fix #674836 (Builds with wrong CFLAGS)

 - Upgrade debhelper mode to 9.
 - Work around debhelper bug 674912 by not defining a default CFLAGS
   in GNUmakefile.
 - Since the new Debian build flags make it impossible to use mblen
   with -Werror, switch to using mbrlen in tbl-dctrl.c (a good idea
   in any case).
 - Add a test case (tests/0021.{in,out,sh}) to verify that tbl-dctrl
   handles UTF-8 correctly (needed to regression-test the above bugfix).
 - As the previous item requires the C.UTF-8 locale, build-depend on
   libc-bin >= 2.13

Signed-off-by: Antti-Juhani Kaijanaho 
---
 GNUmakefile   |3 +--
 debian/changelog  |   15 ---
 debian/compat |2 +-
 debian/control|2 +-
 tbl-dctrl/tbl-dctrl.c |   21 +
 tests/0021.in |2 ++
 tests/0021.out|5 +
 tests/0021.sh |5 +
 8 files changed, 40 insertions(+), 15 deletions(-)
 create mode 100644 tests/0021.in
 create mode 100644 tests/0021.out
 create mode 100644 tests/0021.sh

diff --git a/GNUmakefile b/GNUmakefile
index 3a25b8e..c79aada 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -14,8 +14,7 @@ man8dir = $(mandir)/man8
 localedir = $(datarootdir)/locale
 
 CC = gcc 
-CFLAGS = -g -Wall -Werror
-ALL_CFLAGS = $(CFLAGS) -std=gnu99 -Ilib \
+ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS) -Wall -Werror -std=gnu99 -Ilib \
 -DENABLE_L_DEBUG -D_GNU_SOURCE -DSYSCONF=\"$(sysconfdir)\" \
  -DHAVE_GETTEXT -DPACKAGE=\"dctrl-tools\" -DLOCALEDIR=\"$(localedir)\" 
 
diff --git a/debian/changelog b/debian/changelog
index 7a860e8..3b9e32a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,17 @@
 dctrl-tools (2.22.2) UNRELEASED; urgency=low
 
-  * 
-
- -- Antti-Juhani Kaijanaho   Mon, 28 May 2012 18:05:31 +0300
+  * Closes: #674836 (Builds with wrong CFLAGS), reported by me:
+ - Upgrade debhelper mode to 9.
+ - Work around debhelper bug 674912 by not defining a default CFLAGS
+   in GNUmakefile.
+ - Since the new Debian build flags make it impossible to use mblen
+   with -Werror, switch to using mbrlen in tbl-dctrl.c (a good idea
+   in any case).
+  * Add a test case (tests/0021.{in,out,sh}) to verify that tbl-dctrl
+handles UTF-8 correctly (needed to regression-test the above bugfix).
+ - As it requires the C.UTF-8 locale, build-depend on libc-bin >= 2.13
+
+ -- Antti-Juhani Kaijanaho   Mon, 28 May 2012 19:36:34 +0300
 
 dctrl-tools (2.22.1) unstable; urgency=low
 
diff --git a/debian/compat b/debian/compat
index 45a4fb7..ec63514 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-8
+9
diff --git a/debian/control b/debian/control
index 16b2d41..39143d8 100644
--- a/debian/control
+++ b/debian/control
@@ -4,7 +4,7 @@ Priority: optional
 Maintainer: dctrl-tools developers 
 Uploaders: Antti-Juhani Kaijanaho 
 Standards-Version: 3.9.3
-Build-Depends: gettext (>= 0.11-0), gcc (>= 3.0), debhelper (>= 8), po4a (>= 
0.40)
+Build-Depends: gettext (>= 0.11-0), gcc (>= 3.0), debhelper (>= 9), po4a (>= 
0.40), libc-bin (>= 2.13)
 Vcs-Git: git://git.debian.org/git/collab-maint/dctrl-tools.git
 Vcs-Browser: http://git.debian.org/?p=collab-maint/dctrl-tools.git;a=summary
 
diff --git a/tbl-dctrl/tbl-dctrl.c b/tbl-dctrl/tbl-dctrl.c
index 848f3f3..b295589 100644
--- a/tbl-dctrl/tbl-dctrl.c
+++ b/tbl-dctrl/tbl-dctrl.c
@@ -1,5 +1,5 @@
 /*  dctrl-tools - Debian control file inspection tools
-Copyright © 2005, 2006, 2007, 2008, 2009, 2010, 2011 Antti-Juhani Kaijanaho
+Copyright © 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Antti-Juhani 
Kaijanaho
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "misc.h"
 #include "msg.h"
 #include "i18n.h"
@@ -96,7 +97,8 @@ size_t linewrap(char **res, char const *orig, size_t orig_len,
 
size_t num_lines = 1;
 
-   mblen(NULL, 0);
+mbstate_t mbs;
+memset(&mbs, 0, sizeof mbs);
for (size_t i = 0; i < orig_len; /**/) {
 if (orig[i] == '\n') {
 i++;
@@ -125,7 +127,7 @@ size_t linewrap(char **res, char const *orig, size_t 
orig_len,
bpo = i;
bpr = len;
}
-   int n = mblen(orig + i, orig_len - i);
+   int n = mbrlen(orig + i, orig_len - i, &mbs);
if (n <= 0) break;
for (size_t j = 0; j < n; j++) INSERT(orig[i+j]);
i += n;
@@ -161,7 +163,8 @@ void print_line(struct arguments *args,