mirror of
https://github.com/rcornwell/sims.git
synced 2026-04-17 08:41:20 +00:00
SCP: Updated to current.
This commit is contained in:
28
scp.c
28
scp.c
@@ -13119,8 +13119,6 @@ else {
|
||||
ep->match = match_buf;
|
||||
ep->size = match_size;
|
||||
}
|
||||
ep->match_pattern = (char *)malloc (strlen (match) + 1);
|
||||
strcpy (ep->match_pattern, match);
|
||||
if (ep->act) { /* replace old action? */
|
||||
free (ep->act); /* deallocate */
|
||||
ep->act = NULL; /* now no action */
|
||||
@@ -13243,6 +13241,7 @@ for (i=0; i < exp->size; i++) {
|
||||
if (ep->switches & EXP_TYP_REGEX) {
|
||||
#if defined (USE_REGEX)
|
||||
int *ovector = NULL;
|
||||
int ovector_elts;
|
||||
int rc;
|
||||
char *cbuf = (char *)exp->buf;
|
||||
static size_t sim_exp_match_sub_count = 0;
|
||||
@@ -13261,27 +13260,38 @@ for (i=0; i < exp->size; i++) {
|
||||
}
|
||||
}
|
||||
++regex_checks;
|
||||
ovector = (int *)malloc (3 * (ep->re_nsub + 1) * sizeof (*ovector));
|
||||
ovector_elts = 3 * (ep->re_nsub + 1);
|
||||
ovector = (int *)calloc ((size_t) ovector_elts, sizeof(*ovector));
|
||||
if (sim_deb && exp->dptr && (exp->dptr->dctrl & exp->dbit)) {
|
||||
char *estr = sim_encode_quoted_string (exp->buf, exp->buf_ins);
|
||||
sim_debug (exp->dbit, exp->dptr, "Checking String: %s\n", estr);
|
||||
sim_debug (exp->dbit, exp->dptr, "Against RegEx Match Rule: %s\n", ep->match_pattern);
|
||||
free (estr);
|
||||
}
|
||||
rc = pcre_exec (ep->regex, NULL, cbuf, exp->buf_ins, 0, PCRE_NOTBOL, ovector, 3 * (ep->re_nsub + 1));
|
||||
rc = pcre_exec (ep->regex, NULL, cbuf, exp->buf_ins, 0, PCRE_NOTBOL, ovector, ovector_elts);
|
||||
if (rc >= 0) {
|
||||
size_t j;
|
||||
char *buf = (char *)malloc (1 + exp->buf_ins);
|
||||
|
||||
for (j=0; j < (size_t)rc; j++) {
|
||||
char env_name[32];
|
||||
int end_offs = ovector[2 * j + 1], start_offs = ovector[2 * j];
|
||||
|
||||
sprintf (env_name, "_EXPECT_MATCH_GROUP_%d", (int)j);
|
||||
memcpy (buf, &cbuf[ovector[2 * j]], ovector[2 * j + 1] - ovector[2 * j]);
|
||||
buf[ovector[2 * j + 1] - ovector[2 * j]] = '\0';
|
||||
setenv (env_name, buf, 1); /* Make the match and substrings available as environment variables */
|
||||
sim_debug (exp->dbit, exp->dptr, "%s=%s\n", env_name, buf);
|
||||
}
|
||||
if (start_offs >= 0 && end_offs >= start_offs) {
|
||||
memcpy (buf, &cbuf[start_offs], end_offs - start_offs);
|
||||
buf[end_offs - start_offs] = '\0';
|
||||
setenv (env_name, buf, 1); /* Make the match and substrings available as environment variables */
|
||||
sim_debug (exp->dbit, exp->dptr, "%s=%s\n", env_name, buf);
|
||||
}
|
||||
else {
|
||||
/* Substring was not captured by regexp: remove from the environment
|
||||
* (unsetenv is local static -- doesn't actually remove the variable from
|
||||
* the environment, sets it to an empty string.) */
|
||||
sim_debug (exp->dbit, exp->dptr, "unsetenv %s\n", env_name);
|
||||
unsetenv(env_name);
|
||||
}
|
||||
}
|
||||
for (; j<sim_exp_match_sub_count; j++) {
|
||||
char env_name[32];
|
||||
|
||||
|
||||
12
sim_disk.c
12
sim_disk.c
@@ -3380,12 +3380,14 @@ if ((uptr->flags & UNIT_BUF) && (uptr->filebuf)) {
|
||||
sim_messagef (SCPE_OK, "%s: writing buffer to file: %s\n", sim_uname (uptr), uptr->filename);
|
||||
sim_disk_wrsect (uptr, 0, (uint8 *)uptr->filebuf, NULL, (cap + ctx->sector_size - 1) / ctx->sector_size);
|
||||
}
|
||||
if (uptr->flags & UNIT_MUSTBUF) { /* dyn alloc? */
|
||||
free (uptr->filebuf); /* free buffers */
|
||||
uptr->filebuf = NULL;
|
||||
free (uptr->filebuf2);
|
||||
uptr->filebuf2 = NULL;
|
||||
}
|
||||
uptr->flags = uptr->flags & ~UNIT_BUF;
|
||||
}
|
||||
free (uptr->filebuf); /* free buffers */
|
||||
uptr->filebuf = NULL;
|
||||
free (uptr->filebuf2);
|
||||
uptr->filebuf2 = NULL;
|
||||
|
||||
update_disk_footer (uptr); /* Update meta data if highwater has changed */
|
||||
|
||||
@@ -5756,7 +5758,7 @@ if (1) { /* CHS Calculation */
|
||||
cylinderTimesHeads = totalSectors / sectorsPerTrack;
|
||||
}
|
||||
}
|
||||
cylinders = cylinderTimesHeads / heads;
|
||||
cylinders = (totalSectors + sectorsPerTrack * heads - 1) / (sectorsPerTrack * heads);
|
||||
Footer.DiskGeometry = NtoHl ((cylinders<<16)|(heads<<8)|sectorsPerTrack);
|
||||
}
|
||||
Footer.Checksum = NtoHl (CalculateVhdFooterChecksum(&Footer, sizeof(Footer)));
|
||||
|
||||
@@ -1083,7 +1083,7 @@ do {
|
||||
sim_os_clock_resoluton_ms = clock_diff;
|
||||
clock_last = clock_now;
|
||||
} while (clock_now < clock_start + 100);
|
||||
if ((sim_idle_rate_ms != 0) && (sim_os_clock_resoluton_ms != 0))
|
||||
if ((sim_os_clock_resoluton_ms != 0) && (sim_idle_rate_ms >= sim_os_clock_resoluton_ms))
|
||||
sim_os_tick_hz = 1000/(sim_os_clock_resoluton_ms * (sim_idle_rate_ms/sim_os_clock_resoluton_ms));
|
||||
else {
|
||||
fprintf (stderr, "Can't properly determine host system clock capabilities.\n");
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
11-Jun-2013 MB First version
|
||||
*/
|
||||
|
||||
#if defined(HAVE_LIBPNG) && defined(USE_SIM_VIDEO) && defined(HAVE_LIBSDL)
|
||||
#include <png.h>
|
||||
#endif
|
||||
#include "sim_video.h"
|
||||
#include "scp.h"
|
||||
|
||||
@@ -148,7 +151,6 @@ static char tmp_key_name[40];
|
||||
* http://www.libpng.org/pub/png/src/libpng-LICENSE.txt
|
||||
*/
|
||||
#include <SDL.h>
|
||||
#include <png.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#define SUCCESS 0
|
||||
@@ -1812,10 +1814,12 @@ if (!vptr->vid_texture) {
|
||||
|
||||
vptr->vid_format = SDL_AllocFormat (SDL_PIXELFORMAT_ARGB8888);
|
||||
|
||||
#ifdef SDL_WINDOW_RESIZABLE
|
||||
if (vptr->vid_flags & SIM_VID_RESIZABLE) {
|
||||
SDL_SetWindowResizable(vptr->vid_window, SDL_TRUE);
|
||||
SDL_RenderSetIntegerScale(vptr->vid_renderer, SDL_TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_StopTextInput ();
|
||||
|
||||
@@ -2231,7 +2235,7 @@ return 0;
|
||||
const char *vid_version(void)
|
||||
{
|
||||
static char SDLVersion[160];
|
||||
SDL_version compiled, running;
|
||||
SDL_version compiled = { 0, }, running = { 0, };
|
||||
|
||||
SDL_GetVersion(&running);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user