SCP: add generic length limted and case independent string for all platforms
This commit is contained in:
parent
9179c4ea07
commit
168d0d9c47
4 changed files with 14 additions and 10 deletions
12
scp.c
12
scp.c
|
@ -2123,7 +2123,7 @@ else if (*argv[0]) { /* sim name arg? */
|
|||
strncpy (nbuf + 1, argv[0], PATH_MAX + 1); /* copy sim name */
|
||||
if ((np = (char *)match_ext (nbuf, "EXE"))) /* remove .exe */
|
||||
*np = 0;
|
||||
sim_strlcat (nbuf, ".ini\"", sizeof(nbuf)); /* add .ini" */
|
||||
strlcat (nbuf, ".ini\"", sizeof(nbuf)); /* add .ini" */
|
||||
stat = do_cmd (-1, nbuf) & ~SCPE_NOMESSAGE; /* proc default cmd file */
|
||||
if (stat == SCPE_OPENERR) { /* didn't exist/can't open? */
|
||||
np = strrchr (nbuf, '/'); /* stript path and try again in cwd */
|
||||
|
@ -2916,8 +2916,8 @@ for (nargs = 0; nargs < 10; ) { /* extract arguments */
|
|||
if (do_arg [0] == NULL) /* need at least 1 */
|
||||
return SCPE_2FARG;
|
||||
if ((fpin = fopen (do_arg[0], "r")) == NULL) { /* file failed to open? */
|
||||
sim_strlcpy (cbuf, do_arg[0], sizeof (cbuf)); /* try again with .sim extension */
|
||||
sim_strlcat (cbuf, ".sim", sizeof (cbuf));
|
||||
strlcpy (cbuf, do_arg[0], sizeof (cbuf)); /* try again with .sim extension */
|
||||
strlcat (cbuf, ".sim", sizeof (cbuf));
|
||||
if ((fpin = fopen (cbuf, "r")) == NULL) { /* failed a second time? */
|
||||
if (flag == 0) /* cmd line file? */
|
||||
fprintf (stderr, "Can't open file %s\n", do_arg[0]);
|
||||
|
@ -5094,15 +5094,15 @@ sim_strlcpy (WildName, cptr, sizeof(WildName));
|
|||
cptr = WildName;
|
||||
sim_trim_endspc (WildName);
|
||||
if ((!stat (WildName, &filestat)) && (filestat.st_mode & S_IFDIR))
|
||||
sim_strlcat (WildName, "/*", sizeof(WildName));
|
||||
strlcat (WildName, "/*", sizeof(WildName));
|
||||
if ((*cptr != '/') || (0 == memcmp (cptr, "./", 2)) || (0 == memcmp (cptr, "../", 3))) {
|
||||
#if defined (VMS)
|
||||
getcwd (WholeName, sizeof(WholeName)-1, 0);
|
||||
#else
|
||||
getcwd (WholeName, sizeof(WholeName)-1);
|
||||
#endif
|
||||
sim_strlcat (WholeName, "/", sizeof(WholeName));
|
||||
sim_strlcat (WholeName, cptr, sizeof(WholeName));
|
||||
strlcat (WholeName, "/", sizeof(WholeName));
|
||||
strlcat (WholeName, cptr, sizeof(WholeName));
|
||||
sim_trim_endspc (WholeName);
|
||||
}
|
||||
else
|
||||
|
|
4
scp.h
4
scp.h
|
@ -160,6 +160,10 @@ int sim_strncasecmp (const char *string1, const char *string2, size_t len);
|
|||
int sim_strcasecmp (const char *string1, const char *string2);
|
||||
size_t sim_strlcat (char *dst, const char *src, size_t size);
|
||||
size_t sim_strlcpy (char *dst, const char *src, size_t size);
|
||||
#define strlcpy(dst, src, size) sim_strlcpy((dst), (src), (size))
|
||||
#define strlcat(dst, src, size) sim_strlcat((dst), (src), (size))
|
||||
#define strncasecmp(str1, str2, len) sim_strncasecmp((str1), (str2), (len))
|
||||
#define strcasecmp(str1, str2) sim_strcasecmp ((str1), (str2))
|
||||
CONST char *get_sim_opt (int32 opt, CONST char *cptr, t_stat *st);
|
||||
const char *put_switches (char *buf, size_t bufsize, uint32 sw);
|
||||
CONST char *get_glyph (const char *iptr, char *optr, char mchar);
|
||||
|
|
|
@ -861,7 +861,7 @@ CONST char *cptr;
|
|||
int32 saved_switches = sim_switches;
|
||||
t_stat stat;
|
||||
|
||||
sim_strlcpy (cbuf, sim_rem_command_buf, sizeof (cbuf));
|
||||
strlcpy (cbuf, sim_rem_command_buf, sizeof (cbuf));
|
||||
while (isspace(cbuf[0]))
|
||||
memmove (cbuf, cbuf+1, strlen(cbuf+1)+1); /* skip leading whitespace */
|
||||
sim_sub_args (cbuf, sizeof(cbuf), argv);
|
||||
|
@ -3598,8 +3598,8 @@ static t_stat sim_os_ttinit (void) {
|
|||
SIOUXSettings.toppixel = 42;
|
||||
SIOUXSettings.leftpixel = 6;
|
||||
iBeamCursorH = GetCursor(iBeamCursor);
|
||||
sim_strlcat(title, sim_name, sizeof(title));
|
||||
sim_strlcat(title, " Simulator", sizeof(title));
|
||||
strlcat(title, sim_name, sizeof(title));
|
||||
strlcat(title, " Simulator", sizeof(title));
|
||||
title[0] = strlen(title) - 1; /* Pascal string done */
|
||||
for (i = 0; i <= title[0]; i++) { /* copy to unsigned char */
|
||||
ptitle[i] = title[i];
|
||||
|
|
|
@ -1144,7 +1144,7 @@ int load_pcap(void) {
|
|||
char npcap_path[512] = "";
|
||||
|
||||
if (p_GetSystemDirectory (npcap_path, sizeof(npcap_path) - 7))
|
||||
sim_strlcat (npcap_path, "\\Npcap", sizeof(npcap_path));
|
||||
strlcat (npcap_path, "\\Npcap", sizeof(npcap_path));
|
||||
if (p_SetDllDirectory(npcap_path))
|
||||
hLib = LoadLibraryA(lib_name);
|
||||
p_SetDllDirectory (NULL);
|
||||
|
|
Loading…
Add table
Reference in a new issue