summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fdisk/Makefile.am2
-rw-r--r--fdisk/fdisk.c17
2 files changed, 15 insertions, 4 deletions
diff --git a/fdisk/Makefile.am b/fdisk/Makefile.am
index 50f1dbe8..862fa016 100644
--- a/fdisk/Makefile.am
+++ b/fdisk/Makefile.am
@@ -3,7 +3,7 @@ include $(top_srcdir)/config/include-Makefile.am
EXTRA_DIST = README.fdisk README.cfdisk sfdisk.examples partitiontype.c
fdisk_common = i386_sys_types.c common.h gpt.c gpt.h \
- ../lib/blkdev.c ../lib/wholedisk.c
+ ../lib/blkdev.c ../lib/wholedisk.c ../lib/mbsalign.c
if LINUX
fdisk_common += ../lib/linux_version.c
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 09efd1cc..2a6d419f 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -25,6 +25,7 @@
#include "nls.h"
#include "blkdev.h"
#include "common.h"
+#include "mbsalign.h"
#include "fdisk.h"
#include "wholedisk.h"
@@ -568,9 +569,19 @@ void list_types(struct systypes *sys)
i = done = 0;
do {
- printf("%c%2x %-15.15s", i ? ' ' : '\n',
- sys[next].type, _(sys[next].name));
- next = last[i++] + done;
+ #define NAME_WIDTH 15
+ char name[NAME_WIDTH * MB_LEN_MAX];
+ size_t width = NAME_WIDTH;
+
+ printf("%c%2x ", i ? ' ' : '\n', sys[next].type);
+ size_t ret = mbsalign(_(sys[next].name), name, sizeof(name),
+ &width, MBS_ALIGN_LEFT, 0);
+ if (ret == (size_t)-1 || ret >= sizeof(name))
+ printf("%-15.15s", _(sys[next].name));
+ else
+ fputs(name, stdout);
+
+ next = last[i++] + done;
if (i > 3 || next >= last[i]) {
i = 0;
next = ++done;