Debian Codegraph @

texk/web2c/lib/chartostring.c

raw
1 /* chartostring.c: change a character (i.e., an integer) to a
2 one-character string.
3
4 Written in 1994 by Karl Berry. Public domain. */
5
6 #include <w2c/config.h>
7 #include "lib.h"
8
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. */
15
16 string
17 chartostring (char ch)
18 {
19 string str = xmalloc (2);
20 str[0] = ch;
21 str[1] = 0;
22 return str;
23 }