[plt-scheme] "Create Executable" chooses bad default executable name

From: Evan Farrer (evan.farrer at gmail.com)
Date: Tue Jan 23 10:58:31 EST 2007

There seems to be a design issue with the "Create Executable" dialog box.  If I create a module in a file called 'hello.scm' and then open the "Create Executable" dialog box the default name for the executable is 'hello.scm' which if accepted will clober the source.  There appears to be a function in collects/drscheme/private/unit.ss called 'basename' that was inteded to be used to fix this issue, but it doesn't appear to be called from anywhere (and it appeared to be broken) the attached patch.  Fixes up the basename function and calls it when initializing the "Create Executable" dialog box so I don't have to worry about clobbering my source ;)

The problem and fix both seem so trivial that I suspect that there are some lurking issues that I'm ignorant about.  If this is the case feel free to drop this patch on the floor.  

Thanks to the PLT team for the great work.

Evan Farrer

http://www.cs.utah.edu/~farrer/

-------------- next part --------------
Index: collects/drscheme/private/unit.ss
===================================================================
--- collects/drscheme/private/unit.ss	(revision 5434)
+++ collects/drscheme/private/unit.ss	(working copy)
@@ -247,14 +247,16 @@
       
       (define (basename fn)
         (if fn
-            (let* ([file-name (mzlib:file:file-name-from-path fn)]
-                   [ext (mzlib:file:filename-extension file-name)])
-              (if ext
-                  (substring file-name 0 (- (string-length file-name)
-                                            (string-length ext)
-                                            1))
-                  file-name))
-            #f))
+          (let* ([file-name (mzlib:file:file-name-from-path fn)]
+                 [ext (mzlib:file:filename-extension file-name)]
+                 [file-bytes (path->bytes file-name)])
+            (if ext
+              (bytes->path
+                (subbytes file-bytes 0 (- (bytes-length file-bytes)
+                                          (bytes-length ext)
+                                          1)))
+              fn))
+          #f))
       
       ;; create-executable : (instanceof drscheme:unit:frame<%>) -> void
       (define (create-executable frame)
@@ -279,7 +281,7 @@
                        create-executable
                        (drscheme:language-configuration:language-settings-settings settings)
                        frame
-                       program-filename
+                       (basename program-filename)
                        (send (send frame get-interactions-text) get-user-teachpack-cache))))])))
       
       (define make-execute-bitmap 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20070123/3c448c3b/attachment.sig>

Posted on the users mailing list.