From b0f23c27ee07b3d418d7b535d99a1b080a99b5e4 Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Thu, 5 Dec 2013 08:45:20 +0000
Subject: [PATCH] - Fix alignment for arrays

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4602 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 common/utils/itti_analyzer/libparser/array_type.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/common/utils/itti_analyzer/libparser/array_type.c b/common/utils/itti_analyzer/libparser/array_type.c
index 87c9c2afd21..8235024fa75 100644
--- a/common/utils/itti_analyzer/libparser/array_type.c
+++ b/common/utils/itti_analyzer/libparser/array_type.c
@@ -4,6 +4,8 @@
 #include <string.h>
 #include <ctype.h>
 
+#include <tgmath.h>
+
 #define G_LOG_DOMAIN ("PARSER")
 
 #include "array_type.h"
@@ -34,6 +36,7 @@ int array_dissect_from_buffer(
         int zero_counter = 0;
         gboolean is_string = FALSE;
         char *string;
+        int nb_digits = 0;
 
         /* Factorizes trailing 0 */
         if ((items > 1) && (type_child->type == TYPE_FUNDAMENTAL))
@@ -87,9 +90,11 @@ int array_dissect_from_buffer(
 
         if (is_string == FALSE)
         {
+            nb_digits = log10(items - zero_counter) + 1;
+
             for (i = 0; i < (items - zero_counter); i++)
             {
-                INDENTED_STRING(cbuf, indent, length = sprintf(cbuf, "[%d] ", i));
+                INDENTED_STRING(cbuf, indent, length = sprintf(cbuf, "[%*d] ", nb_digits, i));
                 ui_set_signal_text_cb(user_data, cbuf, length);
 
                 type->child->type_dissect_from_buffer (
-- 
GitLab