OSDN Git Service

2006-05-09 Dave Brolley <brolley@redhat.com>
authorbrolley <brolley>
Tue, 9 May 2006 18:24:22 +0000 (18:24 +0000)
committerbrolley <brolley>
Tue, 9 May 2006 18:24:22 +0000 (18:24 +0000)
        * utils.scm (dirname): New function.

cgen/ChangeLog
cgen/utils.scm

index c72cdbe..648691c 100644 (file)
@@ -5,6 +5,7 @@
        * read.scm (include): Use arch-path as file location.
        (arch-path): Define it with a default setting.
        (-cgen): Update arch-path when "-a" option is specified.
+       * utils.scm (dirname): New function.
 
 2006-05-05  Steve Ellcey  <sje@cup.hp.com>
 
index 80312b0..c79f374 100644 (file)
@@ -1,5 +1,5 @@
 ; Generic Utilities.
-; Copyright (C) 2000-2005 Red Hat, Inc.
+; Copyright (C) 2000-2005, 2006 Red Hat, Inc.
 ; This file is part of CGEN.
 ; See file COPYING.CGEN for details.
 
                   (->string str))
 )
 
+; Return the directory name of the given file name
+
+(define (dirname s)
+  (let loop ((i (string-length s)))
+    (cond ((= i 0) "")
+         ((char=? #\/ (string-ref s (- i 1))) (substring s 0 i))
+         (else (loop (- i 1)))))
+)
+
 ; Turn STR into lowercase.
 
 (define (string-downcase str)