[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Add !HAVE_MBRTOWC fallbacks for mbchar, mbiter and mbuiter
From: |
Bruno Haible |
Subject: |
Re: [PATCH] Add !HAVE_MBRTOWC fallbacks for mbchar, mbiter and mbuiter |
Date: |
Sat, 17 Feb 2007 04:58:18 +0100 |
User-agent: |
KMail/1.5.4 |
Eric Blake wrote:
> > There are probably two uses of the mbchar, mbfile, mbiter, mbuiter modules:
> > (a) Use them only for MB_CUR_MAX > 1, and use simpler datatypes (just
> > 'char' and pointers) for MB_CUR_MAX = 1.
> > (b) Use them always.
>
> ... there are things to be aware of. ...
> the code didn't consistently stick with approach a) vs. b).
The macros I posted can often formulate the algorithm in such a way that it
can be instantiated twice: once for MB_CUR_MAX > 1, once for MB_CUR_MAX = 1,
_without_ code changes. In other words, if you write
/* Instantiate the code for MB_CUR_MAX > 1. */
#include "mbchar_multi.h"
#include "my-code.h"
#include "mbchar_undef.h"
/* Instantiate the code for MB_CUR_MAX = 1. */
#include "mbchar_8bit.h"
#include "my-code.h"
#include "mbchar_undef.h"
you get a multibyte version and a unibyte version of the code that are
consistent - because they share the same source code.
Bruno