From 52e9f6f63b74db2a6a1d67524851649b18794950 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Sat, 2 Jun 2018 02:32:25 +0200 Subject: able to print percentage its now possible to have percentage before and after a variable. except for the date. But percentage with dates does not make much sense to me, so i skipped it. --- src/print_load.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/print_load.c') diff --git a/src/print_load.c b/src/print_load.c index 6da2519..e0ba677 100644 --- a/src/print_load.c +++ b/src/print_load.c @@ -29,21 +29,21 @@ void print_load(yajl_gen json_gen, char *buffer, const char *format, const char for (walk = selected_format; *walk != '\0'; walk++) { if (*walk != '%') { *(outwalk++) = *walk; - continue; - } - if (BEGINS_WITH(walk + 1, "1min")) { + + } else if (BEGINS_WITH(walk + 1, "1min")) { outwalk += sprintf(outwalk, "%1.2f", loadavg[0]); walk += strlen("1min"); - } - if (BEGINS_WITH(walk + 1, "5min")) { + } else if (BEGINS_WITH(walk + 1, "5min")) { outwalk += sprintf(outwalk, "%1.2f", loadavg[1]); walk += strlen("5min"); - } - if (BEGINS_WITH(walk + 1, "15min")) { + } else if (BEGINS_WITH(walk + 1, "15min")) { outwalk += sprintf(outwalk, "%1.2f", loadavg[2]); walk += strlen("15min"); + + } else { + *(outwalk++) = '%'; } } -- cgit v1.2.3