autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: awk for config headers


From: Paul Eggert
Subject: Re: awk for config headers
Date: Mon, 01 Oct 2007 16:40:47 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Thanks for taking this on.  It looks like you'll need another version
of that patch, so I'll just report some minor issues I discovered by
code inspection.

Ralf Wildenhues <address@hidden> writes:

> +  for (key in P) P_is_set[key] = 1

I don't see why this is necessary.  P[x] is either empty (which counts
as false), or is a value that counts as true.  So we should be able
to dispense with P_is_set, and use "if (P[x])" rather than
"if (P_is_set[x])"

I assume D_is_set is necessary because the macro value might be
0 or the empty string.

> +  split(line, arg, " ")
> +  if (arg[1] == "#") {
> +    defundef = arg[2] ""
> +    mac1 = arg[3] ""
> +  } else if (substr(arg[1], 1, 1) == "#") {
> +    defundef = substr(arg[1], 2)
> +    mac1 = arg[2] ""
> +  } else {
> +    mac1 = ""
> +  }

The 'split' doesn't need to be done unless the line starts with '#'.

I don't see why one needs to concatenate the empty string to values;
this is done several times in the code.

> +}
> +macro != "" && (defundef == "define" || defundef == "undef") {

This is a bit confusing.  Why not omit the "}" and put the test
in an "if"?

> +    if (P_is_set[macro])
> +      macro = macro "" P[macro]

This can be simply "macro = macro P[macro]", no?

> +    # Decompose white space to preserve indentation:
> +    split(line, ws1, "#")
> +    split(ws1[2], ws2, "u")
> +    split(ws2[1], ws3, "d")
> +    line = ws1[1] "#" ws3[1] "define " macro " " value

Sorry, I'm a bit lost with this sequence.  Is there some simpler way
to express what's going on?  It seems a bit weird to split on "u", for
example.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]