~ chicken-core (chicken-5) d642ec6c67dd16969a2add9f8f3fc63993338b4d


commit d642ec6c67dd16969a2add9f8f3fc63993338b4d
Author:     Kristian Lein-Mathisen <kristian@adellica.com>
AuthorDate: Sun Apr 29 12:57:44 2018 +0200
Commit:     Kooda <kooda@upyum.com>
CommitDate: Tue May 1 18:05:43 2018 +0200

    Check -L and -I for valid <DIR>
    
    In csc, you can pass -L<DIR> and -I<DIR> which will get passed on to
    the C compiler with the -L prefix, like this:
    
        csc -L/tmp/lib
    
    This is handy. However, -L and -I are overloaded to pass options to
    the C compiler that do not include the prefix, like this:
    
        csc -L -lpng
    
    In the first example, the compiler sees "-L/tmp/lib" and in the
    seconds it sees only "-lpng". This causes problems if second version
    is accidentally quoted, like this:
    
        csc "-L -lpng"
    
    Now C compiler will see "-L -lpng" which isn't an error but it should
    be. We rarely have library directories that are called " -lpng". This
    patch addresses that. If you actually have a library path that starts
    with space, you will have to do something like `csc "-L./ madness"`.
    
    Signed-off-by: Kooda <kooda@upyum.com>

diff --git a/csc.scm b/csc.scm
index b3d562ab..0cd62b7c 100644
--- a/csc.scm
+++ b/csc.scm
@@ -773,8 +773,12 @@ EOF
 		      [(and (> (string-length arg) 1)
 			    (char=? #\- (string-ref arg 0)) )
 		       (cond [(char=? #\L (string-ref arg 1))
+			      (when (char-whitespace? (string-ref arg 2))
+				    (error "bad -L argument, <DIR> starts with whitespace" arg))
  			      (set! link-options (append link-options (list arg))) ]
  			     [(char=? #\I (string-ref arg 1))
+			      (when (char-whitespace? (string-ref arg 2))
+				    (error "bad -I argument: <DIR> starts with whitespace" arg))
  			      (set! compile-options (append compile-options (list arg))) ]
 			     [(char=? #\D (string-ref arg 1))
 			      (t-options "-feature" (substring arg 2)) ]
Trap