public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* [patch][commit] Location of (include file)
@ 2006-05-09 16:23 Dave Brolley
  2006-05-09 18:22 ` Dave Brolley
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Brolley @ 2006-05-09 16:23 UTC (permalink / raw)
  To: cgen

[-- Attachment #1: Type: text/plain, Size: 463 bytes --]

Hi,

I've committed the attached patch. It causes cgen to look for included 
files in the same directory as specified by the -a option (i.e. same as 
the original input file). The previous behaviour was to look in 
$srcdir/cgen/cpu which is obviously not correct when processing files 
from $srcdir/cpu. If -a is not specified, then all files are obtained 
form $srcdir/cgen/cpu (unchanged from before).

Let me know if there are any problems or concerns.

Dave


[-- Attachment #2: cgen-include.ChangeLog --]
[-- Type: text/plain, Size: 210 bytes --]

2006-05-09  Dave Brolley  <brolley@redhat.com>

	* 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.


[-- Attachment #3: cgen-include.patch.txt --]
[-- Type: text/plain, Size: 1809 bytes --]

? cgen/string
Index: cgen/read.scm
===================================================================
RCS file: /cvs/src/src/cgen/read.scm,v
retrieving revision 1.11
diff -c -p -r1.11 read.scm
*** cgen/read.scm	15 Feb 2005 09:01:35 -0000	1.11
--- cgen/read.scm	9 May 2006 16:13:59 -0000
***************
*** 1,5 ****
  ; Top level file for reading and recording .cpu file contents.
! ; Copyright (C) 2000, 2001 Red Hat, Inc.
  ; This file is part of CGEN.
  ; See file COPYING.CGEN for details.
  
--- 1,5 ----
  ; Top level file for reading and recording .cpu file contents.
! ; Copyright (C) 2000, 2001, 2006 Red Hat, Inc.
  ; This file is part of CGEN.
  ; See file COPYING.CGEN for details.
  
*************** Define a preprocessor-style macro.
*** 781,788 ****
  ; .cpu file include mechanism
  
  (define (include file)
!   (logit 1 "Including file " file " ...\n")
!   (reader-read-file! (string-append srcdir "/cpu/" file))
    (logit 2 "Resuming previous file ...\n")
  )
  
--- 781,788 ----
  ; .cpu file include mechanism
  
  (define (include file)
!   (logit 1 "Including file " (string-append arch-path file) " ...\n")
!   (reader-read-file! (string-append arch-path file))
    (logit 2 "Resuming previous file ...\n")
  )
  
*************** Define a preprocessor-style macro.
*** 994,999 ****
--- 994,1001 ----
      )
  )
  
+ (define arch-path (string-append srcdir "/cpu/"))
+ 
  ; Accessors for application option specs
  (define (opt-get-first-pass opt)
    (or (list-ref opt 3) (lambda args #f)))
*************** Define a preprocessor-style macro.
*** 1072,1077 ****
--- 1074,1080 ----
  	      (else
  	       (cond ((str=? "-a" (car opt))
  		      (set! arch-file arg)
+ 		      (set! arch-path (dirname arg))
  		      )
  		     ((str=? "-b" (car opt))
  		      (set! debugging #t)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch][commit] Location of (include file)
  2006-05-09 16:23 [patch][commit] Location of (include file) Dave Brolley
@ 2006-05-09 18:22 ` Dave Brolley
  2006-05-09 22:01   ` Thien-Thi Nguyen
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Brolley @ 2006-05-09 18:22 UTC (permalink / raw)
  To: cgen

[-- Attachment #1: Type: text/plain, Size: 71 bytes --]

Forgot to include this part which also goes with this patch....

Dave


[-- Attachment #2: cgen-include2.ChangeLog --]
[-- Type: text/plain, Size: 87 bytes --]

2006-05-09  Dave Brolley  <brolley@redhat.com>

	* utils.scm (dirname): New function.


[-- Attachment #3: cgen-include2.patch.txt --]
[-- Type: text/plain, Size: 985 bytes --]

Index: cgen/utils.scm
===================================================================
RCS file: /cvs/src/src/cgen/utils.scm,v
retrieving revision 1.18
diff -c -p -r1.18 utils.scm
*** cgen/utils.scm	15 Jun 2005 21:28:19 -0000	1.18
--- cgen/utils.scm	9 May 2006 18:19:54 -0000
***************
*** 1,5 ****
  ; Generic Utilities.
! ; Copyright (C) 2000-2005 Red Hat, Inc.
  ; This file is part of CGEN.
  ; See file COPYING.CGEN for details.
  
--- 1,5 ----
  ; Generic Utilities.
! ; Copyright (C) 2000-2005, 2006 Red Hat, Inc.
  ; This file is part of CGEN.
  ; See file COPYING.CGEN for details.
  
***************
*** 155,160 ****
--- 155,169 ----
  		   (->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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch][commit] Location of (include file)
  2006-05-09 18:22 ` Dave Brolley
@ 2006-05-09 22:01   ` Thien-Thi Nguyen
  2006-05-10 16:27     ` Dave Brolley
  0 siblings, 1 reply; 4+ messages in thread
From: Thien-Thi Nguyen @ 2006-05-09 22:01 UTC (permalink / raw)
  To: brolley; +Cc: cgen

   From: Dave Brolley <brolley@redhat.com>
   Date: Tue, 09 May 2006 14:22:02 -0400

   + ; 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)))))
   + )
   + 

guile> (version)
"1.4.1.107"
guile> (dirname "/etc/hosts")
"/etc"
guile> dirname
#<primitive-procedure dirname>

thi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch][commit] Location of (include file)
  2006-05-09 22:01   ` Thien-Thi Nguyen
@ 2006-05-10 16:27     ` Dave Brolley
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Brolley @ 2006-05-10 16:27 UTC (permalink / raw)
  To: ttn; +Cc: cgen

[-- Attachment #1: Type: text/plain, Size: 572 bytes --]

Thanks! I've commit the attached correction.

Dave

Thien-Thi Nguyen wrote:

>   From: Dave Brolley <brolley@redhat.com>
>   Date: Tue, 09 May 2006 14:22:02 -0400
>
>   + ; 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)))))
>   + )
>   + 
>
>guile> (version)
>"1.4.1.107"
>guile> (dirname "/etc/hosts")
>"/etc"
>guile> dirname
>#<primitive-procedure dirname>
>
>thi
>  
>

[-- Attachment #2: cgen-include3.ChangeLog --]
[-- Type: text/plain, Size: 167 bytes --]

2006-05-10  Dave Brolley  <brolley@redhat.com>

	* read.scm (-cgen): Add trailing "/" to arch-path.
	* utils.scm (dirname): Removed. dirname is a primitive function.


[-- Attachment #3: cgen-include3.patch.txt --]
[-- Type: text/plain, Size: 1462 bytes --]

? cgen/string
Index: cgen/read.scm
===================================================================
RCS file: /cvs/src/src/cgen/read.scm,v
retrieving revision 1.12
diff -c -p -r1.12 read.scm
*** cgen/read.scm	9 May 2006 16:17:07 -0000	1.12
--- cgen/read.scm	10 May 2006 16:22:08 -0000
*************** Define a preprocessor-style macro.
*** 1074,1080 ****
  	      (else
  	       (cond ((str=? "-a" (car opt))
  		      (set! arch-file arg)
! 		      (set! arch-path (dirname arg))
  		      )
  		     ((str=? "-b" (car opt))
  		      (set! debugging #t)
--- 1074,1080 ----
  	      (else
  	       (cond ((str=? "-a" (car opt))
  		      (set! arch-file arg)
! 		      (set! arch-path (string-append (dirname arg) "/"))
  		      )
  		     ((str=? "-b" (car opt))
  		      (set! debugging #t)
Index: cgen/utils.scm
===================================================================
RCS file: /cvs/src/src/cgen/utils.scm,v
retrieving revision 1.19
diff -c -p -r1.19 utils.scm
*** cgen/utils.scm	9 May 2006 18:24:22 -0000	1.19
--- cgen/utils.scm	10 May 2006 16:22:08 -0000
***************
*** 155,169 ****
  		   (->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)
--- 155,160 ----

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-05-10 16:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-09 16:23 [patch][commit] Location of (include file) Dave Brolley
2006-05-09 18:22 ` Dave Brolley
2006-05-09 22:01   ` Thien-Thi Nguyen
2006-05-10 16:27     ` Dave Brolley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).