pcp
[Top] [All Lists]

Re: [pcp] pcp updates: pmcpp

To: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Subject: Re: [pcp] pcp updates: pmcpp
From: Lukas Berk <lberk@xxxxxxxxxx>
Date: Mon, 27 Jul 2015 11:40:09 -0400
Cc: pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <55B2DEE0.8080809@xxxxxxxxxxxxxxxx> (Ken McDonell's message of "Sat, 25 Jul 2015 10:57:04 +1000")
References: <55B2DEE0.8080809@xxxxxxxxxxxxxxxx>
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
Hi Ken,

Ken McDonell <kenj@xxxxxxxxxxxxxxxx> writes:
> commit c54724b797851bf9f9a81691f2dc615000764c13
> Author: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
> Date:   Fri Jul 24 10:08:18 2015 +1000
>
>     pmcpp: major revamp
>     
>     Add -s flag to support shell-like input where # is a comment
>     prefix and pmcpp changes from #... control lines to %25... control
>     lines and generally emits fewer empty lines and on # lineno control
>     lines.
>     
>     Add -r flag to restrict macro expansion to names that have additional
>     syntactic sugar: #name or #{name} (or if -s%2C then %25name or %{name}).
>     
>     Cleanup man page.
>     
>     Add new qa/853 to give pmcpp a more thorough workout.
>     
>     All of this is in preparation for always processing pmlogger config
>     files with pmcpp -rs to provide conditional%2C include file and macro
>     capabilities for pmlogger config files.

I believe this broke compilation for me on my fedora 22 box (gcc appears
to use gnu11 by default for C code).  Specifically the use of 'restrict'
keyword is causing problems.

Would the attached patch work for you? (I'll post it with a few other
pmcollectl patches I have locally later today in a pcp updates email if
so).

Cheers,

Lukas

commit 5bc89f1e8de8239388839eb636e8fe45314b0401
Author: Lukas Berk <lberk@xxxxxxxxxx>
Date:   Mon Jul 27 11:36:11 2015 -0400

    Rename the restrict variable to avoid clash with the C99 keyword.

diff --git a/src/pmcpp/pmcpp.c b/src/pmcpp/pmcpp.c
index 17d0fcf..d9abf13 100644
--- a/src/pmcpp/pmcpp.c
+++ b/src/pmcpp/pmcpp.c
@@ -96,7 +96,7 @@ static char   ctl = '#';
 static int     in_if = IF_NONE;        /* #if... control */
 static int     if_lineno;              /* lineno of last #if... */
 
-static int     restrict = 0;           /* 1 if -r on the command line */
+static int     _restrict = 0;          /* 1 if -r on the command line */
 
 static void err(const char *, ...) __attribute__((noreturn));
 
@@ -346,7 +346,7 @@ do_macro(void)
      */
 
     /* get to the start of the first possible macro name */
-    if (restrict) {
+    if (_restrict) {
        while (*ip && *ip != ctl) {
            if (sub)
                *op++ = *ip;
@@ -369,7 +369,7 @@ do_macro(void)
        if (ip == tp)
            /* skip first character of token */
            tok_end = 0;
-       else if (restrict) {
+       else if (_restrict) {
            if (ip == &tp[1]) {
                /* second character could be { or start of name */
                if (*ip == '{' || isalnum(*ip))
@@ -412,7 +412,7 @@ do_macro(void)
                int             tlen = len;
                char            *token = tp;
                if (debug) printf("<<name=\"%*.*s\"\n", len, len, tp);
-               if (restrict) {
+               if (_restrict) {
                    if (len < 2) {
                        /*
                         * single % or # and not alpha|underscore and not {
@@ -480,7 +480,7 @@ do_macro(void)
                }
            }
            /* get to the start of the next possible macro name */
-           if (restrict) {
+           if (_restrict) {
                while (*ip && *ip != ctl) {
                    if (sub)
                        *op++ = *ip;
@@ -590,7 +590,7 @@ main(int argc, char **argv)
 
        case 'r':       /* restrict macro expansion to #name or #{name} or */
                        /* with -s, %name or %{name} */
-          restrict = 1;
+          _restrict = 1;
           break;
 
        case 's':       /* input text style is shell, not C */
@@ -806,7 +806,7 @@ more:
                /* expect other pmcpp control ... */
                skip_if_false = directive();
                if (skip_if_false == -1) {
-                   if (restrict) {
+                   if (_restrict) {
                        /*
                         * could be a macro expansion request, e.g. #foo
                         * or #{foo} or * %foo or %{foo} ... charge on
<Prev in Thread] Current Thread [Next in Thread>