From 57b093a99de9fcde85d75e8836b8af7244190657 Mon Sep 17 00:00:00 2001 From: Dave Brolley Date: Tue, 9 May 2006 18:24:22 +0000 Subject: [PATCH] 2006-05-09 Dave Brolley * utils.scm (dirname): New function. --- ChangeLog | 1 + utils.scm | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c72cdbe..648691c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/utils.scm b/utils.scm index 80312b0..c79f374 100644 --- a/utils.scm +++ b/utils.scm @@ -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. @@ -155,6 +155,15 @@ (->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) -- 2.43.5