SCP: Allow symbols (environment variables) to describe contain addresses

This allows:
   sim> SET ENV X=80004324
   sim> EXAMINE X
   80004324: xxxxxxxxxx
   sim> DEPOSIT X nnnnn
This commit is contained in:
Mark Pizzolato 2018-06-05 22:24:46 -07:00
parent f6f4fe6c3c
commit ce5c3f0ff5
2 changed files with 22 additions and 4 deletions

25
scp.c
View file

@ -3540,7 +3540,7 @@ return stat | SCPE_NOMESSAGE; /* suppress message sinc
*/ */
static const char * static const char *
_sim_get_env_special (const char *gbuf, char *rbuf, size_t rbuf_size) _sim_gen_env_uplowcase (const char *gbuf, char *rbuf, size_t rbuf_size)
{ {
const char *ap; const char *ap;
char tbuf[CBUFSIZE]; char tbuf[CBUFSIZE];
@ -3548,11 +3548,23 @@ char tbuf[CBUFSIZE];
ap = getenv(gbuf); /* first try using the literal name */ ap = getenv(gbuf); /* first try using the literal name */
if (!ap) { if (!ap) {
get_glyph (gbuf, tbuf, 0); /* now try using the upcased name */ get_glyph (gbuf, tbuf, 0); /* now try using the upcased name */
ap = getenv(tbuf); if (strcmp (gbuf, tbuf)) /* upcase different? */
ap = getenv(tbuf); /* lookup the upcase name */
} }
if (ap) /* environment variable found? */ if (ap) { /* environment variable found? */
strlcpy (rbuf, ap, rbuf_size); /* Return the environment value */ strlcpy (rbuf, ap, rbuf_size); /* Return the environment value */
else { /* otherwise, check for Special Names */ ap = rbuf;
}
return ap;
}
static const char *
_sim_get_env_special (const char *gbuf, char *rbuf, size_t rbuf_size)
{
const char *ap;
ap = _sim_gen_env_uplowcase (gbuf, rbuf, rbuf_size);/* Look for environment variable */
if (!ap) { /* no environment variable found? */
time_t now = (time_t)cmd_time.tv_sec; time_t now = (time_t)cmd_time.tv_sec;
struct tm *tmnow = localtime(&now); struct tm *tmnow = localtime(&now);
@ -7828,6 +7840,7 @@ t_stat exdep_cmd (int32 flag, CONST char *cptr)
char gbuf[CBUFSIZE]; char gbuf[CBUFSIZE];
CONST char *gptr; CONST char *gptr;
CONST char *tptr = NULL; CONST char *tptr = NULL;
const char *ap;
int32 opt; int32 opt;
t_addr low, high; t_addr low, high;
t_stat reason; t_stat reason;
@ -7900,6 +7913,10 @@ for (gptr = gbuf, reason = SCPE_OK;
continue; continue;
} }
if ((ap = getenv (gptr))) {
strlcpy (gbuf, ap, sizeof (gbuf));
gptr = gbuf;
}
tptr = get_range (sim_dfdev, gptr, &low, &high, sim_dfdev->aradix, tptr = get_range (sim_dfdev, gptr, &low, &high, sim_dfdev->aradix,
(((sim_dfunit->capac == 0) || (flag == EX_E))? 0: (((sim_dfunit->capac == 0) || (flag == EX_E))? 0:
sim_dfunit->capac - sim_dfdev->aincr), 0); sim_dfunit->capac - sim_dfdev->aincr), 0);

1
scp.h
View file

@ -246,6 +246,7 @@ CONST char *get_glyph_cmd (const char *iptr, char *optr);
t_value get_uint (const char *cptr, uint32 radix, t_value max, t_stat *status); t_value get_uint (const char *cptr, uint32 radix, t_value max, t_stat *status);
CONST char *get_range (DEVICE *dptr, CONST char *cptr, t_addr *lo, t_addr *hi, CONST char *get_range (DEVICE *dptr, CONST char *cptr, t_addr *lo, t_addr *hi,
uint32 rdx, t_addr max, char term); uint32 rdx, t_addr max, char term);
t_stat sim_set_environment (int32 flag, CONST char *cptr);
t_stat sim_decode_quoted_string (const char *iptr, uint8 *optr, uint32 *osize); t_stat sim_decode_quoted_string (const char *iptr, uint8 *optr, uint32 *osize);
char *sim_encode_quoted_string (const uint8 *iptr, uint32 size); char *sim_encode_quoted_string (const uint8 *iptr, uint32 size);
void fprint_buffer_string (FILE *st, const uint8 *buf, uint32 size); void fprint_buffer_string (FILE *st, const uint8 *buf, uint32 size);