From 2c76290addf7e9927d740dc71ba7a3e03dd40328 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 20 Mar 2004 18:52:33 +0000 Subject: Fix a bug arising when you added a port which should have been at the end of /Makefile, and ended up at the begining Approved by: will --- Tools/scripts/addport | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'Tools/scripts') diff --git a/Tools/scripts/addport b/Tools/scripts/addport index e1a06c417695..a5605d0789b8 100755 --- a/Tools/scripts/addport +++ b/Tools/scripts/addport @@ -307,15 +307,22 @@ foreach my $thisdir (@dirs) { # now let's insert it my $cmd; - if ($port eq "") { + if (scalar @ports == 0) { # there were no previous SUBDIR += lines, so we're going to # put ourselves after the last comment (we can't be after a # .include for example). my $lastcommentnum = &lastcomment; $cmd = "$lastcommentnum\n+\ni\n"; } else { - # OK, append ourselves in the right place, so things *stay* sorted. - $cmd = "/^ SUBDIR += $port/\ni\n"; + if ($port eq "") { + # there were previous SUBDIR lines, but none was greater than we are, + # means, we're the last port, so, add ourselves after the last port + $port = $ports[$#ports]; + $cmd = "/^ SUBDIR += $port/\na\n"; + } else { + # OK, append ourselves in the right place, so things *stay* sorted. + $cmd = "/^ SUBDIR += $port/\ni\n"; + } } print "Inserting new port into $category/Makefile...\n"; open(ED, "|ed Makefile") || die "Cannot start ed to actually insert module\n"; -- cgit