[parted-devel] [PATCH] Fix build failure (conflicting decl of strnlen) and clean up
Jim Meyering
jim at meyering.net
Thu May 31 07:12:09 UTC 2007
Otavio,
I know you said you'd get to this, but after pulling,
I found that it affects --disable-nls builds.
Fix build failure (conflicting decl of strnlen) and clean up
* parted/strlist.h: Include <config.h> first.
[!ENABLE_NLS]: Define wchar_t to char here, too, since we no
longer include "strlist.h" after the definition in table.c.
* parted/table.c: Include <wchar.h> and <string.h> unconditionally,
and before wchar_t redefinition.
Hoist inclusions of xalloc.h and strlist.h, too.
Remove wcwidth and strnlen declarations, since they're guaranteed
to be in the gnulib-supplied-if-needed headers.
Signed-off-by: Jim Meyering <jim at meyering.net>
---
parted/strlist.h | 12 +++++++++++-
parted/table.c | 11 ++++-------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/parted/strlist.h b/parted/strlist.h
index e458ba1..39efb4b 100644
--- a/parted/strlist.h
+++ b/parted/strlist.h
@@ -1,6 +1,6 @@
/*
parted - a frontend to libparted
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
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
@@ -20,8 +20,18 @@
#ifndef STRLIST_H_INCLUDED
#define STRLIST_H_INCLUDED
+#include <config.h>
+
#include <wchar.h>
+#ifndef ENABLE_NLS
+# define L_(str) str
+# ifdef wchar_t
+# undef wchar_t
+# endif
+# define wchar_t char
+#endif
+
typedef struct _StrList StrList;
struct _StrList {
StrList* next;
diff --git a/parted/table.c b/parted/table.c
index 1301549..3c2edf2 100644
--- a/parted/table.c
+++ b/parted/table.c
@@ -27,29 +27,26 @@
#include <stdlib.h>
#include <assert.h>
+#include <wchar.h>
+#include <string.h>
+#include "xalloc.h"
+#include "strlist.h"
#ifdef ENABLE_NLS
-# include <wchar.h>
- int wcswidth (const wchar_t *s, size_t n);
# define L_(str) L##str
#else
# define L_(str) str
# ifdef wchar_t
# undef wchar_t
# endif
-# include <string.h>
# define wchar_t char
# define wcslen strlen
# define wcswidth strnlen
# define wcscat strcat
# define wcsdup strdup
- size_t strnlen (const char *, size_t);
#endif
-#include "xalloc.h"
-#include "strlist.h"
-
static const unsigned int MAX_WIDTH = 512;
static const wchar_t* DELIMITER = L_(" ");
More information about the parted-devel
mailing list