chiark / gitweb /
Prep v239: Uncomment header inclusions that are new or needed now.
[elogind.git] / src / basic / format-table.c
index fe7c351939e0018e74014d5f1b9c0094b40eecd2..6c079bf8d563c6fea96007da111953d77f688d07 100644 (file)
@@ -13,7 +13,7 @@
 //#include "terminal-util.h"
 //#include "time-util.h"
 //#include "utf8.h"
-//#include "util.h"
+#include "util.h"
 
 #define DEFAULT_WEIGHT 100
 
@@ -572,7 +572,7 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
                         break;
 
                 case TABLE_BOOLEAN:
-                        buffer.b = !!va_arg(ap, int);
+                        buffer.b = va_arg(ap, int);
                         data = &buffer.b;
                         break;
 
@@ -882,8 +882,8 @@ static int table_data_requested_width(TableData *d, size_t *ret) {
         return 0;
 }
 
-static char *align_string_mem(const char *str, size_t old_length, size_t new_length, unsigned percent) {
-        size_t w = 0, space, lspace;
+static char *align_string_mem(const char *str, size_t new_length, unsigned percent) {
+        size_t w = 0, space, lspace, old_length;
         const char *p;
         char *ret;
         size_t i;
@@ -893,8 +893,7 @@ static char *align_string_mem(const char *str, size_t old_length, size_t new_len
         assert(str);
         assert(percent <= 100);
 
-        if (old_length == (size_t) -1)
-                old_length = strlen(str);
+        old_length = strlen(str);
 
         /* Determine current width on screen */
         p = str;
@@ -1183,7 +1182,7 @@ int table_print(Table *t, FILE *f) {
                         } else if (l < width[j]) {
                                 /* Field is shorter than allocated space. Let's align with spaces */
 
-                                buffer = align_string_mem(field, (size_t) -1, width[j], d->align_percent);
+                                buffer = align_string_mem(field, width[j], d->align_percent);
                                 if (!buffer)
                                         return -ENOMEM;