From 4e46a9170d841b22f68130aac73d64ffad4cd2aa Mon Sep 17 00:00:00 2001 From: CaS Date: Tue, 17 Sep 2002 09:22:45 +0000 Subject: [PATCH] bugfix source file location. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14471 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 ++++ Tools/AGSParser.m | 72 ++++++++++++++++++++++++++++++++++++++++++++--- Tools/autogsdoc.m | 7 ++++- 3 files changed, 79 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1db57fc35..0e0918a40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-09-16 Richard Frith-Macdonald + + * Tools/AGSParser.m: Bugfix ... look for source files more + intelligently. Try both current directory and relative to header. + 2002-09-16 Richard Frith-Macdonald * Source/NSFileManager.m: Basic/dummy implementations of new MacOS-X diff --git a/Tools/AGSParser.m b/Tools/AGSParser.m index ae4cac5d0..1b2baaa4c 100644 --- a/Tools/AGSParser.m +++ b/Tools/AGSParser.m @@ -787,11 +787,31 @@ fail: [source removeAllObjects]; if (isSource == NO) { + NSFileManager *mgr = [NSFileManager defaultManager]; + NSString *path; + [info setObject: fileName forKey: @"Header"]; [source removeAllObjects]; - [source addObject: - [[[fileName lastPathComponent] stringByDeletingPathExtension] - stringByAppendingPathExtension: @"m"]]; + + /** + * We initially assume that the location of a source file is the + * same as the header, but if there is no file at that location, + * we expect the source to be in the current directory instead. + */ + path = [fileName stringByDeletingPathExtension]; + path = [path stringByAppendingPathExtension: @"m"]; + if ([mgr isReadableFileAtPath: path] == NO) + { + path = [path lastPathComponent]; + if ([mgr isReadableFileAtPath: path] == NO) + { + path = nil; // No default source file found. + } + } + if (path != nil) + { + [source addObject: path]; + } } unitName = nil; itemName = nil; @@ -2617,7 +2637,51 @@ fail: if ([line length] > 0 && [source containsObject: line] == NO) { - [source addObject: line]; + NSFileManager *mgr; + + /* + * See if the path given exists, and add it to + * the list of source files parsed for this + * header. + */ + mgr = [NSFileManager defaultManager]; + if ([mgr isReadableFileAtPath: line] == NO) + { + if ([line isAbsolutePath] == YES) + { + [self log: @"AutogsdocSource: %@ not found!", + line]; + line = nil; + } + else + { + NSString *p; + + /* + * Try forming a path relative to the + * header file if the source file was not + * found in the specified location. + */ + p = [info objectForKey: @"Header"]; + p = [p stringByDeletingLastPathComponent]; + p = [p stringByAppendingPathComponent: line]; + if ([mgr isReadableFileAtPath: p] == NO) + { + [self log: @"AutogsdocSource: %@ not " + @"found (tried %@ too)!", + line, p]; + line = nil; + } + else + { + line = p; + } + } + } + if (line != nil) + { + [source addObject: line]; + } } i = NSMaxRange(r); r = NSMakeRange(i, commentLength - i); diff --git a/Tools/autogsdoc.m b/Tools/autogsdoc.m index 32fd43da2..93b94e416 100644 --- a/Tools/autogsdoc.m +++ b/Tools/autogsdoc.m @@ -58,7 +58,12 @@ making the assumption that each .h file processed uses a .m file of the same name. You may supply multiple AutogsdocSource: lines where a header file declares items which are defined in - multiple source files. + multiple source files.
+ If a file name is absolute, it is used just as supplied.
+ If on the other hand, it is a relative path, the software looks for + the source file first relative to the direcotory in which autogsdoc + is running and then, if not found there, relative to the directory + in which the header file is located. <abstract> An abstract of the content of the document ... placed in the head