From 2a7108b96e7bd599971feeda4bc362b16ec19328 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 29 Mar 2019 12:45:39 +0100 Subject: [PATCH] Fix multiple values for -fdbg-cnt. 2019-03-29 Martin Liska * dbgcnt.c (dbg_cnt_process_single_pair): Fix GNU coding style. (dbg_cnt_process_opt): Parse first tokens aas dbg_cnt_process_single_pair is also using strtok. From-SVN: r270014 --- gcc/ChangeLog | 6 ++++++ gcc/dbgcnt.c | 25 +++++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 155d208961b..7f6b8a5cd32 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-03-29 Martin Liska + + * dbgcnt.c (dbg_cnt_process_single_pair): Fix GNU coding style. + (dbg_cnt_process_opt): Parse first tokens aas + dbg_cnt_process_single_pair is also using strtok. + 2019-03-29 Jakub Jelinek PR rtl-optimization/87485 diff --git a/gcc/dbgcnt.c b/gcc/dbgcnt.c index ebaa310821c..e2f65f449e5 100644 --- a/gcc/dbgcnt.c +++ b/gcc/dbgcnt.c @@ -151,30 +151,35 @@ dbg_cnt_process_single_pair (const char *arg) high = strtol (value2, NULL, 10); } - return dbg_cnt_set_limit_by_name (name, low, high); + return dbg_cnt_set_limit_by_name (name, low, high); } void dbg_cnt_process_opt (const char *arg) { char *str = xstrdup (arg); - const char *next = strtok (str, ","); unsigned int start = 0; - do { - if (!dbg_cnt_process_single_pair (arg)) + auto_vec tokens; + for (const char *next = strtok (str, ","); next != NULL; + next = strtok (NULL, ",")) + tokens.safe_push (next); + + unsigned i; + for (i = 0; i < tokens.length (); i++) + { + if (!dbg_cnt_process_single_pair (tokens[i])) break; - start += strlen (arg) + 1; - next = strtok (NULL, ","); - } while (next != NULL); + start += strlen (tokens[i]) + 1; + } - if (next != NULL) + if (i != tokens.length ()) { char *buffer = XALLOCAVEC (char, start + 2); sprintf (buffer, "%*c", start + 1, '^'); error ("cannot find a valid counter:value pair:"); - error ("%<-fdbg-cnt=%s%>", next); - error (" %s", buffer); + error ("%<-fdbg-cnt=%s%>", arg); + error (" %s", buffer); } } -- 2.30.2