Skip to content
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

Fix attr command #207

Merged
merged 1 commit into from
Jan 4, 2025
Merged

Fix attr command #207

merged 1 commit into from
Jan 4, 2025

Conversation

eduardocasino
Copy link
Contributor

I've found a couple of issues with the attr command that prevent it from working properly:

@@ -109,8 +109,6 @@ int main()
     while (r != 0xff)
     {
         DIRE* de = (DIRE*)cpm_default_dma + r;
-        if (de->rc == 0x80)
-            continue;

         if (modify)
         {

I don't really know what the intent was here, but this prevented attr to work with files with size > 16K and also froze in an infinite loop as r was no longer updated.

@@ -122,6 +120,10 @@ int main()

             de->us = dr; /* Convert to an FCB */
             cpm_set_file_attributes((FCB*)de);
+
+            /* cpm_set_file_attributes() resets directory index, so */
+            /* recover index for last file match */
+            cpm_findfirst((FCB*)de);
         }

         cpm_conout((de->f[8] & 0x80) ? 'R' : '-');

cpm_set_file_attributes() calls find_first/find_next, so the directory index ends messed up. If you tried to modifiy the attributes of a file, for example, it looped endlessly re-modifying the same file. Executing a find_first with the last modified file restores the dir index.

@davidgiven
Copy link
Owner

Thanks --- I think the intention n the first chunk was to skip dirents other than the last one, although the logic's all wrong. I can't immediately find any reference as to whether that's a correct assumption, so let's just update all dirents.

Regarding the second --- yes, that's clearly broken. I do wonder why nobody noticed until now!

Merging. Thanks again!

@davidgiven davidgiven closed this Dec 30, 2024
@eduardocasino
Copy link
Contributor Author

Seems that was closed without merging?

@davidgiven davidgiven reopened this Jan 1, 2025
@davidgiven davidgiven merged commit bf8dbb6 into davidgiven:master Jan 4, 2025
2 checks passed
@davidgiven
Copy link
Owner

Sorry, must have pushed the wrong button. Actually merging now.

@eduardocasino eduardocasino deleted the attr-fix branch January 4, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants