1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
5 # ******************************************************************
8 # ******************************************************************
16 require VMS
::Filespec
;
17 import VMS
::Filespec
qw(unixpath);
20 unshift(@INC, getExecutePath
($0) . 'ChangeLogEditor');
22 require ChangeLogEdit
;
23 require EmailTranslator
;
25 # ************************************************************
27 # ************************************************************
35 if (defined $ENV{'PATH'}) {
36 foreach $part (split(/$envSep/, $ENV{'PATH'})) {
46 my($envSep) = ($^O
eq 'MSWin32' ?
';' : ':');
47 if (defined $ENV{'PATH'}) {
48 foreach $part (split(/$envSep/, $ENV{'PATH'})) {
67 if ($prog ne basename
($prog)) {
68 my($dir) = unixpath
( dirname
($prog) );
69 if ($prog =~ /^[\/\\]/) {
73 $loc = unixpath
(getcwd
()) . $dir;
77 $loc = unixpath
( dirname
(which
($prog)) );
81 $loc = unixpath
( getcwd
() );
84 if ($prog ne basename
($prog)) {
85 if ($prog =~ /^[\/\\]/ ||
86 $prog =~ /^[A-Za-z]:[\/\\]?
/) {
87 $loc = dirname
($prog);
90 $loc = getcwd
() . '/' . dirname
($prog);
94 $loc = dirname
(which
($prog));
111 sub getDefaultDomain
{
113 my($host) = hostname
();
116 ## First try the hostname
117 if ($host =~ /[^\.]+\.(.*)/) {
121 ## Next try the hosts file
122 my($hosts) = ($^O
eq 'MSWin32' ?
123 "$ENV{SystemRoot}/system32/drivers/etc/hosts" :
125 my($fh) = new FileHandle
();
126 if (open($fh, $hosts)) {
128 if (/$host\.([^\s]+)/) {
136 if (!defined $domain) {
137 ## Next try ipconfig on Windows
138 if ($^O
eq 'MSWin32') {
139 if (open($fh, 'ipconfig /all |')) {
141 if (/Primary\s+DNS\s+Suffix[^:]+:\s+(.*)/) {
144 elsif (/DNS\s+Suffix\s+Search[^:]+:\s+(.*)/) {
152 ## Try /etc/resolv.conf on UNIX
153 if (open($fh, '/etc/resolv.conf')) {
155 if (/search\s+(.*)/) {
172 my($base) = basename
($0);
176 print "Usage: $base [ChangeLog File] [user name] [email address]\n" .
177 " " . (' ' x
length($base)) . "[-d <dir1 dir2 ... dirN>]\n\n" .
178 " Uses cvs to determine which files are modified or added\n" .
179 " and generates a bare ChangeLog entry based on those files.\n" .
180 " This script should be run at the same directory level in\n" .
181 " which the ChangeLog exists. The entry is prepended to the\n" .
182 " existing ChangeLog.\n" .
184 " Email addresses are generated with a certain set of\n" .
185 " defaults and can be modified using various environment\n" .
186 " variables. By default email addresses are generated\n" .
187 " using the user last name followed by an underscore and\n" .
188 " the first initial of the user first name followed by the\n" .
191 " REPLYTO If this environment variable is set, the value\n" .
192 " is used as the email address.\n" .
193 " CL_USERNAME This environment variable is used to override\n" .
194 " the user name (obtained from the password file).\n" .
195 " CL_CHANGELOG_FILE This environment variable is used as the\n".
196 " [ChangeLog File] argument if none is given\n".
197 " on the command line.\n".
199 " The user name and email address can be passed as a parameter to\n" .
200 " this script. If either is not passed, then the script will try\n" .
201 " to determine it automatically.\n" .
203 " If -d is used, everything on the command line after it is\n" .
204 " considered a directory or file to be considered in the\n" .
205 " ChangeLog entry.\n";
210 # ************************************************************
212 # ************************************************************
220 foreach my $arg (@ARGV) {
224 elsif ($arg eq '-h') {
227 elsif ($arg eq '-d') {
230 elsif ($arg =~ /^\-/) {
231 usageAndExit
("Unrecognized parameter: $arg");
233 elsif (!defined $file) {
236 elsif (!defined $name) {
239 elsif (!defined $email) {
244 if (!defined $file) {
245 if (defined $ENV{CL_CHANGELOG_FILE
}) {
246 $file = $ENV{CL_CHANGELOG_FILE
};
252 if (!defined $name) {
254 if (defined $ENV{CL_USERNAME
}) {
255 $pwd[6] = $ENV{CL_USERNAME
};
258 if ($^O
eq 'MSWin32' || $^O
eq 'cygwin') {
269 if (!defined $email) {
270 my($trans) = new EmailTranslator
(getDefaultDomain
());
271 $email = $trans->translate($name);
274 my($editor) = new ChangeLogEdit
($name, $email);
275 my($status, $error, $unknown) = $editor->edit($file, @dirs);
277 if (defined $unknown) {
278 my(@uarray) = @
$unknown;
280 print "WARNING: The following files are unknown to the ",
281 "revision control system:\n";
282 foreach my $unk (@uarray) {
290 print "You are now ready to edit the $file.\n";
296 exit($status ?
0 : 1);