SCP: More allow command files to contain UTF-8 data.
- Provide a sim_islower(), sim_isalpha(), sim_isprinit(), sim_isdigit(), sim_isgraph(), sim_isalnum() which make sure that the character being examined as an unsigned char.
This commit is contained in:
parent
b4dbb76bfc
commit
5f786a0de4
2 changed files with 61 additions and 25 deletions
70
scp.c
70
scp.c
|
@ -2878,7 +2878,7 @@ for (; *ip && (op < oend); ) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if ((*ip == '%') &&
|
if ((*ip == '%') &&
|
||||||
(isalnum(ip[1]) || (ip[1] == '*') || (ip[1] == '_'))) { /* sub? */
|
(sim_isalnum(ip[1]) || (ip[1] == '*') || (ip[1] == '_'))) {/* sub? */
|
||||||
if ((ip[1] >= '0') && (ip[1] <= ('9'))) { /* %n = sub */
|
if ((ip[1] >= '0') && (ip[1] <= ('9'))) { /* %n = sub */
|
||||||
ap = do_arg[ip[1] - '0'];
|
ap = do_arg[ip[1] - '0'];
|
||||||
for (i=0; i<ip[1] - '0'; ++i) /* make sure we're not past the list end */
|
for (i=0; i<ip[1] - '0'; ++i) /* make sure we're not past the list end */
|
||||||
|
@ -3317,7 +3317,7 @@ SEND *snd;
|
||||||
|
|
||||||
GET_SWITCHES (cptr); /* get switches */
|
GET_SWITCHES (cptr); /* get switches */
|
||||||
tptr = get_glyph (cptr, gbuf, ',');
|
tptr = get_glyph (cptr, gbuf, ',');
|
||||||
if (isalpha(gbuf[0]) && (strchr (gbuf, ':'))) {
|
if (sim_isalpha(gbuf[0]) && (strchr (gbuf, ':'))) {
|
||||||
r = tmxr_locate_line_send (gbuf, &snd);
|
r = tmxr_locate_line_send (gbuf, &snd);
|
||||||
if (r != SCPE_OK)
|
if (r != SCPE_OK)
|
||||||
return r;
|
return r;
|
||||||
|
@ -3370,7 +3370,7 @@ t_stat r;
|
||||||
SEND *snd;
|
SEND *snd;
|
||||||
|
|
||||||
tptr = get_glyph (cptr, gbuf, ',');
|
tptr = get_glyph (cptr, gbuf, ',');
|
||||||
if (isalpha(gbuf[0]) && (strchr (gbuf, ':'))) {
|
if (sim_isalpha(gbuf[0]) && (strchr (gbuf, ':'))) {
|
||||||
r = tmxr_locate_line_send (gbuf, &snd);
|
r = tmxr_locate_line_send (gbuf, &snd);
|
||||||
if (r != SCPE_OK)
|
if (r != SCPE_OK)
|
||||||
return r;
|
return r;
|
||||||
|
@ -3391,7 +3391,7 @@ EXPECT *exp;
|
||||||
|
|
||||||
GET_SWITCHES (cptr); /* get switches */
|
GET_SWITCHES (cptr); /* get switches */
|
||||||
tptr = get_glyph (cptr, gbuf, ',');
|
tptr = get_glyph (cptr, gbuf, ',');
|
||||||
if (isalpha(gbuf[0]) && (strchr (gbuf, ':'))) {
|
if (sim_isalpha(gbuf[0]) && (strchr (gbuf, ':'))) {
|
||||||
r = tmxr_locate_line_expect (gbuf, &exp);
|
r = tmxr_locate_line_expect (gbuf, &exp);
|
||||||
if (r != SCPE_OK)
|
if (r != SCPE_OK)
|
||||||
return r;
|
return r;
|
||||||
|
@ -3412,7 +3412,7 @@ t_stat r;
|
||||||
EXPECT *exp;
|
EXPECT *exp;
|
||||||
|
|
||||||
tptr = get_glyph (cptr, gbuf, ',');
|
tptr = get_glyph (cptr, gbuf, ',');
|
||||||
if (isalpha(gbuf[0]) && (strchr (gbuf, ':'))) {
|
if (sim_isalpha(gbuf[0]) && (strchr (gbuf, ':'))) {
|
||||||
r = tmxr_locate_line_expect (gbuf, &exp);
|
r = tmxr_locate_line_expect (gbuf, &exp);
|
||||||
if (r != SCPE_OK)
|
if (r != SCPE_OK)
|
||||||
return r;
|
return r;
|
||||||
|
@ -6876,7 +6876,7 @@ while ((*iptr != 0) &&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (islower (*iptr) && uc)
|
if (sim_islower (*iptr) && uc)
|
||||||
*optr = (char)toupper (*iptr);
|
*optr = (char)toupper (*iptr);
|
||||||
else *optr = *iptr;
|
else *optr = *iptr;
|
||||||
iptr++; optr++;
|
iptr++; optr++;
|
||||||
|
@ -6927,6 +6927,36 @@ int sim_isspace (char c)
|
||||||
return isspace ((unsigned char)c);
|
return isspace ((unsigned char)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sim_islower (char c)
|
||||||
|
{
|
||||||
|
return islower ((unsigned char)c);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sim_isalpha (char c)
|
||||||
|
{
|
||||||
|
return isalpha ((unsigned char)c);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sim_isprint (char c)
|
||||||
|
{
|
||||||
|
return isprint ((unsigned char)c);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sim_isdigit (char c)
|
||||||
|
{
|
||||||
|
return isdigit ((unsigned char)c);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sim_isgraph (char c)
|
||||||
|
{
|
||||||
|
return isgraph ((unsigned char)c);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sim_isalnum (char c)
|
||||||
|
{
|
||||||
|
return isalnum ((unsigned char)c);
|
||||||
|
}
|
||||||
|
|
||||||
/* get_yn yes/no question
|
/* get_yn yes/no question
|
||||||
|
|
||||||
Inputs:
|
Inputs:
|
||||||
|
@ -7237,7 +7267,7 @@ while (size--) {
|
||||||
if (quote == *iptr)
|
if (quote == *iptr)
|
||||||
*tptr++ = '\\';
|
*tptr++ = '\\';
|
||||||
default:
|
default:
|
||||||
if (isprint (*iptr))
|
if (sim_isprint (*iptr))
|
||||||
*tptr++ = *iptr;
|
*tptr++ = *iptr;
|
||||||
else {
|
else {
|
||||||
sprintf (tptr, "\\%03o", *iptr);
|
sprintf (tptr, "\\%03o", *iptr);
|
||||||
|
@ -7326,7 +7356,7 @@ for (i = 0; (dptr = sim_devices[i]) != NULL; i++) { /* base + unit#? */
|
||||||
((nptr = dptr->lname) &&
|
((nptr = dptr->lname) &&
|
||||||
(strncmp (cptr, nptr, strlen (nptr)) == 0)))) {
|
(strncmp (cptr, nptr, strlen (nptr)) == 0)))) {
|
||||||
tptr = cptr + strlen (nptr);
|
tptr = cptr + strlen (nptr);
|
||||||
if (isdigit (*tptr)) {
|
if (sim_isdigit (*tptr)) {
|
||||||
if (qdisable (dptr)) /* disabled? */
|
if (qdisable (dptr)) /* disabled? */
|
||||||
return NULL;
|
return NULL;
|
||||||
u = (uint32) get_uint (tptr, 10, dptr->numunits - 1, &r);
|
u = (uint32) get_uint (tptr, 10, dptr->numunits - 1, &r);
|
||||||
|
@ -7455,7 +7485,7 @@ if ((cptr == NULL) || (dptr == NULL) || (dptr->registers == NULL))
|
||||||
tptr = cptr;
|
tptr = cptr;
|
||||||
do {
|
do {
|
||||||
tptr++;
|
tptr++;
|
||||||
} while (isalnum (*tptr) || (*tptr == '*') || (*tptr == '_') || (*tptr == '.'));
|
} while (sim_isalnum (*tptr) || (*tptr == '*') || (*tptr == '_') || (*tptr == '.'));
|
||||||
slnt = tptr - cptr;
|
slnt = tptr - cptr;
|
||||||
for (rptr = dptr->registers; rptr->name != NULL; rptr++) {
|
for (rptr = dptr->registers; rptr->name != NULL; rptr++) {
|
||||||
if ((slnt == strlen (rptr->name)) &&
|
if ((slnt == strlen (rptr->name)) &&
|
||||||
|
@ -7485,7 +7515,7 @@ if (*cptr != '-')
|
||||||
return 0;
|
return 0;
|
||||||
sw = 0;
|
sw = 0;
|
||||||
for (cptr++; (sim_isspace (*cptr) == 0) && (*cptr != 0); cptr++) {
|
for (cptr++; (sim_isspace (*cptr) == 0) && (*cptr != 0); cptr++) {
|
||||||
if (isalpha (*cptr) == 0)
|
if (sim_isalpha (*cptr) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
sw = sw | SWMASK (toupper (*cptr));
|
sw = sw | SWMASK (toupper (*cptr));
|
||||||
}
|
}
|
||||||
|
@ -7879,10 +7909,10 @@ while (sim_isspace (*inptr)) /* bypass white spac
|
||||||
inptr++;
|
inptr++;
|
||||||
val = 0;
|
val = 0;
|
||||||
nodigit = 1;
|
nodigit = 1;
|
||||||
for (c = *inptr; isalnum(c); c = *++inptr) { /* loop through char */
|
for (c = *inptr; sim_isalnum(c); c = *++inptr) { /* loop through char */
|
||||||
if (islower (c))
|
if (sim_islower (c))
|
||||||
c = toupper (c);
|
c = toupper (c);
|
||||||
if (isdigit (c)) /* digit? */
|
if (sim_isdigit (c)) /* digit? */
|
||||||
digit = c - (uint32) '0';
|
digit = c - (uint32) '0';
|
||||||
else if (radix <= 10) /* stop if not expected */
|
else if (radix <= 10) /* stop if not expected */
|
||||||
break;
|
break;
|
||||||
|
@ -9227,7 +9257,7 @@ if (snd && (snd->extoff < snd->insoff)) { /* pending input charact
|
||||||
|
|
||||||
*stat = snd->buffer[snd->extoff++] | SCPE_KFLAG;/* get one */
|
*stat = snd->buffer[snd->extoff++] | SCPE_KFLAG;/* get one */
|
||||||
snd->next_time = sim_gtime() + snd->delay;
|
snd->next_time = sim_gtime() + snd->delay;
|
||||||
if (isgraph(*stat & 0xFF) || ((*stat & 0xFF) == ' '))
|
if (sim_isgraph(*stat & 0xFF) || ((*stat & 0xFF) == ' '))
|
||||||
sprintf (dstr, " '%c'", *stat & 0xFF);
|
sprintf (dstr, " '%c'", *stat & 0xFF);
|
||||||
sim_debug (snd->dbit, snd->dptr, "Byte value: 0x%02X%s injected\n", *stat & 0xFF, dstr);
|
sim_debug (snd->dbit, snd->dptr, "Byte value: 0x%02X%s injected\n", *stat & 0xFF, dstr);
|
||||||
}
|
}
|
||||||
|
@ -9675,7 +9705,7 @@ if (sim_deb && (dptr->dctrl & reason)) {
|
||||||
outbuf[oidx++] = ' ';
|
outbuf[oidx++] = ' ';
|
||||||
outbuf[oidx++] = hex[(data[i+sidx]>>4)&0xf];
|
outbuf[oidx++] = hex[(data[i+sidx]>>4)&0xf];
|
||||||
outbuf[oidx++] = hex[data[i+sidx]&0xf];
|
outbuf[oidx++] = hex[data[i+sidx]&0xf];
|
||||||
if (isprint (data[i+sidx]))
|
if (sim_isprint (data[i+sidx]))
|
||||||
strbuf[sidx] = data[i+sidx];
|
strbuf[sidx] = data[i+sidx];
|
||||||
else
|
else
|
||||||
strbuf[sidx] = '.';
|
strbuf[sidx] = '.';
|
||||||
|
@ -9859,9 +9889,9 @@ for (hblock = astrings; (htext = *hblock) != NULL; hblock++) {
|
||||||
appendText (topic, "+", 1);
|
appendText (topic, "+", 1);
|
||||||
break;
|
break;
|
||||||
default: /* Check for vararg # */
|
default: /* Check for vararg # */
|
||||||
if (isdigit (*htext)) {
|
if (sim_isdigit (*htext)) {
|
||||||
n = 0;
|
n = 0;
|
||||||
while (isdigit (*htext))
|
while (sim_isdigit (*htext))
|
||||||
n += (n * 10) + (*htext++ - '0');
|
n += (n * 10) + (*htext++ - '0');
|
||||||
if (( *htext != 'H' && *htext != 's') ||
|
if (( *htext != 'H' && *htext != 's') ||
|
||||||
n == 0 || n >= VSMAX)
|
n == 0 || n >= VSMAX)
|
||||||
|
@ -9908,14 +9938,14 @@ for (hblock = astrings; (htext = *hblock) != NULL; hblock++) {
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} /* topic text line */
|
} /* topic text line */
|
||||||
if (isdigit (*htext)) { /* Topic heading */
|
if (sim_isdigit (*htext)) { /* Topic heading */
|
||||||
TOPIC **children;
|
TOPIC **children;
|
||||||
TOPIC *newt;
|
TOPIC *newt;
|
||||||
char nbuf[100];
|
char nbuf[100];
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
start = htext;
|
start = htext;
|
||||||
while (isdigit (*htext))
|
while (sim_isdigit (*htext))
|
||||||
n += (n * 10) + (*htext++ - '0');
|
n += (n * 10) + (*htext++ - '0');
|
||||||
if ((htext == start) || !n) {
|
if ((htext == start) || !n) {
|
||||||
FAIL (SCPE_ARG, Invalid topic heading, htext);
|
FAIL (SCPE_ARG, Invalid topic heading, htext);
|
||||||
|
@ -9944,7 +9974,7 @@ for (hblock = astrings; (htext = *hblock) != NULL; hblock++) {
|
||||||
if (*start == '?') { /* Conditional topic? */
|
if (*start == '?') { /* Conditional topic? */
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
start++;
|
start++;
|
||||||
while (isdigit (*start)) /* Get param # */
|
while (sim_isdigit (*start)) /* Get param # */
|
||||||
n += (n * 10) + (*start++ - '0');
|
n += (n * 10) + (*start++ - '0');
|
||||||
if (!*start || *start == '\n'|| n == 0 || n >= VSMAX)
|
if (!*start || *start == '\n'|| n == 0 || n >= VSMAX)
|
||||||
FAIL (SCPE_ARG, Invalid parameter number, start);
|
FAIL (SCPE_ARG, Invalid parameter number, start);
|
||||||
|
|
6
scp.h
6
scp.h
|
@ -126,6 +126,12 @@ char *sim_dname (DEVICE *dptr);
|
||||||
char *sim_uname (UNIT *dptr);
|
char *sim_uname (UNIT *dptr);
|
||||||
t_stat get_yn (char *ques, t_stat deflt);
|
t_stat get_yn (char *ques, t_stat deflt);
|
||||||
int sim_isspace (char c);
|
int sim_isspace (char c);
|
||||||
|
int sim_islower (char c);
|
||||||
|
int sim_isalpha (char c);
|
||||||
|
int sim_isprint (char c);
|
||||||
|
int sim_isdigit (char c);
|
||||||
|
int sim_isgraph (char c);
|
||||||
|
int sim_isalnum (char c);
|
||||||
char *get_sim_opt (int32 opt, char *cptr, t_stat *st);
|
char *get_sim_opt (int32 opt, char *cptr, t_stat *st);
|
||||||
char *get_glyph (const char *iptr, char *optr, char mchar);
|
char *get_glyph (const char *iptr, char *optr, char mchar);
|
||||||
char *get_glyph_nc (const char *iptr, char *optr, char mchar);
|
char *get_glyph_nc (const char *iptr, char *optr, char mchar);
|
||||||
|
|
Loading…
Add table
Reference in a new issue