From 4f7da73885934a052425fc71861b0c9922c2122f Mon Sep 17 00:00:00 2001 From: Mats Date: Tue, 11 Mar 2014 20:15:36 +0100 Subject: Unify use of string comparisons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * strncmp(s1, s2, strlen(s2)) → BEGINS_WITH(s1, s2) * strncmp(s1, s2, strlen(s1)) → strcmp(s1, s2) * Prefer case-insensitive comparison for options --- src/print_run_watch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/print_run_watch.c') diff --git a/src/print_run_watch.c b/src/print_run_watch.c index 893e2cd..bc0d6dc 100644 --- a/src/print_run_watch.c +++ b/src/print_run_watch.c @@ -19,10 +19,10 @@ void print_run_watch(yajl_gen json_gen, char *buffer, const char *title, const c continue; } - if (strncmp(walk+1, "title", strlen("title")) == 0) { + if (BEGINS_WITH(walk+1, "title")) { outwalk += sprintf(outwalk, "%s", title); walk += strlen("title"); - } else if (strncmp(walk+1, "status", strlen("status")) == 0) { + } else if (BEGINS_WITH(walk+1, "status")) { outwalk += sprintf(outwalk, "%s", (running ? "yes" : "no")); walk += strlen("status"); } -- cgit v1.2.3