version 1.36, 2011/04/29 22:18:12 |
version 1.40, 2011/05/01 08:38:56 |
|
|
#endif |
#endif |
|
|
#include <assert.h> |
#include <assert.h> |
|
#include <ctype.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
#include "chars.in" |
#include "chars.in" |
|
|
struct mchars { |
struct mchars { |
enum mcharst type; |
|
struct ln **htab; |
struct ln **htab; |
}; |
}; |
|
|
Line 72 mchars_free(struct mchars *arg) |
|
Line 72 mchars_free(struct mchars *arg) |
|
} |
} |
|
|
struct mchars * |
struct mchars * |
mchars_init(enum mcharst type) |
mchars_alloc(void) |
{ |
{ |
struct mchars *tab; |
struct mchars *tab; |
struct ln **htab; |
struct ln **htab; |
Line 103 mchars_init(enum mcharst type) |
|
Line 103 mchars_init(enum mcharst type) |
|
} |
} |
|
|
tab->htab = htab; |
tab->htab = htab; |
tab->type = type; |
|
return(tab); |
return(tab); |
} |
} |
|
|
Line 137 mchars_res2cp(struct mchars *arg, const char *p, size_ |
|
Line 136 mchars_res2cp(struct mchars *arg, const char *p, size_ |
|
return(ln->unicode); |
return(ln->unicode); |
} |
} |
|
|
|
|
/* |
/* |
* Numbered character to literal character, |
* Numbered character to literal character. |
* represented as a null-terminated string for additional safety. |
* This can only be a printable character (i.e., alnum, punct, space) so |
|
* prevent the character from ruining our state (backspace, newline, and |
|
* so on). |
*/ |
*/ |
const char * |
char |
mchars_num2char(const char *p, size_t sz) |
mchars_num2char(const char *p, size_t sz) |
{ |
{ |
int i; |
int i; |
static char c[2]; |
|
|
|
if (sz > 3) |
if (sz > 3) |
return(NULL); |
return('\0'); |
|
|
i = atoi(p); |
i = atoi(p); |
if (i < 0 || i > 255) |
return(isprint(i) ? (char)i : '\0'); |
return(NULL); |
|
c[0] = (char)i; |
|
c[1] = '\0'; |
|
return(c); |
|
} |
} |
|
|
|
|
/* |
/* |
* Special character to string array. |
* Special character to string array. |
*/ |
*/ |
Line 174 mchars_spec2str(struct mchars *arg, const char *p, siz |
|
Line 169 mchars_spec2str(struct mchars *arg, const char *p, siz |
|
*rsz = strlen(ln->ascii); |
*rsz = strlen(ln->ascii); |
return(ln->ascii); |
return(ln->ascii); |
} |
} |
|
|
|
|
/* |
/* |
* Reserved word to string array. |
* Reserved word to string array. |