[Freeciv-Dev] Re: [PATCH] Names in rulesets. (PR#559)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On 12 Sep 2000, gs234@xxxxxxxxx (Gaute B. Strokkenes) wrote:
> David Pfitzner <dwp@xxxxxxxxxxxxxx> writes:
> > One thing I don't like about this is that it uses the constant
> > MAX_LEN_NAME unrelated to name. That is, it only works for
> > MAX_LEN_NAME strings, but would be rather easy to accidently use
> > for different-size strings as well.
>
> Not really. Firstly, it's static, so it's only available in
> ruleset.c. Secondly, the name 'check_name' is intended to be mnemonic
> (name -> NAME.) Thirdly, the error message doesn't make sense if the
> limit is something other than MAX_LEN_NAME.
Well, consider the suggestion made in relation to the nation name
grammar patch, for having some fields be MAX_LEN_NAME_LONG. By
"hardwiring" MAX_LEN_NAME, your patch does not deal nicely with this
sort of possibility. We might not end up using MAX_LEN_NAME_LONG, but
the point remains that you are making the inflexible assumption that
all "name" strings will be MAX_LEN_NAME, which might not be
permanently valid.
> > #define sz_check_name(name) check_name((name), sizeof(name))
>
> I'm not sure how useful that would be. If you've already copied it
> into a fixed-size buffer, it had better be big enough.
Uh, right. I think what I really want is a version of mystrlcpy/
sz_strlcpy (and maybe friends) which prints a log message on
truncation. (Though I know not all of the truncations involved
in your patch use strcpy.)
-- David
[Freeciv-Dev] Re: [PATCH] Names in rulesets. (PR#559), Gaute B. Strokkenes, 2000/09/12
[Freeciv-Dev] Re: [PATCH] Names in rulesets. (PR#559), Gaute B. Strokkenes, 2000/09/14
|
|