summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntti-Juhani Kaijanaho <ajk@debian.org>2012-06-03 20:45:51 +0300
committerAntti-Juhani Kaijanaho <ajk@debian.org>2012-06-07 12:10:13 +0300
commitf690c98a923c59f2a654127077c19710ff187f49 (patch)
tree417c5e3562a558c2494f1e5632fb878aa5b17696
parentb3e64e090731082b2444fdce2510615eb0dc0cb5 (diff)
downloaddctrl-tools-f690c98a923c59f2a654127077c19710ff187f49.tar.gz
Switch from mblen to mbrlen in tbl-dctrl.c.
Signed-off-by: Antti-Juhani Kaijanaho <ajk@debian.org>
-rw-r--r--debian/changelog6
-rw-r--r--tbl-dctrl/tbl-dctrl.c21
2 files changed, 18 insertions, 9 deletions
diff --git a/debian/changelog b/debian/changelog
index ce73e04..fb47ced 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,8 +4,12 @@ dctrl-tools (2.23) UNRELEASED; urgency=low
* Add a test case (tests/0021.{in,out,sh}) to verify that tbl-dctrl
handles UTF-8 correctly.
- As it requires the C.UTF-8 locale, build-depend on libc-bin >= 2.13
+ * Since mblen is unnecessarily marked warn_unused_result with
+ _FORTIFY_SOURCE, (see bug #674917), causing spurious warnings upon
+ mblen initialization calls, switch to using mbrlen in tbl-dctrl.c (a
+ good idea in any case).
- -- Antti-Juhani Kaijanaho <ajk@debian.org> Thu, 07 Jun 2012 12:07:58 +0300
+ -- Antti-Juhani Kaijanaho <ajk@debian.org> Thu, 07 Jun 2012 12:08:47 +0300
dctrl-tools (2.22.2) unstable; urgency=low
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 <argp.h>
#include <locale.h>
#include <stdlib.h>
+#include <wchar.h>
#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,
} else if (j > 0) {
fputs(args->delim, stdout);
}
- mblen(NULL, 0);
+ mbstate_t mbs;
+ memset(&mbs, 0, sizeof mbs);
size_t k;
size_t m = 0;
for (k = data[j].inx;
@@ -171,8 +174,9 @@ void print_line(struct arguments *args,
k++;
break;
}
- int n = mblen(data[j].wrapped + k,
- data[j].wrapped_len - k);
+ int n = mbrlen(data[j].wrapped + k,
+ data[j].wrapped_len - k,
+ &mbs);
for (int l = 0; l < n; l++) {
putchar(data[j].wrapped[k+l]);
}
@@ -344,7 +348,8 @@ static size_t mbs_len(char const *mbs, size_t n, char const *fname)
if (n == (size_t)(-1)) n = strlen(mbs);
size_t mlen = 0;
size_t len = 0;
- mblen(NULL, 0);
+ mbstate_t mbstate;
+ memset(&mbstate, 0, sizeof mbstate);
for (size_t k = 0; k < n;/**/) {
if (mbs[k] == '\n') {
if (len > mlen) mlen = len;
@@ -353,7 +358,7 @@ static size_t mbs_len(char const *mbs, size_t n, char const *fname)
continue;
}
len++;
- int delta = mblen(mbs + k, n - k);
+ int delta = mbrlen(mbs + k, n - k, &mbstate);
if (delta <= 0) {
message(L_IMPORTANT, fname,
_("bad multibyte character"));