-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FCB: Rename should support asterisk wildcards #42
Conversation
I added a tweak to see if you prefer the function this way? |
int i, afound; | ||
|
||
for (i = 0, afound = 0; i < len; i++) { | ||
if (p[i] == '*' || afound) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But does this properly handle, say, a*.b*
?
Or a*.bat*
?
I mean, you don't seem to be handling dot, which
may have a separate wildcard.
Also not sure if the cases like *a.*t
are valid?
I think the code should be if (p[i] == '*' || (afound && p[i] == ' ')) {
or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The page I linked to in the commit explains better, but essentially it's very simple and not rich like unix wildcards.
so
*a.b*
==> ???????.b??
a*.bat*
is illegal
*a.*t
-> ????????.???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no dot as the input is an FCB name (8+3 chars, no dot, no \0).
If you pass start and length, then why you need more |
I prefer the second commit now, as it reads better in the caller and will be useful for FCB delete too. Yep it's a freedos bug(or unimplemented feature), but I gave up reporting things as nobody is interested there. |
OK, please squash then. |
Yes it was a 'pick one' you like moment. As I changed my mind during the writing of the style question, seems obvious now 😄 |
Since DOS 3.0 the FCB rename function int21/17 supports asterisk wildcards. Add a function to expand the '*' into '?' to fill the remaining buffer. This expansion is very simple as described in the following article: https://blogs.msdn.microsoft.com/oldnewthing/20071217-00/?p=24143/ Just in case the article ever disappears, here's the salient part: 1/ Start with eleven spaces and the cursor at position 1. 2/ Read a character from the input. If the end of the input is reached, then stop. 3/ If the next character in the input is a dot, then set positions 9, 10, and 11 to spaces, move the cursor to position 9, and go back to step 2. 4/ If the next character in the input is an asterisk, then fill the rest of the pattern with question marks, move the cursor to position 12, and go back to step 2. (Yes, this is past the end of the pattern.) 5/ If the cursor is not at position 12, copy the input character to the cursor position and advance the cursor. 6/ Go to step 2.
UBYTE FcbRename(xfcb FAR * lpXfcb) | ||
{ | ||
rfcb FAR *lpRenameFcb; | ||
COUNT FcbDrive; | ||
UBYTE result = FCB_SUCCESS; | ||
void FAR *lpOldDta = dta; | ||
|
||
/* DOS 3.0+ allows * wildcards for rename */ | ||
rfcb FAR *trfcb = (rfcb FAR *)lpXfcb; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is such cast?
Are these structs compatible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the pointer passed into FcbRename should be an rfcb *
, but it's pushed through a generic parsing routine to get the first filename extracted as they are initially compatible. Later they cast it back to get to the second part of the structure. All pretty horrid if you ask me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seem to be the GetNameField()
in fcbfns.c,
which does similar to what you do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be operating with asciiz strings, we have 11 chars, no dot, and no terminator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be very generic: has nFieldSize
for
non-asciiz. And more importantly, it is called from
FcbParseFname()
, which, in turn, is called from
FcbRename()
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's all working then perhaps it's just the destination pattern that's not being expanded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bet.
Plus in this case you likely need to not only
expand, but also match with the from_name,
so that there no ? in the to_name at the end.
So could you please convert this to the bug-report |
Sure, I lost interest in fixing FreeDOS/FDPP stuff. Here's the test case source, and you'll need to assemble for each test with the fn1,fe1,fn2,fe2 updated accordingly as it doesn't handle command line args. .text
.code16
.globl _start16
_start16:
push %%cs
pop %%ds
movw $0x1700, %%ax
movw $fcb, %%dx
int $0x21
cmpb $0, %%al
je prsucc
prfail:
movw $failmsg, %%dx
jmp 1f
prsucc:
movw $succmsg, %%dx
1:
movb $0x9, %%ah
int $0x21
exit:
movb $0x4c, %%ah
int $0x21
fcb:
.byte 0 # 0 default drive
fn1:
.ascii "% -8s" # 8 bytes
fe1:
.ascii "% -3s" # 3 bytes
wk1:
.space 5
fn2:
.ascii "% -8s" # 8 bytes
fe2:
.ascii "% -3s" # 3 bytes
wk2:
.space 16
succmsg:
.ascii "Rename Operation Success$"
failmsg:
.ascii "Rename Operation Failed$" Test one:
Test two:
Test three:
Test Four:
|
How about attaching binaries? |
Okay, will do later. |
Preferably in a new ticket then. |
opened issue #44 to continue |
Not sure why you say "FreeDOS/FDPP |
I have a short attention span these days, and if I don't grok the code, or I find things otherwise awkward I move on. No offence intended regarding FDPP, I'm sure you are right. |
Well you can note the awkward code into wiki, |
Since DOS 3.0 the FCB rename function int21/17 supports asterisk
wildcards. Add a function to expand the '*' into '?' to fill the
remaining buffer.
This changes FDPP to behave the same as PC-DOS, MS-DOS and DR-DOS for both FAT and redirector based filesystems.
Style questions:
FcbExpandAsterisks()
, one with duplication inside the function, or two calls to function that handles filename and extension?