tech-toolchain archive

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

Re: bmake: variable modifiers in SysV include



    Date:        Tue, 3 Apr 2018 20:47:56 +0000 (UTC)
    From:        christos%astron.com@localhost (Christos Zoulas)
    Message-ID:  <pa0p9s$itn$1%blaine.gmane.org@localhost>


  | +static Boolean
  | +IsSysVInclude(const char *line)
  | +{
  | +	size_t o = line[0] == 's' || line[0] == '-' ? 1 : 0;

Is there some reason a var that is only ever 0 or 1 needs to
be a size_t ?   It should be const.

(It could also be just:
	const int o = line[0] == 's' || line [0] == '-';
though I know some people really dislike using C like this for
some bizarre reason -- it is the way it is defined to work, and it
is simpler and easier to follow.)

  | +	if (strncmp(line + o, "include", 7) != 0)
  | +		return FALSE;
  | +	if (!isspace((unsigned char) line[7 + o]))
  | +		return FALSE;

And could the magic 7 go away?

	static const char include[] = "include";

and use "sizeof include - 1" (probably via a #define, or
another const int)?

(And of couse use this instead of the string "include" in
the strncmp.)

kre



Home | Main Index | Thread Index | Old Index