[Coco] Toolshed and RS-DOS filenames with spaces.

tim lindner tlindner at macmess.org
Fri Jan 30 00:29:36 EST 2015


Christopher R. Hawks <chawks at dls.net> wrote:

> decb copy "disk000.dsk,FIX 128.DOC" "FIX 128.DOC"

Chris, I tried to get this to work on Mac OS X and could not. If fact
after looking into the code I can't see how it works on Linux.

libdecb/libdecbopen.c/_decb_cmp() is broken when it comes to spaces in
filenames. I have a patch that makes it work.


diff -r c850a6e703b2 libdecb/libdecbopen.c
--- a/libdecb/libdecbopen.c Wed Jan 21 11:11:07 2015 -0600
+++ b/libdecb/libdecbopen.c Thu Jan 29 21:23:48 2015 -0800
@@ -445,12 +445,14 @@
    
    /* 1. Copy filename. */
    
-   while (*filename != ' ' && count++ < 8)
+   memcpy( p, filename, 8 );
+   p += 8;
+
+   while( *(p-1) == ' ' && count++ < 8)
    {
-       *(p++) = *(filename++);
+       p--;
    }
 
-
    /* 2. If an extension exists, add it. */
    
    if (ext[0] != ' ')




It copies all eight bytes of the file name, and then back tracks every
character until it hits a non-space character.

The previous code would do a forward search and stop on the first space.


-- 
tim lindner
tlindner at macmess.org                                              Bright


More information about the Coco mailing list