beta-0.89.2
[luatex.git] / source / texk / web2c / lib / chartostring.c
blob7b34e694241da219373353794a309cf5594697ea
1 /* chartostring.c: change a character (i.e., an integer) to a
2 one-character string.
4 Written in 1994 by Karl Berry. Public domain. */
6 #include <w2c/config.h>
7 #include "lib.h"
9 /* This is needed because web2c turns the Pascal construct 'x' into the
10 C character constant 'x', not the string "x". And we need to keep it
11 that way because that's how xord is initialized, etc. But sometimes
12 we want one-character strings -- e.g., in tangle.ch and weave.ch.
13 There's no real alternative to wasting the two bytes of memory (plus
14 malloc overhead) here, but it doesn't matter. */
16 string
17 chartostring (char ch)
19 string str = xmalloc (2);
20 str[0] = ch;
21 str[1] = 0;
22 return str;