From f9c0169901b31e82e12ace126753fdd6b1511f39 Mon Sep 17 00:00:00 2001 From: cnfn Date: Wed, 14 Dec 2016 02:32:31 +0800 Subject: fix: cannot get all governors because the file of scaling_available_governors has a n in the line end --- getgov.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/getgov.c b/getgov.c index 462b188..01bedb4 100644 --- a/getgov.c +++ b/getgov.c @@ -24,15 +24,10 @@ void gg_init() memset(gov_string, '\0', sizeof(gov_string) ); gg_available(i, gov_string, sizeof(gov_string) ); - char* curr = gov_string; - char* end_of_curr = g_strstr_len(curr, strlen(curr), " "); - while (end_of_curr) - { + char** list = g_strsplit(g_strstrip(gov_string), " ", -1); + for (char** name = list; *name; ++name) { memset(governors[i][total_governors], '\0', 13); /* FIXME magic */ - memmove(governors[i][total_governors], curr, end_of_curr - curr); - - curr = end_of_curr+1; - end_of_curr = g_strstr_len(curr, strlen(curr), " "); + memmove(governors[i][total_governors], *name, strlen(*name)); total_governors++; } } -- cgit v1.1