Scan for illegal characters in directory and file names after trimming to 8.3 rather than before. Fixes Hexx and maybe others that neglect the Z in ASCIIZ.
Coalesce free memory blocks before resizing a block in case it grows; coalesce after after resizing only if the block shrinks. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3895
This commit is contained in:
parent
f9c67101c7
commit
3c8a5bdc95
2 changed files with 25 additions and 25 deletions
|
@ -66,6 +66,7 @@ bool DOS_MakeName(char const * const name,char * const fullname,Bit8u * drive) {
|
|||
char tempdir[DOS_PATHLENGTH];
|
||||
char upname[DOS_PATHLENGTH];
|
||||
Bitu r,w;
|
||||
Bit8u c;
|
||||
*drive = DOS_GetDefaultDrive();
|
||||
/* First get the drive */
|
||||
if (name_int[1]==':') {
|
||||
|
@ -78,28 +79,11 @@ bool DOS_MakeName(char const * const name,char * const fullname,Bit8u * drive) {
|
|||
}
|
||||
r=0;w=0;
|
||||
while (name_int[r]!=0 && (r<DOS_PATHLENGTH)) {
|
||||
Bit8u c=name_int[r++];
|
||||
if ((c>='a') && (c<='z')) {upname[w++]=c-32;continue;}
|
||||
if ((c>='A') && (c<='Z')) {upname[w++]=c;continue;}
|
||||
if ((c>='0') && (c<='9')) {upname[w++]=c;continue;}
|
||||
switch (c) {
|
||||
case '/':
|
||||
upname[w++]='\\';
|
||||
break;
|
||||
case ' ': /* should be seperator */
|
||||
break;
|
||||
case '\\': case '$': case '#': case '@': case '(': case ')':
|
||||
case '!': case '%': case '{': case '}': case '`': case '~':
|
||||
case '_': case '-': case '.': case '*': case '?': case '&':
|
||||
case '\'': case '+': case '^': case 246: case 255: case 0xa0:
|
||||
case 0xe5: case 0xbd: case 0x9d:
|
||||
upname[w++]=c;
|
||||
break;
|
||||
default:
|
||||
LOG(LOG_FILES,LOG_NORMAL)("Makename encountered an illegal char %c hex:%X in %s!",c,c,name);
|
||||
DOS_SetError(DOSERR_PATH_NOT_FOUND);return false;
|
||||
break;
|
||||
}
|
||||
c=name_int[r++];
|
||||
if ((c>='a') && (c<='z')) c-=32;
|
||||
else if (c==' ') continue; /* should be separator */
|
||||
else if (c=='/') c='\\';
|
||||
upname[w++]=c;
|
||||
}
|
||||
while (r>0 && name_int[r-1]==' ') r--;
|
||||
if (r>=DOS_PATHLENGTH) { DOS_SetError(DOSERR_PATH_NOT_FOUND);return false; }
|
||||
|
@ -176,6 +160,24 @@ bool DOS_MakeName(char const * const name,char * const fullname,Bit8u * drive) {
|
|||
if((strlen(tempdir) - strlen(ext)) > 8) memmove(tempdir + 8, ext, 5);
|
||||
} else tempdir[8]=0;
|
||||
|
||||
for (Bitu i=0;i<strlen(tempdir);i++) {
|
||||
c=tempdir[i];
|
||||
if ((c>='A') && (c<='Z')) continue;
|
||||
if ((c>='0') && (c<='9')) continue;
|
||||
switch (c) {
|
||||
case '$': case '#': case '@': case '(': case ')':
|
||||
case '!': case '%': case '{': case '}': case '`': case '~':
|
||||
case '_': case '-': case '.': case '*': case '?': case '&':
|
||||
case '\'': case '+': case '^': case 246: case 255: case 0xa0:
|
||||
case 0xe5: case 0xbd: case 0x9d:
|
||||
break;
|
||||
default:
|
||||
LOG(LOG_FILES,LOG_NORMAL)("Makename encountered an illegal char %c hex:%X in %s!",c,c,name);
|
||||
DOS_SetError(DOSERR_PATH_NOT_FOUND);return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(fullname)+strlen(tempdir)>=DOS_PATHLENGTH) {
|
||||
DOS_SetError(DOSERR_PATH_NOT_FOUND);return false;
|
||||
}
|
||||
|
|
|
@ -227,12 +227,12 @@ bool DOS_ResizeMemory(Bit16u segment,Bit16u * blocks) {
|
|||
return false;
|
||||
}
|
||||
|
||||
DOS_CompressMemory();
|
||||
Bit16u total=mcb.GetSize();
|
||||
DOS_MCB mcb_next(segment+total);
|
||||
if (*blocks<=total) {
|
||||
if (GCC_UNLIKELY(*blocks==total)) {
|
||||
/* Nothing to do */
|
||||
DOS_CompressMemory();
|
||||
return true;
|
||||
}
|
||||
/* Shrinking MCB */
|
||||
|
@ -268,7 +268,6 @@ bool DOS_ResizeMemory(Bit16u segment,Bit16u * blocks) {
|
|||
mcb_next.SetPSPSeg(MCB_FREE);
|
||||
mcb.SetType(0x4d);
|
||||
mcb.SetPSPSeg(dos.psp());
|
||||
DOS_CompressMemory();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -281,7 +280,6 @@ bool DOS_ResizeMemory(Bit16u segment,Bit16u * blocks) {
|
|||
}
|
||||
mcb.SetSize(total);
|
||||
mcb.SetPSPSeg(dos.psp());
|
||||
DOS_CompressMemory();
|
||||
if (*blocks==total) return true; /* block fit exactly */
|
||||
|
||||
*blocks=total; /* return maximum */
|
||||
|
|
Loading…
Add table
Reference in a new issue