blob: 4a296a38493b09c95fa6935f456484f0eb93d4c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/* sprt.c: */
#include <stdio.h>
#include "xtdio.h"
/* -------------------------------------------------------------------------
* Local Definitions:
*/
#define BUFSIZE 261
#define SFTY 5
/* sprt: this routine makes string characters all visible */
#ifdef __PROTOTYPE__
char *sprt(const char *s)
#else /* __PROTOTYPE__ */
char *sprt(s)
char *s;
#endif /* __PROTOTYPE__ */
{
static char buf1[BUFSIZE];
static char buf2[BUFSIZE];
static char buf3[BUFSIZE];
static char buf4[BUFSIZE];
char *b;
char *bend;
static char *buf = buf3;
int ic;
/* allows up to three sprt()s in one function call */
if(buf == buf1) buf= buf2;
else if(buf == buf2) buf= buf3;
else if(buf == buf3) buf= buf4;
else buf= buf1;
buf[0]= '\0';
bend = buf + BUFSIZE - SFTY;
if(s) for(b= buf; *s && b < bend; ++s, b+= strlen(b)) {
ic= (int) *s;
if(ic < 31) sprintf(b,"^%c",(char) (ic + 64));
else if(ic >= 128) sprintf(b,"~%3d",ic);
else {
*b = *s;
*(b+1)= '\0';
}
b+= strlen(b);
}
return buf;
}
/* --------------------------------------------------------------------- */
|