Re: [AD] Figuring out the language from the environment variable LANG |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Thursday 23 January 2003 8:09 pm, you wrote:
> I always forget about 'its'. Let's see this variation:
>
> install_allegro automatically calls this function, and if you have an
> environment variable named LANG, its first two letters will be used to
> set the system language.
Sounds perfect.
> > + if ((env_lang = getenv("LANG")) && env_lang[0] && env_lang[1]) {
> > + char lang[3] = "en";
> >
> > Kill the "3".
>
> Any particular reason? Specifying size is safer and -pedantic
> allows it. Or I could delete the asignment and later put the NULL
> terminator manually, I guess that would generate less assembler
> and static memory.
Does -pedantic not allow it if you lose the '3'? The idea of removing the '3'
is to let the compiler decide how much space the string needs, and yes it
will include the null terminator. (Incidentally don't call it a NULL
terminator. NUL terminator is fine, as is null terminator. But NULL is a
pointer ;)
The 3 is just another number that could go wrong. It's right in this case
(obviously), but the more often you do it ... well you know what human error
is like :)
> Hehe, letters firts two say would yoda. I trust Ben, his domain
> name ends with .uk, and they have Rowan Atkinson.
Splendidly funny chap, wouldn't you say? :)
> > + AL_CONST char *ext, *datafile;
> > + char filename[1024], *namecpy = ustrdup(name);
> >
> > Don't mix char[] and char* variables.
>
> Why? It's funny...
Don't make me quote from DUMB's source code ... urge to quote - rising ...
dst[s] += (((int)(((LONG_LONG)((int)(((LONG_LONG)((int)(((LONG_LONG)a *
src_subpos) >> 15) + b) * src_subpos) >> 15) + c) * src_subpos) >> 15) +
x[1]) * volume_fact) >> 14; \
Ben