string 3 times; warning in string_table generator.
* of the GNU Lesser General Public License.
*/
-#ifndef _CHARCONV_H
-#define _CHARCONV_H
+#ifndef _CHARSET_CHARCONV_H
+#define _CHARSET_CHARCONV_H
struct conv_context {
$i = 256;
while ($i < $pstr) {
$w = $strval{$i};
+ if (length($w) > 3) {
+ print STDERR "Warning: Entries should have at most 3 characters, see charset/stk-charconv.c\n";
+ }
print length $w, ",";
foreach $x (unpack("C256", $w)) {
print " $x,";
#include "lib/mempool.h"
#include "charset/mp-charconv.h"
#include "charset/stk-charconv.h"
-#include <string.h>
byte *
mp_conv(struct mempool *mp, byte *s, uns in_cs, uns out_cs)
* (c) 2006 Pavel Charvat <pchar@ucw.cz>
*/
-#ifndef _MP_CHARCONV_H
-#define _MP_CHARCONV_H
+#ifndef _CHARSET_MP_CHARCONV_H
+#define _CHARSET_MP_CHARCONV_H
#include "lib/mempool.h"
#include "charset/charconv.h"
-byte *
-mp_conv(struct mempool *mp, byte *s, uns cs_in, uns cs_out);
+byte *mp_conv(struct mempool *mp, byte *s, uns cs_in, uns cs_out);
static inline byte *
mp_conv_to_utf8(struct mempool *mp, byte *s, uns cs_in)
c->source_end = s + l + 1;
/* Resulting string can be longer after the conversion.
- * The following constatnt must be at least 4 for conversion to UTF-8
+ * The following constant must be at least 3 for conversion to UTF-8
* and at least the maximum length of the strings in string_table for other charsets. */
- return 4 * l + 1;
+ return 3 * l + 1;
}
* (c) 2006 Pavel Charvat <pchar@ucw.cz>
*/
-#ifndef _STK_CHARCONV_H
-#define _STK_CHARCONV_H
+#ifndef _CHARSET_STK_CHARCONV_H
+#define _CHARSET_STK_CHARCONV_H
#include "charset/charconv.h"
#include <alloca.h>
+/* The following macros convert strings between given charsets (CONV_CHARSET_x).
+ * The resulting string is allocated on the stack with the exception of cs_in == cs_out,
+ * when the pointer to the input string is returned. */
+
#define stk_conv(s, cs_in, cs_out) \
({ struct conv_context _c; uns _l=stk_conv_internal(&_c, (s), (cs_in), (cs_out)); \
if (_l) { _c.dest=_c.dest_start=alloca(_l); _c.dest_end=_c.dest+_l; conv_run(&_c); } \
#define stk_conv_to_utf8(s, cs_in) stk_conv(s, cs_in, CONV_CHARSET_UTF8)
#define stk_conv_from_utf8(s, cs_out) stk_conv(s, CONV_CHARSET_UTF8, cs_out)
-uns stk_conv_internal(struct conv_context *, byte *, uns, uns);
+uns stk_conv_internal(struct conv_context *c, byte *s, uns cs_in, uns cs_out);
#endif
* of the GNU Lesser General Public License.
*/
-#ifndef _UNICAT_H
-#define _UNICAT_H
+#ifndef _CHARSET_UNICAT_H
+#define _CHARSET_UNICAT_H
extern const byte *_U_cat[];
extern const word *_U_upper[], *_U_lower[], *_U_unaccent[];