lkml.org 
[lkml]   [1997]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Jive -> Kernel (International Linux)
On Sun, 19 Jan 1997, William Sowerbutts wrote:

> >isn't there an even easier way, though? something that uses the
> >pre-processor's ## operator, like this:
> >
> >/* begin example */
> >#define HELLO_generic "generic greeting"
> >#define HELLO_english "hello!"
> >#define HELLO_french "bonjour!"
> >#define HELLO_spanish "buenos dias!"
> >
> >#ifndef LANGUAGE
> >#define LANGUAGE _generic
> >#endif
> >
> >#define INTERNATIONAL(x) PREINTL2(x,LANG)
> >#define PREINTL2(x,y) PREINTL(x,y)
> >#define PREINTL(x,y) x##y
> >
> >printk(INTERNATIONAL(HELLO));
> >/* end example */
> >
> >then all you have to do is stick a -DLANGUAGE=_whatever in the arguments
> >to gcc when you compile the kernel. and yes, somebody has to provide all
> >the language specific strings, but like somebody else pointed out, that
> >can be done incrementally by means of patches.
>
> look at this code fragment:
>
> /* start ... */
> #define HELLO_generic "generic greeting"
> #define HELLO_english "hello!"
> #define HELLO_french "bonjour!"
>
> #define BYE_generic "generic goodbye"
> #define BYE_english "toodle pip"
>
> #define INTERNATIONAL(spam) PREINTL2(spam, LANGUAGE)
> #define PREINTL2(spam,jam) PREINTL(spam,jam)
> #define PREINTL(spatula,quake) spatula##quake
>
> void function(void)
> {
> printk(INTERNATIONAL(HELLO));
> printk(INTERNATIONAL(BYE));
> }
> /* ... end */
>
> okay. Now imagine we compile this with -DLANGUAGE=_english. Great, it all
> works, INTERNATIONAL(HELLO) expands to HELLO_english, INTERNATIONAL(BYE)
> expands to BYE_english.
>
> Now imagine we compile this with -DLANGUAGE=_french. INTERNATIONAL(HELLO)
> expands to HELLO_french, but INTERNATIONAL(BYE) expands BYE_french.
> BYE_french is undefined. Ooops. Well, this is what I want to see happen. If
> BYE_french is undefined, I want BYE_generic to be used in its place.
>
> So do we just add "#define BYE_french BYE_generic"? Well, what about when
> we want to add support for Elbonian? We'd have to trash through all the
> files, adding "#define BYE_elbonian BYE_generic" and so on for each and
> every message. Not a good prospect.
>
> There must be some clever way to do this with preprocessor directives, so
> that INTERNATIONAL(BYE) would expand to BYE_generic instead of BYE_french
> (in the given example), and also if LANGUAGE was defined as something that
> the kernel didn't know of. So saying -DLANGUAGE=_elbonain with a
> non-Elbonian capable kernel would just result in every message being _generic.

This is easy:
#define INTERNATIONAL(x) \PREINTL(x,LANGUAGE)
#define PREINTL(x,y) \
#ifndef x##y\
x##_generic\
#else\
x##y\
#endif

I'm not sure this would work, but it should if cpp is worth anything :).
What was the whole PREINTL2 step for, anyways?

> If we could get it to work with this primary-language and
> fallback-language, we could maybe insert one or two extra layers in
> between. So, for example, one could ask for kernel messages in German. If
> there was no German message, in French. If there was no German and no
> French, then the generic message.

This is insanity. :)

Greg Alexander
http://www.cia-g.com/~sietch/


\
 
 \ /
  Last update: 2005-03-22 13:38    [W:0.171 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site