Annotation of gforth/fixpath.fs, revision 1.9
1.5 pazsan 1: \ fix path in gforth*.exe
2:
1.9 ! anton 3: \ Copyright (C) 2000,2003,2006 Free Software Foundation, Inc.
1.5 pazsan 4:
5: \ This file is part of Gforth.
6:
7: \ Gforth is free software; you can redistribute it and/or
8: \ modify it under the terms of the GNU General Public License
9: \ as published by the Free Software Foundation; either version 2
10: \ of the License, or (at your option) any later version.
11:
12: \ This program is distributed in the hope that it will be useful,
13: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
14: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: \ GNU General Public License for more details.
16:
17: \ You should have received a copy of the GNU General Public License
18: \ along with this program; if not, write to the Free Software
19: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
20:
1.8 pazsan 21: ." Fixing " 2 arg type ." with " 1 arg type cr
1.5 pazsan 22:
1.8 pazsan 23: : "search s" .:/usr/local" ;
1.5 pazsan 24:
25: include string.fs
26:
1.8 pazsan 27: Variable path$ 1 arg path$ $!
28: Variable pathes$ 1 arg pathes$ $!
1.5 pazsan 29: Variable exe$
30:
1.8 pazsan 31: pathes$ 1 1 $del s" /cygdrive/" pathes$ 0 $ins
32: : fixpathes ( addr u -- )
33: bounds ?DO I c@ '\ = IF '/ I c! THEN LOOP ;
34: pathes$ $@ fixpathes
35: s" .:" pathes$ 0 $ins
36:
37: 0 Value #size
38: 0 Value #file
39: : fix-exe ( addr u -- )
40: path$ $@ exe$ $! s" /" exe$ $+! exe$ $+!
1.5 pazsan 41: exe$ $@ r/w bin open-file throw >r
1.8 pazsan 42: r@ file-size throw drop to #size
43: #size allocate throw to #file
44: #file #size r@ read-file throw drop
45: #file #size "search search 2drop #file -
1.5 pazsan 46: 0 r@ reposition-file throw
47: pathes$ $@ 2dup + 0 swap c! 1+ r@ write-file throw
48: r> close-file throw ;
49:
1.8 pazsan 50: 2 arg fix-exe
1.5 pazsan 51:
52: bye
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>