diff options
92 files changed, 8889 insertions, 4930 deletions
diff --git a/gnu/usr.bin/cvs/contrib/README b/gnu/usr.bin/cvs/contrib/README index 412be26..8d90180 100644 --- a/gnu/usr.bin/cvs/contrib/README +++ b/gnu/usr.bin/cvs/contrib/README @@ -1,4 +1,4 @@ -@(#)README 1.8 92/04/10 +$CVSid: @(#)README 1.12 94/09/25 $ This "contrib" directory is a place holder for code/scripts sent to me by contributors around the world. This READM file will be kept @@ -66,3 +66,22 @@ Contents of this directory: $CVSROOT/CVSROOT/history file, as it can grow quite large after extended use. Contributed by David G. Grubbs <dgg@ksr.com> + sccs2rcs A C-shell script that can convert (some) SCCS files + into RCS files, retaining the info contained in the + SCCS file (like dates, author, and log message). + Contributed by Ken Cox <kenstir@viewlogic.com>. + intro.doc A user's view of what you need to know to get + started with CVS. + Contributed by <Steven.Pemberton@cwi.nl>. + rcs2sccs A shell script to convert simple RCS files into + SCCS files, originally gleaned off the network + somewhere (originally by "kenc") and modified by + Jerry Jelinek <jerry@rmtc.Central.Sun.COM> and + Brian Berliner <berliner@sun.com> to increase + robustness and add support for one-level of branches. + rcs2log A shell script to create a ChangeLog-format file + given only a set of RCS files. + Contributed by Paul Eggert <eggert@twinsun.com>. + clmerge A perl script to handle merge conflicts in GNU + style ChangeLog files . + Contributed by Tom Tromey <tromey@busco.lanl.gov>. diff --git a/gnu/usr.bin/cvs/contrib/cln_hist.pl b/gnu/usr.bin/cvs/contrib/cln_hist.pl index b353edc..534863d 100644 --- a/gnu/usr.bin/cvs/contrib/cln_hist.pl +++ b/gnu/usr.bin/cvs/contrib/cln_hist.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -- # -*-Perl-*- # -# cln_hist.pl,v 1.1 1992/04/10 03:04:15 berliner Exp +# $Id: cln_hist.pl,v 1.1 1992/04/10 03:04:15 berliner Exp $ # Contributed by David G. Grubbs <dgg@ksr.com> # # Clean up the history file. 10 Record types: MAR OFT WUCG diff --git a/gnu/usr.bin/cvs/contrib/cvs_acls.pl b/gnu/usr.bin/cvs/contrib/cvs_acls.pl index 1a0096a..2a3b0d9 100644 --- a/gnu/usr.bin/cvs/contrib/cvs_acls.pl +++ b/gnu/usr.bin/cvs/contrib/cvs_acls.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -- # -*-Perl-*- # -# cvs_acls.pl,v 1.2 1992/04/11 16:01:24 berliner Exp +# $Id: cvs_acls.pl,v 1.2 1992/04/11 16:01:24 berliner Exp $ # # Access control lists for CVS. dgg@ksr.com (David G. Grubbs) # diff --git a/gnu/usr.bin/cvs/contrib/cvscheck b/gnu/usr.bin/cvs/contrib/cvscheck index 67fdbbd..1c66688 100644 --- a/gnu/usr.bin/cvs/contrib/cvscheck +++ b/gnu/usr.bin/cvs/contrib/cvscheck @@ -1,5 +1,5 @@ #! /bin/sh -# cvscheck,v 1.2 1992/04/10 03:04:19 berliner Exp +# $Id: cvscheck,v 1.2 1992/04/10 03:04:19 berliner Exp $ # # cvscheck - identify files added, changed, or removed # in CVS working directory diff --git a/gnu/usr.bin/cvs/contrib/cvscheck.man b/gnu/usr.bin/cvs/contrib/cvscheck.man index 10d47f5..84d7db7 100644 --- a/gnu/usr.bin/cvs/contrib/cvscheck.man +++ b/gnu/usr.bin/cvs/contrib/cvscheck.man @@ -1,4 +1,4 @@ -.\" cvscheck.man,v 1.1 1992/04/10 03:04:20 berliner Exp +.\" $Id: cvscheck.man,v 1.1 1992/04/10 03:04:20 berliner Exp $ .\" Contributed by Lowell Skoog <fluke!lowell@uunet.uu.net> .TH CVSCHECK LOCAL "4 March 1991" FLUKE .SH NAME diff --git a/gnu/usr.bin/cvs/contrib/cvshelp.man b/gnu/usr.bin/cvs/contrib/cvshelp.man index a7128a8..ba6590a 100644 --- a/gnu/usr.bin/cvs/contrib/cvshelp.man +++ b/gnu/usr.bin/cvs/contrib/cvshelp.man @@ -1,4 +1,4 @@ -.\" cvshelp.man,v 1.1 1992/04/10 03:04:21 berliner Exp +.\" $Id: cvshelp.man,v 1.1 1992/04/10 03:04:21 berliner Exp $ .\" Contributed by Lowell Skoog <fluke!lowell@uunet.uu.net> .\" Full space in nroff; half space in troff .de SP diff --git a/gnu/usr.bin/cvs/contrib/descend b/gnu/usr.bin/cvs/contrib/descend index b63e4a7..999c46f 100644 --- a/gnu/usr.bin/cvs/contrib/descend +++ b/gnu/usr.bin/cvs/contrib/descend @@ -1,5 +1,5 @@ #! /bin/sh -# descend,v 1.1 1992/04/03 05:22:52 berliner Exp +# $Id: descend,v 1.1 1992/04/03 05:22:52 berliner Exp $ # # descend - walk down a directory tree and execute a command at each node diff --git a/gnu/usr.bin/cvs/contrib/descend.man b/gnu/usr.bin/cvs/contrib/descend.man index adeab3b..a38d4ca 100644 --- a/gnu/usr.bin/cvs/contrib/descend.man +++ b/gnu/usr.bin/cvs/contrib/descend.man @@ -1,4 +1,4 @@ -.\" descend.man,v 1.1 1992/04/03 05:22:53 berliner Exp +.\" $Id: descend.man,v 1.1 1992/04/03 05:22:53 berliner Exp $ .TH DESCEND 1 "31 March 1992" .SH NAME descend \- walk directory tree and execute a command at each node diff --git a/gnu/usr.bin/cvs/contrib/easy-import.perl b/gnu/usr.bin/cvs/contrib/easy-import.perl index d7716b5..59d407a 100644 --- a/gnu/usr.bin/cvs/contrib/easy-import.perl +++ b/gnu/usr.bin/cvs/contrib/easy-import.perl @@ -1,7 +1,7 @@ #!/usr/bin/perl # # Support for importing a source collection into CVS. -# Trys to prevent the user from the most common pitfalls (like creating +# Tries to prevent the user from the most common pitfalls (like creating # new top-level repositories or second-level areas accidentally), and # cares to do some of the `dirty' work like maintaining the modules # database accordingly. @@ -10,8 +10,22 @@ # require "complete.pl"; +require "getopts.pl"; +sub scan_opts +{ + &Getopts("n"); + + $dont_do_it = "-n" if $opt_n; + + die "usage: $0 [-n] [moduledir]\n" . + " -n: don't do any commit, show only\n" + unless $#ARGV <= 0; + + $moduledir = $ARGV[0] if $#ARGV == 0; +} + sub lsdir { # find all subdirectories under @_ @@ -165,12 +179,29 @@ sub checktag } +&scan_opts; &term_init; &cvs_init; +if(! $moduledir) { + @dirs = &lsdir("."); + print "${so}Import from which directory?${se}\n"; + @dirs = (@dirs, "."); + &list(@dirs); + $moduledir = &Complete("Which? [.]: ", @dirs); + $moduledir = "." unless $moduledir ne ""; +} + +chdir $moduledir || die "Cannot chdir to $moduledir\n"; + print "${so}Available repositories:${se}\n"; &list(@reps); +# the following kludge prevents the Complete package from starting +# over with the string just selected; Complete should better provide +# some reinitialize method +$Complete'return = ""; $Complete'r = 0; + $selected = &Complete("Enter repository (<TAB>=complete, ^D=show): ", @reps); @@ -188,9 +219,6 @@ print "\n${so}Selected repository:${se} ${us}$rep${ue}\n"; print "${so}Existent areas in this repository:${se}\n"; &list(@areas); -# the following kludge prevents the Complete package from starting -# over with the string just selected; Complete should better provide -# some reinitialize method $Complete'return = ""; $Complete'r = 0; $selected = @@ -304,21 +332,34 @@ system("cvs co modules") && die "${us}failed.\n${ue}"; print "${so}Inserting new module...${se}\n"; open(ED, "|ed modules/modules") || die "${us}Cannot start ed${ue}\n"; -print(ED "${cmd}${modname}" . ' ' x (32 - length($modname)) . +print(ED "${cmd}${modname}" . ' ' x (16 - length($modname)) . "$area/${modpath}\n.\nw\nq\n"); close(ED); print "${so}Commiting new modules database...${se}\n"; -system("cvs commit -m \" ${modname} --> $area/${modpath}\" modules") +system("cvs $dont_do_it commit -m \" " . + "${modname} --> $area/${modpath}\" modules") && die "Commit failed\n"; -system("cvs release -dQ modules"); +system("cvs $dont_do_it release -dQ modules"); print "${so}Importing source. Enter a commit message in the editor.${se}\n"; -system("cvs import $area/$modpath $vtag $rtag"); +system("cvs $dont_do_it import $area/$modpath $vtag $rtag"); print "${so}You are done now. Go to a different directory, perform a${se}\n". "${us}cvs co ${modname}${ue} ${so}command, and see if your new module" . " builds ok.${se}\n"; +if($dont_do_it) { +print <<END + + +${so}Since you did not allow to commit anything, you'll have${se} +${so}to remove the edited modules' database yourself.${se} +${so}To do this, perform a${se} +${us}cd ${moduledir}; cvs release -dQ modules${ue} +${so}command.${se} +END +; +} diff --git a/gnu/usr.bin/cvs/contrib/log.pl b/gnu/usr.bin/cvs/contrib/log.pl index a6c75f6..d68cc82 100644 --- a/gnu/usr.bin/cvs/contrib/log.pl +++ b/gnu/usr.bin/cvs/contrib/log.pl @@ -1,5 +1,9 @@ -#!/usr/bin/perl +#! /local/bin/perl +# Modified by woods@web.apc.org to add support for mailing 3/29/93 +# use '-m user' for each user to receive cvs log reports +# and use '-f logfile' for the logfile to append to +# # Modified by berliner@Sun.COM to add support for CVS 1.3 2/27/92 # # Date: Tue, 6 Aug 91 13:27 EDT @@ -11,94 +15,134 @@ # now the output looks like this: # # ************************************** -# date: Tuesday, August 6, 1991 @ 13:17 -# author: samborn +# Date: Tuesday, August 6, 1991 @ 13:17 +# Author: samborn +# # Update of /elmer/cvs/CVSROOT.adm # In directory astro:/home/samborn/CVSROOT.adm # # Modified Files: # test3 -# # Added Files: # test6 -# # Removed Files: # test4 -# # Log Message: # wow, what a test # -# RCS: 1.4 /elmer/cvs/CVSROOT.adm/test3,v -# RCS: 1.1 /elmer/cvs/CVSROOT.adm/test6,v -# RCS: 1.1 /elmer/cvs/CVSROOT.adm/Attic/test4,v +# File: test.3 Status: Up-to-date +# Version: 1.4 Thu Apr 29 14:47:07 EDT 1993 +# File: test6 Status: Up-to-date +# Version: 1.1 Thu Apr 29 14:47:33 EDT 1993 +# File: test4 Status: Up-to-date +# Version: 1.1 Thu Apr 29 14:47:46 EDT 1993 # -# +$cvsroot = $ENV{'CVSROOT'}; + # turn off setgid # $) = $(; -# # parse command line arguments # -@files = split(/ /,$ARGV[0]); -$logfile = $ARGV[1]; -$cvsroot = $ENV{'CVSROOT'}; +while (@ARGV) { + $arg = shift @ARGV; + + if ($arg eq '-m') { + $users = "$users " . shift @ARGV; + } elsif ($arg eq '-f') { + ($logfile) && die "Too many '-f' args"; + $logfile = shift @ARGV; + } else { + ($donefiles) && die "Too many arguments!\n"; + $donefiles = 1; + @files = split(/ /, $arg); + } +} + +$srepos = shift @files; +$mailcmd = "| Mail -s 'CVS update: $srepos'"; -# # Some date and time arrays # @mos = (January,February,March,April,May,June,July,August,September, October,November,December); @days = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; -# # get login name # $login = getlogin || (getpwuid($<))[0] || "nobody"; -# # open log file for appending # -if ((open(OUT, ">>" . $logfile)) != 1) { - die "Could not open logfile " . $logfile . "\n"; +open(OUT, ">>" . $logfile) || die "Could not open(" . $logfile . "): $!\n"; +if ($users) { + $mailcmd = "$mailcmd $users"; + open(MAIL, $mailcmd) || die "Could not Exec($mailcmd): $!\n"; } -# -# Header +# print out the log Header # print OUT "\n"; print OUT "**************************************\n"; -print OUT "date: " . $days[$wday] . ", " . $mos[$mon] . " " . $mday . ", 19" . $year . - " @ " . $hour . ":" . sprintf("%02d", $min) . "\n"; -print OUT "author: " . $login . "\n"; +print OUT "Date:\t$days[$wday] $mos[$mon] $mday, 19$year @ $hour:" . sprintf("%02d", $min) . "\n"; +print OUT "Author:\t$login\n\n"; -# -#print the stuff on stdin to the logfile +if (MAIL) { + print MAIL "\n"; + print MAIL "Date:\t$days[$wday] $mos[$mon] $mday, 19$year @ $hour:" . sprintf("%02d", $min) . "\n"; + print MAIL "Author:\t$login\n\n"; +} + +# print the stuff from logmsg that comes in on stdin to the logfile # open(IN, "-"); -while(<IN>) { - print OUT $_; +while (<IN>) { + print OUT $_; + if (MAIL) { + print MAIL $_; + } } close(IN); print OUT "\n"; -# # after log information, do an 'cvs -Qn status' on each file in the arguments. # -for $file (@files[1..$#files]) { - if ($file eq "-") { - last; - } - open(RCS,"-|") || exec 'cvs', '-Qn', 'status', $file; - while (<RCS>) { - if (substr($_, 0, 7) eq " RCS") { - print OUT; - } - } - close (RCS); +while (@files) { + $file = shift @files; + if ($file eq "-") { + print OUT "[input file was '-']\n"; + if (MAIL) { + print MAIL "[input file was '-']\n"; + } + last; + } + + open(RCS, "-|") || exec 'cvs', '-Qn', 'status', $file; + + while (<RCS>) { + if (/^[ \t]*Version/ || /^File:/) { + print OUT; + if (MAIL) { + print MAIL; + } + } + } + close(RCS); } -close (OUT); +close(OUT); +die "Write to $logfile failed" if $?; + +close(MAIL); +die "Pipe to $mailcmd failed" if $?; + +exit 0; + +### Local Variables: +### eval: (fundamental-mode) +### End: diff --git a/gnu/usr.bin/cvs/contrib/mfpipe.pl b/gnu/usr.bin/cvs/contrib/mfpipe.pl index 74cc5e1..3e6357d 100644 --- a/gnu/usr.bin/cvs/contrib/mfpipe.pl +++ b/gnu/usr.bin/cvs/contrib/mfpipe.pl @@ -11,7 +11,7 @@ # Especially if they regularly beat on the same directory. Anyway if you # think anyone would be interested here it is. # -# mfpipe.pl,v 1.1 1992/03/02 01:22:41 berliner Exp +# $Id: mfpipe.pl,v 1.1 1992/03/02 01:22:41 berliner Exp $ # # # File: mfpipe diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/ChangeLog b/gnu/usr.bin/cvs/contrib/pcl-cvs/ChangeLog index fab9a7d..fad2eb1 100644 --- a/gnu/usr.bin/cvs/contrib/pcl-cvs/ChangeLog +++ b/gnu/usr.bin/cvs/contrib/pcl-cvs/ChangeLog @@ -1,3 +1,552 @@ +Tue Jun 1 00:00:03 1993 Per Cederqvist (ceder@lysator.liu.se) + + * Release 1.05. (This release was promised before the end of May, + but I didn't quite make it. No, I didn't fake the date above). + +Mon May 31 01:32:25 1993 Per Cederqvist (ceder@lysator.liu.se) + + * Removed the elib sub-directory. Users must now get the Elib + library separately. + * pcl-cvs.texinfo: Document it. + + * pcl-cvs-lucid.el: A new version, supplied by Jamie Zawinsky, + added. + + * pcl-cvs Id 68: Transform RCS keywords + * Makefile (pcl-cvs-$(VER)): Remove the $ signs in most files in + the distribution. + + * pcl-cvs Id 76: Extra " in cvs-mode-add. + * pcl-cvs.el (cvs-mode-add): Don't add the extra level of quotes + around the log message, since it doesn't work with CVS. + + * pcl-cvs Id 56: '-d <CVSROOT>' support in pcl-cvs + * pcl-cvs.el (cvs-change-cvsroot): New function. + + * pcl-cvs Id 77: *cvs* isn't cleared properly + * pcl-cvs.el (cvs-do-update): Always erase the *cvs* buffer and + re-create the collection. + + * pcl-cvs.el (cvs-do-update): Set mode-line-process in the *cvs* + buffer. + * pcl-cvs.el (cvs-mode): Reset mode-line-process. + + * pcl-cvs Id 59: sort .cvsignore alphabetically! + * pcl-cvs.el (cvs-sort-ignore-file): New variable. + * pcl-cvs.el (cvs-mode-ignore): Use it. + * pcl-cvs.texinfo: Document it. + + * pcl-cvs Id 75: Require final newline. + * pcl-cvs.el (cvs-commit-buffer-require-final-newline): New + variable. + * pcl-cvs.el (cvs-edit-done): Use it. + * pcl-cvs.texinfo: Document it. + + * pcl-cvs Id 72: make clean deletes lucid-emacs.el + * dist-makefile (ELCFILES): Fixed a typo. + + * pcl-cvs Id 46: "cvs remove f" "touch f" "cvs update f" -> parse err. + * pcl-cvs.el (cvs-fileinfo->type): New type: REM-EXIST. + * pcl-cvs.el (cvs-shadow-entry-p): A REMOVED that follows a + REM-EXIST is a shadow. + * pcl-cvs.el (cvs-parse-stderr): Recognize the "should be removed + and is still there" message. + * pcl-cvs.el (cvs-pp): Recognize REM-EXIST. + * pcl-cvs.el (cvs-mode-undo-local-changes): Recognize and complain + about REM-EXIST. Defensive test added: complain about unknown types. + + * pcl-cvs.el (cvs-mode-add): Add an extra level of quotes around + the log message. This is apparently needed by RCVS. <This change + has been removed. --ceder>. + + * pcl-cvs.el (cvs-parse-stderr): Ignore output from RCVS. + +Tue Apr 27 00:48:40 1993 Per Cederqvist (ceder@lysator.liu.se) + + * pcl-cvs.el (cvs-startup-message): Now a defconst instead of a + defvar. + * pcl-cvs.el (cvs-mode-commit): Add a defvar for it. + + * dist-makefile (EMACS): Use $(EMACS) instead of hard-coding 'emacs'. + +Sat Apr 17 12:47:10 1993 Per Cederqvist (ceder@lysator.liu.se) + + * Release 1.04. + + * pcl-cvs.texinfo: Updated the Contributors node. + + * pcl-cvs Id 58: Lucid GNU Emacs support + * pcl-cvs-lucid.el: New file, contributed by the people at Lucid. + * pcl-cvs.el: Autoload pcl-cvs-lucid if running in an Lucid GNU + Emacs. + * compile-all.el: (files-to-compile): Add pcl-cvs-lucid. + * dist-makefile (ELFILES, ELCFILES): Dito. + + * pcl-cvs Id 55: cvs-diff-backup swaps old and new version. + * pcl-cvs.el (cvs-diff-backup-extractor): Old version should be + first. + * pcl-cvs.el (cvs-mode-diff-backup): Call cvs-backup-diffable + correctly. + + * pcl-cvs Id 64: elib substitute + * dist-makefile (install): Warn about Elib. + * pcl-cvs.texinfo: Talk about Elib. + + * pcl-cvs Id 50: Committing the *commit* buffer twice. + * pcl-cvs.el (cvs-edit-done): Report an error if cvs-commit-list + is empty, and empty it when the commit is done. + + * pcl-cvs Id 56: '-d <CVSROOT>' support. + * pcl-cvs.el (cvs-cvsroot): New variable. + * pcl-cvs.el (cvs-do-update, all callers of cvs-execute-list): Use + it everywhere CVS is called, to override CVSROOT. + * pcl-cvs.texinfo (Customization): Document it. + +Thu Apr 1 00:34:55 1993 Per Cederqvist (ceder@lysator.liu.se) + + * pcl-cvs.el (cvs-retrieve-revision-to-tmpfile): Exit status nil + from call-process means everything was successful in some Emacs + versions. + + * pcl-cvs.el (cvs-mode-map): Bind "q" to bury-buffer. + * pcl-cvs.texinfo: Document it. + +Thu Mar 11 00:05:03 1993 Per Cederqvist (ceder@lysator.liu.se) + + * Release 1.03-Emerge (not released). + + * Makefile (pcl-cvs-$(VER)): Don't includ elib-dll-debug.el in the + distribution. (It's included as elib/dll-debug.el). + + * pcl-cvs.el (cvs-mode): Document the "e" key (cvs-mode-emerge). + +Tue Mar 9 00:02:57 1993 Per Cederqvist (ceder@lysator.liu.se) + + * pcl-cvs.texinfo (Emerge): New node. + + * pcl-cvs.el (cvs-kill-buffer-visiting): New function. + + * pcl-cvs.el (cvs-mode-emerge): Handle Conflict and Merged files. + + * pcl-cvs.el (cvs-retrieve-revision-to-tmpfile): Handle any revision. + + * pcl-cvs.el (cvs-fileinfo-*): Store base-revision instead of + backup-file. + + * pcl-cvs.el (cvs-backup-diffable): The file is only diffable if + the backup file is readable. + + * pcl-cvs.el (cvs-mode-map): Bind "e" to cvs-mode-emerge instead + of cvs-mode-find-file (which is anyhow bound to "f"). + +Mon Mar 8 23:06:52 1993 Per Cederqvist (ceder@lysator.liu.se) + + * pcl-cvs.el (cvs-mode-emerge): New function. Currently only + handles emerge of Modified files. + + * pcl-cvs.el (cvs-retrieve-revision-to-tmpfile): New function. + +Sun Jan 24 20:07:18 1993 Per Cederqvist (ceder@lysator.liu.se) + + * elib-dll-debug.el: Moved to elib. + +Mon Jan 18 00:35:59 1993 Per Cederqvist (ceder@mauritz) + + * pcl-cvs.el (cvs-do-update): Added a probably unnecessary sit-for. + + * Release 1.03-Elib-0.05.1 (not released). + + * Elib 0.05 compatibility: + * elib-dll-debug.el, pcl-cvs-buffer.el, test-dll.el: Fix the + require strings. + * pcl-cvs.el (cvs-pp): Insert the string. + + * Release 1.03-Elib-0.05 (not released). + + * elib: New directory, containing the parts of elib that are + required for pcl-cvs. Changes to the files in that directory + that are present in Elib are documented in the ChangeLog of + Elib, not here. + * Makefile (pcl-cvs-$(VER)): Copy the new dir to the distribution. + * dist-makefile (ELFILES, ELCFILES): Don't include the Elib files. + +Fri Jan 8 02:43:49 1993 Per Cederqvist (ceder@konrad) + + * pcl-cvs.el (cvs-mode-map): Bind "e" to cvs-mode-find-file, like + in dired. + +Sun Jan 3 23:25:13 1993 Per Cederqvist (ceder@konrad) + + * elib-dll.el, elib-node.el, cookie.el: Moved to the elib package. + Pcl-cvs now requires elib. + +Tue Dec 29 22:06:57 1992 Per Cederqvist (ceder@konrad) + + * pcl-cvs.el: Tracked the latest (last?) rename of all functions + in cookie.el. + +Thu Sep 24 00:29:16 1992 Per Cederqvist (ceder@robert) + + * pcl-cvs.texinfo (Archives): This version is not distributed with + CVS 1.3, so don't claim that it is. + +Fri Aug 21 15:17:08 1992 Per Cederqvist (ceder@maskros) + + * pcl-cvs.el (cvs-parse-stderr): Fixed two "(set head" that should + be "(setq head". + +Thu Aug 20 05:53:58 1992 Per Cederqvist (ceder@robin) + + * cookie.el: Changes to this file is documented in the ChangeLog + of elib in the future. + +Tue Aug 18 03:30:28 1992 Per Cederqvist (ceder@robin) + + * pcl-cvs.el: Don't use cookie-last-tin (which no longer exists). + + * cookie.el: Use prefix cookie:: for internal functions. + + * cookie.el: (cookie:enter-after, cookie:enter-before, + cookie:nth-cookie): Implemented. + * cookie.el: No longer define (impl). + + * cookie.el: More renames: + cookie:next-cookie -> cookie:goto-next-tin + cookie:previous-cookie -> cookie:goto-previous-tin + tin-next -> cookie:next-tin + tin-previous -> cookie:previous-tin + tin-nth -> cookie:nth-tin + tin-delete -> cookie:delete-tin + cookie:collect -> cookie:collect-cookies + cookie:tin-collect -> cookie:collect-tins + (new) -> cookie:tin-collect-cookies + (new) -> cookie:tin-collect-tins + cookie:refresh -> cookie:refresh-all + tin-invalidate-tins -> cookie:invalidate-tins + +Mon Aug 17 01:39:49 1992 Per Cederqvist (ceder@robin) + + * cookie.el (cookie:set-buffer-bind-dll-let*): New macro. Used in + many places instead of cookie:set-buffer-bind-dll. + * cookie.el (cookie:set-buffer-bind-dll): Renamed the macro + cookie:set-buffer to this. + + * pcl-cvs.el (cvs-use-temp-buffer): Set default-directory. + +Sun Aug 16 20:51:30 1992 Per Cederqvist (ceder@robin) + + * pcl-cvs.el (cvs-add-sub): Fixed call to cvs-add-file-update-buffer. + +Sat Aug 8 20:28:21 1992 Per Cederqvist (ceder@robin) + + * Release 1.03-Cookie-II (not released). + + * pcl-cvs.el (cvs-mode-diff-cvs): Don't care about the exit status + from ``cvs diff''. + + * pcl-cvs.el (cvs-mode): Document cvs-mode-undo-local-changes. + * pcl-cvs.el (cvs-diffable): New function. + + * pcl-cvs.el: Use the new cookie package. + * pcl-cvs.el (cvs-cookie-handle): New variable. + * pcl-cvs.el (cvs-do-update): User the new cookie:create + interface, and cookie:clear if the buffer already existed. Make + the buffer read-only. + * pcl-cvs.el (cvs-mode-next-line, cvs-mode-previous-line): New + functions (used instead of cookie:next-cookie and + cookie:previous-cookie). + + * cookie.el: Major redesign. The handle that is passed to all + cookie functions is now a new datatype, and not the buffer that + the cookies resides in. This way it is possible to have more than + one set of cookies in a buffer. Things that used to be + buffer-local variables are now fields in the handle data type. + cookie-last-tin is no longer available. + * cookie.el (cookie:create): The buffer is not cleared, nor set to + be read-only. + * cookie.el (cookie:next-cookie, cookie:previous-cookie): Since + the first argument is now a handle and not a buffer, these can no + longer be called interactively. You have to write a small wrapper + about them. + * cookie.el (cookie:buffer): New function. + +Tue Aug 4 03:02:25 1992 Per Cederqvist (ceder@robert) + + * pcl-cvs.texinfo (Bugs): Renamed "Reporting bugs and ideas" to + "Bugs" and added a table of known bugs/FAQ:s. + +Mon Aug 3 00:19:39 1992 Per Cederqvist (ceder@robert) + + * pcl-cvs.el, pcl-cvs.texinfo: Big Renaming Time! + The commands that operate in the *cvs* buffer: + cvs-add-change-log-entry-other-window -> cvs-mode-add-change-log-entry-other-window + cvs-mark-all-files -> cvs-mode-mark-all-files + cvs-revert-updated-buffers -> cvs-mode-revert-updated-buffers + cvs-undo-local-changes -> cvs-mode-undo-local-changes + cvs-unmark-up -> cvs-mode-unmark-up + cvs-acknowledge -> cvs-mode-acknowledge + cvs-unmark-all-files -> cvs-mode-unmark-all-files + cvs-add -> cvs-mode-add + cvs-diff-backup -> cvs-mode-diff-backup + cvs-commit -> cvs-mode-commit + cvs-diff-cvs -> cvs-mode-diff-cvs + cvs-find-file -> cvs-mode-find-file + cvs-update-no-prompt -> cvs-mode-update-no-prompt + cvs-ignore -> cvs-mode-ignore + cvs-log -> cvs-mode-log + cvs-mark -> cvs-mode-mark + cvs-find-file-other-window -> cvs-mode-find-file-other-window + cvs-remove-file -> cvs-mode-remove-file + cvs-status -> cvs-mode-status + cvs-remove-handled -> cvs-mode-remove-handled + cvs-unmark -> cvs-mode-unmark + + * pcl-cvs.el (cvs-cvs-diff-flags): Variable deleted. + * pcl-cvs.el (cvs-diff-cvs): Use cvs-diff-flags instead. + * pcl-cvs.texinfo (Customization): Update the doc. + + * pcl-cvs.el (cvs-diff-cvs): Handle exit status 0 (no diffs), 1 + (diffs) and other (error). + * pcl-cvs.el (cvs-execute-list): Add support for this kind of + thing. + + * Revert buffers for committed files: + * pcl-cvs.el (cvs-auto-revert-after-commit): New variable. + * pcl-cvs.texinfo (Committing changes, Customization): Document + it. + * pcl-cvs.el (cvs-after-commit-function): New function. + + * pcl-cvs.el (cvs-execute-list): Return the exit status or nil. + * pcl-cvs.el (cvs-edit-done, cvs-diff-cvs, cvs-remove-file, + cvs-undo-local-changes, cvs-add, cvs-status, cvs-log): Use the + exit status to generate an error message. + + + * pcl-cvs.el (cvs-do-update): It should be "cvs -n update -l", not + "cvs -l update -n". Put the -n and/or -l in the message that is + displayed in the *cvs* buffer during the update. + +Sat Aug 1 00:55:49 1992 Per Cederqvist (ceder@robert) + + * cookie.el (cookie-sort): New function. + + * cookie.el (cookie-clear): Rewritten. No longer clears all local + variables. + +Tue Jul 28 17:21:17 1992 Per Cederqvist (ceder@robin) + + * pcl-cvs.el (cvs-parse-stderr): Try to handle the output from RCS + when it is compiled without DIFF3_BIN and a conflict occurs. + + * pcl-cvs.texinfo (Getting Started): Fixed typo. + + * pcl-cvs-startup.el (cvs-update-other-window): Make the autoload + be interactive. + +Mon Jul 27 19:36:40 1992 Per Cederqvist (ceder@robin) + + * pcl-cvs.el (cvs-revert-updated-buffers, cvs-revert-fileinfo): + New functions. + * pcl-cvs.texinfo (Reverting your buffers): Document it. + + * pcl-cvs.el (cvs-fileinfo->full-path): New function. + * pcl-cvs.el (cvs-full-path): Use it. + + * cookie.el (cookie-map, cookie-map-reverse): Better doc- + string. Removed the unused local variable 'result'. + + * compile-all.el: Renamed elib-files to files-to-compare. + * compile-all.el (compile-pcl-cvs): Bind load-path in a let + statement instead of globally. + +Thu Jul 23 19:02:41 1992 Per Cederqvist (ceder@robin) + + * pcl-cvs.el (cvs-do-update): Check that CVSROOT is set. + * pcl-cvs.el (cvs-diff-cvs): Check that cvs-cvs-diff-flags is a + list. + * pcl-cvs.el (cvs-diff-backup): Check that cvs-diff-flags is a + list. + +Tue Jul 21 11:27:39 1992 Per Cederqvist (ceder@robin) + + * pcl-cvs.el (cvs-parse-error): Make the *cvs* buffer writeable + before trying to write the email message. Require sendmail before + trying to switch to mail-mode. + + * pcl-cvs.el (cvs-do-update): Check that cvs-program exists. + + * pcl-cvs.el (cvs-skip-line): Fixed bracketing error. + +Mon Jul 20 10:31:51 1992 Per Cederqvist (ceder@robin) + + * Release 1.03. + + * pcl-cvs.el, cookie.el: Indentation fixes. + + * Makefile (pcl-cvs-$(VER)): Include NEWS in the distribution. + + * pcl-cvs.el (cvs-rm-program): Deleted. + * pcl-cvs.el (cvs-rmdir-program, cvs-lock-file): New variables. + + * Handle lock files in a nicer way: + * pcl-cvs.el (cvs-update-filter, cvs-delete-lock, + cvs-lock-file-p): New functions. + * pcl-cvs.el (cvs-do-update, cvs-sentinel): Redirect stdout to the + temporary file, not stderr. Use cvs-update-filter. + * pcl-cvs.el (cvs-parse-update): New arguments. + * pcl-cvs.el (cvs-parse-buffer): Renamed to cvs-parse-update. + * pcl-cvs.el (cvs-stderr-file): Renamed to cvs-stdout-file. + * pcl-cvs.texinfo (Miscellaneous commands, Updating the + directory): Document cvs-delete-lock. + + * pcl-cvs.el (cvs-mode): Don't reset buffer-read-only. + + * pcl-cvs.el (cvs-find-file-other-window): Don't save-some-buffers. + +Thu Jul 16 00:19:58 1992 Per Cederqvist (ceder@robin) + + * pcl-cvs.el, test-cookie-el: Use the new names from cookie.el. + + * cookie.el: Big Renaming Time! + External functions: + cookie-next -> tin-next + cookie-previous -> tin-previous + cookie-nth -> tin-nth + cookie-delete -> tin-delete + cookie-filter-tins -> tin-filter + cookie-get-selection -> tin-get-selection + cookie-start-marker -> tin-start-marker + cookie-end-marker -> tin-end-marker + cookie-invalidate-tins -> tin-invalidate-tins + cookie-collect-tins -> tin-collect + cookie-collect-cookies -> cookie-collect + Internal functions: + cookie-create-tin -> cookie-create-wrapper + cookie-tin-start-marker -> cookie-wrapper-start-marker + cookie-tin-cookie-safe -> cookie-wrapper-cookie-safe + cookie-tin-cookie -> cookie-wrapper-cookie + set-cookie-tin-start-marker -> cookie-wrapper-set-start-marker + set-cookie-tin-cookie -> cookie-wrapper-set-cookie + cookie-tin-p -> cookie-wrapper-p + cookie-create-tin-and-insert -> cookie-create-wrapper-and-insert + + * pcl-cvs.el (cvs-find-file, cvs-find-file-other-window): Signal + an appropriate error message if the *cvs* buffer is empty. + + * cookie.el (cookie-create): Make the buffer read-only. + * cookie.el (cookie-create-tin-and-insert, cookie-refresh, + cookie-delete-tin-internal, cookie-refresh-tin): Bind + buffer-read-only to nil while changing the contents of + the buffer. + + * pcl-cvs.el (cvs-byte-compile-files): New function. + * pcl-cvs.texinfo (Miscellaneous commands): Document it. + + * pcl-cvs.el (cvs-diff-ignore-marks): New variable. + * pcl-cvs.el (cvs-diff-cvs, cvs-diff-backup): Don't consider + marked files to be selected if a prefix argument is given XOR the + variable cvs-diff-ignore-marks is non-nil. + * pcl-cvs.el (cvs-get-marked): New optional argument `ignore-marks'. + * pcl-cvs.texinfo (Customization, Viewing differences): Document + this behaviour. + + * pcl-cvs.el (cvs-undo-local-changes): New function. + * pcl-cvs.texinfo (Undoing changes): Document + cvs-undo-local-changes. + * pcl-cvs.el (cvs-mode-map): cvs-unmark-all-files moved from "U" + to "ESC DEL". cvs-undo-local-changes bound to "U". + * pcl-cvs.texinfo (Marking files): Document ESC DEL. + + * pcl-cvs.el (cvs-skip-line): New arguments. All callers updated. + Now calls cvs-parse-error if a parse error occurs. + * pcl-cvs.el (cvs-parse-error): New function that creates a bug + report. + * pcl-cvs.el (cvs-parse-stderr, cvs-parse-stdout): New arguments. + The only caller (cvs-parse-buffer) updated. Call cvs-parse-error + in case of parse error. + + * pcl-cvs.el (pcl-cvs-version): New variable. + + * cookie.el (cookie-create): Kill all local variables in the buffer. + +Fri Jul 10 11:17:40 1992 Per Cederqvist (ceder@robin) + + * Release 1.03beta1. + +Thu Jul 9 03:12:00 1992 Per Cederqvist (ceder@robin) + + * pcl-cvs.el (cvs-update-running): New variable. + * pcl-cvs.el (cvs-do-update): Use it instead of the previous local + variable cvs-process (that no longer exists). Make sure that only + one `cvs update' runs at any given moment. + * pcl-cvs.el (cvs-sentinel): Reset cvs-update-running when the + update process exits. + + * pcl-cvs.el (cvs-update): Switch to the *cvs* buffer. + * pcl-cvs.el (cvs-update-other-window): New function. + * pcl-cvs-startup.el (cvs-update-other-window): Added a autoload + for it. + * pcl-cvs.el (cvs-do-update): Don't pop up any buffer in a window + - let cvs-update or cvs-update-other-window handle that. Also + don't kill the *cvs* buffer, but rather insert a "Running cvs..." + message into it. + * pcl-cvs.el (cvs-parse-buffer): Don't change the window + configuration. + + * pcl-cvs.el (cvs-create-fileinfo, cvs-pp, cvs-fileninfo->type): + New type for a fileinfo: MESSAGE. + + * pcl-cvs.el (cvs-cvs-buffer): Deleted the variable. Use + cvs-buffer-name instead. (I no longer have any plans to allow more + than one cvs update to run at the same time - things only get + confusing). Changed all places where cvs-cvs-buffer was used. + + * pcl-cvs.el: Take care of update programs (the -u option in the + modules file): + * pcl-cvs.el (cvs-update-prog-output-skip-regexp): New variable. + * pcl-cvs.el (cvs-parse-stdout): Skip output from the update + program (using cvs-update-prog-output-skip-regexp). + * pcl-cvs.texinfo (Future enhancements): Document that the + solution is not as good as it should be. + * pcl-cvs.texinfo (Customization): Document the variable. + +Wed Jul 8 20:29:44 1992 Per Cederqvist (ceder@robin) + + * pcl-cvs.el (cvs-do-update): Check that this-dir really exists + and is a directory, and that this-dir/CVS exists and is a + directory. + +Tue Jul 7 01:02:24 1992 Per Cederqvist (ceder@robin) + + * pcl-cvs.texinfo (Customization): Document TMPDIR. + + * This chunk of modifications should make it possible to run + pcl-cvs on hosts that do not line-buffer stdout (such as + DECstation). They work by diverting stdout and stderr from + `cvs update' and later sorting them together. + * pcl-cvs.el (cvs-parse-stderr): Don't fail to parse conflict + data. + * pcl-cvs.el (cvs-remove-stdout-shadows, cvs-shadow-entry-p): New + functions. + * pcl-cvs.el (cvs-parse-buffer): Use it. + * pcl-cvs.el (cvs-remove-empty-directories): New function. + * pcl-cvs.el (cvs-remove-handled, cvs-parse-buffer): Use it. + * pcl-cvs.el (cvs-get-current-dir): New argument ROOT-DIR. All + calls to cvs-get-current-dir updated. + * pcl-cvs.el (cvs-do-update): Allocate a tmp file. Use cvs-shell + (typically /bin/sh) to redirect stderr from CVS to the tmp file. + * pcl-cvs.el (cvs-sentinel): Handle the tmp file. Remove it when + it is parsed. + * pcl-cvs.el (cvs-parse-buffer): New argument STDERR-BUFFER. All + calls to cvs-parse-buffer updated. Rewritten to handle the + separation of stderr and stdout. + * pcl-cvs.el (cvs-shell, cvs-stderr-file): New variables. + * pcl-cvs.el (cvs-compare-fileinfos, cvs-parse-stderr, + cvs-parse-stdout): New functions. + + * pcl-cvs.el (cvs-parse-buffer): Some modifications for output + from RCS 5.6. + Tue Apr 7 09:11:27 1992 Per Cederqvist (ceder@leopold) * Release 1.02. diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/INSTALL b/gnu/usr.bin/cvs/contrib/pcl-cvs/INSTALL index 8c89053..f3c4480 100644 --- a/gnu/usr.bin/cvs/contrib/pcl-cvs/INSTALL +++ b/gnu/usr.bin/cvs/contrib/pcl-cvs/INSTALL @@ -3,47 +3,51 @@ This text is copied from the TeXinfo manual for pcl-cvs. Installation of the pcl-cvs program =================================== - 1. Edit the file `Makefile' to reflect the situation at your site. - The only things you have to change is the definition of - `lispdir' and `infodir'. The elisp files will be copied to - `lispdir', and the info file to `infodir'. + 1. Edit the file `Makefile' to reflect the situation at your site. + The only things you have to change is the definition of `lispdir' + and `infodir'. The elisp files will be copied to `lispdir', and + the info file to `infodir'. 2. Configure pcl-cvs.el - There are a couple of paths that you have to check to make - sure that they match you system. They appear early in the file + There are a couple of paths that you have to check to make sure + that they match you system. They appear early in the file pcl-cvs.el. - *NOTE:* If your system is running emacs 18.57 or earlier - you MUST uncomment the line that says: + *NOTE:* If your system is running emacs 18.57 or earlier you + MUST uncomment the line that says: (setq delete-exited-processes nil) - Setting `delete-exited-processes' to `nil' works around a bug - in emacs that causes it to dump core. The bug was fixed in - emacs 18.58. + Setting `delete-exited-processes' to `nil' works around a bug in + emacs that causes it to dump core. The bug was fixed in emacs + 18.58. - 3. Type `make install' in the source directory. This will + 3. Release 1.05 and later of pcl-cvs requires parts of the Elib + library, version 0.07 or later. Elib is available via anonymous + ftp from prep.ai.mit.edu in `pub/gnu/elib-0.07.tar.z', and from + a lot of other sites that mirrors prep. Get Elib, and install + it, before proceeding. + + 4. Type `make install' in the source directory. This will byte-compile all `.el' files and copy both the `.el' and the `.elc' into the directory you specified in step 1. - If you don't want to install the `.el' files but only the - `.elc' files (the byte-compiled files), you can type ``make + If you don't want to install the `.el' files but only the `.elc' + files (the byte-compiled files), you can type ``make install_elc'' instead of ``make install''. - If you only want to create the compiled elisp files, but - don't want to install them, you can type `make elcfiles' - instead. This is what happens if you only type `make' without - parameters. + If you only want to create the compiled elisp files, but don't + want to install them, you can type `make elcfiles' instead. + This is what happens if you only type `make' without parameters. - 4. Edit the file `default.el' in your emacs lisp directory (usually + 5. Edit the file `default.el' in your emacs lisp directory (usually `/usr/gnu/emacs/lisp' or something similar) and enter the contents of the file `pcl-cvs-startup.el' into it. It contains a couple of `auto-load's that facilitates the use of pcl-cvs. - Installation of the on-line manual. =================================== @@ -55,7 +59,7 @@ Installation of the on-line manual. info file `pcl-cvs.info' that is included in the distribution (type `cp pcl-cvs.info pcl-cvs'). - 2. Move the info file `pcl-cvs' to your standard info directory. + 2. Move the info file `pcl-cvs' to your standard info directory. This might be called something like `/usr/gnu/emacs/info'. 3. Edit the file `dir' in the info directory and enter one line to @@ -65,8 +69,6 @@ Installation of the on-line manual. * Pcl-cvs: (pcl-cvs). An Emacs front-end to CVS. - - How to make typeset documentation from pcl-cvs.texinfo ====================================================== @@ -81,3 +83,4 @@ manual from `pcl-cvs.texinfo'. postscript printer there is a program, `dvi2ps', which does. There is also a program which comes together with TeX, `dvips', which you can use. + diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/Makefile b/gnu/usr.bin/cvs/contrib/pcl-cvs/Makefile index f0ded69..7f6f5b1 100644 --- a/gnu/usr.bin/cvs/contrib/pcl-cvs/Makefile +++ b/gnu/usr.bin/cvs/contrib/pcl-cvs/Makefile @@ -1,6 +1,6 @@ -# Makefile,v 1.2 1992/04/07 20:49:07 berliner Exp -# Makefile for pcl-cvs release 1.02. -# Copyright (C) 1992 Per Cederqvist +# @(#) Id: dist-makefile,v 1.19 1993/05/31 22:43:45 ceder Exp +# Makefile for pcl-cvs release 1.05. +# Copyright (C) 1992, 1993 Per Cederqvist # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,6 +26,10 @@ lispdir = /usr/local/lib/elisp prefix=/usr/local infodir = $(prefix)/info +# Used to byte-compile files. + +EMACS=emacs + # # The rest of this file should not need to be modified. # @@ -33,8 +37,8 @@ infodir = $(prefix)/info # Just in case... SHELL = /bin/sh -ELFILES = pcl-cvs.el cookie.el elib-dll.el elib-node.el -ELCFILES = pcl-cvs.elc cookie.elc elib-dll.elc elib-node.elc +ELFILES = pcl-cvs.el pcl-cvs-lucid.el +ELCFILES = pcl-cvs.elc pcl-cvs-lucid.elc INFOFILES = pcl-cvs TEXTMPS = pcl-cvs.aux pcl-cvs.log pcl-cvs.toc pcl-cvs.dvi pcl-cvs.cp \ pcl-cvs.fn pcl-cvs.vr pcl-cvs.tp pcl-cvs.ky pcl-cvs.pg \ @@ -45,7 +49,7 @@ INSTALL = install INSTALL_DATA = $(INSTALL) elcfiles: - emacs -batch -l ./compile-all.el -f compile-pcl-cvs + $(EMACS) -batch -l ./compile-all.el -f compile-pcl-cvs all: elcfiles info @@ -67,6 +71,7 @@ info pcl-cvs: pcl-cvs.texinfo pcl-cvs.dvi: pcl-cvs.texinfo tex pcl-cvs.texinfo + tex pcl-cvs.texinfo -texindex pcl-cvs.cp pcl-cvs.fn pcl-cvs.vr pcl-cvs.tp pcl-cvs.ky \ pcl-cvs.pg tex pcl-cvs.texinfo diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/README b/gnu/usr.bin/cvs/contrib/pcl-cvs/README index 6f0a5fe..779617f 100644 --- a/gnu/usr.bin/cvs/contrib/pcl-cvs/README +++ b/gnu/usr.bin/cvs/contrib/pcl-cvs/README @@ -1,6 +1,10 @@ -README,v 1.2 1992/04/07 20:49:09 berliner Exp +@(#) Id: README,v 1.14 1993/05/31 22:43:36 ceder Exp -This is the readme file for pcl-cvs, release 1.02. +This is the readme file for pcl-cvs, release 1.05. + +This release of pcl-cvs requires Elib 0.07 or later. Elib is no +longer distributed with pcl-cvs, since that caused too much confusion. +You can get Elib from ftp.lysator.liu.se in pub/emacs/elib-*.tar.?. Pcl-cvs is a front-end to CVS version 1.3. It integrates the most frequently used CVS commands into emacs. @@ -9,6 +13,16 @@ There is some configuration that needs to be done in pcl-cvs.el to get it to work. See the instructions in file INSTALL. Full documentation is in pcl-cvs.texinfo. Since it requires makeinfo -2.14 a preformatted info file is also included (pcl-cvs.info). +version 2 or 3 a preformatted info file is also included (pcl-cvs.info). + +If you have been using a previous version of pcl-cvs (for instance +1.02 which is distributed with CVS 1.3) you should read through the +file NEWS to see what has changed. + +This release has been tested under Emacs 18.59, Emacs 19.10 and Lucid +Emacs 19.6. Emacs 19.10 unfortunately has a file named cookie.el that +collides with the cookie.el that is distributed in Elib. We are +trying to find a solution to that problem. In the mean time, there is +instructions in Elib 0.07 for how to work around the problem. - ceder@lysator.liu.se + Per Cederqvist diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/compile-all.el b/gnu/usr.bin/cvs/contrib/pcl-cvs/compile-all.el index 74f1bca..6563277 100644 --- a/gnu/usr.bin/cvs/contrib/pcl-cvs/compile-all.el +++ b/gnu/usr.bin/cvs/contrib/pcl-cvs/compile-all.el @@ -1,9 +1,10 @@ -;;;; compile-all.el,v 1.2 1992/04/07 20:49:10 berliner Exp -;;;; This file byte-compiles all .el files in pcl-cvs release 1.02. +;;;; @(#) Id: compile-all.el,v 1.11 1993/05/31 18:40:25 ceder Exp +;;;; This file byte-compiles all .el files in pcl-cvs release 1.05. ;;;; ;;;; Copyright (C) 1991 Inge Wallin ;;;; -;;;; This file is part of the GNU Emacs lisp library, Elib. +;;;; This file was once upon a time part of Elib, but have since been +;;;; modified by Per Cederqvist. ;;;; ;;;; GNU Elib is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -21,14 +22,11 @@ ;;;; -(setq elib-files '("elib-node" - "elib-dll" - "cookie" - "pcl-cvs")) +(setq files-to-compile '("pcl-cvs" "pcl-cvs-lucid")) (defun compile-file-if-necessary (file) - "Compile the Elib file FILE if necessary. + "Compile FILE if necessary. This is done if FILE.el is newer than FILE.elc or if FILE.elc doesn't exist." (let ((el-name (concat file ".el")) @@ -41,12 +39,14 @@ This is done if FILE.el is newer than FILE.elc or if FILE.elc doesn't exist." (defun compile-pcl-cvs () - "Byte-compile all uncompiled files of elib. -Be sure to have . in load-path since a number of files in elib -depend on other files and we always want the newer one even if -a previous version of elib exists." + "Byte-compile all uncompiled files of pcl-cvs." (interactive) - (setq load-path (append '(".") load-path)) - (mapcar (function compile-file-if-necessary) - elib-files)) + + ;; Be sure to have . in load-path since a number of files + ;; depend on other files and we always want the newer one even if + ;; a previous version of pcl-cvs exists. + (let ((load-path (append '(".") load-path))) + + (mapcar (function compile-file-if-necessary) + files-to-compile))) diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs-startup.el b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs-startup.el index 27bb57c..f9b2de0 100644 --- a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs-startup.el +++ b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs-startup.el @@ -1,6 +1,14 @@ -;;; pcl-cvs-startup.el,v 1.2 1992/04/07 20:49:17 berliner Exp +;;; @(#) Id: pcl-cvs-startup.el,v 1.4 1993/05/31 18:40:33 ceder Exp (autoload 'cvs-update "pcl-cvs" "Run a 'cvs update' in the current working directory. Feed the output to a *cvs* buffer and run cvs-mode on it. If optional prefix argument LOCAL is non-nil, 'cvs update -l' is run." t) + +(autoload 'cvs-update-other-window "pcl-cvs" + "Run a 'cvs update' in the current working directory. Feed the +output to a *cvs* buffer, display it in the other window, and run +cvs-mode on it. + +If optional prefix argument LOCAL is non-nil, 'cvs update -l' is run." + t) diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.el b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.el index 99da369..9bbbd38 100644 --- a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.el +++ b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.el @@ -1,6 +1,6 @@ -;;; pcl-cvs.el,v 1.2 1992/04/07 20:49:19 berliner Exp -;;; pcl-cvs.el -- A Front-end to CVS 1.3 or later. Release 1.02. -;;; Copyright (C) 1991, 1992 Per Cederqvist +;;; @(#) Id: pcl-cvs.el,v 1.93 1993/05/31 22:44:00 ceder Exp +;;; pcl-cvs.el -- A Front-end to CVS 1.3 or later. Release 1.05. +;;; Copyright (C) 1991, 1992, 1993 Per Cederqvist ;;; ;;; This program is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by @@ -22,8 +22,12 @@ ;;;; General Public License is included in that file. You should read ;;;; it to get the most from this package. +;;;; Send bug reports and improvements to ceder@lysator.liu.se or +;;;; ceder@signum.se. Talk some about Signum Support here. +++FIXME + ;;; Don't try to use this with CVS 1.2 or earlier. It won't work. Get -;;; CVS 1.3. +;;; CVS 1.3. This package works together with RCS 5.6 and probably 5.5 +;;; as well. ;;; Mail questions and bug reports to ceder@lysator.liu.se. @@ -39,8 +43,8 @@ (defvar cvs-diff-program "/usr/gnu/bin/diff" "*Full path to the diff program.") -(defvar cvs-rm-program "/usr/gnu/bin/rm" - "*Full path to the rm program. Typically /bin/rm.") +(defvar cvs-rmdir-program "/usr/gnu/bin/rmdir" + "*Full path to the rmdir program. Typically /bin/rmdir.") ;; Uncomment the following line if you are running on 18.57 or earlier. ;(setq delete-exited-processes nil) @@ -49,9 +53,24 @@ ;; memory, and 18.57 forgets to GCPROT a variable if ;; delete-exited-processes is t. +(defvar cvs-shell "/bin/sh" + "*Full path to a shell that can do redirection on stdout.") + ;;; END OF THINGS TO CHECK WHEN INSTALLING ;;; -------------------------------------------------------- +(defvar cvs-cvsroot nil + "*Specifies where the (current) cvs master repository is. +Overrides the $CVSROOT variable by sending \" -d dir\" to all cvs commands. +This switch is useful if you have multiple CVS repositories.") + +(defvar cvs-stdout-file nil + "Name of the file that holds the output that CVS sends to stdout. +This variable is buffer local.") + +(defvar cvs-lock-file nil + "Full path to a lock file that CVS is waiting for (or was waiting for).") + (defvar cvs-bakprefix ".#" "The prefix that CVS prepends to files when rcsmerge'ing.") @@ -59,11 +78,17 @@ "*Non-nil if input buffers should be cleared before asking for new info.") (defvar cvs-auto-remove-handled nil - "*Non-nil if cvs-remove-handled should be called automatically. + "*Non-nil if cvs-mode-remove-handled should be called automatically. If this is set to any non-nil value entries that does not need to be -checked in will be removed from the *cvs* buffer after every cvs-commit +checked in will be removed from the *cvs* buffer after every cvs-mode-commit command.") +(defvar cvs-sort-ignore-file t + "*Non-nil if cvs-mode-ignore should sort the .cvsignore automatically.") + +(defvar cvs-auto-revert-after-commit t + "*Non-nil if committed buffers should be automatically reverted.") + (defconst cvs-cursor-column 14 "Column to position cursor in in cvs-mode. Column 0 is left-most column.") @@ -81,14 +106,21 @@ Column 0 is left-most column.") "Name of buffer in which the user is prompted for a log message when committing files.") +(defvar cvs-commit-buffer-require-final-newline t + "*t says silently put a newline at the end of commit log messages. +Non-nil but not t says ask user whether to add a newline in each such case. +nil means don't add newlines.") + (defvar cvs-temp-buffer-name "*cvs-tmp*" "*Name of the cvs temporary buffer. Output from cvs is placed here by synchronous commands.") -(defvar cvs-cvs-diff-flags nil - "*List of strings to use as flags to pass to ``cvs diff''. -Used by cvs-diff-cvs. -Set this to '("-u") to get a Unidiff format, or '("-c") to get context diffs.") +(defvar cvs-diff-ignore-marks nil + "*Non-nil if cvs-diff and cvs-mode-diff-backup should ignore any marked files. +Normally they run diff on the files that are marked (with cvs-mode-mark), +or the file under the cursor if no files are marked. If this variable +is set to a non-nil value they will always run diff on the file on the +current line.") (defvar cvs-status-flags nil "*List of strings to pass to ``cvs status''.") @@ -97,8 +129,21 @@ Set this to '("-u") to get a Unidiff format, or '("-c") to get context diffs.") "*List of strings to pass to ``cvs log''.") (defvar cvs-diff-flags nil - "*List of strings to use as flags to pass to ``diff''. -Do not confuse with cvs-cvs-diff-flags. Used by cvs-diff-backup.") + "*List of strings to use as flags to pass to ``diff'' and ``cvs diff''. +Used by cvs-mode-diff-cvs and cvs-mode-diff-backup. +Set this to '(\"-u\") to get a Unidiff format, or '(\"-c\") to get context diffs.") + +(defvar cvs-update-prog-output-skip-regexp "$" + "*A regexp that matches the end of the output from all cvs update programs. +That is, output from any programs that are run by CVS (by the flag -u +in the `modules' file - see cvs(5)) when `cvs update' is performed should +terminate with a line that this regexp matches. It is enough that +some part of the line is matched. + +The default (a single $) fits programs without output.") + +;; The variables below are used internally by pcl-cvs. You should +;; never change them. (defvar cvs-buffers-to-delete nil "List of temporary buffers that should be discarded as soon as possible. @@ -110,21 +155,29 @@ Due to a bug in emacs 18.57 the sentinel can't discard them reliably.") ;; to their .emacs they can get rid of it. Just don't add that line ;; to your default.el! (defvar cvs-inhibit-copyright-message nil - "*Don't display a Copyright message in the ``*cvs*'' buffer.") + "*Non-nil means don't display a Copyright message in the ``*cvs*'' buffer.") -(defvar cvs-startup-message +(defconst pcl-cvs-version "1.05" + "A string denoting the current release version of pcl-cvs.") + +(defconst cvs-startup-message (if cvs-inhibit-copyright-message - "PCL-CVS release 1.02" - "PCL-CVS release 1.02. Copyright (C) 1992 Per Cederqvist + "PCL-CVS release 1.05" + "PCL-CVS release 1.05. Copyright (C) 1992, 1993 Per Cederqvist Pcl-cvs comes with absolutely no warranty; for details consult the manual. This is free software, and you are welcome to redistribute it under certain conditions; again, consult the TeXinfo manual for details.") "*Startup message for CVS.") -(defvar cvs-cvs-buffer nil - "Internal to pcl-cvs.el. -This variable exists in the *cvs-commit-message* buffer and names -the *cvs* buffer.") +(defvar cvs-update-running nil + "This is set to nil when no process is running, and to +the process when a cvs update process is running.") + +(defvar cvs-cookie-handle nil + "Handle for the cookie structure that is displayed in the *cvs* buffer.") + +(defvar cvs-mode-commit nil + "Used internally by pcl-cvs.") ;;; The cvs data structure: ;;; @@ -148,15 +201,20 @@ the *cvs* buffer.") ;;; CONFLICT - conflict when merging ;;; REM-CONFLICT-removed in repository, changed locally. ;;; MOD-CONFLICT-removed locally, changed in repository. +;;; REM-EXIST -removed locally, but still exists. ;;; DIRCHANGE - A change of directory. ;;; UNKNOWN - An unknown file. ;;; MOVE-AWAY - A file that is in the way. ;;; REPOS-MISSING- The directory is removed from the ;;; repository. Go fetch a backup. +;;; MESSAGE - This is a special fileinfo that is used +;;; to display a text that should be in +;;; full-log. ;;; dir Directory the file resides in. Should not end with ;;; slash. ;;; file-name The file name. -;;; backup-file Name of the backup file if MERGED or CONFLICT. +;;; base-revision The revision that the working file was based on. +;;; Onlyy valid for MERGED and CONFLICT files. ;;; cvs-diff-buffer A buffer that contains a 'cvs diff file'. ;;; backup-diff-buffer A buffer that contains a 'diff file backup-file'. ;;; full-log The output from cvs, unparsed. @@ -191,11 +249,15 @@ A fileinfo has the following fields: REM-CONFLICT-removed in repository, but altered locally. MOD-CONFLICT-removed locally, changed in repository. + REM-EXIST - removed locally, but still exists. DIRCHANGE - A change of directory. UNKNOWN - An unknown file. MOVE-AWAY - A file that is in the way. REPOS-MISSING- The directory has vanished from the repository. + MESSAGE - This is a special fileinfo that is used + to display a text that should be in + full-log. dir Directory the file resides in. Should not end with slash. file-name The file name. backup-file Name of the backup file if MERGED or CONFLICT. @@ -222,8 +284,8 @@ A fileinfo has the following fields: (defun cvs-fileinfo->type (cvs-fileinfo) "Get type from CVS-FILEINFO. Type is one of UPDATED, MODIFIED, ADDED, REMOVED, CVS-REMOVED, MERGED, -CONFLICT, REM-CONFLICT, MOD-CONFLICT, DIRCHANGE, UNKNOWN, MOVE-AWAY -or REPOS-MISSING." +CONFLICT, REM-CONFLICT, MOD-CONFLICT, REM-EXIST, DIRCHANGE, UNKNOWN, MOVE-AWAY, +REPOS-MISSING or MESSAGE." (elt (cdr cvs-fileinfo) 2)) (defun cvs-fileinfo->dir (cvs-fileinfo) @@ -235,8 +297,8 @@ The directory name does not end with a slash. " "Get file-name from CVS-FILEINFO." (elt (cdr cvs-fileinfo) 4)) -(defun cvs-fileinfo->backup-file (cvs-fileinfo) - "Get backup-file from CVS-FILEINFO." +(defun cvs-fileinfo->base-revision (cvs-fileinfo) + "Get the base revision from CVS-FILEINFO." (elt (cdr cvs-fileinfo) 5)) (defun cvs-fileinfo->cvs-diff-buffer (cvs-fileinfo) @@ -278,8 +340,8 @@ The directory should now end with a slash." "Set file-name in CVS-FILEINFO to NEWVAL." (aset (cdr cvs-fileinfo) 4 newval)) -(defun cvs-set-fileinfo->backup-file (cvs-fileinfo newval) - "Set backup-file in CVS-FILEINFO to NEWVAL." +(defun cvs-set-fileinfo->base-revision (cvs-fileinfo newval) + "Set base-revision in CVS-FILEINFO to NEWVAL." (aset (cdr cvs-fileinfo) 5 newval)) (defun cvs-set-fileinfo->cvs-diff-buffer (cvs-fileinfo newval) @@ -313,10 +375,12 @@ The directory should now end with a slash." The selected window will not be changed. The temporary buffer will be erased and writable." - (display-buffer (get-buffer-create cvs-temp-buffer-name)) - (set-buffer cvs-temp-buffer-name) - (setq buffer-read-only nil) - (erase-buffer)) + (let ((dir default-directory)) + (display-buffer (get-buffer-create cvs-temp-buffer-name)) + (set-buffer cvs-temp-buffer-name) + (setq buffer-read-only nil) + (setq default-directory dir) + (erase-buffer))) ; Too complicated to handle all the cases that are generated. ; Maybe later. @@ -337,7 +401,20 @@ If optional prefix argument LOCAL is non-nil, 'cvs update -l' is run." (interactive (list (read-file-name "CVS Update (directory): " nil default-directory nil) current-prefix-arg)) - (cvs-do-update directory local nil)) + (cvs-do-update directory local nil) + (switch-to-buffer cvs-buffer-name)) + +(defun cvs-update-other-window (directory &optional local) + "Run a 'cvs update' in the current working directory. Feed the +output to a *cvs* buffer, display it in the other window, and run +cvs-mode on it. + +If optional prefix argument LOCAL is non-nil, 'cvs update -l' is run." + (interactive (list (read-file-name "CVS Update other window (directory): " + nil default-directory nil) + current-prefix-arg)) + (cvs-do-update directory local nil) + (switch-to-buffer-other-window cvs-buffer-name)) (defun cvs-filter (predicate list &rest extra-args) "Apply PREDICATE to each element on LIST. @@ -356,58 +433,109 @@ passed to PREDICATE." (setq list (cdr list))) (cdr head))) -(defun cvs-update-no-prompt () +(defun cvs-mode-update-no-prompt () "Run cvs update in current directory." (interactive) (cvs-do-update default-directory nil nil)) (defun cvs-do-update (directory local dont-change-disc) "Do a 'cvs update' in DIRECTORY. +Args: DIRECTORY LOCAL DONT-CHANGE-DISC &optional NOTTHISWINDOW. If LOCAL is non-nil 'cvs update -l' is executed. If DONT-CHANGE-DISC is non-nil 'cvs -n update' is executed. Both LOCAL and DONT-CHANGE-DISC may be non-nil simultaneously. *Note*: DONT-CHANGE-DISC does not yet work. The parser gets confused." (save-some-buffers) + (if (not (file-exists-p cvs-program)) + (error "%s: file not found (check setting of cvs-program)" + cvs-program)) + (if (not (or (getenv "CVSROOT") cvs-cvsroot)) + (error "Both cvs-cvsroot and environment variable CVSROOT unset.")) (let* ((this-dir (file-name-as-directory (expand-file-name directory))) - (use-this-window (equal (buffer-name (current-buffer)) - cvs-buffer-name)) (update-buffer (generate-new-buffer (concat (file-name-nondirectory (substring this-dir 0 -1)) "-update"))) - cvs-process args) - - ;; The *cvs* buffer is killed to avoid confusion - is the update ready - ;; or not? - (if (get-buffer cvs-buffer-name) - (kill-buffer cvs-buffer-name)) - - ;; Generate "-n update -l". - (if local (setq args (list "-l"))) - (setq args (cons "update" args)) - (if dont-change-disc (setq args (cons "-n" args))) - - ;; Set up the buffer that receives the output from "cvs update". - (if use-this-window - (switch-to-buffer update-buffer) - (set-buffer update-buffer) - (display-buffer update-buffer)) - + (temp-name (make-temp-name + (concat (file-name-as-directory + (or (getenv "TMPDIR") "/tmp")) + "pcl-cvs."))) + (args nil)) + + ;; Check that this-dir exists and is a directory that is under CVS contr. + + (if (not (file-directory-p this-dir)) + (error "%s is not a directory." this-dir)) + (if (not (file-directory-p (concat this-dir "CVS"))) + (error "%s does not contain CVS controlled files." this-dir)) + + ;; Check that at most one `cvs update' is run at any time. + + (if (and cvs-update-running (process-status cvs-update-running) + (or (eq (process-status cvs-update-running) 'run) + (eq (process-status cvs-update-running) 'stop))) + (error "Can't run two `cvs update' simultaneously.")) + + ;; Generate "-d /master -n update -l". + (setq args (concat (if cvs-cvsroot (concat " -d " cvs-cvsroot)) + (if dont-change-disc " -n ") + " update " + (if local " -l "))) + + ;; Set up the buffer that receives the stderr output from "cvs update". + (set-buffer update-buffer) (setq default-directory this-dir) - (setq cvs-process + (make-local-variable 'cvs-stdout-file) + (setq cvs-stdout-file temp-name) + + (setq cvs-update-running (let ((process-connection-type nil)) ; Use a pipe, not a pty. - (apply 'start-process "cvs" update-buffer cvs-program args))) + (start-process "cvs" update-buffer cvs-shell "-c" + (concat cvs-program " " args " > " temp-name)))) (setq mode-line-process (concat ": " - (symbol-name (process-status cvs-process)))) + (symbol-name (process-status cvs-update-running)))) (set-buffer-modified-p (buffer-modified-p)) ; Update the mode line. - (set-process-sentinel cvs-process 'cvs-sentinel) + (set-process-sentinel cvs-update-running 'cvs-sentinel) + (set-process-filter cvs-update-running 'cvs-update-filter) + (set-marker (process-mark cvs-update-running) (point-min)) + + (save-excursion + (set-buffer (get-buffer-create cvs-buffer-name)) + (setq buffer-read-only nil) + (erase-buffer) + (cvs-mode)) + + (setq cvs-cookie-handle + (collection-create + cvs-buffer-name 'cvs-pp + cvs-startup-message ;Se comment above cvs-startup-message. + "---------- End -----")) + + (cookie-enter-first + cvs-cookie-handle + (cvs-create-fileinfo + 'MESSAGE nil nil (concat "\n Running `cvs " args "' in " this-dir + "...\n"))) + + (save-excursion + (set-buffer cvs-buffer-name) + (setq mode-line-process + (concat ": " + (symbol-name (process-status cvs-update-running)))) + (set-buffer-modified-p (buffer-modified-p)) ; Update the mode line. + (setq buffer-read-only t)) ;; Work around a bug in emacs 18.57 and earlier. (setq cvs-buffers-to-delete - (cvs-delete-unused-temporary-buffers cvs-buffers-to-delete)))) + (cvs-delete-unused-temporary-buffers cvs-buffers-to-delete))) + + ;; The following line is said to improve display updates on some + ;; emacses. It shouldn't be needed, but it does no harm. + (sit-for 0)) + (defun cvs-delete-unused-temporary-buffers (list) "Delete all buffers on LIST that is not visible. @@ -430,27 +558,30 @@ Return a list of all buffers that still is alive." To get the *cvs* buffer you should use ``\\[cvs-update]''. -Full documentation is in the TeXinfo file. These are the most useful commands: - -\\[cookie-previous-cookie] Move up. \\[cookie-next-cookie] Move down. -\\[cvs-commit] Commit file. \\[cvs-update-no-prompt] Reupdate directory. -\\[cvs-mark] Mark file/dir. \\[cvs-unmark] Unmark file/dir. -\\[cvs-mark-all-files] Mark all files. \\[cvs-unmark-all-files] Unmark all files. -\\[cvs-find-file] Edit file/run Dired. \\[cvs-find-file-other-window] Find file or run Dired in other window. -\\[cvs-remove-handled] Remove processed entries. \\[cvs-add-change-log-entry-other-window] Write ChangeLog in other window. -\\[cvs-add] Add to repository. \\[cvs-remove-file] Remove file. -\\[cvs-diff-cvs] Diff between base revision. \\[cvs-diff-backup] Diff backup file. -\\[cvs-acknowledge] Delete line from buffer. \\[cvs-ignore] Add file to the .cvsignore file. -\\[cvs-log] Run ``cvs log''. \\[cvs-status] Run ``cvs status''. +Full documentation is in the Texinfo file. These are the most useful commands: + +\\[cvs-mode-previous-line] Move up. \\[cvs-mode-next-line] Move down. +\\[cvs-mode-commit] Commit file. \\[cvs-mode-update-no-prompt] Reupdate directory. +\\[cvs-mode-mark] Mark file/dir. \\[cvs-mode-unmark] Unmark file/dir. +\\[cvs-mode-mark-all-files] Mark all files. \\[cvs-mode-unmark-all-files] Unmark all files. +\\[cvs-mode-find-file] Edit file/run Dired. \\[cvs-mode-find-file-other-window] Find file or run Dired in other window. +\\[cvs-mode-remove-handled] Remove processed entries. \\[cvs-mode-add-change-log-entry-other-window] Write ChangeLog in other window. +\\[cvs-mode-add] Add to repository. \\[cvs-mode-remove-file] Remove file. +\\[cvs-mode-diff-cvs] Diff between base revision. \\[cvs-mode-diff-backup] Diff backup file. +\\[cvs-mode-emerge] Run emerge on base revision/backup file. +\\[cvs-mode-acknowledge] Delete line from buffer. \\[cvs-mode-ignore] Add file to the .cvsignore file. +\\[cvs-mode-log] Run ``cvs log''. \\[cvs-mode-status] Run ``cvs status''. +\\[cvs-mode-undo-local-changes] Revert the last checked in version - discard your changes to the file. Entry to this mode runs cvs-mode-hook. -This description is updated for release 1.02 of pcl-cvs. +This description is updated for release 1.05 of pcl-cvs. + All bindings: \\{cvs-mode-map}" (interactive) (setq major-mode 'cvs-mode) (setq mode-name "CVS") - (setq buffer-read-only nil) + (setq mode-line-process nil) (buffer-flush-undo (current-buffer)) (make-local-variable 'goal-column) (setq goal-column cvs-cursor-column) @@ -477,10 +608,16 @@ it is finished." (setq mode-line-process (concat ": " (symbol-name (process-status proc)))) - (cvs-parse-buffer) - (setq cvs-buffers-to-delete - (cons (process-buffer proc) cvs-buffers-to-delete))) - (set-buffer-modified-p (buffer-modified-p))) + (let* ((out-file cvs-stdout-file) + (stdout-buffer (find-file-noselect out-file))) + (cvs-parse-update stdout-buffer (process-buffer proc)) + (setq cvs-buffers-to-delete + (cons (process-buffer proc) + (cons stdout-buffer + cvs-buffers-to-delete))) + (delete-file out-file))) + (set-buffer-modified-p (buffer-modified-p)) + (setq cvs-update-running nil)) (if (equal obuf (process-buffer proc)) nil (set-buffer (process-buffer proc)) @@ -488,9 +625,90 @@ it is finished." (goto-char opoint)) (set-buffer obuf)))))) -(defun cvs-skip-line (regexp errormsg &optional arg) +(defun cvs-update-filter (proc string) + "Filter function for pcl-cvs. +This function gets the output that CVS sends to stderr. It inserts it +into (process-buffer proc) but it also checks if CVS is waiting for a +lock file. If so, it inserts a message cookie in the *cvs* buffer." + (let ((old-buffer (current-buffer)) + (data (match-data))) + (unwind-protect + (progn + (set-buffer (process-buffer proc)) + (save-excursion + ;; Insert the text, moving the process-marker. + (goto-char (process-mark proc)) + (insert string) + (set-marker (process-mark proc) (point)) + ;; Delete any old lock message + (if (tin-nth cvs-cookie-handle 1) + (tin-delete cvs-cookie-handle + (tin-nth cvs-cookie-handle 1))) + ;; Check if CVS is waiting for a lock. + (beginning-of-line 0) ;Move to beginning of last + ;complete line. + (cond + ((looking-at + "^cvs update: \\[..:..:..\\] waiting \ +for \\(.*\\)lock in \\(.*\\)$") + (setq cvs-lock-file (buffer-substring (match-beginning 2) + (match-end 2))) + (cookie-enter-last + cvs-cookie-handle + (cvs-create-fileinfo + 'MESSAGE nil nil + (concat "\tWaiting for " + (buffer-substring (match-beginning 1) + (match-end 1)) + "lock in " cvs-lock-file + ".\n\t (type M-x cvs-delete-lock to delete it)"))))))) + (store-match-data data) + (set-buffer old-buffer)))) + +(defun cvs-delete-lock () + "Delete the lock file that CVS is waiting for. +Note that this can be dangerous. You should only do this +if you are convinced that the process that created the lock is dead." + (interactive) + (cond + ((not (or (file-exists-p + (concat (file-name-as-directory cvs-lock-file) "#cvs.lock")) + (cvs-filter (function cvs-lock-file-p) + (directory-files cvs-lock-file)))) + (error "No lock files found.")) + ((yes-or-no-p (concat "Really delete locks in " cvs-lock-file "? ")) + ;; Re-read the directory -- the locks might have disappeared. + (let ((locks (cvs-filter (function cvs-lock-file-p) + (directory-files cvs-lock-file)))) + (while locks + (delete-file (concat (file-name-as-directory cvs-lock-file) + (car locks))) + (setq locks (cdr locks))) + (cvs-remove-directory + (concat (file-name-as-directory cvs-lock-file) "#cvs.lock")))))) + +(defun cvs-remove-directory (dir) + "Remove a directory." + (if (file-directory-p dir) + (call-process cvs-rmdir-program nil nil nil dir) + (error "Not a directory: %s" dir)) + (if (file-exists-p dir) + (error "Could not remove directory %s" dir))) + +(defun cvs-lock-file-p (file) + "Return true if FILE looks like a CVS lock file." + (or + (string-match "^#cvs.tfl.[0-9]+$" file) + (string-match "^#cvs.rfl.[0-9]+$" file) + (string-match "^#cvs.wfl.[0-9]+$" file))) + +(defun cvs-skip-line (stdout stderr regexp &optional arg) "Like forward-line, but check that the skipped line matches REGEXP. -If it doesn't match REGEXP (error ERRORMSG) is called. +Args: STDOUT STDERR REGEXP &optional ARG. + +If it doesn't match REGEXP a bug report is generated and displayed. +STDOUT and STDERR is only used to do that. + If optional ARG, a number, is given the ARGth parenthesized expression in the REGEXP is returned as a string. Point should be in column 1 when this function is called." @@ -501,203 +719,297 @@ Point should be in column 1 when this function is called." (buffer-substring (match-beginning arg) (match-end arg)))) (t - (error errormsg)))) - -(defun cvs-get-current-dir (dirname) - "Return current working directory, suitable for cvs-parse-buffer. -Args: DIRNAME. -Concatenates default-directory and DIRNAME to form an absolute path." + (cvs-parse-error stdout stderr + (if (eq (current-buffer) stdout) 'STDOUT 'STDERR) + (point))))) + +(defun cvs-get-current-dir (root-dir dirname) + "Return current working directory, suitable for cvs-parse-update. +Args: ROOT-DIR DIRNAME. +Concatenates ROOT-DIR and DIRNAME to form an absolute path." (if (string= "." dirname) - (substring default-directory 0 -1) - (concat default-directory dirname))) + (substring root-dir 0 -1) + (concat root-dir dirname))) +(defun cvs-compare-fileinfos (a b) + "Compare fileinfo A with fileinfo B and return t if A is `less'." + (cond + ;; Sort acording to directories. + ((string< (cvs-fileinfo->dir a) (cvs-fileinfo->dir b)) t) + ((not (string= (cvs-fileinfo->dir a) (cvs-fileinfo->dir b))) nil) + + ;; The DIRCHANGE entry is always first within the directory. + ((and (eq (cvs-fileinfo->type a) 'DIRCHANGE) + (not (eq (cvs-fileinfo->type b) 'DIRCHANGE))) t) + ((and (eq (cvs-fileinfo->type b) 'DIRCHANGE) + (not (eq (cvs-fileinfo->type a) 'DIRCHANGE))) nil) + ;; All files are sorted by file name. + ((string< (cvs-fileinfo->file-name a) (cvs-fileinfo->file-name b))))) + +(defun cvs-parse-error (stdout-buffer stderr-buffer err-buf pos) + "Handle a parse error when parsing the output from cvs. +Args: STDOUT-BUFFER STDERR-BUFFER ERR-BUF POS. +ERR-BUF should be 'STDOUT or 'STDERR." + (setq pos (1- pos)) + (set-buffer cvs-buffer-name) + (setq buffer-read-only nil) + (erase-buffer) + (insert "To: ceder@lysator.liu.se\n") + (insert "Subject: pcl-cvs " pcl-cvs-version " parse error.\n") + (insert "--text follows this line--\n\n") + (insert "This bug report is automatically generated by pcl-cvs\n") + (insert "because it doesn't understand some output from CVS. Below\n") + (insert "is detailed information about the error. Please send\n") + (insert "this, together with any information you think might be\n") + (insert "useful for me to fix the bug, to the address above. But\n") + (insert "please check the \"known problems\" section of the\n") + (insert "documentation first. Note that this buffer contains\n") + (insert "information that you might consider confidential. You\n") + (insert "are encouraged to read through it before sending it.\n") + (insert "\n") + (insert "Press C-c C-c to send this email.\n\n") + (insert "Please state the version of these programs you are using:\n") + (insert "RCS: \ndiff: \n\n") + + (let* ((stdout (save-excursion (set-buffer stdout-buffer) (buffer-string))) + (stderr (save-excursion (set-buffer stderr-buffer) (buffer-string))) + (errstr (if (eq err-buf 'STDOUT) stdout stderr)) + (errline-end (string-match "\n" errstr pos)) + (errline (substring errstr pos errline-end))) + (insert (format "Offending line (%d chars): >" (- errline-end pos))) + (insert errline) + (insert "<\n") + (insert "Sent to " (symbol-name err-buf) " at pos " (format "%d\n" pos)) + (insert "Emacs-version: " (emacs-version) "\n") + (insert "Pcl-cvs $" "Id:" "$" ": " "Id: pcl-cvs.el,v 1.93 1993/05/31 22:44:00 ceder Exp \n") + (insert "\n") + (insert (format "--- Contents of stdout buffer (%d chars) ---\n" + (length stdout))) + (insert stdout) + (insert "--- End of stdout buffer ---\n") + (insert (format "--- Contents of stderr buffer (%d chars) ---\n" + (length stderr))) + (insert stderr) + (insert "--- End of stderr buffer ---\n") + (insert "End of bug report.\n") + (require 'sendmail) + (mail-mode) + (error "CVS parse error - please report this bug."))) + +(defun cvs-parse-update (stdout-buffer stderr-buffer) + "Parse the output from `cvs update'. + +Args: STDOUT-BUFFER STDERR-BUFFER. + +This functions parses the from `cvs update' (which should be +separated in its stdout- and stderr-components) and prints a +pretty representation of it in the *cvs* buffer. -(defun cvs-parse-buffer () - "Parse the current buffer and select a *cvs* buffer. Signals an error if unexpected output was detected in the buffer." - (goto-char (point-min)) - (let ((buf (get-buffer-create cvs-buffer-name)) - (current-dir default-directory) - (root-dir default-directory) - (parse-buf (current-buffer))) - - (cookie-create - buf 'cvs-pp cvs-startup-message ;Se comment above cvs-startup-message. - "---------- End -----") - - (cookie-enter-first - buf - (cvs-create-fileinfo - 'DIRCHANGE current-dir - nil "")) + (let* ((head (cons 'dummy nil)) + (tail (cvs-parse-stderr stdout-buffer stderr-buffer + head default-directory)) + (root-dir default-directory)) + (cvs-parse-stdout stdout-buffer stderr-buffer tail root-dir) + (setq head (sort (cdr head) (function cvs-compare-fileinfos))) + + (collection-clear cvs-cookie-handle) + (collection-append-cookies cvs-cookie-handle head) + (cvs-remove-stdout-shadows) + (cvs-remove-empty-directories) + (set-buffer cvs-buffer-name) + (cvs-mode) + (goto-char (point-min)) + (tin-goto-previous cvs-cookie-handle (point-min) 1) + (setq default-directory root-dir))) + +(defun cvs-remove-stdout-shadows () + "Remove entries in the *cvs* buffer that comes from both stdout and stderr. +If there is two entries for a single file the second one should be +deleted. (Remember that sort uses a stable sort algorithm, so one can +be sure that the stderr entry is always first)." + (collection-filter-tins cvs-cookie-handle + (function + (lambda (tin) + (not (cvs-shadow-entry-p tin)))))) + +(defun cvs-shadow-entry-p (tin) + "Return non-nil if TIN is a shadow entry. +Args: TIN. +A TIN is a shadow entry if the previous tin contains the same file." + (let* ((previous-tin (tin-previous cvs-cookie-handle tin)) + (curr (tin-cookie cvs-cookie-handle tin)) + (prev (and previous-tin + (tin-cookie cvs-cookie-handle previous-tin)))) + (and + prev curr + (string= (cvs-fileinfo->file-name prev) (cvs-fileinfo->file-name curr)) + (string= (cvs-fileinfo->dir prev) (cvs-fileinfo->dir curr)) + (or + (and (eq (cvs-fileinfo->type prev) 'CONFLICT) + (eq (cvs-fileinfo->type curr) 'CONFLICT)) + (and (eq (cvs-fileinfo->type prev) 'MERGED) + (eq (cvs-fileinfo->type curr) 'MODIFIED)) + (and (eq (cvs-fileinfo->type prev) 'REM-EXIST) + (eq (cvs-fileinfo->type curr) 'REMOVED)))))) + + +(defun cvs-parse-stderr (stdout-buffer stderr-buffer head dir) + "Parse the output from CVS that is written to stderr. +Args: STDOUT-BUFFER STDERR-BUFFER HEAD DIR +STDOUT-BUFFER holds the output that cvs sent to stdout. It is only +used to create a bug report in case there is a parse error. +STDERR-BUFFER is the buffer that holds the output to parse. +HEAD is a cons-cell, the head of the list that is built. +DIR is the directory the `cvs update' was run in. + +This function returns the last cons-cell in the list that is built." - (while (< (point) (point-max)) - (cond + (save-window-excursion + (set-buffer stderr-buffer) + (goto-char (point-min)) + (let ((current-dir dir) + (root-dir dir)) - ;; CVS is descending a subdirectory. + (while (< (point) (point-max)) + (cond - ((looking-at "cvs update: Updating \\(.*\\)$") - (setq current-dir - (cvs-get-current-dir - (buffer-substring (match-beginning 1) (match-end 1)))) + ;; RCVS support (for now, we simply ignore any output from + ;; RCVS, including error messages!) - ;; Omit empty directories. - (if (eq (cvs-fileinfo->type (cookie-last buf)) - 'DIRCHANGE) - (cookie-delete-last buf)) + ((looking-at "updating of .* finished$") + (forward-line 1)) - (cookie-enter-last - buf - (cvs-create-fileinfo - 'DIRCHANGE current-dir - nil (buffer-substring (match-beginning 0) - (match-end 0)))) - (forward-line 1)) + ((looking-at "REMOTE FOLDER:.*") + (forward-line 1) + (while (and (< (point) (point-max)) (not (looking-at "phase 2.*"))) + (forward-line 1)) + (forward-line 2)) - ;; File removed, since it is removed (by third party) in repository. + ((looking-at "turn on remote mode$") + (forward-line 1) + (while (and (< (point) (point-max)) (not (looking-at "phase 2.*"))) + (forward-line 1)) + (forward-line 2)) + + ((looking-at "phase 3.*") + (goto-char (point-max))) + + ;; End of RCVS stuff. + + ;; CVS is descending a subdirectory. + + ((looking-at "cvs update: Updating \\(.*\\)$") + (setq current-dir + (cvs-get-current-dir + root-dir + (buffer-substring (match-beginning 1) (match-end 1)))) + (setcdr head (list (cvs-create-fileinfo + 'DIRCHANGE current-dir + nil (buffer-substring (match-beginning 0) + (match-end 0))))) + (setq head (cdr head)) + (forward-line 1)) + + ;; File removed, since it is removed (by third party) in repository. - ((or (looking-at "cvs update: warning: \\(.*\\) is not (any longer) \ -pertinent") - (looking-at "cvs update: \\(.*\\) is no longer in the repository")) - (cookie-enter-last - buf - (cvs-create-fileinfo - 'CVS-REMOVED current-dir - (file-name-nondirectory - (buffer-substring (match-beginning 1) (match-end 1))) - (buffer-substring (match-beginning 0) - (match-end 0)))) - (forward-line 1)) - - ;; File removed by you, but recreated by cvs. Ignored. - - ((looking-at "cvs update: warning: .* was lost$") - (forward-line 1)) - - ;; A file that has been created by you, but added to the cvs - ;; repository by another. - - ((looking-at "^cvs update: move away \\(.*\\); it is in the way$") - (cookie-enter-last - buf - (cvs-create-fileinfo - 'MOVE-AWAY current-dir - (file-name-nondirectory - (buffer-substring (match-beginning 1) (match-end 1))) - (buffer-substring (match-beginning 0) - (match-end 0)))) - (forward-line 1)) - - ;; Empty line. Probably inserted by mistake by user (or developer :-) - ;; Ignore. - - ((looking-at "^$") - (forward-line 1)) - - ;; Cvs waits for a lock. Ignore. - - ((looking-at - "^cvs update: \\[..:..:..\\] waiting for .*lock in ") - (forward-line 1)) - - ;; File removed in repository, but edited by you. - - ((looking-at - "cvs update: conflict: \\(.*\\) is modified but no longer \ + ((or (looking-at + "cvs update: warning: \\(.*\\) is not (any longer) pertinent") + (looking-at + "cvs update: \\(.*\\) is no longer in the repository")) + + (setcdr head (list (cvs-create-fileinfo + 'CVS-REMOVED current-dir + (file-name-nondirectory + (buffer-substring (match-beginning 1) + (match-end 1))) + (buffer-substring (match-beginning 0) + (match-end 0))))) + (setq head (cdr head)) + (forward-line 1)) + + ;; File removed by you, but recreated by cvs. Ignored. + + ((looking-at "cvs update: warning: .* was lost$") + (forward-line 1)) + + ;; A file that has been created by you, but added to the cvs + ;; repository by another. + + ((looking-at "^cvs update: move away \\(.*\\); it is in the way$") + (setcdr head (list (cvs-create-fileinfo + 'MOVE-AWAY current-dir + (file-name-nondirectory + (buffer-substring (match-beginning 1) + (match-end 1))) + (buffer-substring (match-beginning 0) + (match-end 0))))) + (setq head (cdr head)) + (forward-line 1)) + + ;; Empty line. Probably inserted by mistake by user (or developer :-) + ;; Ignore. + + ((looking-at "^$") + (forward-line 1)) + + ;; Cvs waits for a lock. Ignore. + + ((looking-at + "^cvs update: \\[..:..:..\\] waiting for .*lock in ") + (forward-line 1)) + + ;; File removed in repository, but edited by you. + + ((looking-at + "cvs update: conflict: \\(.*\\) is modified but no longer \ in the repository$") - (cookie-enter-last - buf - (cvs-create-fileinfo - 'REM-CONFLICT current-dir - (file-name-nondirectory - (buffer-substring (match-beginning 1) (match-end 1))) - (buffer-substring (match-beginning 0) - (match-end 0)))) - (forward-line 1)) - - ((looking-at - "cvs update: conflict: removed \\(.*\\) was modified by second party") - (cvs-create-fileinfo - 'MOD-CONFLICT current-dir - (buffer-substring (match-beginning 1) (match-end 1)) - (buffer-substring (match-beginning 0) (match-end 0))) - (forward-line 1)) - - ((looking-at "cvs update: in directory ") - (let ((start (point))) - (forward-line 1) - (cvs-skip-line - (regexp-quote "cvs [update aborted]: there is no repository ") - "Unexpected cvs output.") - (cookie-enter-last - buf - (cvs-create-fileinfo - 'REPOS-MISSING current-dir - nil - (buffer-substring start (point)))))) - - ;; The file is copied from the repository. - - ((looking-at "U \\(.*\\)$") - (cookie-enter-last - buf - (let ((fileinfo - (cvs-create-fileinfo - 'UPDATED current-dir - (file-name-nondirectory - (buffer-substring (match-beginning 1) (match-end 1))) - (buffer-substring (match-beginning 0) (match-end 0))))) - (cvs-set-fileinfo->handled fileinfo t) - fileinfo)) - (forward-line 1)) - - ;; The file is modified by the user, and untouched in the repository. - - ((looking-at "M \\(.*\\)$") - (cookie-enter-last - buf - (cvs-create-fileinfo - 'MODIFIED current-dir - (file-name-nondirectory - (buffer-substring (match-beginning 1) (match-end 1))) - (buffer-substring (match-beginning 0) (match-end 0)))) - (forward-line 1)) - - ;; The file is "cvs add"ed, but not "cvs ci"ed. - - ((looking-at "A \\(.*\\)$") - (cookie-enter-last - buf - (cvs-create-fileinfo - 'ADDED current-dir - (file-name-nondirectory - (buffer-substring (match-beginning 1) (match-end 1))) - (buffer-substring (match-beginning 0) (match-end 0)))) - (forward-line 1)) - - ;; The file is "cvs remove"ed, but not "cvs ci"ed. - - ((looking-at "R \\(.*\\)$") - (cookie-enter-last - buf - (cvs-create-fileinfo - 'REMOVED current-dir - (file-name-nondirectory - (buffer-substring (match-beginning 1) (match-end 1))) - (buffer-substring (match-beginning 0) (match-end 0)))) - (forward-line 1)) - - ;; Unknown file. + (setcdr head (list + (cvs-create-fileinfo + 'REM-CONFLICT current-dir + (file-name-nondirectory + (buffer-substring (match-beginning 1) (match-end 1))) + (buffer-substring (match-beginning 0) + (match-end 0))))) + (setq head (cdr head)) + (forward-line 1)) + + ((looking-at + "cvs update: conflict: removed \\(.*\\) was modified by \ +second party") + (setcdr head + (list + (cvs-create-fileinfo + 'MOD-CONFLICT current-dir + (buffer-substring (match-beginning 1) (match-end 1)) + (buffer-substring (match-beginning 0) (match-end 0))))) + (setq head (cdr head)) + (forward-line 1)) + + ((looking-at + "cvs update: \\(.*\\) should be removed and is still there") + (setcdr head + (list + (cvs-create-fileinfo + 'REM-EXIST current-dir + (buffer-substring (match-beginning 1) (match-end 1)) + (buffer-substring (match-beginning 0) (match-end 0))))) + (setq head (cdr head)) + (forward-line 1)) + + ((looking-at "cvs update: in directory ") + (let ((start (point))) + (forward-line 1) + (cvs-skip-line + stdout-buffer stderr-buffer + (regexp-quote "cvs [update aborted]: there is no repository ")) + (setcdr head (list + (cvs-create-fileinfo + 'REPOS-MISSING current-dir + nil + (buffer-substring start (point))))) + (setq head (cdr head)))) - ((looking-at "? \\(.*\\)$") - (cookie-enter-last - buf - (cvs-create-fileinfo - 'UNKNOWN current-dir - (file-name-nondirectory - (buffer-substring (match-beginning 1) (match-end 1))) - (buffer-substring (match-beginning 0) (match-end 0)))) - (forward-line 1)) (t ;; CVS has decided to merge someone elses changes into this @@ -708,79 +1020,149 @@ in the repository$") (let ((complex-start (point)) initial-revision filename) - (cvs-skip-line "^RCS file: .*$" "Parse error.") + (cvs-skip-line stdout-buffer stderr-buffer "^RCS file: .*$") (setq initial-revision - (cvs-skip-line "^retrieving revision \\(.*\\)$" - "Unexpected output from cvs." 1)) - (cvs-skip-line "^retrieving revision .*$" - "Unexpected output from cvs.") + (cvs-skip-line stdout-buffer stderr-buffer + "^retrieving revision \\(.*\\)$" 1)) + (cvs-skip-line stdout-buffer stderr-buffer + "^retrieving revision .*$") ;; Get the file name from the next line. (setq filename (cvs-skip-line + stdout-buffer stderr-buffer "^Merging differences between [0-9.]+ and [0-9.]+ into \\(.*\\)$" - "Unexpected output from cvs." 1)) (cond + ;; Was it a conflict? + ((looking-at + ;; Allow both RCS 5.5 and 5.6. (5.6 prints "rcs" and " warning"). + "^\\(rcs\\)?merge\\( warning\\)?: overlaps during merge$") - ;; The file was successfully merged. + ;; Yes, this is a conflict. + (cvs-skip-line + stdout-buffer stderr-buffer + "^\\(rcs\\)?merge\\( warning\\)?: overlaps during merge$") + + (cvs-skip-line stdout-buffer stderr-buffer + "^cvs update: conflicts found in ") - ((looking-at "^M ") - (forward-line 1) (let ((fileinfo (cvs-create-fileinfo - 'MERGED current-dir + 'CONFLICT current-dir filename (buffer-substring complex-start (point))))) - (cvs-set-fileinfo->backup-file - fileinfo - (concat cvs-bakprefix filename "." initial-revision)) - (cookie-enter-last - buf fileinfo))) - ;; A conflicting merge. + (cvs-set-fileinfo->base-revision fileinfo initial-revision) + + (setcdr head (list fileinfo)) + (setq head (cdr head)))) + + ;; Was it a conflict, and was RCS compiled without DIFF3_BIN? + + ((looking-at + ;; Allow both RCS 5.5 and 5.6. (5.6 prints "rcs" and " warning"). + "^\\(rcs\\)?merge\\( warning\\)?: overlaps or other probl\ +ems during merge$") + + ;; Yes, this is a conflict. + (cvs-skip-line + stdout-buffer stderr-buffer + "^\\(rcs\\)?merge\\( warning\\)?: overlaps .*during merge$") + + (cvs-skip-line stdout-buffer stderr-buffer + "^cvs update: could not merge ") + (cvs-skip-line stdout-buffer stderr-buffer + "^cvs update: restoring .* from backup file ") - (t - (cvs-skip-line "^merge: overlaps during merge$" - "Unexpected output from cvs.") - (cvs-skip-line "^cvs update: conflicts found in " - "Unexpected output from cvs.") - (cvs-skip-line "^C " "Unexpected cvs output.") (let ((fileinfo (cvs-create-fileinfo 'CONFLICT current-dir filename (buffer-substring complex-start (point))))) - (cvs-set-fileinfo->backup-file - fileinfo - (concat cvs-bakprefix filename "." initial-revision)) + (setcdr head (list fileinfo)) + (setq head (cdr head)))) + + (t + ;; Not a conflict; it must be a succesful merge. + (let ((fileinfo + (cvs-create-fileinfo + 'MERGED current-dir + filename + (buffer-substring complex-start (point))))) + (cvs-set-fileinfo->base-revision fileinfo initial-revision) + (setcdr head (list fileinfo)) + (setq head (cdr head))))))))))) + head) - (cookie-enter-last buf fileinfo)))))))) - ;; All parsing is done. +(defun cvs-parse-stdout (stdout-buffer stderr-buffer head root-dir) + "Parse the output from CVS that is written to stderr. +Args: STDOUT-BUFFER STDERR-BUFFER HEAD ROOT-DIR +STDOUT-BUFFER is the buffer that holds the output to parse. +STDERR-BUFFER holds the output that cvs sent to stderr. It is only +used to create a bug report in case there is a parse error. - ;; If the last entry is a directory, remove it. - (if (eq (cvs-fileinfo->type (cookie-last buf)) - 'DIRCHANGE) - (cookie-delete-last buf)) +HEAD is a cons-cell, the head of the list that is built. +ROOT-DIR is the directory the `cvs update' was run in. - (set-buffer buf) - (cvs-mode) - (setq cookie-last-tin (cookie-nth buf 0)) +This function doesn't return anything particular." + (save-window-excursion + (set-buffer stdout-buffer) (goto-char (point-min)) - (cookie-previous-cookie buf (point-min) 1) - (setq default-directory root-dir) - (if (get-buffer-window parse-buf) - (set-window-buffer (get-buffer-window parse-buf) buf) - (display-buffer buf)))) + (while (< (point) (point-max)) + (cond + ;; M: The file is modified by the user, and untouched in the repository. + ;; A: The file is "cvs add"ed, but not "cvs ci"ed. + ;; R: The file is "cvs remove"ed, but not "cvs ci"ed. + ;; C: Conflict + ;; U: The file is copied from the repository. + ;; ?: Unknown file. + + + ((looking-at "\\([MARCU?]\\) \\(.*\\)$") + (let* + ((c (char-after (match-beginning 1))) + (full-path + (concat (file-name-as-directory root-dir) + (buffer-substring (match-beginning 2) (match-end 2)))) + (fileinfo (cvs-create-fileinfo + (cond ((eq c ?M) 'MODIFIED) + ((eq c ?A) 'ADDED) + ((eq c ?R) 'REMOVED) + ((eq c ?C) 'CONFLICT) + ((eq c ?U) 'UPDATED) + ((eq c ??) 'UNKNOWN)) + (substring (file-name-directory full-path) 0 -1) + (file-name-nondirectory full-path) + (buffer-substring (match-beginning 0) (match-end 0))))) + ;; Updated files require no further action. + (if (eq c ?U) + (cvs-set-fileinfo->handled fileinfo t)) + + ;; Link this last on the list. + (setcdr head (list fileinfo)) + (setq head (cdr head)) + (forward-line 1))) + + ;; Executing a program because of the -u option in modules. + ((looking-at "cvs update: Executing") + ;; Skip by any output the program may generate to stdout. + ;; Note that pcl-cvs will get seriously confused if the + ;; program prints anything to stderr. + (re-search-forward cvs-update-prog-output-skip-regexp) + (forward-line 1)) + + (t (cvs-parse-error stdout-buffer stderr-buffer 'STDOUT (point))))))) (defun cvs-pp (fileinfo) - "Pretty print FILEINFO into a string." + "Pretty print FILEINFO. Insert a printed representation in current buffer. +For use by the cookie package." (let ((a (cvs-fileinfo->type fileinfo)) (s (if (cvs-fileinfo->marked fileinfo) @@ -788,36 +1170,41 @@ in the repository$") (f (cvs-fileinfo->file-name fileinfo)) (ci (if (cvs-fileinfo->handled fileinfo) " " "ci"))) - (cond - ((eq a 'UPDATED) - (format "%s Updated %s" s f)) - ((eq a 'MODIFIED) - (format "%s Modified %s %s" s ci f)) - ((eq a 'MERGED) - (format "%s Merged %s %s" s ci f)) - ((eq a 'CONFLICT) - (format "%s Conflict %s" s f)) - ((eq a 'ADDED) - (format "%s Added %s %s" s ci f)) - ((eq a 'REMOVED) - (format "%s Removed %s %s" s ci f)) - ((eq a 'UNKNOWN) - (format "%s Unknown %s" s f)) - ((eq a 'CVS-REMOVED) - (format "%s Removed from repository: %s" s f)) - ((eq a 'REM-CONFLICT) - (format "%s Conflict: Removed from repository, changed by you: %s" s f)) - ((eq a 'MOD-CONFLICT) - (format "%s Conflict: Removed by you, changed in repository: %s" s f)) - ((eq a 'DIRCHANGE) - (format "\nIn directory %s:" - (cvs-fileinfo->dir fileinfo))) - ((eq a 'MOVE-AWAY) - (format "%s Move away %s - it is in the way" s f)) - ((eq a 'REPOS-MISSING) - (format " This repository is missing! Remove this dir manually.")) - (t - (format "%s Internal error! %s" s f))))) + (insert + (cond + ((eq a 'UPDATED) + (format "%s Updated %s" s f)) + ((eq a 'MODIFIED) + (format "%s Modified %s %s" s ci f)) + ((eq a 'MERGED) + (format "%s Merged %s %s" s ci f)) + ((eq a 'CONFLICT) + (format "%s Conflict %s" s f)) + ((eq a 'ADDED) + (format "%s Added %s %s" s ci f)) + ((eq a 'REMOVED) + (format "%s Removed %s %s" s ci f)) + ((eq a 'UNKNOWN) + (format "%s Unknown %s" s f)) + ((eq a 'CVS-REMOVED) + (format "%s Removed from repository: %s" s f)) + ((eq a 'REM-CONFLICT) + (format "%s Conflict: Removed from repository, changed by you: %s" s f)) + ((eq a 'MOD-CONFLICT) + (format "%s Conflict: Removed by you, changed in repository: %s" s f)) + ((eq a 'REM-EXIST) + (format "%s Conflict: Removed by you, but still exists: %s" s f)) + ((eq a 'DIRCHANGE) + (format "\nIn directory %s:" + (cvs-fileinfo->dir fileinfo))) + ((eq a 'MOVE-AWAY) + (format "%s Move away %s - it is in the way" s f)) + ((eq a 'REPOS-MISSING) + (format " This repository is missing! Remove this dir manually.")) + ((eq a 'MESSAGE) + (cvs-fileinfo->full-log fileinfo)) + (t + (format "%s Internal error! %s" s f)))))) ;;; You can define your own keymap in .emacs. pcl-cvs.el won't overwrite it. @@ -826,56 +1213,61 @@ in the repository$") nil (setq cvs-mode-map (make-keymap)) (suppress-keymap cvs-mode-map) - (define-key cvs-mode-map " " 'cookie-next-cookie) + (define-key cvs-mode-map " " 'cvs-mode-next-line) (define-key cvs-mode-map "?" 'describe-mode) - (define-key cvs-mode-map "A" 'cvs-add-change-log-entry-other-window) - (define-key cvs-mode-map "M" 'cvs-mark-all-files) - (define-key cvs-mode-map "U" 'cvs-unmark-all-files) - (define-key cvs-mode-map "\C-?" 'cvs-unmark-up) - (define-key cvs-mode-map "\C-n" 'cookie-next-cookie) - (define-key cvs-mode-map "\C-p" 'cookie-previous-cookie) - (define-key cvs-mode-map "a" 'cvs-add) - (define-key cvs-mode-map "b" 'cvs-diff-backup) - (define-key cvs-mode-map "c" 'cvs-commit) - (define-key cvs-mode-map "d" 'cvs-diff-cvs) - (define-key cvs-mode-map "f" 'cvs-find-file) - (define-key cvs-mode-map "g" 'cvs-update-no-prompt) - (define-key cvs-mode-map "i" 'cvs-ignore) - (define-key cvs-mode-map "l" 'cvs-log) - (define-key cvs-mode-map "m" 'cvs-mark) - (define-key cvs-mode-map "n" 'cookie-next-cookie) - (define-key cvs-mode-map "o" 'cvs-find-file-other-window) - (define-key cvs-mode-map "p" 'cookie-previous-cookie) - (define-key cvs-mode-map "r" 'cvs-remove-file) - (define-key cvs-mode-map "s" 'cvs-status) - (define-key cvs-mode-map "\C-k" 'cvs-acknowledge) - (define-key cvs-mode-map "x" 'cvs-remove-handled) - (define-key cvs-mode-map "u" 'cvs-unmark)) - - -(defun cvs-get-marked () + (define-key cvs-mode-map "A" 'cvs-mode-add-change-log-entry-other-window) + (define-key cvs-mode-map "M" 'cvs-mode-mark-all-files) + (define-key cvs-mode-map "R" 'cvs-mode-revert-updated-buffers) + (define-key cvs-mode-map "U" 'cvs-mode-undo-local-changes) + (define-key cvs-mode-map "\C-?" 'cvs-mode-unmark-up) + (define-key cvs-mode-map "\C-k" 'cvs-mode-acknowledge) + (define-key cvs-mode-map "\C-n" 'cvs-mode-next-line) + (define-key cvs-mode-map "\C-p" 'cvs-mode-previous-line) + (define-key cvs-mode-map "\M-\C-?" 'cvs-mode-unmark-all-files) + (define-key cvs-mode-map "a" 'cvs-mode-add) + (define-key cvs-mode-map "b" 'cvs-mode-diff-backup) + (define-key cvs-mode-map "c" 'cvs-mode-commit) + (define-key cvs-mode-map "d" 'cvs-mode-diff-cvs) + (define-key cvs-mode-map "e" 'cvs-mode-emerge) + (define-key cvs-mode-map "f" 'cvs-mode-find-file) + (define-key cvs-mode-map "g" 'cvs-mode-update-no-prompt) + (define-key cvs-mode-map "i" 'cvs-mode-ignore) + (define-key cvs-mode-map "l" 'cvs-mode-log) + (define-key cvs-mode-map "m" 'cvs-mode-mark) + (define-key cvs-mode-map "n" 'cvs-mode-next-line) + (define-key cvs-mode-map "o" 'cvs-mode-find-file-other-window) + (define-key cvs-mode-map "p" 'cvs-mode-previous-line) + (define-key cvs-mode-map "q" 'bury-buffer) + (define-key cvs-mode-map "r" 'cvs-mode-remove-file) + (define-key cvs-mode-map "s" 'cvs-mode-status) + (define-key cvs-mode-map "x" 'cvs-mode-remove-handled) + (define-key cvs-mode-map "u" 'cvs-mode-unmark)) + + +(defun cvs-get-marked (&optional ignore-marks) "Return a list of all selected tins. -If there are any marked tins, return them. +If there are any marked tins, and IGNORE-MARKS is nil, return them. Otherwise, if the cursor selects a directory, return all files in it. Otherwise return (a list containing) the file the cursor points to, or -an empty list if it doesn't point to a file at all." +an empty list if it doesn't point to a file at all. + +Args: &optional IGNORE-MARKS." (cond ;; Any marked cookies? - ((cookie-collect-tins (current-buffer) - 'cvs-fileinfo->marked)) + ((and (not ignore-marks) + (collection-collect-tin cvs-cookie-handle 'cvs-fileinfo->marked))) ;; Nope. (t - (let ((sel (cookie-get-selection - (current-buffer) (point) cookie-last-tin))) + (let ((sel (tin-locate cvs-cookie-handle (point)))) (cond ;; If a directory is selected, all it members are returned. ((and sel (eq (cvs-fileinfo->type - (cookie-cookie (current-buffer) sel)) + (tin-cookie cvs-cookie-handle sel)) 'DIRCHANGE)) - (cookie-collect-tins - (current-buffer) 'cvs-dir-member-p - (cvs-fileinfo->dir (cookie-cookie (current-buffer) sel)))) + (collection-collect-tin + cvs-cookie-handle 'cvs-dir-member-p + (cvs-fileinfo->dir (tin-cookie cvs-cookie-handle sel)))) (t (list sel))))))) @@ -885,30 +1277,66 @@ an empty list if it doesn't point to a file at all." (and (not (eq (cvs-fileinfo->type fileinfo) 'DIRCHANGE)) (string= (cvs-fileinfo->dir fileinfo) dir))) -(defun cvs-dir-empty-p (cvs-buf tin) +(defun cvs-dir-empty-p (tin) "Return non-nil if TIN is a directory that is empty. Args: CVS-BUF TIN." - (and (eq (cvs-fileinfo->type (cookie-cookie cvs-buf tin)) 'DIRCHANGE) - (or (not (cookie-next cvs-buf tin)) - (eq (cvs-fileinfo->type (cookie-cookie cvs-buf - (cookie-next cvs-buf tin))) + (and (eq (cvs-fileinfo->type (tin-cookie cvs-cookie-handle tin)) 'DIRCHANGE) + (or (not (tin-next cvs-cookie-handle tin)) + (eq (cvs-fileinfo->type + (tin-cookie cvs-cookie-handle + (tin-next cvs-cookie-handle tin))) 'DIRCHANGE)))) -(defun cvs-remove-handled () +(defun cvs-mode-revert-updated-buffers () + "Revert any buffers that are UPDATED, MERGED or CONFLICT." + (interactive) + (cookie-map (function cvs-revert-fileinfo) cvs-cookie-handle)) + +(defun cvs-revert-fileinfo (fileinfo) + "Revert the buffer that holds the file in FILEINFO if it has changed, +and if the type is UPDATED, MERGED or CONFLICT." + (let* ((type (cvs-fileinfo->type fileinfo)) + (file (cvs-fileinfo->full-path fileinfo)) + (buffer (get-file-buffer file))) + ;; For a revert to happen... + (cond + ((and + ;; ...the type must be one that justifies a revert... + (or (eq type 'UPDATED) + (eq type 'MERGED) + (eq type 'CONFLICT)) + ;; ...and the user must be editing the file... + buffer) + (save-excursion + (set-buffer buffer) + (cond + ((buffer-modified-p) + (error "%s: edited since last cvs-update." + (buffer-file-name))) + ;; Go ahead and revert the file. + (t (revert-buffer 'dont-use-auto-save-file 'dont-ask)))))))) + + +(defun cvs-mode-remove-handled () "Remove all lines that are handled. Empty directories are removed." (interactive) ;; Pass one: remove files that are handled. - (cookie-filter (current-buffer) + (collection-filter-cookies cvs-cookie-handle (function (lambda (fileinfo) (not (cvs-fileinfo->handled fileinfo))))) ;; Pass two: remove empty directories. - (cookie-filter-tins (current-buffer) - (function - (lambda (tin) - (not (cvs-dir-empty-p (current-buffer) tin)))))) + (cvs-remove-empty-directories)) + -(defun cvs-mark (pos) +(defun cvs-remove-empty-directories () + "Remove empty directories in the *cvs* buffer." + (collection-filter-tins cvs-cookie-handle + (function + (lambda (tin) + (not (cvs-dir-empty-p tin)))))) + +(defun cvs-mode-mark (pos) "Mark a fileinfo. Args: POS. If the fileinfo is a directory, all the contents of that directory are marked instead. A directory can never be marked. @@ -916,9 +1344,8 @@ POS is a buffer position." (interactive "d") - (let* ((tin (cookie-get-selection - (current-buffer) pos cookie-last-tin)) - (sel (cookie-cookie (current-buffer) tin))) + (let* ((tin (tin-locate cvs-cookie-handle pos)) + (sel (tin-cookie cvs-cookie-handle tin))) (cond ;; Does POS point to a directory? If so, mark all files in that directory. @@ -929,20 +1356,20 @@ POS is a buffer position." ((cvs-dir-member-p f dir) (cvs-set-fileinfo->marked f t) t)))) ;Tell cookie to redisplay this cookie. - (current-buffer) + cvs-cookie-handle (cvs-fileinfo->dir sel))) (t (cvs-set-fileinfo->marked sel t) - (cookie-invalidate-tins (current-buffer) tin) - (cookie-next-cookie (current-buffer) pos 1))))) + (tin-invalidate cvs-cookie-handle tin) + (tin-goto-next cvs-cookie-handle pos 1))))) -(defun cvs-committable (tin cvs-buf) +(defun cvs-committable (tin) "Check if the TIN is committable. It is committable if it a) is not handled and b) is either MODIFIED, ADDED, REMOVED, MERGED or CONFLICT." - (let* ((fileinfo (cookie-cookie cvs-buf tin)) + (let* ((fileinfo (tin-cookie cvs-cookie-handle tin)) (type (cvs-fileinfo->type fileinfo))) (and (not (cvs-fileinfo->handled fileinfo)) (or (eq type 'MODIFIED) @@ -951,7 +1378,7 @@ It is committable if it (eq type 'MERGED) (eq type 'CONFLICT))))) -(defun cvs-commit () +(defun cvs-mode-commit () "Check in all marked files, or the current file. The user will be asked for a log message in a buffer. @@ -963,8 +1390,7 @@ buffer so that it is easy to kill the contents of the buffer with \\[kill-region (let* ((cvs-buf (current-buffer)) (marked (cvs-filter (function cvs-committable) - (cvs-get-marked) - cvs-buf))) + (cvs-get-marked)))) (if (null marked) (error "Nothing to commit!") (pop-to-buffer (get-buffer-create cvs-commit-prompt-buffer)) @@ -976,35 +1402,68 @@ buffer so that it is easy to kill the contents of the buffer with \\[kill-region (cvs-edit-mode) (make-local-variable 'cvs-commit-list) (setq cvs-commit-list marked) - (make-local-variable 'cvs-cvs-buffer) - (setq cvs-cvs-buffer cvs-buf) (message "Press C-c C-c when you are done editing.")))) (defun cvs-edit-done () "Commit the files to the repository." (interactive) + (if (null cvs-commit-list) + (error "You have already commited the files")) + (if (and (> (point-max) 1) + (/= (char-after (1- (point-max))) ?\n) + (or (eq cvs-commit-buffer-require-final-newline t) + (and cvs-commit-buffer-require-final-newline + (yes-or-no-p + (format "Buffer %s does not end in newline. Add one? " + (buffer-name)))))) + (save-excursion + (goto-char (point-max)) + (insert ?\n))) (save-some-buffers) (let ((cc-list cvs-commit-list) - (cc-buffer cvs-cvs-buffer) + (cc-buffer (get-buffer cvs-buffer-name)) (msg-buffer (current-buffer)) (msg (buffer-substring (point-min) (point-max)))) (pop-to-buffer cc-buffer) (bury-buffer msg-buffer) (cvs-use-temp-buffer) (message "Committing...") - (cvs-execute-list cc-list cvs-program (list "commit" "-m" msg)) - (mapcar (function - (lambda (tin) - (cvs-set-fileinfo->handled (cookie-cookie cc-buffer tin) t))) - cc-list) - (apply 'cookie-invalidate-tins cc-buffer cc-list) + (if (cvs-execute-list cc-list cvs-program + (if cvs-cvsroot + (list "-d" cvs-cvsroot "commit" "-m" msg) + (list "commit" "-m" msg))) + (error "Something went wrong. Check the %s buffer carefully." + cvs-temp-buffer-name)) + (let ((ccl cc-list)) + (while ccl + (cvs-after-commit-function (tin-cookie cvs-cookie-handle (car ccl))) + (setq ccl (cdr ccl)))) + (apply 'tin-invalidate cvs-cookie-handle cc-list) + (set-buffer msg-buffer) + (setq cvs-commit-list nil) (set-buffer cc-buffer) (if cvs-auto-remove-handled - (cvs-remove-handled))) + (cvs-mode-remove-handled))) (message "Committing... Done.")) +(defun cvs-after-commit-function (fileinfo) + "Do everything that needs to be done when FILEINFO has been commited. +The fileinfo->handle is set, and if the buffer is present it is reverted." + (cvs-set-fileinfo->handled fileinfo t) + (if cvs-auto-revert-after-commit + (let* ((file (cvs-fileinfo->full-path fileinfo)) + (buffer (get-file-buffer file))) + ;; For a revert to happen... + (if buffer + ;; ...the user must be editing the file... + (save-excursion + (set-buffer buffer) + (if (not (buffer-modified-p)) + ;; ...but it must be unmodified. + (revert-buffer 'dont-use-auto-save-file 'dont-ask))))))) + (defun cvs-execute-list (tin-list program constant-args) "Run PROGRAM on all elements on TIN-LIST. @@ -1015,11 +1474,19 @@ arguments given to the program will be CONSTANT-ARGS followed by all the files (from TIN-LIST) that resides in that directory. If the files in TIN-LIST resides in different directories the PROGRAM will be run once for each directory (if all files in the same directory appears -after each other." - +after each other). + +Any output from PROGRAM will be inserted in the current buffer. + +This function return nil if all went well, or the numerical exit +status or a signal name as a string. Note that PROGRAM might be called +several times. This will return non-nil if something goes wrong, but +there is no way to know which process that failed." + + (let ((exitstatus nil)) (while tin-list (let ((current-dir (cvs-fileinfo->dir - (cookie-cookie cvs-buffer-name + (tin-cookie cvs-cookie-handle (car tin-list)))) arg-list arg-str) @@ -1029,10 +1496,10 @@ after each other." (string= current-dir (cvs-fileinfo->dir - (cookie-cookie cvs-buffer-name (car tin-list))))) + (tin-cookie cvs-cookie-handle (car tin-list))))) (setq arg-list (cons (cvs-fileinfo->file-name - (cookie-cookie cvs-buffer-name (car tin-list))) + (tin-cookie cvs-cookie-handle (car tin-list))) arg-list)) (setq tin-list (cdr tin-list))) @@ -1048,9 +1515,15 @@ after each other." (nconc (copy-sequence constant-args) arg-list) " "))) - (apply 'call-process program nil t t - (nconc (copy-sequence constant-args) arg-list)) - (goto-char (point-max))))) + (let ((res (apply 'call-process program nil t t + (nconc (copy-sequence constant-args) arg-list)))) + ;; Remember the first, or highest, exitstatus. + (if (and (not (and (integerp res) (zerop res))) + (or (null exitstatus) + (and (integerp exitstatus) (= 1 exitstatus)))) + (setq exitstatus res))) + (goto-char (point-max)))) + exitstatus)) (defun cvs-execute-single-file-list (tin-list extractor program constant-args) @@ -1070,11 +1543,11 @@ this file, or a list of arguments to send to the program." (while tin-list (let ((default-directory (file-name-as-directory (cvs-fileinfo->dir - (cookie-cookie cvs-buffer-name - (car tin-list))))) + (tin-cookie cvs-cookie-handle + (car tin-list))))) (arg-list (funcall extractor - (cookie-cookie cvs-buffer-name (car tin-list))))) + (tin-cookie cvs-cookie-handle (car tin-list))))) ;; Execute the command unless extractor returned t. @@ -1113,36 +1586,87 @@ This mode is based on fundamental mode." (define-key cvs-edit-mode-map "\C-c\C-c" 'cvs-edit-done)) -(defun cvs-diff-cvs () +(defun cvs-diffable (tins) + "Return a list of all tins on TINS that it makes sense to run +``cvs diff'' on." + ;; +++ There is an unnecessary (nreverse) here. Get the list the + ;; other way around instead! + (let ((result nil)) + (while tins + (let ((type (cvs-fileinfo->type + (tin-cookie cvs-cookie-handle (car tins))))) + (if (or (eq type 'MODIFIED) + (eq type 'UPDATED) + (eq type 'MERGED) + (eq type 'CONFLICT) + (eq type 'REMOVED) ;+++Does this line make sense? + (eq type 'ADDED)) ;+++Does this line make sense? + (setq result (cons (car tins) result))) + (setq tins (cdr tins)))) + (nreverse result))) + + +(defun cvs-mode-diff-cvs (&optional ignore-marks) "Diff the selected files against the repository. -The flags the variable cvs-cvs-diff-flags will be passed to ``cvs diff''." - (interactive) +The flags in the variable cvs-diff-flags (which should be a list +of strings) will be passed to ``cvs diff''. If the variable +cvs-diff-ignore-marks is non-nil any marked files will not be +considered to be selected. An optional prefix argument will invert +the influence from cvs-diff-ignore-marks." + + (interactive "P") + + (if (not (listp cvs-diff-flags)) + (error "cvs-diff-flags should be a list of strings")) (save-some-buffers) - (let ((marked (cvs-get-marked))) + (let ((marked (cvs-diffable + (cvs-get-marked + (or (and ignore-marks (not cvs-diff-ignore-marks)) + (and (not ignore-marks) cvs-diff-ignore-marks)))))) (cvs-use-temp-buffer) (message "cvsdiffing...") - (cvs-execute-list marked cvs-program (cons "diff" cvs-cvs-diff-flags))) - (message "cvsdiffing... Done.")) - - -(defun cvs-backup-diffable (tin cvs-buf) + ;; Don't care much about the exit status since it is the _sum_ of + ;; the status codes from the different files (not the _max_ as it + ;; should be). + (if (cvs-execute-list marked cvs-program + (if cvs-cvsroot + (cons "-d" (cons cvs-cvsroot + (cons "diff" cvs-diff-flags))) + (cons "diff" cvs-diff-flags))) + (message "cvsdiffing... Done.") + (message "cvsdiffing... No differences found.")))) + + +(defun cvs-backup-diffable (tin) "Check if the TIN is backup-diffable. It must have a backup file to be diffable." - (cvs-fileinfo->backup-file (cookie-cookie cvs-buf tin))) + (file-readable-p + (cvs-fileinfo->backup-file (tin-cookie cvs-cookie-handle tin)))) -(defun cvs-diff-backup () +(defun cvs-mode-diff-backup (&optional ignore-marks) "Diff the files against the backup file. This command can be used on files that are marked with \"Merged\" or \"Conflict\" in the *cvs* buffer. +If the variable cvs-diff-ignore-marks is non-nil any marked files will +not be considered to be selected. An optional prefix argument will +invert the influence from cvs-diff-ignore-marks. + The flags in cvs-diff-flags will be passed to ``diff''." - (interactive) + (interactive "P") + + (if (not (listp cvs-diff-flags)) + (error "cvs-diff-flags should be a list of strings.")) + (save-some-buffers) - (let ((marked (cvs-filter (function cvs-backup-diffable) - (cvs-get-marked) - (current-buffer)))) + (let ((marked (cvs-filter + (function cvs-backup-diffable) + (cvs-get-marked + (or + (and ignore-marks (not cvs-diff-ignore-marks)) + (and (not ignore-marks) cvs-diff-ignore-marks)))))) (if (null marked) (error "No ``Conflict'' or ``Merged'' file selected!")) (cvs-use-temp-buffer) @@ -1155,72 +1679,76 @@ The flags in cvs-diff-flags will be passed to ``diff''." (defun cvs-diff-backup-extractor (fileinfo) "Return the filename and the name of the backup file as a list. Signal an error if there is no backup file." - (if (null (cvs-fileinfo->backup-file fileinfo)) + (if (not (file-readable-p (cvs-fileinfo->backup-file fileinfo))) (error "%s has no backup file." (concat (file-name-as-directory (cvs-fileinfo->dir fileinfo)) (cvs-fileinfo->file-name fileinfo)))) - (list (cvs-fileinfo->file-name fileinfo) - (cvs-fileinfo->backup-file fileinfo))) + (list (cvs-fileinfo->backup-file fileinfo) + (cvs-fileinfo->file-name fileinfo))) -(defun cvs-find-file-other-window (pos) +(defun cvs-mode-find-file-other-window (pos) "Select a buffer containing the file in another window. Args: POS" (interactive "d") - (save-some-buffers) - (let* ((cookie-last-tin - (cookie-get-selection (current-buffer) pos cookie-last-tin)) - (type (cvs-fileinfo->type (cookie-cookie (current-buffer) - cookie-last-tin)))) - (cond - ((or (eq type 'REMOVED) - (eq type 'CVS-REMOVED)) - (error "Can't visit a removed file.")) - ((eq type 'DIRCHANGE) - (let ((obuf (current-buffer)) - (odir default-directory)) - (setq default-directory - (file-name-as-directory - (cvs-fileinfo->dir - (cookie-cookie (current-buffer) cookie-last-tin)))) - (dired-other-window default-directory) - (set-buffer obuf) - (setq default-directory odir))) - (t - (find-file-other-window (cvs-full-path (current-buffer) - cookie-last-tin)))))) + (let ((tin (tin-locate cvs-cookie-handle pos))) + (if tin + (let ((type (cvs-fileinfo->type (tin-cookie cvs-cookie-handle + tin)))) + (cond + ((or (eq type 'REMOVED) + (eq type 'CVS-REMOVED)) + (error "Can't visit a removed file.")) + ((eq type 'DIRCHANGE) + (let ((obuf (current-buffer)) + (odir default-directory)) + (setq default-directory + (file-name-as-directory + (cvs-fileinfo->dir + (tin-cookie cvs-cookie-handle tin)))) + (dired-other-window default-directory) + (set-buffer obuf) + (setq default-directory odir))) + (t + (find-file-other-window (cvs-full-path tin))))) + (error "There is no file to find.")))) -(defun cvs-full-path (buffer tin) - "Return the full path for the file that is described in TIN. -Args: BUFFER TIN." +(defun cvs-fileinfo->full-path (fileinfo) + "Return the full path for the file that is described in FILEINFO." (concat (file-name-as-directory - (cvs-fileinfo->dir (cookie-cookie buffer tin))) - (cvs-fileinfo->file-name (cookie-cookie buffer tin)))) + (cvs-fileinfo->dir fileinfo)) + (cvs-fileinfo->file-name fileinfo))) -(defun cvs-find-file (pos) +(defun cvs-full-path (tin) + "Return the full path for the file that is described in TIN." + (cvs-fileinfo->full-path (tin-cookie cvs-cookie-handle tin))) + +(defun cvs-mode-find-file (pos) "Select a buffer containing the file in another window. Args: POS" (interactive "d") (let* ((cvs-buf (current-buffer)) - (cookie-last-tin (cookie-get-selection cvs-buf pos cookie-last-tin)) - (fileinfo (cookie-cookie cvs-buf cookie-last-tin)) - (type (cvs-fileinfo->type fileinfo))) - (cond - ((or (eq type 'REMOVED) - (eq type 'CVS-REMOVED)) - (error "Can't visit a removed file.")) - ((eq type 'DIRCHANGE) - (let ((odir default-directory)) - (setq default-directory - (file-name-as-directory (cvs-fileinfo->dir fileinfo))) - (dired default-directory) - (set-buffer cvs-buf) - (setq default-directory odir))) - (t - (find-file (cvs-full-path cvs-buf cookie-last-tin)))))) + (tin (tin-locate cvs-cookie-handle pos))) + (if tin + (let* ((fileinfo (tin-cookie cvs-cookie-handle tin)) + (type (cvs-fileinfo->type fileinfo))) + (cond + ((or (eq type 'REMOVED) + (eq type 'CVS-REMOVED)) + (error "Can't visit a removed file.")) + ((eq type 'DIRCHANGE) + (let ((odir default-directory)) + (setq default-directory + (file-name-as-directory (cvs-fileinfo->dir fileinfo))) + (dired default-directory) + (set-buffer cvs-buf) + (setq default-directory odir))) + (t + (find-file (cvs-full-path tin))))) + (error "There is no file to find.")))) -(defun cvs-mark-all-files () +(defun cvs-mode-mark-all-files () "Mark all files. Directories are not marked." (interactive) @@ -1229,16 +1757,15 @@ Directories are not marked." ((not (eq (cvs-fileinfo->type cookie) 'DIRCHANGE)) (cvs-set-fileinfo->marked cookie t) t)))) - (current-buffer))) + cvs-cookie-handle)) -(defun cvs-unmark (pos) +(defun cvs-mode-unmark (pos) "Unmark a fileinfo. Args: POS." (interactive "d") - (let* ((tin (cookie-get-selection - (current-buffer) pos cookie-last-tin)) - (sel (cookie-cookie (current-buffer) tin))) + (let* ((tin (tin-locate cvs-cookie-handle pos)) + (sel (tin-cookie cvs-cookie-handle tin))) (cond ((eq (cvs-fileinfo->type sel) 'DIRCHANGE) @@ -1248,14 +1775,14 @@ Directories are not marked." ((cvs-dir-member-p f dir) (cvs-set-fileinfo->marked f nil) t)))) - (current-buffer) + cvs-cookie-handle (cvs-fileinfo->dir sel))) (t (cvs-set-fileinfo->marked sel nil) - (cookie-invalidate-tins (current-buffer) tin) - (cookie-next-cookie (current-buffer) pos 1))))) + (tin-invalidate cvs-cookie-handle tin) + (tin-goto-next cvs-cookie-handle pos 1))))) -(defun cvs-unmark-all-files () +(defun cvs-mode-unmark-all-files () "Unmark all files. Directories are also unmarked, but that doesn't matter, since they should always be unmarked." @@ -1263,13 +1790,13 @@ they should always be unmarked." (cookie-map (function (lambda (cookie) (cvs-set-fileinfo->marked cookie nil) t)) - (current-buffer))) + cvs-cookie-handle)) -(defun cvs-do-removal (cvs-buf tins) +(defun cvs-do-removal (tins) "Remove files. -Args: CVS-BUF TINS. -CVS-BUF is the cvs buffer. TINS is a list of tins that the +Args: TINS. +TINS is a list of tins that the user wants to delete. The files are deleted. If the type of the tin is 'UNKNOWN the tin is removed from the buffer. If it is anything else the file is added to a list that should be @@ -1283,70 +1810,141 @@ Returns a list of tins files that should be `cvs remove'd." (let (files-to-remove) (while tins (let* ((tin (car tins)) - (fileinfo (cookie-cookie cvs-buf tin)) + (fileinfo (tin-cookie cvs-cookie-handle tin)) (type (cvs-fileinfo->type fileinfo))) (if (not (or (eq type 'REMOVED) (eq type 'CVS-REMOVED))) (progn - (delete-file (cvs-full-path cvs-buf tin)) + (delete-file (cvs-full-path tin)) (cond ((or (eq type 'UNKNOWN) (eq type 'MOVE-AWAY)) - (cookie-delete cvs-buf tin)) + (tin-delete cvs-cookie-handle tin)) (t (setq files-to-remove (cons tin files-to-remove)) (cvs-set-fileinfo->type fileinfo 'REMOVED) (cvs-set-fileinfo->handled fileinfo nil) - (cookie-invalidate-tins cvs-buf tin)))))) + (tin-invalidate cvs-cookie-handle tin)))))) (setq tins (cdr tins))) files-to-remove)) (t nil))) -(defun cvs-remove-file () +(defun cvs-mode-remove-file () "Remove all marked files." (interactive) - (let ((files-to-remove (cvs-do-removal (current-buffer) (cvs-get-marked)))) + (let ((files-to-remove (cvs-do-removal (cvs-get-marked)))) (if (null files-to-remove) nil (cvs-use-temp-buffer) (message "removing from repository...") - (cvs-execute-list files-to-remove cvs-program '("remove")) - (message "removing from repository... done.")))) - -(defun cvs-acknowledge () + (if (cvs-execute-list files-to-remove cvs-program + (if cvs-cvsroot + (list "-d" cvs-cvsroot "remove") + '("remove"))) + (error "CVS exited with non-zero exit status.") + (message "removing from repository... done."))))) + +(defun cvs-mode-undo-local-changes () + "Undo local changes to all marked files. +The file is removed and `cvs update FILE' is run." + (interactive) + (let ((tins-to-undo (cvs-get-marked))) + (cvs-use-temp-buffer) + (mapcar 'cvs-insert-full-path tins-to-undo) + (cond + ((and tins-to-undo (yes-or-no-p (format "Undo changes to %d files? " + (length tins-to-undo)))) + (let (files-to-update) + (while tins-to-undo + (let* ((tin (car tins-to-undo)) + (fileinfo (tin-cookie cvs-cookie-handle tin)) + (type (cvs-fileinfo->type fileinfo))) + (cond + ((or + (eq type 'UPDATED) (eq type 'MODIFIED) (eq type 'MERGED) + (eq type 'CONFLICT) (eq type 'CVS-REMOVED) + (eq type 'REM-CONFLICT) (eq type 'MOVE-AWAY) + (eq type 'REMOVED)) + (if (not (eq type 'REMOVED)) + (delete-file (cvs-full-path tin))) + (setq files-to-update (cons tin files-to-update)) + (cvs-set-fileinfo->type fileinfo 'UPDATED) + (cvs-set-fileinfo->handled fileinfo t) + (tin-invalidate cvs-cookie-handle tin)) + + ((eq type 'MOD-CONFLICT) + (error "Use cvs-mode-add instead on %s." + (cvs-fileinfo->file-name fileinfo))) + + ((eq type 'REM-CONFLICT) + (error "Can't deal with a file you have removed and recreated.")) + + ((eq type 'DIRCHANGE) + (error "Undo on directories not supported (yet).")) + + ((eq type 'ADDED) + (error "There is no old revision to get for %s" + (cvs-fileinfo->file-name fileinfo))) + (t (error "cvs-mode-undo-local-changes: can't handle an %s" + type))) + + (setq tins-to-undo (cdr tins-to-undo)))) + (cvs-use-temp-buffer) + (message "Regetting files from repository...") + (if (cvs-execute-list files-to-update cvs-program + (if cvs-cvsroot + (list "-d" cvs-cvsroot "update") + '("update"))) + (error "CVS exited with non-zero exit status.") + (message "Regetting files from repository... done."))))))) + +(defun cvs-mode-acknowledge () "Remove all marked files from the buffer." (interactive) (mapcar (function (lambda (tin) - (cookie-delete (current-buffer) tin))) - (cvs-get-marked)) - (setq cookie-last-tin nil)) + (tin-delete cvs-cookie-handle tin))) + (cvs-get-marked))) -(defun cvs-unmark-up (pos) +(defun cvs-mode-unmark-up (pos) "Unmark the file on the previous line. Takes one argument POS, a buffer position." (interactive "d") - (cookie-previous-cookie (current-buffer) pos 1) - (cvs-set-fileinfo->marked (cookie-cookie (current-buffer) cookie-last-tin) - nil) - (cookie-invalidate-tins (current-buffer) cookie-last-tin)) - -(defun cvs-add-file-update-buffer (cvs-buf tin) - "Subfunction to cvs-add. Internal use only. + (let ((tin (tin-goto-previous cvs-cookie-handle pos 1))) + (cond + (tin + (cvs-set-fileinfo->marked (tin-cookie cvs-cookie-handle tin) + nil) + (tin-invalidate cvs-cookie-handle tin))))) + +(defun cvs-mode-previous-line (arg) + "Go to the previous line. +If a prefix argument is given, move by that many lines." + (interactive "p") + (tin-goto-previous cvs-cookie-handle (point) arg)) + +(defun cvs-mode-next-line (arg) + "Go to the next line. +If a prefix argument is given, move by that many lines." + (interactive "p") + (tin-goto-next cvs-cookie-handle (point) arg)) + +(defun cvs-add-file-update-buffer (tin) + "Subfunction to cvs-mode-add. Internal use only. Update the display. Return non-nil if `cvs add' should be called on this -file. Args: CVS-BUF TIN. +file. Args: TIN. Returns 'ADD or 'RESURRECT." - (let ((fileinfo (cookie-cookie cvs-buf tin))) + (let ((fileinfo (tin-cookie cvs-cookie-handle tin))) (cond ((eq (cvs-fileinfo->type fileinfo) 'UNKNOWN) (cvs-set-fileinfo->type fileinfo 'ADDED) - (cookie-invalidate-tins cvs-buf tin) + (tin-invalidate cvs-cookie-handle tin) 'ADD) ((eq (cvs-fileinfo->type fileinfo) 'REMOVED) (cvs-set-fileinfo->type fileinfo 'UPDATED) (cvs-set-fileinfo->handled fileinfo t) - (cookie-invalidate-tins cvs-buf tin) + (tin-invalidate cvs-cookie-handle tin) 'RESURRECT)))) (defun cvs-add-sub (cvs-buf candidates) @@ -1357,7 +1955,7 @@ The first list is unknown tins that shall be `cvs add -m msg'ed. The second list is removed files that shall be `cvs add'ed (resurrected)." (let (add resurrect) (while candidates - (let ((type (cvs-add-file-update-buffer cvs-buf (car candidates)))) + (let ((type (cvs-add-file-update-buffer (car candidates)))) (cond ((eq type 'ADD) (setq add (cons (car candidates) add))) ((eq type 'RESURRECT) @@ -1365,7 +1963,7 @@ The second list is removed files that shall be `cvs add'ed (resurrected)." (setq candidates (cdr candidates))) (cons add resurrect))) -(defun cvs-add () +(defun cvs-mode-add () "Add marked files to the cvs repository." (interactive) @@ -1380,15 +1978,23 @@ The second list is removed files that shall be `cvs add'ed (resurrected)." (cond (resurrect (message "Resurrecting files from repository...") - (cvs-execute-list resurrect cvs-program '("add")) - (message "Done."))) + (if (cvs-execute-list resurrect cvs-program + (if cvs-cvsroot + (list "-d" cvs-cvsroot "add") + '("add"))) + (error "CVS exited with non-zero exit status.") + (message "Done.")))) (cond (added (message "Adding new files to repository...") - (cvs-execute-list added cvs-program (list "add" "-m" msg)) - (message "Done."))))) - -(defun cvs-ignore () + (if (cvs-execute-list added cvs-program + (if cvs-cvsroot + (list "-d" cvs-cvsroot "add" "-m" msg) + (list "add" "-m" msg))) + (error "CVS exited with non-zero exit status.") + (message "Done.")))))) + +(defun cvs-mode-ignore () "Arrange so that CVS ignores the selected files. This command ignores files that are not flagged as `Unknown'." (interactive) @@ -1396,12 +2002,12 @@ This command ignores files that are not flagged as `Unknown'." (mapcar (function (lambda (tin) (cond ((eq (cvs-fileinfo->type - (cookie-cookie (current-buffer) tin)) 'UNKNOWN) + (tin-cookie cvs-cookie-handle tin)) + 'UNKNOWN) (cvs-append-to-ignore - (cookie-cookie (current-buffer) tin)) - (cookie-delete (current-buffer) tin))))) - (cvs-get-marked)) - (setq cookie-last-tin nil)) + (tin-cookie cvs-cookie-handle tin)) + (tin-delete cvs-cookie-handle tin))))) + (cvs-get-marked))) (defun cvs-append-to-ignore (fileinfo) "Append the file in fileinfo to the .cvsignore file" @@ -1413,9 +2019,11 @@ This command ignores files that are not flagged as `Unknown'." (if (not (zerop (current-column))) (insert "\n")) (insert (cvs-fileinfo->file-name fileinfo) "\n") + (if cvs-sort-ignore-file + (sort-lines nil (point-min) (point-max))) (save-buffer))) -(defun cvs-status () +(defun cvs-mode-status () "Show cvs status for all marked files." (interactive) @@ -1423,26 +2031,45 @@ This command ignores files that are not flagged as `Unknown'." (let ((marked (cvs-get-marked))) (cvs-use-temp-buffer) (message "Running cvs status ...") - (cvs-execute-list marked cvs-program (cons "status" cvs-status-flags))) - (message "Running cvs status ... Done.")) - -(defun cvs-log () + (if (cvs-execute-list + marked cvs-program + (if cvs-cvsroot + (cons "-d" (cons cvs-cvsroot (cons "status" cvs-status-flags))) + (cons "status" cvs-status-flags))) + (error "CVS exited with non-zero exit status.") + (message "Running cvs status ... Done.")))) + +(defun cvs-mode-log () "Display the cvs log of all selected files." (interactive) (let ((marked (cvs-get-marked))) (cvs-use-temp-buffer) (message "Running cvs log ...") - (cvs-execute-list marked cvs-program (cons "log" cvs-log-flags))) - (message "Running cvs log ... Done.")) - + (if (cvs-execute-list marked cvs-program + (if cvs-cvsroot + (cons "-d" (cons cvs-cvsroot + (cons "log" cvs-log-flags))) + (cons "log" cvs-log-flags))) + (error "CVS exited with non-zero exit status.") + (message "Running cvs log ... Done.")))) + +(defun cvs-byte-compile-files () + "Run byte-compile-file on all selected files that end in '.el'." + (interactive) + (let ((marked (cvs-get-marked))) + (while marked + (let ((filename (cvs-full-path (car marked)))) + (if (string-match "\\.el$" filename) + (byte-compile-file filename))) + (setq marked (cdr marked))))) (defun cvs-insert-full-path (tin) - "Insert full path to the file described in TIN." - (insert (format "%s\n" (cvs-full-path cvs-buffer-name tin)))) + "Insert full path to the file described in TIN in the current buffer." + (insert (format "%s\n" (cvs-full-path tin)))) -(defun cvs-add-change-log-entry-other-window (pos) +(defun cvs-mode-add-change-log-entry-other-window (pos) "Add a ChangeLog entry in the ChangeLog of the current directory. Args: POS." (interactive "d") @@ -1451,9 +2078,9 @@ Args: POS." (setq default-directory (file-name-as-directory (cvs-fileinfo->dir - (cookie-cookie - cvs-buf - (cookie-get-selection cvs-buf pos cookie-last-tin))))) + (tin-cookie + cvs-cookie-handle + (tin-locate cvs-cookie-handle pos))))) (if (not default-directory) ;In case there was no entries. (setq default-directory odir)) (add-change-log-entry-other-window) @@ -1463,7 +2090,7 @@ Args: POS." (defun print-cvs-tin (foo) "Debug utility." - (let ((cookie (cookie-cookie (current-buffer) foo)) + (let ((cookie (tin-cookie cvs-cookie-handle foo)) (stream (get-buffer-create "debug"))) (princ "==============\n" stream) (princ (cvs-fileinfo->file-name cookie) stream) @@ -1474,3 +2101,106 @@ Args: POS." (princ "\n" stream) (princ (cvs-fileinfo->marked cookie) stream) (princ "\n" stream))) + +(defun cvs-mode-emerge (pos) + "Emerge appropriate revisions of the selected file. +Args: POS" + (interactive "d") + (let* ((cvs-buf (current-buffer)) + (tin (tin-locate cvs-cookie-handle pos))) + (if tin + (let* ((fileinfo (tin-cookie cvs-cookie-handle tin)) + (type (cvs-fileinfo->type fileinfo))) + (cond + ((eq type 'MODIFIED) + (require 'emerge) + (let ((tmp-file + (cvs-retrieve-revision-to-tmpfile fileinfo))) + (unwind-protect + (if (not (emerge-files + t + (cvs-fileinfo->full-path fileinfo) + tmp-file + (cvs-fileinfo->full-path fileinfo))) + (error "Emerge session failed")) + (delete-file tmp-file)))) + + ((or (eq type 'MERGED) + (eq type 'CONFLICT)) + (require 'emerge) + (let ((tmp-file + (cvs-retrieve-revision-to-tmpfile + fileinfo)) + (ancestor-file + (cvs-retrieve-revision-to-tmpfile + fileinfo + (cvs-fileinfo->base-revision fileinfo)))) + (unwind-protect + (if (not (emerge-files-with-ancestor + t + (cvs-fileinfo->backup-file fileinfo) + tmp-file + ancestor-file + (cvs-fileinfo->full-path fileinfo))) + (error "Emerge session failed")) + (delete-file tmp-file) + (delete-file ancestor-file)))) + (t + (error "Can only emerge \"Modified\", \"Merged\" or \"Conflict\"%s" + " files")))) + (error "There is no file to emerge.")))) + +(defun cvs-retrieve-revision-to-tmpfile (fileinfo &optional revision) + "Retrieve the latest revision of the file in FILEINFO to a temporary file. +If second optional argument REVISION is given, retrieve that revision instead." + (let + ((temp-name (make-temp-name + (concat (file-name-as-directory + (or (getenv "TMPDIR") "/tmp")) + "pcl-cvs." revision)))) + (cvs-kill-buffer-visiting temp-name) + (if revision + (message "Retrieving revision %s..." revision) + (message "Retrieving latest revision...")) + (let ((res (call-process cvs-shell nil nil nil "-c" + (concat cvs-program " update -p " + (if revision + (concat "-r " revision " ") + "") + (cvs-fileinfo->full-path fileinfo) + " > " temp-name)))) + (if (and res (not (and (integerp res) (zerop res)))) + (error "Something went wrong: %s" res)) + + (if revision + (message "Retrieving revision %s... Done." revision) + (message "Retrieving latest revision... Done.")) + (find-file-noselect temp-name) + temp-name))) + +(defun cvs-fileinfo->backup-file (fileinfo) + "Construct the file name of the backup file for FILEINFO." + (if (cvs-fileinfo->base-revision fileinfo) + (concat cvs-bakprefix (cvs-fileinfo->file-name fileinfo) + "." (cvs-fileinfo->base-revision fileinfo)))) + +(defun cvs-kill-buffer-visiting (filename) + "If there is any buffer visiting FILENAME, kill it (without confirmation)." + (let ((l (buffer-list))) + (while l + (if (string= (buffer-file-name (car l)) filename) + (kill-buffer (car l))) + (setq l (cdr l))))) + +(defun cvs-change-cvsroot (newroot) + "Change the cvsroot." + (interactive "DNew repository: ") + (if (or (file-directory-p (expand-file-name "CVSROOT" newroot)) + (y-or-n-p (concat "Warning: no CVSROOT found inside repository." + " Change cvs-cvsroot anyhow?"))) + (setq cvs-cvsroot newroot))) + +(if (string-match "Lucid" emacs-version) + (progn + (autoload 'pcl-cvs-fontify "pcl-cvs-lucid") + (add-hook 'cvs-mode-hook 'pcl-cvs-fontify))) diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info index 3c0d3c0..060d932 100644 --- a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info +++ b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.info @@ -1,4 +1,4 @@ -Info file pcl-cvs, produced by Makeinfo, -*- Text -*- from input +This is Info file pcl-cvs, produced by Makeinfo-1.49 from the input file pcl-cvs.texinfo. Copyright (C) 1992 Per Cederqvist @@ -15,18 +15,18 @@ derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for -modified versions, except that the section entitled "GNU General -Public License" and this permission notice may be included in -translations approved by the Free Software Foundation instead of in -the original English. +manual into another language, under the above conditions for modified +versions, except that the section entitled "GNU General Public +License" and this permission notice may be included in translations +approved by the Free Software Foundation instead of in the original +English. File: pcl-cvs, Node: Top, Next: Copying, Prev: (dir), Up: (dir) This info manual describes pcl-cvs which is a GNU Emacs front-end to CVS. It works with CVS version 1.3. This manual is updated to -release 1.02 of pcl-cvs. +release 1.05 of pcl-cvs. * Menu: @@ -40,9 +40,8 @@ release 1.02 of pcl-cvs. * Customization:: How you can tailor pcl-cvs to suit your needs. * Future enhancements:: Future enhancements of pcl-cvs. -* Reporting bugs and ideas:: Where to report bugs. - -* Function and Variable Index:: List of functions and variables. +* Bugs:: Bugs (known and unknown). +* Function and Variable Index:: List of functions and variables. * Concept Index:: List of concepts. * Key Index:: List of keystrokes. @@ -50,7 +49,7 @@ release 1.02 of pcl-cvs. Installation -* Pcl-cvs installation:: How to install pcl-cvs on your system. +* Pcl-cvs installation:: How to install pcl-cvs on your system. * On-line manual installation:: How to install the on-line manual. * Typeset manual installation:: How to create typeset documentation about pcl-cvs. @@ -76,9 +75,13 @@ Commands * Editing files:: Loading files into Emacs. * Getting info about files:: Display the log and status of files. * Adding and removing files:: Adding and removing files +* Undoing changes:: Undoing changes * Removing handled entries:: Uninteresting lines can easily be removed. * Ignoring files:: Telling CVS to ignore generated files. * Viewing differences:: Commands to `diff' different versions. +* Emerge:: +* Reverting your buffers:: Reverting your buffers +* Miscellaneous commands:: Miscellaneous commands File: pcl-cvs, Node: Copying, Next: Installation, Prev: Top, Up: Top @@ -86,7 +89,7 @@ File: pcl-cvs, Node: Copying, Next: Installation, Prev: Top, Up: Top GNU GENERAL PUBLIC LICENSE ************************** - Version 2, June 1991 + Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA @@ -99,27 +102,25 @@ Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. -This General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit -to using it. (Some other Free Software Foundation software is -covered by the GNU Library General Public License instead.) You can -apply it to your programs, too. +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and -charge for this service if you wish), that you receive source code -or can get it if you want it, that you can change the software or -use pieces of it in new free programs; and that you know you can do -these things. +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the -rights. These restrictions translate to certain responsibilities -for you if you distribute copies of the software, or if you modify -it. +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that @@ -127,9 +128,9 @@ you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. - We protect your rights with two steps: (1) copyright the -software, and (2) offer you this license which gives you legal -permission to copy, distribute and/or modify the software. + We protect your rights with two steps: (1) copyright the software, +and (2) offer you this license which gives you legal permission to +copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this @@ -140,20 +141,20 @@ reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making -the program proprietary. To prevent this, we have made it clear -that any patent must be licensed for everyone's free use or not -licensed at all. +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at +all. The precise terms and conditions for copying, distribution and modification follow. - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 1. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be - distributed under the terms of this General Public License. - The "Program", below, refers to any such program or work, and a + distributed under the terms of this General Public License. The + "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or @@ -161,13 +162,13 @@ modification follow. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". - Activities other than copying, distribution and modification - are not covered by this License; they are outside its scope. - The act of running the Program is not restricted, and the - output from the Program is covered only if its contents - constitute a work based on the Program (independent of having - been made by running the Program). Whether that is true - depends on what the Program does. + Activities other than copying, distribution and modification are + not covered by this License; they are outside its scope. The + act of running the Program is not restricted, and the output + from the Program is covered only if its contents constitute a + work based on the Program (independent of having been made by + running the Program). Whether that is true depends on what the + Program does. 2. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you @@ -177,27 +178,26 @@ modification follow. absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. - You may charge a fee for the physical act of transferring a + You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 3. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and - distribute such modifications or work under the terms of - Section 1 above, provided that you also meet all of these - conditions: + distribute such modifications or work under the terms of Section + 1 above, provided that you also meet all of these conditions: - 1. You must cause the modified files to carry prominent - notices stating that you changed the files and the date of - any change. + a. You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any + change. - 2. You must cause any work that you distribute or publish, + b. You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. - 3. If the modified program normally reads commands + c. If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an @@ -206,11 +206,11 @@ modification follow. that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive - but does not normally print such an announcement, your - work based on the Program is not required to print an + but does not normally print such an announcement, your work + based on the Program is not required to print an announcement.) - These requirements apply to the modified work as a whole. If + These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, @@ -222,86 +222,83 @@ modification follow. whole, and thus to each and every part regardless of who wrote it. - Thus, it is not the intent of this section to claim rights - or contest your rights to work written entirely by you; rather, - the intent is to exercise the right to control the distribution - of derivative or collective works based on the Program. + Thus, it is not the intent of this section to claim rights or + contest your rights to work written entirely by you; rather, the + intent is to exercise the right to control the distribution of + derivative or collective works based on the Program. - In addition, mere aggregation of another work not based on - the Program with the Program (or with a work based on the - Program) on a volume of a storage or distribution medium does - not bring the other work under the scope of this License. + In addition, mere aggregation of another work not based on the + Program with the Program (or with a work based on the Program) + on a volume of a storage or distribution medium does not bring + the other work under the scope of this License. 4. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the - terms of Sections 1 and 2 above provided that you also do one - of the following: + terms of Sections 1 and 2 above provided that you also do one of + the following: - 1. Accompany it with the complete corresponding + a. Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, - 2. Accompany it with a written offer, valid for at least three + b. Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source - code, to be distributed under the terms of Sections 1 and - 2 above on a medium customarily used for software + code, to be distributed under the terms of Sections 1 and 2 + above on a medium customarily used for software interchange; or, - 3. Accompany it with the information you received as to the + c. Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) - The source code for a work means the preferred form of the - work for making modifications to it. For an executable work, + The source code for a work means the preferred form of the work + for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, - plus the scripts used to control compilation and installation - of the executable. However, as a special exception, the source + plus the scripts used to control compilation and installation of + the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major - components (compiler, kernel, and so on) of the operating - system on which the executable runs, unless that component - itself accompanies the executable. + components (compiler, kernel, and so on) of the operating system + on which the executable runs, unless that component itself + accompanies the executable. - If distribution of executable or object code is made by - offering access to copy from a designated place, then offering - equivalent access to copy the source code from the same place - counts as distribution of the source code, even though third - parties are not compelled to copy the source along with the - object code. + If distribution of executable or object code is made by offering + access to copy from a designated place, then offering equivalent + access to copy the source code from the same place counts as + distribution of the source code, even though third parties are + not compelled to copy the source along with the object code. 5. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program - is void, and will automatically terminate your rights under - this License. However, parties who have received copies, or - rights, from you under this License will not have their - licenses terminated so long as such parties remain in full - compliance. + is void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, + from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. 6. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to - modify or distribute the Program or its derivative works. - These actions are prohibited by law if you do not accept this - License. Therefore, by modifying or distributing the Program - (or any work based on the Program), you indicate your - acceptance of this License to do so, and all its terms and - conditions for copying, distributing or modifying the Program - or works based on it. + modify or distribute the Program or its derivative works. These + actions are prohibited by law if you do not accept this License. + Therefore, by modifying or distributing the Program (or any + work based on the Program), you indicate your acceptance of this + License to do so, and all its terms and conditions for copying, + distributing or modifying the Program or works based on it. 7. Each time you redistribute the Program (or any work based on the - Program), the recipient automatically receives a license from - the original licensor to copy, distribute or modify the Program + Program), the recipient automatically receives a license from the + original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights - granted herein. You are not responsible for enforcing - compliance by third parties to this License. + granted herein. You are not responsible for enforcing compliance + by third parties to this License. 8. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent @@ -309,79 +306,78 @@ modification follow. agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy - simultaneously your obligations under this License and any - other pertinent obligations, then as a consequence you may not - distribute the Program at all. For example, if a patent - license would not permit royalty-free redistribution of the - Program by all those who receive copies directly or indirectly - through you, then the only way you could satisfy both it and - this License would be to refrain entirely from distribution of - the Program. - - If any portion of this section is held invalid or - unenforceable under any particular circumstance, the balance of - the section is intended to apply and the section as a whole is - intended to apply in other circumstances. - - It is not the purpose of this section to induce you to - infringe any patents or other property right claims or to - contest validity of any such claims; this section has the sole - purpose of protecting the integrity of the free software - distribution system, which is implemented by public license - practices. Many people have made generous contributions to the - wide range of software distributed through that system in - reliance on consistent application of that system; it is up to - the author/donor to decide if he or she is willing to - distribute software through any other system and a licensee - cannot impose that choice. - - This section is intended to make thoroughly clear what is + simultaneously your obligations under this License and any other + pertinent obligations, then as a consequence you may not + distribute the Program at all. For example, if a patent license + would not permit royalty-free redistribution of the Program by + all those who receive copies directly or indirectly through you, + then the only way you could satisfy both it and this License + would be to refrain entirely from distribution of the Program. + + If any portion of this section is held invalid or unenforceable + under any particular circumstance, the balance of the section is + intended to apply and the section as a whole is intended to + apply in other circumstances. + + It is not the purpose of this section to induce you to infringe + any patents or other property right claims or to contest + validity of any such claims; this section has the sole purpose + of protecting the integrity of the free software distribution + system, which is implemented by public license practices. Many + people have made generous contributions to the wide range of + software distributed through that system in reliance on + consistent application of that system; it is up to the + author/donor to decide if he or she is willing to distribute + software through any other system and a licensee cannot impose + that choice. + + This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 9. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted - interfaces, the original copyright holder who places the - Program under this License may add an explicit geographical - distribution limitation excluding those countries, so that - distribution is permitted only in or among countries not thus - excluded. In such case, this License incorporates the - limitation as if written in the body of this License. + interfaces, the original copyright holder who places the Program + under this License may add an explicit geographical distribution + limitation excluding those countries, so that distribution is + permitted only in or among countries not thus excluded. In such + case, this License incorporates the limitation as if written in + the body of this License. 10. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - Each version is given a distinguishing version number. If - the Program specifies a version number of this License which - applies to it and "any later version", you have the option of - following the terms and conditions either of that version or of - any later version published by the Free Software Foundation. - If the Program does not specify a version number of this - License, you may choose any version ever published by the Free - Software Foundation. + Each version is given a distinguishing version number. If the + Program specifies a version number of this License which applies + to it and "any later version", you have the option of following + the terms and conditions either of that version or of any later + version published by the Free Software Foundation. If the + Program does not specify a version number of this License, you + may choose any version ever published by the Free Software + Foundation. 11. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free - Software Foundation; we sometimes make exceptions for this. - Our decision will be guided by the two goals of preserving the - free status of all derivatives of our free software and of - promoting the sharing and reuse of software generally. + Software Foundation; we sometimes make exceptions for this. Our + decision will be guided by the two goals of preserving the free + status of all derivatives of our free software and of promoting + the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 12. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT - HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" - WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE - ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS - WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE - COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT + WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE + QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE + PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY + SERVICING, REPAIR OR CORRECTION. 13. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY @@ -390,19 +386,19 @@ modification follow. INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY - YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE - WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY - HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH + ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS + END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs ======================================================= - If you develop a new program, and you want it to be of the -greatest possible use to the public, the best way to achieve this is -to make it free software which everyone can redistribute and change -under these terms. + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most @@ -427,8 +423,8 @@ notice is found. along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - Also add information on how to contact you by electronic and -paper mail. + Also add information on how to contact you by electronic and paper +mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: @@ -444,8 +440,8 @@ commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. - You should also get your employer (if you work as a programmer) -or your school, if any, to sign a "copyright disclaimer" for the + You should also get your employer (if you work as a programmer) or +your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program @@ -472,12 +468,12 @@ CVS front-end. You should install not only the elisp files themselves, but also the on-line documentation so that your users will know how to use it. You can create typeset documentation from the file `pcl-cvs.texinfo' as well as an on-line info file. The -following steps are also described in the file `INSTALL' in the -source directory. +following steps are also described in the file `INSTALL' in the source +directory. * Menu: -* Pcl-cvs installation:: How to install pcl-cvs on your system. +* Pcl-cvs installation:: How to install pcl-cvs on your system. * On-line manual installation:: How to install the on-line manual. * Typeset manual installation:: How to create typeset documentation about pcl-cvs. @@ -488,44 +484,50 @@ File: pcl-cvs, Node: Pcl-cvs installation, Next: On-line manual installation, Installation of the pcl-cvs program =================================== - 1. Edit the file `Makefile' to reflect the situation at your site. - The only things you have to change is the definition of - `lispdir' and `infodir'. The elisp files will be copied to - `lispdir', and the info file to `infodir'. + 1. Edit the file `Makefile' to reflect the situation at your site. + The only things you have to change is the definition of `lispdir' + and `infodir'. The elisp files will be copied to `lispdir', and + the info file to `infodir'. 2. Configure pcl-cvs.el - There are a couple of paths that you have to check to make - sure that they match you system. They appear early in the file + There are a couple of paths that you have to check to make sure + that they match you system. They appear early in the file pcl-cvs.el. - *NOTE:* If your system is running emacs 18.57 or earlier - you MUST uncomment the line that says: + *NOTE:* If your system is running emacs 18.57 or earlier you + MUST uncomment the line that says: (setq delete-exited-processes nil) - Setting `delete-exited-processes' to `nil' works around a bug - in emacs that causes it to dump core. The bug was fixed in - emacs 18.58. + Setting `delete-exited-processes' to `nil' works around a bug in + emacs that causes it to dump core. The bug was fixed in emacs + 18.58. + + 3. Release 1.05 and later of pcl-cvs requires parts of the Elib + library, version 0.07 or later. Elib is available via anonymous + ftp from prep.ai.mit.edu in `pub/gnu/elib-0.07.tar.z', and from + a lot of other sites that mirrors prep. Get Elib, and install + it, before proceeding. - 3. Type `make install' in the source directory. This will + 4. Type `make install' in the source directory. This will byte-compile all `.el' files and copy both the `.el' and the `.elc' into the directory you specified in step 1. - If you don't want to install the `.el' files but only the - `.elc' files (the byte-compiled files), you can type ``make + If you don't want to install the `.el' files but only the `.elc' + files (the byte-compiled files), you can type ``make install_elc'' instead of ``make install''. - If you only want to create the compiled elisp files, but - don't want to install them, you can type `make elcfiles' - instead. This is what happens if you only type `make' without - parameters. + If you only want to create the compiled elisp files, but don't + want to install them, you can type `make elcfiles' instead. + This is what happens if you only type `make' without parameters. - 4. Edit the file `default.el' in your emacs lisp directory (usually + 5. Edit the file `default.el' in your emacs lisp directory (usually `/usr/gnu/emacs/lisp' or something similar) and enter the contents of the file `pcl-cvs-startup.el' into it. It contains a couple of `auto-load's that facilitates the use of pcl-cvs. + File: pcl-cvs, Node: On-line manual installation, Next: Typeset manual installation, Prev: Pcl-cvs installation, Up: Installation @@ -540,7 +542,7 @@ Installation of the on-line manual. info file `pcl-cvs.info' that is included in the distribution (type `cp pcl-cvs.info pcl-cvs'). - 2. Move the info file `pcl-cvs' to your standard info directory. + 2. Move the info file `pcl-cvs' to your standard info directory. This might be called something like `/usr/gnu/emacs/info'. 3. Edit the file `dir' in the info directory and enter one line to @@ -567,6 +569,7 @@ manual from `pcl-cvs.texinfo'. There is also a program which comes together with TeX, `dvips', which you can use. + File: pcl-cvs, Node: About pcl-cvs, Next: Getting started, Prev: Installation, Up: Top @@ -589,37 +592,40 @@ Contributors to pcl-cvs Contributions to the package are welcome. I have limited time to work on this project, but I will gladly add any code that you -contribute to me to this package (*note Reporting bugs and ideas::.). +contribute to me to this package (*note Bugs::.). The following persons have made contributions to pcl-cvs. - * Brian Berliner wrote CVS, together with some other contributors. + * Brian Berliner wrote CVS, together with some other contributors. Without his work on CVS this package would be useless... * Per Cederqvist wrote most of the otherwise unattributed functions in pcl-cvs as well as all documentation. * Inge Wallin (`inge@lysator.liu.se') wrote the skeleton to - `pcl-cvs.texinfo', and gave useful comments on it. He also - wrote the files `elib-node.el' and `compile-all.el'. The file + `pcl-cvs.texinfo', and gave useful comments on it. He also wrote + the files `elib-node.el' and `compile-all.el'. The file `cookie.el' was inspired by Inge. * Linus Tolke (`linus@lysator.liu.se') contributed useful comments on both the functionality and the documentation. + * Jamie Zawinski (`jwz@lucid.com') contributed `pcl-cvs-lucid.el'. + + * Leif Lonnblad contributed RCVS support. + + Apart from these, a lot of people have send me suggestions, ideas, +requests, bug reports and encouragement. Thanks a lot! Without your +there would be no new releases of pcl-cvs. + File: pcl-cvs, Node: Archives, Prev: Contributors, Up: About pcl-cvs Where can I get pcl-cvs? ======================== - This release of pcl-cvs is included in the CVS 1.3 distribution. -However, since pcl-cvs has had less time to mature (the first line of -code was written less than a year ago) it is likely that there will -be a new release of pcl-cvs before the next release of CVS. - - The latest release of pcl-cvs can be fetched via anonymous ftp -from `ftp.lysator.liu.se', (IP no. 130.236.254.1) in the directory + The latest release of pcl-cvs can be fetched via anonymous ftp from +`ftp.lysator.liu.se', (IP no. 130.236.254.1) in the directory `pub/emacs'. If you don't live in Scandinavia you should probably check with archie to see if there is a site closer to you that archives pcl-cvs. @@ -635,16 +641,16 @@ Getting started *************** This document assumes that you know what CVS is, and that you at -least knows the fundamental concepts of CVS. If that is not the -case you should read the man page for CVS. +least knows the fundamental concepts of CVS. If that is not the case +you should read the man page for CVS. Pcl-cvs is only useful once you have checked out a module. So before you invoke it you must have a copy of a module somewhere in the file system. - You invoke pcl-cvs by typing `M-x pcl-cvs RET'. If your emacs + You invoke pcl-cvs by typing `M-x cvs-update RET'. If your emacs responds with `[No match]' your system administrator has not -installed pcl-cvs properly. Try `M-x load-library RET pcl-cvs RET'. +installed pcl-cvs properly. Try `M-x load-library RET pcl-cvs RET'. If that also fails - talk to your root. If it succeeds you might put this line in your `.emacs' file so that you don't have to type the `load-library' command every time you wish to use pcl-cvs: @@ -652,12 +658,12 @@ this line in your `.emacs' file so that you don't have to type the (autoload 'cvs-update "pcl-cvs" nil t) The function `cvs-update' will ask for a directory. The command -`cvs update' will be run in that directory. (It should contain -files that have been checked out from a CVS archive.) The output -from `cvs' will be parsed and presented in a table in a buffer called +`cvs update' will be run in that directory. (It should contain files +that have been checked out from a CVS archive.) The output from +`cvs' will be parsed and presented in a table in a buffer called `*cvs*'. It might look something like this: - PCL-CVS release 1.02. + PCL-CVS release 1.05. In directory /users/ceder/FOO/test: Updated bar @@ -683,10 +689,10 @@ Committing changes::. You can press `x' to get rid of the "uninteresting" files that have only been `Updated' (and don't require any further action from you). - You can also easily get a `diff' between your modified file and -the base version that you started from, and you can get the output -from `cvs log' and `cvs status' on the listed files simply by -pressing a key (*note Getting info about files::.). + You can also easily get a `diff' between your modified file and the +base version that you started from, and you can get the output from +`cvs log' and `cvs status' on the listed files simply by pressing a +key (*note Getting info about files::.). File: pcl-cvs, Node: Buffer contents, Next: Commands, Prev: Getting started, Up: Top @@ -720,33 +726,33 @@ File status The `file status' field can have the following values: `Updated' - The file was brought up to date with respect to the repository. - This is done for any file that exists in the repository but - not in your source, and for files that you haven't changed but - are not the most recent versions available in the repository. + The file was brought up to date with respect to the repository. + This is done for any file that exists in the repository but not + in your source, and for files that you haven't changed but are + not the most recent versions available in the repository. `Modified' - The file is modified in your working directory, and there - was no modification to the same file in the repository. + The file is modified in your working directory, and there was + no modification to the same file in the repository. `Merged' The file is modified in your working directory, and there were modifications in the repository as well as in your copy, but - they were merged successfully, without conflict, in your - working directory. + they were merged successfully, without conflict, in your working + directory. `Conflict' A conflict was detected while trying to merge your changes to - FILE with changes from the source repository. FILE (the copy - in your working directory) is now the output of the `rcsmerge' + FILE with changes from the source repository. FILE (the copy in + your working directory) is now the output of the `rcsmerge' command on the two versions; an unmodified copy of your file is also in your working directory, with the name `.#FILE.VERSION', - where VERSION is the RCS revision that your modified file - started from. *Note Viewing differences::, for more details. + where VERSION is the RCS revision that your modified file started + from. *Note Viewing differences::, for more details. `Added' - The file has been added by you, but it still needs to be - checked in to the repository. + The file has been added by you, but it still needs to be checked + in to the repository. `Removed' The file has been removed by you, but it needs to be checked in @@ -770,8 +776,8 @@ longer strings in the fields: `Removed from repository, changed by you' You have modified a file that someone have removed from the - repository. You can correct this situation by removing the - file manually (see *note Adding and removing files::.). + repository. You can correct this situation by removing the file + manually (see *note Adding and removing files::.). `Removed by you, changed in repository' You have removed a file, and before you committed the removal @@ -795,18 +801,17 @@ Selected files Many of the commands works on the current set of "selected" files. - * If there are any files that are marked they constitute the set - of selected files. + * If there are any files that are marked they constitute the set of + selected files. * Otherwise, if the cursor points to a file, that file is the selected file. - * Otherwise, if the cursor points to a directory, all the files - in that directory that appears in the buffer are the selected - files. + * Otherwise, if the cursor points to a directory, all the files in + that directory that appears in the buffer are the selected files. - This scheme might seem a little complicated, but once one get -used to it, it is quite powerful. + This scheme might seem a little complicated, but once one get used +to it, it is quite powerful. *Note Marking files:: tells how you mark and unmark files. @@ -831,9 +836,13 @@ type. * Editing files:: Loading files into Emacs. * Getting info about files:: Display the log and status of files. * Adding and removing files:: Adding and removing files +* Undoing changes:: Undoing changes * Removing handled entries:: Uninteresting lines can easily be removed. * Ignoring files:: Telling CVS to ignore generated files. * Viewing differences:: Commands to `diff' different versions. +* Emerge:: +* Reverting your buffers:: Reverting your buffers +* Miscellaneous commands:: Miscellaneous commands File: pcl-cvs, Node: Updating the directory, Next: Movement commands, Prev: Commands, Up: Commands @@ -842,11 +851,10 @@ Updating the directory ====================== `M-x cvs-update' - Run a `cvs update' command. You will be asked for the - directory in which the `cvs update' will be run. The output - will be parsed by pcl-cvs, and the result printed in the - `*cvs*' buffer (see *note Buffer contents::. for a description - of the contents). + Run a `cvs update' command. You will be asked for the directory + in which the `cvs update' will be run. The output will be + parsed by pcl-cvs, and the result printed in the `*cvs*' buffer + (see *note Buffer contents::. for a description of the contents). By default, `cvs-update' will descend recursively into subdirectories. You can avoid that behavior by giving a prefix @@ -855,11 +863,22 @@ Updating the directory All other commands in pcl-cvs requires that you have a `*cvs*' buffer. This is the command that you use to get one. + CVS uses lock files in the repository to ensure the integrity of + the data files in the repository. They might be left behind + i.e. if a workstation crashes in the middle of a CVS operation. + CVS outputs a message when it is waiting for a lock file to go + away. Pcl-cvs will show the same message in the *cvs* buffer, + together with instructions for deleting the lock files. You + should normally not have to delete them manually -- just wait a + little while and the problem should fix itself. But if the lock + files doesn't disappear you can delete them with `M-x + cvs-delete-lock RET'. + `g' This will run `cvs update' again. It will always use the same buffer that was used with the previous `cvs update'. Give a prefix argument to avoid descending into subdirectories. This - runs the command `cvs-update-no-prompt'. + runs the command `cvs-mode-update-no-prompt'. File: pcl-cvs, Node: Movement commands, Next: Marking files, Prev: Updating the directory, Up: Commands @@ -868,8 +887,8 @@ Movement Commands ================= You can use most normal Emacs commands to move forward and -backward in the buffer. Some keys are rebound to functions that -take advantage of the fact that the buffer is a pcl-cvs buffer: +backward in the buffer. Some keys are rebound to functions that take +advantage of the fact that the buffer is a pcl-cvs buffer: `SPC' `C-n' @@ -889,27 +908,27 @@ Marking files ============= Pcl-cvs works on a set of "selected files" (*note Selected -files::.). You can mark and unmark files with these commands: +files::.). You can mark and unmark files with these commands: `m' This marks the file that the cursor is positioned on. If the cursor is positioned on a directory all files in that directory - will be marked. (`cvs-mark'). + will be marked. (`cvs-mode-mark'). `u' Unmark the file that the cursor is positioned on. If the cursor - is on a directory, all files in that directory will be unmarked. - (`cvs-unmark'). + is on a directory, all files in that directory will be unmarked. + (`cvs-mode-unmark'). `M' - Mark *all* files in the buffer (`cvs-mark-all-files'). + Mark *all* files in the buffer (`cvs-mode-mark-all-files'). -`U' - Unmark *all* files (`cvs-unmark-all-files'). +`ESC DEL' + Unmark *all* files (`cvs-mode-unmark-all-files'). `DEL' - Unmark the file on the previous line, and move point to that - line (`cvs-unmark-up'). + Unmark the file on the previous line, and move point to that line + (`cvs-mode-unmark-up'). File: pcl-cvs, Node: Committing changes, Next: Editing files, Prev: Marking files, Up: Commands @@ -922,46 +941,53 @@ Committing changes Buffer contents::.) can be checked in with the `c' command. It checks in all selected files (*note Selected files::.) (except those who lack the "ci"-marker - they are ignored). Pressing - `c' causes `cvs-commit' to be run. + `c' causes `cvs-mode-commit' to be run. When you press `c' you will get a buffer called - `*cvs-commit-message*'. Enter the log message for the file(s) - in it. When you are ready you should press `C-c C-c' to - actually commit the files (using `cvs-edit-done'). + `*cvs-commit-message*'. Enter the log message for the file(s) in + it. When you are ready you should press `C-c C-c' to actually + commit the files (using `cvs-edit-done'). Normally the `*cvs-commit-message*' buffer will retain the log message from the previous commit, but if the variable - `cvs-erase-input-buffer' is set to a non-nil value the buffer - will be erased. Point and mark will always be located around - the entire buffer so that you can easily erase it with `C-w' + `cvs-erase-input-buffer' is set to a non-`nil' value the buffer + will be erased. Point and mark will always be located around the + entire buffer so that you can easily erase it with `C-w' (`kill-region'). + If you are editing the files in your emacs an automatic + `revert-buffer' will be performed. (If the file contains `$Id$' + keywords `cvs commit' will write a new file with the new values + substituted. The auto-revert makes sure that you get them into + your buffer). The revert will not occur if you have modified + your buffer, or if `cvs-auto-revert-after-commit' is set to + `nil'. + File: pcl-cvs, Node: Editing files, Next: Getting info about files, Prev: Committing changes, Up: Commands Editing files ============= - There are currently three commands that can be used to find a -file (that is, load it into a buffer and start editing it there). -These commands work on the line that the cursor is situated at. -They ignore any marked files. + There are currently three commands that can be used to find a file +(that is, load it into a buffer and start editing it there). These +commands work on the line that the cursor is situated at. They +ignore any marked files. `f' - Find the file that the cursor points to. Run `dired' - - (*note Dired: (Emacs)Dired.) - - if the cursor points to a directory (`cvs-find-file'). + Find the file that the cursor points to. Run `dired' (*note + Dired: (Emacs)Dired.) if the cursor points to a directory + (`cvs-mode-find-file'). `o' - Like `f', but use another window (`cvs-find-file-other-window'). + Like `f', but use another window + (`cvs-mode-find-file-other-window'). `A' - Invoke `add-change-log-entry-other-window' to edit a - `ChangeLog' file. The `ChangeLog' will be found in the - directory of the file the cursor points to. - (`cvs-add-change-log-entry-other-window'). + Invoke `add-change-log-entry-other-window' to edit a `ChangeLog' + file. The `ChangeLog' will be found in the directory of the + file the cursor points to. + (`cvs-mode-add-change-log-entry-other-window'). File: pcl-cvs, Node: Getting info about files, Next: Adding and removing files, Prev: Editing files, Up: Commands @@ -969,19 +995,19 @@ File: pcl-cvs, Node: Getting info about files, Next: Adding and removing files Getting info about files ======================== - Both of the following commands can be customized. *Note + Both of the following commands can be customized. *Note Customization::. `l' Run `cvs log' on all selected files, and show the result in a - temporary buffer (`cvs-log'). + temporary buffer (`cvs-mode-log'). `s' Run `cvs status' on all selected files, and show the result in a - temporary buffer (`cvs-status'). + temporary buffer (`cvs-mode-status'). -File: pcl-cvs, Node: Adding and removing files, Next: Removing handled entries, Prev: Getting info about files, Up: Commands +File: pcl-cvs, Node: Adding and removing files, Next: Undoing changes, Prev: Getting info about files, Up: Commands Adding and removing files ========================= @@ -992,9 +1018,9 @@ remove files from the CVS repository. `a' Add all selected files. This command can be used on `Unknown' files (see *note File status::.). The status of the file will - change to `Added', and you will have to use `c' (`cvs-commit', - see *note Committing changes::.) to really add the file to the - repository. + change to `Added', and you will have to use `c' + (`cvs-mode-commit', see *note Committing changes::.) to really + add the file to the repository. This command can also be used on `Removed' files (before you commit them) to resurrect them. @@ -1002,42 +1028,55 @@ remove files from the CVS repository. Selected files that are neither `Unknown' nor `Removed' will be ignored by this command. - The command that is run is `cvs-add'. + The command that is run is `cvs-mode-add'. `r' This command removes the selected files (after prompting for confirmation). The files are `rm'ed from your directory and - (unless the status was `Unknown'; *note File status::.) they - will also be `cvs remove'd. If the files were `Unknown' they - will disappear from the buffer. Otherwise their status will - change to `Removed', and you must use `c' (`cvs-commit', *note + (unless the status was `Unknown'; *note File status::.) they will + also be `cvs remove'd. If the files were `Unknown' they will + disappear from the buffer. Otherwise their status will change to + `Removed', and you must use `c' (`cvs-mode-commit', *note Committing changes::.) to commit the removal. - The command that is run is `cvs-remove-file'. + The command that is run is `cvs-mode-remove-file'. -File: pcl-cvs, Node: Removing handled entries, Next: Ignoring files, Prev: Adding and removing files, Up: Commands +File: pcl-cvs, Node: Undoing changes, Next: Removing handled entries, Prev: Adding and removing files, Up: Commands + +Undoing changes +=============== + +`U' + If you have modified a file, and for some reason decide that you + don't want to keep the changes, you can undo them with this + command. It works by removing your working copy of the file and + then getting the latest version from the repository + (`cvs-mode-undo-local-changes'. + + +File: pcl-cvs, Node: Removing handled entries, Next: Ignoring files, Prev: Undoing changes, Up: Commands Removing handled entries ======================== `x' This command allows you to remove all entries that you have - processed. More specifically, the lines for `Updated' files - (*note File status::. and files that have been checked in - (*note Committing changes::.) are removed from the buffer. If - a directory becomes empty the heading for that directory is - also removed. This makes it easier to get an overview of what - needs to be done. - - The command is called `cvs-remove-handled'. If + processed. More specifically, the lines for `Updated' files + (*note File status::. and files that have been checked in (*note + Committing changes::.) are removed from the buffer. If a + directory becomes empty the heading for that directory is also + removed. This makes it easier to get an overview of what needs + to be done. + + The command is called `cvs-mode-remove-handled'. If `cvs-auto-remove-handled' is set to non-`nil' this will automatically be performed after every commit. `C-k' - This command can be used for lines that `cvs-remove-handled' - would not delete, but that you want to delete - (`cvs-acknowledge'). + This command can be used for lines that + `cvs-mode-remove-handled' would not delete, but that you want to + delete (`cvs-mode-acknowledge'). File: pcl-cvs, Node: Ignoring files, Next: Viewing differences, Prev: Removing handled entries, Up: Commands @@ -1048,39 +1087,111 @@ Ignoring files `i' Arrange so that CVS will ignore the selected files. The file names are added to the `.cvsignore' file in the corresponding - directory. If the `.cvsignore' doesn't exist it will be - created. + directory. If the `.cvsignore' doesn't exist it will be created. - The `.cvsignore' file should normally be added to the - repository, but you could ignore it also if you like it better - that way. + The `.cvsignore' file should normally be added to the repository, + but you could ignore it also if you like it better that way. - This runs `cvs-ignore'. + This runs `cvs-mode-ignore'. -File: pcl-cvs, Node: Viewing differences, Prev: Ignoring files, Up: Commands +File: pcl-cvs, Node: Viewing differences, Next: Emerge, Prev: Ignoring files, Up: Commands Viewing differences =================== `d' Display a `cvs diff' between the selected files and the RCS - version that they are based on. *Note Customization:: - describes how you can send flags to `cvs diff'. (The function - that does the job is `cvs-diff-cvs'). + version that they are based on. *Note Customization:: describes + how you can send flags to `cvs diff'. If CVS-DIFF-IGNORE-MARKS + is set to a non-`nil' value or if a prefix argument is given + (but not both) any marked files will not be considered to be + selected. (`cvs-mode-diff-cvs'). `b' If CVS finds a conflict while merging two versions of a file - (during a `cvs update', *note Updating the directory::.) it - will save the original file in a file called `.#FILE.VERSION' - where FILE is the name of the file, and VERSION is the RCS - version number that your file was based on. + (during a `cvs update', *note Updating the directory::.) it will + save the original file in a file called `.#FILE.VERSION' where + FILE is the name of the file, and VERSION is the RCS version + number that your file was based on. With the `b' command you can run a `diff' on the files `.#FILE.VERSION' and `FILE'. You can get a context- or Unidiff by setting `cvs-diff-flags' - *note Customization::.. This command only works on files that have status `Conflict' or - `Merged'. The name of the command is `cvs-diff-backup'. + `Merged'. + + If CVS-DIFF-IGNORE-MARKS is set to a non-`nil' value or if a + prefix argument is given (but not both) any marked files will + not be considered to be selected. (`cvs-mode-diff-backup'). + + +File: pcl-cvs, Node: Emerge, Next: Reverting your buffers, Prev: Viewing differences, Up: Commands + +Running emerge +============== + +`e' + Invoke `emerge' on one file. This command works slightly + different depending on the file status. + + `Modified' + Run `emerge-files' with your working file as file A, and + the latest revision in the repository as file B. + + `Merged' + `Conflict' + Run `emerge-files-with-ancestor' with your working file (as + it was prior to your invocation of `cvs-update') as file A, + the latest revision in the repository as file B, and the + revision that you based your local modifications on as + ancestor. + + *Note:* CVS has already performed a merge. The resulting file is + not used in any way if you use this command. If you use the `q' + command inside `emerge' (to successfully terminate the merge) the + file that CVS created will be overwritten. + + +File: pcl-cvs, Node: Reverting your buffers, Next: Miscellaneous commands, Prev: Emerge, Up: Commands + +Reverting your buffers +====================== + +`R' + If you are editing (or just viewing) a file in a buffer, and + that file is changed by CVS during a `cvs-update', all you have + to do is type `R' in the *cvs* buffer to read in the new + versions of the files. + + All files that are `Updated', `Merged' or in `Conflict' are + reverted from the disk. Any other files are ignored. Only files + that you were already editing are read. + + An error is signalled if you have modified the buffer since it + was last changed. (`cvs-mode-revert-updated-buffers'). + + +File: pcl-cvs, Node: Miscellaneous commands, Prev: Reverting your buffers, Up: Commands + +Miscellaneous commands +====================== + +`M-x cvs-byte-compile-files' + Byte compile all selected files that end in .el. + +`M-x cvs-delete-lock' + This command can be used in any buffer, and deletes the lock + files that the *cvs* buffer informs you about. You should + normally never have to use this command since CVS tries very + carefully to always remove the lock files itself. + + You can only use this command when a message in the *cvs* buffer + tells you so. You should wait a while before using this command + in case someone else is running a cvs command. + +`q' + Bury the *cvs* buffer. (`bury-buffer'). File: pcl-cvs, Node: Customization, Next: Future enhancements, Prev: Commands, Up: Top @@ -1088,77 +1199,176 @@ File: pcl-cvs, Node: Customization, Next: Future enhancements, Prev: Commands Customization ************* - If you have an idea about any customization that would be handy -but isn't present in this list, please tell me! *Note Reporting -bugs and ideas:: for info on how to reach me. + If you have an idea about any customization that would be handy but +isn't present in this list, please tell me! *Note Bugs:: for info on +how to reach me. `cvs-erase-input-buffer' - If set to anything else than `nil' the edit buffer will be - erased before you write the log message (*note Committing - changes::.). + If set to anything else than `nil' the edit buffer will be erased + before you write the log message (*note Committing changes::.). `cvs-inhibit-copyright-message' The copyright message that is displayed on startup can be - annoying after a while. Set this variable to `t' if you want - to get rid of it. (But don't set this to `t' in the system - defaults file - new users should see this message at least - once). + annoying after a while. Set this variable to `t' if you want to + get rid of it. (But don't set this to `t' in the system defaults + file - new users should see this message at least once). -`cvs-cvs-diff-flags' - A list of strings to pass as arguments to the `cvs diff' - program. This is used by `cvs-diff-cvs' (key `d', *note - Viewing differences::.). If you prefer the Unidiff format you - could add this line to your `.emacs' file: +`cvs-diff-flags' + A list of strings to pass as arguments to the `cvs diff' and + `diff' programs. This is used by `cvs-mode-diff-cvs' and + `cvs-mode-diff-backup' (key `b', *note Viewing differences::.). + If you prefer the Unidiff format you could add this line to your + `.emacs' file: - (setq cvs-cvs-diff-flags '("-u")) + (setq cvs-diff-flags '("-u")) -`cvs-diff-flags' - Like `cvs-cvs-diff-flags', but passed to `diff'. This is used - by `cvs-diff-backup' (key `b', *note Viewing differences::.). +`cvs-diff-ignore-marks' + If this variable is non-`nil' or if a prefix argument is given + (but not both) to `cvs-mode-diff-cvs' or `cvs-mode-diff-backup' + marked files are not considered selected. `cvs-log-flags' - List of strings to send to `cvs log'. Used by `cvs-log' (key - `l', *note Getting info about files::.). + List of strings to send to `cvs log'. Used by `cvs-mode-log' + (key `l', *note Getting info about files::.). `cvs-status-flags' - List of strings to send to `cvs status'. Used by `cvs-status' - (key `s', *note Getting info about files::.). + List of strings to send to `cvs status'. Used by + `cvs-mode-status' (key `s', *note Getting info about files::.). `cvs-auto-remove-handled' If this variable is set to any non-`nil' value - `cvs-remove-handled' will be called every time you check in + `cvs-mode-remove-handled' will be called every time you check in files, after the check-in is ready. *Note Removing handled entries::. +`cvs-auto-revert-after-commit' + If this variable is set to any non-`nil' value any buffers you + have that visit a file that is committed will be automatically + reverted. This variable is default `t'. *Note Committing + changes::. + +`cvs-update-prog-output-skip-regexp' + The `-u' flag in the `modules' file can be used to run a command + whenever a `cvs update' is performed (see cvs(5)). This regexp + is used to search for the last line in that output. It is + normally set to `"$"'. That setting is only correct if the + command outputs nothing. Note that pcl-cvs will get very + confused if the command outputs *anything* to `stderr'. + +`cvs-cvsroot' + This variable can be set to override `CVSROOT'. It should be a + string. If it is set then everytime a cvs command is run it will + be called as `cvs -d CVS-CVSROOT...' This can be useful if your + site has several repositories. + +`TMPDIR' + Pcl-cvs uses this *environment variable* to decide where to put + the temporary files it needs. It defaults to `/tmp' if it is + not set. + +`cvs-commit-buffer-require-final-newline' + When you enter a log message in the `*cvs-commit-message*' buffer + pcl-cvs will normally automatically insert a trailing newline, + unless there already is one. This behavior can be controlled via + `cvs-commit-buffer-require-final-newline'. If it is `t' (the + default behavior), a newline will always be appended. If it is + `nil', newlines will never be appended. Any other value causes + pcl-cvs to ask the user whenever there is no trailing newline in + the commit message buffer. + +`cvs-sort-ignore-file' + If this variable is set to any non-`nil' value the `.cvsignore' + will always be sorted whenever you use `cvs-mode-ignore' to add + a file to it. This option is on by default. + -File: pcl-cvs, Node: Future enhancements, Next: Reporting bugs and ideas, Prev: Customization, Up: Top +File: pcl-cvs, Node: Future enhancements, Next: Bugs, Prev: Customization, Up: Top Future enhancements ******************* Pcl-cvs is still under development and needs a number of -enhancements to be called complete. Here is my current wish-list -for future releases of pcl-cvs: - - * Dired support. I have an experimental `dired-cvs.el' that works - together with CVS 1.2. Unfortunately I wrote it on top of a - non-standard `dired.el', so it must be rewritten. +enhancements to be called complete. Below is my current wish-list +for future releases of pcl-cvs. Please, let me know which of these +features you want most. They are listed below in approximately the +order that I currently think I will implement them in. + + * Rewritten parser code. There are many situations where pcl-cvs + will fail to recognize the output from CVS. The situation could + be greatly increased. + + * `cvs-status'. This will run `cvs status' in a directory and + produce a buffer that looks pretty much like the current *cvs* + buffer. That buffer will include information for all + version-controlled files. (There will be a simple keystroke to + remove all "uninteresting" files, that is, files that are + "Up-to-date"). In this new buffer you will be able to update a + file, commit a file, et c. The big win with this is that you + will be able to watch the differences between your current + working file and the head revision in the repository before you + update the file, and you can then choose to update it or let it + wait for a while longer. + + * Log mode. When this mode is finished you will be able to move + around (using `n' and `p') between the revisions of a file, mark + two of them, and run a diff between them. You will be able to + hide branches (similar to the way you can hide sub-paragraphs in + outline-mode) and do merges between revisions. Other ideas + about this are welcome. + + * The current model for marks in the *cvs* buffer seems to be + confusing. I am considering to use the VM model instead, where + marks are normally inactive. To activate the mark, you issue a + command like `cvs-mode-next-command-uses-marks'. I might + implement a flag so that you can use either version. Feedback + on this before I start coding it is very welcome. * It should be possible to run commands such as `cvs log', `cvs status' and `cvs commit' directly from a buffer containing a file, instead of having to `cvs-update'. If the directory contains many files the `cvs-update' can take quite some time, - especially on a slow machine. + especially on a slow machine. I planed to put these kind of + commands on the prefix `C-c C-v', but that turned out to be used + by for instance c++-mode. If you have any suggestions for a + better prefix key, please let me know. + + * Increased robustness. For instance, you can not currently press + `C-g' when you are entering the description of a file that you + are adding without confusing pcl-cvs. + + * Support for multiple active *cvs* buffers. + + * Dired support. I have an experimental `dired-cvs.el' that works + together with CVS 1.2. Unfortunately I wrote it on top of a + non-standard `dired.el', so it must be rewritten. + + * An ability to send user-supplied options to all the cvs commands. + + * Pcl-cvs is not at all clever about what it should do when `cvs + update' runs a program (due to the `-u' option in the `modules' + file -- see `cvs(5)'). The current release uses a regexp to + search for the end. At the very least that regexp should be + configured for different modules. Tell me if you have any idea + about what is the right thing to do. In a perfect world the + program should also be allowed to print to `stderr' without + causing pcl-cvs to crash. If you miss something in this wish-list, let me know! I don't promise that I will write it, but I will at least try to coordinate the efforts of making a good Emacs front end to CVS. See *Note -Reporting bugs and ideas:: for information about how to reach me. +Bugs:: for information about how to reach me. + + So far, I have written most of pcl-cvs in my all-to-rare spare +time. If you want pcl-cvs to be developed faster you can write a +contract with Signum Support to do the extension. You can reach +Signum Support by email to `info@signum.se' or via mail to Signum +Support AB, Box 2044, S-580 02 Linkoping, Sweden. Phone: +46 (0) 13 - +21 46 00. Fax: +46 (0) 13 - 21 47 00. -File: pcl-cvs, Node: Reporting bugs and ideas, Next: Function and Variable Index, Prev: Future enhancements, Up: Top +File: pcl-cvs, Node: Bugs, Next: Function and Variable Index, Prev: Future enhancements, Up: Top -Reporting bugs and ideas +Bugs (known and unknown) ************************ If you find a bug or misfeature, don't hesitate to tell me! Send @@ -1168,43 +1378,89 @@ email to `ceder@lysator.liu.se'. extensions to this package, I would like to hear from you. I hope that you find this package useful! + Below is a partial list of currently known problems with pcl-cvs +version 1.05. + +Commit causes Emacs to hang + Emacs waits for the `cvs commit' command to finish before you can + do anything. If you start a background job from the loginfo + file you must take care that it closes `stdout' and `stderr' if + you do not want to wait for it. (You do that with + `background-command &>- 2&>- &' if you are starting + `background-command' from a `/bin/sh' shell script). + + Your emacs will also hang if there was a lock file in the + repository. In this case you can type `C-g' to get control over + your emacs again. + +Name clash in Emacs 19 + This is really a bug in Elib or the Emacs 19 distribution. Both + Elib and Emacs 19.6 through at least 19.10 contains a file named + `cookie.el'. One of the files will have to be renamed, and we + are currently negotiating about which of the files to rename. + +Commands while cvs-update is running + It is possible to type commands in the *cvs* buffer while the + update is running, but error messages is all that you will get. + The error messages should be better. + +Unexpected output from CVS + Unexpected output from CVS confuses pcl-cvs. It will currently + create a bug report that you can mail to me. It should do + something more civilized. + -File: pcl-cvs, Node: Function and Variable Index, Next: Concept Index, Prev: Reporting bugs and ideas, Up: Top +File: pcl-cvs, Node: Function and Variable Index, Next: Concept Index, Prev: Bugs, Up: Top Function and Variable Index *************************** * Menu: +* bury-buffer: Miscellaneous commands. * cookie-next-cookie: Movement commands. * cookie-previous-cookie: Movement commands. -* cvs-acknowledge: Removing handled entries. -* cvs-add: Adding and removing files. -* cvs-add-change-log-entry-other-window: Editing files. * cvs-auto-remove-handled (variable): Customization. -* cvs-commit: Committing changes. -* cvs-cvs-diff-flags (variable): Customization. -* cvs-diff-backup: Viewing differences. -* cvs-diff-cvs: Viewing differences. +* cvs-auto-revert-after-commit (variable): Customization. +* cvs-auto-revert-after-commit (variable): Committing changes. +* cvs-byte-compile-files: Miscellaneous commands. +* cvs-commit-buffer-require-final-newline (variable): Customization. +* cvs-cvsroot (variable): Customization. +* cvs-delete-lock: Updating the directory. * cvs-diff-flags (variable): Customization. -* cvs-erase-input-buffer (variable): Committing changes. +* cvs-diff-ignore-marks (variable): Customization. +* cvs-diff-ignore-marks (variable): Viewing differences. * cvs-erase-input-buffer (variable): Customization. -* cvs-find-file: Editing files. -* cvs-find-file-other-window: Editing files. +* cvs-erase-input-buffer (variable): Committing changes. * cvs-inhibit-copyright-message (variable): Customization. -* cvs-log: Getting info about files. * cvs-log-flags (variable): Customization. -* cvs-mark: Marking files. -* cvs-mark-all-files: Marking files. -* cvs-remove-file: Adding and removing files. -* cvs-remove-handled: Removing handled entries. -* cvs-status: Getting info about files. +* cvs-mode-acknowledge: Removing handled entries. +* cvs-mode-add: Adding and removing files. +* cvs-mode-add-change-log-entry-other-window: Editing files. +* cvs-mode-commit: Committing changes. +* cvs-mode-diff-backup: Viewing differences. +* cvs-mode-diff-cvs: Viewing differences. +* cvs-mode-emerge: Emerge. +* cvs-mode-find-file: Editing files. +* cvs-mode-find-file-other-window: Editing files. +* cvs-mode-ignore: Removing handled entries. +* cvs-mode-log: Getting info about files. +* cvs-mode-mark: Marking files. +* cvs-mode-mark-all-files: Marking files. +* cvs-mode-remove-file: Adding and removing files. +* cvs-mode-remove-handled: Removing handled entries. +* cvs-mode-revert-updated-buffers: Reverting your buffers. +* cvs-mode-status: Getting info about files. +* cvs-mode-undo-local-changes: Undoing changes. +* cvs-mode-unmark: Marking files. +* cvs-mode-unmark-all-files: Marking files. +* cvs-mode-unmark-up: Marking files. +* cvs-mode-update-no-prompt: Updating the directory. +* cvs-sort-ignore-file (variable): Customization. * cvs-status-flags (variable): Customization. -* cvs-unmark: Marking files. -* cvs-unmark-all-files: Marking files. -* cvs-unmark-up: Marking files. * cvs-update: Updating the directory. -* cvs-update-no-prompt: Updating the directory. +* cvs-update-prog-output-skip-regexp (variable): Customization. +* TMPDIR (environment variable): Customization. File: pcl-cvs, Node: Concept Index, Next: Key Index, Prev: Function and Variable Index, Up: Top @@ -1214,21 +1470,29 @@ Concept Index * Menu: +* -u option in modules file: Customization. +* .cvsignore file, sorting: Customization. * About pcl-cvs: About pcl-cvs. * Active files: Selected files. * Added (file status): File status. * Adding files: Adding and removing files. * Archives: Archives. -* Author, how to reach: Reporting bugs and ideas. +* Author, how to reach: Bugs. * Authors: Contributors. +* Automatically inserting newline: Customization. * Automatically remove handled files: Customization. +* Automatically sorting .cvsignore: Customization. * Buffer contents: Buffer contents. -* Bugs, how to report them: Reporting bugs and ideas. +* Bugs, how to report them: Bugs. +* Bugs, known: Bugs. +* Byte compilation: Miscellaneous commands. * Ci: Committing changes. * Commit buffer: Committing changes. +* Commit message, inserting newline: Customization. * Committing changes: Committing changes. * Conflict (file status): File status. * Conflicts, how to resolve them: Viewing differences. +* Conflicts, resolving: Emerge. * Context diff, how to get: Customization. * Contributors: Contributors. * Copyright message, getting rid of it: Customization. @@ -1239,22 +1503,27 @@ Concept Index * Edit buffer: Committing changes. * Editing files: Editing files. * Email archives: Archives. -* Email to the author: Reporting bugs and ideas. +* Email to the author: Bugs. +* Emerge: Emerge. * Enhancements: Future enhancements. * Erasing commit message: Committing changes. * Erasing the input buffer: Customization. * Example run: Getting started. * Expunging uninteresting entries: Removing handled entries. +* FAQ: Bugs. * File selection: Selected files. * File status: File status. * Finding files: Editing files. +* Flush changes: Undoing changes. * Ftp-sites: Archives. * Generating a typeset manual: Typeset manual installation. * Generating the on-line manual: On-line manual installation. * Getting pcl-cvs: Archives. +* Getting rid of lock files: Miscellaneous commands. * Getting rid of the Copyright message.: Customization. * Getting rid of uninteresting lines: Removing handled entries. * Getting status: Getting info about files. +* Getting the *cvs* buffer: Updating the directory. * Handled lines, removing them: Removing handled entries. * Info-file (how to generate): On-line manual installation. * Inhibiting the Copyright message.: Customization. @@ -1264,7 +1533,10 @@ Concept Index * Installation of typeset manual: Typeset manual installation. * Introduction: Getting started. * Invoking dired: Editing files. +* Invoking emerge: Emerge. +* Known bugs: Bugs. * Loading files: Editing files. +* Lock files: Miscellaneous commands. * Log (RCS/cvs command): Getting info about files. * Manual installation (on-line): On-line manual installation. * Manual installation (typeset): Typeset manual installation. @@ -1272,28 +1544,40 @@ Concept Index * Marking files: Marking files. * Merged (file status): File status. * Modified (file status): File status. +* Modules file (-u option): Customization. * Move away FILE - it is in the way (file status): File status. * Movement Commands: Movement commands. * On-line manual (how to generate): On-line manual installation. * Printing a manual: Typeset manual installation. +* Problems, list of common: Bugs. * Putting files under CVS control: Adding and removing files. +* Recompiling elisp files: Miscellaneous commands. * Removed (file status): File status. * Removed by you, changed in repository (file status): File status. * Removed from repository (file status): File status. * Removed from repository, changed by you (file status): File status. * Removing files: Adding and removing files. * Removing uninteresting (processed) lines: Removing handled entries. -* Reporting bugs and ideas: Reporting bugs and ideas. +* Reporting bugs and ideas: Bugs. +* Require final newline: Customization. +* Resolving conflicts: Emerge. * Resurrecting files: Adding and removing files. +* Reverting buffers: Reverting your buffers. +* Reverting buffers after commit: Committing changes. +* Reverting buffers after commit: Customization. * Selected files: Selected files. * Selecting files (commands to mark files): Marking files. * Sites: Archives. +* Sorting the .cvsignore file: Customization. * Status (cvs command): Getting info about files. +* Syncing buffers: Reverting your buffers. * TeX - generating a typeset manual: Typeset manual installation. * This repository is missing!... (file status): File status. +* Undo changes: Undoing changes. * Unidiff, how to get: Customization. * Uninteresting entries, getting rid of them: Removing handled entries. * Unknown (file status): File status. +* Update program (-u option in modules file): Customization. * Updated (file status): File status. * Variables, list of all: Customization. * Viewing differences: Viewing differences. @@ -1306,62 +1590,70 @@ Key Index * Menu: +* a - add a file: Adding and removing files. * A - add ChangeLog entry: Editing files. +* b - diff backup file: Viewing differences. +* c - commit files: Committing changes. * C-k - remove selected entries: Removing handled entries. * C-n - Move down one file: Movement commands. * C-p - Move up one file: Movement commands. -* DEL - unmark previous file: Marking files. -* M - marking all files: Marking files. -* SPC - Move down one file: Movement commands. -* U - unmark all files: Marking files. -* a - add a file: Adding and removing files. -* b - diff backup file: Viewing differences. -* c - commit files: Committing changes. * d - run cvs diff: Viewing differences. +* DEL - unmark previous file: Marking files. +* e - invoke emerge: Emerge. +* ESC DEL - unmark all files: Marking files. * f - find file or directory: Editing files. * g - Rerun cvs update: Updating the directory. * l - run cvs log: Getting info about files. * m - marking a file: Marking files. +* M - marking all files: Marking files. * n - Move down one file: Movement commands. * o - find file in other window: Editing files. * p - Move up on file: Movement commands. +* q - bury the *cvs* buffer: Miscellaneous commands. * r - remove a file: Adding and removing files. +* R - revert buffers: Reverting your buffers. * s - run cvs status: Getting info about files. +* SPC - Move down one file: Movement commands. +* U - undo changes: Undoing changes. * u - unmark a file: Marking files. * x - remove processed entries: Removing handled entries. Tag Table: -Node: Top1004 -Node: Copying3396 -Node: Installation22716 -Node: Pcl-cvs installation23507 -Node: On-line manual installation25291 -Node: Typeset manual installation26310 -Node: About pcl-cvs27048 -Node: Contributors27417 -Node: Archives28440 -Node: Getting started29287 -Node: Buffer contents31728 -Node: File status32277 -Node: Selected files35303 -Node: Commands35976 -Node: Updating the directory37018 -Node: Movement commands38043 -Node: Marking files38629 -Node: Committing changes39456 -Node: Editing files40502 -Node: Getting info about files41335 -Node: Adding and removing files41805 -Node: Removing handled entries43145 -Node: Ignoring files44058 -Node: Viewing differences44593 -Node: Customization45595 -Node: Future enhancements47326 -Node: Reporting bugs and ideas48394 -Node: Function and Variable Index48842 -Node: Concept Index50743 -Node: Key Index55865 +Node: Top1007 +Node: Copying3571 +Node: Installation22803 +Node: Pcl-cvs installation23593 +Node: On-line manual installation25654 +Node: Typeset manual installation26672 +Node: About pcl-cvs27411 +Node: Contributors27780 +Node: Archives29083 +Node: Getting started29662 +Node: Buffer contents32105 +Node: File status32654 +Node: Selected files35679 +Node: Commands36347 +Node: Updating the directory37558 +Node: Movement commands39217 +Node: Marking files39803 +Node: Committing changes40658 +Node: Editing files42124 +Node: Getting info about files42969 +Node: Adding and removing files43448 +Node: Undoing changes44799 +Node: Removing handled entries45259 +Node: Ignoring files46176 +Node: Viewing differences46706 +Node: Emerge48014 +Node: Reverting your buffers48988 +Node: Miscellaneous commands49685 +Node: Customization50427 +Node: Future enhancements54107 +Node: Bugs58298 +Node: Function and Variable Index60079 +Node: Concept Index62872 +Node: Key Index69468 End Tag Table diff --git a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.texinfo b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.texinfo index 5ad8db1..0b51f77 100644 --- a/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.texinfo +++ b/gnu/usr.bin/cvs/contrib/pcl-cvs/pcl-cvs.texinfo @@ -1,6 +1,6 @@ \input texinfo @c -*-texinfo-*- -@comment pcl-cvs.texinfo,v 1.2 1992/04/07 20:49:23 berliner Exp +@comment Id: pcl-cvs.texinfo,v 1.45 1993/05/31 22:38:15 ceder Exp @comment Documentation for the GNU Emacs CVS mode. @comment Copyright (C) 1992 Per Cederqvist @@ -62,12 +62,12 @@ Free Software Foundation instead of in the original English. @sp @center @titlefont{pcl-cvs - the Emacs Front-End to CVS} @sp 2 -@center release 1.02 +@center release 1.05 @comment -release- @sp 3 @center Per Cederqvist @sp 3 -@center last updated 29 Mar 1992 +@center last updated 31 May 1993 @comment -date- @comment The following two commands start the copyright page @@ -104,7 +104,7 @@ Free Software Foundation instead of in the original English. @ifinfo This info manual describes pcl-cvs which is a GNU Emacs front-end to CVS. It works with CVS version 1.3. This manual is updated to release -1.02 of pcl-cvs. +1.05 of pcl-cvs. @end ifinfo @comment -release- @@ -119,9 +119,8 @@ CVS. It works with CVS version 1.3. This manual is updated to release * Customization:: How you can tailor pcl-cvs to suit your needs. * Future enhancements:: Future enhancements of pcl-cvs. -* Reporting bugs and ideas:: Where to report bugs. - -* Function and Variable Index:: List of functions and variables. +* Bugs:: Bugs (known and unknown). +* Function and Variable Index:: List of functions and variables. * Concept Index:: List of concepts. * Key Index:: List of keystrokes. @@ -129,7 +128,7 @@ CVS. It works with CVS version 1.3. This manual is updated to release Installation -* Pcl-cvs installation:: How to install pcl-cvs on your system. +* Pcl-cvs installation:: How to install pcl-cvs on your system. * On-line manual installation:: How to install the on-line manual. * Typeset manual installation:: How to create typeset documentation about pcl-cvs. @@ -155,9 +154,13 @@ Commands * Editing files:: Loading files into Emacs. * Getting info about files:: Display the log and status of files. * Adding and removing files:: Adding and removing files +* Undoing changes:: Undoing changes * Removing handled entries:: Uninteresting lines can easily be removed. * Ignoring files:: Telling CVS to ignore generated files. * Viewing differences:: Commands to @samp{diff} different versions. +* Emerge:: +* Reverting your buffers:: Reverting your buffers +* Miscellaneous commands:: Miscellaneous commands @end menu @node Copying, Installation, Top, Top @@ -565,7 +568,7 @@ steps are also described in the file @file{INSTALL} in the source directory. @menu -* Pcl-cvs installation:: How to install pcl-cvs on your system. +* Pcl-cvs installation:: How to install pcl-cvs on your system. * On-line manual installation:: How to install the on-line manual. * Typeset manual installation:: How to create typeset documentation about pcl-cvs. @@ -601,6 +604,13 @@ in emacs that causes it to dump core. The bug was fixed in emacs 18.58.@refill @item +Release 1.05 and later of pcl-cvs requires parts of the Elib library, +version 0.07 or later. Elib is available via anonymous ftp from +prep.ai.mit.edu in @file{pub/gnu/elib-0.07.tar.z}, and from a lot of +other sites that mirrors prep. Get Elib, and install it, before +proceeding. + +@item Type @samp{make install} in the source directory. This will byte-compile all @file{.el} files and copy both the @file{.el} and the @file{.elc} into the directory you specified in step 1. @@ -701,7 +711,7 @@ frequently used CVS commands into emacs. Contributions to the package are welcome. I have limited time to work on this project, but I will gladly add any code that you contribute to -me to this package (@pxref{Reporting bugs and ideas}). +me to this package (@pxref{Bugs}). The following persons have made contributions to pcl-cvs. @@ -724,8 +734,17 @@ the files @file{elib-node.el} and @file{compile-all.el}. The file Linus Tolke (@samp{linus@@lysator.liu.se}) contributed useful comments on both the functionality and the documentation.@refill +@item +Jamie Zawinski (@samp{jwz@@lucid.com}) contributed +@file{pcl-cvs-lucid.el}. + +@item +Leif Lonnblad contributed RCVS support. @end itemize +Apart from these, a lot of people have send me suggestions, ideas, +requests, bug reports and encouragement. Thanks a lot! Without your +there would be no new releases of pcl-cvs. @node Archives, , Contributors, About pcl-cvs @comment node-name, next, previous, up @@ -736,11 +755,6 @@ on both the functionality and the documentation.@refill @cindex Getting pcl-cvs @cindex Email archives -This release of pcl-cvs is included in the CVS 1.3 distribution. -However, since pcl-cvs has had less time to mature (the first line of -code was written less than a year ago) it is likely that there will be a -new release of pcl-cvs before the next release of CVS. - The latest release of pcl-cvs can be fetched via anonymous ftp from @code{ftp.lysator.liu.se}, (IP no. 130.236.254.1) in the directory @code{pub/emacs}. If you don't live in Scandinavia you should probably @@ -765,7 +779,7 @@ Pcl-cvs is only useful once you have checked out a module. So before you invoke it you must have a copy of a module somewhere in the file system. -You invoke pcl-cvs by typing @kbd{M-x pcl-cvs RET}. If your emacs +You invoke pcl-cvs by typing @kbd{M-x cvs-update RET}. If your emacs responds with @samp{[No match]} your system administrator has not installed pcl-cvs properly. Try @kbd{M-x load-library RET pcl-cvs RET}. If that also fails - talk to your root. If it succeeds you might put @@ -783,7 +797,7 @@ files that have been checked out from a CVS archive.) The output from @samp{*cvs*}. It might look something like this: @example -PCL-CVS release 1.02. +PCL-CVS release 1.05. @comment -release- In directory /users/ceder/FOO/test: @@ -979,16 +993,22 @@ you can use in pcl-cvs. They are grouped together by type. * Editing files:: Loading files into Emacs. * Getting info about files:: Display the log and status of files. * Adding and removing files:: Adding and removing files +* Undoing changes:: Undoing changes * Removing handled entries:: Uninteresting lines can easily be removed. * Ignoring files:: Telling CVS to ignore generated files. * Viewing differences:: Commands to @samp{diff} different versions. +* Emerge:: +* Reverting your buffers:: Reverting your buffers +* Miscellaneous commands:: Miscellaneous commands @end menu @node Updating the directory, Movement commands, Commands, Commands @comment node-name, next, previous, up @section Updating the directory @findex cvs-update -@findex cvs-update-no-prompt +@findex cvs-mode-update-no-prompt +@findex cvs-delete-lock +@cindex Getting the *cvs* buffer @kindex g - Rerun @samp{cvs update} @@ -1007,11 +1027,21 @@ argument to it (e.g., by typing @kbd{C-u M-x cvs-update RET}).@refill All other commands in pcl-cvs requires that you have a @samp{*cvs*} buffer. This is the command that you use to get one.@refill +CVS uses lock files in the repository to ensure the integrity of the +data files in the repository. They might be left behind i.e. if a +workstation crashes in the middle of a CVS operation. CVS outputs a +message when it is waiting for a lock file to go away. Pcl-cvs will +show the same message in the *cvs* buffer, together with instructions +for deleting the lock files. You should normally not have to delete +them manually --- just wait a little while and the problem should fix +itself. But if the lock files doesn't disappear you can delete them +with @kbd{M-x cvs-delete-lock RET}.@refill + @item g This will run @samp{cvs update} again. It will always use the same buffer that was used with the previous @samp{cvs update}. Give a prefix argument to avoid descending into subdirectories. This runs the command -@samp{cvs-update-no-prompt}.@refill +@samp{cvs-mode-update-no-prompt}.@refill @end table @node Movement commands, Marking files, Updating the directory, Commands @comment node-name, next, previous, up @@ -1051,13 +1081,13 @@ These keys move one file backward, towards the beginning of the buffer @kindex m - marking a file @kindex M - marking all files @kindex u - unmark a file -@kindex U - unmark all files +@kindex ESC DEL - unmark all files @kindex DEL - unmark previous file -@findex cvs-mark -@findex cvs-unmark -@findex cvs-mark-all-files -@findex cvs-unmark-all-files -@findex cvs-unmark-up +@findex cvs-mode-mark +@findex cvs-mode-unmark +@findex cvs-mode-mark-all-files +@findex cvs-mode-unmark-all-files +@findex cvs-mode-unmark-up Pcl-cvs works on a set of @dfn{selected files} (@pxref{Selected files}). You can mark and unmark files with these commands: @@ -1066,22 +1096,22 @@ You can mark and unmark files with these commands: @item m This marks the file that the cursor is positioned on. If the cursor is positioned on a directory all files in that directory will be marked. -(@code{cvs-mark}). +(@code{cvs-mode-mark}). @item u Unmark the file that the cursor is positioned on. If the cursor is on a directory, all files in that directory will be unmarked. -(@code{cvs-unmark}).@refill +(@code{cvs-mode-unmark}).@refill @item M -Mark @emph{all} files in the buffer (@code{cvs-mark-all-files}). +Mark @emph{all} files in the buffer (@code{cvs-mode-mark-all-files}). -@item U -Unmark @emph{all} files (@code{cvs-unmark-all-files}). +@item @key{ESC} @key{DEL} +Unmark @emph{all} files (@code{cvs-mode-unmark-all-files}). @item @key{DEL} Unmark the file on the previous line, and move point to that line -(@code{cvs-unmark-up}). +(@code{cvs-mode-unmark-up}). @end table @node Committing changes, Editing files, Marking files, Commands @@ -1089,12 +1119,14 @@ Unmark the file on the previous line, and move point to that line @section Committing changes @cindex Committing changes @cindex Ci -@findex cvs-commit +@findex cvs-mode-commit @kindex c - commit files @vindex cvs-erase-input-buffer (variable) +@vindex cvs-auto-revert-after-commit (variable) @cindex Commit buffer @cindex Edit buffer @cindex Erasing commit message +@cindex Reverting buffers after commit @table @kbd @item c @@ -1102,7 +1134,7 @@ All files that have a "need to be checked in"-marker (@pxref{Buffer contents}) can be checked in with the @kbd{c} command. It checks in all selected files (@pxref{Selected files}) (except those who lack the "ci"-marker - they are ignored). Pressing @kbd{c} causes -@code{cvs-commit} to be run.@refill +@code{cvs-mode-commit} to be run.@refill When you press @kbd{c} you will get a buffer called @samp{*cvs-commit-message*}. Enter the log message for the file(s) in @@ -1111,10 +1143,18 @@ commit the files (using @code{cvs-edit-done}). Normally the @samp{*cvs-commit-message*} buffer will retain the log message from the previous commit, but if the variable -@code{cvs-erase-input-buffer} is set to a non-nil value the buffer will -be erased. Point and mark will always be located around the entire -buffer so that you can easily erase it with @kbd{C-w} +@code{cvs-erase-input-buffer} is set to a non-@code{nil} value the +buffer will be erased. Point and mark will always be located around the +entire buffer so that you can easily erase it with @kbd{C-w} (@samp{kill-region}).@refill + +If you are editing the files in your emacs an automatic +@samp{revert-buffer} will be performed. (If the file contains +@samp{$@asis{Id}$} keywords @samp{cvs commit} will write a new file with +the new values substituted. The auto-revert makes sure that you get +them into your buffer). The revert will not occur if you have modified +your buffer, or if @samp{cvs-auto-revert-after-commit} is set to +@samp{nil}.@refill @end table @node Editing files, Getting info about files, Committing changes, Commands @@ -1126,9 +1166,9 @@ buffer so that you can easily erase it with @kbd{C-w} @cindex Loading files @cindex Dired @cindex Invoking dired -@findex cvs-find-file -@findex cvs-find-file-other-window -@findex cvs-add-change-log-entry-other-window +@findex cvs-mode-find-file +@findex cvs-mode-find-file-other-window +@findex cvs-mode-add-change-log-entry-other-window @kindex f - find file or directory @kindex o - find file in other window @kindex A - add ChangeLog entry @@ -1144,17 +1184,17 @@ Find the file that the cursor points to. Run @samp{dired} @ifinfo (@pxref{Dired,,,Emacs}) @end ifinfo -if the cursor points to a directory (@code{cvs-find-file}).@refill +if the cursor points to a directory (@code{cvs-mode-find-file}).@refill @item o Like @kbd{f}, but use another window -(@code{cvs-find-file-other-window}).@refill +(@code{cvs-mode-find-file-other-window}).@refill @item A Invoke @samp{add-change-log-entry-other-window} to edit a @samp{ChangeLog} file. The @samp{ChangeLog} will be found in the directory of the file the cursor points to. -(@code{cvs-add-change-log-entry-other-window}).@refill +(@code{cvs-mode-add-change-log-entry-other-window}).@refill @end table @node Getting info about files, Adding and removing files, Editing files, Commands @@ -1165,8 +1205,8 @@ directory of the file the cursor points to. @cindex Getting status @kindex l - run @samp{cvs log} @kindex s - run @samp{cvs status} -@findex cvs-log -@findex cvs-status +@findex cvs-mode-log +@findex cvs-mode-status Both of the following commands can be customized. @xref{Customization}.@refill @@ -1174,14 +1214,14 @@ Both of the following commands can be customized. @table @kbd @item l Run @samp{cvs log} on all selected files, and show the result in a -temporary buffer (@code{cvs-log}). +temporary buffer (@code{cvs-mode-log}). @item s Run @samp{cvs status} on all selected files, and show the result in a -temporary buffer (@code{cvs-status}). +temporary buffer (@code{cvs-mode-status}). @end table -@node Adding and removing files, Removing handled entries, Getting info about files, Commands +@node Adding and removing files, Undoing changes, Getting info about files, Commands @comment node-name, next, previous, up @section Adding and removing files @cindex Adding files @@ -1191,8 +1231,8 @@ temporary buffer (@code{cvs-status}). @cindex Putting files under CVS control @kindex a - add a file @kindex r - remove a file -@findex cvs-add -@findex cvs-remove-file +@findex cvs-mode-add +@findex cvs-mode-remove-file The following commands are available to make it easy to add and remove files from the CVS repository. @@ -1201,7 +1241,7 @@ files from the CVS repository. @item a Add all selected files. This command can be used on @samp{Unknown} files (see @pxref{File status}). The status of the file will change to -@samp{Added}, and you will have to use @kbd{c} (@samp{cvs-commit}, see +@samp{Added}, and you will have to use @kbd{c} (@samp{cvs-mode-commit}, see @pxref{Committing changes}) to really add the file to the repository.@refill @@ -1211,7 +1251,7 @@ them) to resurrect them. Selected files that are neither @samp{Unknown} nor @samp{Removed} will be ignored by this command. -The command that is run is @code{cvs-add}. +The command that is run is @code{cvs-mode-add}. @item r This command removes the selected files (after prompting for @@ -1219,13 +1259,29 @@ confirmation). The files are @samp{rm}ed from your directory and (unless the status was @samp{Unknown}; @pxref{File status}) they will also be @samp{cvs remove}d. If the files were @samp{Unknown} they will disappear from the buffer. Otherwise their status will change to -@samp{Removed}, and you must use @kbd{c} (@samp{cvs-commit}, +@samp{Removed}, and you must use @kbd{c} (@samp{cvs-mode-commit}, @pxref{Committing changes}) to commit the removal.@refill -The command that is run is @code{cvs-remove-file}. +The command that is run is @code{cvs-mode-remove-file}. +@end table + +@node Undoing changes, Removing handled entries, Adding and removing files, Commands +@comment node-name, next, previous, up +@section Undoing changes +@cindex Undo changes +@cindex Flush changes +@kindex U - undo changes +@findex cvs-mode-undo-local-changes + +@table @kbd +@item U +If you have modified a file, and for some reason decide that you don't +want to keep the changes, you can undo them with this command. It works +by removing your working copy of the file and then getting the latest +version from the repository (@code{cvs-mode-undo-local-changes}. @end table -@node Removing handled entries, Ignoring files, Adding and removing files, Commands +@node Removing handled entries, Ignoring files, Undoing changes, Commands @comment node-name, next, previous, up @section Removing handled entries @cindex Expunging uninteresting entries @@ -1235,8 +1291,9 @@ The command that is run is @code{cvs-remove-file}. @cindex Handled lines, removing them @kindex x - remove processed entries @kindex C-k - remove selected entries -@findex cvs-remove-handled -@findex cvs-acknowledge +@findex cvs-mode-remove-handled +@findex cvs-mode-acknowledge +@findex cvs-mode-ignore @table @kbd @item x @@ -1247,13 +1304,13 @@ are removed from the buffer. If a directory becomes empty the heading for that directory is also removed. This makes it easier to get an overview of what needs to be done. -The command is called @code{cvs-remove-handled}. If -@samp{cvs-auto-remove-handled} is set to non-@samp{nil} this will +The command is called @code{cvs-mode-remove-handled}. If +@samp{cvs-auto-remove-handled} is set to non-@code{nil} this will automatically be performed after every commit.@refill @item C-k -This command can be used for lines that @samp{cvs-remove-handled} would -not delete, but that you want to delete (@code{cvs-acknowledge}). +This command can be used for lines that @samp{cvs-mode-remove-handled} would +not delete, but that you want to delete (@code{cvs-mode-acknowledge}). @end table @node Ignoring files, Viewing differences, Removing handled entries, Commands @@ -1269,10 +1326,10 @@ the @file{.cvsignore} doesn't exist it will be created. The @file{.cvsignore} file should normally be added to the repository, but you could ignore it also if you like it better that way. -This runs @code{cvs-ignore}. +This runs @code{cvs-mode-ignore}. @end table -@node Viewing differences, , Ignoring files, Commands +@node Viewing differences, Emerge, Ignoring files, Commands @comment node-name, next, previous, up @section Viewing differences @cindex Diff @@ -1280,29 +1337,122 @@ This runs @code{cvs-ignore}. @cindex Viewing differences @kindex d - run @samp{cvs diff} @kindex b - diff backup file -@findex cvs-diff-cvs -@findex cvs-diff-backup +@findex cvs-mode-diff-cvs +@findex cvs-mode-diff-backup +@vindex cvs-diff-ignore-marks (variable) @table @kbd @item d Display a @samp{cvs diff} between the selected files and the RCS version that they are based on. @xref{Customization} describes how you can send -flags to @samp{cvs diff}. (The function that does the job is -@code{cvs-diff-cvs}).@refill +flags to @samp{cvs diff}. If @var{cvs-diff-ignore-marks} is set to a +non-@code{nil} value or if a prefix argument is given (but not both) any +marked files will not be considered to be selected. +(@code{cvs-mode-diff-cvs}).@refill @item b If CVS finds a conflict while merging two versions of a file (during a @samp{cvs update}, @pxref{Updating the directory}) it will save the original file in a file called @file{.#@var{FILE}.@var{VERSION}} where @var{FILE} is the name of the file, and @var{VERSION} is the RCS version -number that your file was based on. +number that your file was based on.@refill With the @kbd{b} command you can run a @samp{diff} on the files @file{.#@var{FILE}.@var{VERSION}} and @file{@var{FILE}}. You can get a context- or Unidiff by setting @samp{cvs-diff-flags} - @pxref{Customization}. This command only works on files that have -status @samp{Conflict} or @samp{Merged}. The name of the command is -@code{cvs-diff-backup}. @refill +status @samp{Conflict} or @samp{Merged}.@refill + +If @var{cvs-diff-ignore-marks} is set to a non-@code{nil} value or if a +prefix argument is given (but not both) any marked files will not be +considered to be selected. (@code{cvs-mode-diff-backup}).@refill +@end table + +@node Emerge, Reverting your buffers, Viewing differences, Commands +@comment node-name, next, previous, up +@section Running emerge +@cindex Emerge +@cindex Invoking emerge +@cindex Conflicts, resolving +@cindex Resolving conflicts +@kindex e - invoke @samp{emerge} +@findex cvs-mode-emerge + +@table @kbd +@item e +Invoke @samp{emerge} on one file. This command works slightly different +depending on the file status. + +@table @asis +@item @samp{Modified} +Run @samp{emerge-files} with your working file as file A, and the latest +revision in the repository as file B. + +@item @samp{Merged} +@itemx @samp{Conflict} +Run @samp{emerge-files-with-ancestor} with your working file (as it was +prior to your invocation of @samp{cvs-update}) as file A, the latest +revision in the repository as file B, and the revision that you based +your local modifications on as ancestor. +@end table + +@strong{Note:} CVS has already performed a merge. The resulting file is +not used in any way if you use this command. If you use the @kbd{q} +command inside @samp{emerge} (to successfully terminate the merge) the +file that CVS created will be overwritten. +@end table + +@node Reverting your buffers, Miscellaneous commands, Emerge, Commands +@comment node-name, next, previous, up +@section Reverting your buffers +@findex cvs-mode-revert-updated-buffers +@kindex R - revert buffers +@cindex Syncing buffers +@cindex Reverting buffers + +@table @kbd +@item R +If you are editing (or just viewing) a file in a buffer, and that file +is changed by CVS during a @samp{cvs-update}, all you have to do is type +@kbd{R} in the *cvs* buffer to read in the new versions of the +files.@refill + +All files that are @samp{Updated}, @samp{Merged} or in @samp{Conflict} +are reverted from the disk. Any other files are ignored. Only files +that you were already editing are read.@refill + +An error is signalled if you have modified the buffer since it was last +changed. (@code{cvs-mode-revert-updated-buffers}).@refill +@end table + +@node Miscellaneous commands, , Reverting your buffers, Commands +@comment node-name, next, previous, up +@section Miscellaneous commands +@findex cvs-byte-compile-files +@cindex Recompiling elisp files +@cindex Byte compilation +@cindex Getting rid of lock files +@cindex Lock files +@kindex q - bury the *cvs* buffer +@findex bury-buffer + +@table @kbd +@item M-x cvs-byte-compile-files +Byte compile all selected files that end in .el. + +@item M-x cvs-delete-lock +This command can be used in any buffer, and deletes the lock files that +the *cvs* buffer informs you about. You should normally never have to +use this command since CVS tries very carefully to always remove the +lock files itself. + +You can only use this command when a message in the *cvs* buffer tells +you so. You should wait a while before using this command in case +someone else is running a cvs command. + +@item q +Bury the *cvs* buffer. (@code{bury-buffer}). + @end table @node Customization, Future enhancements, Commands, Top @@ -1310,11 +1460,17 @@ status @samp{Conflict} or @samp{Merged}. The name of the command is @chapter Customization @vindex cvs-erase-input-buffer (variable) @vindex cvs-inhibit-copyright-message (variable) -@vindex cvs-cvs-diff-flags (variable) @vindex cvs-diff-flags (variable) +@vindex cvs-diff-ignore-marks (variable) @vindex cvs-log-flags (variable) @vindex cvs-status-flags (variable) @vindex cvs-auto-remove-handled (variable) +@vindex cvs-update-prog-output-skip-regexp (variable) +@vindex cvs-cvsroot (variable) +@vindex TMPDIR (environment variable) +@vindex cvs-auto-revert-after-commit (variable) +@vindex cvs-commit-buffer-require-final-newline (variable) +@vindex cvs-sort-ignore-file (variable) @cindex Inhibiting the Copyright message. @cindex Copyright message, getting rid of it @cindex Getting rid of the Copyright message. @@ -1324,14 +1480,24 @@ status @samp{Conflict} or @samp{Merged}. The name of the command is @cindex Context diff, how to get @cindex Unidiff, how to get @cindex Automatically remove handled files +@cindex -u option in modules file +@cindex Modules file (-u option) +@cindex Update program (-u option in modules file) +@cindex Reverting buffers after commit +@cindex Require final newline +@cindex Automatically inserting newline +@cindex Commit message, inserting newline +@cindex Sorting the .cvsignore file +@cindex .cvsignore file, sorting +@cindex Automatically sorting .cvsignore If you have an idea about any customization that would be handy but -isn't present in this list, please tell me! @xref{Reporting bugs and -ideas} for info on how to reach me.@refill +isn't present in this list, please tell me! @xref{Bugs} for info on how +to reach me.@refill @table @samp @item cvs-erase-input-buffer -If set to anything else than @samp{nil} the edit buffer will be erased +If set to anything else than @code{nil} the edit buffer will be erased before you write the log message (@pxref{Committing changes}). @item cvs-inhibit-copyright-message @@ -1340,71 +1506,180 @@ a while. Set this variable to @samp{t} if you want to get rid of it. (But don't set this to @samp{t} in the system defaults file - new users should see this message at least once). -@item cvs-cvs-diff-flags -A list of strings to pass as arguments to the @samp{cvs diff} program. -This is used by @samp{cvs-diff-cvs} (key @kbd{d}, @pxref{Viewing -differences}). If you prefer the Unidiff format you could add this line -to your @file{.emacs} file:@refill +@item cvs-diff-flags +A list of strings to pass as arguments to the @samp{cvs diff} and +@samp{diff} programs. This is used by @samp{cvs-mode-diff-cvs} and +@samp{cvs-mode-diff-backup} (key @kbd{b}, @pxref{Viewing differences}). If +you prefer the Unidiff format you could add this line to your +@file{.emacs} file:@refill @example -(setq cvs-cvs-diff-flags '("-u")) +(setq cvs-diff-flags '("-u")) @end example -@item cvs-diff-flags -Like @samp{cvs-cvs-diff-flags}, but passed to @samp{diff}. This is used -by @samp{cvs-diff-backup} (key @kbd{b}, @pxref{Viewing differences}). +@item cvs-diff-ignore-marks +If this variable is non-@code{nil} or if a prefix argument is given (but +not both) to @samp{cvs-mode-diff-cvs} or @samp{cvs-mode-diff-backup} +marked files are not considered selected. @item cvs-log-flags -List of strings to send to @samp{cvs log}. Used by @samp{cvs-log} (key -@kbd{l}, @pxref{Getting info about files}). +List of strings to send to @samp{cvs log}. Used by @samp{cvs-mode-log} +(key @kbd{l}, @pxref{Getting info about files}). @item cvs-status-flags -List of strings to send to @samp{cvs status}. Used by @samp{cvs-status} +List of strings to send to @samp{cvs status}. Used by @samp{cvs-mode-status} (key @kbd{s}, @pxref{Getting info about files}). @item cvs-auto-remove-handled -If this variable is set to any non-@samp{nil} value -@samp{cvs-remove-handled} will be called every time you check in files, -after the check-in is ready. @xref{Removing handled entries}.@refill +If this variable is set to any non-@code{nil} value +@samp{cvs-mode-remove-handled} will be called every time you check in +files, after the check-in is ready. @xref{Removing handled +entries}.@refill + +@item cvs-auto-revert-after-commit +If this variable is set to any non-@samp{nil} value any buffers you have +that visit a file that is committed will be automatically reverted. +This variable is default @samp{t}. @xref{Committing changes}.@refill + +@item cvs-update-prog-output-skip-regexp +The @samp{-u} flag in the @file{modules} file can be used to run a command +whenever a @samp{cvs update} is performed (see cvs(5)). This regexp +is used to search for the last line in that output. It is normally set +to @samp{"$"}. That setting is only correct if the command outputs +nothing. Note that pcl-cvs will get very confused if the command +outputs @emph{anything} to @samp{stderr}. + +@item cvs-cvsroot +This variable can be set to override @samp{CVSROOT}. It should be a +string. If it is set then everytime a cvs command is run it will be +called as @samp{cvs -d @var{cvs-cvsroot}@dots{}} This can be useful if +your site has several repositories. + +@item TMPDIR +Pcl-cvs uses this @emph{environment variable} to decide where to put the +temporary files it needs. It defaults to @file{/tmp} if it is not set. + +@item cvs-commit-buffer-require-final-newline +When you enter a log message in the @samp{*cvs-commit-message*} buffer +pcl-cvs will normally automatically insert a trailing newline, unless +there already is one. This behavior can be controlled via +@samp{cvs-commit-buffer-require-final-newline}. If it is @samp{t} (the +default behavior), a newline will always be appended. If it is +@samp{nil}, newlines will never be appended. Any other value causes +pcl-cvs to ask the user whenever there is no trailing newline in the +commit message buffer. + +@item cvs-sort-ignore-file +If this variable is set to any non-@samp{nil} value the +@file{.cvsignore} will always be sorted whenever you use +@samp{cvs-mode-ignore} to add a file to it. This option is on by +default. @end table -@node Future enhancements, Reporting bugs and ideas, Customization, Top +@node Future enhancements, Bugs, Customization, Top @comment node-name, next, previous, up @chapter Future enhancements @cindex Enhancements Pcl-cvs is still under development and needs a number of enhancements to -be called complete. Here is my current wish-list for future releases of -pcl-cvs: +be called complete. Below is my current wish-list for future releases +of pcl-cvs. Please, let me know which of these features you want most. +They are listed below in approximately the order that I currently think +I will implement them in. @itemize @bullet @item -Dired support. I have an experimental @file{dired-cvs.el} that works -together with CVS 1.2. Unfortunately I wrote it on top of a -non-standard @file{dired.el}, so it must be rewritten.@refill +Rewritten parser code. There are many situations where pcl-cvs will +fail to recognize the output from CVS. The situation could be greatly +increased. + +@item +@samp{cvs-status}. This will run @samp{cvs status} in a directory and +produce a buffer that looks pretty much like the current *cvs* buffer. +That buffer will include information for all version-controlled files. +(There will be a simple keystroke to remove all "uninteresting" files, +that is, files that are "Up-to-date"). In this new buffer you will be +able to update a file, commit a file, et c. The big win with this is +that you will be able to watch the differences between your current +working file and the head revision in the repository before you update +the file, and you can then choose to update it or let it wait for a +while longer. + +@item +Log mode. When this mode is finished you will be able to move around +(using @kbd{n} and @kbd{p}) between the revisions of a file, mark two of +them, and run a diff between them. You will be able to hide branches +(similar to the way you can hide sub-paragraphs in outline-mode) and do +merges between revisions. Other ideas about this are welcome. + +@item +The current model for marks in the *cvs* buffer seems to be confusing. +I am considering to use the VM model instead, where marks are normally +inactive. To activate the mark, you issue a command like +@samp{cvs-mode-next-command-uses-marks}. I might implement a flag so +that you can use either version. Feedback on this before I start coding +it is very welcome. @item It should be possible to run commands such as @samp{cvs log}, @samp{cvs status} and @samp{cvs commit} directly from a buffer containing a file, instead of having to @samp{cvs-update}. If the directory contains many files the @samp{cvs-update} can take quite some time, especially on a -slow machine. +slow machine. I planed to put these kind of commands on the prefix +@kbd{C-c C-v}, but that turned out to be used by for instance c++-mode. +If you have any suggestions for a better prefix key, please let me know. + +@item +Increased robustness. For instance, you can not currently press +@kbd{C-g} when you are entering the description of a file that you are +adding without confusing pcl-cvs. + +@item +Support for multiple active *cvs* buffers. + +@item +Dired support. I have an experimental @file{dired-cvs.el} that works +together with CVS 1.2. Unfortunately I wrote it on top of a +non-standard @file{dired.el}, so it must be rewritten.@refill + +@item +An ability to send user-supplied options to all the cvs commands. + +@item +Pcl-cvs is not at all clever about what it should do when @samp{cvs +update} runs a program (due to the @samp{-u} option in the +@file{modules} file --- see @samp{cvs(5)}). The current release uses a +regexp to search for the end. At the very least that regexp should be +configured for different modules. Tell me if you have any idea about +what is the right thing to do. In a perfect world the program should +also be allowed to print to @samp{stderr} without causing pcl-cvs to +crash. @end itemize If you miss something in this wish-list, let me know! I don't promise that I will write it, but I will at least try to coordinate the efforts -of making a good Emacs front end to CVS. See @xref{Reporting bugs and -ideas} for information about how to reach me.@refill +of making a good Emacs front end to CVS. See @xref{Bugs} for +information about how to reach me.@refill +So far, I have written most of pcl-cvs in my all-to-rare spare time. If +you want pcl-cvs to be developed faster you can write a contract with +Signum Support to do the extension. You can reach Signum Support by +email to @samp{info@@signum.se} or via mail to Signum Support AB, Box +2044, S-580 02 Linkoping, Sweden. Phone: +46 (0) 13 - 21 46 00. Fax: +46 +(0) 13 - 21 47 00. -@node Reporting bugs and ideas, Function and Variable Index, Future enhancements, Top +@node Bugs, Function and Variable Index, Future enhancements, Top @comment node-name, next, previous, up -@chapter Reporting bugs and ideas +@chapter Bugs (known and unknown) @cindex Reporting bugs and ideas @cindex Bugs, how to report them @cindex Author, how to reach @cindex Email to the author +@cindex Known bugs +@cindex Bugs, known +@cindex FAQ +@cindex Problems, list of common If you find a bug or misfeature, don't hesitate to tell me! Send email to @samp{ceder@@lysator.liu.se}. @@ -1413,8 +1688,40 @@ If you have ideas for improvements, or if you have written some extensions to this package, I would like to hear from you. I hope that you find this package useful! +Below is a partial list of currently known problems with pcl-cvs version +1.05. + +@table @asis +@item Commit causes Emacs to hang +Emacs waits for the @samp{cvs commit} command to finish before you can +do anything. If you start a background job from the loginfo file you +must take care that it closes @samp{stdout} and @samp{stderr} if you do +not want to wait for it. (You do that with @samp{background-command &>- +2&>- &} if you are starting @samp{background-command} from a +@samp{/bin/sh} shell script). + +Your emacs will also hang if there was a lock file in the repository. +In this case you can type @kbd{C-g} to get control over your emacs +again. + +@item Name clash in Emacs 19 +This is really a bug in Elib or the Emacs 19 distribution. Both Elib and +Emacs 19.6 through at least 19.10 contains a file named +@file{cookie.el}. One of the files will have to be renamed, and we are +currently negotiating about which of the files to rename. + +@item Commands while cvs-update is running +It is possible to type commands in the *cvs* buffer while the update is +running, but error messages is all that you will get. The error +messages should be better. + +@item Unexpected output from CVS +Unexpected output from CVS confuses pcl-cvs. It will currently create a +bug report that you can mail to me. It should do something more +civilized. +@end table -@node Function and Variable Index, Concept Index, Reporting bugs and ideas, Top +@node Function and Variable Index, Concept Index, Bugs, Top @comment node-name, next, previous, up @unnumbered Function and Variable Index diff --git a/gnu/usr.bin/cvs/contrib/rcs-to-cvs b/gnu/usr.bin/cvs/contrib/rcs-to-cvs index 1a241b9..5863ed8 100644 --- a/gnu/usr.bin/cvs/contrib/rcs-to-cvs +++ b/gnu/usr.bin/cvs/contrib/rcs-to-cvs @@ -1,208 +1,184 @@ -#!/bin/csh +#!/bin/sh # -# rcs-to-cvs,v 1.3 1992/04/10 03:04:25 berliner Exp -# Contributed by Per Cederqvist <ceder@lysator.liu.se>. +# $Id: rcs-to-cvs,v 1.4 1994/09/21 07:23:16 berliner Exp $ +# Based on the CVS 1.0 checkin csh script. +# Contributed by Per Cederqvist <ceder@signum.se>. +# Rewritten in sh by David MacKenzie <djm@cygnus.com>. # # Copyright (c) 1989, Brian Berliner # -# You may distribute under the terms of the GNU General Public License -# as specified in the README file that comes with the CVS 1.0 kit. +# You may distribute under the terms of the GNU General Public License. # ############################################################################# -# # -# This script is used to check in sources that previously was under RCS or # -# no source control system. # -# # -# Usage: rcs-to-cvs repository # -# # -# The repository is the directory where the sources should # -# be deposited. -# # -# checkin traverses the current directory, ensuring that an # -# identical directory structure exists in the repository directory. It # -# then checks the files in in the following manner: # -# # -# 1) If the file doesn't yet exist, check it in # -# as revision 0.1 # -# # -# The script also is somewhat verbose in letting the user know what is # -# going on. It prints a diagnostic when it creates a new file, or updates # -# a file that has been modified on the trunk. # -# # +# +# Check in sources that previously were under RCS or no source control system. +# +# The repository is the directory where the sources should be deposited. +# +# Traverses the current directory, ensuring that an +# identical directory structure exists in the repository directory. It +# then checks the files in in the following manner: +# +# 1) If the file doesn't yet exist, check it in as revision 1.1 +# +# The script also is somewhat verbose in letting the user know what is +# going on. It prints a diagnostic when it creates a new file, or updates +# a file that has been modified on the trunk. +# +# Bugs: doesn't put the files in branch 1.1.1 +# doesn't put in release and vendor tags +# ############################################################################# -set vbose = 0 -set message = "" -set cvsbin = /usr/gnu/bin -set rcsbin = /usr/gnu/bin -set grep = /bin/grep -set message_file = /usr/tmp/checkin.$$ -set got_one = 0 +usage="Usage: rcs-to-cvs [-v] [-m message] [-f message_file] repository" +vbose=0 +message="" +message_file=/usr/tmp/checkin.$$ +got_one=0 -if ( $#argv < 1 ) then - echo "Usage: rcs-to-cvs [-v] [-m message] [-f message_file] repository" +if [ $# -lt 1 ]; then + echo "$usage" >&2 exit 1 -endif -while ( $#argv ) - switch ( $argv[1] ) - case -v: - set vbose = 1 - breaksw - case -m: +fi + +while [ $# -ne 0 ]; do + case "$1" in + -v) + vbose=1 + ;; + -m) shift - echo $argv[1] > $message_file - set got_one = 1 - breaksw - case -f: + echo $1 > $message_file + got_one=1 + ;; + -f) shift - set message_file = $argv[1] - set got_one = 2 - breaksw - default: + message_file=$1 + got_one=2 + ;; + *) break - endsw + esac shift -end -if ( $#argv < 1 ) then - echo "Usage: rcs-to-cvs [-v] [-m message] [-f message_file] repository" +done + +if [ $# -lt 1 ]; then + echo "$usage" >&2 exit 1 -endif -set repository = $argv[1] +fi + +repository=$1 shift -if ( ! $?CVSROOT ) then - echo "Please set the environmental variable CVSROOT to the root" - echo " of the tree you wish to update" +if [ -z "$CVSROOT" ]; then + echo "Please the environmental variable CVSROOT to the root" >&2 + echo " of the tree you wish to update" >&2 exit 1 -endif +fi -if ( $got_one == 0 ) then +if [ $got_one -eq 0 ]; then echo "Please Edit this file to contain the RCS log information" >$message_file - echo "to be associated with this file (please remove these lines)">>$message_file - if ( $?EDITOR ) then - $EDITOR $message_file > /dev/tty - else - /usr/ucb/vi $message_file > /dev/tty - endif - set got_one = 1 -endif + echo "to be associated with this directory (please remove these lines)">>$message_file + ${EDITOR-/usr/ucb/vi} $message_file + got_one=1 +fi umask 22 -set update_dir = ${CVSROOT}/${repository} -if ( -d SCCS ) then - echo SCCS files detected! +update_dir=${CVSROOT}/${repository} +[ ! -d ${update_dir} ] && mkdir $update_dir + +if [ -d SCCS ]; then + echo SCCS files detected! >&2 exit 1 -endif -if ( -d RCS ) then - $rcsbin/co RCS/* >& /dev/null -endif -foreach name ( * .[a-zA-Z0-9]* ) +fi +if [ -d RCS ]; then + co RCS/* +fi + +for name in * .[a-zA-Z0-9]* +do + case "$name" in + RCS | \* | .\[a-zA-Z0-9\]\* ) continue ;; + esac echo $name - if ( "$name" == SCCS ) then - continue - endif - if ( "$name" == RCS ) then - continue - endif - if ( $vbose ) then + if [ $vbose -ne 0 ]; then echo "Updating ${repository}/${name}" - endif - if ( -d "$name" ) then - if ( ! -d "${update_dir}/${name}" ) then + fi + if [ -d "$name" ]; then + if [ ! -d "${update_dir}/${name}" ]; then echo "WARNING: Creating new directory ${repository}/${name}" mkdir "${update_dir}/${name}" - if ( $status ) then - echo "ERROR: mkdir failed - aborting" + if [ $? -ne 0 ]; then + echo "ERROR: mkdir failed - aborting" >&2 exit 1 - endif - endif - chdir "$name" - if ( $status ) then - echo "ERROR: Couldn\'t chdir to "$name" - aborting" + fi + fi + cd "$name" + if [ $? -ne 0 ]; then + echo "ERROR: Couldn\'t cd to $name - aborting" >&2 exit 1 - endif - if ( $vbose ) then - rcs-to-cvs -v -f $message_file "${repository}/${name}" + fi + if [ $vbose -ne 0 ]; then + $0 -v -f $message_file "${repository}/${name}" else - rcs-to-cvs -f $message_file "${repository}/${name}" - endif - if ( $status ) then + $0 -f $message_file "${repository}/${name}" + fi + if [ $? -ne 0 ]; then exit 1 - endif - chdir .. + fi + cd .. else # if not directory - if ( ! -f "$name" ) then - echo "WARNING: "$name" is neither a regular file" + if [ ! -f "$name" ]; then + echo "WARNING: $name is neither a regular file" echo " nor a directory - ignored" continue - endif - set file = "${update_dir}/${name},v" - set new = 0 - set comment = "" - grep -s '\$Log.*\$' "${name}" - if ( $status == 0 ) then # If $Log keyword - set myext = ${name:e} - set knownext = 0 - foreach xx ( "c" "csh" "e" "f" "h" "l" "mac" "me" "mm" "ms" "p" "r" "red" "s" "sh" "sl" "cl" "ml" "el" "tex" "y" "ye" "yr" "" ) - if ( "${myext}" == "${xx}" ) then - set knownext = 1 - break - endif - end - if ( $knownext == 0 ) then - echo For file ${file}: + fi + file="${update_dir}/${name},v" + comment="" + if grep -s '\$Log.*\$' "${name}"; then # If $Log keyword + myext=`echo $name | sed 's,.*\.,,'` + [ "$myext" = "$name" ] && myext= + case "$myext" in + c | csh | e | f | h | l | mac | me | mm | ms | p | r | red | s | sh | sl | cl | ml | el | tex | y | ye | yr | "" ) + ;; + + * ) + echo "For file ${file}:" grep '\$Log.*\$' "${name}" echo -n "Please insert a comment leader for file ${name} > " - set comment = $< - endif - endif - if ( ! -f "$file" ) then # If not exists in repository - if ( ! -f "${update_dir}/Attic/${name},v" ) then + read comment + ;; + esac + fi + if [ ! -f "$file" ]; then # If not exists in repository + if [ ! -f "${update_dir}/Attic/${name},v" ]; then echo "WARNING: Creating new file ${repository}/${name}" - if ( -f RCS/"${name}",v ) then + if [ -f RCS/"${name}",v ]; then echo "MSG: Copying old rcs file." cp RCS/"${name}",v "$file" else - if ( "${comment}" != "" ) then - $rcsbin/rcs -q -i -c"${comment}" -t${message_file} -m'.' "$file" - endif - $rcsbin/ci -q -u0.1 -t${message_file} -m'.' "$file" - if ( $status ) then - echo "ERROR: Initial check-in of $file failed - aborting" + if [ -n "${comment}" ]; then + rcs -q -i -c"${comment}" -t${message_file} -m'.' "$file" + fi + ci -q -u1.1 -t${message_file} -m'.' "$file" + if [ $? -ne 0 ]; then + echo "ERROR: Initial check-in of $file failed - aborting" >&2 exit 1 - endif - set new = 1 - endif + fi + fi else - set file = "${update_dir}/Attic/${name},v" + file="${update_dir}/Attic/${name},v" echo "WARNING: IGNORED: ${repository}/Attic/${name}" continue - endif + fi else # File existed - echo ERROR: File exists: Ignored: "$file" + echo "ERROR: File exists in repository: Ignored: $file" continue -# set headbranch = `sed -n '/^head/p; /^branch/p; 2q' $file` -# if ( $#headbranch != 2 && $#headbranch != 4 ) then -# echo "ERROR: corrupted RCS file $file - aborting" -# endif -# set head = "$headbranch[2]" -# set branch = "" -# if ( $#headbranch == 4 ) then -# set branch = "$headbranch[4]" -# endif -# if ( "$head" == "1.1;" && "$branch" != "1.1.1;" ) then -# ${rcsbin}/rcsdiff -q -r1.1 $file > /dev/null -# if ( ! $status ) then -# set new = 1 -# endif -# else -# if ( "$branch" != "1.1.1;" ) then -# echo -n "WARNING: Updating locally modified file " -# echo "${repository}/${name}" -# endif -# endif - endif - endif -end -if ( $got_one == 1 ) rm $message_file + fi + fi +done + +[ $got_one -eq 1 ] && rm -f $message_file + +exit 0 diff --git a/gnu/usr.bin/cvs/contrib/sccs2rcs b/gnu/usr.bin/cvs/contrib/sccs2rcs index a208645..654024b 100644 --- a/gnu/usr.bin/cvs/contrib/sccs2rcs +++ b/gnu/usr.bin/cvs/contrib/sccs2rcs @@ -43,7 +43,7 @@ # # Various hacks made by Brian Berliner before inclusion in CVS contrib area. # -# sccs2rcs,v 1.1 1992/04/10 03:04:26 berliner Exp +# $Id: sccs2rcs,v 1.1 1992/04/10 03:04:26 berliner Exp $ #we'll assume the user set up the path correctly diff --git a/gnu/usr.bin/cvs/cvs/add.c b/gnu/usr.bin/cvs/cvs/add.c index b4925bf..e14c79c 100644 --- a/gnu/usr.bin/cvs/cvs/add.c +++ b/gnu/usr.bin/cvs/cvs/add.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Add * @@ -27,17 +27,13 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)add.c 1.46 92/04/03"; +static char rcsid[] = "$CVSid: @(#)add.c 1.55 94/10/22 $"; +USE(rcsid) #endif -#if __STDC__ -static int add_directory (char *repository, char *dir); -static int build_entry (char *repository, char *user, char *options, - char *message, List * entries); -#else -static int add_directory (); -static int build_entry (); -#endif /* __STDC__ */ +static int add_directory PROTO((char *repository, char *dir)); +static int build_entry PROTO((char *repository, char *user, char *options, + char *message, List * entries, char *tag)); static char *add_usage[] = { @@ -52,7 +48,7 @@ add (argc, argv) int argc; char *argv[]; { - char message[MAXMESGLEN]; + char *message = NULL; char *user; int i; char *repository; @@ -67,9 +63,8 @@ add (argc, argv) usage (add_usage); /* parse args */ - message[0] = '\0'; optind = 1; - while ((c = gnu_getopt (argc, argv, "k:m:")) != -1) + while ((c = getopt (argc, argv, "k:m:")) != -1) { switch (c) { @@ -80,14 +75,7 @@ add (argc, argv) break; case 'm': - if (strlen (optarg) >= sizeof (message)) - { - error (0, 0, "warning: message too long; truncated!"); - (void) strncpy (message, optarg, sizeof (message)); - message[sizeof (message) - 1] = '\0'; - } - else - (void) strcpy (message, optarg); + message = xstrdup (optarg); break; case '?': default: @@ -111,7 +99,8 @@ add (argc, argv) int begin_err = err; user = argv[i]; - if (index (user, '/') != NULL) + strip_trailing_slashes (user); + if (strchr (user, '/') != NULL) { error (0, 0, "cannot add files with '/' in their name; %s not added", user); @@ -153,19 +142,18 @@ add (argc, argv) /* There is a user file, so build the entry for it */ if (build_entry (repository, user, vers->options, - message, entries) != 0) - err++; - else if (!quiet) + message, entries, vers->tag) != 0) + err++; + else { - added_files++; - error (0, 0, "scheduling file `%s' for addition", - user); + added_files++; + if (!quiet) + error (0, 0, "scheduling file `%s' for addition", user); } } } else { - /* * There is an RCS file already, so somebody else must've * added it @@ -214,7 +202,7 @@ add (argc, argv) (void) strcpy (vers->vn_user, tmp); (void) sprintf (tmp, "Resurrected %s", user); Register (entries, user, vers->vn_user, tmp, vers->options, - vers->tag, vers->date); + vers->tag, vers->date, vers->ts_conflict); free (tmp); /* XXX - bugs here; this really resurrect the head */ @@ -257,6 +245,10 @@ add (argc, argv) error (0, 0, "use 'cvs commit' to add %s permanently", (added_files == 1) ? "this file" : "these files"); dellist (&entries); + + if (message) + free (message); + return (err); } @@ -276,7 +268,7 @@ add_directory (repository, dir) char message[PATH_MAX + 100]; char *tag, *date; - if (index (dir, '/') != NULL) + if (strchr (dir, '/') != NULL) { error (0, 0, "directory %s not added; must be a direct sub-directory", dir); @@ -334,10 +326,12 @@ add_directory (repository, dir) if (!isdir (rcsdir)) { mode_t omask; - char line[MAXLINELEN]; Node *p; List *ulist; +#if 0 + char line[MAXLINELEN]; + (void) printf ("Add directory %s to the repository (y/n) [n] ? ", rcsdir); (void) fflush (stdout); @@ -348,6 +342,8 @@ add_directory (repository, dir) error (0, 0, "directory %s not added", rcsdir); goto out; } +#endif + omask = umask (2); if (mkdir (rcsdir, 0777) < 0) { @@ -389,12 +385,13 @@ out: * interrogating the user. Returns non-zero on error. */ static int -build_entry (repository, user, options, message, entries) +build_entry (repository, user, options, message, entries, tag) char *repository; char *user; char *options; char *message; List *entries; + char *tag; { char fname[PATH_MAX]; char line[MAXLINELEN]; @@ -418,6 +415,7 @@ build_entry (repository, user, options, message, entries) /* * The options for the "add" command are store in the file CVS/user,p + * XXX - no they are not! */ (void) sprintf (fname, "%s/%s%s", CVSADM, user, CVSEXT_OPT); fp = open_file (fname, "w+"); @@ -431,7 +429,7 @@ build_entry (repository, user, options, message, entries) */ (void) sprintf (fname, "%s/%s%s", CVSADM, user, CVSEXT_LOG); fp = open_file (fname, "w+"); - if (*message && fputs (message, fp) == EOF) + if (message && fputs (message, fp) == EOF) error (1, errno, "cannot write to %s", fname); if (fclose(fp) == EOF) error(1, errno, "cannot close %s", fname); @@ -442,6 +440,6 @@ build_entry (repository, user, options, message, entries) * and ,t files, but who cares). */ (void) sprintf (line, "Initial %s", user); - Register (entries, user, "0", line, options, (char *) 0, (char *) 0); + Register (entries, user, "0", line, options, tag, (char *) 0, (char *) 0); return (0); } diff --git a/gnu/usr.bin/cvs/cvs/admin.c b/gnu/usr.bin/cvs/cvs/admin.c index 91d3929..14a5b51 100644 --- a/gnu/usr.bin/cvs/cvs/admin.c +++ b/gnu/usr.bin/cvs/cvs/admin.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Administration * @@ -14,18 +14,14 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)admin.c 1.17 92/03/31"; +static char rcsid[] = "$CVSid: @(#)admin.c 1.20 94/09/30 $"; +USE(rcsid) #endif -#if __STDC__ -static Dtype admin_dirproc (char *dir, char *repos, char *update_dir); -static int admin_fileproc (char *file, char *update_dir, +static Dtype admin_dirproc PROTO((char *dir, char *repos, char *update_dir)); +static int admin_fileproc PROTO((char *file, char *update_dir, char *repository, List *entries, - List *srcfiles); -#else -static int admin_fileproc (); -static Dtype admin_dirproc (); -#endif /* __STDC__ */ + List *srcfiles)); static char *admin_usage[] = { @@ -60,7 +56,7 @@ admin (argc, argv) /* start the recursion processor */ err = start_recursion (admin_fileproc, (int (*) ()) NULL, admin_dirproc, (int (*) ()) NULL, argc, argv, 0, - W_LOCAL, 0, 1, (char *) NULL, 1); + W_LOCAL, 0, 1, (char *) NULL, 1, 0); return (err); } diff --git a/gnu/usr.bin/cvs/cvs/checkin.c b/gnu/usr.bin/cvs/cvs/checkin.c index 14f7c05..1f7691b 100644 --- a/gnu/usr.bin/cvs/cvs/checkin.c +++ b/gnu/usr.bin/cvs/cvs/checkin.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Check In * @@ -18,22 +18,25 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)checkin.c 1.40 92/03/31"; +static char rcsid[] = "$CVSid: @(#)checkin.c 1.48 94/10/07 $"; +USE(rcsid) #endif int -Checkin (type, file, repository, rcs, rev, tag, message, entries) +Checkin (type, file, repository, rcs, rev, tag, options, message, entries) int type; char *file; char *repository; char *rcs; char *rev; char *tag; + char *options; char *message; List *entries; { char fname[PATH_MAX]; Vers_TS *vers; + int set_time; (void) printf ("Checking in %s;\n", file); (void) sprintf (fname, "%s/%s%s", CVSADM, CVSPREFIX, file); @@ -48,7 +51,8 @@ Checkin (type, file, repository, rcs, rev, tag, message, entries) run_setup ("%s%s -f %s%s", Rcsbin, RCS_CI, rev ? "-r" : "", rev ? rev : ""); - run_args ("-m%s", message); + run_args ("-m%s", (*message == '\0' || strcmp(message, "\n") == 0) ? + "*** empty log message ***\n" : message); run_arg (rcs); switch (run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) @@ -64,16 +68,25 @@ Checkin (type, file, repository, rcs, rev, tag, message, entries) * original user file. */ - /* XXX - make sure -k options are used on the co; and tag/date? */ - run_setup ("%s%s -q %s%s", Rcsbin, RCS_CO, + if (strcmp (options, "-V4") == 0) /* upgrade to V5 now */ + options[0] = '\0'; + run_setup ("%s%s -q %s %s%s", Rcsbin, RCS_CO, options, rev ? "-r" : "", rev ? rev : ""); run_arg (rcs); (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL); xchmod (file, 1); if (xcmp (file, fname) == 0) + { rename_file (fname, file); + /* the time was correct, so leave it alone */ + set_time = 0; + } else + { (void) unlink_file (fname); + /* sync up with the time from the RCS file */ + set_time = 1; + } /* * If we want read-only files, muck the permissions here, before @@ -92,11 +105,11 @@ Checkin (type, file, repository, rcs, rev, tag, message, entries) /* re-register with the new data */ vers = Version_TS (repository, (char *) NULL, tag, (char *) NULL, - file, 1, 1, entries, (List *) NULL); + file, 1, set_time, entries, (List *) NULL); if (strcmp (vers->options, "-V4") == 0) vers->options[0] = '\0'; - Register (entries, file, vers->vn_rcs, vers->ts_user, vers->options, - vers->tag, vers->date); + Register (entries, file, vers->vn_rcs, vers->ts_user, + vers->options, vers->tag, vers->date, (char *) 0); history_write (type, (char *) 0, vers->vn_rcs, file, repository); freevers_ts (&vers); break; @@ -131,5 +144,6 @@ Checkin (type, file, repository, rcs, rev, tag, message, entries) run_arg (rcs); (void) run_exec (RUN_TTY, RUN_TTY, DEVNULL, RUN_NORMAL); } + return (0); } diff --git a/gnu/usr.bin/cvs/cvs/checkout.c b/gnu/usr.bin/cvs/cvs/checkout.c index ad5a5b8..a5a79ad 100644 --- a/gnu/usr.bin/cvs/cvs/checkout.c +++ b/gnu/usr.bin/cvs/cvs/checkout.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Create Version * @@ -36,22 +36,17 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)checkout.c 1.67 92/04/10"; +static char rcsid[] = "$CVSid: @(#)checkout.c 1.78 94/10/07 $"; +USE(rcsid) #endif -#if __STDC__ -static char *findslash (char *start, char *p); -static int build_dirs_and_chdir (char *dir, char *prepath, char *realdir, - int sticky); -static int checkout_proc (int *pargc, char *argv[], char *where, +static char *findslash PROTO((char *start, char *p)); +static int build_dirs_and_chdir PROTO((char *dir, char *prepath, char *realdir, + int sticky)); +static int checkout_proc PROTO((int *pargc, char *argv[], char *where, char *mwhere, char *mfile, int shorten, int local_specified, char *omodule, - char *msg); -#else -static int checkout_proc (); -static char *findslash (); -static int build_dirs_and_chdir (); -#endif /* __STDC__ */ + char *msg)); static char *checkout_usage[] = { @@ -84,8 +79,8 @@ static char *export_usage[] = "\t-l\tLocal directory only, not recursive\n", "\t-n\tDo not run module program (if any).\n", "\t-q\tSomewhat quiet.\n", - "\t-r rev\tCheck out revision or tag. (implies -P)\n", - "\t-D date\tCheck out revisions as of date. (implies -P)\n", + "\t-r rev\tCheck out revision or tag.\n", + "\t-D date\tCheck out revisions as of date.\n", "\t-d dir\tCheck out into dir instead of module name.\n", NULL }; @@ -106,7 +101,7 @@ checkout (argc, argv) int argc; char *argv[]; { - register int i; + int i; int c; DBM *db; int cat = 0, err = 0, status = 0; @@ -139,7 +134,7 @@ checkout (argc, argv) ign_setup (); optind = 1; - while ((c = gnu_getopt (argc, argv, valid_options)) != -1) + while ((c = getopt (argc, argv, valid_options)) != -1) { switch (c) { @@ -261,9 +256,15 @@ checkout (argc, argv) where = (char *) NULL; if (!isfile (CVSADM) && !isfile (OCVSADM)) { - (void) sprintf (repository, "%s/%s", CVSroot, CVSNULLREPOS); + (void) sprintf (repository, "%s/%s/%s", CVSroot, CVSROOTADM, + CVSNULLREPOS); if (!isfile (repository)) (void) mkdir (repository, 0777); + + /* I'm not sure whether this check is redundant. */ + if (!isdir (repository)) + error (1, 0, "there is no repository %s", repository); + Create_Admin (".", repository, (char *) NULL, (char *) NULL); if (!noexec) { @@ -283,11 +284,11 @@ checkout (argc, argv) * attempt to cd to the indicated place. where then becomes simply the * last component */ - if (where != NULL && index (where, '/') != NULL) + if (where != NULL && strchr (where, '/') != NULL) { char *slash; - slash = rindex (where, '/'); + slash = strrchr (where, '/'); *slash = '\0'; if (chdir (where) < 0) @@ -358,7 +359,7 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten, char file[PATH_MAX]; /* if mfile is really a path, straighten it out first */ - if ((cp = rindex (mfile, '/')) != NULL) + if ((cp = strrchr (mfile, '/')) != NULL) { *cp = 0; (void) strcat (repository, "/"); @@ -386,7 +387,7 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten, { char *slash; - if ((slash = rindex (mfile, '/')) != NULL) + if ((slash = strrchr (mfile, '/')) != NULL) mwhere = slash + 1; else mwhere = mfile; @@ -448,7 +449,7 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten, */ if (shorten && where == NULL) { - if ((cp = rindex (argv[0], '/')) != NULL) + if ((cp = strrchr (argv[0], '/')) != NULL) { (void) strcpy (xwhere, cp + 1); where = xwhere; @@ -498,8 +499,8 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten, * elements exist in where. Big Black Magic */ prepath = xstrdup (repository); - cp = rindex (where, '/'); - cp2 = rindex (prepath, '/'); + cp = strrchr (where, '/'); + cp2 = strrchr (prepath, '/'); while (cp != NULL) { cp = findslash (where, cp - 1); @@ -533,13 +534,23 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten, if (!noexec && *pargc > 1) { + /* I'm not sure whether this check is redundant. */ + if (!isdir (repository)) + error (1, 0, "there is no repository %s", repository); + Create_Admin (".", repository, (char *) NULL, (char *) NULL); fp = open_file (CVSADM_ENTSTAT, "w+"); if (fclose(fp) == EOF) error(1, errno, "cannot close %s", CVSADM_ENTSTAT); } else + { + /* I'm not sure whether this check is redundant. */ + if (!isdir (repository)) + error (1, 0, "there is no repository %s", repository); + Create_Admin (".", repository, tag, date); + } } else { @@ -622,8 +633,9 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten, if (vers->ts_user == NULL) { (void) sprintf (line, "Initial %s", user); - Register (entries, user, vers->vn_rcs, line, vers->options, - vers->tag, vers->date); + Register (entries, user, vers->vn_rcs ? vers->vn_rcs : "0", + line, vers->options, vers->tag, + vers->date, (char *) 0); } freevers_ts (&vers); } @@ -650,9 +662,9 @@ findslash (start, p) char *start; char *p; { - while ((int) p >= (int) start && *p != '/') + while (p >= start && *p != '/') p--; - if ((int) p < (int) start) + if (p < start) return (NULL); else return (p); @@ -681,7 +693,7 @@ build_dirs_and_chdir (dir, prepath, realdir, sticky) (void) strcpy (path, dir); (void) strcpy (path2, realdir); for (cp = path, cp2 = path2; - (slash = index (cp, '/')) != NULL && (slash2 = index (cp2, '/')) != NULL; + (slash = strchr (cp, '/')) != NULL && (slash2 = strchr (cp2, '/')) != NULL; cp = slash + 1, cp2 = slash2 + 1) { *slash = '\0'; @@ -696,6 +708,9 @@ build_dirs_and_chdir (dir, prepath, realdir, sticky) strcmp (command_name, "export") != 0) { (void) sprintf (repository, "%s/%s", prepath, path2); + /* I'm not sure whether this check is redundant. */ + if (!isdir (repository)) + error (1, 0, "there is no repository %s", repository); Create_Admin (".", repository, sticky ? (char *) NULL : tag, sticky ? (char *) NULL : date); if (!noexec) diff --git a/gnu/usr.bin/cvs/cvs/classify.c b/gnu/usr.bin/cvs/cvs/classify.c index 318fab8..ff9305d 100644 --- a/gnu/usr.bin/cvs/cvs/classify.c +++ b/gnu/usr.bin/cvs/cvs/classify.c @@ -3,28 +3,25 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * */ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)classify.c 1.11 92/03/31"; +static char rcsid[] = "$CVSid: @(#)classify.c 1.17 94/10/07 $"; +USE(rcsid) #endif -#if __STDC__ -static void sticky_ck (char *file, int aflag, Vers_TS * vers, List * entries); -#else -static void sticky_ck (); -#endif /* __STDC__ */ +static void sticky_ck PROTO((char *file, int aflag, Vers_TS * vers, List * entries)); /* * Classify the state of a file */ Ctype Classify_File (file, tag, date, options, force_tag_match, aflag, repository, - entries, srcfiles, versp) + entries, srcfiles, versp, update_dir, pipeout) char *file; char *tag; char *date; @@ -35,9 +32,18 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, List *entries; List *srcfiles; Vers_TS **versp; + char *update_dir; + int pipeout; { Vers_TS *vers; Ctype ret; + char *fullname; + + fullname = xmalloc (strlen (update_dir) + strlen (file) + 10); + if (update_dir[0] == '\0') + strcpy (fullname, file); + else + sprintf (fullname, "%s/%s", update_dir, file); /* get all kinds of good data about the file */ vers = Version_TS (repository, options, tag, date, file, @@ -54,7 +60,7 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, /* there is no user file */ if (!force_tag_match || !(vers->tag || vers->date)) if (!really_quiet) - error (0, 0, "nothing known about %s", file); + error (0, 0, "nothing known about %s", fullname); ret = T_UNKNOWN; } else @@ -63,7 +69,7 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, if (!force_tag_match || !(vers->tag || vers->date)) if (!really_quiet) error (0, 0, "use `cvs add' to create an entry for %s", - file); + fullname); ret = T_UNKNOWN; } } @@ -78,16 +84,26 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, } else { + if (pipeout) + { + /* + * The user file doesn't necessarily have anything + * to do with this. + */ + ret = T_CHECKOUT; + } /* * There is a user file; print a warning and add it to the * conflict list, only if it is indeed different from what we * plan to extract */ - if (No_Difference (file, vers, entries)) + else if (No_Difference (file, vers, entries, + repository, update_dir)) { /* the files were different so it is a conflict */ if (!really_quiet) - error (0, 0, "move away %s; it is in the way", file); + error (0, 0, "move away %s; it is in the way", + fullname); ret = T_CONFLICT; } else @@ -107,7 +123,7 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, * entry */ if (!really_quiet) - error (0, 0, "warning: new-born %s has disappeared", file); + error (0, 0, "warning: new-born %s has disappeared", fullname); ret = T_REMOVE_ENTRY; } else @@ -126,7 +142,7 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, if (!really_quiet) error (0, 0, "conflict: %s created independently by second party", - file); + fullname); ret = T_CONFLICT; } } @@ -169,7 +185,7 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, if (!really_quiet) error (0, 0, "conflict: removed %s was modified by second party", - file); + fullname); ret = T_CONFLICT; } } @@ -177,7 +193,8 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, { /* The user file shouldn't be there */ if (!really_quiet) - error (0, 0, "%s should be removed and is still there", file); + error (0, 0, "%s should be removed and is still there", + fullname); ret = T_REMOVED; } } @@ -193,7 +210,7 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, /* There is no user file, so just remove the entry */ if (!really_quiet) error (0, 0, "warning: %s is not (any longer) pertinent", - file); + fullname); ret = T_REMOVE_ENTRY; } else if (strcmp (vers->ts_user, vers->ts_rcs) == 0) @@ -204,7 +221,8 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, * the entry list */ if (!really_quiet) - error (0, 0, "%s is no longer in the repository", file); + error (0, 0, "%s is no longer in the repository", + fullname); ret = T_REMOVE_ENTRY; } else @@ -213,13 +231,14 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, * The user file has been modified and since it is no longer * in the repository, a conflict is raised */ - if (No_Difference (file, vers, entries)) + if (No_Difference (file, vers, entries, + repository, update_dir)) { /* they are different -> conflict */ if (!really_quiet) error (0, 0, "conflict: %s is modified but no longer in the repository", - file); + fullname); ret = T_CONFLICT; } else @@ -228,7 +247,7 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, if (!really_quiet) error (0, 0, "warning: %s is not (any longer) pertinent", - file); + fullname); ret = T_REMOVE_ENTRY; } } @@ -246,7 +265,7 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, */ if (strcmp (command_name, "update") == 0) if (!really_quiet) - error (0, 0, "warning: %s was lost", file); + error (0, 0, "warning: %s was lost", fullname); ret = T_CHECKOUT; } else if (strcmp (vers->ts_user, vers->ts_rcs) == 0) @@ -274,7 +293,8 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, * The user file appears to have been modified, but we call * No_Difference to verify that it really has been modified */ - if (No_Difference (file, vers, entries)) + if (No_Difference (file, vers, entries, + repository, update_dir)) { /* @@ -323,7 +343,7 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, if (strcmp (command_name, "update") == 0) if (!really_quiet) - error (0, 0, "warning: %s was lost", file); + error (0, 0, "warning: %s was lost", fullname); ret = T_CHECKOUT; } else if (strcmp (vers->ts_user, vers->ts_rcs) == 0) @@ -336,7 +356,8 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, } else { - if (No_Difference (file, vers, entries)) + if (No_Difference (file, vers, entries, + repository, update_dir)) /* really modified, needs to merge */ ret = T_NEEDS_MERGE; else @@ -352,6 +373,8 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository, else freevers_ts (&vers); + free (fullname); + /* return the status of the file */ return (ret); } @@ -374,7 +397,7 @@ sticky_ck (file, aflag, vers, entries) ((entdate && !vers->date) || (!entdate && vers->date))) { Register (entries, file, vers->vn_user, vers->ts_rcs, - vers->options, vers->tag, vers->date); + vers->options, vers->tag, vers->date, vers->ts_conflict); } } } diff --git a/gnu/usr.bin/cvs/cvs/commit.c b/gnu/usr.bin/cvs/cvs/commit.c index 1b2f3be..cb36e9f 100644 --- a/gnu/usr.bin/cvs/cvs/commit.c +++ b/gnu/usr.bin/cvs/cvs/commit.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Commit Files * @@ -17,68 +17,46 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)commit.c 1.84 92/03/31"; +static char rcsid[] = "$CVSid: @(#)commit.c 1.101 94/10/07 $"; +USE(rcsid) #endif -#if __STDC__ -static Dtype check_direntproc (char *dir, char *repos, char *update_dir); -static int check_fileproc (char *file, char *update_dir, char *repository, - List * entries, List * srcfiles); -static int check_filesdoneproc (int err, char *repos, char *update_dir); -static int checkaddfile (char *file, char *repository, char *tag); -static Dtype commit_direntproc (char *dir, char *repos, char *update_dir); -static int commit_dirleaveproc (char *dir, int err, char *update_dir); -static int commit_fileproc (char *file, char *update_dir, char *repository, - List * entries, List * srcfiles); -static int commit_filesdoneproc (int err, char *repository, char *update_dir); -static int finaladd (char *file, char *revision, char *tag, char *repository, - List *entries); -static int findmaxrev (Node * p); -static int fsortcmp (Node * p, Node * q); -static int lock_RCS (char *user, char *rcs, char *rev, char *repository); -static int lock_filesdoneproc (int err, char *repository, char *update_dir); -static int lockrcsfile (char *file, char *repository, char *rev); -static int precommit_list_proc (Node * p); -static int precommit_proc (char *repository, char *filter); -static int remove_file (char *file, char *repository, char *tag, - List *entries); -static void fix_rcs_modes (char *rcs, char *user); -static void fixaddfile (char *file, char *repository); -static void fixbranch (char *file, char *repository, char *branch); -static void unlockrcs (char *file, char *repository); -static void ci_delproc (Node *p); -static void locate_rcs (char *file, char *repository, char *rcs); -#else -static int fsortcmp (); -static int lock_filesdoneproc (); -static int check_fileproc (); -static Dtype check_direntproc (); -static int precommit_list_proc (); -static int precommit_proc (); -static int check_filesdoneproc (); -static int commit_fileproc (); -static int commit_filesdoneproc (); -static Dtype commit_direntproc (); -static int commit_dirleaveproc (); -static int findmaxrev (); -static int remove_file (); -static int finaladd (); -static void unlockrcs (); -static void fixaddfile (); -static void fixbranch (); -static int checkaddfile (); -static int lockrcsfile (); -static int lock_RCS (); -static void fix_rcs_modes (); -static void ci_delproc (); -static void locate_rcs (); -#endif /* __STDC__ */ +static Dtype check_direntproc PROTO((char *dir, char *repos, char *update_dir)); +static int check_fileproc PROTO((char *file, char *update_dir, char *repository, + List * entries, List * srcfiles)); +static int check_filesdoneproc PROTO((int err, char *repos, char *update_dir)); +static int checkaddfile PROTO((char *file, char *repository, char *tag, + List *srcfiles)); +static Dtype commit_direntproc PROTO((char *dir, char *repos, char *update_dir)); +static int commit_dirleaveproc PROTO((char *dir, int err, char *update_dir)); +static int commit_fileproc PROTO((char *file, char *update_dir, char *repository, + List * entries, List * srcfiles)); +static int commit_filesdoneproc PROTO((int err, char *repository, char *update_dir)); +static int finaladd PROTO((char *file, char *revision, char *tag, char *options, + char *repository, List *entries)); +static int findmaxrev PROTO((Node * p, void *closure)); +static int fsortcmp PROTO((Node * p, Node * q)); +static int lock_RCS PROTO((char *user, char *rcs, char *rev, char *repository)); +static int lock_filesdoneproc PROTO((int err, char *repository, char *update_dir)); +static int lockrcsfile PROTO((char *file, char *repository, char *rev)); +static int precommit_list_proc PROTO((Node * p, void *closure)); +static int precommit_proc PROTO((char *repository, char *filter)); +static int remove_file PROTO((char *file, char *repository, char *tag, + char *message, List *entries, List *srcfiles)); +static void fix_rcs_modes PROTO((char *rcs, char *user)); +static void fixaddfile PROTO((char *file, char *repository)); +static void fixbranch PROTO((char *file, char *repository, char *branch)); +static void unlockrcs PROTO((char *file, char *repository)); +static void ci_delproc PROTO((Node *p)); +static void masterlist_delproc PROTO((Node *p)); +static void locate_rcs PROTO((char *file, char *repository, char *rcs)); struct commit_info { Ctype status; /* as returned from Classify_File() */ char *rev; /* a numeric rev, if we know it */ char *tag; /* any sticky tag, or -r option */ + char *options; /* Any sticky -k option */ }; struct master_lists { @@ -86,6 +64,7 @@ struct master_lists List *cilist; /* list with commit_info structs */ }; +static int force_ci; static int got_message; static int run_module_prog = 1; static int aflag; @@ -98,11 +77,12 @@ static char *message; static char *commit_usage[] = { - "Usage: %s %s [-nRl] [-m msg | -f logfile] [-r rev] files...\n", + "Usage: %s %s [-nRlf] [-m msg | -F logfile] [-r rev] files...\n", "\t-n\tDo not run the module program (if any).\n", "\t-R\tProcess directories recursively.\n", "\t-l\tLocal directory only (not recursive).\n", - "\t-f file\tRead the log message from file.\n", + "\t-f\tForce the file to be committed; disables recursion.\n", + "\t-F file\tRead the log message from file.\n", "\t-m msg\tLog message.\n", "\t-r rev\tCommit to this branch or trunk revision.\n", NULL @@ -136,10 +116,8 @@ commit (argc, argv) } #endif /* CVS_BADROOT */ - message = xmalloc (MAXMESGLEN + 1); - message[0] = '\0'; /* Null message by default */ optind = 1; - while ((c = gnu_getopt (argc, argv, "nlRm:f:r:")) != -1) + while ((c = getopt (argc, argv, "nlRm:fF:r:")) != -1) { switch (c) { @@ -152,14 +130,13 @@ commit (argc, argv) #else use_editor = FALSE; #endif - if (strlen (optarg) >= (size_t) MAXMESGLEN) + if (message) { - error (0, 0, "warning: message too long; truncated!"); - (void) strncpy (message, optarg, MAXMESGLEN); - message[MAXMESGLEN] = '\0'; + free (message); + message = NULL; } - else - (void) strcpy (message, optarg); + + message = xstrdup(optarg); break; case 'r': if (tag) @@ -173,6 +150,10 @@ commit (argc, argv) local = 0; break; case 'f': + force_ci = 1; + local = 1; /* also disable recursion */ + break; + case 'F': #ifdef FORCE_USE_EDITOR use_editor = TRUE; #else @@ -198,19 +179,26 @@ commit (argc, argv) tag[strlen (tag) - 1] = '\0'; } - /* some checks related to the "-f logfile" option */ + /* some checks related to the "-F logfile" option */ if (logfile) { int n, logfd; + struct stat statbuf; - if (*message) + if (message) error (1, 0, "cannot specify both a message and a log file"); - if ((logfd = open (logfile, O_RDONLY)) < 0 || - (n = read (logfd, message, MAXMESGLEN)) < 0) - { + if ((logfd = open (logfile, O_RDONLY)) < 0) + error (1, errno, "cannot open log file %s", logfile); + + if (fstat(logfd, &statbuf) < 0) + error (1, errno, "cannot find size of log file %s", logfile); + + message = xmalloc (statbuf.st_size + 1); + + if ((n = read (logfd, message, statbuf.st_size + 1)) < 0) error (1, errno, "cannot read log message from %s", logfile); - } + (void) close (logfd); message[n] = '\0'; } @@ -226,7 +214,8 @@ commit (argc, argv) locklist = getlist (); err = start_recursion ((int (*) ()) NULL, lock_filesdoneproc, (Dtype (*) ()) NULL, (int (*) ()) NULL, argc, - argv, local, W_LOCAL, aflag, 0, (char *) NULL, 0); + argv, local, W_LOCAL, aflag, 0, (char *) NULL, 0, + 0); sortlist (locklist, fsortcmp); if (Writer_Lock (locklist) != 0) error (1, 0, "lock failed - giving up"); @@ -241,7 +230,8 @@ commit (argc, argv) */ err = start_recursion (check_fileproc, check_filesdoneproc, check_direntproc, (int (*) ()) NULL, argc, - argv, local, W_LOCAL, aflag, 0, (char *) NULL, 1); + argv, local, W_LOCAL, aflag, 0, (char *) NULL, 1, + 0); if (err) { Lock_Cleanup (); @@ -255,7 +245,7 @@ commit (argc, argv) err = start_recursion (commit_fileproc, commit_filesdoneproc, commit_direntproc, commit_dirleaveproc, argc, argv, local, W_LOCAL, aflag, 0, - (char *) NULL, 1); + (char *) NULL, 1, 0); /* * Unlock all the dirs and clean up @@ -291,6 +281,7 @@ lock_filesdoneproc (err, repository, update_dir) p = getnode (); p->type = LOCK; p->key = xstrdup (repository); + /* FIXME-KRP: this error condition should not simply be passed by. */ if (p->key == NULL || addnode (locklist, p) != 0) freenode (p); return (err); @@ -330,15 +321,23 @@ check_fileproc (file, update_dir, repository, entries, srcfiles) { status = Classify_File (file, (char *) NULL, (char *) NULL, (char *) NULL, 1, aflag, repository, - entries, srcfiles, &vers); - if (status == T_UPTODATE) + entries, srcfiles, &vers, update_dir, 0); + if (status == T_UPTODATE || status == T_MODIFIED || + status == T_ADDED) { + Ctype xstatus; + freevers_ts (&vers); - status = Classify_File (file, tag, (char *) NULL, - (char *) NULL, 1, aflag, repository, - entries, srcfiles, &vers); - if (status == T_REMOVE_ENTRY) + xstatus = Classify_File (file, tag, (char *) NULL, + (char *) NULL, 1, aflag, repository, + entries, srcfiles, &vers, update_dir, + 0); + if (xstatus == T_REMOVE_ENTRY) status = T_MODIFIED; + else if (status == T_MODIFIED && xstatus == T_CONFLICT) + status = T_MODIFIED; + else + status = xstatus; } } else @@ -352,21 +351,22 @@ check_fileproc (file, update_dir, repository, entries, srcfiles) xtag = xstrdup (tag); if ((numdots (xtag) & 1) != 0) { - cp = rindex (xtag, '.'); + cp = strrchr (xtag, '.'); *cp = '\0'; } status = Classify_File (file, xtag, (char *) NULL, (char *) NULL, 1, aflag, repository, - entries, srcfiles, &vers); + entries, srcfiles, &vers, update_dir, 0); if ((status == T_REMOVE_ENTRY || status == T_CONFLICT) - && (cp = rindex (xtag, '.')) != NULL) + && (cp = strrchr (xtag, '.')) != NULL) { /* pluck one more dot off the revision */ *cp = '\0'; freevers_ts (&vers); status = Classify_File (file, xtag, (char *) NULL, (char *) NULL, 1, aflag, repository, - entries, srcfiles, &vers); + entries, srcfiles, &vers, update_dir, + 0); if (status == T_UPTODATE || status == T_REMOVE_ENTRY) status = T_MODIFIED; } @@ -378,17 +378,30 @@ check_fileproc (file, update_dir, repository, entries, srcfiles) } else status = Classify_File (file, tag, (char *) NULL, (char *) NULL, - 1, 0, repository, entries, srcfiles, &vers); + 1, 0, repository, entries, srcfiles, &vers, + update_dir, 0); noexec = save_noexec; quiet = save_quiet; really_quiet = save_really_quiet; + /* + * If the force-commit option is enabled, and the file in question + * appears to be up-to-date, just make it look modified so that + * it will be committed. + */ + if (force_ci && status == T_UPTODATE) + status = T_MODIFIED; + switch (status) { case T_CHECKOUT: case T_NEEDS_MERGE: case T_CONFLICT: - case T_REMOVE_ENTRY: + if (update_dir[0] == '\0') + error (0, 0, "Up-to-date check failed for `%s'", file); + else + error (0, 0, "Up-to-date check failed for `%s/%s'", + update_dir, file); error (0, 0, "Up-to-date check failed for `%s'", file); freevers_ts (&vers); return (1); @@ -403,32 +416,115 @@ check_fileproc (file, update_dir, repository, entries, srcfiles) * - if status is T_REMOVED, can't have a numeric tag * - if status is T_ADDED, rcs file must not exist * - if status is T_ADDED, can't have a non-trunk numeric rev + * - if status is T_MODIFIED and a Conflict marker exists, don't + * allow the commit if timestamp is identical or if we find + * an RCS_MERGE_PAT in the file. */ if (!tag || !isdigit (*tag)) { if (vers->date) { - error (0, 0, - "cannot commit with sticky date for file `%s'", - file); + if (update_dir[0] == '\0') + error (0, 0, + "cannot commit with sticky date for file `%s'", + file); + else + error + (0, 0, + "cannot commit with sticky date for file `%s/%s'", + update_dir, file); freevers_ts (&vers); return (1); } if (status == T_MODIFIED && vers->tag && !RCS_isbranch (file, vers->tag, srcfiles)) { - error (0, 0, - "sticky tag `%s' for file `%s' is not a branch", - vers->tag, file); + if (update_dir[0] == '\0') + error (0, 0, + "sticky tag `%s' for file `%s' is not a branch", + vers->tag, file); + else + error + (0, 0, + "sticky tag `%s' for file `%s/%s' is not a branch", + vers->tag, update_dir, file); freevers_ts (&vers); return (1); } } + if (status == T_MODIFIED && !force_ci && vers->ts_conflict) + { + char *filestamp; + int retcode; + + /* + * We found a "conflict" marker. + * + * If the timestamp on the file is the same as the + * timestamp stored in the Entries file, we block the commit. + */ + filestamp = time_stamp (file); + retcode = strcmp (vers->ts_conflict, filestamp); + free (filestamp); + if (retcode == 0) + { + if (update_dir[0] == '\0') + error (0, 0, + "file `%s' had a conflict and has not been modified", + file); + else + error (0, 0, + "file `%s/%s' had a conflict and has not been modified", + update_dir, file); + freevers_ts (&vers); + return (1); + } + + /* + * If the timestamps differ, look for Conflict indicators + * in the file to see if we should block the commit anyway + */ + run_setup ("%s -s", GREP); + run_arg (RCS_MERGE_PAT); + run_arg (file); + retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL); + + if (retcode == -1) + { + if (update_dir[0] == '\0') + error (1, errno, + "fork failed while examining conflict in `%s'", + file); + else + error (1, errno, + "fork failed while examining conflict in `%s/%s'", + update_dir, file); + } + else if (retcode == 0) + { + if (update_dir[0] == '\0') + error (0, 0, + "file `%s' still contains conflict indicators", + file); + else + error (0, 0, + "file `%s/%s' still contains conflict indicators", + update_dir, file); + freevers_ts (&vers); + return (1); + } + } + if (status == T_REMOVED && vers->tag && isdigit (*vers->tag)) { - error (0, 0, + if (update_dir[0] == '\0') + error (0, 0, "cannot remove file `%s' which has a numeric sticky tag of `%s'", - file, vers->tag); + file, vers->tag); + else + error (0, 0, + "cannot remove file `%s/%s' which has a numeric sticky tag of `%s'", + update_dir, file, vers->tag); freevers_ts (&vers); return (1); } @@ -439,18 +535,28 @@ check_fileproc (file, update_dir, repository, entries, srcfiles) locate_rcs (file, repository, rcs); if (isreadable (rcs)) { - error (0, 0, + if (update_dir[0] == '\0') + error (0, 0, "cannot add file `%s' when RCS file `%s' already exists", - file, rcs); + file, rcs); + else + error (0, 0, + "cannot add file `%s/%s' when RCS file `%s' already exists", + update_dir, file, rcs); freevers_ts (&vers); return (1); } if (vers->tag && isdigit (*vers->tag) && numdots (vers->tag) > 1) { - error (0, 0, + if (update_dir[0] == '\0') + error (0, 0, "cannot add file `%s' with revision `%s'; must be on trunk", - file, vers->tag); + file, vers->tag); + else + error (0, 0, + "cannot add file `%s/%s' with revision `%s'; must be on trunk", + update_dir, file, vers->tag); freevers_ts (&vers); return (1); } @@ -480,6 +586,7 @@ check_fileproc (file, update_dir, repository, entries, srcfiles) ml->ulist = ulist; ml->cilist = cilist; p->data = (char *) ml; + p->delproc = masterlist_delproc; (void) addnode (mulist, p); } @@ -505,17 +612,21 @@ check_fileproc (file, update_dir, repository, entries, srcfiles) else ci->rev = (char *) NULL; ci->tag = xstrdup (vers->tag); + ci->options = xstrdup(vers->options); p->data = (char *) ci; (void) addnode (cilist, p); break; case T_UNKNOWN: - error (0, 0, "nothing known about `%s'", file); + if (update_dir[0] == '\0') + error (0, 0, "nothing known about `%s'", file); + else + error (0, 0, "nothing known about `%s/%s'", update_dir, file); freevers_ts (&vers); return (1); case T_UPTODATE: break; default: - error (0, 0, "Unknown status 0x%x for `%s'", status, file); + error (0, 0, "CVS internal error: unknown status %d", status); break; } @@ -543,11 +654,15 @@ check_direntproc (dir, repos, update_dir) * Walklist proc to run pre-commit checks */ static int -precommit_list_proc (p) +precommit_list_proc (p, closure) Node *p; + void *closure; { - if (p->data == (char *) T_ADDED || p->data == (char *) T_MODIFIED) + if (p->data == (char *) T_ADDED || p->data == (char *) T_MODIFIED || + p->data == (char *) T_REMOVED) + { run_arg (p->key); + } return (0); } @@ -561,14 +676,28 @@ precommit_proc (repository, filter) char *filter; { /* see if the filter is there, only if it's a full path */ - if (filter[0] == '/' && !isfile (filter)) + if (filter[0] == '/') { - error (0, errno, "cannot find pre-commit filter `%s'", filter); - return (1); /* so it fails! */ + char *s, *cp; + + s = xstrdup (filter); + for (cp = s; *cp; cp++) + if (isspace (*cp)) + { + *cp = '\0'; + break; + } + if (!isfile (s)) + { + error (0, errno, "cannot find pre-commit filter `%s'", s); + free (s); + return (1); /* so it fails! */ + } + free (s); } run_setup ("%s %s", filter, repository); - (void) walklist (ulist, precommit_list_proc); + (void) walklist (ulist, precommit_list_proc, NULL); return (run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL|RUN_REALLY)); } @@ -647,10 +776,10 @@ commit_fileproc (file, update_dir, repository, entries, srcfiles) * need to get the commit message ourselves */ if (use_editor && !got_message) - { + { got_message = 1; - do_editor (update_dir, message, repository, ulist); - } + do_editor (update_dir, &message, repository, ulist); + } p = findnode (cilist, file); if (p == NULL) @@ -662,15 +791,17 @@ commit_fileproc (file, update_dir, repository, entries, srcfiles) if (lockrcsfile (file, repository, ci->rev) != 0) { unlockrcs (file, repository); - return (1); + err = 1; + goto out; } } else if (ci->status == T_ADDED) { - if (checkaddfile (file, repository, ci->tag) != 0) + if (checkaddfile (file, repository, ci->tag, srcfiles) != 0) { fixaddfile (file, repository); - return (1); + err = 1; + goto out; } } @@ -685,7 +816,7 @@ commit_fileproc (file, update_dir, repository, entries, srcfiles) { /* find the max major rev number in this directory */ maxrev = 0; - (void) walklist (entries, findmaxrev); + (void) walklist (entries, findmaxrev, NULL); if (maxrev == 0) maxrev = 1; xrev = xmalloc (20); @@ -693,27 +824,34 @@ commit_fileproc (file, update_dir, repository, entries, srcfiles) } /* XXX - an added file with symbolic -r should add tag as well */ - err = finaladd (file, ci->rev ? ci->rev : xrev, ci->tag, + err = finaladd (file, ci->rev ? ci->rev : xrev, ci->tag, ci->options, repository, entries); if (xrev) free (xrev); - return (err); } - - if (ci->status == T_MODIFIED) + else if (ci->status == T_MODIFIED) { locate_rcs (file, repository, rcs); err = Checkin ('M', file, repository, rcs, ci->rev, ci->tag, - message, entries); + ci->options, message, entries); if (err != 0) { unlockrcs (file, repository); fixbranch (file, repository, sbranch); } } + else if (ci->status == T_REMOVED) + err = remove_file (file, repository, ci->tag, message, + entries, srcfiles); - if (ci->status == T_REMOVED) - err = remove_file (file, repository, ci->tag, entries); +out: + if (err != 0) + { + /* on failure, remove the file from ulist */ + p = findnode (ulist, file); + if (p) + delnode (p); + } return (err); } @@ -728,19 +866,16 @@ commit_filesdoneproc (err, repository, update_dir) char *repository; char *update_dir; { - List *ulist, *cilist; char *xtag = (char *) NULL; Node *p; + List *ulist; p = findnode (mulist, update_dir); - if (p != NULL) - { - ulist = ((struct master_lists *) p->data)->ulist; - cilist = ((struct master_lists *) p->data)->cilist; - } - else + if (p == NULL) return (err); + ulist = ((struct master_lists *) p->data)->ulist; + got_message = 0; /* see if we need to specify a per-directory or -r option tag */ @@ -748,8 +883,6 @@ commit_filesdoneproc (err, repository, update_dir) ParseTag (&xtag, (char **) NULL); Update_Logfile (repository, message, tag ? tag : xtag, (FILE *) 0, ulist); - dellist (&ulist); - dellist (&cilist); if (xtag) free (xtag); @@ -765,7 +898,7 @@ commit_filesdoneproc (err, repository, update_dir) { if (fgets (line, sizeof (line), fp) != NULL) { - if ((cp = rindex (line, '\n')) != NULL) + if ((cp = strrchr (line, '\n')) != NULL) *cp = '\0'; repository = Name_Repository ((char *) NULL, update_dir); run_setup ("%s %s", line, repository); @@ -817,7 +950,7 @@ commit_direntproc (dir, repos, update_dir) { got_message = 1; real_repos = Name_Repository (dir, update_dir); - do_editor (update_dir, message, real_repos, ulist); + do_editor (update_dir, &message, real_repos, ulist); free (real_repos); } return (R_PROCESS); @@ -844,15 +977,16 @@ commit_dirleaveproc (dir, err, update_dir) * find the maximum major rev number in an entries file */ static int -findmaxrev (p) +findmaxrev (p, closure) Node *p; + void *closure; { char *cp; int thisrev; Entnode *entdata; entdata = (Entnode *) p->data; - cp = index (entdata->version, '.'); + cp = strchr (entdata->version, '.'); if (cp != NULL) *cp = '\0'; thisrev = atoi (entdata->version); @@ -870,18 +1004,23 @@ findmaxrev (p) * link to keep it relative after we move it into the attic. */ static int -remove_file (file, repository, tag, entries) +remove_file (file, repository, tag, message, entries, srcfiles) char *file; char *repository; char *tag; + char *message; List *entries; + List *srcfiles; { - int omask; + mode_t omask; int retcode; char rcs[PATH_MAX]; - char tmp[PATH_MAX]; + char *tmp; + + retcode = 0; locate_rcs (file, repository, rcs); + if (tag) { /* a symbolic tag is specified; just remove the tag from the file */ @@ -894,20 +1033,28 @@ remove_file (file, repository, tag, entries) "failed to remove tag `%s' from `%s'", tag, rcs); return (1); } + Scratch_Entry (entries, file); return (0); } else { - /* no symbolic tag specified; really move it into the Attic */ + /* this was the head; really move it into the Attic */ + tmp = xmalloc(strlen(repository) + + sizeof('/') + + sizeof(CVSATTIC) + + sizeof('/') + + strlen(file) + + sizeof(RCSEXT) + 1); (void) sprintf (tmp, "%s/%s", repository, CVSATTIC); omask = umask (2); (void) mkdir (tmp, 0777); (void) umask (omask); (void) sprintf (tmp, "%s/%s/%s%s", repository, CVSATTIC, file, RCSEXT); + if ((strcmp (rcs, tmp) == 0 || rename (rcs, tmp) != -1) || (!isreadable (rcs) && isreadable (tmp))) - { + { Scratch_Entry (entries, file); return (0); } @@ -919,10 +1066,11 @@ remove_file (file, repository, tag, entries) * Do the actual checkin for added files */ static int -finaladd (file, rev, tag, repository, entries) +finaladd (file, rev, tag, options, repository, entries) char *file; char *rev; char *tag; + char *options; char *repository; List *entries; { @@ -931,7 +1079,7 @@ finaladd (file, rev, tag, repository, entries) char rcs[PATH_MAX]; locate_rcs (file, repository, rcs); - ret = Checkin ('A', file, repository, rcs, rev, tag, + ret = Checkin ('A', file, repository, rcs, rev, tag, options, message, entries); if (ret == 0) { @@ -1015,24 +1163,27 @@ fixbranch (file, repository, branch) * with a tag, put the file in the Attic and point the symbolic tag * at the committed revision. */ + static int -checkaddfile (file, repository, tag) +checkaddfile (file, repository, tag, srcfiles) char *file; char *repository; char *tag; + List *srcfiles; { FILE *fp; char *cp; char rcs[PATH_MAX]; char fname[PATH_MAX]; - int omask; + mode_t omask; int retcode = 0; if (tag) { (void) sprintf(rcs, "%s/%s", repository, CVSATTIC); omask = umask (2); - (void) mkdir (rcs, 0777); + if (mkdir (rcs, 0777) != 0 && errno != EEXIST) + error (1, errno, "cannot make directory `%s'", rcs);; (void) umask (omask); (void) sprintf (rcs, "%s/%s/%s%s", repository, CVSATTIC, file, RCSEXT); } @@ -1045,7 +1196,7 @@ checkaddfile (file, repository, tag) fp = open_file (fname, "r"); while (fgets (fname, sizeof (fname), fp) != NULL) { - if ((cp = rindex (fname, '\n')) != NULL) + if ((cp = strrchr (fname, '\n')) != NULL) *cp = '\0'; if (*fname) run_arg (fname); @@ -1058,6 +1209,7 @@ checkaddfile (file, repository, tag) "could not create %s", rcs); return (1); } + fix_rcs_modes (rcs, file); return (0); } @@ -1207,10 +1359,27 @@ ci_delproc (p) free (ci->rev); if (ci->tag) free (ci->tag); + if (ci->options) + free (ci->options); free (ci); } /* + * Free the commit_info structure in p. + */ +static void +masterlist_delproc (p) + Node *p; +{ + struct master_lists *ml; + + ml = (struct master_lists *) p->data; + dellist (&ml->ulist); + dellist (&ml->cilist); + free (ml); +} + +/* * Find an RCS file in the repository. */ static void diff --git a/gnu/usr.bin/cvs/cvs/create_adm.c b/gnu/usr.bin/cvs/cvs/create_adm.c index 911258e..55eb649 100644 --- a/gnu/usr.bin/cvs/cvs/create_adm.c +++ b/gnu/usr.bin/cvs/cvs/create_adm.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Create Administration. * @@ -14,7 +14,8 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)create_adm.c 1.24 92/03/31"; +static char rcsid[] = "$CVSid: @(#)create_adm.c 1.28 94/09/23 $"; +USE(rcsid) #endif void @@ -31,9 +32,6 @@ Create_Admin (dir, repository, tag, date) if (noexec) return; - if (!isdir (repository)) - error (1, 0, "there is no repository %s", repository); - if (dir != NULL) (void) sprintf (tmp, "%s/%s", dir, CVSADM); else @@ -58,6 +56,11 @@ Create_Admin (dir, repository, tag, date) (void) strcpy (tmp, CVSADM); make_directory (tmp); +#ifdef CVSADM_ROOT + /* record the current cvs root for later use */ + + Create_Root (dir, CVSroot); +#endif /* CVSADM_ROOT */ if (dir != NULL) (void) sprintf (tmp, "%s/%s", dir, CVSADM_REP); else diff --git a/gnu/usr.bin/cvs/cvs/cvs.1 b/gnu/usr.bin/cvs/cvs/cvs.1 index f0c648f..bd9e034 100644 --- a/gnu/usr.bin/cvs/cvs/cvs.1 +++ b/gnu/usr.bin/cvs/cvs/cvs.1 @@ -2,7 +2,7 @@ .ds Rv \\$3 .ds Dt \\$4 .. -.Id cvs.1,v 1.12 1992/04/10 03:05:16 berliner Exp +.Id $Id: cvs.1,v 1.16 1994/10/03 21:26:10 berliner Exp $ .TH CVS 1 "\*(Dt" .\" Full space in nroff; half space in troff .de SP @@ -181,8 +181,10 @@ Use .I editor to enter revision log information. Overrides the setting of the +.SM CVSEDITOR +and the .SM EDITOR -environment variable. +environment variables. .TP .B \-l Do not log the @@ -206,7 +208,7 @@ activity. Particularly useful with to explore the potential impact of an unfamiliar command. .TP .B \-r -Makes new working files files read-only. +Makes new working files read-only. Same effect as if the .SM CVSREAD environment variable is set. @@ -388,7 +390,7 @@ same date (unless you explicitly override it; see the description of the \fBupdate\fP command). .B \-D is available with the -.BR checkout ", " diff, ", " history ", " export ", " +.BR checkout ", " diff ", " history ", " export ", " .BR rdiff ", " rtag ", and " .B update commands. @@ -437,7 +439,7 @@ options described in .BR rcs ( 1 ) are available. The \fB\-k\fP option is available with the .BR add ", " checkout ", " diff ", " -.RB rdiff ", and " update +.BR rdiff ", and " update commands. Your \fIkflag\fP specification is ``sticky'' when you use it to create a private copy of a source file; that is, when you use this option with the \fBcheckout\fP or \fBupdate\fP commands, @@ -911,6 +913,13 @@ changed; you can use the option to limit .B commit to the current directory only. +Sometimes you may want to force a file to be committed even though it +is unchanged; this is achieved with the +.B \-f +flag, which also has the effect of disabling recursion (you can turn +it back on with +.B \-R +of course). .SP .B commit verifies that the selected files are up to date with the current revisions @@ -931,7 +940,7 @@ source repository file. You can instead specify the log message on the command line with the .B \-m option, thus suppressing the editor invocation, or use the -.B \-f +.B \-F option to specify that the argument \fIfile\fP contains the log message. .SP The @@ -960,7 +969,8 @@ number of dots) with the .B \-r option. To create a branch revision, one typically use the -.B \-b option of the +.B \-b +option of the .BR rtag " or " tag commands. Then, either @@ -1144,7 +1154,7 @@ Report on checked-out modules. .B \ \ \ \ \ \ \-T Report on all tags. .TP 1i -\fB\ \ \ \ \ \ \-x\fP \fItyp\fP +\fB\ \ \ \ \ \ \-x\fP \fItype\fP Extract a particular set of record types \fIX\fP from the \fBcvs\fP history. The types are indicated by single letters, which you may specify in combination. @@ -1162,6 +1172,18 @@ added; and `R', when a file is removed. .B \ \ \ \ \ \ \-e Everything (all record types); equivalent to specifying .` "\-xMACFROGWUT". +.TP 1i +\fB\ \ \ \ \ \ \-z\fP \fIzone\fP +Use time zone +.I zone +when outputting history records. +The zone name +.B LT +stands for local time; +numeric offsets stand for hours and minutes ahead of UTC. +For example, +.B +0530 +stands for 5 hours and 30 minutes ahead of (i.e. east of) UTC. .PP .RS .5i The options shown as \fB\-\fP\fIflags\fP constrain the report without @@ -1260,8 +1282,8 @@ CVS* cvslog.* tags TAGS \&.make.state .nse_depinfo *~ #* .#* ,* -*.old *.bak *.orig *.rej .del\-* -*.a *.o *.Z *.elc *.ln core +*.old *.bak *.BAK *.orig *.rej .del\-* +*.a *.o *.so *.Z *.elc *.ln core .fi .ft P .in -1i @@ -1295,7 +1317,12 @@ command options are available: \fB\-Q\fP, \fB\-q\fP, and \fB\-m\fP \fB\-m\fP, your editor is invoked (as with \fBcommit\fP) to allow you to enter one. .SP -There are two additional special options. +There are three additional special options. +.SP +Use +.` "\-d" +to specify that each file's time of last modification should be used +for the checkin date and time. .SP Use .` "\-b \fIbranch\fP" @@ -1481,7 +1508,7 @@ into the .` "Attic" directory (also within the source repository). .SP -This command is recursive by default, scheduing all physically removed +This command is recursive by default, scheduling all physically removed files that it finds for removal by the next .BR commit . Use the @@ -1546,7 +1573,7 @@ option to have .B rtag look in the .` "Attic" -for removed files that contin the specified tag. +for removed files that contain the specified tag. The tag is removed from these files, which makes it convenient to re-use a symbolic tag as development continues (and files get removed from the up-coming distribution). @@ -1796,8 +1823,8 @@ CVS* cvslog.* tags TAGS \&.make.state .nse_depinfo *~ #* .#* ,* -*.old *.bak *.orig *.rej .del\-* -*.a *.o *.Z *.elc *.ln core +*.old *.bak *.BAK *.orig *.rej .del\-* +*.a *.o *.so *.Z *.elc *.ln core .fi .ft P .in -1i @@ -1881,7 +1908,7 @@ Records programs for piping log entries. .TP CVSROOT/rcsinfo,v -Records pathnames to templates used dueing a +Records pathnames to templates used during a .` "cvs commit" operation. .TP @@ -1946,10 +1973,15 @@ and If not set, a compiled-in value is used; see the display from .` "cvs \-v". .TP -.SM EDITOR +.SM CVSEDITOR Specifies the program to use for recording log messages during .BR commit . -If not set, the default is +If not set, the +.SM EDITOR +environment variable is used instead. +If +.SM EDITOR +is not set either, the default is .BR /usr/ucb/vi . .SH "AUTHORS" .TP diff --git a/gnu/usr.bin/cvs/cvs/cvs.5 b/gnu/usr.bin/cvs/cvs/cvs.5 index 49ca562..9c477f3 100644 --- a/gnu/usr.bin/cvs/cvs/cvs.5 +++ b/gnu/usr.bin/cvs/cvs/cvs.5 @@ -243,7 +243,7 @@ removed by this \fBcommit\fP invocation. .SP For `\|commitinfo\|', the rest of the line is a command-line template to execute. -The template can include can include not only a program name, but whatever +The template can include not only a program name, but whatever list of arguments you wish. The full path to the current source repository is appended to the template, followed by the file names of any files involved in the commit (added, @@ -254,7 +254,7 @@ should be loaded into the log message template. .SP For `\|editinfo\|', the rest of the line is a command-line template to execute. -The template can include can include not only a program name, but whatever +The template can include not only a program name, but whatever list of arguments you wish. The full path to the current log message template file is appended to the template. diff --git a/gnu/usr.bin/cvs/cvs/cvs.h b/gnu/usr.bin/cvs/cvs/cvs.h index ec47581..95c6a9b 100644 --- a/gnu/usr.bin/cvs/cvs/cvs.h +++ b/gnu/usr.bin/cvs/cvs/cvs.h @@ -1,50 +1,119 @@ -/* @(#)cvs.h 1.72 92/03/31 */ +/* $CVSid: @(#)cvs.h 1.86 94/10/22 $ */ + +/* + * basic information used in all source files + * + */ + + +#include "config.h" /* this is stuff found via autoconf */ +#include "options.h" /* these are some larger questions which + can't easily be automatically checked + for */ + +/* AIX requires this to be the first thing in the file. */ +#ifdef __GNUC__ +#define alloca __builtin_alloca +#else /* not __GNUC__ */ +#if HAVE_ALLOCA_H +#include <alloca.h> +#else /* not HAVE_ALLOCA_H */ +#ifdef _AIX + #pragma alloca +#else /* not _AIX */ +char *alloca (); +#endif /* not _AIX */ +#endif /* not HAVE_ALLOCA_H */ +#endif /* not __GNUC__ */ + +#if __STDC__ +#define CONST const +#define PTR void * +#else +#define CONST +#define PTR char * +#endif + +/* Add prototype support. */ +#ifndef PROTO +#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) +#define PROTO(ARGS) ARGS +#else +#define PROTO(ARGS) () +#endif +#endif + +#if __GNUC__ == 2 +#define USE(var) static char sizeof##var = sizeof(sizeof##var) + sizeof(var); +#else +#define USE(var) +#endif + -#include "system.h" #include <stdio.h> + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#ifdef HAVE_STRING_H +#include <string.h> +#else +#include <strings.h> +#endif + +#include <fnmatch.h> /* This is supposed to be available on Posix systems */ + #include <ctype.h> #include <pwd.h> #include <signal.h> + +#ifdef HAVE_ERRNO_H +#include <errno.h> +#else +#ifndef errno +extern int errno; +#endif /* !errno */ +#endif /* HAVE_ERRNO_H */ + +#include "system.h" + #include "hash.h" -#include "rcs.h" -#include "regex.h" -#include "fnmatch.h" -#include "getopt.h" -#include "wait.h" -#include "config.h" + #ifdef MY_NDBM #include "myndbm.h" #else #include <ndbm.h> -#endif /* !MY_NDBM */ +#endif /* MY_NDBM */ + +#include "regex.h" +#include "getopt.h" +#include "wait.h" + +#include "rcs.h" + /* XXX - for now this is static */ -#undef PATH_MAX +#ifndef PATH_MAX #ifdef MAXPATHLEN #define PATH_MAX MAXPATHLEN+2 #else #define PATH_MAX 1024+2 #endif +#endif /* PATH_MAX */ /* just in case this implementation does not define this */ #ifndef L_tmpnam #define L_tmpnam 50 #endif -#if __STDC__ -#define CONST const -#define PTR void * -#else -#define CONST -#define PTR char * -#endif /* * Copyright (c) 1992, Brian Berliner and Jeff Polk * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Definitions for the CVS Administrative directory and the files it contains. * Here as #define's to make changing the names a simple task. @@ -54,6 +123,7 @@ #define CVSADM_ENTBAK "CVS/Entries.Backup" #define CVSADM_ENTSTAT "CVS/Entries.Static" #define CVSADM_REP "CVS/Repository" +#define CVSADM_ROOT "CVS/Root" #define CVSADM_CIPROG "CVS/Checkin.prog" #define CVSADM_UPROG "CVS/Update.prog" #define CVSADM_TAG "CVS/Tag" @@ -80,6 +150,7 @@ #define CVSROOTADM_EDITINFO "editinfo" #define CVSROOTADM_HISTORY "history" #define CVSROOTADM_IGNORE "cvsignore" +#define CVSROOTADM_CHECKOUTLIST "checkoutlist" #define CVSNULLREPOS "Emptydir" /* an empty directory */ /* support for the modules file (CVSROOTADM_MODULES) */ @@ -98,6 +169,7 @@ #define CVSTFL "#cvs.tfl" #define CVSRFL "#cvs.rfl" #define CVSWFL "#cvs.wfl" +#define CVSRFLPAT "#cvs.rfl.*" /* wildcard expr to match read locks */ #define CVSEXT_OPT ",p" #define CVSEXT_LOG ",t" #define CVSPREFIX ",," @@ -129,7 +201,8 @@ #define RCSBIN_ENV "RCSBIN" /* RCS binary directory */ /* #define RCSBIN_DFLT Set by config.h */ -#define EDITOR_ENV "EDITOR" /* which editor to use */ +#define EDITOR1_ENV "CVSEDITOR" /* which editor to use */ +#define EDITOR2_ENV "EDITOR" /* which editor to use */ /* #define EDITOR_DFLT Set by config.h */ #define CVSROOT_ENV "CVSROOT" /* source directory root */ @@ -154,7 +227,6 @@ #define MAXLINELEN 5000 /* max input line from a file */ #define MAXPROGLEN 30000 /* max program length to system() */ #define MAXLISTLEN 40000 /* For [A-Z]list holders */ -#define MAXMESGLEN 10000 /* max RCS log message size */ #define MAXDATELEN 50 /* max length for a date */ /* The type of request that is being done in do_module() */ @@ -198,12 +270,13 @@ struct vers_ts * empty = no user file * 0 = user file is new * -vers = user file to be removed */ - char *vn_rcs; /* the verion for the rcs file + char *vn_rcs; /* the version for the rcs file * (tag version?) */ char *ts_user; /* the timestamp for the user file */ char *ts_rcs; /* the user timestamp from entries */ char *options; /* opts from Entries file * (keyword expansion) */ + char *ts_conflict; /* Holds time_stamp of conflict */ char *tag; /* tag stored in the Entries file */ char *date; /* date stored in the Entries file */ Entnode *entdata; /* pointer to entries file node */ @@ -249,190 +322,126 @@ typedef enum direnter_type Dtype; extern char *program_name, *command_name; extern char *Rcsbin, *Editor, *CVSroot; +#ifdef CVSADM_ROOT +extern char *CVSADM_Root; +extern int cvsadmin_root; +#endif /* CVSADM_ROOT */ extern char *CurDir; extern int really_quiet, quiet; extern int use_editor; extern int cvswrite; -extern int trace; /* Show all commands */ -extern int noexec; /* Don't modify disk anywhere */ -extern int logoff; /* Don't write history entry */ +extern int trace; /* Show all commands */ +extern int noexec; /* Don't modify disk anywhere */ +extern int logoff; /* Don't write history entry */ /* Externs that are included directly in the CVS sources */ -#if __STDC__ -int Reader_Lock (char *xrepository); -DBM *open_module (void); -FILE *Fopen (char *name, char *mode); -FILE *open_file (char *name, char *mode); -List *Find_Dirs (char *repository, int which); -List *ParseEntries (int aflag); -char *Make_Date (char *rawdate); -char *Name_Repository (char *dir, char *update_dir); -char *Short_Repository (char *repository); -char *getcaller (void); -char *time_stamp (char *file); -char *xmalloc (int bytes); -char *xrealloc (char *ptr, int bytes); -char *xstrdup (char *str); -int No_Difference (char *file, Vers_TS * vers, List * entries); -int Parse_Info (char *infofile, char *repository, int (*callproc) (), int all); -int Reader_Lock (char *xrepository); -int SIG_register (int sig, SIGTYPE (*fn) ()); -int Writer_Lock (List * list); -int gethostname (char *name, int namelen); -int ign_name (char *name); -int isdir (char *file); -int isfile (char *file); -int islink (char *file); -int isreadable (char *file); -int iswritable (char *file); -int link_file (char *from, char *to); -int numdots (char *s); -int run_exec (char *stin, char *stout, char *sterr, int flags); -int unlink_file (char *f); -int update (int argc, char *argv[]); -int xcmp (char *file1, char *file2); -int yesno (void); -time_t get_date (char *date, struct timeb *now); -void Create_Admin (char *dir, char *repository, char *tag, char *date); -void Lock_Cleanup (void); -void ParseTag (char **tagp, char **datep); -void Scratch_Entry (List * list, char *fname); -void WriteTag (char *dir, char *tag, char *date); -void cat_module (int status); -void check_entries (char *dir); -void close_module (DBM * db); -void copy_file (char *from, char *to); -void error (int status, int errnum, char *message,...); -void fperror (FILE * fp, int status, int errnum, char *message,...); -void free_names (int *pargc, char *argv[]); -void freevers_ts (Vers_TS ** versp); -void ign_add (char *ign, int hold); -void ign_add_file (char *file, int hold); -void ign_setup (void); -void line2argv (int *pargc, char *argv[], char *line); -void make_directories (char *name); -void make_directory (char *name); -void rename_file (char *from, char *to); -void run_arg (char *s); -void run_args (char *fmt,...); -void run_print (FILE * fp); -void run_setup (char *fmt,...); -void strip_path (char *path); -void update_delproc (Node * p); -void usage (char **cpp); -void xchmod (char *fname, int writable); -int Checkin (int type, char *file, char *repository, char *rcs, char *rev, - char *tag, char *message, List * entries); -Ctype Classify_File (char *file, char *tag, char *date, char *options, +DBM *open_module PROTO((void)); +FILE *Fopen PROTO((char *name, char *mode)); +FILE *open_file PROTO((char *name, char *mode)); +List *Find_Dirs PROTO((char *repository, int which)); +List *ParseEntries PROTO((int aflag)); +char *Make_Date PROTO((char *rawdate)); +char *Name_Repository PROTO((char *dir, char *update_dir)); +#ifdef CVSADM_ROOT +char *Name_Root PROTO((char *dir, char *update_dir)); +void Create_Root PROTO((char *dir, char *rootdir)); +int same_directories PROTO((char *dir1, char *dir2)); +#endif /* CVSADM_ROOT */ +char *Short_Repository PROTO((char *repository)); +char *gca PROTO((char *rev1, char *rev2)); +char *getcaller PROTO((void)); +char *time_stamp PROTO((char *file)); +char *xmalloc PROTO((size_t bytes)); +char *xrealloc PROTO((char *ptr, size_t bytes)); +char *xstrdup PROTO((char *str)); +int No_Difference PROTO((char *file, Vers_TS * vers, List * entries, + char *repository, char *update_dir)); +int Parse_Info PROTO((char *infofile, char *repository, int PROTO((*callproc)) PROTO(()), int all)); +int Reader_Lock PROTO((char *xrepository)); +int SIG_register PROTO((int sig, RETSIGTYPE PROTO((*fn)) PROTO(()))); +int Writer_Lock PROTO((List * list)); +int ign_name PROTO((char *name)); +int isdir PROTO((char *file)); +int isfile PROTO((char *file)); +int islink PROTO((char *file)); +int isreadable PROTO((char *file)); +int iswritable PROTO((char *file)); +int joining PROTO((void)); +int link_file PROTO((char *from, char *to)); +int numdots PROTO((char *s)); +int run_exec PROTO((char *stin, char *stout, char *sterr, int flags)); +int unlink_file PROTO((char *f)); +int update PROTO((int argc, char *argv[])); +int xcmp PROTO((char *file1, char *file2)); +int yesno PROTO((void)); +time_t get_date PROTO((char *date, struct timeb *now)); +void Create_Admin PROTO((char *dir, char *repository, char *tag, char *date)); +void Lock_Cleanup PROTO((void)); +void ParseTag PROTO((char **tagp, char **datep)); +void Scratch_Entry PROTO((List * list, char *fname)); +void WriteTag PROTO((char *dir, char *tag, char *date)); +void cat_module PROTO((int status)); +void check_entries PROTO((char *dir)); +void close_module PROTO((DBM * db)); +void copy_file PROTO((char *from, char *to)); +void error PROTO((int status, int errnum, char *message,...)); +void fperror PROTO((FILE * fp, int status, int errnum, char *message,...)); +void free_names PROTO((int *pargc, char *argv[])); +void freevers_ts PROTO((Vers_TS ** versp)); +void ign_add PROTO((char *ign, int hold)); +void ign_add_file PROTO((char *file, int hold)); +void ign_setup PROTO((void)); +void ign_dir_add PROTO((char *name)); +int ignore_directory PROTO((char *name)); +void line2argv PROTO((int *pargc, char *argv[], char *line)); +void make_directories PROTO((char *name)); +void make_directory PROTO((char *name)); +void rename_file PROTO((char *from, char *to)); +void run_arg PROTO((char *s)); +void run_args PROTO((char *fmt,...)); +void run_print PROTO((FILE * fp)); +void run_setup PROTO((char *fmt,...)); +void strip_path PROTO((char *path)); +void strip_trailing_slashes PROTO((char *path)); +void update_delproc PROTO((Node * p)); +void usage PROTO((char **cpp)); +void xchmod PROTO((char *fname, int writable)); +int Checkin PROTO((int type, char *file, char *repository, char *rcs, char *rev, + char *tag, char *options, char *message, List *entries)); +Ctype Classify_File PROTO((char *file, char *tag, char *date, char *options, int force_tag_match, int aflag, char *repository, - List *entries, List *srcfiles, Vers_TS **versp); -List *Find_Names (char *repository, int which, int aflag, - List ** optentries); -void Register (List * list, char *fname, char *vn, char *ts, - char *options, char *tag, char *date); -void Update_Logfile (char *repository, char *xmessage, char *xrevision, - FILE * xlogfp, List * xchanges); -Vers_TS *Version_TS (char *repository, char *options, char *tag, + List *entries, List *srcfiles, Vers_TS **versp, + char *update_dir, int pipeout)); +List *Find_Names PROTO((char *repository, int which, int aflag, + List ** optentries)); +void Register PROTO((List * list, char *fname, char *vn, char *ts, + char *options, char *tag, char *date, char *ts_conflict)); +void Update_Logfile PROTO((char *repository, char *xmessage, char *xrevision, + FILE * xlogfp, List * xchanges)); +Vers_TS *Version_TS PROTO((char *repository, char *options, char *tag, char *date, char *user, int force_tag_match, - int set_time, List * entries, List * xfiles); -void do_editor (char *dir, char *message, char *repository, - List * changes); -int do_module (DBM * db, char *mname, enum mtype m_type, char *msg, - int (*callback_proc) (), char *where, int shorten, - int local_specified, int run_module_prog, char *extra_arg); -int do_recursion (int (*xfileproc) (), int (*xfilesdoneproc) (), - Dtype (*xdirentproc) (), int (*xdirleaveproc) (), + int set_time, List * entries, List * xfiles)); +void do_editor PROTO((char *dir, char **messagep, + char *repository, List * changes)); +int do_module PROTO((DBM * db, char *mname, enum mtype m_type, char *msg, + int PROTO((*callback_proc)) (), char *where, int shorten, + int local_specified, int run_module_prog, char *extra_arg)); +int do_recursion PROTO((int PROTO((*xfileproc)) (), int PROTO((*xfilesdoneproc)) (), + Dtype PROTO((*xdirentproc)) (), int PROTO((*xdirleaveproc)) (), Dtype xflags, int xwhich, int xaflag, int xreadlock, - int xdosrcs); -int do_update (int argc, char *argv[], char *xoptions, char *xtag, + int xdosrcs)); +int do_update PROTO((int argc, char *argv[], char *xoptions, char *xtag, char *xdate, int xforce, int local, int xbuild, int xaflag, int xprune, int xpipeout, int which, - char *xjoin_rev1, char *xjoin_rev2, char *preload_update_dir); -void history_write (int type, char *update_dir, char *revs, char *name, - char *repository); -int start_recursion (int (*fileproc) (), int (*filesdoneproc) (), - Dtype (*direntproc) (), int (*dirleaveproc) (), + char *xjoin_rev1, char *xjoin_rev2, char *preload_update_dir)); +void history_write PROTO((int type, char *update_dir, char *revs, char *name, + char *repository)); +int start_recursion PROTO((int PROTO((*fileproc)) (), int PROTO((*filesdoneproc)) (), + Dtype PROTO((*direntproc)) (), int PROTO((*dirleaveproc)) (), int argc, char *argv[], int local, int which, int aflag, int readlock, char *update_preload, - int dosrcs); -void SIG_beginCrSect (); -void SIG_endCrSect (); -#else /* !__STDC__ */ -DBM *open_module (); -FILE *Fopen (); -FILE *open_file (); -List *Find_Dirs (); -List *Find_Names (); -List *ParseEntries (); -Vers_TS *Version_TS (); -char *Make_Date (); -char *Name_Repository (); -char *Short_Repository (); -char *getcaller (); -char *time_stamp (); -char *xmalloc (); -char *xrealloc (); -char *xstrdup (); -int Checkin (); -Ctype Classify_File (); -int No_Difference (); -int Parse_Info (); -int Reader_Lock (); -int SIG_register (); -int Writer_Lock (); -int do_module (); -int do_recursion (); -int do_update (); -int gethostname (); -int ign_name (); -int isdir (); -int isfile (); -int islink (); -int isreadable (); -int iswritable (); -int link_file (); -int numdots (); -int run_exec (); -int start_recursion (); -int unlink_file (); -int update (); -int xcmp (); -int yesno (); -time_t get_date (); -void Create_Admin (); -void Lock_Cleanup (); -void ParseTag (); -void ParseTag (); -void Register (); -void Scratch_Entry (); -void Update_Logfile (); -void WriteTag (); -void cat_module (); -void check_entries (); -void close_module (); -void copy_file (); -void do_editor (); -void error (); -void fperror (); -void free_names (); -void freevers_ts (); -void history_write (); -void ign_add (); -void ign_add_file (); -void ign_setup (); -void line2argv (); -void make_directories (); -void make_directory (); -void rename_file (); -void run_arg (); -void run_args (); -void run_print (); -void run_setup (); -void strip_path (); -void update_delproc (); -void usage (); -void xchmod (); -void SIG_beginCrSect (); -void SIG_endCrSect (); -#endif /* __STDC__ */ + int dosrcs, int wd_is_repos)); +void SIG_beginCrSect PROTO((void)); +void SIG_endCrSect PROTO((void)); +void read_cvsrc PROTO((int *argc, char ***argv)); diff --git a/gnu/usr.bin/cvs/cvs/diff.c b/gnu/usr.bin/cvs/cvs/diff.c index db8b4b7..99d8c18 100644 --- a/gnu/usr.bin/cvs/cvs/diff.c +++ b/gnu/usr.bin/cvs/cvs/diff.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Difference * @@ -17,24 +17,18 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)diff.c 1.52 92/04/10"; +static char rcsid[] = "$CVSid: @(#)diff.c 1.61 94/10/22 $"; +USE(rcsid) #endif -#if __STDC__ -static Dtype diff_dirproc (char *dir, char *pos_repos, char *update_dir); -static int diff_dirleaveproc (char *dir, int err, char *update_dir); -static int diff_file_nodiff (char *file, char *repository, List *entries, - List *srcfiles, Vers_TS *vers); -static int diff_fileproc (char *file, char *update_dir, char *repository, - List * entries, List * srcfiles); -static void diff_mark_errors (int err); -#else -static int diff_fileproc (); -static Dtype diff_dirproc (); -static int diff_dirleaveproc (); -static int diff_file_nodiff (); -static void diff_mark_errors (); -#endif /* __STDC__ */ +static Dtype diff_dirproc PROTO((char *dir, char *pos_repos, char *update_dir)); +static int diff_filesdoneproc PROTO((int err, char *repos, char *update_dir)); +static int diff_dirleaveproc PROTO((char *dir, int err, char *update_dir)); +static int diff_file_nodiff PROTO((char *file, char *repository, List *entries, + List *srcfiles, Vers_TS *vers)); +static int diff_fileproc PROTO((char *file, char *update_dir, char *repository, + List * entries, List * srcfiles)); +static void diff_mark_errors PROTO((int err)); static char *diff_rev1, *diff_rev2; static char *diff_date1, *diff_date2; @@ -42,10 +36,11 @@ static char *use_rev1, *use_rev2; static char *options; static char opts[PATH_MAX]; static int diff_errors; +static int empty_files = 0; static char *diff_usage[] = { - "Usage: %s %s [-l] [rcsdiff-options]\n", + "Usage: %s %s [-lN] [rcsdiff-options]\n", #ifdef CVS_DIFFDATE " [[-r rev1 | -D date1] [-r rev2 | -D date2]] [files...] \n", #else @@ -54,6 +49,7 @@ static char *diff_usage[] = "\t-l\tLocal directory only, not recursive\n", "\t-D d1\tDiff revision for date against working file.\n", "\t-D d2\tDiff rev1/date1 against date2.\n", + "\t-N\tinclude diffs for added and removed files.\n", "\t-r rev1\tDiff revision for rev1 against working file.\n", "\t-r rev2\tDiff rev1/date1 against rev2.\n", NULL @@ -67,6 +63,7 @@ diff (argc, argv) char tmp[50]; int c, err = 0; int local = 0; + int which; if (argc == -1) usage (diff_usage); @@ -77,8 +74,8 @@ diff (argc, argv) * non-recursive/recursive diff. */ optind = 1; - while ((c = gnu_getopt (argc, argv, - "abcdefhilnpqtuw0123456789BHQRTC:D:F:I:L:V:k:r:")) != -1) + while ((c = getopt (argc, argv, + "abcdefhilnpqtuw0123456789BHNQRTC:D:F:I:L:V:k:r:")) != -1) { switch (c) { @@ -137,6 +134,9 @@ diff (argc, argv) diff_date1 = Make_Date (optarg); break; #endif + case 'N': + empty_files = 1; + break; case '?': default: usage (diff_usage); @@ -150,10 +150,14 @@ diff (argc, argv) if (!options) options = xstrdup (""); + which = W_LOCAL; + if (diff_rev2 != NULL || diff_date2 != NULL) + which |= W_REPOS | W_ATTIC; + /* start the recursion processor */ - err = start_recursion (diff_fileproc, (int (*) ()) NULL, diff_dirproc, + err = start_recursion (diff_fileproc, diff_filesdoneproc, diff_dirproc, diff_dirleaveproc, argc, argv, local, - W_LOCAL, 0, 1, (char *) NULL, 1); + which, 0, 1, (char *) NULL, 1, 0); /* clean up */ free (options); @@ -174,11 +178,23 @@ diff_fileproc (file, update_dir, repository, entries, srcfiles) { int status, err = 2; /* 2 == trouble, like rcsdiff */ Vers_TS *vers; + enum { + DIFF_ERROR, + DIFF_ADDED, + DIFF_REMOVED, + DIFF_NEITHER + } empty_file = DIFF_NEITHER; + char tmp[L_tmpnam+1]; vers = Version_TS (repository, (char *) NULL, (char *) NULL, (char *) NULL, file, 1, 0, entries, srcfiles); - if (vers->vn_user == NULL) + if (diff_rev2 != NULL || diff_date2 != NULL) + { + /* Skip all the following checks regarding the user file; we're + not using it. */ + } + else if (vers->vn_user == NULL) { error (0, 0, "I know nothing about %s", file); freevers_ts (&vers); @@ -187,17 +203,27 @@ diff_fileproc (file, update_dir, repository, entries, srcfiles) } else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0') { - error (0, 0, "%s is a new entry, no comparison available", file); - freevers_ts (&vers); - diff_mark_errors (err); - return (err); + if (empty_files) + empty_file = DIFF_ADDED; + else + { + error (0, 0, "%s is a new entry, no comparison available", file); + freevers_ts (&vers); + diff_mark_errors (err); + return (err); + } } else if (vers->vn_user[0] == '-') { - error (0, 0, "%s was removed, no comparison available", file); - freevers_ts (&vers); - diff_mark_errors (err); - return (err); + if (empty_files) + empty_file = DIFF_REMOVED; + else + { + error (0, 0, "%s was removed, no comparison available", file); + freevers_ts (&vers); + diff_mark_errors (err); + return (err); + } } else { @@ -220,25 +246,65 @@ diff_fileproc (file, update_dir, repository, entries, srcfiles) } } - if (diff_file_nodiff (file, repository, entries, srcfiles, vers)) + if (empty_file == DIFF_NEITHER && diff_file_nodiff (file, repository, entries, srcfiles, vers)) { freevers_ts (&vers); return (0); } + /* Output an "Index:" line for patch to use */ (void) fflush (stdout); - if (use_rev2) + if (update_dir[0]) + (void) printf ("Index: %s/%s\n", update_dir, file); + else + (void) printf ("Index: %s\n", file); + (void) fflush (stdout); + + if (empty_file == DIFF_ADDED || empty_file == DIFF_REMOVED) { - run_setup ("%s%s %s %s -r%s -r%s", Rcsbin, RCS_DIFF, - opts, *options ? options : vers->options, - use_rev1, use_rev2); + (void) printf ("===================================================================\nRCS file: %s\n", + file); + (void) printf ("diff -N %s\n", file); + + if (empty_file == DIFF_ADDED) + { + run_setup ("%s %s %s %s", DIFF, opts, DEVNULL, file); + } + else + { + /* + * FIXME: Should be setting use_rev1 using the logic in + * diff_file_nodiff, and using that revision. This code + * is broken for "cvs diff -N -r foo". + */ + run_setup ("%s%s -p -q %s -r%s", Rcsbin, RCS_CO, + *options ? options : vers->options, vers->vn_rcs); + run_arg (vers->srcfile->path); + if (run_exec (RUN_TTY, tmpnam (tmp), RUN_TTY, RUN_REALLY) == -1) + { + (void) unlink (tmp); + error (1, errno, "fork failed during checkout of %s", + vers->srcfile->path); + } + + run_setup ("%s %s %s %s", DIFF, opts, tmp, DEVNULL); + } } else { - run_setup ("%s%s %s %s -r%s", Rcsbin, RCS_DIFF, opts, - *options ? options : vers->options, use_rev1); + if (use_rev2) + { + run_setup ("%s%s %s %s -r%s -r%s", Rcsbin, RCS_DIFF, + opts, *options ? options : vers->options, + use_rev1, use_rev2); + } + else + { + run_setup ("%s%s %s %s -r%s", Rcsbin, RCS_DIFF, opts, + *options ? options : vers->options, use_rev1); + } + run_arg (vers->srcfile->path); } - run_arg (vers->srcfile->path); switch ((status = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_REALLY|RUN_COMBINED))) @@ -254,6 +320,9 @@ diff_fileproc (file, update_dir, repository, entries, srcfiles) break; } + if (empty_file == DIFF_REMOVED) + (void) unlink (tmp); + (void) fflush (stdout); freevers_ts (&vers); diff_mark_errors (err); @@ -288,7 +357,20 @@ diff_dirproc (dir, pos_repos, update_dir) } /* - * Concoct the proper exit status. + * Concoct the proper exit status - done with files + */ +/* ARGSUSED */ +static int +diff_filesdoneproc (err, repos, update_dir) + int err; + char *repos; + char *update_dir; +{ + return (diff_errors); +} + +/* + * Concoct the proper exit status - leaving directories */ /* ARGSUSED */ static int @@ -366,7 +448,12 @@ diff_file_nodiff (file, repository, entries, srcfiles, vers) } /* now, see if we really need to do the diff */ - return (strcmp (use_rev1, use_rev2) == 0); + if (use_rev1 && use_rev2) { + return (strcmp (use_rev1, use_rev2) == 0); + } else { + error(0, 0, "No HEAD revision for file %s", file); + return (1); + } } if (use_rev1 == NULL || strcmp (use_rev1, vers->vn_user) == 0) { diff --git a/gnu/usr.bin/cvs/cvs/entries.c b/gnu/usr.bin/cvs/cvs/entries.c index 6453e4f..0dfd165 100644 --- a/gnu/usr.bin/cvs/cvs/entries.c +++ b/gnu/usr.bin/cvs/cvs/entries.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Entries file to Files file * @@ -14,16 +14,13 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)entries.c 1.37 92/03/31"; +static char rcsid[] = "$CVSid: @(#)entries.c 1.44 94/10/07 $"; +USE(rcsid) #endif -#if __STDC__ -static Node *AddEntryNode (List * list, char *name, char *version, +static Node *AddEntryNode PROTO((List * list, char *name, char *version, char *timestamp, char *options, char *tag, - char *date); -#else -static Node *AddEntryNode (); -#endif /* __STDC__ */ + char *date, char *conflict)); static FILE *entfile; static char *entfilename; /* for error messages */ @@ -32,15 +29,24 @@ static char *entfilename; /* for error messages */ * Write out the line associated with a node of an entries file */ static int -write_ent_proc (node) - Node *node; +write_ent_proc (node, closure) + Node *node; + void *closure; { Entnode *p; p = (Entnode *) node->data; - if (fprintf (entfile, "/%s/%s/%s/%s/", node->key, p->version, - p->timestamp, p->options) == EOF) + if (fprintf (entfile, "/%s/%s/%s", node->key, p->version, + p->timestamp) == EOF) + error (1, errno, "cannot write %s", entfilename); + if (p->conflict) + { + if (fprintf (entfile, "+%s", p->conflict) == EOF) + error (1, errno, "cannot write %s", entfilename); + } + if (fprintf (entfile, "/%s/", p->options) == EOF) error (1, errno, "cannot write %s", entfilename); + if (p->tag) { if (fprintf (entfile, "T%s\n", p->tag) == EOF) @@ -67,7 +73,7 @@ write_entries (list) /* open the new one and walk the list writing entries */ entfilename = CVSADM_ENTBAK; entfile = open_file (entfilename, "w+"); - (void) walklist (list, write_ent_proc); + (void) walklist (list, write_ent_proc, NULL); if (fclose (entfile) == EOF) error (1, errno, "error closing %s", entfilename); @@ -102,7 +108,7 @@ Scratch_Entry (list, fname) * removing the old entry first, if necessary. */ void -Register (list, fname, vn, ts, options, tag, date) +Register (list, fname, vn, ts, options, tag, date, ts_conflict) List *list; char *fname; char *vn; @@ -110,13 +116,19 @@ Register (list, fname, vn, ts, options, tag, date) char *options; char *tag; char *date; + char *ts_conflict; { + int should_write_file = !noexec; Node *node; if (trace) - (void) fprintf (stderr, "-> Register(%s, %s, %s, %s, %s %s)\n", - fname, vn, ts, options, tag ? tag : "", - date ? date : ""); + { + (void) fprintf (stderr, "-> Register(%s, %s, %s%s%s, %s, %s %s)\n", + fname, vn, ts, + ts_conflict ? "+" : "", ts_conflict ? ts_conflict : "", + options, tag ? tag : "", date ? date : ""); + } + /* was it already there? */ if ((node = findnode (list, fname)) != NULL) { @@ -124,21 +136,24 @@ Register (list, fname, vn, ts, options, tag, date) delnode (node); /* add the new one and re-write the file */ - (void) AddEntryNode (list, fname, vn, ts, options, tag, date); - if (!noexec) + (void) AddEntryNode (list, fname, vn, ts, options, tag, + date, ts_conflict); + + if (should_write_file) write_entries (list); } else { /* add the new one */ - node = AddEntryNode (list, fname, vn, ts, options, tag, date); + node = AddEntryNode (list, fname, vn, ts, options, tag, + date, ts_conflict); - if (!noexec) + if (should_write_file) { /* append it to the end */ entfilename = CVSADM_ENT; entfile = open_file (entfilename, "a"); - (void) write_ent_proc (node); + (void) write_ent_proc (node, NULL); if (fclose (entfile) == EOF) error (1, errno, "error closing %s", entfilename); } @@ -174,11 +189,14 @@ ParseEntries (aflag) List *entries; char line[MAXLINELEN]; char *cp, *user, *vn, *ts, *options; - char *tag_or_date, *tag, *date; + char *tag_or_date, *tag, *date, *ts_conflict; char *dirtag, *dirdate; int lineno = 0; + int do_rewrite = 0; FILE *fpin; + vn = ts = options = tag = date = ts_conflict = 0; + /* get a fresh list... */ entries = getlist (); @@ -192,7 +210,7 @@ ParseEntries (aflag) struct stickydirtag *sdtp; sdtp = (struct stickydirtag *) xmalloc (sizeof (*sdtp)); - bzero ((char *) sdtp, sizeof (*sdtp)); + memset ((char *) sdtp, 0, sizeof (*sdtp)); sdtp->aflag = aflag; sdtp->tag = xstrdup (dirtag); sdtp->date = xstrdup (dirdate); @@ -214,23 +232,23 @@ ParseEntries (aflag) if (line[0] == '/') { user = line + 1; - if ((cp = index (user, '/')) == NULL) + if ((cp = strchr (user, '/')) == NULL) continue; *cp++ = '\0'; vn = cp; - if ((cp = index (vn, '/')) == NULL) + if ((cp = strchr (vn, '/')) == NULL) continue; *cp++ = '\0'; ts = cp; - if ((cp = index (ts, '/')) == NULL) + if ((cp = strchr (ts, '/')) == NULL) continue; *cp++ = '\0'; options = cp; - if ((cp = index (options, '/')) == NULL) + if ((cp = strchr (options, '/')) == NULL) continue; *cp++ = '\0'; tag_or_date = cp; - if ((cp = index (tag_or_date, '\n')) == NULL) + if ((cp = strchr (tag_or_date, '\n')) == NULL) continue; *cp = '\0'; tag = (char *) NULL; @@ -239,7 +257,40 @@ ParseEntries (aflag) tag = tag_or_date + 1; else if (*tag_or_date == 'D') date = tag_or_date + 1; - (void) AddEntryNode (entries, user, vn, ts, options, tag, date); + + if (ts_conflict = strchr (ts, '+')) + *ts_conflict++ = '\0'; + + /* + * XXX - Convert timestamp from old format to new format. + * + * If the timestamp doesn't match the file's current + * mtime, we'd have to generate a string that doesn't + * match anyways, so cheat and base it on the existing + * string; it doesn't have to match the same mod time. + * + * For an unmodified file, write the correct timestamp. + */ + { + struct stat sb; + if (strlen (ts) > 30 && stat (user, &sb) == 0) + { + extern char *ctime (); + char *c = ctime (&sb.st_mtime); + + if (!strncmp (ts + 25, c, 24)) + ts = time_stamp (user); + else + { + ts += 24; + ts[0] = '*'; + } + do_rewrite = 1; + } + } + + (void) AddEntryNode (entries, user, vn, ts, options, tag, + date, ts_conflict); } else { @@ -254,6 +305,9 @@ ParseEntries (aflag) } } + if (do_rewrite && !noexec) + write_entries (entries); + /* clean up and return */ if (fpin) (void) fclose (fpin); @@ -311,13 +365,13 @@ check_entries (dir) continue; } rev = line; - if ((ts = index (line, '|')) == NULL) + if ((ts = strchr (line, '|')) == NULL) continue; *ts++ = '\0'; - if ((user = rindex (ts, ' ')) == NULL) + if ((user = strrchr (ts, ' ')) == NULL) continue; *user++ = '\0'; - if ((cp = index (user, '|')) == NULL) + if ((cp = strchr (user, '|')) == NULL) continue; *cp = '\0'; opt = ""; @@ -368,6 +422,8 @@ Entries_delproc (node) free (p->tag); if (p->date) free (p->date); + if (p->conflict) + free (p->conflict); free ((char *) p); } @@ -376,7 +432,7 @@ Entries_delproc (node) * list */ static Node * -AddEntryNode (list, name, version, timestamp, options, tag, date) +AddEntryNode (list, name, version, timestamp, options, tag, date, conflict) List *list; char *name; char *version; @@ -384,6 +440,7 @@ AddEntryNode (list, name, version, timestamp, options, tag, date) char *options; char *tag; char *date; + char *conflict; { Node *p; Entnode *entdata; @@ -404,6 +461,7 @@ AddEntryNode (list, name, version, timestamp, options, tag, date) entdata->options = xstrdup (options); if (entdata->options == NULL) entdata->options = xstrdup ("");/* must be non-NULL */ + entdata->conflict = xstrdup (conflict); entdata->tag = xstrdup (tag); entdata->date = xstrdup (date); @@ -452,7 +510,8 @@ WriteTag (dir, tag, date) error (1, errno, "cannot close %s", tmp); } else - (void) unlink_file (tmp); + if (unlink_file (tmp) < 0 && errno != ENOENT) + error (1, errno, "cannot remove %s", tmp); } /* @@ -476,7 +535,7 @@ ParseTag (tagp, datep) { if (fgets (line, sizeof (line), fp) != NULL) { - if ((cp = rindex (line, '\n')) != NULL) + if ((cp = strrchr (line, '\n')) != NULL) *cp = '\0'; if (*line == 'T' && tagp) *tagp = xstrdup (line + 1); diff --git a/gnu/usr.bin/cvs/cvs/find_names.c b/gnu/usr.bin/cvs/cvs/find_names.c index 187bd23..a77807b 100644 --- a/gnu/usr.bin/cvs/cvs/find_names.c +++ b/gnu/usr.bin/cvs/cvs/find_names.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Find Names * @@ -19,16 +19,12 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)find_names.c 1.38 92/04/10"; +static char rcsid[] = "$CVSid: @(#)find_names.c 1.45 94/10/22 $"; +USE(rcsid) #endif -#if __STDC__ -static int find_dirs (char *dir, List * list, int checkadm); -static int find_rcs (char *dir, List * list); -#else -static int find_rcs (); -static int find_dirs (); -#endif /* __STDC__ */ +static int find_dirs PROTO((char *dir, List * list, int checkadm)); +static int find_rcs PROTO((char *dir, List * list)); static List *filelist; @@ -36,8 +32,9 @@ static List *filelist; * add the key from entry on entries list to the files list */ static int -add_entries_proc (node) - Node *node; +add_entries_proc (node, closure) + Node *node; + void *closure; { Node *fnode; @@ -82,7 +79,7 @@ Find_Names (repository, which, aflag, optentries) if (entries != NULL) { /* walk the entries file adding elements to the files list */ - (void) walklist (entries, add_entries_proc); + (void) walklist (entries, add_entries_proc, NULL); /* if our caller wanted the entries list, return it; else free it */ if (optentries != NULL) @@ -167,28 +164,21 @@ find_rcs (dir, list) List *list; { Node *p; - CONST char *regex_err; - char line[50]; - struct direct *dp; + struct dirent *dp; DIR *dirp; /* set up to read the dir */ if ((dirp = opendir (dir)) == NULL) return (1); - /* set up a regular expression to find the ,v files */ - (void) sprintf (line, ".*%s$", RCSEXT); - if ((regex_err = re_comp (line)) != NULL) - error (1, 0, "%s", regex_err); - /* read the dir, grabbing the ,v files */ while ((dp = readdir (dirp)) != NULL) { - if (re_exec (dp->d_name)) + if (fnmatch (RCSPAT, dp->d_name, 0) == 0) { char *comma; - comma = rindex (dp->d_name, ','); /* strip the ,v */ + comma = strrchr (dp->d_name, ','); /* strip the ,v */ *comma = '\0'; p = getnode (); p->type = FILES; @@ -213,17 +203,10 @@ find_dirs (dir, list, checkadm) int checkadm; { Node *p; - CONST char *regex_err; char tmp[PATH_MAX]; - char admdir[PATH_MAX]; - struct direct *dp; + struct dirent *dp; DIR *dirp; - /* build a regex to blow off ,v files */ - (void) sprintf (tmp, ".*%s$", RCSEXT); - if ((regex_err = re_comp (tmp)) != NULL) - error (1, 0, "%s", regex_err); - /* set up to read the dir */ if ((dirp = opendir (dir)) == NULL) return (1); @@ -234,38 +217,61 @@ find_dirs (dir, list, checkadm) if (strcmp (dp->d_name, ".") == 0 || strcmp (dp->d_name, "..") == 0 || strcmp (dp->d_name, CVSATTIC) == 0 || - strcmp (dp->d_name, CVSLCK) == 0 || - re_exec (dp->d_name)) /* don't bother stating ,v files */ + strcmp (dp->d_name, CVSLCK) == 0) continue; - (void) sprintf (tmp, "%s/%s", dir, dp->d_name); - if (isdir (tmp)) +#ifdef DT_DIR + if (dp->d_type != DT_DIR) { - /* check for administration directories (if needed) */ - if (checkadm) + if (dp->d_type != DT_UNKNOWN && dp->d_type != DT_LNK) + continue; +#endif + /* don't bother stating ,v files */ + if (fnmatch (RCSPAT, dp->d_name, 0) == 0) + continue; + + sprintf (tmp, "%s/%s", dir, dp->d_name); + if (!isdir (tmp)) + continue; + +#ifdef DT_DIR + } +#endif + + /* check for administration directories (if needed) */ + if (checkadm) + { + /* blow off symbolic links to dirs in local dir */ +#ifdef DT_DIR + if (dp->d_type != DT_DIR) { - /* blow off symbolic links to dirs in local dir */ + /* we're either unknown or a symlink at this point */ + if (dp->d_type == DT_LNK) + continue; +#endif if (islink (tmp)) continue; - - /* check for new style */ - (void) sprintf (admdir, "%s/%s", tmp, CVSADM); - if (!isdir (admdir)) - { - /* and old style */ - (void) sprintf (admdir, "%s/%s", tmp, OCVSADM); - if (!isdir (admdir)) - continue; - } +#ifdef DT_DIR } +#endif - /* put it in the list */ - p = getnode (); - p->type = DIRS; - p->key = xstrdup (dp->d_name); - if (addnode (list, p) != 0) - freenode (p); + /* check for new style */ + (void) sprintf (tmp, "%s/%s/%s", dir, dp->d_name, CVSADM); + if (!isdir (tmp)) + { + /* and old style */ + (void) sprintf (tmp, "%s/%s/%s", dir, dp->d_name, OCVSADM); + if (!isdir (tmp)) + continue; + } } + + /* put it in the list */ + p = getnode (); + p->type = DIRS; + p->key = xstrdup (dp->d_name); + if (addnode (list, p) != 0) + freenode (p); } (void) closedir (dirp); return (0); diff --git a/gnu/usr.bin/cvs/cvs/history.c b/gnu/usr.bin/cvs/cvs/history.c index 9675c4c..acec3cf 100644 --- a/gnu/usr.bin/cvs/cvs/history.c +++ b/gnu/usr.bin/cvs/cvs/history.c @@ -179,7 +179,8 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)history.c 1.31 92/04/10"; +static char rcsid[] = "$CVSid: @(#)history.c 1.33 94/09/21 $"; +USE(rcsid) #endif static struct hrec @@ -197,33 +198,18 @@ static struct hrec } *hrec_head; -#if __STDC__ -static char *fill_hrec (char *line, struct hrec * hr); -static int accept_hrec (struct hrec * hr, struct hrec * lr); -static int select_hrec (struct hrec * hr); -static int sort_order (CONST PTR l, CONST PTR r); -static int within (char *find, char *string); -static time_t date_and_time (char *date_str); -static void expand_modules (void); -static void read_hrecs (char *fname); -static void report_hrecs (void); -static void save_file (char *dir, char *name, char *module); -static void save_module (char *module); -static void save_user (char *name); -#else -static int sort_order (); -static time_t date_and_time (); -static void save_user (); -static void save_file (); -static void save_module (); -static void expand_modules (); -static char *fill_hrec (); -static void read_hrecs (); -static int within (); -static int select_hrec (); -static void report_hrecs (); -static int accept_hrec (); -#endif /* __STDC__ */ +static char *fill_hrec PROTO((char *line, struct hrec * hr)); +static int accept_hrec PROTO((struct hrec * hr, struct hrec * lr)); +static int select_hrec PROTO((struct hrec * hr)); +static int sort_order PROTO((CONST PTR l, CONST PTR r)); +static int within PROTO((char *find, char *string)); +static time_t date_and_time PROTO((char *date_str)); +static void expand_modules PROTO((void)); +static void read_hrecs PROTO((char *fname)); +static void report_hrecs PROTO((void)); +static void save_file PROTO((char *dir, char *name, char *module)); +static void save_module PROTO((char *module)); +static void save_user PROTO((char *name)); #define ALL_REC_TYPES "TOFWUCGMAR" #define USER_INCREMENT 2 @@ -247,6 +233,14 @@ static short repos_sort; static short file_sort; static short module_sort; +#ifdef HAVE_RCS5 +static short tz_local; +static time_t tz_seconds_east_of_GMT; +static char *tz_name = "+0000"; +#else +static char tz_name[] = "LT"; +#endif + static time_t since_date; static char since_rev[20]; /* Maxrev ~= 99.99.99.999 */ static char since_tag[64]; @@ -301,6 +295,7 @@ static char *history_usg[] = " -r <rev/tag> Since rev or tag (looks inside RCS files!)\n", " -t <tag> Since tag record placed in history file (by anyone).\n", " -u <user> For user name (repeatable)\n", + " -z <tz> Output for time zone <tz> (e.g. -z -0700)\n", NULL}; /* Sort routine for qsort: @@ -385,7 +380,7 @@ history (argc, argv) usage (history_usg); optind = 1; - while ((c = gnu_getopt (argc, argv, "Tacelow?D:b:f:m:n:p:r:t:u:x:X:")) != -1) + while ((c = getopt (argc, argv, "Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:")) != -1) { switch (c) { @@ -481,11 +476,47 @@ history (argc, argv) char *cp; for (cp = optarg; *cp; cp++) - if (!index (ALL_REC_TYPES, *cp)) - error (1, 0, "%c is not a valid report type", cp); + if (!strchr (ALL_REC_TYPES, *cp)) + error (1, 0, "%c is not a valid report type", *cp); } (void) strcpy (rec_types, optarg); break; + case 'z': +#ifndef HAVE_RCS5 + error (0, 0, "-z not supported with RCS 4"); +#else + tz_local = + (optarg[0] == 'l' || optarg[0] == 'L') + && (optarg[1] == 't' || optarg[1] == 'T') + && !optarg[2]; + if (tz_local) + tz_name = optarg; + else + { + /* + * Convert a known time with the given timezone to time_t. + * Use the epoch + 23 hours, so timezones east of GMT work. + */ + static char f[] = "1/1/1970 23:00 %s"; + char *buf = xmalloc (sizeof (f) - 2 + strlen (optarg)); + time_t t; + sprintf (buf, f, optarg); + t = get_date (buf, (struct timeb *) NULL); + free (buf); + if (t == (time_t) -1) + error (0, 0, "%s is not a known time zone", optarg); + else + { + /* + * Convert to seconds east of GMT, removing the + * 23-hour offset mentioned above. + */ + tz_seconds_east_of_GMT = (time_t)23 * 60 * 60 - t; + tz_name = optarg; + } + } +#endif + break; case '?': default: usage (history_usg); @@ -508,7 +539,7 @@ history (argc, argv) if (tag_report) { - if (!index (rec_types, 'T')) + if (!strchr (rec_types, 'T')) (void) strcat (rec_types, "T"); } else if (extract) @@ -559,7 +590,7 @@ history (argc, argv) save_user (getcaller ()); /* If we're looking back to a Tag value, must consider "Tag" records */ - if (*since_tag && !index (rec_types, 'T')) + if (*since_tag && !strchr (rec_types, 'T')) (void) strcat (rec_types, "T"); argc -= c; @@ -637,7 +668,7 @@ history_write (type, update_dir, revs, name, repository) if (chdir (pw->pw_dir) < 0) error (1, errno, "can't chdir(%s)", pw->pw_dir); if (!getwd (homedir)) - error (1, errno, "can't getwd in:", pw->pw_dir); + error (1, errno, "can't getwd in %s", pw->pw_dir); (void) chdir (workdir); i = strlen (homedir); @@ -837,16 +868,16 @@ fill_hrec (line, hr) int off; static int idx = 0; - bzero ((char *) hr, sizeof (*hr)); + memset ((char *) hr, 0, sizeof (*hr)); while (isspace (*line)) line++; - if (!(rtn = index (line, '\n'))) + if (!(rtn = strchr (line, '\n'))) return (""); *rtn++ = '\0'; hr->type = line++; (void) sscanf (line, "%x", &hr->date); - while (*line && index ("0123456789abcdefABCDEF", *line)) + while (*line && strchr ("0123456789abcdefABCDEF", *line)) line++; if (*line == '\0') return (rtn); @@ -854,7 +885,7 @@ fill_hrec (line, hr) line++; NEXT_BAR (user); NEXT_BAR (dir); - if ((cp = rindex (hr->dir, '*')) != NULL) + if ((cp = strrchr (hr->dir, '*')) != NULL) { *cp++ = '\0'; (void) sscanf (cp, "%x", &off); @@ -865,7 +896,7 @@ fill_hrec (line, hr) NEXT_BAR (repos); NEXT_BAR (rev); hr->idx = idx++; - if (index ("FOT", *(hr->type))) + if (strchr ("FOT", *(hr->type))) hr->mod = line; NEXT_BAR (file); /* This returns ptr to next line or final '\0' */ @@ -981,7 +1012,7 @@ within (find, string) while (*string) { - if (!(string = index (string, c))) + if (!(string = strchr (string, c))) return (0); string++; if (!strncmp (find, string, len)) @@ -1104,9 +1135,9 @@ select_hrec (hr) * file_list is null, keep everything. Otherwise, keep only files on * file_list, matched appropriately. */ - if (!index (rec_types, *(hr->type))) + if (!strchr (rec_types, *(hr->type))) return (0); - if (!index ("TFO", *(hr->type))) /* Don't bother with "file" if "TFO" */ + if (!strchr ("TFO", *(hr->type))) /* Don't bother with "file" if "TFO" */ { if (file_list) /* If file_list is null, accept all */ { @@ -1132,7 +1163,7 @@ select_hrec (hr) } else { - if (index (cp, '/')) + if (strchr (cp, '/')) { (void) sprintf (cp2 = cmpfile, "%s/%s", hr->repos, hr->file); @@ -1215,7 +1246,7 @@ report_hrecs () ty = *(lr->type); (void) strcpy (repos, lr->repos); - if ((cp = rindex (repos, '/')) != NULL) + if ((cp = strrchr (repos, '/')) != NULL) { if (lr->mod && !strcmp (++cp, lr->mod)) { @@ -1253,12 +1284,21 @@ report_hrecs () continue; ty = *(lr->type); +#ifdef HAVE_RCS5 + if (!tz_local) + { + time_t t = lr->date + tz_seconds_east_of_GMT; + tm = gmtime (&t); + } + else +#endif tm = localtime (&(lr->date)); - (void) printf ("%c %02d/%02d %02d:%02d %-*s", ty, tm->tm_mon + 1, - tm->tm_mday, tm->tm_hour, tm->tm_min, user_len, lr->user); + (void) printf ("%c %02d/%02d %02d:%02d %s %-*s", ty, tm->tm_mon + 1, + tm->tm_mday, tm->tm_hour, tm->tm_min, tz_name, + user_len, lr->user); (void) sprintf (workdir, "%s%s", lr->dir, lr->end); - if ((cp = rindex (workdir, '/')) != NULL) + if ((cp = strrchr (workdir, '/')) != NULL) { if (lr->mod && !strcmp (++cp, lr->mod)) { @@ -1266,7 +1306,7 @@ report_hrecs () } } (void) strcpy (repos, lr->repos); - if ((cp = rindex (repos, '/')) != NULL) + if ((cp = strrchr (repos, '/')) != NULL) { if (lr->mod && !strcmp (++cp, lr->mod)) { diff --git a/gnu/usr.bin/cvs/cvs/ignore.c b/gnu/usr.bin/cvs/cvs/ignore.c index 74ab90c..0005f40 100644 --- a/gnu/usr.bin/cvs/cvs/ignore.c +++ b/gnu/usr.bin/cvs/cvs/ignore.c @@ -1,11 +1,12 @@ /* - * .cvsignore file support contributed by David G. Grubbs <dgg@ksr.com> + * .cvsignore file support contributed by David G. Grubbs <dgg@odi.com> */ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)ignore.c 1.13 92/04/03"; +static char rcsid[] = "$CVSid: @(#)ignore.c 1.16 94/09/24 $"; +USE(rcsid) #endif /* @@ -147,7 +148,7 @@ ign_add (ign, hold) * (saving it if necessary). We also catch * as a special case in a * global ignore file as an optimization */ - if (isspace (*(ign + 1)) && (*ign == '!' || *ign == '*')) + if ((!*(ign+1) || isspace (*(ign+1))) && (*ign == '!' || *ign == '*')) { if (!hold) { @@ -225,3 +226,47 @@ ign_name (name) return (1); return (0); } + + +static char **dir_ign_list = NULL; +static int dir_ign_max = 0; +static int dir_ign_current = 0; + +/* add a directory to list of dirs to ignore */ +void ign_dir_add (name) + char *name; +{ + /* make sure we've got the space for the entry */ + if (dir_ign_current <= dir_ign_max) + { + dir_ign_max += IGN_GROW; + dir_ign_list = (char **) xrealloc ((char *) dir_ign_list, (dir_ign_max+1) * sizeof(char*)); + } + + dir_ign_list[dir_ign_current] = name; + + dir_ign_current += 1 ; +} + + +/* this function returns 1 (true) if the given directory name is part of + * the list of directories to ignore + */ + +int ignore_directory (name) + char *name; +{ + int i; + + if (!dir_ign_list) + return 0; + + i = dir_ign_current; + while (i--) + { + if (strncmp(name, dir_ign_list[i], strlen(dir_ign_list[i])) == 0) + return 1; + } + + return 0; +} diff --git a/gnu/usr.bin/cvs/cvs/import.c b/gnu/usr.bin/cvs/cvs/import.c index bf66dcb..2d2cdb8 100644 --- a/gnu/usr.bin/cvs/cvs/import.c +++ b/gnu/usr.bin/cvs/cvs/import.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * "import" checks in the vendor release located in the current directory into * the CVS source repository. The CVS vendor branch support is utilized. @@ -19,39 +19,29 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)import.c 1.52 92/03/31"; +static char rcsid[] = "$CVSid: @(#)import.c 1.63 94/09/30 $"; +USE(rcsid) #endif #define FILE_HOLDER ".#cvsxxx" -#if __STDC__ -static char *get_comment (char *user); -static int add_rcs_file (char *message, char *rcs, char *user, char *vtag, - int targc, char *targv[]); -static int expand_at_signs (char *buf, off_t size, FILE *fp); -static int add_rev (char *message, char *rcs, char *vfile, char *vers); -static int add_tags (char *rcs, char *vfile, char *vtag, int targc, - char *targv[]); -static int import_descend (char *message, char *vtag, int targc, char *targv[]); -static int import_descend_dir (char *message, char *dir, char *vtag, - int targc, char *targv[]); -static int process_import_file (char *message, char *vfile, char *vtag, - int targc, char *targv[]); -static int update_rcs_file (char *message, char *vfile, char *vtag, int targc, - char *targv[]); -static void add_log (int ch, char *fname); -#else -static int import_descend (); -static int process_import_file (); -static int update_rcs_file (); -static int add_rev (); -static int add_tags (); -static char *get_comment (); -static int add_rcs_file (); -static int expand_at_signs (); -static void add_log (); -static int import_descend_dir (); -#endif /* __STDC__ */ +static char *get_comment PROTO((char *user)); +static int add_rcs_file PROTO((char *message, char *rcs, char *user, char *vtag, + int targc, char *targv[])); +static int expand_at_signs PROTO((char *buf, off_t size, FILE *fp)); +static int add_rev PROTO((char *message, char *rcs, char *vfile, char *vers)); +static int add_tags PROTO((char *rcs, char *vfile, char *vtag, int targc, + char *targv[])); +static int import_descend PROTO((char *message, char *vtag, int targc, char *targv[])); +static int import_descend_dir PROTO((char *message, char *dir, char *vtag, + int targc, char *targv[])); +static int process_import_file PROTO((char *message, char *vfile, char *vtag, + int targc, char *targv[])); +static int update_rcs_file PROTO((char *message, char *vfile, char *vtag, int targc, + char *targv[], int inattic)); +static void add_log PROTO((int ch, char *fname)); +static int str2expmode PROTO((char const* expstring)); +static int strn2expmode PROTO((char const* expstring, size_t n)); static int repos_len; static char vhead[50]; @@ -59,25 +49,42 @@ static char vbranch[50]; static FILE *logfp; static char repository[PATH_MAX]; static int conflicts; +static int use_file_modtime; +static char *keyword_opt = NULL; static char *import_usage[] = { - "Usage: %s %s [-Qq] [-I ign] [-m msg] [-b branch]\n", + "Usage: %s %s [-Qq] [-d] [-k subst] [-I ign] [-m msg] [-b branch]\n", " repository vendor-tag release-tags...\n", "\t-Q\tReally quiet.\n", "\t-q\tSomewhat quiet.\n", + "\t-d\tUse the file's modification time as the time of import.\n", + "\t-k sub\tSet default RCS keyword substitution mode.\n", "\t-I ign\tMore files to ignore (! to reset).\n", "\t-b bra\tVendor branch id.\n", "\t-m msg\tLog message.\n", NULL }; +static char *keyword_usage[] = +{ + "%s %s: invalid RCS keyword expansion mode\n", + "Valid expansion modes include:\n", + " -kkv\tGenerate keywords using the default form.\n", + " -kkvl\tLike -kkv, except locker's name inserted.\n", + " -kk\tGenerate only keyword names in keyword strings.\n", + " -kv\tGenerate only keyword values in keyword strings.\n", + " -ko\tGenerate the old keyword string (no changes from checked in file).\n", + NULL, +}; + + int import (argc, argv) int argc; char *argv[]; { - char message[MAXMESGLEN]; + char *message = NULL; char tmpfile[L_tmpnam+1]; char *cp; int i, c, msglen, err; @@ -90,9 +97,8 @@ import (argc, argv) ign_setup (); (void) strcpy (vbranch, CVSBRANCH); - message[0] = '\0'; optind = 1; - while ((c = gnu_getopt (argc, argv, "Qqb:m:I:")) != -1) + while ((c = getopt (argc, argv, "Qqdb:m:I:k:")) != -1) { switch (c) { @@ -102,6 +108,9 @@ import (argc, argv) case 'q': quiet = 1; break; + case 'd': + use_file_modtime = 1; + break; case 'b': (void) strcpy (vbranch, optarg); break; @@ -111,18 +120,17 @@ import (argc, argv) #else use_editor = FALSE; #endif - if (strlen (optarg) >= (sizeof (message) - 1)) - { - error (0, 0, "warning: message too long; truncated!"); - (void) strncpy (message, optarg, sizeof (message)); - message[sizeof (message) - 2] = '\0'; - } - else - (void) strcpy (message, optarg); + message = xstrdup(optarg); break; case 'I': ign_add (optarg, 0); break; + case 'k': + if (str2expmode(optarg) != -1) + keyword_opt = optarg; + else + usage (keyword_usage); + break; case '?': default: usage (import_usage); @@ -167,15 +175,25 @@ import (argc, argv) if (numdots (vbranch) != 2) error (1, 0, "Only branches with two dots are supported: %s", vbranch); (void) strcpy (vhead, vbranch); - cp = rindex (vhead, '.'); + cp = strrchr (vhead, '.'); *cp = '\0'; if (use_editor) - do_editor ((char *) NULL, message, repository, (List *) NULL); - msglen = strlen (message); + { + do_editor ((char *) NULL, &message, repository, + (List *) NULL); + } + + msglen = message == NULL ? 0 : strlen (message); if (msglen == 0 || message[msglen - 1] != '\n') { - message[msglen] = '\n'; - message[msglen + 1] = '\0'; + char *nm = xmalloc (msglen + 2); + if (message != NULL) + { + (void) strcpy (nm, message); + free (message); + } + (void) strcat (nm + msglen, "\n"); + message = nm; } /* @@ -235,6 +253,10 @@ import (argc, argv) Update_Logfile (repository, message, vbranch, logfp, ulist); dellist (&ulist); (void) fclose (logfp); + + if (message) + free (message); + return (err); } @@ -249,7 +271,7 @@ import_descend (message, vtag, targc, targv) char *targv[]; { DIR *dirp; - struct direct *dp; + struct dirent *dp; int err = 0; int has_dirs = 0; @@ -299,10 +321,14 @@ import_descend (message, vtag, targc, targv) { while ((dp = readdir (dirp)) != NULL) { - if (ign_name (dp->d_name) || !isdir (dp->d_name)) + if (!strcmp(".", dp->d_name) || !strcmp("..", dp->d_name)) + continue; + if (!isdir (dp->d_name) || ign_name (dp->d_name)) continue; err += import_descend_dir (message, dp->d_name, vtag, targc, targv); + /* need to re-load .cvsignore after each dir traversal */ + ign_add_file (CVSDOTIGNORE, 1); } (void) closedir (dirp); } @@ -323,6 +349,7 @@ process_import_file (message, vfile, vtag, targc, targv) { char attic_name[PATH_MAX]; char rcs[PATH_MAX]; + int inattic = 0; (void) sprintf (rcs, "%s/%s%s", repository, vfile, RCSEXT); if (!isfile (rcs)) @@ -339,12 +366,13 @@ process_import_file (message, vfile, vtag, targc, targv) add_log ('N', vfile); return (add_rcs_file (message, rcs, vfile, vtag, targc, targv)); } + inattic = 1; } /* * an rcs file exists. have to do things the official, slow, way. */ - return (update_rcs_file (message, vfile, vtag, targc, targv)); + return (update_rcs_file (message, vfile, vtag, targc, targv, inattic)); } /* @@ -352,27 +380,32 @@ process_import_file (message, vfile, vtag, targc, targv) * (possibly already existing) vendor branch. */ static int -update_rcs_file (message, vfile, vtag, targc, targv) +update_rcs_file (message, vfile, vtag, targc, targv, inattic) char *message; char *vfile; char *vtag; int targc; char *targv[]; + int inattic; { Vers_TS *vers; - char letter; + int letter; int ierrno; + char *tmpdir; vers = Version_TS (repository, (char *) NULL, vbranch, (char *) NULL, vfile, 1, 0, (List *) NULL, (List *) NULL); if (vers->vn_rcs != NULL) { - char xtmpfile[50]; + char xtmpfile[PATH_MAX]; int different; int retcode = 0; - /* XXX - should be more unique */ - (void) sprintf (xtmpfile, "/tmp/%s", FILE_HOLDER); + tmpdir = getenv ("TMPDIR"); + if (tmpdir == NULL || tmpdir[0] == '\0') + tmpdir = "/tmp"; + + (void) sprintf (xtmpfile, "%s/cvs-imp%d", tmpdir, getpid()); /* * The rcs file does have a revision on the vendor branch. Compare @@ -422,15 +455,15 @@ update_rcs_file (message, vfile, vtag, targc, targv) } /* We may have failed to parse the RCS file; check just in case */ - if (vers->srcfile == NULL || add_rev (message, vers->srcfile->path, - vfile, vers->vn_rcs) || + if (vers->srcfile == NULL || + add_rev (message, vers->srcfile->path, vfile, vers->vn_rcs) || add_tags (vers->srcfile->path, vfile, vtag, targc, targv)) { freevers_ts (&vers); return (1); } - if (vers->srcfile->branch == NULL || + if (vers->srcfile->branch == NULL || inattic || strcmp (vers->srcfile->branch, vbranch) != 0) { conflicts++; @@ -490,6 +523,8 @@ add_rev (message, rcs, vfile, vers) } run_setup ("%s%s -q -f -r%s", Rcsbin, RCS_CI, vbranch); run_args ("-m%s", message); + if (use_file_modtime) + run_arg ("-d"); run_arg (rcs); status = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL); ierrno = errno; @@ -583,8 +618,11 @@ struct compair comtable[] = */ "a", "-- ", /* Ada */ "ada", "-- ", + "adb", "-- ", "asm", ";; ", /* assembler (MS-DOS) */ + "ads", "-- ", /* Ada */ "bat", ":: ", /* batch (MS-DOS) */ + "body", "-- ", /* Ada */ "c", " * ", /* C */ "c++", "// ", /* C++ in all its infinite guises */ "cc", "// ", @@ -596,6 +634,8 @@ struct compair comtable[] = "cs", " * ", /* C* */ "csh", "# ", /* shell */ "e", "# ", /* efl */ + "epsf", "% ", /* encapsulated postscript */ + "epsi", "% ", /* encapsulated postscript */ "el", "; ", /* Emacs Lisp */ "f", "c ", /* Fortran */ "for", "c ", @@ -646,6 +686,7 @@ struct compair comtable[] = #endif "sh", "# ", /* shell */ "sl", "% ", /* psl */ + "spec", "-- ", /* Ada */ "tex", "% ", /* tex */ "y", " * ", /* yacc */ "ye", " * ", /* yacc-efl */ @@ -663,7 +704,7 @@ get_comment (user) char suffix_path[PATH_MAX]; int i; - cp = rindex (user, '.'); + cp = strrchr (user, '.'); if (cp != NULL) { cp++; @@ -702,7 +743,10 @@ add_rcs_file (message, rcs, user, vtag, targc, targv) struct stat sb; struct tm *ftm; time_t now; - char altdate1[50], altdate2[50]; + char altdate1[50]; +#ifndef HAVE_RCS5 + char altdate2[50]; +#endif char *author, *buf; int i, mode, ierrno, err = 0; @@ -730,15 +774,29 @@ add_rcs_file (message, rcs, user, vtag, targc, targv) if (fprintf (fprcs, "%s:%s;\n", vtag, vbranch) == EOF || fprintf (fprcs, "locks ; strict;\n") == EOF || /* XXX - make sure @@ processing works in the RCS file */ - fprintf (fprcs, "comment @%s@;\n\n", get_comment (user)) == EOF) + fprintf (fprcs, "comment @%s@;\n", get_comment (user)) == EOF) { goto write_error; } + if (keyword_opt != NULL) + if (fprintf (fprcs, "expand @%s@;\n", keyword_opt) == EOF) + { + goto write_error; + } + + if (fprintf (fprcs, "\n") == EOF) + goto write_error; + /* * puttree() */ - (void) time (&now); + if (fstat (fileno (fpuser), &sb) < 0) + error (1, errno, "cannot fstat %s", user); + if (use_file_modtime) + now = sb.st_mtime; + else + (void) time (&now); #ifdef HAVE_RCS5 ftm = gmtime (&now); #else @@ -748,16 +806,20 @@ add_rcs_file (message, rcs, user, vtag, targc, targv) ftm->tm_year + (ftm->tm_year < 100 ? 0 : 1900), ftm->tm_mon + 1, ftm->tm_mday, ftm->tm_hour, ftm->tm_min, ftm->tm_sec); - now++; #ifdef HAVE_RCS5 - ftm = gmtime (&now); +#define altdate2 altdate1 #else + /* + * If you don't have RCS V5 or later, you need to lie about the ci + * time, since RCS V4 and earlier insist that the times differ. + */ + now++; ftm = localtime (&now); -#endif (void) sprintf (altdate2, DATEFORM, ftm->tm_year + (ftm->tm_year < 100 ? 0 : 1900), ftm->tm_mon + 1, ftm->tm_mday, ftm->tm_hour, ftm->tm_min, ftm->tm_sec); +#endif author = getcaller (); if (fprintf (fprcs, "\n%s\n", vhead) == EOF || @@ -786,8 +848,6 @@ add_rcs_file (message, rcs, user, vtag, targc, targv) goto write_error; } - if (fstat (fileno (fpuser), &sb) < 0) - error (1, errno, "cannot fstat %s", user); if (sb.st_size > 0) { off_t size; @@ -797,7 +857,10 @@ add_rcs_file (message, rcs, user, vtag, targc, targv) if (fread (buf, (int) size, 1, fpuser) != 1) error (1, errno, "cannot read file %s for copying", user); if (expand_at_signs (buf, size, fprcs) == EOF) + { + free (buf); goto write_error; + } free (buf); } if (fprintf (fprcs, "@\n\n") == EOF || @@ -874,7 +937,7 @@ expand_at_signs (buf, size, fp) */ static void add_log (ch, fname) - char ch; + int ch; char *fname; { if (!really_quiet) /* write to terminal */ @@ -964,7 +1027,7 @@ import_descend_dir (message, dir, vtag, targc, targv) } err = import_descend (message, vtag, targc, targv); out: - if ((cp = rindex (repository, '/')) != NULL) + if ((cp = strrchr (repository, '/')) != NULL) *cp = '\0'; else repository[0] = '\0'; @@ -972,3 +1035,36 @@ import_descend_dir (message, dir, vtag, targc, targv) error (1, errno, "cannot chdir to %s", cwd); return (err); } + +/* the following code is taken from code in rcs/src/rcssyn.c, and returns a + * positive value if 'expstring' contains a valid RCS expansion token for + * the -k option. If an invalid expansion is named, then return -1. + */ + +char const *const expand_names[] = { + /* These must agree with *_EXPAND in rcs/src/rcsbase.h. */ + "kv","kvl","k","v","o", + 0 +}; + +static int +str2expmode(s) + char const *s; +/* Yield expand mode corresponding to S, or -1 if bad. */ +{ + return strn2expmode(s, strlen(s)); +} + +static int +strn2expmode(s, n) + char const *s; + size_t n; +{ + char const *const *p; + + for (p = expand_names; *p; ++p) + if (memcmp(*p,s,n) == 0 && !(*p)[n]) + return p - expand_names; + return -1; +} + diff --git a/gnu/usr.bin/cvs/cvs/lock.c b/gnu/usr.bin/cvs/cvs/lock.c index 5da23b3..940e963 100644 --- a/gnu/usr.bin/cvs/cvs/lock.c +++ b/gnu/usr.bin/cvs/cvs/lock.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Set Lock * @@ -13,30 +13,20 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)lock.c 1.42 92/04/10"; +static char rcsid[] = "$CVSid: @(#)lock.c 1.50 94/09/30 $"; +USE(rcsid) #endif extern char *ctime (); -#if __STDC__ -static int readers_exist (char *repository); -static int set_lock (char *lockdir, int will_wait, char *repository); -static void set_lockers_name (struct stat *statp); -static int set_writelock_proc (Node * p); -static int unlock_proc (Node * p); -static int write_lock (char *repository); -static void unlock (char *repository); -static void lock_wait (); -#else -static int unlock_proc (); -static void unlock (); -static int set_writelock_proc (); -static int write_lock (); -static int readers_exist (); -static int set_lock (); -static void set_lockers_name (); -static void lock_wait (); -#endif /* __STDC__ */ +static int readers_exist PROTO((char *repository)); +static int set_lock PROTO((char *lockdir, int will_wait, char *repository)); +static void set_lockers_name PROTO((struct stat *statp)); +static int set_writelock_proc PROTO((Node * p, void *closure)); +static int unlock_proc PROTO((Node * p, void *closure)); +static int write_lock PROTO((char *repository)); +static void unlock PROTO((char *repository)); +static void lock_wait PROTO((char *repository)); static char lockers_name[20]; static char *repository; @@ -65,7 +55,7 @@ Lock_Cleanup () /* clean up multiple locks (if any) */ if (locklist != (List *) NULL) { - (void) walklist (locklist, unlock_proc); + (void) walklist (locklist, unlock_proc, NULL); locklist = (List *) NULL; } } @@ -74,8 +64,9 @@ Lock_Cleanup () * walklist proc for removing a list of locks */ static int -unlock_proc (p) +unlock_proc (p, closure) Node *p; + void *closure; { unlock (p->key); return (0); @@ -94,13 +85,15 @@ unlock (repository) if (readlock[0] != '\0') { (void) sprintf (tmp, "%s/%s", repository, readlock); - (void) unlink (tmp); + if (unlink (tmp) < 0 && errno != ENOENT) + error (0, errno, "failed to remove lock %s", tmp); } if (writelock[0] != '\0') { (void) sprintf (tmp, "%s/%s", repository, writelock); - (void) unlink (tmp); + if (unlink (tmp) < 0 && errno != ENOENT) + error (0, errno, "failed to remove lock %s", tmp); } /* @@ -118,6 +111,13 @@ unlock (repository) } /* + * Since some systems don't define this... + */ +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 256 +#endif + +/* * Create a lock file for readers */ int @@ -127,10 +127,18 @@ Reader_Lock (xrepository) int err = 0; FILE *fp; char tmp[PATH_MAX]; +#ifdef HAVE_LONG_FILE_NAMES + char hostname[MAXHOSTNAMELEN]; +#endif if (noexec) return (0); +#ifdef HAVE_LONG_FILE_NAMES + memset(hostname, 0, sizeof(hostname)); + gethostname(hostname, sizeof(hostname) - 1); +#endif + /* we only do one directory at a time for read locks! */ if (repository != NULL) { @@ -139,7 +147,13 @@ Reader_Lock (xrepository) } if (readlock[0] == '\0') - (void) sprintf (readlock, "%s.%d", CVSRFL, getpid ()); + (void) sprintf (readlock, +#ifdef HAVE_LONG_FILE_NAMES + "%s.%s.%d", CVSRFL, hostname, +#else + "%s.%d", CVSRFL, +#endif + getpid ()); /* remember what we're locking (for lock_cleanup) */ repository = xrepository; @@ -152,16 +166,24 @@ Reader_Lock (xrepository) (void) SIG_register (SIGTERM, Lock_Cleanup); /* make sure we can write the repository */ - (void) sprintf (tmp, "%s/%s.%d", xrepository, CVSTFL, getpid ()); + (void) sprintf (tmp, +#ifdef HAVE_LONG_FILE_NAMES + "%s/%s.%s.%d", xrepository, CVSTFL, hostname, +#else + "%s/%s.%d", xrepository, CVSTFL, +#endif + getpid()); if ((fp = fopen (tmp, "w+")) == NULL || fclose (fp) == EOF) { error (0, errno, "cannot create read lock in repository `%s'", xrepository); readlock[0] = '\0'; - (void) unlink (tmp); + if (unlink (tmp) < 0 && errno != ENOENT) + error (0, errno, "failed to remove lock %s", tmp); return (1); } - (void) unlink (tmp); + if (unlink (tmp) < 0) + error (0, errno, "failed to remove lock %s", tmp); /* get the lock dir for our own */ (void) sprintf (tmp, "%s/%s", xrepository, CVSLCK); @@ -218,7 +240,7 @@ Writer_Lock (list) locklist = list; /* init for Lock_Cleanup */ (void) strcpy (lockers_name, "unknown"); - (void) walklist (list, set_writelock_proc); + (void) walklist (list, set_writelock_proc, NULL); switch (lock_error) { @@ -247,8 +269,9 @@ Writer_Lock (list) * walklist proc for setting write locks */ static int -set_writelock_proc (p) +set_writelock_proc (p, closure) Node *p; + void *closure; { /* if some lock was not OK, just skip this one */ if (lock_error != L_OK) @@ -271,9 +294,23 @@ write_lock (repository) int status; FILE *fp; char tmp[PATH_MAX]; +#ifdef HAVE_LONG_FILE_NAMES + char hostname[MAXHOSTNAMELEN]; +#endif + +#ifdef HAVE_LONG_FILE_NAMES + memset(hostname, 0, sizeof(hostname)); + gethostname(hostname, sizeof(hostname) - 1); +#endif if (writelock[0] == '\0') - (void) sprintf (writelock, "%s.%d", CVSWFL, getpid ()); + (void) sprintf (writelock, +#ifdef HAVE_LONG_FILE_NAMES + "%s.%s.%d", CVSWFL, hostname, +#else + "%s.%d", CVSWFL, +#endif + getpid()); /* make sure we clean up on error */ (void) SIG_register (SIGHUP, Lock_Cleanup); @@ -283,15 +320,23 @@ write_lock (repository) (void) SIG_register (SIGTERM, Lock_Cleanup); /* make sure we can write the repository */ - (void) sprintf (tmp, "%s/%s.%d", repository, CVSTFL, getpid ()); + (void) sprintf (tmp, +#ifdef HAVE_LONG_FILE_NAMES + "%s/%s.%s.%d", repository, CVSTFL, hostname, +#else + "%s/%s.%d", repository, CVSTFL, +#endif + getpid ()); if ((fp = fopen (tmp, "w+")) == NULL || fclose (fp) == EOF) { error (0, errno, "cannot create write lock in repository `%s'", repository); - (void) unlink (tmp); + if (unlink (tmp) < 0 && errno != ENOENT) + error (0, errno, "failed to remove lock %s", tmp); return (L_ERROR); } - (void) unlink (tmp); + if (unlink (tmp) < 0) + error (0, errno, "failed to remove lock %s", tmp); /* make sure the lock dir is ours (not necessarily unique to us!) */ (void) sprintf (tmp, "%s/%s", repository, CVSLCK); @@ -318,7 +363,9 @@ write_lock (repository) { int xerrno = errno; - (void) unlink (tmp); + if (unlink (tmp) < 0 && errno != ENOENT) + error (0, errno, "failed to remove lock %s", tmp); + /* free the lock dir if we created it */ if (status == L_OK) { @@ -349,9 +396,8 @@ readers_exist (repository) { char line[MAXLINELEN]; DIR *dirp; - struct direct *dp; + struct dirent *dp; struct stat sb; - CONST char *regex_err; int ret = 0; #ifdef CVS_FUDGELOCKS @@ -361,43 +407,46 @@ again: if ((dirp = opendir (repository)) == NULL) error (1, 0, "cannot open directory %s", repository); - (void) sprintf (line, "^%s.*", CVSRFL); - if ((regex_err = re_comp (line)) != NULL) - error (1, 0, "%s", regex_err); - + errno = 0; while ((dp = readdir (dirp)) != NULL) { - (void) sprintf (line, "%s/%s", repository, dp->d_name); - if (re_exec (dp->d_name)) + if (fnmatch (CVSRFLPAT, dp->d_name, 0) == 0) { #ifdef CVS_FUDGELOCKS time_t now; - (void) time (&now); +#endif - /* - * If the create time of the file is more than CVSLCKAGE seconds - * ago, try to clean-up the lock file, and if successful, re-open - * the directory and try again. - */ + (void) sprintf (line, "%s/%s", repository, dp->d_name); if (stat (line, &sb) != -1) { +#ifdef CVS_FUDGELOCKS + /* + * If the create time of the file is more than CVSLCKAGE + * seconds ago, try to clean-up the lock file, and if + * successful, re-open the directory and try again. + */ if (now >= (sb.st_ctime + CVSLCKAGE) && unlink (line) != -1) { - (void) closedir (dirp); + if (closedir (dirp) < 0) + error (0, errno, + "error closing directory %s", repository); goto again; } +#endif set_lockers_name (&sb); } -#else - if (stat (line, &sb) != -1) - set_lockers_name (&sb); -#endif + ret = 1; break; } + errno = 0; } - (void) closedir (dirp); + if (errno != 0) + error (0, errno, "error reading directory %s", repository); + + if (closedir (dirp) < 0) + error (0, errno, "error closing directory %s", repository); return (ret); } diff --git a/gnu/usr.bin/cvs/cvs/log.c b/gnu/usr.bin/cvs/cvs/log.c index 9e7ab8b..4c3718e 100644 --- a/gnu/usr.bin/cvs/cvs/log.c +++ b/gnu/usr.bin/cvs/cvs/log.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Print Log Information * @@ -15,17 +15,13 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)log.c 1.39 92/03/31"; +static char rcsid[] = "$CVSid: @(#)log.c 1.44 94/09/30 $"; +USE(rcsid) #endif -#if __STDC__ -static Dtype log_dirproc (char *dir, char *repository, char *update_dir); -static int log_fileproc (char *file, char *update_dir, char *repository, - List * entries, List * srcfiles); -#else -static int log_fileproc (); -static Dtype log_dirproc (); -#endif /* __STDC__ */ +static Dtype log_dirproc PROTO((char *dir, char *repository, char *update_dir)); +static int log_fileproc PROTO((char *file, char *update_dir, char *repository, + List * entries, List * srcfiles)); static char options[PATH_MAX]; @@ -76,7 +72,7 @@ cvslog (argc, argv) err = start_recursion (log_fileproc, (int (*) ()) NULL, log_dirproc, (int (*) ()) NULL, argc, argv, local, W_LOCAL | W_REPOS | W_ATTIC, 0, 1, - (char *) NULL, 1); + (char *) NULL, 1, 0); return (err); } @@ -99,8 +95,25 @@ log_fileproc (file, update_dir, repository, entries, srcfiles) p = findnode (srcfiles, file); if (p == NULL || (rcsfile = (RCSNode *) p->data) == NULL) { + /* no rcs file. What *do* we know about this file? */ + p = findnode (entries, file); + if (p != NULL) + { + Entnode *e; + + e = (Entnode *) p->data; + if (e->version[0] == '0' || e->version[1] == '\0') + { + if (!really_quiet) + error (0, 0, "%s has been added, but not committed", + file); + return(0); + } + } + if (!really_quiet) error (0, 0, "nothing known about %s", file); + return (1); } diff --git a/gnu/usr.bin/cvs/cvs/logmsg.c b/gnu/usr.bin/cvs/cvs/logmsg.c index ce1da92..8fd0b2d 100644 --- a/gnu/usr.bin/cvs/cvs/logmsg.c +++ b/gnu/usr.bin/cvs/cvs/logmsg.c @@ -3,36 +3,34 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. */ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)logmsg.c 1.40 92/04/10"; +static char rcsid[] = "$CVSid: @(#)logmsg.c 1.48 94/09/29 $"; +USE(rcsid) #endif -#if __STDC__ -static int find_type (Node * p); -static int fmt_proc (Node * p); -static int logfile_write (char *repository, char *filter, char *title, +/* this is slightly dangerous, since it could conflict with other systems' + * own prototype. + */ +#if 0 +/* Which is why I'll nuke this */ +extern int gethostname PROTO((char *name, int len)); +#endif + +static int find_type PROTO((Node * p, void *closure)); +static int fmt_proc PROTO((Node * p, void *closure)); +static int logfile_write PROTO((char *repository, char *filter, char *title, char *message, char *revision, FILE * logfp, - List * changes); -static int rcsinfo_proc (char *repository, char *template); -static int title_proc (Node * p); -static int update_logfile_proc (char *repository, char *filter); -static void setup_tmpfile (FILE * xfp, char *xprefix, List * changes); -static int editinfo_proc (char *repository, char *template); -#else -static void setup_tmpfile (); -static int find_type (); -static int fmt_proc (); -static int rcsinfo_proc (); -static int update_logfile_proc (); -static int title_proc (); -static int logfile_write (); -static int editinfo_proc (); -#endif /* __STDC__ */ + List * changes)); +static int rcsinfo_proc PROTO((char *repository, char *template)); +static int title_proc PROTO((Node * p, void *closure)); +static int update_logfile_proc PROTO((char *repository, char *filter)); +static void setup_tmpfile PROTO((FILE * xfp, char *xprefix, List * changes)); +static int editinfo_proc PROTO((char *repository, char *template)); static FILE *fp; static char *strlist; @@ -42,8 +40,7 @@ static Ctype type; /* * Puts a standard header on the output which is either being prepared for an * editor session, or being sent to a logfile program. The modified, added, - * and removed files are included (if any) and formatted to look pretty. - */ + * and removed files are included (if any) and formatted to look pretty. */ static char *prefix; static int col; static void @@ -57,30 +54,30 @@ setup_tmpfile (xfp, xprefix, changes) prefix = xprefix; type = T_MODIFIED; - if (walklist (changes, find_type) != 0) + if (walklist (changes, find_type, NULL) != 0) { (void) fprintf (fp, "%sModified Files:\n", prefix); (void) fprintf (fp, "%s\t", prefix); col = 8; - (void) walklist (changes, fmt_proc); + (void) walklist (changes, fmt_proc, NULL); (void) fprintf (fp, "\n"); } type = T_ADDED; - if (walklist (changes, find_type) != 0) + if (walklist (changes, find_type, NULL) != 0) { (void) fprintf (fp, "%sAdded Files:\n", prefix); (void) fprintf (fp, "%s\t", prefix); col = 8; - (void) walklist (changes, fmt_proc); + (void) walklist (changes, fmt_proc, NULL); (void) fprintf (fp, "\n"); } type = T_REMOVED; - if (walklist (changes, find_type) != 0) + if (walklist (changes, find_type, NULL) != 0) { (void) fprintf (fp, "%sRemoved Files:\n", prefix); (void) fprintf (fp, "%s\t", prefix); col = 8; - (void) walklist (changes, fmt_proc); + (void) walklist (changes, fmt_proc, NULL); (void) fprintf (fp, "\n"); } } @@ -89,8 +86,9 @@ setup_tmpfile (xfp, xprefix, changes) * Looks for nodes of a specified type and returns 1 if found */ static int -find_type (p) +find_type (p, closure) Node *p; + void *closure; { if (p->data == (char *) type) return (1); @@ -104,8 +102,9 @@ find_type (p) * match the one we're looking for */ static int -fmt_proc (p) +fmt_proc (p, closure) Node *p; + void *closure; { if (p->data == (char *) type) { @@ -131,41 +130,40 @@ fmt_proc (p) * */ void -do_editor (dir, message, repository, changes) +do_editor (dir, messagep, repository, changes) char *dir; - char *message; + char **messagep; char *repository; List *changes; { static int reuse_log_message = 0; char line[MAXLINELEN], fname[L_tmpnam+1]; - char *orig_message; struct stat pre_stbuf, post_stbuf; int retcode = 0; + char *p; if (noexec || reuse_log_message) return; - orig_message = xstrdup (message); /* save it for later */ - /* Create a temporary file */ (void) tmpnam (fname); again: if ((fp = fopen (fname, "w+")) == NULL) error (1, 0, "cannot create temporary file %s", fname); - /* set up the file so that the first line is blank if no msg specified */ - if (*orig_message) + if (*messagep) { - (void) fprintf (fp, "%s", orig_message); - if (orig_message[strlen (orig_message) - 1] != '\n') + (void) fprintf (fp, "%s", *messagep); + + if ((*messagep)[strlen (*messagep) - 1] != '\n') (void) fprintf (fp, "\n"); } else (void) fprintf (fp, "\n"); - /* tack templates on if necessary */ - (void) Parse_Info (CVSROOTADM_RCSINFO, repository, rcsinfo_proc, 1); + if (repository != NULL) + /* tack templates on if necessary */ + (void) Parse_Info (CVSROOTADM_RCSINFO, repository, rcsinfo_proc, 1); (void) fprintf (fp, "%s----------------------------------------------------------------------\n", @@ -176,7 +174,8 @@ do_editor (dir, message, repository, changes) if (dir != NULL) (void) fprintf (fp, "%sCommitting in %s\n%s\n", CVSEDITPREFIX, dir, CVSEDITPREFIX); - setup_tmpfile (fp, CVSEDITPREFIX, changes); + if (changes != NULL) + setup_tmpfile (fp, CVSEDITPREFIX, changes); (void) fprintf (fp, "%s----------------------------------------------------------------------\n", CVSEDITPREFIX); @@ -189,7 +188,8 @@ do_editor (dir, message, repository, changes) if (editinfo_editor) free (editinfo_editor); editinfo_editor = (char *) NULL; - (void) Parse_Info (CVSROOTADM_EDITINFO, repository, editinfo_proc, 0); + if (repository != NULL) + (void) Parse_Info (CVSROOTADM_EDITINFO, repository, editinfo_proc, 0); /* run the editor */ run_setup ("%s", editinfo_editor ? editinfo_editor : Editor); @@ -200,29 +200,47 @@ do_editor (dir, message, repository, changes) editinfo_editor ? "Logfile verification failed" : "warning: editor session failed"); - /* put the entire message back into the message variable */ + /* put the entire message back into the *messagep variable */ + fp = open_file (fname, "r"); - *message = '\0'; - while (fgets (line, sizeof (line), fp) != NULL) + + if (*messagep) + free (*messagep); + + if (stat (fname, &post_stbuf) != 0) + error (1, errno, "cannot find size of temp file %s", fname); + + if (post_stbuf.st_size == 0) + *messagep = NULL; + else { - if (strncmp (line, CVSEDITPREFIX, sizeof (CVSEDITPREFIX) - 1) == 0) - continue; - if (((int) strlen (message) + (int) strlen (line)) >= MAXMESGLEN) + *messagep = (char *) xmalloc (post_stbuf.st_size); + *messagep[0] = '\0'; + } + +/* !!! XXX FIXME: fgets is broken. This should not have any line + length limits. */ + + if (*messagep) + { + p = *messagep; + while (fgets (line, sizeof (line), fp) != NULL) { - error (0, 0, "warning: log message truncated!"); - break; + if (strncmp (line, CVSEDITPREFIX, sizeof (CVSEDITPREFIX) - 1) == 0) + continue; + (void) strcpy (p, line); + p += strlen (line); } - (void) strcat (message, line); } (void) fclose (fp); - if ((stat (fname, &post_stbuf) == 0 && - pre_stbuf.st_mtime == post_stbuf.st_mtime) || - (*message == '\0' || strcmp (message, "\n") == 0)) + if (pre_stbuf.st_mtime == post_stbuf.st_mtime || + *messagep == NULL || + strcmp (*messagep, "\n") == 0) { for (;;) { (void) printf ("\nLog message unchanged or not specified\n"); - (void) printf ("a)bort, c)continue, e)dit, !)reuse this message unchanged for remaining dirs\n"); + (void) printf ("a)bort, c)ontinue, e)dit, !)reuse this message unchanged for remaining dirs\n"); (void) printf ("Action: (continue) "); (void) fflush (stdout); *line = '\0'; @@ -241,7 +259,6 @@ do_editor (dir, message, repository, changes) (void) printf ("Unknown input\n"); } } - free (orig_message); (void) unlink_file (fname); } @@ -303,6 +320,10 @@ Update_Logfile (repository, xmessage, xrevision, xlogfp, xchanges) { char *srepos; + /* nothing to do if the list is empty */ + if (xchanges == NULL || xchanges->list->next == xchanges->list) + return; + /* set up static vars for update_logfile_proc */ message = xmessage; revision = xrevision; @@ -318,13 +339,13 @@ Update_Logfile (repository, xmessage, xrevision, xlogfp, xchanges) strlist[0] = '\0'; type = T_TITLE; - (void) walklist (changes, title_proc); + (void) walklist (changes, title_proc, NULL); type = T_ADDED; - (void) walklist (changes, title_proc); + (void) walklist (changes, title_proc, NULL); type = T_MODIFIED; - (void) walklist (changes, title_proc); + (void) walklist (changes, title_proc, NULL); type = T_REMOVED; - (void) walklist (changes, title_proc); + (void) walklist (changes, title_proc, NULL); title = xmalloc (strlen (srepos) + strlen (strlist) + 1 + 2); /* for 's */ (void) sprintf (title, "'%s%s'", srepos, strlist); @@ -355,8 +376,9 @@ update_logfile_proc (repository, filter) * concatenate each name onto strlist */ static int -title_proc (p) +title_proc (p, closure) Node *p; + void *closure; { if (p->data == (char *) type) { diff --git a/gnu/usr.bin/cvs/cvs/main.c b/gnu/usr.bin/cvs/cvs/main.c index ce10eb8..3751b3c 100644 --- a/gnu/usr.bin/cvs/cvs/main.c +++ b/gnu/usr.bin/cvs/cvs/main.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License - * as specified in the README file that comes with the CVS 1.3 kit. + * as specified in the README file that comes with the CVS 1.4 kit. * * This is the main C driver for the CVS system. * @@ -35,7 +35,10 @@ #include "cvs.h" #include "patchlevel.h" -char rcsid[] = "@(#)main.c 1.64 92/03/31\n"; +#ifndef lint +char rcsid[] = "$CVSid: @(#)main.c 1.78 94/10/07 $\n"; +USE(rcsid) +#endif extern char *getenv (); @@ -43,6 +46,7 @@ char *program_name; char *command_name = ""; int use_editor = TRUE; +int use_cvsrc = TRUE; int cvswrite = !CVSREAD_DFLT; int really_quiet = FALSE; int quiet = FALSE; @@ -58,40 +62,28 @@ char *CurDir; char *Rcsbin = RCSBIN_DFLT; char *Editor = EDITOR_DFLT; char *CVSroot = CVSROOT_DFLT; - -#if __STDC__ -int add (int argc, char **argv); -int admin (int argc, char **argv); -int checkout (int argc, char **argv); -int commit (int argc, char **argv); -int diff (int argc, char **argv); -int history (int argc, char **argv); -int import (int argc, char **argv); -int cvslog (int argc, char **argv); -int patch (int argc, char **argv); -int release (int argc, char **argv); -int cvsremove (int argc, char **argv); -int rtag (int argc, char **argv); -int status (int argc, char **argv); -int tag (int argc, char **argv); -int update (int argc, char **argv); -#else -int add (); -int admin (); -int checkout (); -int commit (); -int diff (); -int history (); -int import (); -int cvslog (); -int patch (); -int release (); -int cvsremove (); -int rtag (); -int status (); -int tag (); -int update (); -#endif /* __STDC__ */ +#ifdef CVSADM_ROOT +/* + * The path found in CVS/Root must match $CVSROOT and/or 'cvs -d root' + */ +char *CVSADM_Root = CVSROOT_DFLT; +#endif /* CVSADM_ROOT */ + +int add PROTO((int argc, char **argv)); +int admin PROTO((int argc, char **argv)); +int checkout PROTO((int argc, char **argv)); +int commit PROTO((int argc, char **argv)); +int diff PROTO((int argc, char **argv)); +int history PROTO((int argc, char **argv)); +int import PROTO((int argc, char **argv)); +int cvslog PROTO((int argc, char **argv)); +int patch PROTO((int argc, char **argv)); +int release PROTO((int argc, char **argv)); +int cvsremove PROTO((int argc, char **argv)); +int rtag PROTO((int argc, char **argv)); +int status PROTO((int argc, char **argv)); +int tag PROTO((int argc, char **argv)); +int update PROTO((int argc, char **argv)); struct cmd { @@ -137,6 +129,7 @@ static char *usg[] = " -b bindir Find RCS programs in 'bindir'\n", " -e editor Use 'editor' for editing log information\n", " -d CVS_root Overrides $CVSROOT as the root of the CVS tree\n", + " -f Do not use the ~/.cvsrc file\n", "\n", " and where 'command' is:\n", " add Adds a new file/directory to the repository\n", @@ -158,7 +151,7 @@ static char *usg[] = NULL, }; -static SIGTYPE +static RETSIGTYPE main_cleanup () { exit (1); @@ -173,13 +166,13 @@ main (argc, argv) char *cp; struct cmd *cm; int c, help = FALSE, err = 0; - int rcsbin_update_env, cvs_update_env; + int rcsbin_update_env, cvs_update_env = 0; char tmp[PATH_MAX]; /* * Just save the last component of the path for error messages */ - if ((program_name = rindex (argv[0], '/')) == NULL) + if ((program_name = strrchr (argv[0], '/')) == NULL) program_name = argv[0]; else program_name++; @@ -193,12 +186,15 @@ main (argc, argv) * they can be overridden by command line arguments */ rcsbin_update_env = *Rcsbin; /* RCSBIN_DFLT must be set */ + cvs_update_env = 0; if ((cp = getenv (RCSBIN_ENV)) != NULL) { Rcsbin = cp; rcsbin_update_env = 0; /* it's already there */ } - if ((cp = getenv (EDITOR_ENV)) != NULL) + if ((cp = getenv (EDITOR1_ENV)) != NULL) + Editor = cp; + else if ((cp = getenv (EDITOR2_ENV)) != NULL) Editor = cp; if ((cp = getenv (CVSROOT_ENV)) != NULL) { @@ -209,7 +205,7 @@ main (argc, argv) cvswrite = FALSE; optind = 1; - while ((c = gnu_getopt (argc, argv, "Qqrwtnlvb:e:d:H")) != -1) + while ((c = getopt (argc, argv, "Qqrwtnlvb:e:d:Hf")) != -1) { switch (c) { @@ -234,11 +230,10 @@ main (argc, argv) logoff = TRUE; break; case 'v': - (void) fputs (rcsid, stdout); (void) fputs (version_string, stdout); (void) sprintf (tmp, "Patch Level: %d\n", PATCHLEVEL); (void) fputs (tmp, stdout); - (void) fputs ("\nCopyright (c) 1992, Brian Berliner and Jeff Polk\nCopyright (c) 1989-1992, Brian Berliner\n\nCVS may be copied only under the terms of the GNU General Public License,\na copy of which can be found with the CVS 1.3 distribution kit.\n", stdout); + (void) fputs ("\nCopyright (c) 1993-1994 Brian Berliner\nCopyright (c) 1993-1994 david d `zoo' zuhn\nCopyright (c) 1992, Brian Berliner and Jeff Polk\nCopyright (c) 1989-1992, Brian Berliner\n\nCVS may be copied only under the terms of the GNU General Public License,\na copy of which can be found with the CVS distribution kit.\n", stdout); exit (0); break; case 'b': @@ -253,8 +248,12 @@ main (argc, argv) cvs_update_env = 1; /* need to update environment */ break; case 'H': + use_cvsrc = FALSE; /* this ensure that cvs -H works */ help = TRUE; break; + case 'f': + use_cvsrc = FALSE; + break; case '?': default: usage (usg); @@ -265,25 +264,49 @@ main (argc, argv) if (argc < 1) usage (usg); +#ifdef CVSADM_ROOT /* - * XXX - Compatibility. This can be removed in the release after CVS 1.3. - * Try to rename the CVSROOT.adm file to CVSROOT, unless there already is - * a CVSROOT directory. + * See if we are able to find a 'better' value for CVSroot in the + * CVSADM_ROOT directory. */ - if (CVSroot != NULL) + CVSADM_Root = Name_Root((char *) NULL, (char *) NULL); + if (CVSADM_Root != NULL) { - char rootadm[PATH_MAX]; - char orootadm[PATH_MAX]; - - (void) sprintf (rootadm, "%s/%s", CVSroot, CVSROOTADM); - if (!isdir (rootadm)) - { - (void) sprintf (orootadm, "%s/%s", CVSroot, OCVSROOTADM); - if (isdir (orootadm)) - (void) rename (orootadm, rootadm); - } - strip_path (CVSroot); + if (CVSroot == NULL) + { + CVSroot = CVSADM_Root; + cvs_update_env = 1; /* need to update environment */ + } + else + { + /* + * Now for the hard part, compare the two directories. If they + * are not identical, then abort this command. + */ + if ((strcmp (CVSroot, CVSADM_Root) != 0) && + !same_directories(CVSroot, CVSADM_Root)) + { + error (0, 0, "%s value for CVS Root found in %s", + CVSADM_Root, CVSADM_ROOT); + if (cvs_update_env) + { + error (0, 0, "does not match command line -d %s setting", + CVSroot); + error (1, 0, + "you may wish to try the cvs command again without the -d option "); + } + else + { + error (0, 0, + "does not match CVSROOT environment value of %s", + CVSroot); + error (1, 0, + "you may wish to unsetenv CVSROOT and try again"); + } + } + } } +#endif /* CVSADM_ROOT */ /* * Specifying just the '-H' flag to the sub-command causes a Usage @@ -326,7 +349,7 @@ main (argc, argv) } } -#ifndef PUTENV_MISSING +#ifdef HAVE_PUTENV /* Now, see if we should update the environment with the Rcsbin value */ if (cvs_update_env) { @@ -387,7 +410,7 @@ main (argc, argv) (void) SIG_register (SIGPIPE, main_cleanup); (void) SIG_register (SIGTERM, main_cleanup); -#ifndef SETVBUF_MISSING +#ifdef HAVE_SETVBUF /* * Make stdout line buffered, so 'tail -f' can monitor progress. * Patch creates too much output to monitor and it runs slowly. @@ -396,7 +419,11 @@ main (argc, argv) (void) setvbuf (stdout, (char *) NULL, _IOLBF, 0); #endif + if (use_cvsrc) + read_cvsrc(&argc, &argv); + err = (*(cm->func)) (argc, argv); + } /* * If the command's error count is modulo 256, we need to change it diff --git a/gnu/usr.bin/cvs/cvs/modules.c b/gnu/usr.bin/cvs/cvs/modules.c index b0658d7..384fbfd 100644 --- a/gnu/usr.bin/cvs/cvs/modules.c +++ b/gnu/usr.bin/cvs/cvs/modules.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License - * as specified in the README file that comes with the CVS 1.3 kit. + * as specified in the README file that comes with the CVS 1.4 kit. * * Modules * @@ -23,7 +23,8 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)modules.c 1.57 92/04/10"; +static char rcsid[] = "$CVSid: @(#)modules.c 1.62 94/09/29 $"; +USE(rcsid) #endif struct sortrec @@ -34,13 +35,8 @@ struct sortrec char *comment; }; -#if __STDC__ -static int sort_order (CONST PTR l, CONST PTR r); -static void save_d (char *k, int ks, char *d, int ds); -#else -static int sort_order (); -static void save_d (); -#endif /* __STDC__ */ +static int sort_order PROTO((CONST PTR l, CONST PTR r)); +static void save_d PROTO((char *k, int ks, char *d, int ds)); /* @@ -117,6 +113,13 @@ do_module (db, mname, m_type, msg, callback_proc, where, if (getwd (cwd) == NULL) error (1, 0, "cannot get current working directory: %s", cwd); + /* if this is a directory to ignore, add it to that list */ + if (mname[0] == '!' && mname[1] != '\0') + { + ign_dir_add (mname+1); + return(err); + } + /* strip extra stuff from the module name */ strip_path (mname); @@ -142,12 +145,20 @@ do_module (db, mname, m_type, msg, callback_proc, where, val.dptr[val.dsize] = '\0'; /* If the line ends in a comment, strip it off */ - if ((cp = index (val.dptr, '#')) != NULL) + if ((cp = strchr (val.dptr, '#')) != NULL) { do *cp-- = '\0'; while (isspace (*cp)); } + else + { + /* Always strip trailing spaces */ + cp = strchr (val.dptr, '\0'); + while (cp > val.dptr && isspace(*--cp)) + *cp = '\0'; + } + value = val.dptr; mwhere = xstrdup (mname); goto found; @@ -161,7 +172,7 @@ do_module (db, mname, m_type, msg, callback_proc, where, /* check to see if mname is a directory or file */ (void) sprintf (file, "%s/%s", CVSroot, mname); - if ((acp = rindex (mname, '/')) != NULL) + if ((acp = strrchr (mname, '/')) != NULL) { *acp = '\0'; (void) sprintf (attic_file, "%s/%s/%s/%s%s", CVSroot, mname, @@ -183,13 +194,13 @@ do_module (db, mname, m_type, msg, callback_proc, where, if (isfile (file) || isfile (attic_file)) { /* if mname was a file, we have to split it into "dir file" */ - if ((cp = rindex (mname, '/')) != NULL && cp != mname) + if ((cp = strrchr (mname, '/')) != NULL && cp != mname) { char *slashp; /* put the ' ' in a copy so we don't mess up the original */ value = strcpy (xvalue, mname); - slashp = rindex (value, '/'); + slashp = strrchr (value, '/'); *slashp = ' '; } else @@ -218,7 +229,7 @@ do_module (db, mname, m_type, msg, callback_proc, where, } /* look up everything to the first / as a module */ - if (mname[0] != '/' && (cp = index (mname, '/')) != NULL) + if (mname[0] != '/' && (cp = strchr (mname, '/')) != NULL) { /* Make the slash the new end of the string temporarily */ *cp = '\0'; @@ -240,7 +251,7 @@ do_module (db, mname, m_type, msg, callback_proc, where, val.dptr[val.dsize] = '\0'; /* If the line ends in a comment, strip it off */ - if ((cp2 = index (val.dptr, '#')) != NULL) + if ((cp2 = strchr (val.dptr, '#')) != NULL) { do *cp2-- = '\0'; @@ -282,7 +293,7 @@ do_module (db, mname, m_type, msg, callback_proc, where, value = zvalue; /* search the value for the special delimiter and save for later */ - if ((cp = index (value, CVSMODULE_SPEC)) != NULL) + if ((cp = strchr (value, CVSMODULE_SPEC)) != NULL) { *cp = '\0'; /* null out the special char */ spec_opt = cp + 1; /* save the options for later */ @@ -326,6 +337,9 @@ do_module (db, mname, m_type, msg, callback_proc, where, CVSROOTADM, CVSNULLREPOS); if (!isfile (nullrepos)) (void) mkdir (nullrepos, 0777); + if (!isdir (nullrepos)) + error (1, 0, "there is no repository %s", nullrepos); + Create_Admin (".", nullrepos, (char *) NULL, (char *) NULL); if (!noexec) { @@ -363,7 +377,7 @@ do_module (db, mname, m_type, msg, callback_proc, where, /* parse the args */ optind = 1; - while ((c = gnu_getopt (modargc, modargv, CVSMODULE_OPTS)) != -1) + while ((c = getopt (modargc, modargv, CVSMODULE_OPTS)) != -1) { switch (c) { @@ -417,9 +431,16 @@ do_module (db, mname, m_type, msg, callback_proc, where, int i; for (i = 0; i < modargc; i++) - err += do_module (db, modargv[i], m_type, msg, callback_proc, - where, shorten, local_specified, - run_module_prog, extra_arg); + { + if (strcmp (mname, modargv[i]) == 0) + error (0, 0, + "module `%s' in modules file contains infinite loop", + mname); + else + err += do_module (db, modargv[i], m_type, msg, callback_proc, + where, shorten, local_specified, + run_module_prog, extra_arg); + } if (mwhere) free (mwhere); free (zvalue); @@ -445,7 +466,7 @@ do_module (db, mname, m_type, msg, callback_proc, where, { char *next_opt; - cp = index (spec_opt, CVSMODULE_SPEC); + cp = strchr (spec_opt, CVSMODULE_SPEC); if (cp != NULL) { /* save the beginning of the next arg */ @@ -648,7 +669,7 @@ save_d (k, ks, d, ds) s_rec->status = def_status; /* Minor kluge, but general enough to maintain */ - for (cp = s_rec->rest; (cp2 = index (cp, '-')) != NULL; cp = ++cp2) + for (cp = s_rec->rest; (cp2 = strchr (cp, '-')) != NULL; cp = ++cp2) { if (*(cp2 + 1) == 's' && *(cp2 + 2) == ' ') { @@ -665,7 +686,7 @@ save_d (k, ks, d, ds) cp = s_rec->rest; /* Find comment field, clean up on all three sides & compress blanks */ - if ((cp2 = cp = index (cp, '#')) != NULL) + if ((cp2 = cp = strchr (cp, '#')) != NULL) { if (*--cp2 == ' ') *cp2 = '\0'; @@ -748,13 +769,13 @@ cat_module (status) optind = 1; wid = 0; - while ((c = gnu_getopt (argc, argv, CVSMODULE_OPTS)) != -1) + while ((c = getopt (argc, argv, CVSMODULE_OPTS)) != -1) { if (!status) { - if (c == 'a') + if (c == 'a' || c == 'l') { - (void) printf (" -a"); + (void) printf (" -%c", c); wid += 3; /* Could just set it to 3 */ } else diff --git a/gnu/usr.bin/cvs/cvs/no_diff.c b/gnu/usr.bin/cvs/cvs/no_diff.c index 4057c88..ec3e641 100644 --- a/gnu/usr.bin/cvs/cvs/no_diff.c +++ b/gnu/usr.bin/cvs/cvs/no_diff.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * No Difference * @@ -17,14 +17,17 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)no_diff.c 1.35 92/03/31"; +static char rcsid[] = "$CVSid: @(#)no_diff.c 1.39 94/10/07 $"; +USE(rcsid) #endif int -No_Difference (file, vers, entries) +No_Difference (file, vers, entries, repository, update_dir) char *file; Vers_TS *vers; List *entries; + char *repository; + char *update_dir; { Node *p; char tmp[L_tmpnam+1]; @@ -58,7 +61,7 @@ No_Difference (file, vers, entries) ts = time_stamp (file); Register (entries, file, vers->vn_user ? vers->vn_user : vers->vn_rcs, ts, - options, vers->tag, vers->date); + options, vers->tag, vers->date, (char *) 0); free (ts); /* update the entdata pointer in the vers_ts structure */ @@ -72,14 +75,21 @@ No_Difference (file, vers, entries) } else { - error (0, retcode == -1 ? errno : 0, - "could not check out revision %s of %s", vers->vn_user, file); + if (update_dir[0] == '\0') + error (0, retcode == -1 ? errno : 0, + "could not check out revision %s of %s", + vers->vn_user, file); + else + error (0, retcode == -1 ? errno : 0, + "could not check out revision %s of %s/%s", + vers->vn_user, update_dir, file); ret = -1; /* different since we couldn't tell */ } if (trace) (void) fprintf (stderr, "-> unlink(%s)\n", tmp); - (void) unlink (tmp); + if (unlink (tmp) < 0) + error (0, errno, "could not remove %s", tmp); free (options); return (ret); } diff --git a/gnu/usr.bin/cvs/cvs/parseinfo.c b/gnu/usr.bin/cvs/cvs/parseinfo.c index 65343f5..17cf1da 100644 --- a/gnu/usr.bin/cvs/cvs/parseinfo.c +++ b/gnu/usr.bin/cvs/cvs/parseinfo.c @@ -3,13 +3,14 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. */ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)parseinfo.c 1.16 92/04/10"; +static char rcsid[] = "$CVSid: @(#)parseinfo.c 1.18 94/09/23 $"; +USE(rcsid) #endif /* @@ -87,7 +88,7 @@ Parse_Info (infofile, repository, callproc, all) value = cp; /* strip the newline off the end of the value */ - if ((cp = rindex (value, '\n')) != NULL) + if ((cp = strrchr (value, '\n')) != NULL) *cp = '\0'; /* diff --git a/gnu/usr.bin/cvs/cvs/patch.c b/gnu/usr.bin/cvs/cvs/patch.c index 11134a7..69e5b09 100644 --- a/gnu/usr.bin/cvs/cvs/patch.c +++ b/gnu/usr.bin/cvs/cvs/patch.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Patch * @@ -15,24 +15,17 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)patch.c 1.50 92/04/10"; - +static char rcsid[] = "$CVSid: @(#)patch.c 1.57 94/09/30 $"; +USE(rcsid) #endif -#if __STDC__ -static SIGTYPE patch_cleanup (void); -static Dtype patch_dirproc (char *dir, char *repos, char *update_dir); -static int patch_fileproc (char *file, char *update_dir, char *repository, - List * entries, List * srcfiles); -static int patch_proc (int *pargc, char *argv[], char *xwhere, +static RETSIGTYPE patch_cleanup PROTO((void)); +static Dtype patch_dirproc PROTO((char *dir, char *repos, char *update_dir)); +static int patch_fileproc PROTO((char *file, char *update_dir, char *repository, + List * entries, List * srcfiles)); +static int patch_proc PROTO((int *pargc, char *argv[], char *xwhere, char *mwhere, char *mfile, int shorten, - int local_specified, char *mname, char *msg); -#else -static int patch_proc (); -static int patch_fileproc (); -static Dtype patch_dirproc (); -static SIGTYPE patch_cleanup (); -#endif /* __STDC__ */ + int local_specified, char *mname, char *msg)); static int force_tag_match = 1; static int patch_short = 0; @@ -77,7 +70,7 @@ patch (argc, argv) usage (patch_usage); optind = 1; - while ((c = gnu_getopt (argc, argv, "V:k:cuftsQqlRD:r:")) != -1) + while ((c = getopt (argc, argv, "V:k:cuftsQqlRD:r:")) != -1) { switch (c) { @@ -218,7 +211,7 @@ patch_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified, char path[PATH_MAX]; /* if the portion of the module is a path, put the dir part on repos */ - if ((cp = rindex (mfile, '/')) != NULL) + if ((cp = strrchr (mfile, '/')) != NULL) { *cp = '\0'; (void) strcat (repository, "/"); @@ -264,7 +257,7 @@ patch_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified, /* start the recursion processor */ err = start_recursion (patch_fileproc, (int (*) ()) NULL, patch_dirproc, (int (*) ()) NULL, *pargc - 1, argv + 1, local, - which, 0, 1, where, 1); + which, 0, 1, where, 1, 1); return (err); } @@ -282,6 +275,7 @@ patch_fileproc (file, update_dir, repository, entries, srcfiles) List *entries; List *srcfiles; { + struct utimbuf t; char *vers_tag, *vers_head; char rcsspace[PATH_MAX]; char *rcs = rcsspace; @@ -296,7 +290,6 @@ patch_fileproc (file, update_dir, repository, entries, srcfiles) char *cp1, *cp2, *commap; FILE *fp; - /* find the parsed rcs file */ p = findnode (srcfiles, file); if (p == NULL) @@ -374,6 +367,10 @@ patch_fileproc (file, update_dir, repository, entries, srcfiles) ret = 1; goto out; } + memset ((char *) &t, 0, sizeof (t)); + if ((t.actime = t.modtime = RCS_getrevtime (rcsfile, vers_tag, + (char *) 0, 0)) != -1) + (void) utime (tmpfile1, &t); } else if (toptwo_diffs) { @@ -392,6 +389,9 @@ patch_fileproc (file, update_dir, repository, entries, srcfiles) ret = 1; goto out; } + if ((t.actime = t.modtime = RCS_getrevtime (rcsfile, vers_head, + (char *) 0, 0)) != -1) + (void) utime (tmpfile2, &t); } run_setup ("%s -%c", DIFF, unidiff ? 'u' : 'c'); run_arg (tmpfile1); @@ -409,6 +409,15 @@ patch_fileproc (file, update_dir, repository, entries, srcfiles) * lines of the diff output file, and munge them to include more * reasonable file names that "patch" will understand. */ + + /* Output an "Index:" line for patch to use */ + (void) fflush (stdout); + if (update_dir[0]) + (void) printf ("Index: %s/%s\n", update_dir, file); + else + (void) printf ("Index: %s\n", file); + (void) fflush (stdout); + fp = open_file (tmpfile3, "r"); if (fgets (line1, sizeof (line1), fp) == NULL || fgets (line2, sizeof (line2), fp) == NULL) @@ -423,8 +432,8 @@ patch_fileproc (file, update_dir, repository, entries, srcfiles) { if (strncmp (line1, "*** ", 4) != 0 || strncmp (line2, "--- ", 4) != 0 || - (cp1 = index (line1, '\t')) == NULL || - (cp2 = index (line2, '\t')) == NULL) + (cp1 = strchr (line1, '\t')) == NULL || + (cp2 = strchr (line2, '\t')) == NULL) { error (0, 0, "invalid diff header for %s", rcs); ret = 1; @@ -436,8 +445,8 @@ patch_fileproc (file, update_dir, repository, entries, srcfiles) { if (strncmp (line1, "--- ", 4) != 0 || strncmp (line2, "+++ ", 4) != 0 || - (cp1 = index (line1, '\t')) == NULL || - (cp2 = index (line2, '\t')) == NULL) + (cp1 = strchr (line1, '\t')) == NULL || + (cp2 = strchr (line2, '\t')) == NULL) { error (0, 0, "invalid unidiff header for %s", rcs); ret = 1; @@ -451,7 +460,7 @@ patch_fileproc (file, update_dir, repository, entries, srcfiles) (void) strcpy (strippath, REPOS_STRIP); if (strncmp (rcs, strippath, strlen (strippath)) == 0) rcs += strlen (strippath); - commap = rindex (rcs, ','); + commap = strrchr (rcs, ','); *commap = '\0'; if (vers_tag != NULL) { @@ -511,7 +520,7 @@ patch_dirproc (dir, repos, update_dir) /* * Clean up temporary files */ -static SIGTYPE +static RETSIGTYPE patch_cleanup () { if (tmpfile1[0] != '\0') diff --git a/gnu/usr.bin/cvs/cvs/rcs.c b/gnu/usr.bin/cvs/cvs/rcs.c index e882b8c..2c424d9 100644 --- a/gnu/usr.bin/cvs/cvs/rcs.c +++ b/gnu/usr.bin/cvs/cvs/rcs.c @@ -2,7 +2,7 @@ * Copyright (c) 1992, Brian Berliner and Jeff Polk * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * The routines contained in this file do all the rcs file parsing and * manipulation @@ -11,37 +11,54 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)rcs.c 1.28 92/03/31"; +static char rcsid[] = "$CVSid: @(#)rcs.c 1.40 94/10/07 $"; +USE(rcsid) #endif -#if __STDC__ -static char *RCS_getbranch (RCSNode * rcs, char *tag, int force_tag_match); -static char *RCS_getdatebranch (RCSNode * rcs, char *date, char *branch); -static int getrcskey (FILE * fp, char **keyp, char **valp); -static int parse_rcs_proc (Node * file); -static int checkmagic_proc (Node *p); -static void do_branches (List * list, char *val); -static void do_symbols (List * list, char *val); -static void null_delproc (Node * p); -static void rcsnode_delproc (Node * p); -static void rcsvers_delproc (Node * p); -#else -static int parse_rcs_proc (); -static int checkmagic_proc (); -static void rcsnode_delproc (); -static void rcsvers_delproc (); -static void null_delproc (); -static int getrcskey (); -static void do_symbols (); -static void do_branches (); -static char *RCS_getbranch (); -static char *RCS_getdatebranch (); -#endif /* __STDC__ */ +static RCSNode *RCS_parsercsfile_i PROTO((FILE * fp, char *rcsfile)); +static char *RCS_getdatebranch PROTO((RCSNode * rcs, char *date, char *branch)); +static int getrcskey PROTO((FILE * fp, char **keyp, char **valp)); +static int parse_rcs_proc PROTO((Node * file, void *closure)); +static int checkmagic_proc PROTO((Node *p, void *closure)); +static void do_branches PROTO((List * list, char *val)); +static void do_symbols PROTO((List * list, char *val)); +static void null_delproc PROTO((Node * p)); +static void rcsnode_delproc PROTO((Node * p)); +static void rcsvers_delproc PROTO((Node * p)); static List *rcslist; static char *repository; /* + * We don't want to use isspace() from the C library because: + * + * 1. The definition of "whitespace" in RCS files includes ASCII + * backspace, but the C locale doesn't. + * 2. isspace is an very expensive function call in some implementations + * due to the addition of wide character support. + */ +static const char spacetab[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, /* 0x00 - 0x0f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 - 0x1f */ + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 - 0x2f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 - 0x3f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x4f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 - 0x5f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x8f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x7f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 - 0xaf */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 - 0xbf */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 - 0xcf */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 - 0xdf */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 - 0xef */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0xf0 - 0xff */ +}; + +#define whitespace(c) (spacetab[c] != 0) + +/* * Parse all the rcs files specified and return a list */ List * @@ -54,7 +71,7 @@ RCS_parsefiles (files, xrepos) rcslist = getlist (); /* walk the list parsing files */ - if (walklist (files, parse_rcs_proc) != 0) + if (walklist (files, parse_rcs_proc, NULL) != 0) { /* free the list and return NULL on error */ dellist (&rcslist); @@ -69,10 +86,10 @@ RCS_parsefiles (files, xrepos) * Parse an rcs file into a node on the rcs list */ static int -parse_rcs_proc (file) +parse_rcs_proc (file, closure) Node *file; + void *closure; { - Node *p; RCSNode *rdata; /* parse the rcs file into rdata */ @@ -80,18 +97,33 @@ parse_rcs_proc (file) /* if we got a valid RCSNode back, put it on the list */ if (rdata != (RCSNode *) NULL) - { - p = getnode (); - p->key = xstrdup (file->key); - p->delproc = rcsnode_delproc; - p->type = RCSNODE; - p->data = (char *) rdata; - (void) addnode (rcslist, p); - } + RCS_addnode (file->key, rdata, rcslist); + return (0); } /* + * Add an RCSNode to a list of them. + */ + +void +RCS_addnode (file, rcs, list) + char *file; + RCSNode *rcs; + List *list; +{ + Node *p; + + p = getnode (); + p->key = xstrdup (file); + p->delproc = rcsnode_delproc; + p->type = RCSNODE; + p->data = (char *) rcs; + (void) addnode (list, p); +} + + +/* * Parse an rcsfile given a user file name and a repository */ RCSNode * @@ -100,43 +132,46 @@ RCS_parse (file, repos) char *repos; { RCSNode *rcs; + FILE *fp; char rcsfile[PATH_MAX]; (void) sprintf (rcsfile, "%s/%s%s", repos, file, RCSEXT); - if (!isreadable (rcsfile)) + if ((fp = fopen (rcsfile, "r")) != NULL) { - (void) sprintf (rcsfile, "%s/%s/%s%s", repos, CVSATTIC, - file, RCSEXT); - if (!isreadable (rcsfile)) - return (NULL); - rcs = RCS_parsercsfile (rcsfile); + rcs = RCS_parsercsfile_i(fp, rcsfile); + if (rcs != NULL) + rcs->flags |= VALID; + + fclose (fp); + return (rcs); + } + + (void) sprintf (rcsfile, "%s/%s/%s%s", repos, CVSATTIC, file, RCSEXT); + if ((fp = fopen (rcsfile, "r")) != NULL) + { + rcs = RCS_parsercsfile_i(fp, rcsfile); if (rcs != NULL) { rcs->flags |= INATTIC; rcs->flags |= VALID; } + + fclose (fp); return (rcs); } - rcs = RCS_parsercsfile (rcsfile); - if (rcs != NULL) - rcs->flags |= VALID; - return (rcs); + + return (NULL); } /* - * Do the real work of parsing an RCS file + * Parse a specific rcsfile. */ RCSNode * RCS_parsercsfile (rcsfile) char *rcsfile; { - Node *q, *r; - RCSNode *rdata; - RCSVers *vnode; - int n; - char *cp; - char *key, *value; FILE *fp; + RCSNode *rcs; /* open the rcsfile */ if ((fp = fopen (rcsfile, "r")) == NULL) @@ -145,9 +180,30 @@ RCS_parsercsfile (rcsfile) return (NULL); } + rcs = RCS_parsercsfile_i (fp, rcsfile); + + fclose (fp); + return (rcs); +} + +/* + * Do the real work of parsing an RCS file + */ +static RCSNode * +RCS_parsercsfile_i (fp, rcsfile) + FILE *fp; + char *rcsfile; +{ + Node *q, *r; + RCSNode *rdata; + RCSVers *vnode; + int n; + char *cp; + char *key, *value; + /* make a node */ rdata = (RCSNode *) xmalloc (sizeof (RCSNode)); - bzero ((char *) rdata, sizeof (RCSNode)); + memset ((char *) rdata, 0, sizeof (RCSNode)); rdata->refcount = 1; rdata->path = xstrdup (rcsfile); rdata->versions = getlist (); @@ -161,14 +217,24 @@ RCS_parsercsfile (rcsfile) { /* get the next key/value pair */ - /* if key is NULL here, then the file is missing some headers */ + /* if key is NULL here, then the file is missing some headers + or we had trouble reading the file. */ if (getrcskey (fp, &key, &value) == -1 || key == NULL) { + if (!really_quiet) - error (0, 0, "`%s' does not appear to be a valid rcs file", - rcsfile); + { + if (ferror(fp)) + { + error (1, 0, "error reading `%s'", rcsfile); + } + else + { + error (0, 0, "`%s' does not appear to be a valid rcs file", + rcsfile); + } + } freercsnode (&rdata); - (void) fclose (fp); return (NULL); } @@ -184,7 +250,7 @@ RCS_parsercsfile (rcsfile) if ((numdots (rdata->branch) & 1) != 0) { /* turn it into a branch if it's a revision */ - cp = rindex (rdata->branch, '.'); + cp = strrchr (rdata->branch, '.'); *cp = '\0'; } continue; @@ -193,9 +259,7 @@ RCS_parsercsfile (rcsfile) { if (value != NULL) { - /* if there are tags, set up the tag list */ - rdata->symbols = getlist (); - do_symbols (rdata->symbols, value); + rdata->symbols_data = xstrdup(value); continue; } } @@ -225,7 +289,7 @@ RCS_parsercsfile (rcsfile) /* grab the value of the date from value */ valp = value + strlen (RCSDATE);/* skip the "date" keyword */ - while (isspace (*valp)) /* take space off front of value */ + while (whitespace (*valp)) /* take space off front of value */ valp++; (void) strcpy (date, valp); @@ -237,7 +301,7 @@ RCS_parsercsfile (rcsfile) q->delproc = rcsvers_delproc; r->delproc = null_delproc; q->data = r->data = xmalloc (sizeof (RCSVers)); - bzero (q->data, sizeof (RCSVers)); + memset (q->data, 0, sizeof (RCSVers)); vnode = (RCSVers *) q->data; /* fill in the version before we forget it */ @@ -290,7 +354,6 @@ RCS_parsercsfile (rcsfile) break; } - (void) fclose (fp); return (rdata); } @@ -325,6 +388,8 @@ freercsnode (rnodep) dellist (&(*rnodep)->dates); if ((*rnodep)->symbols != (List *) NULL) dellist (&(*rnodep)->symbols); + if ((*rnodep)->symbols_data != (char *) NULL) + free ((*rnodep)->symbols_data); if ((*rnodep)->head != (char *) NULL) free ((*rnodep)->head); if ((*rnodep)->branch != (char *) NULL) @@ -405,14 +470,14 @@ getrcskey (fp, keyp, valp) *valp = (char *) NULL; return (-1); } - if (!isspace (c)) + if (!whitespace (c)) break; } /* fill in key */ cur = key; max = key + keysize; - while (!isspace (c) && c != ';') + while (!whitespace (c) && c != ';') { if (cur < max) *cur++ = c; @@ -432,6 +497,14 @@ getrcskey (fp, keyp, valp) return (-1); } } + if (cur >= max) + { + key = xrealloc (key, keysize + ALLOCINCR); + cur = key + keysize; + keysize += ALLOCINCR; + max = key + keysize; + } + *cur = '\0'; /* if we got "desc", we are done with the file */ @@ -538,10 +611,10 @@ getrcskey (fp, keyp, valp) */ /* whitespace with white set means compress it out */ - if (white && isspace (c)) + if (white && whitespace (c)) continue; - if (isspace (c)) + if (whitespace (c)) { /* make c a space and set white */ white = 1; @@ -568,7 +641,16 @@ getrcskey (fp, keyp, valp) /* terminate the string */ if (cur) + { + if (cur >= max) + { + value = xrealloc (value, valsize + ALLOCINCR); + cur = value + valsize; + valsize += ALLOCINCR; + max = value + valsize; + } *cur = '\0'; + } /* if the string is empty, make it null */ if (value && *value != '\0') @@ -594,7 +676,7 @@ do_symbols (list, val) for (;;) { /* skip leading whitespace */ - while (isspace (*cp)) + while (whitespace (*cp)) cp++; /* if we got to the end, we are done */ @@ -603,10 +685,10 @@ do_symbols (list, val) /* split it up into tag and rev */ tag = cp; - cp = index (cp, ':'); + cp = strchr (cp, ':'); *cp++ = '\0'; rev = cp; - while (!isspace (*cp) && *cp != '\0') + while (!whitespace (*cp) && *cp != '\0') cp++; if (*cp != '\0') *cp++ = '\0'; @@ -634,7 +716,7 @@ do_branches (list, val) for (;;) { /* skip leading whitespace */ - while (isspace (*cp)) + while (whitespace (*cp)) cp++; /* if we got to the end, we are done */ @@ -643,7 +725,7 @@ do_branches (list, val) /* find the end of this branch */ branch = cp; - while (!isspace (*cp) && *cp != '\0') + while (!whitespace (*cp) && *cp != '\0') cp++; if (*cp != '\0') *cp++ = '\0'; @@ -686,7 +768,7 @@ RCS_getversion (rcs, tag, date, force_tag_match) if (tagrev == NULL) return ((char *) NULL); - if ((cp = rindex (tagrev, '.')) != NULL) + if ((cp = strrchr (tagrev, '.')) != NULL) *cp = '\0'; rev = RCS_getdatebranch (rcs, date, tagrev); free (tagrev); @@ -733,8 +815,9 @@ RCS_gettag (rcs, tag, force_tag_match) /* If we got a symbolic tag, resolve it to a numeric */ if (rcs == NULL) p = NULL; - else - p = findnode (rcs->symbols, tag); + else { + p = findnode (RCS_symbols(rcs), tag); + } if (p != NULL) { int dots; @@ -750,7 +833,7 @@ RCS_gettag (rcs, tag, force_tag_match) dots = numdots (tag); if (dots > 2 && (dots & 1) != 0) { - branch = rindex (tag, '.'); + branch = strrchr (tag, '.'); cp = branch++ - 1; while (*cp != '.') cp--; @@ -874,7 +957,7 @@ RCS_magicrev (rcs, rev) (void) sprintf (xrev, "%s.%d.%d", rev, RCS_MAGIC_BRANCH, rev_num); /* walk the symbols list to see if a magic one already exists */ - if (walklist (rcs->symbols, checkmagic_proc) != 0) + if (walklist (RCS_symbols(rcs), checkmagic_proc, NULL) != 0) continue; /* we found a free magic branch. Claim it as ours */ @@ -887,8 +970,9 @@ RCS_magicrev (rcs, rev) * Returns 0 if the symbol does not match, 1 if it does. */ static int -checkmagic_proc (p) +checkmagic_proc (p, closure) Node *p; + void *closure; { if (strcmp (check_rev, p->data) == 0) return (1); @@ -897,9 +981,9 @@ checkmagic_proc (p) } /* - * Returns non-zero if the specified revision number or symbolic tag - * resolves to a "branch" within the rcs file. We do take into account - * any magic branches as well. + * Given a list of RCSNodes, returns non-zero if the specified + * revision number or symbolic tag resolves to a "branch" within the + * rcs file. */ int RCS_isbranch (file, rev, srcfiles) @@ -907,7 +991,6 @@ RCS_isbranch (file, rev, srcfiles) char *rev; List *srcfiles; { - int dots; Node *p; RCSNode *rcs; @@ -922,7 +1005,27 @@ RCS_isbranch (file, rev, srcfiles) /* now, look for a match in the symbols list */ rcs = (RCSNode *) p->data; - p = findnode (rcs->symbols, rev); + return (RCS_nodeisbranch (rev, rcs)); +} + +/* + * Given an RCSNode, returns non-zero if the specified revision number + * or symbolic tag resolves to a "branch" within the rcs file. We do + * take into account any magic branches as well. + */ +int +RCS_nodeisbranch (rev, rcs) + char *rev; + RCSNode *rcs; +{ + int dots; + Node *p; + + /* numeric revisions are easy -- even number of dots is a branch */ + if (isdigit (*rev)) + return ((numdots (rev) & 1) == 0); + + p = findnode (RCS_symbols(rcs), rev); if (p == NULL) return (0); dots = numdots (p->data); @@ -933,7 +1036,7 @@ RCS_isbranch (file, rev, srcfiles) if (dots > 2) { char *magic; - char *branch = rindex (p->data, '.'); + char *branch = strrchr (p->data, '.'); char *cp = branch - 1; while (*cp != '.') cp--; @@ -972,7 +1075,7 @@ RCS_whatbranch (file, rev, srcfiles) /* now, look for a match in the symbols list */ rcs = (RCSNode *) p->data; - p = findnode (rcs->symbols, rev); + p = findnode (RCS_symbols(rcs), rev); if (p == NULL) return ((char *) NULL); dots = numdots (p->data); @@ -983,7 +1086,7 @@ RCS_whatbranch (file, rev, srcfiles) if (dots > 2) { char *magic; - char *branch = rindex (p->data, '.'); + char *branch = strrchr (p->data, '.'); char *cp = branch++ - 1; while (*cp != '.') cp--; @@ -1008,7 +1111,7 @@ RCS_whatbranch (file, rev, srcfiles) * Get the head of the specified branch. If the branch does not exist, * return NULL or RCS_head depending on force_tag_match */ -static char * +char * RCS_getbranch (rcs, tag, force_tag_match) RCSNode *rcs; char *tag; @@ -1025,7 +1128,7 @@ RCS_getbranch (rcs, tag, force_tag_match) return ((char *) NULL); /* find out if the tag contains a dot, or is on the trunk */ - cp = rindex (tag, '.'); + cp = strrchr (tag, '.'); /* trunk processing is the special case */ if (cp == NULL) @@ -1237,7 +1340,7 @@ RCS_getdatebranch (rcs, date, branch) /* look up the first revision on the branch */ xrev = xstrdup (branch); - cp = rindex (xrev, '.'); + cp = strrchr (xrev, '.'); if (cp == NULL) { free (xrev); @@ -1374,6 +1477,20 @@ RCS_getrevtime (rcs, rev, date, fudge) return (revdate); } +List * +RCS_symbols(rcs) + RCSNode *rcs; +{ + if (rcs->symbols_data) { + rcs->symbols = getlist (); + do_symbols (rcs->symbols, rcs->symbols_data); + free(rcs->symbols_data); + rcs->symbols_data = NULL; + } + + return rcs->symbols; +} + /* * The argument ARG is the getopt remainder of the -k option specified on the * command line. This function returns malloc'ed space that can be used @@ -1439,7 +1556,7 @@ RCS_check_tag (tag) if (!isgraph (*cp)) error (1, 0, "tag `%s' has non-visible graphic characters", tag); - if (index (invalid, *cp)) + if (strchr (invalid, *cp)) error (1, 0, "tag `%s' must not contain the characters `%s'", tag, invalid); } @@ -1447,3 +1564,4 @@ RCS_check_tag (tag) else error (1, 0, "tag `%s' must start with a letter", tag); } + diff --git a/gnu/usr.bin/cvs/cvs/rcs.h b/gnu/usr.bin/cvs/cvs/rcs.h index ba5bdae..6d6ecd4 100644 --- a/gnu/usr.bin/cvs/cvs/rcs.h +++ b/gnu/usr.bin/cvs/cvs/rcs.h @@ -1,11 +1,11 @@ -/* @(#)rcs.h 1.14 92/03/31 */ +/* $CVSid: @(#)rcs.h 1.18 94/09/23 $ */ /* * Copyright (c) 1992, Brian Berliner and Jeff Polk * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * RCS source control definitions needed by rcs.c and friends */ @@ -19,6 +19,7 @@ #define RCS_RCSMERGE "rcsmerge" #define RCS_MERGE_PAT "^>>>>>>> " /* runs "grep" with this pattern */ #define RCSEXT ",v" +#define RCSPAT "*,v" #define RCSHEAD "head" #define RCSBRANCH "branch" #define RCSSYMBOLS "symbols" @@ -39,6 +40,7 @@ struct rcsnode char *path; char *head; char *branch; + char *symbols_data; List *symbols; List *versions; List *dates; @@ -66,37 +68,23 @@ typedef struct rcsversnode RCSVers; /* * exported interfaces */ -#if __STDC__ -List *RCS_parsefiles (List * files, char *xrepos); -RCSNode *RCS_parse (char *file, char *repos); -RCSNode *RCS_parsercsfile (char *rcsfile); -char *RCS_check_kflag (char *arg); -char *RCS_getdate (RCSNode * rcs, char *date, int force_tag_match); -char *RCS_gettag (RCSNode * rcs, char *tag, int force_tag_match); -char *RCS_getversion (RCSNode * rcs, char *tag, char *date, - int force_tag_match); -char *RCS_magicrev (RCSNode *rcs, char *rev); -int RCS_isbranch (char *file, char *rev, List *srcfiles); -char *RCS_whatbranch (char *file, char *tag, List *srcfiles); -char *RCS_head (RCSNode * rcs); -int RCS_datecmp (char *date1, char *date2); -time_t RCS_getrevtime (RCSNode * rcs, char *rev, char *date, int fudge); -void RCS_check_tag (char *tag); -void freercsnode (RCSNode ** rnodep); -#else -List *RCS_parsefiles (); -RCSNode *RCS_parse (); -char *RCS_head (); -char *RCS_getversion (); -char *RCS_magicrev (); -int RCS_isbranch (); -char *RCS_whatbranch (); -char *RCS_gettag (); -char *RCS_getdate (); -char *RCS_check_kflag (); -void RCS_check_tag (); -time_t RCS_getrevtime (); -RCSNode *RCS_parsercsfile (); -int RCS_datecmp (); -void freercsnode (); -#endif /* __STDC__ */ +List *RCS_parsefiles PROTO((List * files, char *xrepos)); +RCSNode *RCS_parse PROTO((char *file, char *repos)); +RCSNode *RCS_parsercsfile PROTO((char *rcsfile)); +char *RCS_check_kflag PROTO((char *arg)); +char *RCS_getdate PROTO((RCSNode * rcs, char *date, int force_tag_match)); +char *RCS_gettag PROTO((RCSNode * rcs, char *tag, int force_tag_match)); +char *RCS_getversion PROTO((RCSNode * rcs, char *tag, char *date, + int force_tag_match)); +char *RCS_magicrev PROTO((RCSNode *rcs, char *rev)); +int RCS_isbranch PROTO((char *file, char *rev, List *srcfiles)); +int RCS_nodeisbranch PROTO((char *rev, RCSNode *rcs)); +char *RCS_whatbranch PROTO((char *file, char *tag, List *srcfiles)); +char *RCS_head PROTO((RCSNode * rcs)); +int RCS_datecmp PROTO((char *date1, char *date2)); +time_t RCS_getrevtime PROTO((RCSNode * rcs, char *rev, char *date, int fudge)); +List *RCS_symbols PROTO((RCSNode *rcs)); +void RCS_check_tag PROTO((char *tag)); +void freercsnode PROTO((RCSNode ** rnodep)); +void RCS_addnode PROTO((char *file, RCSNode *rcs, List *list)); +char *RCS_getbranch PROTO((RCSNode * rcs, char *tag, int force_tag_match)); diff --git a/gnu/usr.bin/cvs/cvs/recurse.c b/gnu/usr.bin/cvs/cvs/recurse.c index 82301d5..5ea344c 100644 --- a/gnu/usr.bin/cvs/cvs/recurse.c +++ b/gnu/usr.bin/cvs/cvs/recurse.c @@ -2,7 +2,7 @@ * Copyright (c) 1992, Brian Berliner and Jeff Polk * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * General recursion handler * @@ -11,18 +11,15 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)recurse.c 1.22 92/04/10"; +static char rcsid[] = "$CVSid: @(#)recurse.c 1.31 94/09/30 $"; +USE(rcsid) #endif -#if __STDC__ -static int do_dir_proc (Node * p); -static int do_file_proc (Node * p); -static void addlist (List ** listp, char *key); -#else -static int do_file_proc (); -static int do_dir_proc (); -static void addlist (); -#endif /* __STDC__ */ +static int do_dir_proc PROTO((Node * p, void *closure)); +static int do_file_proc PROTO((Node * p, void *closure)); +static void addlist PROTO((List ** listp, char *key)); +static int unroll_files_proc PROTO((Node *p, void *closure)); +static void addfile PROTO((List **listp, char *dir, char *file)); /* @@ -41,17 +38,35 @@ static char update_dir[PATH_MAX]; static char *repository = NULL; static List *entries = NULL; static List *srcfiles = NULL; -static List *filelist = NULL; -static List *dirlist = NULL; + +static List *filelist = NULL; /* holds list of files on which to operate */ +static List *dirlist = NULL; /* holds list of directories on which to operate */ + +struct recursion_frame { + int (*fileproc)(); + int (*filesdoneproc) (); + Dtype (*direntproc) (); + int (*dirleaveproc) (); + Dtype flags; + int which; + int aflag; + int readlock; + int dosrcs; +}; /* - * Called to start a recursive command Command line arguments are processed - * if present, otherwise the local directory is processed. + * Called to start a recursive command. + * + * Command line arguments dictate the directories and files on which + * we operate. In the special case of no arguments, we default to + * ".". + * + * The general algorythm is as follows. */ int start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc, argc, argv, local, which, aflag, readlock, - update_preload, dosrcs) + update_preload, dosrcs, wd_is_repos) int (*fileproc) (); int (*filesdoneproc) (); Dtype (*direntproc) (); @@ -64,9 +79,12 @@ start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc, int readlock; char *update_preload; int dosrcs; + int wd_is_repos; /* Set if caller has already cd'd to the repository */ { int i, err = 0; Dtype flags; + List *files_by_dir = NULL; + struct recursion_frame frame; if (update_preload == NULL) update_dir[0] = '\0'; @@ -89,7 +107,8 @@ start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc, if (srcfiles) dellist (&srcfiles); if (filelist) - dellist (&filelist); + dellist (&filelist); /* FIXME-krp: no longer correct. */ +/* FIXME-krp: clean up files_by_dir */ if (dirlist) dellist (&dirlist); @@ -111,139 +130,128 @@ start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc, err += do_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc, flags, which, aflag, readlock, dosrcs); + return(err); } - else - { - /* - * There were arguments, so we have to handle them by hand. To do - * that, we set up the filelist and dirlist with the arguments and - * call do_recursion. do_recursion recognizes the fact that the - * lists are non-null when it starts and doesn't update them - */ - /* look for args with /-s in them */ - for (i = 0; i < argc; i++) - if (index (argv[i], '/') != NULL) - break; + /* + * There were arguments, so we have to handle them by hand. To do + * that, we set up the filelist and dirlist with the arguments and + * call do_recursion. do_recursion recognizes the fact that the + * lists are non-null when it starts and doesn't update them. + * + * explicitly named directories are stored in dirlist. + * explicitly named files are stored in filelist. + * other possibility is named entities whicha are not currently in + * the working directory. + */ + + for (i = 0; i < argc; i++) + { + /* if this argument is a directory, then add it to the list of + directories. */ - /* if we didn't find any hard one's, do it the easy way */ - if (i == argc) + if (isdir(argv[i])) + addlist (&dirlist, argv[i]); + else { - /* set up the lists */ - for (i = 0; i < argc; i++) + /* otherwise, split argument into directory and component names. */ + char *dir; + char *comp; + char tmp[PATH_MAX]; + char *file_to_try; + + dir = xstrdup (argv[i]); + if ((comp = strrchr (dir, '/')) == NULL) { - if (isdir (argv[i])) - addlist (&dirlist, argv[i]); - else - { - if (isdir (CVSADM) || isdir (OCVSADM)) - { - char *repos; - char tmp[PATH_MAX]; - - repos = Name_Repository ((char *) NULL, update_dir); - (void) sprintf (tmp, "%s/%s", repos, argv[i]); - if (isdir (tmp)) - addlist (&dirlist, argv[i]); - else - addlist (&filelist, argv[i]); - free (repos); - } - else - addlist (&filelist, argv[i]); - } + /* no dir component. What we have is an implied "./" */ + comp = dir; + dir = xstrdup("."); } + else + { + char *p = comp; - /* we aren't recursive if no directories were specified */ - if (dirlist == NULL) - local = 1; + *p++ = '\0'; + comp = xstrdup (p); + } - /* process the lists */ - err += do_recursion (fileproc, filesdoneproc, direntproc, - dirleaveproc, flags, which, aflag, - readlock, dosrcs); - } - /* otherwise - do it the hard way */ - else - { - char *cp; - char *dir = (char *) NULL; - char *comp = (char *) NULL; - char *oldupdate = (char *) NULL; - char savewd[PATH_MAX]; + /* if this argument exists as a file in the current + working directory tree, then add it to the files list. */ - if (getwd (savewd) == NULL) - error (1, 0, "could not get working directory: %s", savewd); + if (wd_is_repos) + { + /* If doing rtag, we've done a chdir to the repository. */ + sprintf (tmp, "%s%s", argv[i], RCSEXT); + file_to_try = tmp; + } + else + file_to_try = argv[i]; - for (i = 0; i < argc; i++) + if(isfile(file_to_try)) + addfile (&files_by_dir, dir, comp); + else if (isdir (dir)) { - /* split the arg into the dir and component parts */ - dir = xstrdup (argv[i]); - if ((cp = rindex (dir, '/')) != NULL) + if (isdir (CVSADM) || isdir (OCVSADM)) { - *cp = '\0'; - comp = xstrdup (cp + 1); - oldupdate = xstrdup (update_dir); - if (update_dir[0] != '\0') + /* otherwise, look for it in the repository. */ + char *save_update_dir; + char *repos; + + /* save & set (aka push) update_dir */ + save_update_dir = xstrdup (update_dir); + + if (*update_dir != '\0') (void) strcat (update_dir, "/"); - (void) strcat (update_dir, dir); - } - else - { - comp = xstrdup (dir); - if (dir) - free (dir); - dir = (char *) NULL; - } - - /* chdir to the appropriate place if necessary */ - if (dir && chdir (dir) < 0) - error (1, errno, "could not chdir to %s", dir); - /* set up the list */ - if (isdir (comp)) - addlist (&dirlist, comp); - else - { - if (isdir (CVSADM) || isdir (OCVSADM)) - { - char *repos; - char tmp[PATH_MAX]; - - repos = Name_Repository ((char *) NULL, update_dir); - (void) sprintf (tmp, "%s/%s", repos, comp); - if (isdir (tmp)) - addlist (&dirlist, comp); - else - addlist (&filelist, comp); - free (repos); - } + (void) strcat (update_dir, dir); + + /* look for it in the repository. */ + repos = Name_Repository (dir, update_dir); + (void) sprintf (tmp, "%s/%s", repos, comp); + + if (isdir(tmp)) + addlist (&dirlist, argv[i]); else - addlist (&filelist, comp); - } - - /* do the recursion */ - err += do_recursion (fileproc, filesdoneproc, direntproc, - dirleaveproc, flags, which, - aflag, readlock, dosrcs); + addfile (&files_by_dir, dir, comp); - /* chdir back and fix update_dir if necessary */ - if (dir && chdir (savewd) < 0) - error (1, errno, "could not chdir to %s", dir); - if (oldupdate) - { - (void) strcpy (update_dir, oldupdate); - free (oldupdate); + (void) sprintf (update_dir, "%s", save_update_dir); + free (save_update_dir); } - + else + addfile (&files_by_dir, dir, comp); } - if (dir) - free (dir); - if (comp) - free (comp); + else + error (1, 0, "no such directory `%s'", dir); + + free (dir); + free (comp); } } + + /* At this point we have looped over all named arguments and built + a coupla lists. Now we unroll the lists, setting up and + calling do_recursion. */ + + frame.fileproc = fileproc; + frame.filesdoneproc = filesdoneproc; + frame.direntproc = direntproc; + frame.dirleaveproc = dirleaveproc; + frame.flags = flags; + frame.which = which; + frame.aflag = aflag; + frame.readlock = readlock; + frame.dosrcs = dosrcs; + err += walklist (files_by_dir, unroll_files_proc, (void *) &frame); + + /* then do_recursion on the dirlist. */ + if (dirlist != NULL) + err += do_recursion (frame.fileproc, frame.filesdoneproc, + frame.direntproc, frame.dirleaveproc, + frame.flags, frame.which, frame.aflag, + frame.readlock, frame.dosrcs); + + return (err); } @@ -360,7 +368,7 @@ do_recursion (xfileproc, xfilesdoneproc, xdirentproc, xdirleaveproc, srcfiles = (List *) NULL; /* process the files */ - err += walklist (filelist, do_file_proc); + err += walklist (filelist, do_file_proc, NULL); /* unlock it */ if (readlock) @@ -378,7 +386,7 @@ do_recursion (xfileproc, xfilesdoneproc, xdirentproc, xdirleaveproc, /* process the directories (if necessary) */ if (dirlist != NULL) - err += walklist (dirlist, do_dir_proc); + err += walklist (dirlist, do_dir_proc, NULL); #ifdef notdef else if (dirleaveproc != NULL) err += dirleaveproc(".", err, "."); @@ -399,8 +407,9 @@ do_recursion (xfileproc, xfilesdoneproc, xdirentproc, xdirleaveproc, * Process each of the files in the list with the callback proc */ static int -do_file_proc (p) +do_file_proc (p, closure) Node *p; + void *closure; { if (fileproc != NULL) return (fileproc (p->key, update_dir, repository, entries, srcfiles)); @@ -412,8 +421,9 @@ do_file_proc (p) * Process each of the directories in the list (recursing as we go) */ static int -do_dir_proc (p) +do_dir_proc (p, closure) Node *p; + void *closure; { char *dir = p->key; char savewd[PATH_MAX]; @@ -508,7 +518,7 @@ do_dir_proc (p) } /* put back update_dir */ - if ((cp = rindex (update_dir, '/')) != NULL) + if ((cp = strrchr (update_dir, '/')) != NULL) *cp = '\0'; else update_dir[0] = '\0'; @@ -517,7 +527,7 @@ do_dir_proc (p) } /* - * Add a node to a list allocating the list if necessary + * Add a node to a list allocating the list if necessary. */ static void addlist (listp, key) @@ -531,5 +541,87 @@ addlist (listp, key) p = getnode (); p->type = FILES; p->key = xstrdup (key); - (void) addnode (*listp, p); + if (addnode (*listp, p) != 0) + freenode (p); +} + +static void +addfile (listp, dir, file) + List **listp; + char *dir; + char *file; +{ + Node *n; + + /* add this dir. */ + (void) addlist (listp, dir); + + n = findnode (*listp, dir); + if (n == NULL) + { + error (1, 0, "can't find recently added dir node `%s' in start_recursion.", + dir); + } + + n->type = DIRS; + addlist ((List **) &n->data, file); + return; +} + +static int +unroll_files_proc (p, closure) + Node *p; + void *closure; +{ + Node *n; + struct recursion_frame *frame = (struct recursion_frame *) closure; + int err = 0; + List *save_dirlist; + char savewd[PATH_MAX]; + char *save_update_dir = NULL; + + /* if this dir was also an explicitly named argument, then skip + it. We'll catch it later when we do dirs. */ + n = findnode (dirlist, p->key); + if (n != NULL) + return (0); + + /* otherwise, call dorecusion for this list of files. */ + filelist = (List *) p->data; + save_dirlist = dirlist; + dirlist = NULL; + + if (strcmp(p->key, ".") != 0) + { + if (getwd (savewd) == NULL) + error (1, 0, "could not get working directory: %s", savewd); + + if (chdir (p->key) < 0) + error (1, errno, "could not chdir to %s", p->key); + + save_update_dir = xstrdup (update_dir); + + if (*update_dir != '\0') + (void) strcat (update_dir, "/"); + + (void) strcat (update_dir, p->key); + } + + err += do_recursion (frame->fileproc, frame->filesdoneproc, + frame->direntproc, frame->dirleaveproc, + frame->flags, frame->which, frame->aflag, + frame->readlock, frame->dosrcs); + + if (save_update_dir != NULL) + { + (void) strcpy (update_dir, save_update_dir); + free (save_update_dir); + + if (chdir (savewd) < 0) + error (1, errno, "could not chdir to %s", savewd); + } + + dirlist = save_dirlist; + filelist = NULL; + return(err); } diff --git a/gnu/usr.bin/cvs/cvs/release.c b/gnu/usr.bin/cvs/cvs/release.c index 34d36bc..a6200d9 100644 --- a/gnu/usr.bin/cvs/cvs/release.c +++ b/gnu/usr.bin/cvs/cvs/release.c @@ -12,14 +12,11 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)release.c 1.21 92/02/29"; +static char rcsid[] = "$CVSid: @(#)release.c 1.23 94/09/21 $"; +USE(rcsid) #endif -#if __STDC__ -static void release_delete (char *dir); -#else -static void release_delete (); -#endif /* __STDC__ */ +static void release_delete PROTO((char *dir)); static char *release_usage[] = { @@ -49,7 +46,7 @@ release (argc, argv) if (argc == -1) usage (release_usage); optind = 1; - while ((c = gnu_getopt (argc, argv, "Qdq")) != -1) + while ((c = getopt (argc, argv, "Qdq")) != -1) { switch (c) { @@ -116,7 +113,7 @@ release (argc, argv) continue; } val.dptr[val.dsize] = '\0'; - if ((cp = index (val.dptr, '#')) != NULL) /* Strip out a comment */ + if ((cp = strchr (val.dptr, '#')) != NULL) /* Strip out a comment */ { do { @@ -128,7 +125,7 @@ release (argc, argv) margv = modargv; optind = 1; - while (gnu_getopt (margc, margv, CVSMODULE_OPTS) != -1) + while (getopt (margc, margv, CVSMODULE_OPTS) != -1) /* do nothing */ ; margc -= optind; margv += optind; @@ -159,7 +156,7 @@ release (argc, argv) c = 0; while (fgets (line, sizeof (line), fp)) { - if (index ("MARCZ", *line)) + if (strchr ("MARCZ", *line)) c++; (void) printf (line); } @@ -211,7 +208,11 @@ release_delete (dir) "Parent dir on a different disk, delete of %s aborted", dir); return; } - run_setup ("%s -r", RM); + /* + * XXX - shouldn't this just delete the CVS-controlled files and, perhaps, + * the files that would normally be ignored and leave everything else? + */ + run_setup ("%s -fr", RM); run_arg (dir); if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0) error (0, retcode == -1 ? errno : 0, diff --git a/gnu/usr.bin/cvs/cvs/remove.c b/gnu/usr.bin/cvs/cvs/remove.c index 5cce883..0a893d1 100644 --- a/gnu/usr.bin/cvs/cvs/remove.c +++ b/gnu/usr.bin/cvs/cvs/remove.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Remove a File * @@ -18,26 +18,24 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)remove.c 1.34 92/04/10"; +static char rcsid[] = "$CVSid: @(#)remove.c 1.39 94/10/07 $"; +USE(rcsid) #endif -#if __STDC__ -static int remove_fileproc (char *file, char *update_dir, +static int remove_fileproc PROTO((char *file, char *update_dir, char *repository, List *entries, - List *srcfiles); -static Dtype remove_dirproc (char *dir, char *repos, char *update_dir); -#else -static Dtype remove_dirproc (); -static int remove_fileproc (); -#endif + List *srcfiles)); +static Dtype remove_dirproc PROTO((char *dir, char *repos, char *update_dir)); +static int force; static int local; static int removed_files; -static int auto_removed_files; +static int existing_files; static char *remove_usage[] = { - "Usage: %s %s [-lR] [files...]\n", + "Usage: %s %s [-flR] [files...]\n", + "\t-f\tDelete the file before removing it.\n", "\t-l\tProcess this directory only (not recursive).\n", "\t-R\tProcess directories recursively.\n", NULL @@ -54,10 +52,13 @@ cvsremove (argc, argv) usage (remove_usage); optind = 1; - while ((c = gnu_getopt (argc, argv, "lR")) != -1) + while ((c = getopt (argc, argv, "flR")) != -1) { switch (c) { + case 'f': + force = 1; + break; case 'l': local = 1; break; @@ -76,15 +77,18 @@ cvsremove (argc, argv) /* start the recursion processor */ err = start_recursion (remove_fileproc, (int (*) ()) NULL, remove_dirproc, (int (*) ()) NULL, argc, argv, local, - W_LOCAL, 0, 1, (char *) NULL, 1); + W_LOCAL, 0, 1, (char *) NULL, 1, 0); if (removed_files) error (0, 0, "use '%s commit' to remove %s permanently", program_name, (removed_files == 1) ? "this file" : "these files"); - else - if (!auto_removed_files) - error (0, 0, "no files removed; use `%s' to remove the file first", - RM); + + if (existing_files) + error (0, 0, + ((existing_files == 1) ? + "%d file exists; use `%s' to remove it first" : + "%d files exist; use `%s' to remove them first"), + existing_files, RM); return (err); } @@ -104,24 +108,28 @@ remove_fileproc (file, update_dir, repository, entries, srcfiles) char fname[PATH_MAX]; Vers_TS *vers; + /* + * If unlinking the file works, good. If not, the "unremoved" + * error will indicate problems. + */ + if (force) + (void) unlink (file); + vers = Version_TS (repository, (char *) NULL, (char *) NULL, (char *) NULL, file, 0, 0, entries, srcfiles); if (vers->ts_user != NULL) { - freevers_ts (&vers); - return (0); + existing_files++; + if (!quiet) + error (0, 0, "file `%s' still in working directory", file); } - - if (vers->vn_user == NULL) + else if (vers->vn_user == NULL) { if (!quiet) - error (0, 0, "nothing known about %s", file); - freevers_ts (&vers); - return (0); + error (0, 0, "nothing known about `%s'", file); } - - if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0') + else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0') { /* * It's a file that has been added, but not commited yet. So, @@ -134,13 +142,12 @@ remove_fileproc (file, update_dir, repository, entries, srcfiles) (void) sprintf (fname, "%s/%s%s", CVSADM, file, CVSEXT_LOG); (void) unlink_file (fname); if (!quiet) - error (0, 0, "removed `%s'.", file); - auto_removed_files++; + error (0, 0, "removed `%s'", file); } else if (vers->vn_user[0] == '-') { - freevers_ts (&vers); - return (0); + if (!quiet) + error (0, 0, "file `%s' already scheduled for removal", file); } else { @@ -148,12 +155,10 @@ remove_fileproc (file, update_dir, repository, entries, srcfiles) (void) strcpy (fname, "-"); (void) strcat (fname, vers->vn_user); Register (entries, file, fname, vers->ts_rcs, vers->options, - vers->tag, vers->date); + vers->tag, vers->date, vers->ts_conflict); if (!quiet) - { - error (0, 0, "scheduling %s for removal", file); - removed_files++; - } + error (0, 0, "scheduling `%s' for removal", file); + removed_files++; } freevers_ts (&vers); diff --git a/gnu/usr.bin/cvs/cvs/repos.c b/gnu/usr.bin/cvs/cvs/repos.c index 43a9dfe..e7794d4 100644 --- a/gnu/usr.bin/cvs/cvs/repos.c +++ b/gnu/usr.bin/cvs/cvs/repos.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Name of Repository * @@ -13,7 +13,8 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)repos.c 1.28 92/03/31"; +static char rcsid[] = "$CVSid: @(#)repos.c 1.32 94/09/23 $"; +USE(rcsid) #endif char * @@ -112,7 +113,7 @@ Name_Repository (dir, update_dir) error (1, errno, "cannot read %s", CVSADM_REP); } (void) fclose (fpin); - if ((cp = rindex (repos, '\n')) != NULL) + if ((cp = strrchr (repos, '\n')) != NULL) *cp = '\0'; /* strip the newline */ /* diff --git a/gnu/usr.bin/cvs/cvs/rtag.c b/gnu/usr.bin/cvs/cvs/rtag.c index a53e8c7..c10f68b 100644 --- a/gnu/usr.bin/cvs/cvs/rtag.c +++ b/gnu/usr.bin/cvs/cvs/rtag.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Rtag * @@ -14,24 +14,18 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)rtag.c 1.57 92/04/10"; +static char rcsid[] = "$CVSid: @(#)rtag.c 1.61 94/09/30 $"; +USE(rcsid) #endif -#if __STDC__ -static Dtype rtag_dirproc (char *dir, char *repos, char *update_dir); -static int rtag_fileproc (char *file, char *update_dir, +static Dtype rtag_dirproc PROTO((char *dir, char *repos, char *update_dir)); +static int rtag_fileproc PROTO((char *file, char *update_dir, char *repository, List * entries, - List * srcfiles); -static int rtag_proc (int *pargc, char *argv[], char *xwhere, + List * srcfiles)); +static int rtag_proc PROTO((int *pargc, char *argv[], char *xwhere, char *mwhere, char *mfile, int shorten, - int local_specified, char *mname, char *msg); -static int rtag_delete (RCSNode *rcsfile); -#else -static int rtag_proc (); -static int rtag_fileproc (); -static Dtype rtag_dirproc (); -static int rtag_delete (); -#endif /* __STDC__ */ + int local_specified, char *mname, char *msg)); +static int rtag_delete PROTO((RCSNode *rcsfile)); static char *symtag; static char *numtag; @@ -41,10 +35,11 @@ static int branch_mode; /* make an automagic "branch" tag */ static char *date; static int local; /* recursive by default */ static int force_tag_match = 1; /* force by default */ +static int force_tag_move; /* don't move existing tags by default */ static char *rtag_usage[] = { - "Usage: %s %s [-QaflRnq] [-b] [-d] [-r tag|-D date] tag modules...\n", + "Usage: %s %s [-QaflRnqF] [-b] [-d] [-r tag|-D date] tag modules...\n", "\t-Q\tReally quiet.\n", "\t-a\tClear tag from removed files that would not otherwise be tagged.\n", "\t-f\tForce a head revision match if tag/date not found.\n", @@ -55,6 +50,7 @@ static char *rtag_usage[] = "\t-d\tDelete the given Tag.\n", "\t-b\tMake the tag a \"branch\" tag, allowing concurrent development.\n", "\t-[rD]\tExisting tag or Date.\n", + "\t-F\tMove tag if it already exists\n", NULL }; @@ -73,7 +69,7 @@ rtag (argc, argv) usage (rtag_usage); optind = 1; - while ((c = gnu_getopt (argc, argv, "anfQqlRdbr:D:")) != -1) + while ((c = getopt (argc, argv, "FanfQqlRdbr:D:")) != -1) { switch (c) { @@ -112,6 +108,9 @@ rtag (argc, argv) free (date); date = Make_Date (optarg); break; + case 'F': + force_tag_move = 1; + break; case '?': default: usage (rtag_usage); @@ -178,7 +177,7 @@ rtag_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified, char path[PATH_MAX]; /* if the portion of the module is a path, put the dir part on repos */ - if ((cp = rindex (mfile, '/')) != NULL) + if ((cp = strrchr (mfile, '/')) != NULL) { *cp = '\0'; (void) strcat (repository, "/"); @@ -224,7 +223,7 @@ rtag_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified, /* start the recursion processor */ err = start_recursion (rtag_fileproc, (int (*) ()) NULL, rtag_dirproc, (int (*) ()) NULL, *pargc - 1, argv + 1, local, - which, 0, 1, where, 1); + which, 0, 1, where, 1, 1); return (err); } @@ -304,40 +303,60 @@ rtag_fileproc (file, update_dir, repository, entries, srcfiles) } else { - char *oversion; - - /* - * As an enhancement for the case where a tag is being re-applied to - * a large body of a module, make one extra call to Version_Number to - * see if the tag is already set in the RCS file. If so, check to - * see if it needs to be moved. If not, do nothing. This will - * likely save a lot of time when simply moving the tag to the - * "current" head revisions of a module -- which I have found to be a - * typical tagging operation. - */ - oversion = RCS_getversion (rcsfile, symtag, (char *) 0, 1); - if (oversion != NULL) - { - if (strcmp (version, oversion) == 0) - { - free (version); - free (oversion); - return (0); - } - free (oversion); - } - rev = branch_mode ? RCS_magicrev (rcsfile, version) : version; - run_setup ("%s%s -q -N%s:%s", Rcsbin, RCS, symtag, rev); + char *oversion; + + /* + * As an enhancement for the case where a tag is being re-applied to + * a large body of a module, make one extra call to Version_Number to + * see if the tag is already set in the RCS file. If so, check to + * see if it needs to be moved. If not, do nothing. This will + * likely save a lot of time when simply moving the tag to the + * "current" head revisions of a module -- which I have found to be a + * typical tagging operation. + */ + rev = branch_mode ? RCS_magicrev (rcsfile, version) : version; + oversion = RCS_getversion (rcsfile, symtag, (char *) 0, 1); + if (oversion != NULL) + { + int isbranch = RCS_isbranch (file, symtag, srcfiles); + + /* + * if versions the same and neither old or new are branches don't + * have to do anything + */ + if (strcmp (version, oversion) == 0 && !branch_mode && !isbranch) + { + free (oversion); + free (version); + return (0); + } + + if (!force_tag_move) { /* we're NOT going to move the tag */ + if (update_dir[0]) + (void) printf ("W %s/%s", update_dir, file); + else + (void) printf ("W %s", file); + + (void) printf (" : %s already exists on %s %s", + symtag, isbranch ? "branch" : "version", oversion); + (void) printf (" : NOT MOVING tag to %s %s\n", + branch_mode ? "branch" : "version", rev); + free (oversion); + free (version); + return (0); + } + free (oversion); + } + run_setup ("%s%s -q -N%s:%s", Rcsbin, RCS, symtag, rev); } run_arg (rcsfile->path); if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0) { - if (!quiet) - error (0, retcode == -1 ? errno : 0, - "failed to set tag `%s' to revision `%s' in `%s'", - symtag, rev, rcsfile->path); - free (version); - return (1); + error (1, retcode == -1 ? errno : 0, + "failed to set tag `%s' to revision `%s' in `%s'", + symtag, rev, rcsfile->path); + free (version); + return (1); } free (version); return (0); diff --git a/gnu/usr.bin/cvs/cvs/status.c b/gnu/usr.bin/cvs/cvs/status.c index 9749740..2f14a0b 100644 --- a/gnu/usr.bin/cvs/cvs/status.c +++ b/gnu/usr.bin/cvs/cvs/status.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Status Information */ @@ -11,23 +11,20 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)status.c 1.48 92/03/31"; +static char rcsid[] = "$CVSid: @(#)status.c 1.56 94/10/07 $"; +USE(rcsid) #endif -#if __STDC__ -static Dtype status_dirproc (char *dir, char *repos, char *update_dir); -static int status_fileproc (char *file, char *update_dir, +static Dtype status_dirproc PROTO((char *dir, char *repos, char *update_dir)); +static int status_fileproc PROTO((char *file, char *update_dir, char *repository, List * entries, - List * srcfiles); -static int tag_list_proc (Node * p); -#else -static int tag_list_proc (); -static int status_fileproc (); -static Dtype status_dirproc (); -#endif /* __STDC__ */ + List * srcfiles)); +static int tag_list_proc PROTO((Node * p, void *closure)); static int local = 0; static int long_format = 0; +static char *xfile; +static List *xsrcfiles; static char *status_usage[] = { @@ -50,7 +47,7 @@ status (argc, argv) usage (status_usage); optind = 1; - while ((c = gnu_getopt (argc, argv, "vlR")) != -1) + while ((c = getopt (argc, argv, "vlR")) != -1) { switch (c) { @@ -75,7 +72,7 @@ status (argc, argv) /* start the recursion processor */ err = start_recursion (status_fileproc, (int (*) ()) NULL, status_dirproc, (int (*) ()) NULL, argc, argv, local, - W_LOCAL, 0, 1, (char *) NULL, 1); + W_LOCAL, 0, 1, (char *) NULL, 1, 0); return (err); } @@ -97,7 +94,8 @@ status_fileproc (file, update_dir, repository, entries, srcfiles) Vers_TS *vers; status = Classify_File (file, (char *) NULL, (char *) NULL, (char *) NULL, - 1, 0, repository, entries, srcfiles, &vers); + 1, 0, repository, entries, srcfiles, &vers, + update_dir, 0); switch (status) { case T_UNKNOWN: @@ -116,7 +114,10 @@ status_fileproc (file, update_dir, repository, entries, srcfiles) sstat = "Locally Removed"; break; case T_MODIFIED: - sstat = "Locally Modified"; + if (vers->ts_conflict) + sstat = "Unresolved Conflict"; + else + sstat = "Locally Modified"; break; case T_REMOVE_ENTRY: sstat = "Entry Invalid"; @@ -136,20 +137,20 @@ status_fileproc (file, update_dir, repository, entries, srcfiles) if (vers->ts_user == NULL) (void) printf ("File: no file %s\t\tStatus: %s\n\n", file, sstat); else - (void) printf ("File: %-17.17s\tStatus: %s\n\n", file, sstat); + (void) printf ("File: %-17s\tStatus: %s\n\n", file, sstat); if (vers->vn_user == NULL) - (void) printf (" Version:\t\tNo entry for %s\n", file); + (void) printf (" Working revision:\tNo entry for %s\n", file); else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0') - (void) printf (" Version:\t\tNew file!\n"); + (void) printf (" Working revision:\tNew file!\n"); else - (void) printf (" Version:\t\t%s\t%s\n", vers->vn_user, - &vers->ts_rcs[25]); + (void) printf (" Working revision:\t%s\t%s\n", vers->vn_user, + vers->ts_rcs); if (vers->vn_rcs == NULL) - (void) printf (" RCS Version:\tNo revision control file\n"); + (void) printf (" Repository revision:\tNo revision control file\n"); else - (void) printf (" RCS Version:\t%s\t%s\n", vers->vn_rcs, + (void) printf (" Repository revision:\t%s\t%s\n", vers->vn_rcs, vers->srcfile->path); if (vers->entdata) @@ -161,36 +162,49 @@ status_fileproc (file, update_dir, repository, entries, srcfiles) { if (vers->vn_rcs == NULL) (void) printf ( - " Sticky Tag:\t\t%s - MISSING from RCS file!\n", + " Sticky Tag:\t\t%s - MISSING from RCS file!\n", edata->tag); else { if (isdigit (edata->tag[0])) - (void) printf (" Sticky Tag:\t\t%s\n", edata->tag); + (void) printf (" Sticky Tag:\t\t%s\n", edata->tag); else - (void) printf (" Sticky Tag:\t\t%s (%s: %s)\n", - edata->tag, numdots (vers->vn_rcs) % 2 ? - "revision" : "branch", vers->vn_rcs); + { + int isbranch = RCS_isbranch (file, edata->tag, srcfiles); + + (void) printf (" Sticky Tag:\t\t%s (%s: %s)\n", + edata->tag, + isbranch ? "branch" : "revision", + isbranch ? + RCS_whatbranch(file, edata->tag, srcfiles) : + vers->vn_rcs); + } } } else - (void) printf (" Sticky Tag:\t\t(none)\n"); + (void) printf (" Sticky Tag:\t\t(none)\n"); if (edata->date) - (void) printf (" Sticky Date:\t%s\n", edata->date); + (void) printf (" Sticky Date:\t\t%s\n", edata->date); else - (void) printf (" Sticky Date:\t(none)\n"); + (void) printf (" Sticky Date:\t\t(none)\n"); if (edata->options && edata->options[0]) - (void) printf (" Sticky Options:\t%s\n", edata->options); + (void) printf (" Sticky Options:\t%s\n", edata->options); else - (void) printf (" Sticky Options:\t(none)\n"); + (void) printf (" Sticky Options:\t(none)\n"); if (long_format && vers->srcfile) { - (void) printf ("\n Existing Tags:\n"); - if (vers->srcfile->symbols) - (void) walklist (vers->srcfile->symbols, tag_list_proc); + List *symbols = RCS_symbols(vers->srcfile); + + (void) printf ("\n Existing Tags:\n"); + if (symbols) + { + xfile = file; + xsrcfiles = srcfiles; + (void) walklist (symbols, tag_list_proc, NULL); + } else (void) printf ("\tNo Tags Exist\n"); } @@ -220,11 +234,15 @@ status_dirproc (dir, repos, update_dir) * Print out a tag and its type */ static int -tag_list_proc (p) +tag_list_proc (p, closure) Node *p; + void *closure; { + int isbranch = RCS_isbranch (xfile, p->key, xsrcfiles); + (void) printf ("\t%-25.25s\t(%s: %s)\n", p->key, - numdots (p->data) % 2 ? "revision" : "branch", + isbranch ? "branch" : "revision", + isbranch ? RCS_whatbranch(xfile, p->key, xsrcfiles) : p->data); return (0); } diff --git a/gnu/usr.bin/cvs/cvs/tag.c b/gnu/usr.bin/cvs/cvs/tag.c index 71a8c46..fa7f162 100644 --- a/gnu/usr.bin/cvs/cvs/tag.c +++ b/gnu/usr.bin/cvs/cvs/tag.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Tag * @@ -14,33 +14,31 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)tag.c 1.56 92/03/31"; +static char rcsid[] = "$CVSid: @(#)tag.c 1.60 94/09/30 $"; +USE(rcsid) #endif -#if __STDC__ -static Dtype tag_dirproc (char *dir, char *repos, char *update_dir); -static int tag_fileproc (char *file, char *update_dir, +static Dtype tag_dirproc PROTO((char *dir, char *repos, char *update_dir)); +static int tag_fileproc PROTO((char *file, char *update_dir, char *repository, List * entries, - List * srcfiles); -#else -static int tag_fileproc (); -static Dtype tag_dirproc (); -#endif /* __STDC__ */ + List * srcfiles)); static char *symtag; static int delete; /* adding a tag by default */ static int branch_mode; /* make an automagic "branch" tag */ static int local; /* recursive by default */ +static int force_tag_move; /* don't force tag to move by default */ static char *tag_usage[] = { - "Usage: %s %s [-QlRq] [-b] [-d] tag [files...]\n", + "Usage: %s %s [-QlRqF] [-b] [-d] tag [files...]\n", "\t-Q\tReally quiet.\n", "\t-l\tLocal directory only, not recursive.\n", "\t-R\tProcess directories recursively.\n", "\t-q\tSomewhat quiet.\n", "\t-d\tDelete the given Tag.\n", "\t-b\tMake the tag a \"branch\" tag, allowing concurrent development.\n", + "\t-F\tMove tag if it already exists\n", NULL }; @@ -56,7 +54,7 @@ tag (argc, argv) usage (tag_usage); optind = 1; - while ((c = gnu_getopt (argc, argv, "QqlRdb")) != -1) + while ((c = getopt (argc, argv, "FQqlRdb")) != -1) { switch (c) { @@ -78,6 +76,9 @@ tag (argc, argv) case 'b': branch_mode = 1; break; + case 'F': + force_tag_move = 1; + break; case '?': default: usage (tag_usage); @@ -100,7 +101,7 @@ tag (argc, argv) /* start the recursion processor */ err = start_recursion (tag_fileproc, (int (*) ()) NULL, tag_dirproc, (int (*) ()) NULL, argc, argv, local, - W_LOCAL, 0, 1, (char *) NULL, 1); + W_LOCAL, 0, 1, (char *) NULL, 1, 0); return (err); } @@ -210,26 +211,47 @@ tag_fileproc (file, update_dir, repository, entries, srcfiles) * time when simply moving the tag to the "current" head revisions of a * module -- which I have found to be a typical tagging operation. */ + rev = branch_mode ? RCS_magicrev (vers->srcfile, version) : version; oversion = RCS_getversion (vers->srcfile, symtag, (char *) NULL, 1); if (oversion != NULL) { - if (strcmp (version, oversion) == 0) - { - free (oversion); - freevers_ts (&vers); - return (0); - } - free (oversion); + int isbranch = RCS_isbranch (file, symtag, srcfiles); + + /* + * if versions the same and neither old or new are branches don't have + * to do anything + */ + if (strcmp (version, oversion) == 0 && !branch_mode && !isbranch) + { + free (oversion); + freevers_ts (&vers); + return (0); + } + + if (!force_tag_move) { /* we're NOT going to move the tag */ + if (update_dir[0]) + (void) printf ("W %s/%s", update_dir, file); + else + (void) printf ("W %s", file); + + (void) printf (" : %s already exists on %s %s", + symtag, isbranch ? "branch" : "version", oversion); + (void) printf (" : NOT MOVING tag to %s %s\n", + branch_mode ? "branch" : "version", rev); + free (oversion); + freevers_ts (&vers); + return (0); + } + free (oversion); } - rev = branch_mode ? RCS_magicrev (vers->srcfile, version) : version; + run_setup ("%s%s -q -N%s:%s", Rcsbin, RCS, symtag, rev); run_arg (vers->srcfile->path); if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL)) != 0) { - if (!quiet) - error (0, retcode == -1 ? errno : 0, - "failed to set tag %s to revision %s in %s", - symtag, rev, vers->srcfile->path); + error (1, retcode == -1 ? errno : 0, + "failed to set tag %s to revision %s in %s", + symtag, rev, vers->srcfile->path); freevers_ts (&vers); return (1); } diff --git a/gnu/usr.bin/cvs/cvs/update.c b/gnu/usr.bin/cvs/cvs/update.c index e0dc287..9fdc0b4 100644 --- a/gnu/usr.bin/cvs/cvs/update.c +++ b/gnu/usr.bin/cvs/cvs/update.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * "update" updates the version in the present directory with respect to the RCS * repository. The present version must have been created by "checkout". The @@ -36,39 +36,26 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)update.c 1.83 92/04/10"; +static char rcsid[] = "$CVSid: @(#)update.c 1.95 94/10/22 $"; +USE(rcsid) #endif -#if __STDC__ -static int checkout_file (char *file, char *repository, List *entries, - List *srcfiles, Vers_TS *vers_ts, char *update_dir); -static int isemptydir (char *dir); -static int merge_file (char *file, char *repository, List *entries, - Vers_TS *vers, char *update_dir); -static int scratch_file (char *file, char *repository, List * entries, - char *update_dir); -static Dtype update_dirent_proc (char *dir, char *repository, char *update_dir); -static int update_dirleave_proc (char *dir, int err, char *update_dir); -static int update_file_proc (char *file, char *update_dir, char *repository, - List * entries, List * srcfiles); -static int update_filesdone_proc (int err, char *repository, char *update_dir); -static int write_letter (char *file, int letter, char *update_dir); -static void ignore_files (List * ilist, char *update_dir); -static void join_file (char *file, List *srcfiles, Vers_TS *vers_ts, - char *update_dir); -#else -static int update_file_proc (); -static int update_filesdone_proc (); -static Dtype update_dirent_proc (); -static int update_dirleave_proc (); -static int isemptydir (); -static int scratch_file (); -static int checkout_file (); -static int write_letter (); -static int merge_file (); -static void ignore_files (); -static void join_file (); -#endif /* __STDC__ */ +static int checkout_file PROTO((char *file, char *repository, List *entries, + List *srcfiles, Vers_TS *vers_ts, char *update_dir)); +static int isemptydir PROTO((char *dir)); +static int merge_file PROTO((char *file, char *repository, List *entries, + Vers_TS *vers, char *update_dir)); +static int scratch_file PROTO((char *file, char *repository, List * entries, + char *update_dir)); +static Dtype update_dirent_proc PROTO((char *dir, char *repository, char *update_dir)); +static int update_dirleave_proc PROTO((char *dir, int err, char *update_dir)); +static int update_file_proc PROTO((char *file, char *update_dir, char *repository, + List * entries, List * srcfiles)); +static int update_filesdone_proc PROTO((int err, char *repository, char *update_dir)); +static int write_letter PROTO((char *file, int letter, char *update_dir)); +static void ignore_files PROTO((List * ilist, char *update_dir)); +static void join_file PROTO((char *file, List *srcfiles, Vers_TS *vers_ts, + char *update_dir, List *entries)); static char *options = NULL; static char *tag = NULL; @@ -81,7 +68,7 @@ static int update_build_dirs = 0; static int update_prune_dirs = 0; static int pipeout = 0; static List *ignlist = (List *) NULL; - +static time_t last_register_time; static char *update_usage[] = { "Usage:\n %s %s [-APQdflRpq] [-k kopt] [-r rev|-D date] [-j rev] [-I ign] [files...]\n", @@ -121,7 +108,7 @@ update (argc, argv) /* parse the args */ optind = 1; - while ((c = gnu_getopt (argc, argv, "ApPflRQqdk:r:D:j:I:")) != -1) + while ((c = getopt (argc, argv, "ApPflRQqdk:r:D:j:I:")) != -1) { switch (c) { @@ -192,7 +179,10 @@ update (argc, argv) if (argc <= 0 && !pipeout) { if (update_build_dirs) - (void) unlink_file (CVSADM_ENTSTAT); + { + if (unlink_file (CVSADM_ENTSTAT) < 0 && errno != ENOENT) + error (1, errno, "cannot remove file %s", CVSADM_ENTSTAT); + } /* keep the CVS/Tag file current with the specified arguments */ if (aflag || tag || date) @@ -256,14 +246,14 @@ do_update (argc, argv, xoptions, xtag, xdate, xforce, local, xbuild, xaflag, /* setup the join support */ join_rev1 = xjoin_rev1; join_rev2 = xjoin_rev2; - if (join_rev1 && (cp = index (join_rev1, ':')) != NULL) + if (join_rev1 && (cp = strchr (join_rev1, ':')) != NULL) { *cp++ = '\0'; date_rev1 = Make_Date (cp); } else date_rev1 = (char *) NULL; - if (join_rev2 && (cp = index (join_rev2, ':')) != NULL) + if (join_rev2 && (cp = strchr (join_rev2, ':')) != NULL) { *cp++ = '\0'; date_rev2 = Make_Date (cp); @@ -275,7 +265,18 @@ do_update (argc, argv, xoptions, xtag, xdate, xforce, local, xbuild, xaflag, err = start_recursion (update_file_proc, update_filesdone_proc, update_dirent_proc, update_dirleave_proc, argc, argv, local, which, aflag, 1, - preload_update_dir, 1); + preload_update_dir, 1, 0); + + /* see if we need to sleep before returning */ + if (last_register_time) + { + time_t now; + + (void) time (&now); + if (now == last_register_time) + sleep (1); /* to avoid time-stamp races */ + } + return (err); } @@ -303,7 +304,8 @@ update_file_proc (file, update_dir, repository, entries, srcfiles) Vers_TS *vers; status = Classify_File (file, tag, date, options, force_tag_match, - aflag, repository, entries, srcfiles, &vers); + aflag, repository, entries, srcfiles, &vers, + update_dir, pipeout); if (pipeout) { /* @@ -351,13 +353,65 @@ update_file_proc (file, update_dir, repository, entries, srcfiles) break; case T_CONFLICT: /* old punt-type errors */ retval = 1; + (void) write_letter (file, 'C', update_dir); break; - case T_NEEDS_MERGE: /* needs merging */ + case T_NEEDS_MERGE: /* needs merging */ retval = merge_file (file, repository, entries, vers, update_dir); break; case T_MODIFIED: /* locally modified */ - retval = write_letter (file, 'M', update_dir); + retval = 0; + if (vers->ts_conflict) + { + char *filestamp; + int retcode; + + /* + * If the timestamp has changed and no conflict indicators + * are found, it isn't a 'C' any more. + */ + filestamp = time_stamp (file); + retcode = strcmp (vers->ts_conflict, filestamp); + free (filestamp); + + if (retcode) + { + /* + * If the timestamps differ, look for Conflict + * indicators to see if 'C' anyway. + */ + run_setup ("%s -s", GREP); + run_arg (RCS_MERGE_PAT); + run_arg (file); + retcode = run_exec (RUN_TTY, RUN_TTY, + RUN_TTY,RUN_NORMAL); + if (retcode == -1) + { + if (update_dir[0] == '\0') + error (1, errno, + "fork failed while examining conflict in `%s'", + file); + else + error (1, errno, + "fork failed while examining conflict in `%s/%s'", + update_dir, file); + } + } + if (!retcode) + { + (void) write_letter (file, 'C', update_dir); + retval = 1; + } + else + { + /* Reregister to clear conflict flag. */ + Register (entries, file, vers->vn_rcs, vers->ts_rcs, + vers->options, vers->tag, + vers->date, (char *)0); + } + } + if (!retval) + retval = write_letter (file, 'M', update_dir); break; case T_CHECKOUT: /* needs checkout */ retval = checkout_file (file, repository, entries, srcfiles, @@ -382,7 +436,7 @@ update_file_proc (file, update_dir, repository, entries, srcfiles) /* only try to join if things have gone well thus far */ if (retval == 0 && join_rev1) - join_file (file, srcfiles, vers, update_dir); + join_file (file, srcfiles, vers, update_dir, entries); /* if this directory has an ignore list, add this file to it */ if (ignlist) @@ -392,7 +446,8 @@ update_file_proc (file, update_dir, repository, entries, srcfiles) p = getnode (); p->type = FILES; p->key = xstrdup (file); - (void) addnode (ignlist, p); + if (addnode (ignlist, p) != 0) + freenode (p); } freevers_ts (&vers); @@ -423,6 +478,14 @@ update_filesdone_proc (err, repository, update_dir) run_arg (CVSADM); (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL); } +#ifdef CVSADM_ROOT + else + { + /* If there is no CVS/Root file, add one */ + if (!isfile (CVSADM_ROOT)) + Create_Root( (char *) NULL, CVSroot ); + } +#endif /* CVSADM_ROOT */ return (err); } @@ -441,6 +504,14 @@ update_dirent_proc (dir, repository, update_dir) char *repository; char *update_dir; { + if (ignore_directory (update_dir)) + { + /* print the warm fuzzy message */ + if (!quiet) + error (0, 0, "Ignoring %s", update_dir); + return R_SKIP_ALL; + } + if (!isdir (dir)) { /* if we aren't building dirs, blow it off */ @@ -472,7 +543,8 @@ update_dirent_proc (dir, repository, update_dir) char tmp[PATH_MAX]; (void) sprintf (tmp, "%s/%s", dir, CVSADM_ENTSTAT); - (void) unlink_file (tmp); + if (unlink_file (tmp) < 0 && errno != ENOENT) + error (1, errno, "cannot remove file %s", tmp); } /* keep the CVS/Tag file current with the specified arguments */ @@ -515,7 +587,7 @@ update_dirleave_proc (dir, err, update_dir) repository = Name_Repository ((char *) NULL, update_dir); if (fgets (line, sizeof (line), fp) != NULL) { - if ((cp = rindex (line, '\n')) != NULL) + if ((cp = strrchr (line, '\n')) != NULL) *cp = '\0'; run_setup ("%s %s", line, repository); (void) printf ("%s %s: Executing '", program_name, command_name); @@ -534,6 +606,35 @@ update_dirleave_proc (dir, err, update_dir) run_arg (CVSADM); (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL); } +#ifdef CVSADM_ROOT + else + { + /* If there is no CVS/Root file, add one */ + if (!isreadable (CVSADM_ROOT)) + { + if (isfile (CVSADM_ROOT)) + { + error (0, 0, "bad permissions %s/%s deleteing it", update_dir, + CVSADM_ROOT); + if (unlink_file (CVSADM_ROOT) == -1) + { + error (0, errno, "delete failed for %s/%s", + update_dir, CVSADM_ROOT); + } + } + Create_Root( (char *) NULL, CVSroot ); + } + else + { + char *root = Name_Root( (char *) NULL, update_dir); + + if (root == NULL) + Create_Root( (char *) NULL, CVSroot ); + else + free (root); /* all is well, release the storage */ + } + } +#endif /* CVSADM_ROOT */ /* Prune empty dirs on the way out - if necessary */ (void) chdir (".."); @@ -556,7 +657,7 @@ isemptydir (dir) char *dir; { DIR *dirp; - struct direct *dp; + struct dirent *dp; if ((dirp = opendir (dir)) == NULL) { @@ -671,8 +772,12 @@ checkout_file (file, repository, entries, srcfiles, vers_ts, update_dir) force_tag_match, set_time, entries, srcfiles); if (strcmp (xvers_ts->options, "-V4") == 0) xvers_ts->options[0] = '\0'; + + (void) time (&last_register_time); + Register (entries, file, xvers_ts->vn_rcs, xvers_ts->ts_user, - xvers_ts->options, xvers_ts->tag, xvers_ts->date); + xvers_ts->options, xvers_ts->tag, xvers_ts->date, + (char *)0); /* Clear conflict flag on fresh checkout */ /* fix up the vers structure, in case it is used by join */ if (join_rev1) @@ -727,7 +832,7 @@ checkout_file (file, repository, entries, srcfiles, vers_ts, update_dir) static int write_letter (file, letter, update_dir) char *file; - char letter; + int letter; char *update_dir; { if (!really_quiet) @@ -791,11 +896,20 @@ merge_file (file, repository, entries, vers, update_dir) rename_file (backup, file); return (1); } - /* XXX - Might want to make sure that rcsmerge changed the file */ + if (strcmp (vers->options, "-V4") == 0) vers->options[0] = '\0'; - Register (entries, file, vers->vn_rcs, vers->ts_rcs, vers->options, - vers->tag, vers->date); + (void) time (&last_register_time); + { + char *cp = 0; + + if (status) + cp = time_stamp (file); + Register (entries, file, vers->vn_rcs, vers->ts_rcs, vers->options, + vers->tag, vers->date, cp); + if (cp) + free (cp); + } /* fix up the vers structure, in case it is used by join */ if (join_rev1) @@ -805,6 +919,14 @@ merge_file (file, repository, entries, vers, update_dir) vers->vn_user = xstrdup (vers->vn_rcs); } + if (!xcmp (backup, file)) + { + printf ("%s already contains the differences between %s and %s\n", + user, vers->vn_user, vers->vn_rcs); + history_write ('G', update_dir, vers->vn_rcs, file, repository); + return (0); + } + /* possibly run GREP to see if there appear to be conflicts in the file */ run_setup ("%s -s", GREP); run_arg (RCS_MERGE_PAT); @@ -839,98 +961,216 @@ merge_file (file, repository, entries, vers, update_dir) * (-j option) */ static void -join_file (file, srcfiles, vers, update_dir) +join_file (file, srcfiles, vers, update_dir, entries) char *file; List *srcfiles; Vers_TS *vers; char *update_dir; + List *entries; { char user[PATH_MAX]; char backup[PATH_MAX]; - char *rev, *baserev; char *options; int status; + char *rev1; + char *rev2; + char *jrev1; + char *jrev2; + char *jdate1; + char *jdate2; + + jrev1 = join_rev1; + jrev2 = join_rev2; + jdate1 = date_rev1; + jdate2 = date_rev2; + /* determine if we need to do anything at all */ - if (vers->vn_user == NULL || vers->srcfile == NULL || + if (vers->srcfile == NULL || vers->srcfile->path == NULL) { return; } - /* special handling when two revisions are specified */ - if (join_rev1 && join_rev2) + /* in all cases, use two revs. */ + + /* if only one rev is specified, it becomes the second rev */ + if (jrev2 == NULL) + { + jrev2 = jrev1; + jrev1 = NULL; + jdate2 = jdate1; + jdate1 = NULL; + } + + /* convert the second rev spec, walking branches and dates. */ + + rev2 = RCS_getversion (vers->srcfile, jrev2, jdate2, 1); + if (rev2 == NULL) { - rev = RCS_getversion (vers->srcfile, join_rev2, date_rev2, 1); - if (rev == NULL) + if (!quiet) { - if (!quiet && date_rev2 == NULL) + if (jdate2 != NULL) error (0, 0, - "cannot find revision %s in file %s", join_rev2, file); + "cannot find revision %s as of %s in file %s", + jrev2, jdate2, file); + else + error (0, 0, + "cannot find revision %s in file %s", + jrev2, file); return; } + } + + /* skip joining identical revs */ + if (strcmp (rev2, vers->vn_user) == 0) /* no merge necessary */ + { + free (rev2); + return; + } - baserev = RCS_getversion (vers->srcfile, join_rev1, date_rev1, 1); - if (baserev == NULL) + if (jrev1 == NULL) + { + char *tst; + /* if the first rev is missing, then it is implied to be the + greatest common ancestor of both the join rev, and the + checked out rev. */ + + tst = vers->vn_user; + if (*tst == '!') { - if (!quiet && date_rev1 == NULL) - error (0, 0, - "cannot find revision %s in file %s", join_rev1, file); - free (rev); - return; + /* file was dead. merge anyway and pretend it's been + added. */ + ++tst; + Register (entries, file, "0", vers->ts_user, vers->options, + vers->tag, (char *) 0, (char *) 0); + } + rev1 = gca (tst, rev2); + if (rev1 == NULL) + { + /* this should not be possible */ + error (0, 0, "bad gca"); + abort(); } - /* - * nothing to do if: - * second revision matches our BASE revision (vn_user) && - * both revisions are on the same branch - */ - if (strcmp (vers->vn_user, rev) == 0 && - numdots (baserev) == numdots (rev)) + tst = RCS_gettag (vers->srcfile, rev2, 1); + if (tst == NULL) { - /* might be the same branch. take a real look */ - char *dot = rindex (baserev, '.'); - int len = (dot - baserev) + 1; + /* this should not be possible. */ + error (0, 0, "cannot find gca"); + abort(); + } - if (strncmp (baserev, rev, len) == 0) - return; + free (tst); + + /* these two cases are noops */ + if (strcmp (rev1, rev2) == 0) + { + free (rev1); + free (rev2); + return; } } else { - rev = RCS_getversion (vers->srcfile, join_rev1, date_rev1, 1); - if (rev == NULL) - return; - if (strcmp (rev, vers->vn_user) == 0) /* no merge necessary */ + /* otherwise, convert the first rev spec, walking branches and + dates. */ + + rev1 = RCS_getversion (vers->srcfile, jrev1, jdate1, 1); + if (rev1 == NULL + && !quiet) { - free (rev); + if (jdate1 != NULL) + error (0, 0, + "cannot find revision %s as of %s in file %s", + jrev1, jdate1, file); + else + error (0, 0, + "cannot find revision %s in file %s", + jrev1, file); return; } + } - baserev = RCS_whatbranch (file, join_rev1, srcfiles); - if (baserev) - { - char *cp; + /* do the join */ - /* we get a branch -- turn it into a revision, or NULL if trunk */ - if ((cp = rindex (baserev, '.')) == NULL) +#if 0 + dome { + /* special handling when two revisions are specified */ + if (join_rev1 && join_rev2) + { + rev = RCS_getversion (vers->srcfile, join_rev2, date_rev2, 1); + if (rev == NULL) { - free (baserev); - baserev = (char *) NULL; + if (!quiet && date_rev2 == NULL) + error (0, 0, + "cannot find revision %s in file %s", join_rev2, file); + return; + } + + baserev = RCS_getversion (vers->srcfile, join_rev1, date_rev1, 1); + if (baserev == NULL) + { + if (!quiet && date_rev1 == NULL) + error (0, 0, + "cannot find revision %s in file %s", join_rev1, file); + free (rev); + return; + } + + /* + * nothing to do if: + * second revision matches our BASE revision (vn_user) && + * both revisions are on the same branch + */ + if (strcmp (vers->vn_user, rev) == 0 && + numdots (baserev) == numdots (rev)) + { + /* might be the same branch. take a real look */ + char *dot = strrchr (baserev, '.'); + int len = (dot - baserev) + 1; + + if (strncmp (baserev, rev, len) == 0) + return; } - else - *cp = '\0'; + } + else + { + rev = RCS_getversion (vers->srcfile, join_rev1, date_rev1, 1); + if (rev == NULL) + return; + if (strcmp (rev, vers->vn_user) == 0) /* no merge necessary */ + { + free (rev); + return; + } + + baserev = RCS_whatbranch (file, join_rev1, srcfiles); + if (baserev) + { + char *cp; + + /* we get a branch -- turn it into a revision, or NULL if trunk */ + if ((cp = strrchr (baserev, '.')) == NULL) + { + free (baserev); + baserev = (char *) NULL; + } + else + *cp = '\0'; + } + } + if (baserev && strcmp (baserev, rev) == 0) + { + /* they match -> nothing to do */ + free (rev); + free (baserev); + return; } } - if (baserev && strcmp (baserev, rev) == 0) - { - /* they match -> nothing to do */ - free (rev); - free (baserev); - return; - } +#endif - /* OK, so we have a revision and possibly a base revision; continue on */ + /* OK, so we have two revisions; continue on */ /* * The users currently modified file is moved to a backup file name @@ -951,13 +1191,15 @@ join_file (file, srcfiles, vers, update_dir) options = vers->options; #ifdef HAVE_RCS5 +#if 0 if (*options == '\0') options = "-kk"; /* to ignore keyword expansions */ #endif +#endif /* XXX - Do merge by hand instead of using rcsmerge, due to -k handling */ - run_setup ("%s%s %s %s%s -r%s", Rcsbin, RCS_RCSMERGE, options, - baserev ? "-r" : "", baserev ? baserev : "", rev); + run_setup ("%s%s %s -r%s -r%s", Rcsbin, RCS_RCSMERGE, options, + rev1, rev2); run_arg (vers->srcfile->path); status = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL); if (status != 0 @@ -967,14 +1209,28 @@ join_file (file, srcfiles, vers, update_dir) ) { error (0, status == -1 ? errno : 0, - "could not merge revision %s of %s", rev, user); + "could not merge revision %s of %s", rev2, user); error (status == -1 ? 1 : 0, 0, "restoring %s from backup file %s", user, backup); rename_file (backup, file); } - free (rev); - if (baserev) - free (baserev); + free (rev1); + free (rev2); + +#ifdef HAVE_RCS5 + if (status == 1) + { + char *cp = 0; + + if (status) + cp = time_stamp (file); + Register (entries, file, vers->vn_rcs, vers->ts_rcs, vers->options, + vers->tag, vers->date, cp); + if (cp) + free(cp); + } +#endif + return; } @@ -988,7 +1244,7 @@ ignore_files (ilist, update_dir) char *update_dir; { DIR *dirp; - struct direct *dp; + struct dirent *dp; struct stat sb; char *file; char *xdir; @@ -1011,18 +1267,47 @@ ignore_files (ilist, update_dir) continue; if (findnode (ilist, file) != NULL) continue; - if (lstat (file, &sb) != -1) + + if ( +#ifdef DT_DIR + dp->d_type != DT_UNKNOWN || +#endif + lstat(file, &sb) != -1) { - if (S_ISDIR (sb.st_mode)) - continue; -#ifdef S_IFLNK - if (S_ISLNK (sb.st_mode)) + + if ( +#ifdef DT_DIR + dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN && +#endif + S_ISDIR(sb.st_mode)) + { + char temp[PATH_MAX]; + + (void) sprintf (temp, "%s/%s", file, CVSADM); + if (isdir (temp)) + continue; + } +#ifdef S_ISLNK + else if ( +#ifdef DT_DIR + dp->d_type == DT_LNK || dp->d_type == DT_UNKNOWN && +#endif + S_ISLNK(sb.st_mode)) + { continue; + } #endif - } + } + if (ign_name (file)) continue; (void) write_letter (file, '?', xdir); } (void) closedir (dirp); } + +int +joining () +{ + return (join_rev1 != NULL); +} diff --git a/gnu/usr.bin/cvs/cvs/vers_ts.c b/gnu/usr.bin/cvs/cvs/vers_ts.c index 6ac2488..0bc1242 100644 --- a/gnu/usr.bin/cvs/cvs/vers_ts.c +++ b/gnu/usr.bin/cvs/cvs/vers_ts.c @@ -3,16 +3,17 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. */ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)vers_ts.c 1.36 92/03/31"; +static char rcsid[] = "$CVSid: @(#)vers_ts.c 1.45 94/10/07 $"; +USE(rcsid) #endif -extern char *ctime (); /* XXX - should use gmtime/asctime */ +#define ctime(X) do not use ctime, please /* * Fill in and return a Vers_TS structure "user" is the name of the local @@ -39,7 +40,7 @@ Version_TS (repository, options, tag, date, user, force_tag_match, /* get a new Vers_TS struct */ vers_ts = (Vers_TS *) xmalloc (sizeof (Vers_TS)); - bzero ((char *) vers_ts, sizeof (*vers_ts)); + memset ((char *) vers_ts, 0, sizeof (*vers_ts)); /* * look up the entries file entry and fill in the version and timestamp @@ -63,6 +64,7 @@ Version_TS (repository, options, tag, date, user, force_tag_match, vers_ts->vn_user = xstrdup (entdata->version); vers_ts->ts_rcs = xstrdup (entdata->timestamp); + vers_ts->ts_conflict = xstrdup (entdata->conflict); if (!tag) { if (!(sdtp && sdtp->aflag)) @@ -124,8 +126,10 @@ Version_TS (repository, options, tag, date, user, force_tag_match, else rcsdata = NULL; } - else + else if (repository != NULL) rcsdata = RCS_parse (user, repository); + else + rcsdata = NULL; if (rcsdata != NULL) { @@ -141,7 +145,7 @@ Version_TS (repository, options, tag, date, user, force_tag_match, else vers_ts->vn_rcs = RCS_getversion (rcsdata, vers_ts->tag, vers_ts->date, force_tag_match); - } + } /* * If the source control file exists and has the requested revision, @@ -152,16 +156,19 @@ Version_TS (repository, options, tag, date, user, force_tag_match, { struct utimbuf t; + memset ((char *) &t, 0, sizeof (t)); if (vers_ts->vn_rcs && - (t.actime = t.modtime = RCS_getrevtime (rcsdata, vers_ts->vn_rcs, - (char *) 0, 0)) != -1) + (t.actime = t.modtime = RCS_getrevtime (rcsdata, + vers_ts->vn_rcs, (char *) 0, 0)) != -1) (void) utime (user, &t); } } /* get user file time-stamp in ts_user */ if (entries != (List *) NULL) - vers_ts->ts_user = time_stamp (user); + { + vers_ts->ts_user = time_stamp (user); + } return (vers_ts); } @@ -184,13 +191,10 @@ time_stamp (file) } else { - ts = xmalloc (51); /* 51 = 2 ctime strings + NULL */ - cp = ctime (&sb.st_ctime); /* copy in the create time */ - cp[24] = ' '; + ts = xmalloc (25); + cp = asctime (gmtime (&sb.st_mtime)); /* copy in the modify time */ + cp[24] = 0; (void) strcpy (ts, cp); - cp = ctime (&sb.st_mtime); /* copy in the modify time */ - cp[24] = '\0'; - (void) strcat (ts, cp); } return (ts); @@ -219,6 +223,8 @@ freevers_ts (versp) free ((*versp)->tag); if ((*versp)->date) free ((*versp)->date); + if ((*versp)->ts_conflict) + free ((*versp)->ts_conflict); free ((char *) *versp); *versp = (Vers_TS *) NULL; } diff --git a/gnu/usr.bin/cvs/cvsinit/cvsinit.sh b/gnu/usr.bin/cvs/cvsinit/cvsinit.sh index 58e4332..61f3a10 100644 --- a/gnu/usr.bin/cvs/cvsinit/cvsinit.sh +++ b/gnu/usr.bin/cvs/cvsinit/cvsinit.sh @@ -1,14 +1,18 @@ +#! /bin/sh : # # Copyright (c) 1992, Brian Berliner # # You may distribute under the terms of the GNU General Public License as -# specified in the README file that comes with the CVS 1.3 kit. +# specified in the README file that comes with the CVS 1.4 kit. # -# @(#)cvsinit 1.1 92/03/31 +# $CVSid: @(#)cvsinit.sh 1.1 94/10/22 $ # # This script should be run once to help you setup your site for CVS. +# this line is edited by Makefile when creating cvsinit.inst +CVSLIB="xLIBDIRx" + # Make sure that the CVSROOT variable is set if [ "x$CVSROOT" = x ]; then echo "The CVSROOT environment variable is not set." @@ -155,9 +159,9 @@ else for perlpath in `echo $PATH | sed -e 's/:/ /g'` x; do if [ -f $perlpath/perl ]; then echo "#!$perlpath/perl" > $CVSROOT/CVSROOT/log.pl - cat contrib/log.pl >> $CVSROOT/CVSROOT/log.pl + cat $CVSLIB/contrib/log.pl >> $CVSROOT/CVSROOT/log.pl chmod 755 $CVSROOT/CVSROOT/log.pl - cp examples/loginfo $CVSROOT/CVSROOT/loginfo + cp $CVSLIB/examples/loginfo $CVSROOT/CVSROOT/loginfo break fi done @@ -207,13 +211,15 @@ for info in commitinfo rcsinfo editinfo; do else echo "The $CVSROOT/CVSROOT/$info file does not exist." echo "Making a simple one for you..." - sed -e 's/^\([^#]\)/#\1/' examples/$info > $CVSROOT/CVSROOT/$info + sed -e 's/^\([^#]\)/#\1/' $CVSLIB/examples/$info > $CVSROOT/CVSROOT/$info fi (cd $CVSROOT/CVSROOT; ci -q -u -t/dev/null -m"initial checkin of $info" $info) echo "" fi done +# XXX - also add a stub for the cvsignore file + # Turn on history logging by default if [ ! -f $CVSROOT/CVSROOT/history ]; then echo "Enabling CVS history logging..." diff --git a/gnu/usr.bin/cvs/examples/commitinfo b/gnu/usr.bin/cvs/examples/commitinfo index bdb94b6..7e602e2 100644 --- a/gnu/usr.bin/cvs/examples/commitinfo +++ b/gnu/usr.bin/cvs/examples/commitinfo @@ -1,5 +1,5 @@ # -# commitinfo,v 1.2 1992/03/31 04:19:47 berliner Exp +# $Id: commitinfo,v 1.2 1992/03/31 04:19:47 berliner Exp $ # # The "commitinfo" file is used to control pre-commit checks. # The filter on the right is invoked with the repository and a list diff --git a/gnu/usr.bin/cvs/examples/editinfo b/gnu/usr.bin/cvs/examples/editinfo index b454abd..fb3f4e7 100644 --- a/gnu/usr.bin/cvs/examples/editinfo +++ b/gnu/usr.bin/cvs/examples/editinfo @@ -1,5 +1,5 @@ # -# editinfo,v 1.1 1992/03/21 06:49:39 berliner Exp +# $Id: editinfo,v 1.1 1992/03/21 06:49:39 berliner Exp $ # # The "editinfo" file is used to allow verification of logging # information. It works best when a template (as specified in the diff --git a/gnu/usr.bin/cvs/examples/loginfo b/gnu/usr.bin/cvs/examples/loginfo index 6339439..d9f82da 100644 --- a/gnu/usr.bin/cvs/examples/loginfo +++ b/gnu/usr.bin/cvs/examples/loginfo @@ -1,5 +1,5 @@ # -# @(#)loginfo 1.5 92/03/31 +# $CVSid: @(#)loginfo 1.5 92/03/31 $ # # The "loginfo" file is used to control where "cvs commit" log information # is sent. The first entry on a line is a regular expression which is tested diff --git a/gnu/usr.bin/cvs/examples/modules b/gnu/usr.bin/cvs/examples/modules index 893b47b..891ae3d 100644 --- a/gnu/usr.bin/cvs/examples/modules +++ b/gnu/usr.bin/cvs/examples/modules @@ -1,6 +1,6 @@ # # CVS Modules file for Prisma sources -# @(#)modules 1.5 92/03/31 +# $CVSid: @(#)modules 1.5 92/03/31 $ # # Three different line formats are valid: # key -a aliases... diff --git a/gnu/usr.bin/cvs/examples/rcsinfo b/gnu/usr.bin/cvs/examples/rcsinfo index 6d91455..21a7b47 100644 --- a/gnu/usr.bin/cvs/examples/rcsinfo +++ b/gnu/usr.bin/cvs/examples/rcsinfo @@ -1,5 +1,5 @@ # -# rcsinfo,v 1.3 1992/04/10 18:59:14 berliner Exp +# $Id: rcsinfo,v 1.3 1992/04/10 18:59:14 berliner Exp $ # # The "rcsinfo" file is used to control templates with which the editor # is invoked on commit and import. diff --git a/gnu/usr.bin/cvs/lib/alloca.c b/gnu/usr.bin/cvs/lib/alloca.c index d2a54b3..b57659e 100644 --- a/gnu/usr.bin/cvs/lib/alloca.c +++ b/gnu/usr.bin/cvs/lib/alloca.c @@ -30,7 +30,7 @@ static char SCCSid[] = "@(#)alloca.c 1.1"; /* for the "what" utility */ #endif -#ifdef emacs +#if defined(emacs) || defined(HAVE_CONFIG_H) #include "config.h" #ifdef static /* actually, only want this if static is defined as "" @@ -43,7 +43,7 @@ lose -- must know STACK_DIRECTION at compile-time #endif /* STACK_DIRECTION undefined */ #endif /* static */ -#endif /* emacs */ +#endif /* emacs || HAVE_CONFIG_H*/ #if __STDC__ typedef void *pointer; /* generic pointer type */ diff --git a/gnu/usr.bin/cvs/lib/argmatch.c b/gnu/usr.bin/cvs/lib/argmatch.c index 3f765fe..327a27d 100644 --- a/gnu/usr.bin/cvs/lib/argmatch.c +++ b/gnu/usr.bin/cvs/lib/argmatch.c @@ -17,6 +17,10 @@ /* Written by David MacKenzie <djm@ai.mit.edu> */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #ifdef STDC_HEADERS #include <string.h> diff --git a/gnu/usr.bin/cvs/lib/dup2.c b/gnu/usr.bin/cvs/lib/dup2.c index 0bd3aca..1974383 100644 --- a/gnu/usr.bin/cvs/lib/dup2.c +++ b/gnu/usr.bin/cvs/lib/dup2.c @@ -4,6 +4,10 @@ last edit: 11-Feb-1987 D A Gwyn */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <errno.h> #include <fcntl.h> diff --git a/gnu/usr.bin/cvs/lib/error.c b/gnu/usr.bin/cvs/lib/error.c index fadb1c5..6734c02 100644 --- a/gnu/usr.bin/cvs/lib/error.c +++ b/gnu/usr.bin/cvs/lib/error.c @@ -19,9 +19,13 @@ /* Brian Berliner added support for CVS */ #ifndef lint -static char rcsid[] = "@(#)error.c 1.9 92/03/31"; +static char rcsid[] = "$CVSid: @(#)error.c 1.13 94/09/30 $"; #endif /* not lint */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> /* turn on CVS support by default, since this is the CVS distribution */ @@ -35,7 +39,7 @@ void Lock_Cleanup(); #endif /* __STDC__ */ #endif /* CVS_SUPPORT */ -#ifndef VPRINTF_MISSING +#ifdef HAVE_VPRINTF #if __STDC__ #include <stdarg.h> @@ -47,7 +51,7 @@ void Lock_Cleanup(); #else -#ifndef DOPRNT_MISSING +#ifdef HAVE_DOPRNT #define va_alist args #define va_dcl int args; #else @@ -57,7 +61,7 @@ void Lock_Cleanup(); #endif -#ifdef STDC_HEADERS +#if STDC_HEADERS #include <stdlib.h> #include <string.h> #else @@ -68,19 +72,7 @@ void exit (); #endif /* __STDC__ */ #endif -#ifdef STRERROR_MISSING -static char * -strerror (errnum) - int errnum; -{ - extern char *sys_errlist[]; - extern int sys_nerr; - - if (errnum > 0 && errnum < sys_nerr) - return sys_errlist[errnum]; - return "Unknown system error"; -} -#endif /* STRERROR_MISSING */ +extern char *strerror (); /* Print the program name and error message MESSAGE, which is a printf-style format string with optional args. @@ -88,7 +80,7 @@ strerror (errnum) Exit with status STATUS if it is nonzero. */ /* VARARGS */ void -#if !defined (VPRINTF_MISSING) && __STDC__ +#if defined (HAVE_VPRINTF) && __STDC__ error (int status, int errnum, char *message, ...) #else error (status, errnum, message, va_alist) @@ -102,7 +94,7 @@ error (status, errnum, message, va_alist) #ifdef CVS_SUPPORT extern char *command_name; #endif -#ifndef VPRINTF_MISSING +#ifdef HAVE_VPRINTF va_list args; #endif @@ -117,12 +109,12 @@ error (status, errnum, message, va_alist) #else fprintf (stderr, "%s: ", program_name); #endif -#ifndef VPRINTF_MISSING +#ifdef HAVE_VPRINTF VA_START (args, message); vfprintf (stderr, message, args); va_end (args); #else -#ifndef DOPRNT_MISSING +#ifdef HAVE_DOPRNT _doprnt (message, &args, stderr); #else fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8); @@ -149,7 +141,7 @@ error (status, errnum, message, va_alist) Exit with status STATUS if it is nonzero. */ /* VARARGS */ void -#if !defined (VPRINTF_MISSING) && __STDC__ +#if defined (HAVE_VPRINTF) && __STDC__ fperror (FILE *fp, int status, int errnum, char *message, ...) #else fperror (fp, status, errnum, message, va_alist) @@ -161,17 +153,17 @@ fperror (fp, status, errnum, message, va_alist) #endif { extern char *program_name; -#ifndef VPRINTF_MISSING +#ifdef HAVE_VPRINTF va_list args; #endif fprintf (fp, "%s: ", program_name); -#ifndef VPRINTF_MISSING +#ifdef HAVE_VPRINTF VA_START (args, message); vfprintf (fp, message, args); va_end (args); #else -#ifndef DOPRNT_MISSING +#ifdef HAVE_DOPRNT _doprnt (message, &args, fp); #else fprintf (fp, message, a1, a2, a3, a4, a5, a6, a7, a8); diff --git a/gnu/usr.bin/cvs/lib/fnmatch.c b/gnu/usr.bin/cvs/lib/fnmatch.c index 50fa94c..2a05430 100644 --- a/gnu/usr.bin/cvs/lib/fnmatch.c +++ b/gnu/usr.bin/cvs/lib/fnmatch.c @@ -18,6 +18,10 @@ Cambridge, MA 02139, USA. */ /* Modified slightly by Brian Berliner <berliner@sun.com> for CVS use */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + /* IGNORE(@ */ /* #include <ansidecl.h> */ /* @) */ @@ -28,10 +32,6 @@ Cambridge, MA 02139, USA. */ extern int errno; #endif -#if !__STDC__ -#define const -#endif - /* Match STRING against the filename pattern PATTERN, returning zero if it matches, nonzero if not. */ int diff --git a/gnu/usr.bin/cvs/lib/ftruncate.c b/gnu/usr.bin/cvs/lib/ftruncate.c index 17d263d..13f20a3 100644 --- a/gnu/usr.bin/cvs/lib/ftruncate.c +++ b/gnu/usr.bin/cvs/lib/ftruncate.c @@ -1,6 +1,10 @@ /* ftruncate emulations that work on some System V's. This file is in the public domain. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> #include <fcntl.h> diff --git a/gnu/usr.bin/cvs/lib/getdate.y b/gnu/usr.bin/cvs/lib/getdate.y index d010cb6..5769e9c 100644 --- a/gnu/usr.bin/cvs/lib/getdate.y +++ b/gnu/usr.bin/cvs/lib/getdate.y @@ -1,39 +1,110 @@ %{ -/* 1.8 -** @(#)getdate.y 1.8 92/03/03 -** +/* ** Originally written by Steven M. Bellovin <smb@research.att.com> while ** at the University of North Carolina at Chapel Hill. Later tweaked by ** a couple of people on Usenet. Completely overhauled by Rich $alz ** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990; ** send any email to Rich. ** -** This grammar has eight shift/reduce conflicts. +** This grammar has 10 shift/reduce conflicts. ** ** This code is in the public domain and has no copyright. */ /* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */ /* SUPPRESS 288 on yyerrlab *//* Label unused */ -#include "system.h" +#ifdef HAVE_CONFIG_H +#if defined (emacs) || defined (CONFIG_BROKETS) +#include <config.h> +#else +#include "config.h" +#endif +#endif + +/* Since the code of getdate.y is not included in the Emacs executable + itself, there is no need to #define static in this file. Even if + the code were included in the Emacs executable, it probably + wouldn't do any harm to #undef it here; this will only cause + problems if we try to write to a static variable, which I don't + think this code needs to do. */ +#ifdef emacs +#undef static +#endif + +#include <stdio.h> #include <ctype.h> -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) -#ifdef __GNUC__ -#undef alloca /* might get redefined below */ +/* The code at the top of get_date which figures out the offset of the + current time zone checks various CPP symbols to see if special + tricks are need, but defaults to using the gettimeofday system call. + Include <sys/time.h> if that will be used. */ + +#if defined(vms) + +#include <types.h> +#include <time.h> + +#else + +#include <sys/types.h> + +#ifdef TIME_WITH_SYS_TIME +#include <sys/time.h> +#include <time.h> +#else +#ifdef HAVE_SYS_TIME_H +#include <sys/time.h> +#else +#include <time.h> +#endif +#endif + +#ifdef timezone +#undef timezone /* needed for sgi */ +#endif + +#if defined(HAVE_SYS_TIMEB_H) +#include <sys/timeb.h> +#else +/* +** We use the obsolete `struct timeb' as part of our interface! +** Since the system doesn't have it, we define it here; +** our callers must do likewise. +*/ +struct timeb { + time_t time; /* Seconds since the epoch */ + unsigned short millitm; /* Field not used */ + short timezone; /* Minutes west of GMT */ + short dstflag; /* Field not used */ +}; +#endif /* defined(HAVE_SYS_TIMEB_H) */ + +#endif /* defined(vms) */ + +#if defined (STDC_HEADERS) || defined (USG) +#include <string.h> #endif + +/* Some old versions of bison generate parsers that use bcopy. + That loses on systems that don't provide the function, so we have + to redefine it here. */ +#if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy) +#define bcopy(from, to, len) memcpy ((to), (from), (len)) #endif -extern struct tm *localtime(); +extern struct tm *gmtime(); +extern struct tm *localtime(); #define yyparse getdate_yyparse #define yylex getdate_yylex #define yyerror getdate_yyerror #if !defined(lint) && !defined(SABER) -static char RCS[] = "@(#)getdate.y 1.8 92/03/03"; +static char RCS[] = "$CVSid: @(#)getdate.y 1.11 94/09/21 $"; #endif /* !defined(lint) && !defined(SABER) */ +static int yylex (); +static int yyerror (); #define EPOCH 1970 #define HOUR(x) ((time_t)(x) * 60) @@ -202,6 +273,18 @@ date : tUNUMBER '/' tUNUMBER { yyDay = $3; yyYear = $5; } + | tUNUMBER tSNUMBER tSNUMBER { + /* ISO 8601 format. yyyy-mm-dd. */ + yyYear = $1; + yyMonth = -$2; + yyDay = -$3; + } + | tUNUMBER tMONTH tSNUMBER { + /* e.g. 17-JUN-1992. */ + yyDay = $1; + yyMonth = $2; + yyYear = -$3; + } | tMONTH tUNUMBER { yyMonth = $1; yyDay = $2; @@ -263,25 +346,24 @@ number : tUNUMBER { yyYear = $1; else { if($1>10000) { - time_t date_part; - - date_part= $1/10000; yyHaveDate++; - yyDay= (date_part)%100; - yyMonth= (date_part/100)%100; - yyYear = date_part/10000; - } - yyHaveTime++; - if ($1 < 100) { - yyHour = $1; - yyMinutes = 0; + yyDay= ($1)%100; + yyMonth= ($1/100)%100; + yyYear = $1/10000; } else { - yyHour = $1 / 100; - yyMinutes = $1 % 100; - } - yySeconds = 0; - yyMeridian = MER24; + yyHaveTime++; + if ($1 < 100) { + yyHour = $1; + yyMinutes = 0; + } + else { + yyHour = $1 / 100; + yyMinutes = $1 % 100; + } + yySeconds = 0; + yyMeridian = MER24; + } } } ; @@ -297,7 +379,7 @@ o_merid : /* NULL */ { %% /* Month and day table. */ -static TABLE MonthDayTable[] = { +static TABLE const MonthDayTable[] = { { "january", tMONTH, 1 }, { "february", tMONTH, 2 }, { "march", tMONTH, 3 }, @@ -326,7 +408,7 @@ static TABLE MonthDayTable[] = { }; /* Time units table. */ -static TABLE UnitsTable[] = { +static TABLE const UnitsTable[] = { { "year", tMONTH_UNIT, 12 }, { "month", tMONTH_UNIT, 1 }, { "fortnight", tMINUTE_UNIT, 14 * 24 * 60 }, @@ -341,7 +423,7 @@ static TABLE UnitsTable[] = { }; /* Assorted relative-time words. */ -static TABLE OtherTable[] = { +static TABLE const OtherTable[] = { { "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 }, { "yesterday", tMINUTE_UNIT, -1 * 24 * 60 }, { "today", tMINUTE_UNIT, 0 }, @@ -367,7 +449,7 @@ static TABLE OtherTable[] = { /* The timezone table. */ /* Some of these are commented out because a time_t can't store a float. */ -static TABLE TimezoneTable[] = { +static TABLE const TimezoneTable[] = { { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */ { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */ { "utc", tZONE, HOUR( 0) }, @@ -451,7 +533,7 @@ static TABLE TimezoneTable[] = { }; /* Military timezone table. */ -static TABLE MilitaryTable[] = { +static TABLE const MilitaryTable[] = { { "a", tZONE, HOUR( 1) }, { "b", tZONE, HOUR( 2) }, { "c", tZONE, HOUR( 3) }, @@ -484,7 +566,7 @@ static TABLE MilitaryTable[] = { /* ARGSUSED */ -int +static int yyerror(s) char *s; { @@ -514,6 +596,8 @@ ToSeconds(Hours, Minutes, Seconds, Meridian) if (Hours < 1 || Hours > 12) return -1; return ((Hours + 12) * 60L + Minutes) * 60L + Seconds; + default: + abort (); } /* NOTREACHED */ } @@ -530,7 +614,7 @@ Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode) MERIDIAN Meridian; DSTMODE DSTmode; { - static int DaysInMonth[12] = { + static int DaysInMonth[12] = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; time_t tod; @@ -624,7 +708,7 @@ LookupWord(buff) { register char *p; register char *q; - register TABLE *tp; + register const TABLE *tp; int i; int abbrev; @@ -725,7 +809,7 @@ LookupWord(buff) } -int +static int yylex() { register char c; @@ -777,48 +861,62 @@ yylex() } } +#define TM_YEAR_ORIGIN 1900 + +/* Yield A - B, measured in seconds. */ +static long +difftm (a, b) + struct tm *a, *b; +{ + int ay = a->tm_year + (TM_YEAR_ORIGIN - 1); + int by = b->tm_year + (TM_YEAR_ORIGIN - 1); + int days = ( + /* difference in day of year */ + a->tm_yday - b->tm_yday + /* + intervening leap days */ + + ((ay >> 2) - (by >> 2)) + - (ay/100 - by/100) + + ((ay/100 >> 2) - (by/100 >> 2)) + /* + difference in years * 365 */ + + (long)(ay-by) * 365 + ); + return (60*(60*(24*days + (a->tm_hour - b->tm_hour)) + + (a->tm_min - b->tm_min)) + + (a->tm_sec - b->tm_sec)); +} time_t get_date(p, now) char *p; struct timeb *now; { - struct tm *tm; + struct tm *tm, gmt; struct timeb ftz; time_t Start; time_t tod; yyInput = p; if (now == NULL) { - now = &ftz; -#if defined(FTIME_MISSING) + now = &ftz; (void)time(&ftz.time); - /* Set the timezone global. */ - tzset(); -#if defined(HAVE_TIMEZONE) - tm = localtime(&ftz.time); - ftz.timezone = tm->tm_gmtoff / 60; -#else -#if defined(timezone) - ftz.tzone = (int) timezone / 60; -#else - ftz.timezone = (int) timezone / 60; -#endif /* defined(timezone) */ -#endif /* defined(HAVE_TIMEZONE) */ -#else - (void)ftime(&ftz); -#endif /* defined(FTIME_MISSING) */ + + if (! (tm = gmtime (&ftz.time))) + return -1; + gmt = *tm; /* Make a copy, in case localtime modifies *tm. */ + + if (! (tm = localtime (&ftz.time))) + return -1; + + ftz.timezone = difftm (&gmt, tm) / 60; + if(tm->tm_isdst) + ftz.timezone += 60; } tm = localtime(&now->time); yyYear = tm->tm_year; yyMonth = tm->tm_mon + 1; yyDay = tm->tm_mday; -#if defined(timezone) - yyTimezone = now->tzone; -#else yyTimezone = now->timezone; -#endif /* defined(timezone) */ yyDSTmode = DSTmaybe; yyHour = 0; yyMinutes = 0; @@ -865,6 +963,7 @@ get_date(p, now) #if defined(TEST) /* ARGSUSED */ +int main(ac, av) int ac; char *av[]; diff --git a/gnu/usr.bin/cvs/lib/getopt.c b/gnu/usr.bin/cvs/lib/getopt.c index c322fc2..446a8e4 100644 --- a/gnu/usr.bin/cvs/lib/getopt.c +++ b/gnu/usr.bin/cvs/lib/getopt.c @@ -1,10 +1,15 @@ /* Getopt for GNU. - Copyright (C) 1987-1992 Free Software Foundation, Inc. + NOTE: getopt is now part of the C library, so if you don't know what + "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu + before changing it! - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,73 +18,73 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !__STDC__ +/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. + Ditto for AIX 3.2 and <stdlib.h>. */ +#ifndef _NO_PROTO +#define _NO_PROTO +#endif + +#ifdef HAVE_CONFIG_H +#if defined (emacs) || defined (CONFIG_BROKETS) +/* We use <config.h> instead of "config.h" so that a compilation + using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h + (which it would do because it found this file in $srcdir). */ +#include <config.h> +#else +#include "config.h" +#endif +#endif + +#ifndef __STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const #define const #endif +#endif + +#include <stdio.h> + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +/* Don't include stdlib.h for non-GNU C libraries because some of them + contain conflicting prototypes for getopt. */ +#include <stdlib.h> +#endif /* GNU C library. */ /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. - As `getopt' works, it permutes the elements of `argv' so that, + As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. - Setting the environment variable _POSIX_OPTION_ORDER disables permutation. + Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #ifndef lint -static char rcsid[] = "@(#)getopt.c 1.7 92/03/31"; -#endif - -#include <stdio.h> - -#if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) -#include <stdlib.h> -#else /* STDC_HEADERS or __GNU_LIBRARY__ */ -char *getenv (); -char *malloc (); -#endif /* STDC_HEADERS or __GNU_LIBRARY__ */ - -/* AIX requires this to be the first thing in the file. */ -#ifdef __GNUC__ -#if !defined(bsdi) && !defined(__386BSD__) -#define alloca __builtin_alloca +static char rcsid[] = "$CVSid: @(#)getopt.c 1.10 94/09/21 $"; #endif -#else /* not __GNUC__ */ -#ifdef sparc -#include <alloca.h> -#else -#ifdef _AIX - #pragma alloca -#else -char *alloca (); -#endif -#endif /* sparc */ -#endif /* not __GNUC__ */ -#if defined(USG) || defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) -#include <string.h> -#ifndef bcopy -#define bcopy(s, d, n) memcpy ((d), (s), (n)) -#endif -#ifndef index -#define index strchr -#endif -#else /* USG or STDC_HEADERS or __GNU_LIBRARY__ */ -#ifdef VMS -#include <string.h> -#else /* VMS */ -#include <strings.h> -#endif /* VMS */ -/* Declaring bcopy causes errors on systems whose declarations are different. - If the declaration is omitted, everything works fine. */ -#endif /* USG or STDC_HEADERS or __GNU_LIBRARY__ */ +#include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, @@ -87,7 +92,7 @@ char *alloca (); Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ -char *optarg = 0; +char *optarg = NULL; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller @@ -101,6 +106,7 @@ char *optarg = 0; Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ +/* XXX 1003.2 says this must be 1 before any call. */ int optind = 0; /* The next char to be scanned in the option-element @@ -117,17 +123,23 @@ static char *nextchar; int opterr = 1; +/* Set to an option character which was unrecognized. + This must be initialized on some systems to avoid linking in the + system's own getopt implementation. */ + +int optopt = '?'; + /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable - _POSIX_OPTION_ORDER is defined, PERMUTE otherwise. + POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment - variable POSIX_ME_HARDER, or using `+' as the first character + variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, @@ -151,28 +163,50 @@ static enum REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; -/* Describe the long-named options requested by the application. - _GETOPT_LONG_OPTIONS is a vector of `struct option' terminated by an - element containing a name which is zero. - The field `has_arg' is 1 if the option takes an argument, - 2 if it takes an optional argument. */ - -struct option -{ - char *name; - int has_arg; - int *flag; - int val; -}; +/* Value of POSIXLY_CORRECT environment variable. */ +static char *posixly_correct; + +#ifdef __GNU_LIBRARY__ +/* We want to avoid inclusion of string.h with non-GNU libraries + because there are many ways it can cause trouble. + On some systems, it contains special magic macros that don't work + in GCC. */ +#include <string.h> +#define my_index strchr +#else -const struct option *_getopt_long_options; +/* Avoid depending on library functions or files + whose names are inconsistent. */ -int _getopt_long_only = 0; +char *getenv (); -/* Index in _GETOPT_LONG_OPTIONS of the long-named option actually found. - Only valid when a long-named option was found. */ +static char * +my_index (str, chr) + const char *str; + int chr; +{ + while (*str) + { + if (*str == chr) + return (char *) str; + str++; + } + return 0; +} -int option_index; +/* If using GCC, we can safely declare strlen this way. + If not using GCC, it is ok not to declare it. */ +#ifdef __GNUC__ +/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. + That was relevant to code that was here before. */ +#ifndef __STDC__ +/* gcc with -traditional declares the built-in strlen to return int, + and has done so at least since version 2.4.5. -- rms. */ +extern int strlen (const char *); +#endif /* not __STDC__ */ +#endif /* __GNUC__ */ + +#endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ @@ -185,32 +219,104 @@ static int last_nonopt; /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) - which contains all the non-options that have been skipped so far. + which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all - the options processed since those non-options were skipped. + the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe - the new indices of the non-options in ARGV after they are moved. */ + the new indices of the non-options in ARGV after they are moved. */ static void exchange (argv) char **argv; { - int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *); - char **temp = (char **) alloca (nonopts_size); + int bottom = first_nonopt; + int middle = last_nonopt; + int top = optind; + char *tem; - /* Interchange the two blocks of data in ARGV. */ + /* Exchange the shorter segment with the far end of the longer segment. + That puts the shorter segment into the right place. + It leaves the longer segment in the right place overall, + but it consists of two parts that need to be swapped next. */ + + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + register int i; + + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } + else + { + /* Top segment is the short one. */ + int len = top - middle; + register int i; - bcopy (&argv[first_nonopt], temp, nonopts_size); - bcopy (&argv[last_nonopt], &argv[first_nonopt], - (optind - last_nonopt) * sizeof (char *)); - bcopy (temp, &argv[first_nonopt + optind - last_nonopt], nonopts_size); + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } + +/* Initialize the internal data when the first call is made. */ + +static const char * +_getopt_initialize (optstring) + const char *optstring; +{ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + first_nonopt = last_nonopt = optind = 1; + + nextchar = NULL; + + posixly_correct = getenv ("POSIXLY_CORRECT"); + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (posixly_correct != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + + return optstring; +} /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. @@ -245,78 +351,67 @@ exchange (argv) handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. - Long-named options begin with `+' instead of `-'. + Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field - otherwise. */ + if the `flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of `struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ int -gnu_getopt (argc, argv, optstring) +_getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; - char **argv; + char *const *argv; const char *optstring; + const struct option *longopts; + int *longind; + int long_only; { - optarg = 0; - - /* Initialize the internal data when the first call is made. - Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ + optarg = NULL; if (optind == 0) - { - first_nonopt = last_nonopt = optind = 1; + optstring = _getopt_initialize (optstring); - nextchar = 0; - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') - { - ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - ordering = REQUIRE_ORDER; - ++optstring; - } - else if (getenv ("POSIX_ME_HARDER") != 0) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - } - - if (nextchar == 0 || *nextchar == 0) + if (nextchar == NULL || *nextchar == '\0') { + /* Advance to the next ARGV-element. */ + if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange (argv); + exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; - /* Now skip any additional non-options + /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc - && (argv[optind][0] != '-' - || argv[optind][1] == 0) - && (_getopt_long_options == 0 - || argv[optind][0] != '+' - || argv[optind][1] == 0)) + && (argv[optind][0] != '-' || argv[optind][1] == '\0')) optind++; last_nonopt = optind; } - /* Special ARGV-element `--' means premature end of options. + /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ @@ -326,7 +421,7 @@ gnu_getopt (argc, argv, optstring) optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange (argv); + exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; @@ -349,9 +444,7 @@ gnu_getopt (argc, argv, optstring) /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ - if ((argv[optind][0] != '-' || argv[optind][1] == 0) - && (_getopt_long_options == 0 - || argv[optind][0] != '+' || argv[optind][1] == 0)) + if ((argv[optind][0] != '-' || argv[optind][1] == '\0')) { if (ordering == REQUIRE_ORDER) return EOF; @@ -360,32 +453,48 @@ gnu_getopt (argc, argv, optstring) } /* We have found another option-ARGV-element. - Start decoding its characters. */ + Skip the initial punctuation. */ - nextchar = argv[optind] + 1; + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[optind][1] == '-')); } - if (_getopt_long_options != 0 - && (argv[optind][0] == '+' - || (_getopt_long_only && argv[optind][0] == '-')) - ) + /* Decode the current option-ARGV-element. */ + + /* Check whether the ARGV-element is a long option. + + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an abbreviation of + the long option, just like "--fu", and not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + + if (longopts != NULL + && (argv[optind][1] == '-' + || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { + char *nameend; const struct option *p; - char *s = nextchar; + const struct option *pfound = NULL; int exact = 0; int ambig = 0; - const struct option *pfound = 0; - int indfound = 0; + int indfound; + int option_index; - while (*s && *s != '=') - s++; + for (nameend = nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; - /* Test all options for either exact match or abbreviated matches. */ - for (p = _getopt_long_options, option_index = 0; p->name; - p++, option_index++) - if (!strncmp (p->name, nextchar, s - nextchar)) + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) { - if (s - nextchar == strlen (p->name)) + if (nameend - nextchar == strlen (p->name)) { /* Exact match found. */ pfound = p; @@ -393,39 +502,52 @@ gnu_getopt (argc, argv, optstring) exact = 1; break; } - else if (pfound == 0) + else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else - /* Second nonexact match found. */ + /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { - fprintf (stderr, "%s: option `%s' is ambiguous\n", - argv[0], argv[optind]); + if (opterr) + fprintf (stderr, "%s: option `%s' is ambiguous\n", + argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; return '?'; } - if (pfound != 0) + if (pfound != NULL) { option_index = indfound; optind++; - if (*s) + if (*nameend) { - if (pfound->has_arg > 0) - optarg = s + 1; + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; else { - fprintf (stderr, - "%s: option `%c%s' doesn't allow an argument\n", - argv[0], argv[optind - 1][0], pfound->name); + if (opterr) + { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + "%s: option `--%s' doesn't allow an argument\n", + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + "%s: option `%c%s' doesn't allow an argument\n", + argv[0], argv[optind - 1][0], pfound->name); + } nextchar += strlen (nextchar); return '?'; } @@ -436,13 +558,16 @@ gnu_getopt (argc, argv, optstring) optarg = argv[optind++]; else { - fprintf (stderr, "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); + if (opterr) + fprintf (stderr, "%s: option `%s' requires an argument\n", + argv[0], argv[optind - 1]); nextchar += strlen (nextchar); - return '?'; + return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; @@ -450,43 +575,52 @@ gnu_getopt (argc, argv, optstring) } return pfound->val; } - /* Can't find it as a long option. If this is getopt_long_only, - and the option starts with '-' and is a valid short - option, then interpret it as a short option. Otherwise it's - an error. */ - if (_getopt_long_only == 0 || argv[optind][0] == '+' || - index (optstring, *nextchar) == 0) + + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' + || my_index (optstring, *nextchar) == NULL) { - if (opterr != 0) - fprintf (stderr, "%s: unrecognized option `%c%s'\n", - argv[0], argv[optind][0], nextchar); - nextchar += strlen (nextchar); + if (opterr) + { + if (argv[optind][1] == '-') + /* --option */ + fprintf (stderr, "%s: unrecognized option `--%s'\n", + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, "%s: unrecognized option `%c%s'\n", + argv[0], argv[optind][0], nextchar); + } + nextchar = (char *) ""; optind++; return '?'; } } - /* Look at and handle the next option-character. */ + /* Look at and handle the next short option-character. */ { char c = *nextchar++; - char *temp = index (optstring, c); + char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ - if (*nextchar == 0) - optind++; + if (*nextchar == '\0') + ++optind; - if (temp == 0 || c == ':') + if (temp == NULL || c == ':') { - if (opterr != 0) + if (opterr) { - if (c < 040 || c >= 0177) - fprintf (stderr, "%s: unrecognized option, character code 0%o\n", - argv[0], c); + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); else - fprintf (stderr, "%s: unrecognized option `-%c'\n", - argv[0], c); + fprintf (stderr, "%s: invalid option -- %c\n", argv[0], c); } + optopt = c; return '?'; } if (temp[1] == ':') @@ -494,19 +628,19 @@ gnu_getopt (argc, argv, optstring) if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ - if (*nextchar != 0) + if (*nextchar != '\0') { optarg = nextchar; optind++; } else - optarg = 0; - nextchar = 0; + optarg = NULL; + nextchar = NULL; } else { /* This is an option that requires an argument. */ - if (*nextchar != 0) + if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, @@ -515,21 +649,42 @@ gnu_getopt (argc, argv, optstring) } else if (optind == argc) { - if (opterr != 0) - fprintf (stderr, "%s: option `-%c' requires an argument\n", - argv[0], c); - c = '?'; + if (opterr) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, "%s: option requires an argument -- %c\n", + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; - nextchar = 0; + nextchar = NULL; } } return c; } } + +int +getopt (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); +} + +#endif /* _LIBC or not __GNU_LIBRARY__. */ #ifdef TEST @@ -548,7 +703,7 @@ main (argc, argv) { int this_option_optind = optind ? optind : 1; - c = gnu_getopt (argc, argv, "abc:d:0123456789"); + c = getopt (argc, argv, "abc:d:0123456789"); if (c == EOF) break; diff --git a/gnu/usr.bin/cvs/lib/getopt.h b/gnu/usr.bin/cvs/lib/getopt.h index 5f902de..f644aa1 100644 --- a/gnu/usr.bin/cvs/lib/getopt.h +++ b/gnu/usr.bin/cvs/lib/getopt.h @@ -1,10 +1,10 @@ -/* declarations for getopt - Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. +/* Declarations for getopt. + Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,9 +13,16 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* @(#)getopt.h 1.6 92/03/31 */ +/* $CVSid: @(#)getopt.h 1.7 94/09/21 $ */ + +#ifndef _GETOPT_H +#define _GETOPT_H 1 + +#ifdef __cplusplus +extern "C" { +#endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, @@ -44,16 +51,21 @@ extern int optind; extern int opterr; +/* Set to an option character which was unrecognized. */ + +extern int optopt; + /* Describe the long-named options requested by the application. - _GETOPT_LONG_OPTIONS is a vector of `struct option' terminated by an - element containing a name which is zero. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. The field `has_arg' is: - 0 if the option does not take an argument, - 1 if the option requires an argument, - 2 if the option takes an optional argument. + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. - If the field `flag' is nonzero, it points to a variable that is set + If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. @@ -66,37 +78,54 @@ extern int opterr; struct option { +#if __STDC__ + const char *name; +#else char *name; +#endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; -#if __STDC__ -extern const struct option *_getopt_long_options; -#else -extern struct option *_getopt_long_options; -#endif - -/* If nonzero, '-' can introduce long-named options. - Set by getopt_long_only. */ - -extern int _getopt_long_only; +/* Names for the values of the `has_arg' field of `struct option'. */ -/* The index in GETOPT_LONG_OPTIONS of the long-named option found. - Only valid when a long-named option has been found by the most - recent call to `getopt'. */ - -extern int option_index; +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 #if __STDC__ -int gnu_getopt (int argc, char **argv, const char *shortopts); -int gnu_getopt_long (int argc, char **argv, const char *shortopts, - const struct option *longopts, int *longind); -int gnu_getopt_long_only (int argc, char **argv, const char *shortopts, - const struct option *longopts, int *longind); -#else -int gnu_getopt (); -int gnu_getopt_long (); -int gnu_getopt_long_only (); +#if defined(__GNU_LIBRARY__) +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int argc, char *const *argv, const char *shortopts); +#else /* not __GNU_LIBRARY__ */ +extern int getopt (); +#endif /* not __GNU_LIBRARY__ */ +extern int getopt_long (int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +extern int getopt_long_only (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind, + int long_only); +#else /* not __STDC__ */ +extern int getopt (); +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +#endif /* not __STDC__ */ + +#ifdef __cplusplus +} #endif + +#endif /* _GETOPT_H */ diff --git a/gnu/usr.bin/cvs/lib/getopt1.c b/gnu/usr.bin/cvs/lib/getopt1.c index 8606462..f784b57 100644 --- a/gnu/usr.bin/cvs/lib/getopt1.c +++ b/gnu/usr.bin/cvs/lib/getopt1.c @@ -1,10 +1,11 @@ -/* Getopt for GNU. - Copyright (C) 1987-1992 Free Software Foundation, Inc. +/* getopt_long and getopt_long_only entry points for GNU getopt. + Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 + Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,67 +14,84 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef HAVE_CONFIG_H +#if defined (emacs) || defined (CONFIG_BROKETS) +/* We use <config.h> instead of "config.h" so that a compilation + using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h + (which it would do because it found this file in $srcdir). */ +#include <config.h> +#else +#include "config.h" +#endif +#endif + #include "getopt.h" -#if !__STDC__ +#ifndef __STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const #define const #endif +#endif + +#include <stdio.h> + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) + -#if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ #include <stdlib.h> -#else /* STDC_HEADERS or __GNU_LIBRARY__ */ +#else char *getenv (); -#endif /* STDC_HEADERS or __GNU_LIBRARY__ */ +#endif -#if !defined (NULL) +#ifndef NULL #define NULL 0 #endif int -gnu_getopt_long (argc, argv, options, long_options, opt_index) +getopt_long (argc, argv, options, long_options, opt_index) int argc; - char **argv; + char *const *argv; const char *options; const struct option *long_options; int *opt_index; { - int val; - - /* For strict POSIX compatibility, we must turn off long options. */ - if (getenv ("POSIX_ME_HARDER") == 0) - _getopt_long_options = long_options; - val = gnu_getopt (argc, argv, options); - if (val == 0 && opt_index != NULL) - *opt_index = option_index; - return val; + return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } -/* Like getopt_long, but '-' as well as '+' can indicate a long option. - If an option that starts with '-' doesn't match a long option, +/* Like getopt_long, but '-' as well as '--' can indicate a long option. + If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option - instead. */ + instead. */ -int -gnu_getopt_long_only (argc, argv, options, long_options, opt_index) +int +getopt_long_only (argc, argv, options, long_options, opt_index) int argc; - char **argv; + char *const *argv; const char *options; const struct option *long_options; int *opt_index; { - int val; - - _getopt_long_options = long_options; - _getopt_long_only = 1; - val = gnu_getopt (argc, argv, options); - if (val == 0 && opt_index != NULL) - *opt_index = option_index; - return val; + return _getopt_internal (argc, argv, options, long_options, opt_index, 1); } - + +#endif /* _LIBC or not __GNU_LIBRARY__. */ + #ifdef TEST #include <stdio.h> @@ -89,7 +107,6 @@ main (argc, argv) while (1) { int this_option_optind = optind ? optind : 1; - char *name = '\0'; int option_index = 0; static struct option long_options[] = { @@ -110,7 +127,7 @@ main (argc, argv) switch (c) { case 0: - printf ("option %s", (long_options[option_index]).name); + printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); @@ -144,6 +161,10 @@ main (argc, argv) printf ("option c with value `%s'\n", optarg); break; + case 'd': + printf ("option d with value `%s'\n", optarg); + break; + case '?': break; diff --git a/gnu/usr.bin/cvs/lib/getwd.c b/gnu/usr.bin/cvs/lib/getwd.c index 854feaf..573a788 100644 --- a/gnu/usr.bin/cvs/lib/getwd.c +++ b/gnu/usr.bin/cvs/lib/getwd.c @@ -19,6 +19,10 @@ of getwd() which is much faster than getcwd(). As a result, we use the system's getwd() if it is available */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "system.h" /* Get the current working directory into PATHNAME */ diff --git a/gnu/usr.bin/cvs/lib/hash.c b/gnu/usr.bin/cvs/lib/hash.c index fb29497..afc554d 100644 --- a/gnu/usr.bin/cvs/lib/hash.c +++ b/gnu/usr.bin/cvs/lib/hash.c @@ -2,7 +2,7 @@ * Copyright (c) 1992, Brian Berliner and Jeff Polk * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Polk's hash list manager. So cool. */ @@ -10,31 +10,32 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "@(#)hash.c 1.14 92/03/31"; +static char rcsid[] = "$CVSid: @(#)hash.c 1.19 94/09/23 $"; +USE(rcsid) #endif /* global caches */ static List *listcache = NULL; static Node *nodecache = NULL; -#if __STDC__ -static void freenode_mem (Node * p); -#else -static void freenode_mem (); -#endif /* __STDC__ */ +static void freenode_mem PROTO((Node * p)); /* hash function */ static int hashp (key) char *key; { - register char *p; - register int n = 0; + unsigned int h = 0; + unsigned int g; - for (p = key; *p; p++) - n += *p; + while (*key != 0) + { + h = (h << 4) + *key++; + if ((g = h & 0xf0000000) != 0) + h = (h ^ (g >> 24)) ^ g; + } - return (n % HASHSIZE); + return (h % HASHSIZE); } /* @@ -60,7 +61,7 @@ getlist () { /* make a new list from scratch */ list = (List *) xmalloc (sizeof (List)); - bzero ((char *) list, sizeof (List)); + memset ((char *) list, 0, sizeof (List)); node = getnode (); list->list = node; node->type = HEADER; @@ -130,7 +131,7 @@ getnode () } /* always make it clean */ - bzero ((char *) p, sizeof (Node)); + memset ((char *) p, 0, sizeof (Node)); p->type = UNKNOWN; return (p); @@ -247,7 +248,8 @@ addnode (list, p) } /* - * look up an entry in hash list table + * look up an entry in hash list table and return a pointer to the + * node. Return NULL on error or not found. */ Node * findnode (list, key) @@ -273,9 +275,10 @@ findnode (list, key) * walk a list with a specific proc */ int -walklist (list, proc) +walklist (list, proc, closure) List *list; int (*proc) (); + void *closure; { Node *head, *p; int err = 0; @@ -285,7 +288,7 @@ walklist (list, proc) head = list->list; for (p = head->next; p != head; p = p->next) - err += proc (p); + err += proc (p, closure); return (err); } @@ -336,3 +339,61 @@ sortlist (list, comp) } } } + +/* Debugging functions. Quite useful to call from within gdb. */ + +char * +nodetypestring (type) + Ntype type; +{ + switch (type) { + case UNKNOWN: return("UNKNOWN"); + case HEADER: return("HEADER"); + case ENTRIES: return("ENTRIES"); + case FILES: return("FILES"); + case LIST: return("LIST"); + case RCSNODE: return("RCSNODE"); + case RCSVERS: return("RCSVERS"); + case DIRS: return("DIRS"); + case UPDATE: return("UPDATE"); + case LOCK: return("LOCK"); + case NDBMNODE: return("NDBMNODE"); + } + + return("<trash>"); +} + +int +printnode (node, closure) + Node *node; + void *closure; +{ + if (node == NULL) + { + (void) printf("NULL node.\n"); + return(0); + } + + (void) printf("Node at 0x%p: type = %s, key = 0x%p = \"%s\", data = 0x%p, next = 0x%p, prev = 0x%p\n", + node, nodetypestring(node->type), node->key, node->key, node->data, node->next, node->prev); + + return(0); +} + +void +printlist (list) + List *list; +{ + if (list == NULL) + { + (void) printf("NULL list.\n"); + return; + } + + (void) printf("List at 0x%p: list = 0x%p, HASHSIZE = %d, next = 0x%p\n", + list, list->list, HASHSIZE, list->next); + + (void) walklist(list, printnode, NULL); + + return; +} diff --git a/gnu/usr.bin/cvs/lib/hash.h b/gnu/usr.bin/cvs/lib/hash.h index 54f227e..8e10e81 100644 --- a/gnu/usr.bin/cvs/lib/hash.h +++ b/gnu/usr.bin/cvs/lib/hash.h @@ -1,10 +1,10 @@ -/* @(#)hash.h 1.18 92/03/31 */ +/* $CVSid: @(#)hash.h 1.23 94/10/07 $ */ /* * Copyright (c) 1992, Brian Berliner and Jeff Polk * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. */ /* @@ -51,27 +51,16 @@ struct entnode char *options; char *tag; char *date; + char *conflict; }; typedef struct entnode Entnode; -#if __STDC__ -List *getlist (void); -Node *findnode (List * list, char *key); -Node *getnode (void); -int addnode (List * list, Node * p); -int walklist (List * list, int (*proc) ()); -void dellist (List ** listp); -void delnode (Node * p); -void freenode (Node * p); -void sortlist (List * list, int (*comp) ()); -#else -List *getlist (); -Node *findnode (); -Node *getnode (); -int addnode (); -int walklist (); -void dellist (); -void delnode (); -void freenode (); -void sortlist (); -#endif /* __STDC__ */ +List *getlist PROTO((void)); +Node *findnode PROTO((List * list, char *key)); +Node *getnode PROTO((void)); +int addnode PROTO((List * list, Node * p)); +int walklist PROTO((List * list, int PROTO((*proc)) PROTO((Node *n, void *closure)), void *closure)); +void dellist PROTO((List ** listp)); +void delnode PROTO((Node * p)); +void freenode PROTO((Node * p)); +void sortlist PROTO((List * list, int PROTO((*comp))())); diff --git a/gnu/usr.bin/cvs/lib/mkdir.c b/gnu/usr.bin/cvs/lib/mkdir.c index b17cca2..a70c1d8 100644 --- a/gnu/usr.bin/cvs/lib/mkdir.c +++ b/gnu/usr.bin/cvs/lib/mkdir.c @@ -15,6 +15,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> #include <sys/stat.h> #include <errno.h> diff --git a/gnu/usr.bin/cvs/lib/myndbm.c b/gnu/usr.bin/cvs/lib/myndbm.c index 8069698..33ef49c 100644 --- a/gnu/usr.bin/cvs/lib/myndbm.c +++ b/gnu/usr.bin/cvs/lib/myndbm.c @@ -2,7 +2,7 @@ * Copyright (c) 1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * A simple ndbm-emulator for CVS. It parses a text file of the format: * @@ -18,7 +18,8 @@ #ifdef MY_NDBM #ifndef lint -static char rcsid[] = "@(#)myndbm.c 1.5 92/03/31"; +static char rcsid[] = "$CVSid: @(#)myndbm.c 1.7 94/09/23 $"; +USE(rcsid) #endif static void mydbm_load_file (); @@ -138,7 +139,7 @@ mydbm_load_file (fp, list) for (cont = 0; fgets (line, sizeof (line), fp) != NULL;) { - if ((cp = rindex (line, '\n')) != NULL) + if ((cp = strrchr (line, '\n')) != NULL) *cp = '\0'; /* strip the newline */ /* diff --git a/gnu/usr.bin/cvs/lib/myndbm.h b/gnu/usr.bin/cvs/lib/myndbm.h index d71acdf..3af31305 100644 --- a/gnu/usr.bin/cvs/lib/myndbm.h +++ b/gnu/usr.bin/cvs/lib/myndbm.h @@ -1,4 +1,4 @@ -/* @(#)myndbm.h 1.3 92/02/29 */ +/* $CVSid: @(#)myndbm.h 1.4 94/09/21 $ */ #ifdef MY_NDBM @@ -27,18 +27,10 @@ typedef struct #define dbm_firstkey mydbm_firstkey #define dbm_nextkey mydbm_nextkey -#if __STDC__ -DBM *mydbm_open (char *file, int flags, int mode); -void mydbm_close (DBM * db); -datum mydbm_fetch (DBM * db, datum key); -datum mydbm_firstkey (DBM * db); -datum mydbm_nextkey (DBM * db); -#else -DBM *mydbm_open (); -void mydbm_close (); -datum mydbm_fetch (); -datum mydbm_firstkey (); -datum mydbm_nextkey (); -#endif /* __STDC__ */ +DBM *mydbm_open PROTO((char *file, int flags, int mode)); +void mydbm_close PROTO((DBM * db)); +datum mydbm_fetch PROTO((DBM * db, datum key)); +datum mydbm_firstkey PROTO((DBM * db)); +datum mydbm_nextkey PROTO((DBM * db)); #endif /* MY_NDBM */ diff --git a/gnu/usr.bin/cvs/lib/regex.c b/gnu/usr.bin/cvs/lib/regex.c index 3bccfd3..8169880 100644 --- a/gnu/usr.bin/cvs/lib/regex.c +++ b/gnu/usr.bin/cvs/lib/regex.c @@ -1,8 +1,9 @@ /* Extended regular expression matching and search library, - version 0.4. - (Implements POSIX draft P10003.2/D11.2, except for multibyte characters.) + version 0.12. + (Implements POSIX draft P10003.2/D11.2, except for + internationalization features.) - Copyright (C) 1985, 1989, 1990, 1991, 1992 Free Software Foundation, Inc. + Copyright (C) 1993 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,26 +19,24 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* AIX requires this to be the first thing in the file. */ #if defined (_AIX) && !defined (REGEX_MALLOC) #pragma alloca #endif #define _GNU_SOURCE -/* For interactive testing, compile with -Dtest. Then this becomes - a self-contained program which reads a pattern, describes how it - compiles, then reads a string and searches for it. If a command-line - argument is present, it is taken to be the value for obscure_syntax (in - decimal). The default is 0 (Emacs-style syntax). - - If DEBUG is defined, this prints many voluminous messages about what - it is doing (if the variable `debug' is nonzero). */ +/* We need this for `regex.h', and perhaps for the Emacs include files. */ +#include <sys/types.h> +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* The `emacs' switch turns on certain matching commands that make sense only in Emacs. */ #ifdef emacs -#include "config.h" + #include "lisp.h" #include "buffer.h" #include "syntax.h" @@ -47,41 +46,31 @@ #else /* not emacs */ -/* POSIX.1 says that <unistd.h> might need <sys/types.h>. We also need - it for regex.h. */ -#include <sys/types.h> - -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -#if defined (USG) || defined (POSIX) || defined (STDC_HEADERS) -#ifndef BSTRING +/* We used to test for `BSTRING' here, but only GCC and Emacs define + `BSTRING', as far as I know, and neither of them use this code. */ +#if HAVE_STRING_H || STDC_HEADERS #include <string.h> -#ifndef bcopy -#define bcopy(s,d,n) memcpy ((d), (s), (n)) -#endif #ifndef bcmp -#define bcmp(s1,s2,n) memcmp ((s1), (s2), (n)) +#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) +#endif +#ifndef bcopy +#define bcopy(s, d, n) memcpy ((d), (s), (n)) #endif #ifndef bzero -#define bzero(s,n) memset ((s), 0, (n)) +#define bzero(s, n) memset ((s), 0, (n)) +#endif +#else +#include <strings.h> #endif -#endif /* not BSTRING */ -#endif /* USG or POSIX or STDC_HEADERS */ #ifdef STDC_HEADERS #include <stdlib.h> -#else /* not STDC_HEADERS */ +#else char *malloc (); char *realloc (); -#endif /* not STDC_HEADERS */ - -/* If debugging, we use standard I/O. */ -#ifdef DEBUG -#include <stdio.h> #endif + /* Define the syntax stuff for \<, \>, etc. */ /* This must be nonzero for the wordchar and notwordchar pattern @@ -97,7 +86,7 @@ extern char *re_syntax_table; #else /* not SYNTAX_TABLE */ /* How many characters in the character set. */ -#define CHAR_SET_SIZE 256 +#define CHAR_SET_SIZE 256 static char re_syntax_table[CHAR_SET_SIZE]; @@ -131,33 +120,55 @@ init_syntax_once () #define SYNTAX(c) re_syntax_table[c] #endif /* not emacs */ - - + /* Get the interface, including the syntax bits. */ #include "regex.h" - -/* isalpha(3) etc. are used for the character classes. */ +/* isalpha etc. are used for the character classes. */ #include <ctype.h> -#ifndef isgraph -#define isgraph(c) (isprint (c) && !isspace (c)) + +#ifndef isascii +#define isascii(c) 1 #endif -#ifndef isblank -#define isblank(c) ((c) == ' ' || (c) == '\t') + +#ifdef isblank +#define ISBLANK(c) (isascii (c) && isblank (c)) +#else +#define ISBLANK(c) ((c) == ' ' || (c) == '\t') +#endif +#ifdef isgraph +#define ISGRAPH(c) (isascii (c) && isgraph (c)) +#else +#define ISGRAPH(c) (isascii (c) && isprint (c) && !isspace (c)) #endif +#define ISPRINT(c) (isascii (c) && isprint (c)) +#define ISDIGIT(c) (isascii (c) && isdigit (c)) +#define ISALNUM(c) (isascii (c) && isalnum (c)) +#define ISALPHA(c) (isascii (c) && isalpha (c)) +#define ISCNTRL(c) (isascii (c) && iscntrl (c)) +#define ISLOWER(c) (isascii (c) && islower (c)) +#define ISPUNCT(c) (isascii (c) && ispunct (c)) +#define ISSPACE(c) (isascii (c) && isspace (c)) +#define ISUPPER(c) (isascii (c) && isupper (c)) +#define ISXDIGIT(c) (isascii (c) && isxdigit (c)) + #ifndef NULL #define NULL 0 #endif -#ifndef SIGN_EXTEND_CHAR -#ifdef __CHAR_UNSIGNED__ /* for, e.g., IBM RT */ -#define SIGN_EXTEND_CHAR(c) (((c)^128) - 128) /* As in Harbison and Steele. */ -#else -#define SIGN_EXTEND_CHAR /* As nothing. */ -#endif /* not CHAR_UNSIGNED */ -#endif /* not SIGN_EXTEND_CHAR */ - +/* We remove any previous definition of `SIGN_EXTEND_CHAR', + since ours (we hope) works properly with all combinations of + machines, compilers, `char' and `unsigned char' argument types. + (Per Bothner suggested the basic approach.) */ +#undef SIGN_EXTEND_CHAR +#if __STDC__ +#define SIGN_EXTEND_CHAR(c) ((signed char) (c)) +#else /* not __STDC__ */ +/* As in Harbison and Steele. */ +#define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) +#endif + /* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we use `alloca' instead of `malloc'. This is because using malloc in re_search* or re_match* could cause memory leaks when C-g is used in @@ -165,12 +176,13 @@ init_syntax_once () the other hand, malloc is more portable, and easier to debug. Because we sometimes use alloca, some routines have to be macros, - not functions---alloca-allocated space disappears at the end of the + not functions -- `alloca'-allocated space disappears at the end of the function it is called in. */ + #ifdef REGEX_MALLOC #define REGEX_ALLOCATE malloc -#define REGEX_REALLOCATE(source, size) (realloc (source, size)) +#define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) #else /* not REGEX_MALLOC */ @@ -181,31 +193,38 @@ init_syntax_once () #ifdef __GNUC__ #define alloca __builtin_alloca #else /* not __GNUC__ */ -#ifdef sparc +#if HAVE_ALLOCA_H #include <alloca.h> -#else /* not __GNUC__ or sparc */ +#else /* not __GNUC__ or HAVE_ALLOCA_H */ +#ifndef _AIX /* Already did AIX, up at the top. */ char *alloca (); -#endif /* not sparc */ -#endif /* not __GNUC__ */ +#endif /* not _AIX */ +#endif /* not HAVE_ALLOCA_H */ +#endif /* not __GNUC__ */ #endif /* not alloca */ -/* Still not REGEX_MALLOC. */ - #define REGEX_ALLOCATE alloca -/* Requires a `char *destination' declared. */ -#define REGEX_REALLOCATE(source, size) \ - (destination = (char *) alloca (size), \ - bcopy (source, destination, size), \ +/* Assumes a `char *destination' variable. */ +#define REGEX_REALLOCATE(source, osize, nsize) \ + (destination = (char *) alloca (nsize), \ + bcopy (source, destination, osize), \ destination) #endif /* not REGEX_MALLOC */ + +/* True if `size1' is non-NULL and PTR is pointing anywhere inside + `string1' or just past its end. This works if PTR is NULL, which is + a good thing. */ +#define FIRST_STRING_P(ptr) \ + (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) + /* (Re)Allocate N items of type T using malloc, or fail. */ -#define TALLOC(n, t) (t *) malloc ((n) * sizeof (t)) +#define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t))) #define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t))) - +#define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t))) #define BYTEWIDTH 8 /* In bits. */ @@ -213,6 +232,10 @@ char *alloca (); #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) + +typedef char boolean; +#define false 0 +#define true 1 /* These are the command codes that appear in compiled regular expressions. Some opcodes are followed by argument bytes. A @@ -281,17 +304,17 @@ typedef enum endbuf, /* Followed by two byte relative address to which to jump. */ - no_pop_jump, + jump, - /* Same as no_pop_jump, but marks the end of an alternative. */ - jump_past_next_alt, + /* Same as jump, but marks the end of an alternative. */ + jump_past_alt, /* Followed by two-byte relative address of place to resume at in case of failure. */ on_failure_jump, /* Like on_failure_jump, but pushes a placeholder instead of the - current string position. */ + current string position when executed. */ on_failure_keep_string_jump, /* Throw away latest failure point and then jump to following @@ -299,7 +322,7 @@ typedef enum pop_failure_jump, /* Change to pop_failure_jump if know won't have to backtrack to - match; otherwise change to no_pop_jump. This is used to jump + match; otherwise change to jump. This is used to jump back to the beginning of a repeat. If what follows this jump clearly won't match what the repeat does, such that we can be sure that there is no use backtracking out of repetitions @@ -314,18 +337,21 @@ typedef enum of jump when compiling an alternative. */ dummy_failure_jump, - /* Used like on_failure_jump except has to succeed n times; The - two-byte relative address following it is useless until then. - The address is followed by two more bytes containing n. */ + /* Push a dummy failure point and continue. Used at the end of + alternatives. */ + push_dummy_failure, + + /* Followed by two-byte relative address and two-byte number n. + After matching N times, jump to the address upon failure. */ succeed_n, - /* Similar to no_pop_jump, but jump n times only; also the - relative address following is in turn followed by yet two - more bytes containing n. */ - no_pop_jump_n, + /* Followed by two-byte relative address, and two-byte number n. + Jump to the address N times, then fail. */ + jump_n, - /* Set the following relative location (two bytes) to the - subsequent (two-byte) number. */ + /* Set the following two-byte relative address to the + subsequent two-byte number. The address *includes* the two + bytes of number. */ set_number_at, wordchar, /* Matches any word-constituent character. */ @@ -361,7 +387,6 @@ typedef enum (destination)[1] = (number) >> 8; \ } while (0) - /* Same as STORE_NUMBER, except increment DESTINATION to the byte after where the number is stored. Therefore, DESTINATION must be an lvalue. */ @@ -372,28 +397,32 @@ typedef enum (destination) += 2; \ } while (0) - /* Put into DESTINATION a number stored in two contiguous bytes starting at SOURCE. */ #define EXTRACT_NUMBER(destination, source) \ do { \ (destination) = *(source) & 0377; \ - (destination) += SIGN_EXTEND_CHAR (*(const char *)((source) + 1)) << 8;\ + (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \ } while (0) #ifdef DEBUG -static int -extract_number (source) +static void +extract_number (dest, source) + int *dest; unsigned char *source; { - int answer = *source & 0377; - answer += (SIGN_EXTEND_CHAR (*(char *)((source) + 1))) << 8; - - return answer; + int temp = SIGN_EXTEND_CHAR (*(source + 1)); + *dest = *source & 0377; + *dest += temp << 8; } -#endif +#ifndef EXTRACT_MACROS /* To debug the macros. */ +#undef EXTRACT_NUMBER +#define EXTRACT_NUMBER(dest, src) extract_number (&dest, src) +#endif /* not EXTRACT_MACROS */ + +#endif /* DEBUG */ /* Same as EXTRACT_NUMBER, except increment SOURCE to after the number. SOURCE must be an lvalue. */ @@ -410,32 +439,86 @@ extract_number_and_incr (destination, source) int *destination; unsigned char **source; { - *destination = extract_number (*source); + extract_number (destination, *source); *source += 2; } -#endif +#ifndef EXTRACT_MACROS +#undef EXTRACT_NUMBER_AND_INCR +#define EXTRACT_NUMBER_AND_INCR(dest, src) \ + extract_number_and_incr (&dest, &src) +#endif /* not EXTRACT_MACROS */ -/* Is true if there is a first string and if PTR is pointing anywhere - inside it or just past the end. */ - -#define IS_IN_FIRST_STRING(ptr) \ - (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) +#endif /* DEBUG */ +/* If DEBUG is defined, Regex prints many voluminous messages about what + it is doing (if the variable `debug' is nonzero). If linked with the + main program in `iregex.c', you can enter patterns and strings + interactively. And if linked with the main program in `main.c' and + the other test files, you can run the already-written tests. */ + #ifdef DEBUG +/* We use standard I/O for debugging. */ +#include <stdio.h> + +/* It is useful to test things that ``must'' be true when debugging. */ +#include <assert.h> + +static int debug = 0; + +#define DEBUG_STATEMENT(e) e +#define DEBUG_PRINT1(x) if (debug) printf (x) +#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) +#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) +#define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4) +#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ + if (debug) print_partial_compiled_pattern (s, e) +#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ + if (debug) print_double_string (w, s1, sz1, s2, sz2) + + extern void printchar (); -/* Print a compiled pattern buffer in human-readable form, starting at +/* Print the fastmap in human-readable form. */ + +void +print_fastmap (fastmap) + char *fastmap; +{ + unsigned was_a_range = 0; + unsigned i = 0; + + while (i < (1 << BYTEWIDTH)) + { + if (fastmap[i++]) + { + was_a_range = 0; + printchar (i - 1); + while (i < (1 << BYTEWIDTH) && fastmap[i]) + { + was_a_range = 1; + i++; + } + if (was_a_range) + { + printf ("-"); + printchar (i - 1); + } + } + } + putchar ('\n'); +} + + +/* Print a compiled pattern string in human-readable form, starting at the START pointer into it and ending just before the pointer END. */ -static void -partial_compiled_pattern_printer (pbufp, start, end) - struct re_pattern_buffer *pbufp; +void +print_partial_compiled_pattern (start, end) unsigned char *start; unsigned char *end; { - int mcnt, mcnt2; unsigned char *p = start; unsigned char *pend = end; @@ -446,7 +529,7 @@ partial_compiled_pattern_printer (pbufp, start, end) return; } - /* This loop loops over pattern commands. */ + /* Loop over pattern commands. */ while (p < pend) { switch ((re_opcode_t) *p++) @@ -489,12 +572,21 @@ partial_compiled_pattern_printer (pbufp, start, end) { register int c; - printf ("/charset%s/", *(p - 1) == charset_not ? "_not" : ""); + printf ("/charset%s", + (re_opcode_t) *(p - 1) == charset_not ? "_not" : ""); + + assert (p + *p < pend); - for (c = 0; p < pend && c < *p * BYTEWIDTH; c++) + for (c = 0; c < *p; c++) { - if (p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - printchar (c); + unsigned bit; + unsigned char map_byte = p[1 + c]; + + putchar ('/'); + + for (bit = 0; bit < BYTEWIDTH; bit++) + if (map_byte & (1 << bit)) + printchar (c * BYTEWIDTH + bit); } p += 1 + *p; break; @@ -523,6 +615,10 @@ partial_compiled_pattern_printer (pbufp, start, end) printf ("/dummy_failure_jump/0/%d", mcnt); break; + case push_dummy_failure: + printf ("/push_dummy_failure"); + break; + case maybe_pop_jump: extract_number_and_incr (&mcnt, &p); printf ("/maybe_pop_jump/0/%d", mcnt); @@ -533,14 +629,14 @@ partial_compiled_pattern_printer (pbufp, start, end) printf ("/pop_failure_jump/0/%d", mcnt); break; - case jump_past_next_alt: + case jump_past_alt: extract_number_and_incr (&mcnt, &p); - printf ("/jump_past_next_alt/0/%d", mcnt); + printf ("/jump_past_alt/0/%d", mcnt); break; - case no_pop_jump: + case jump: extract_number_and_incr (&mcnt, &p); - printf ("/no_pop_jump/0/%d", mcnt); + printf ("/jump/0/%d", mcnt); break; case succeed_n: @@ -549,10 +645,10 @@ partial_compiled_pattern_printer (pbufp, start, end) printf ("/succeed_n/0/%d/0/%d", mcnt, mcnt2); break; - case no_pop_jump_n: + case jump_n: extract_number_and_incr (&mcnt, &p); extract_number_and_incr (&mcnt2, &p); - printf ("/no_pop_jump_n/0/%d/0/%d", mcnt, mcnt2); + printf ("/jump_n/0/%d/0/%d", mcnt, mcnt2); break; case set_number_at: @@ -589,36 +685,26 @@ partial_compiled_pattern_printer (pbufp, start, end) printf ("/after_dot"); break; - case wordchar: - printf ("/wordchar-emacs"); - mcnt = (int) Sword; - break; - case syntaxspec: printf ("/syntaxspec"); mcnt = *p++; printf ("/%d", mcnt); break; - case notwordchar: - printf ("/notwordchar-emacs"); - mcnt = (int) Sword; - break; - case notsyntaxspec: printf ("/notsyntaxspec"); mcnt = *p++; printf ("/%d", mcnt); break; -#else /* not emacs */ +#endif /* emacs */ + case wordchar: - printf ("/wordchar-notemacs"); + printf ("/wordchar"); break; case notwordchar: - printf ("/notwordchar-notemacs"); + printf ("/notwordchar"); break; -#endif /* not emacs */ case begbuf: printf ("/begbuf"); @@ -635,20 +721,39 @@ partial_compiled_pattern_printer (pbufp, start, end) printf ("/\n"); } -static void -compiled_pattern_printer (pbufp) - struct re_pattern_buffer *pbufp; + +void +print_compiled_pattern (bufp) + struct re_pattern_buffer *bufp; { - partial_compiled_pattern_printer (pbufp, pbufp->buffer, - pbufp->buffer + pbufp->used); + unsigned char *buffer = bufp->buffer; + + print_partial_compiled_pattern (buffer, buffer + bufp->used); + printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated); + + if (bufp->fastmap_accurate && bufp->fastmap) + { + printf ("fastmap: "); + print_fastmap (bufp->fastmap); + } + + printf ("re_nsub: %d\t", bufp->re_nsub); + printf ("regs_alloc: %d\t", bufp->regs_allocated); + printf ("can_be_null: %d\t", bufp->can_be_null); + printf ("newline_anchor: %d\n", bufp->newline_anchor); + printf ("no_sub: %d\t", bufp->no_sub); + printf ("not_bol: %d\t", bufp->not_bol); + printf ("not_eol: %d\t", bufp->not_eol); + printf ("syntax: %d\n", bufp->syntax); + /* Perhaps we should print the translate table? */ } -static void -double_string_printer (where, string1, size1, string2, size2) - unsigned char *where; - unsigned char *string1; - unsigned char *string2; +void +print_double_string (where, string1, size1, string2, size2) + const char *where; + const char *string1; + const char *string2; int size1; int size2; { @@ -658,7 +763,7 @@ double_string_printer (where, string1, size1, string2, size2) printf ("(null)"); else { - if (IS_IN_FIRST_STRING (where)) + if (FIRST_STRING_P (where)) { for (this_char = where - string1; this_char < size1; this_char++) printchar (string1[this_char]); @@ -671,24 +776,6 @@ double_string_printer (where, string1, size1, string2, size2) } } -#endif /* DEBUG */ - -#ifdef DEBUG - -/* It is useful to test things that must to be true when debugging. */ -#include <assert.h> - -static int debug = 0; - -#define DEBUG_STATEMENT(e) e -#define DEBUG_PRINT1(x) if (debug) printf (x) -#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) -#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) -#define DEBUG_COMPILED_PATTERN_PRINTER(p, s, e) \ - if (debug) partial_compiled_pattern_printer (p, s, e) -#define DEBUG_DOUBLE_STRING_PRINTER(w, s1, sz1, s2, sz2) \ - if (debug) double_string_printer (w, s1, sz1, s2, sz2) - #else /* not DEBUG */ #undef assert @@ -698,19 +785,16 @@ static int debug = 0; #define DEBUG_PRINT1(x) #define DEBUG_PRINT2(x1, x2) #define DEBUG_PRINT3(x1, x2, x3) -#define DEBUG_COMPILED_PATTERN_PRINTER(p, s, e) -#define DEBUG_DOUBLE_STRING_PRINTER(w, s1, sz1, s2, sz2) +#define DEBUG_PRINT4(x1, x2, x3, x4) +#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) +#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) #endif /* not DEBUG */ - -typedef char boolean; -#define false 0 -#define true 1 -/* Set by re_set_syntax to the current regexp syntax to recognize. Can - also be assigned to more or less arbitrarily. Since we use this as a - collection of bits, declaring it unsigned maximizes portability. */ -reg_syntax_t obscure_syntax = 0; +/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can + also be assigned to arbitrarily: each pattern buffer stores its own + syntax, so it can be changed between regex compilations. */ +reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS; /* Specify the precise syntax of regexps for compilation. This provides @@ -724,9 +808,9 @@ reg_syntax_t re_set_syntax (syntax) reg_syntax_t syntax; { - reg_syntax_t ret = obscure_syntax; + reg_syntax_t ret = re_syntax_options; - obscure_syntax = syntax; + re_syntax_options = syntax; return ret; } @@ -753,12 +837,13 @@ static const char *re_error_msg[] = "Unmatched ) or \\)", /* REG_ERPAREN */ }; -/* Other subroutine declarations and macros for regex_compile. */ +/* Subroutine declarations and macros for regex_compile. */ -static void store_jump (), insert_jump (), store_jump_n (), - insert_jump_n (), insert_op_2 (); - -static boolean at_endline_op_p (), group_in_compile_stack (); +static void store_op1 (), store_op2 (); +static void insert_op1 (), insert_op2 (); +static boolean at_begline_loc_p (), at_endline_loc_p (); +static boolean group_in_compile_stack (); +static reg_errcode_t compile_range (); /* Fetch the next character in the uncompiled pattern---translating it if necessary. Also cast from a signed character in the constant @@ -795,22 +880,19 @@ static boolean at_endline_op_p (), group_in_compile_stack (); /* Make sure we have at least N more bytes of space in buffer. */ #define GET_BUFFER_SPACE(n) \ - { \ while (b - bufp->buffer + (n) > bufp->allocated) \ - EXTEND_BUFFER (); \ - } + EXTEND_BUFFER () /* Make sure we have one more byte of buffer space and then add C to it. */ -#define PAT_PUSH(c) \ +#define BUF_PUSH(c) \ do { \ GET_BUFFER_SPACE (1); \ *b++ = (unsigned char) (c); \ } while (0) -/* Make sure we have two more bytes of buffer space and then add C1 and - C2 to it. */ -#define PAT_PUSH_2(c1, c2) \ +/* Ensure we have two more bytes of buffer space and then append C1 and C2. */ +#define BUF_PUSH_2(c1, c2) \ do { \ GET_BUFFER_SPACE (2); \ *b++ = (unsigned char) (c1); \ @@ -818,9 +900,8 @@ static boolean at_endline_op_p (), group_in_compile_stack (); } while (0) -/* Make sure we have two more bytes of buffer space and then add C1, C2 - and C3 to it. */ -#define PAT_PUSH_3(c1, c2, c3) \ +/* As with BUF_PUSH_2, except for three bytes. */ +#define BUF_PUSH_3(c1, c2, c3) \ do { \ GET_BUFFER_SPACE (3); \ *b++ = (unsigned char) (c1); \ @@ -828,11 +909,31 @@ static boolean at_endline_op_p (), group_in_compile_stack (); *b++ = (unsigned char) (c3); \ } while (0) -/* This is not an arbitrary limit: the arguments to the opcodes which - represent offsets into the pattern are two bytes long. So if 2^16 - bytes turns out to be too small, many things would have to change. */ + +/* Store a jump with opcode OP at LOC to location TO. We store a + relative address offset by the three bytes the jump itself occupies. */ +#define STORE_JUMP(op, loc, to) \ + store_op1 (op, loc, (to) - (loc) - 3) + +/* Likewise, for a two-argument jump. */ +#define STORE_JUMP2(op, loc, to, arg) \ + store_op2 (op, loc, (to) - (loc) - 3, arg) + +/* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */ +#define INSERT_JUMP(op, loc, to) \ + insert_op1 (op, loc, (to) - (loc) - 3, b) + +/* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */ +#define INSERT_JUMP2(op, loc, to, arg) \ + insert_op2 (op, loc, (to) - (loc) - 3, arg, b) + + +/* This is not an arbitrary limit: the arguments which represent offsets + into the pattern are two bytes long. So if 2^16 bytes turns out to + be too small, many things would have to change. */ #define MAX_BUF_SIZE (1L << 16) + /* Extend the buffer by twice its current size via realloc and reset the pointers that pointed into the old block to point to the correct places in the new one. If extending the buffer results in it @@ -866,14 +967,18 @@ static boolean at_endline_op_p (), group_in_compile_stack (); /* Since we have one byte reserved for the register number argument to {start,stop}_memory, the maximum number of groups we can report things about is what fits in that byte. */ -typedef unsigned char regnum_t; -#define MAX_REGNUM ((regnum_t) ((1 << BYTEWIDTH) - 1)) +#define MAX_REGNUM 255 + +/* But patterns can have more than `MAX_REGNUM' registers. We just + ignore the excess. */ +typedef unsigned regnum_t; /* Macros for the compile stack. */ -/* This type needs to be able to hold values from 0 to MAX_BUF_SIZE - 1. */ -typedef short pattern_offset_t; +/* Since offsets can go either forwards or backwards, this type needs to + be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */ +typedef int pattern_offset_t; typedef struct { @@ -903,7 +1008,9 @@ typedef struct /* Set the bit for character C in a list. */ -#define SET_LIST_BIT(c) (b[(c) / BYTEWIDTH] |= 1 << ((c) % BYTEWIDTH)) +#define SET_LIST_BIT(c) \ + (b[((unsigned char) (c)) / BYTEWIDTH] \ + |= 1 << (((unsigned char) c) % BYTEWIDTH)) /* Get the next unsigned number in the uncompiled pattern. */ @@ -911,7 +1018,7 @@ typedef struct { if (p != pend) \ { \ PATFETCH (c); \ - while (isdigit (c)) \ + while (ISDIGIT (c)) \ { \ if (num < 0) \ num = 0; \ @@ -923,28 +1030,6 @@ typedef struct } \ } - -/* Read the endpoint of a range from the uncompiled pattern and set the - corresponding bits in the compiled pattern. */ - -#define DO_RANGE \ - { \ - char end; \ - char this_char = p[-2]; \ - \ - if (p == pend) \ - return REG_ERANGE; \ - PATFETCH (end); \ - if (syntax & RE_NO_EMPTY_RANGES && this_char > end) \ - return REG_ERANGE; \ - while (this_char <= end) \ - { \ - SET_LIST_BIT (TRANSLATE (this_char)); \ - this_char++; \ - } \ - } - - #define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */ #define IS_CHAR_CLASS(string) \ @@ -954,10 +1039,9 @@ typedef struct || STREQ (string, "space") || STREQ (string, "print") \ || STREQ (string, "punct") || STREQ (string, "graph") \ || STREQ (string, "cntrl") || STREQ (string, "blank")) - -/* regex_compile compiles PATTERN (of length SIZE) according to SYNTAX. - Returns one of error codes defined in regex.h, or zero for success. +/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. + Returns one of error codes defined in `regex.h', or zero for success. Assumes the `allocated' (and perhaps `buffer') and `translate' fields are set in BUFP on entry. @@ -967,9 +1051,9 @@ typedef struct `buffer' is the compiled pattern; `syntax' is set to SYNTAX; `used' is set to the length of the compiled pattern; - `fastmap_accurate' is set to zero; - `re_nsub' is set to the number of groups in PATTERN; - `not_bol' and `not_eol' are set to zero. + `fastmap_accurate' is zero; + `re_nsub' is the number of subexpressions in PATTERN; + `not_bol' and `not_eol' are zero; The `fastmap' and `newline_anchor' fields are neither examined nor set. */ @@ -981,12 +1065,20 @@ regex_compile (pattern, size, syntax, bufp) reg_syntax_t syntax; struct re_pattern_buffer *bufp; { + /* We fetch characters from PATTERN here. Even though PATTERN is + `char *' (i.e., signed), we declare these variables as unsigned, so + they can be reliably used as array indices. */ register unsigned char c, c1; + + /* A random tempory spot in PATTERN. */ const char *p1; /* Points to the end of the buffer, where we should append. */ register unsigned char *b; + /* Keeps track of unclosed groups. */ + compile_stack_type compile_stack; + /* Points to the current (ending) position in the pattern. */ const char *p = pattern; const char *pend = pattern + size; @@ -1005,28 +1097,23 @@ regex_compile (pattern, size, syntax, bufp) operand. Reset at the beginning of groups and alternatives. */ unsigned char *laststart = 0; - /* Place in the uncompiled pattern (i.e., the {) to - which to go back if the interval is invalid. */ - const char *beg_interval; /* The `{'. */ - const char *following_left_brace; - /* Address of beginning of regexp, or inside of last group. */ unsigned char *begalt; - + + /* Place in the uncompiled pattern (i.e., the {) to + which to go back if the interval is invalid. */ + const char *beg_interval; + /* Address of the place where a forward jump should go to the end of - the containing expression. Each alternative of an `or'---except the - last---ends with a forward jump of this sort. */ + the containing expression. Each alternative of an `or' -- except the + last -- ends with a forward jump of this sort. */ unsigned char *fixup_alt_jump = 0; /* Counts open-groups as they are encountered. Remembered for the matching close-group on the compile stack, so the same register - number is put in the stop_memory as the start_memory. The type - here is determined by MAX_REGNUM. */ + number is put in the stop_memory as the start_memory. */ regnum_t regnum = 0; - /* Keeps track of unclosed groups. */ - compile_stack_type compile_stack; - #ifdef DEBUG DEBUG_PRINT1 ("\nCompiling pattern: "); if (debug) @@ -1035,8 +1122,7 @@ regex_compile (pattern, size, syntax, bufp) for (debug_count = 0; debug_count < size; debug_count++) printchar (pattern[debug_count]); - - DEBUG_PRINT1 ("\n"); + putchar ('\n'); } #endif /* DEBUG */ @@ -1069,9 +1155,9 @@ regex_compile (pattern, size, syntax, bufp) if (bufp->allocated == 0) { if (bufp->buffer) - { /* EXTEND_BUFFER loses when bufp->allocated is 0. This loses if - buffer's address is bogus, but that is the user's - responsibility. */ + { /* If zero allocated, but buffer is non-null, try to realloc + enough space. This loses if buffer's address is bogus, but + that is the user's responsibility. */ RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); } else @@ -1092,33 +1178,21 @@ regex_compile (pattern, size, syntax, bufp) switch (c) { - /* ^ matches the empty string at the beginning of a string (or - possibly a line). If RE_CONTEXT_INDEP_ANCHORS is set, ^ is - always an operator (and foo^bar is unmatchable). If that bit - isn't set, it's an operator only at the beginning of the - pattern or after an alternation or open-group operator, or, - if RE_NEWLINE_ORDINARY is not set, after a newline (except it - can be preceded by other operators that match the empty - string); otherwise, it's a normal character. */ case '^': { - if ( /* If at start of (sub)pattern, it's an operator. */ - laststart == 0 + if ( /* If at start of pattern, it's an operator. */ + p == pattern + 1 /* If context independent, it's an operator. */ || syntax & RE_CONTEXT_INDEP_ANCHORS - /* If after a newline, might be an operator. (Since - laststart is nonzero here, we know we have at - least one byte before the ^.) */ - || (!(syntax & RE_NEWLINE_ORDINARY) && p[-2] == '\n')) - PAT_PUSH (begline); + /* Otherwise, depends on what's come before. */ + || at_begline_loc_p (pattern, p, syntax)) + BUF_PUSH (begline); else goto normal_char; } break; - /* $ matches the empty string following the end of the string (or - possibly a line). It follows rules dual to those for ^. */ case '$': { if ( /* If at end of pattern, it's an operator. */ @@ -1126,8 +1200,8 @@ regex_compile (pattern, size, syntax, bufp) /* If context independent, it's an operator. */ || syntax & RE_CONTEXT_INDEP_ANCHORS /* Otherwise, depends on what's next. */ - || at_endline_op_p (p, pend, syntax)) - PAT_PUSH (endline); + || at_endline_loc_p (p, pend, syntax)) + BUF_PUSH (endline); else goto normal_char; } @@ -1219,7 +1293,7 @@ regex_compile (pattern, size, syntax, bufp) through the loop. */ assert (p - 1 > pattern); - /* Get the space for the jump. */ + /* Allocate the space for the jump. */ GET_BUFFER_SPACE (3); /* We know we are not at the first character of the pattern, @@ -1228,15 +1302,16 @@ regex_compile (pattern, size, syntax, bufp) the `*'. Do we have to do something analogous here for null bytes, because of RE_DOT_NOT_NULL? */ if (TRANSLATE (*(p - 2)) == TRANSLATE ('.') + && zero_times_ok && p < pend && TRANSLATE (*p) == TRANSLATE ('\n') && !(syntax & RE_DOT_NEWLINE)) { /* We have .*\n. */ - store_jump (b, no_pop_jump, laststart); + STORE_JUMP (jump, b, laststart); keep_string_p = true; } else /* Anything else. */ - store_jump (b, maybe_pop_jump, laststart - 3); + STORE_JUMP (maybe_pop_jump, b, laststart - 3); /* We've added more stuff to the buffer. */ b += 3; @@ -1245,20 +1320,21 @@ regex_compile (pattern, size, syntax, bufp) /* On failure, jump from laststart to b + 3, which will be the end of the buffer after this jump is inserted. */ GET_BUFFER_SPACE (3); - insert_jump (keep_string_p ? on_failure_keep_string_jump + INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump : on_failure_jump, - laststart, b + 3, b); + laststart, b + 3); pending_exact = 0; b += 3; if (!zero_times_ok) { /* At least one repetition is required, so insert a - dummy_failure before the initial on_failure_jump - instruction of the loop. This effects a skip over that - instruction the first time we hit that loop. */ + `dummy_failure_jump' before the initial + `on_failure_jump' instruction of the loop. This + effects a skip over that instruction the first time + we hit that loop. */ GET_BUFFER_SPACE (3); - insert_jump (dummy_failure_jump, laststart, laststart + 6, b); + INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); b += 3; } } @@ -1267,25 +1343,25 @@ regex_compile (pattern, size, syntax, bufp) case '.': laststart = b; - PAT_PUSH (anychar); + BUF_PUSH (anychar); break; case '[': { - boolean just_had_a_char_class = false; + boolean had_char_class = false; if (p == pend) return REG_EBRACK; - /* Ensure that we have enough space to push an entire - charset: the opcode, the byte count, and the bitmap. */ - while (b - bufp->buffer + 2 + (1 << BYTEWIDTH) / BYTEWIDTH - > bufp->allocated) - EXTEND_BUFFER (); + /* Ensure that we have enough space to push a charset: the + opcode, the length count, and the bitset; 34 bytes in all. */ + GET_BUFFER_SPACE (34); laststart = b; - PAT_PUSH (*p == '^' ? charset_not : charset); + /* We test `*p == '^' twice, instead of using an if + statement, so we only need one BUF_PUSH. */ + BUF_PUSH (*p == '^' ? charset_not : charset); if (*p == '^') p++; @@ -1293,7 +1369,7 @@ regex_compile (pattern, size, syntax, bufp) p1 = p; /* Push the number of bytes in the bitmap. */ - PAT_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); + BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); /* Clear the whole map. */ bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); @@ -1328,7 +1404,7 @@ regex_compile (pattern, size, syntax, bufp) /* Look ahead to see if it's a range when the last thing was a character class. */ - if (just_had_a_char_class && c == '-' && *p != ']') + if (had_char_class && c == '-' && *p != ']') return REG_ERANGE; /* Look ahead to see if it's a range when the last thing @@ -1340,13 +1416,20 @@ regex_compile (pattern, size, syntax, bufp) && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') && *p != ']') { - DO_RANGE; + reg_errcode_t ret + = compile_range (&p, pend, translate, syntax, b); + if (ret != REG_NOERROR) return ret; } else if (p[0] == '-' && p[1] != ']') { /* This handles ranges made up of characters only. */ - PATFETCH (c1); /* The `-'. */ - DO_RANGE; + reg_errcode_t ret; + + /* Move past the `-'. */ + PATFETCH (c1); + + ret = compile_range (&p, pend, translate, syntax, b); + if (ret != REG_NOERROR) return ret; } /* See if we're at the beginning of a possible character @@ -1401,21 +1484,21 @@ regex_compile (pattern, size, syntax, bufp) for (ch = 0; ch < 1 << BYTEWIDTH; ch++) { - if ( (is_alnum && isalnum (ch)) - || (is_alpha && isalpha (ch)) - || (is_blank && isblank (ch)) - || (is_cntrl && iscntrl (ch)) - || (is_digit && isdigit (ch)) - || (is_graph && isgraph (ch)) - || (is_lower && islower (ch)) - || (is_print && isprint (ch)) - || (is_punct && ispunct (ch)) - || (is_space && isspace (ch)) - || (is_upper && isupper (ch)) - || (is_xdigit && isxdigit (ch))) + if ( (is_alnum && ISALNUM (ch)) + || (is_alpha && ISALPHA (ch)) + || (is_blank && ISBLANK (ch)) + || (is_cntrl && ISCNTRL (ch)) + || (is_digit && ISDIGIT (ch)) + || (is_graph && ISGRAPH (ch)) + || (is_lower && ISLOWER (ch)) + || (is_print && ISPRINT (ch)) + || (is_punct && ISPUNCT (ch)) + || (is_space && ISSPACE (ch)) + || (is_upper && ISUPPER (ch)) + || (is_xdigit && ISXDIGIT (ch))) SET_LIST_BIT (ch); } - just_had_a_char_class = true; + had_char_class = true; } else { @@ -1424,12 +1507,12 @@ regex_compile (pattern, size, syntax, bufp) PATUNFETCH; SET_LIST_BIT ('['); SET_LIST_BIT (':'); - just_had_a_char_class = false; + had_char_class = false; } } else { - just_had_a_char_class = false; + had_char_class = false; SET_LIST_BIT (c); } } @@ -1459,14 +1542,14 @@ regex_compile (pattern, size, syntax, bufp) case '\n': if (syntax & RE_NEWLINE_ALT) - goto handle_bar; + goto handle_alt; else goto normal_char; case '|': if (syntax & RE_NO_BK_VBAR) - goto handle_bar; + goto handle_alt; else goto normal_char; @@ -1491,16 +1574,8 @@ regex_compile (pattern, size, syntax, bufp) case '(': if (syntax & RE_NO_BK_PARENS) goto normal_backslash; - handle_open: - if (syntax & RE_NO_EMPTY_GROUPS) - { - p1 = p; - if (!(syntax & RE_NO_BK_PARENS) && *p1 == '\\') p1++; - - /* If found an empty group... */ - if (*p1 == ')') return REG_BADPAT; - } + handle_open: bufp->re_nsub++; regnum++; @@ -1524,11 +1599,13 @@ regex_compile (pattern, size, syntax, bufp) COMPILE_STACK_TOP.regnum = regnum; /* We will eventually replace the 0 with the number of - groups inner to this one. */ + groups inner to this one. But do not push a + start_memory for groups beyond the last one we can + represent in the compiled pattern. */ if (regnum <= MAX_REGNUM) { COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2; - PAT_PUSH_3 (start_memory, regnum, 0); + BUF_PUSH_3 (start_memory, regnum, 0); } compile_stack.avail++; @@ -1536,6 +1613,10 @@ regex_compile (pattern, size, syntax, bufp) fixup_alt_jump = 0; laststart = 0; begalt = b; + /* If we've reached MAX_REGNUM groups, then this open + won't actually generate any code, so we'll have to + clear pending_exact explicitly. */ + pending_exact = 0; break; @@ -1550,10 +1631,18 @@ regex_compile (pattern, size, syntax, bufp) handle_close: if (fixup_alt_jump) - store_jump (fixup_alt_jump, jump_past_next_alt, b); + { /* Push a dummy failure point at the end of the + alternative for a possible future + `pop_failure_jump' to pop. See comments at + `push_dummy_failure' in `re_match_2'. */ + BUF_PUSH (push_dummy_failure); + + /* We allocated space for this jump when we assigned + to `fixup_alt_jump', in the `handle_alt' case below. */ + STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1); + } /* See similar code for backslashed left paren above. */ - if (COMPILE_STACK_EMPTY) if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_char; @@ -1577,6 +1666,10 @@ regex_compile (pattern, size, syntax, bufp) : 0; laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; this_group_regnum = COMPILE_STACK_TOP.regnum; + /* If we've reached MAX_REGNUM groups, then this open + won't actually generate any code, so we'll have to + clear pending_exact explicitly. */ + pending_exact = 0; /* We're at the end of the group, so now we know how many groups were inside this one. */ @@ -1586,7 +1679,7 @@ regex_compile (pattern, size, syntax, bufp) = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; *inner_group_loc = regnum - this_group_regnum; - PAT_PUSH_3 (stop_memory, this_group_regnum, + BUF_PUSH_3 (stop_memory, this_group_regnum, regnum - this_group_regnum); } } @@ -1596,27 +1689,14 @@ regex_compile (pattern, size, syntax, bufp) case '|': /* `\|'. */ if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) goto normal_backslash; - handle_bar: + handle_alt: if (syntax & RE_LIMITED_OPS) goto normal_char; - /* Disallow empty alternatives if RE_NO_EMPTY_ALTS is set. - Caveat: can't detect if the vbar is followed by a - trailing '$' yet, unless it's the last thing in a - pattern; the routine for verifying endlines has to do - the rest. */ - if ((syntax & RE_NO_EMPTY_ALTS) - && (!laststart || p == pend - || (*p == '$' && p + 1 == pend) - || ((syntax & RE_NO_BK_PARENS) - ? (p < pend && *p == ')') - : (p + 1 < pend && p[0] == '\\' && p[1] == ')')))) - return REG_BADPAT; - /* Insert before the previous alternative a jump which jumps to this alternative if the former fails. */ GET_BUFFER_SPACE (3); - insert_jump (on_failure_jump, begalt, b + 6, b); + INSERT_JUMP (on_failure_jump, begalt, b + 6); pending_exact = 0; b += 3; @@ -1631,13 +1711,13 @@ regex_compile (pattern, size, syntax, bufp) | v | v a | b | c - If we are at `b,' then fixup_alt_jump right now points to a - three-byte space after `a.' We'll put in the jump, set - fixup_alt_jump to right after `b,' and leave behind three - bytes which we'll fill in when we get to after `c.' */ + If we are at `b', then fixup_alt_jump right now points to a + three-byte space after `a'. We'll put in the jump, set + fixup_alt_jump to right after `b', and leave behind three + bytes which we'll fill in when we get to after `c'. */ if (fixup_alt_jump) - store_jump (fixup_alt_jump, jump_past_next_alt, b); + STORE_JUMP (jump_past_alt, fixup_alt_jump, b); /* Mark and leave space for a jump after this alternative, to be filled in later either by next alternative or @@ -1662,14 +1742,12 @@ regex_compile (pattern, size, syntax, bufp) handle_interval: { - /* If got here, then intervals must be allowed. */ + /* If got here, then the syntax allows intervals. */ - /* For intervals, at least (most) this many matches must - be made. */ + /* At least (most) this many matches must be made. */ int lower_bound = -1, upper_bound = -1; - beg_interval = p - 1; /* The `{'. */ - following_left_brace = NULL; + beg_interval = p - 1; if (p == pend) { @@ -1686,8 +1764,8 @@ regex_compile (pattern, size, syntax, bufp) GET_UNSIGNED_NUMBER (upper_bound); if (upper_bound < 0) upper_bound = RE_DUP_MAX; } - - if (upper_bound < 0) + else + /* Interval such as `{1}' => match exactly once. */ upper_bound = lower_bound; if (lower_bound < 0 || upper_bound > RE_DUP_MAX @@ -1727,70 +1805,82 @@ regex_compile (pattern, size, syntax, bufp) goto unfetch_interval; } - /* If upper_bound is zero, don't want to succeed at all; - jump from laststart to b + 3, which will be the end of - the buffer after this jump is inserted. */ + /* If the upper bound is zero, don't want to succeed at + all; jump from `laststart' to `b + 3', which will be + the end of the buffer after we insert the jump. */ if (upper_bound == 0) { GET_BUFFER_SPACE (3); - insert_jump (no_pop_jump, laststart, b + 3, b); + INSERT_JUMP (jump, laststart, b + 3); b += 3; } - /* Otherwise, after lower_bound number of succeeds, jump - to after the no_pop_jump_n which will be inserted at - the end of the buffer, and insert that - no_pop_jump_n. */ + /* Otherwise, we have a nontrivial interval. When + we're all done, the pattern will look like: + set_number_at <jump count> <upper bound> + set_number_at <succeed_n count> <lower bound> + succeed_n <after jump addr> <succed_n count> + <body of loop> + jump_n <succeed_n addr> <jump count> + (The upper bound and `jump_n' are omitted if + `upper_bound' is 1, though.) */ else - { /* Set to 5 if only one repetition is allowed and - hence no no_pop_jump_n is inserted at the current - end of the buffer. Otherwise, need 10 bytes total - for the succeed_n and the no_pop_jump_n. */ - unsigned slots_needed = upper_bound == 1 ? 5 : 10; - - GET_BUFFER_SPACE (slots_needed); - /* Initialize the succeed_n to n, even though it will - be set by its attendant set_number_at, because - re_compile_fastmap will need to know it. Jump to - what the end of buffer will be after inserting - this succeed_n and possibly appending a - no_pop_jump_n. */ - insert_jump_n (succeed_n, laststart, b + slots_needed, - b, lower_bound); - b += 5; /* Just increment for the succeed_n here. */ - - - /* More than one repetition is allowed, so put in at - the end of the buffer a backward jump from b to the - succeed_n we put in above. By the time we've gotten - to this jump when matching, we'll have matched once - already, so jump back only upper_bound - 1 times. */ + { /* If the upper bound is > 1, we need to insert + more at the end of the loop. */ + unsigned nbytes = 10 + (upper_bound > 1) * 10; + + GET_BUFFER_SPACE (nbytes); + + /* Initialize lower bound of the `succeed_n', even + though it will be set during matching by its + attendant `set_number_at' (inserted next), + because `re_compile_fastmap' needs to know. + Jump to the `jump_n' we might insert below. */ + INSERT_JUMP2 (succeed_n, laststart, + b + 5 + (upper_bound > 1) * 5, + lower_bound); + b += 5; + + /* Code to initialize the lower bound. Insert + before the `succeed_n'. The `5' is the last two + bytes of this `set_number_at', plus 3 bytes of + the following `succeed_n'. */ + insert_op2 (set_number_at, laststart, 5, lower_bound, b); + b += 5; + if (upper_bound > 1) - { - store_jump_n (b, no_pop_jump_n, laststart, - upper_bound - 1); + { /* More than one repetition is allowed, so + append a backward jump to the `succeed_n' + that starts this interval. + + When we've reached this during matching, + we'll have matched the interval once, so + jump back only `upper_bound - 1' times. */ + STORE_JUMP2 (jump_n, b, laststart + 5, + upper_bound - 1); b += 5; - /* When hit this when matching, reset the - preceding no_pop_jump_n's n to upper_bound - 1. */ - PAT_PUSH (set_number_at); - - /* Only need to get space for the numbers. */ - GET_BUFFER_SPACE (4); - STORE_NUMBER_AND_INCR (b, -5); - STORE_NUMBER_AND_INCR (b, upper_bound - 1); + /* The location we want to set is the second + parameter of the `jump_n'; that is `b-2' as + an absolute address. `laststart' will be + the `set_number_at' we're about to insert; + `laststart+3' the number to set, the source + for the relative address. But we are + inserting into the middle of the pattern -- + so everything is getting moved up by 5. + Conclusion: (b - 2) - (laststart + 3) + 5, + i.e., b - laststart. + + We insert this at the beginning of the loop + so that if we fail during matching, we'll + reinitialize the bounds. */ + insert_op2 (set_number_at, laststart, b - laststart, + upper_bound - 1, b); + b += 5; } - - /* When hit this when matching, set the succeed_n's n. */ - GET_BUFFER_SPACE (5); - insert_op_2 (set_number_at, laststart, b, 5, lower_bound); - b += 5; } pending_exact = 0; beg_interval = NULL; - - if (following_left_brace) - goto normal_char; } break; @@ -1814,87 +1904,75 @@ regex_compile (pattern, size, syntax, bufp) /* There is no way to specify the before_dot and after_dot operators. rms says this is ok. --karl */ case '=': - PAT_PUSH (at_dot); + BUF_PUSH (at_dot); break; case 's': laststart = b; PATFETCH (c); - PAT_PUSH_2 (syntaxspec, syntax_spec_code[c]); + BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); break; case 'S': laststart = b; PATFETCH (c); - PAT_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); + BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); break; #endif /* emacs */ case 'w': laststart = b; - PAT_PUSH (wordchar); + BUF_PUSH (wordchar); break; case 'W': laststart = b; - PAT_PUSH (notwordchar); + BUF_PUSH (notwordchar); break; case '<': - PAT_PUSH (wordbeg); + BUF_PUSH (wordbeg); break; case '>': - PAT_PUSH (wordend); + BUF_PUSH (wordend); break; case 'b': - PAT_PUSH (wordbound); + BUF_PUSH (wordbound); break; case 'B': - PAT_PUSH (notwordbound); + BUF_PUSH (notwordbound); break; case '`': - PAT_PUSH (begbuf); + BUF_PUSH (begbuf); break; case '\'': - PAT_PUSH (endbuf); + BUF_PUSH (endbuf); break; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': if (syntax & RE_NO_BK_REFS) goto normal_char; c1 = c - '0'; if (c1 > regnum) - { - if (syntax & RE_NO_MISSING_BK_REF) - return REG_ESUBREG; - else - goto normal_char; - } + return REG_ESUBREG; /* Can't back reference to a subexpression if inside of it. */ if (group_in_compile_stack (compile_stack, c1)) goto normal_char; laststart = b; - PAT_PUSH_2 (duplicate, c1); + BUF_PUSH_2 (duplicate, c1); break; @@ -1942,11 +2020,11 @@ regex_compile (pattern, size, syntax, bufp) laststart = b; - PAT_PUSH_2 (exactn, 0); + BUF_PUSH_2 (exactn, 0); pending_exact = b - 1; } - PAT_PUSH (c); + BUF_PUSH (c); (*pending_exact)++; break; } /* switch (c) */ @@ -1956,7 +2034,7 @@ regex_compile (pattern, size, syntax, bufp) /* Through the pattern now. */ if (fixup_alt_jump) - store_jump (fixup_alt_jump, jump_past_next_alt, b); + STORE_JUMP (jump_past_alt, fixup_alt_jump, b); if (!COMPILE_STACK_EMPTY) return REG_EPAREN; @@ -1965,169 +2043,125 @@ regex_compile (pattern, size, syntax, bufp) /* We have succeeded; set the length of the buffer. */ bufp->used = b - bufp->buffer; + +#ifdef DEBUG + if (debug) + { + DEBUG_PRINT1 ("\nCompiled pattern: "); + print_compiled_pattern (bufp); + } +#endif /* DEBUG */ + return REG_NOERROR; } /* regex_compile */ -/* Subroutines for regex_compile. */ +/* Subroutines for `regex_compile'. */ -/* Store a jump of the form <OPCODE> <relative address>. - Store in the location FROM a jump operation to jump to relative - address FROM - TO. OPCODE is the opcode to store. */ +/* Store OP at LOC followed by two-byte integer parameter ARG. */ static void -store_jump (from, op, to) - unsigned char *from, *to; - re_opcode_t op; +store_op1 (op, loc, arg) + re_opcode_t op; + unsigned char *loc; + int arg; { - from[0] = (unsigned char) op; - STORE_NUMBER (from + 1, to - (from + 3)); + *loc = (unsigned char) op; + STORE_NUMBER (loc + 1, arg); } -/* Open up space before char FROM, and insert there a jump to TO. - CURRENT_END gives the end of the storage not in use, so we know - how much data to copy up. OP is the opcode of the jump to insert. - - If you call this function, you must zero out pending_exact. */ +/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ static void -insert_jump (op, from, to, current_end) - re_opcode_t op; - unsigned char *from, *to, *current_end; +store_op2 (op, loc, arg1, arg2) + re_opcode_t op; + unsigned char *loc; + int arg1, arg2; { - register unsigned char *pfrom = current_end; /* Copy from here... */ - register unsigned char *pto = current_end + 3; /* ...to here. */ - - while (pfrom != from) - *--pto = *--pfrom; - - store_jump (from, op, to); + *loc = (unsigned char) op; + STORE_NUMBER (loc + 1, arg1); + STORE_NUMBER (loc + 3, arg2); } -/* Store a jump of the form <opcode> <relative address> <n>. - - Store in the location FROM a jump operation to jump to relative - address FROM - TO. OPCODE is the opcode to store, N is a number the - jump uses, say, to decide how many times to jump. - - If you call this function, you must zero out pending_exact. */ +/* Copy the bytes from LOC to END to open up three bytes of space at LOC + for OP followed by two-byte integer parameter ARG. */ static void -store_jump_n (from, op, to, n) - unsigned char *from, *to; - re_opcode_t op; - unsigned n; +insert_op1 (op, loc, arg, end) + re_opcode_t op; + unsigned char *loc; + int arg; + unsigned char *end; { - from[0] = (unsigned char) op; - STORE_NUMBER (from + 1, to - (from + 3)); - STORE_NUMBER (from + 3, n); -} + register unsigned char *pfrom = end; + register unsigned char *pto = end + 3; + while (pfrom != loc) + *--pto = *--pfrom; + + store_op1 (op, loc, arg); +} -/* Similar to insert_jump, but handles a jump which needs an extra - number to handle minimum and maximum cases. Open up space at - location FROM, and insert there a jump to TO. CURRENT_END gives the - end of the storage in use, so we know how much data to copy up. OP is - the opcode of the jump to insert. - If you call this function, you must zero out pending_exact. */ +/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ static void -insert_jump_n (op, from, to, current_end, n) - re_opcode_t op; - unsigned char *from, *to, *current_end; - unsigned n; +insert_op2 (op, loc, arg1, arg2, end) + re_opcode_t op; + unsigned char *loc; + int arg1, arg2; + unsigned char *end; { - register unsigned char *pfrom = current_end; - register unsigned char *pto = current_end + 5; + register unsigned char *pfrom = end; + register unsigned char *pto = end + 5; - while (pfrom != from) + while (pfrom != loc) *--pto = *--pfrom; - store_jump_n (from, op, to, n); + store_op2 (op, loc, arg1, arg2); } -/* Open up space at location THERE, and insert operation OP followed by - NUM_1 and NUM_2. CURRENT_END gives the end of the storage in use, so - we know how much data to copy up. - - If you call this function, you must zero out pending_exact. */ +/* P points to just after a ^ in PATTERN. Return true if that ^ comes + after an alternative or a begin-subexpression. We assume there is at + least one character before the ^. */ -static void -insert_op_2 (op, there, current_end, num_1, num_2) - re_opcode_t op; - unsigned char *there, *current_end; - int num_1, num_2; +static boolean +at_begline_loc_p (pattern, p, syntax) + const char *pattern, *p; + reg_syntax_t syntax; { - register unsigned char *pfrom = current_end; - register unsigned char *pto = current_end + 5; - - while (pfrom != there) - *--pto = *--pfrom; + const char *prev = p - 2; + boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\'; - there[0] = (unsigned char) op; - STORE_NUMBER (there + 1, num_1); - STORE_NUMBER (there + 3, num_2); + return + /* After a subexpression? */ + (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) + /* After an alternative? */ + || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); } -/* Return true if the pattern position P is at a close-group or - alternation operator, or if it is a newline and RE_NEWLINE_ORDINARY - is not set in SYNTAX. Before checking, though, we skip past all - operators that match the empty string. - - This is not quite the dual of what happens with ^. There, we can - easily check if the (sub)pattern so far can match only the empty - string, because we have seen the pattern, and `laststart' is set to - exactly that. But we cannot easily look at the pattern yet to come - to see if it matches the empty string; that would require us to compile - the pattern, then go back and analyze the pattern after every - endline. POSIX required this at one point (that $ be in a - ``trailing'' position to be considered an anchor), so we implemented - it, but it was slow and took lots of code, and we were never really - convinced it worked in all cases. So now it's gone, and we live with - the slight inconsistency between ^ and $. */ +/* The dual of at_begline_loc_p. This one is for $. We assume there is + at least one character after the $, i.e., `P < PEND'. */ static boolean -at_endline_op_p (p, pend, syntax) +at_endline_loc_p (p, pend, syntax) const char *p, *pend; int syntax; { - boolean context_indep = !!(syntax & RE_CONTEXT_INDEP_ANCHORS); + const char *next = p; + boolean next_backslash = *next == '\\'; + const char *next_next = p + 1 < pend ? p + 1 : NULL; - /* Skip past operators that match the empty string. (Except we don't - handle empty groups.) */ - while (p < pend) - { - if (context_indep && (*p == '^' || *p == '$')) - p++; - - /* All others start with \. */ - else if (*p == '\\' && p + 1 < pend - && (p[1] == 'b' || p[1] == 'B' - || p[1] == '<' || p[1] == '>' - || p[1] == '`' || p[1] == '\'' -#ifdef emacs - || p[1] == '=' -#endif - )) - p += 2; - - else /* Not an empty string operator. */ - break; - } - - /* See what we're at now. */ - return p < pend - && ((!(syntax & RE_NEWLINE_ORDINARY) && *p == '\n') - || (syntax & RE_NO_BK_PARENS - ? *p == ')' - : *p == '\\' && p + 1 < pend && p[1] == ')') - || (syntax & RE_NO_BK_VBAR - ? *p == '|' - : (*p == '\\' && p + 1 < pend && p[1] == '|'))); + return + /* Before a subexpression? */ + (syntax & RE_NO_BK_PARENS ? *next == ')' + : next_backslash && next_next && *next_next == ')') + /* Before an alternative? */ + || (syntax & RE_NO_BK_VBAR ? *next == '|' + : next_backslash && next_next && *next_next == '|'); } @@ -2149,6 +2183,63 @@ group_in_compile_stack (compile_stack, regnum) return false; } + + +/* Read the ending character of a range (in a bracket expression) from the + uncompiled pattern *P_PTR (which ends at PEND). We assume the + starting character is in `P[-2]'. (`P[-1]' is the character `-'.) + Then we set the translation of all bits between the starting and + ending characters (inclusive) in the compiled pattern B. + + Return an error code. + + We use these short variable names so we can use the same macros as + `regex_compile' itself. */ + +static reg_errcode_t +compile_range (p_ptr, pend, translate, syntax, b) + const char **p_ptr, *pend; + char *translate; + reg_syntax_t syntax; + unsigned char *b; +{ + unsigned this_char; + + const char *p = *p_ptr; + int range_start, range_end; + + if (p == pend) + return REG_ERANGE; + + /* Even though the pattern is a signed `char *', we need to fetch + with unsigned char *'s; if the high bit of the pattern character + is set, the range endpoints will be negative if we fetch using a + signed char *. + + We also want to fetch the endpoints without translating them; the + appropriate translation is done in the bit-setting loop below. */ + range_start = ((unsigned char *) p)[-2]; + range_end = ((unsigned char *) p)[0]; + + /* Have to increment the pointer into the pattern string, so the + caller isn't still at the ending character. */ + (*p_ptr)++; + + /* If the start is after the end, the range is empty. */ + if (range_start > range_end) + return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; + + /* Here we see why `this_char' has to be larger than an `unsigned + char' -- the range is inclusive, so if `range_end' == 0xff + (assuming 8-bit characters), we would otherwise go into an infinite + loop, since all characters <= 0xff. */ + for (this_char = range_start; this_char <= range_end; this_char++) + { + SET_LIST_BIT (TRANSLATE (this_char)); + } + + return REG_NOERROR; +} /* Failure stack declarations and macros; both re_compile_fastmap and re_match_2 use a failure stack. These have to be macros because of @@ -2157,7 +2248,7 @@ group_in_compile_stack (compile_stack, regnum) /* Number of failure points for which to initially allocate space when matching. If this number is exceeded, we allocate more - space---so it is not a hard limit. */ + space, so it is not a hard limit. */ #ifndef INIT_FAILURE_ALLOC #define INIT_FAILURE_ALLOC 5 #endif @@ -2168,75 +2259,76 @@ group_in_compile_stack (compile_stack, regnum) change it ourselves. */ int re_max_failures = 2000; -typedef const unsigned char *failure_stack_elt_t; +typedef const unsigned char *fail_stack_elt_t; typedef struct { - failure_stack_elt_t *stack; + fail_stack_elt_t *stack; unsigned size; unsigned avail; /* Offset of next open position. */ -} failure_stack_type; +} fail_stack_type; -#define FAILURE_STACK_EMPTY() (failure_stack.avail == 0) -#define FAILURE_STACK_PTR_EMPTY() (failure_stack_ptr->avail == 0) -#define FAILURE_STACK_FULL() (failure_stack.avail == failure_stack.size) -#define FAILURE_STACK_TOP() (failure_stack.stack[failure_stack.avail]) +#define FAIL_STACK_EMPTY() (fail_stack.avail == 0) +#define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0) +#define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) +#define FAIL_STACK_TOP() (fail_stack.stack[fail_stack.avail]) -/* Initialize FAILURE_STACK. Return 1 if success, 0 if not. */ +/* Initialize `fail_stack'. Do `return -2' if the alloc fails. */ -#define INIT_FAILURE_STACK(failure_stack) \ - ((failure_stack).stack = (failure_stack_elt_t *) \ - REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (failure_stack_elt_t)), \ - (failure_stack).stack == NULL \ - ? 0 \ - : ((failure_stack).size = INIT_FAILURE_ALLOC, \ - (failure_stack).avail = 0, \ - 1)) +#define INIT_FAIL_STACK() \ + do { \ + fail_stack.stack = (fail_stack_elt_t *) \ + REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \ + \ + if (fail_stack.stack == NULL) \ + return -2; \ + \ + fail_stack.size = INIT_FAILURE_ALLOC; \ + fail_stack.avail = 0; \ + } while (0) -/* Double the size of FAILURE_STACK, up to approximately - `re_max_failures' items. +/* Double the size of FAIL_STACK, up to approximately `re_max_failures' items. Return 1 if succeeds, and 0 if either ran out of memory allocating space for it or it was already too large. REGEX_REALLOCATE requires `destination' be declared. */ -#define DOUBLE_FAILURE_STACK(failure_stack) \ - ((failure_stack).size > re_max_failures * MAX_FAILURE_ITEMS \ +#define DOUBLE_FAIL_STACK(fail_stack) \ + ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \ ? 0 \ - : ((failure_stack).stack = (failure_stack_elt_t *) \ - REGEX_REALLOCATE ((failure_stack).stack, \ - ((failure_stack).size << 1) * sizeof (failure_stack_elt_t)), \ + : ((fail_stack).stack = (fail_stack_elt_t *) \ + REGEX_REALLOCATE ((fail_stack).stack, \ + (fail_stack).size * sizeof (fail_stack_elt_t), \ + ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \ \ - (failure_stack).stack == NULL \ + (fail_stack).stack == NULL \ ? 0 \ - : ((failure_stack).size <<= 1, \ + : ((fail_stack).size <<= 1, \ 1))) -/* Push PATTERN_OP on FAILURE_STACK. +/* Push PATTERN_OP on FAIL_STACK. Return 1 if was able to do so and 0 if ran out of memory allocating space to do so. */ -#define PUSH_PATTERN_OP(pattern_op, failure_stack) \ - ((FAILURE_STACK_FULL () \ - && !DOUBLE_FAILURE_STACK (failure_stack)) \ +#define PUSH_PATTERN_OP(pattern_op, fail_stack) \ + ((FAIL_STACK_FULL () \ + && !DOUBLE_FAIL_STACK (fail_stack)) \ ? 0 \ - : ((failure_stack).stack[(failure_stack).avail++] = pattern_op, \ + : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \ 1)) /* This pushes an item onto the failure stack. Must be a four-byte - value. Assumes the variable `failure_stack'. Probably should only + value. Assumes the variable `fail_stack'. Probably should only be called from within `PUSH_FAILURE_POINT'. */ #define PUSH_FAILURE_ITEM(item) \ - failure_stack.stack[failure_stack.avail++] = (failure_stack_elt_t) item + fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item -/* The complement operation. Assumes stack is nonempty, and pointed to - `failure_stack_ptr'. */ -#define POP_FAILURE_ITEM() \ - failure_stack_ptr->stack[--failure_stack_ptr->avail] +/* The complement operation. Assumes `fail_stack' is nonempty. */ +#define POP_FAILURE_ITEM() fail_stack.stack[--fail_stack.avail] /* Used to omit pushing failure point id's when we're not debugging. */ #ifdef DEBUG @@ -2251,8 +2343,8 @@ typedef struct /* Push the information about the state we will need if we ever fail back to it. - Requires variables failure_stack, regstart, regend, reg_info, and - num_regs be declared. DOUBLE_FAILURE_STACK requires `destination' be + Requires variables fail_stack, regstart, regend, reg_info, and + num_regs be declared. DOUBLE_FAIL_STACK requires `destination' be declared. Does `return FAILURE_CODE' if runs out of memory. */ @@ -2265,9 +2357,10 @@ typedef struct int this_reg; \ \ DEBUG_STATEMENT (failure_id++); \ + DEBUG_STATEMENT (nfailure_points_pushed++); \ DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \ - DEBUG_PRINT2 (" Before push, next avail: %d\n", (failure_stack).avail);\ - DEBUG_PRINT2 (" size: %d\n", (failure_stack).size);\ + DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\ + DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\ \ DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \ DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \ @@ -2275,11 +2368,11 @@ typedef struct /* Ensure we have enough space allocated for what we will push. */ \ while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \ { \ - if (!DOUBLE_FAILURE_STACK (failure_stack)) \ + if (!DOUBLE_FAIL_STACK (fail_stack)) \ return failure_code; \ \ DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \ - (failure_stack).size); \ + (fail_stack).size); \ DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\ } \ \ @@ -2299,7 +2392,7 @@ typedef struct PUSH_FAILURE_ITEM (regend[this_reg]); \ \ DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \ - DEBUG_PRINT2 (" match_nothing=%d", \ + DEBUG_PRINT2 (" match_null=%d", \ REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ DEBUG_PRINT2 (" matched_something=%d", \ @@ -2310,18 +2403,18 @@ typedef struct PUSH_FAILURE_ITEM (reg_info[this_reg].word); \ } \ \ - DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg); \ + DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ PUSH_FAILURE_ITEM (lowest_active_reg); \ \ DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ PUSH_FAILURE_ITEM (highest_active_reg); \ \ DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \ - DEBUG_COMPILED_PATTERN_PRINTER (bufp, pattern_place, pend); \ + DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ PUSH_FAILURE_ITEM (pattern_place); \ \ DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \ - DEBUG_DOUBLE_STRING_PRINTER (string_place, string1, size1, string2, \ + DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ size2); \ DEBUG_PRINT1 ("'\n"); \ PUSH_FAILURE_ITEM (string_place); \ @@ -2342,8 +2435,7 @@ typedef struct #endif /* We push at most this many items on the stack. */ -#define MAX_FAILURE_ITEMS \ - ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS) +#define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS) /* We actually push this many items. */ #define NUM_FAILURE_ITEMS \ @@ -2351,8 +2443,77 @@ typedef struct + NUM_NONREG_ITEMS) /* How many items can still be added to the stack without overflowing it. */ -#define REMAINING_AVAIL_SLOTS \ - ((failure_stack).size - (failure_stack).avail) +#define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) + + +/* Pops what PUSH_FAIL_STACK pushes. + + We restore into the parameters, all of which should be lvalues: + STR -- the saved data position. + PAT -- the saved pattern position. + LOW_REG, HIGH_REG -- the highest and lowest active registers. + REGSTART, REGEND -- arrays of string positions. + REG_INFO -- array of information about each subexpression. + + Also assumes the variables `fail_stack' and (if debugging), `bufp', + `pend', `string1', `size1', `string2', and `size2'. */ + +#define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\ +{ \ + DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \ + int this_reg; \ + const unsigned char *string_temp; \ + \ + assert (!FAIL_STACK_EMPTY ()); \ + \ + /* Remove failure points and point to how many regs pushed. */ \ + DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \ + DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \ + DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \ + \ + assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ + \ + DEBUG_POP (&failure_id); \ + DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \ + \ + /* If the saved string location is NULL, it came from an \ + on_failure_keep_string_jump opcode, and we want to throw away the \ + saved NULL, thus retaining our current position in the string. */ \ + string_temp = POP_FAILURE_ITEM (); \ + if (string_temp != NULL) \ + str = (const char *) string_temp; \ + \ + DEBUG_PRINT2 (" Popping string 0x%x: `", str); \ + DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ + DEBUG_PRINT1 ("'\n"); \ + \ + pat = (unsigned char *) POP_FAILURE_ITEM (); \ + DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \ + DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ + \ + /* Restore register info. */ \ + high_reg = (unsigned) POP_FAILURE_ITEM (); \ + DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ + \ + low_reg = (unsigned) POP_FAILURE_ITEM (); \ + DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ + \ + for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ + { \ + DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ + \ + reg_info[this_reg].word = POP_FAILURE_ITEM (); \ + DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ + \ + regend[this_reg] = (const char *) POP_FAILURE_ITEM (); \ + DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ + \ + regstart[this_reg] = (const char *) POP_FAILURE_ITEM (); \ + DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ + } \ + \ + DEBUG_STATEMENT (nfailure_points_popped++); \ +} /* POP_FAILURE_POINT */ /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible @@ -2360,20 +2521,19 @@ typedef struct is used by re_search to skip quickly over impossible starting points. The caller must supply the address of a (1 << BYTEWIDTH)-byte data - area as BUFP->fastmap. The other components of BUFP describe the - pattern to be used. + area as BUFP->fastmap. - We set the `can_be_null' and `fastmap_accurate' fields in the pattern + We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in + the pattern buffer. - Returns 0 if it can compile a fastmap. Returns -2 if there is an - internal error. */ + Returns 0 if we succeed, -2 if an internal error. */ int re_compile_fastmap (bufp) struct re_pattern_buffer *bufp; { int j, k; - failure_stack_type failure_stack; + fail_stack_type fail_stack; #ifndef REGEX_MALLOC char *destination; #endif @@ -2386,31 +2546,57 @@ re_compile_fastmap (bufp) const unsigned char *p = pattern; register unsigned char *pend = pattern + size; - INIT_FAILURE_STACK (failure_stack); + /* Assume that each path through the pattern can be null until + proven otherwise. We set this false at the bottom of switch + statement, to which we get only if a particular path doesn't + match the empty string. */ + boolean path_can_be_null = true; - bzero (fastmap, 1 << BYTEWIDTH); - bufp->fastmap_accurate = 1; /* It will be when we're done. */ + /* We aren't doing a `succeed_n' to begin with. */ + boolean succeed_n_p = false; + + assert (fastmap != NULL && p != NULL); + + INIT_FAIL_STACK (); + bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */ + bufp->fastmap_accurate = 1; /* It will be when we're done. */ bufp->can_be_null = 0; - while (p) + while (p != pend || !FAIL_STACK_EMPTY ()) { - boolean is_a_succeed_n = false; - if (p == pend) - if (FAILURE_STACK_EMPTY ()) - { - bufp->can_be_null = 1; - break; - } - else - p = failure_stack.stack[--failure_stack.avail]; + { + bufp->can_be_null |= path_can_be_null; + /* Reset for next path. */ + path_can_be_null = true; + + p = fail_stack.stack[--fail_stack.avail]; + } + + /* We should never be about to go beyond the end of the pattern. */ + assert (p < pend); + #ifdef SWITCH_ENUM_BUG switch ((int) ((re_opcode_t) *p++)) #else switch ((re_opcode_t) *p++) #endif { + + /* I guess the idea here is to simply not bother with a fastmap + if a backreference is used, since it's too hard to figure out + the fastmap for the corresponding group. Setting + `can_be_null' stops `re_search_2' from using the fastmap, so + that is all we do. */ + case duplicate: + bufp->can_be_null = 1; + return 0; + + + /* Following are the cases which match a character. These end + with `break'. */ + case exactn: fastmap[p[1]] = 1; break; @@ -2434,40 +2620,95 @@ re_compile_fastmap (bufp) break; + case wordchar: + for (j = 0; j < (1 << BYTEWIDTH); j++) + if (SYNTAX (j) == Sword) + fastmap[j] = 1; + break; + + + case notwordchar: + for (j = 0; j < (1 << BYTEWIDTH); j++) + if (SYNTAX (j) != Sword) + fastmap[j] = 1; + break; + + + case anychar: + /* `.' matches anything ... */ + for (j = 0; j < (1 << BYTEWIDTH); j++) + fastmap[j] = 1; + + /* ... except perhaps newline. */ + if (!(bufp->syntax & RE_DOT_NEWLINE)) + fastmap['\n'] = 0; + + /* Return if we have already set `can_be_null'; if we have, + then the fastmap is irrelevant. Something's wrong here. */ + else if (bufp->can_be_null) + return 0; + + /* Otherwise, have to check alternative paths. */ + break; + + +#ifdef emacs + case syntaxspec: + k = *p++; + for (j = 0; j < (1 << BYTEWIDTH); j++) + if (SYNTAX (j) == (enum syntaxcode) k) + fastmap[j] = 1; + break; + + + case notsyntaxspec: + k = *p++; + for (j = 0; j < (1 << BYTEWIDTH); j++) + if (SYNTAX (j) != (enum syntaxcode) k) + fastmap[j] = 1; + break; + + + /* All cases after this match the empty string. These end with + `continue'. */ + + + case before_dot: + case at_dot: + case after_dot: + continue; +#endif /* not emacs */ + + case no_op: case begline: + case endline: case begbuf: case endbuf: case wordbound: case notwordbound: case wordbeg: case wordend: + case push_dummy_failure: continue; - case endline: - if (!bufp->can_be_null) - bufp->can_be_null = 2; - break; - - - case no_pop_jump_n: + case jump_n: case pop_failure_jump: case maybe_pop_jump: - case no_pop_jump: - case jump_past_next_alt: + case jump: + case jump_past_alt: case dummy_failure_jump: EXTRACT_NUMBER_AND_INCR (j, p); p += j; if (j > 0) continue; - /* Jump backward reached implies we just went through - the body of a loop and matched nothing. Opcode jumped to - should be an on_failure_jump or succeed_n. Just treat it - like an ordinary jump. For a * loop, it has pushed its - failure point already; if so, discard that as redundant. */ - + /* Jump backward implies we just went through the body of a + loop and matched nothing. Opcode jumped to should be + `on_failure_jump' or `succeed_n'. Just treat it like an + ordinary jump. For a * loop, it has pushed its failure + point already; if so, discard that as redundant. */ if ((re_opcode_t) *p != on_failure_jump && (re_opcode_t) *p != succeed_n) continue; @@ -2477,14 +2718,15 @@ re_compile_fastmap (bufp) p += j; /* If what's on the stack is where we are now, pop it. */ - if (!FAILURE_STACK_EMPTY () - && failure_stack.stack[failure_stack.avail - 1] == p) - failure_stack.avail--; + if (!FAIL_STACK_EMPTY () + && fail_stack.stack[fail_stack.avail - 1] == p) + fail_stack.avail--; continue; case on_failure_jump: + case on_failure_keep_string_jump: handle_on_failure_jump: EXTRACT_NUMBER_AND_INCR (j, p); @@ -2492,23 +2734,27 @@ re_compile_fastmap (bufp) end of the pattern. We don't want to push such a point, since when we restore it above, entering the switch will increment `p' past the end of the pattern. We don't need - to push such a point since there can't be any more - possibilities for the fastmap beyond pend. */ + to push such a point since we obviously won't find any more + fastmap entries beyond `pend'. Such a pattern can match + the null string, though. */ if (p + j < pend) { - if (!PUSH_PATTERN_OP (p + j, failure_stack)) + if (!PUSH_PATTERN_OP (p + j, fail_stack)) return -2; } + else + bufp->can_be_null = 1; - if (is_a_succeed_n) - EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ + if (succeed_n_p) + { + EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ + succeed_n_p = false; + } continue; case succeed_n: - is_a_succeed_n = true; - /* Get to the number of times to succeed. */ p += 2; @@ -2517,6 +2763,7 @@ re_compile_fastmap (bufp) if (k == 0) { p -= 4; + succeed_n_p = true; /* Spaghetti code alert. */ goto handle_on_failure_jump; } continue; @@ -2533,75 +2780,60 @@ re_compile_fastmap (bufp) continue; - /* I don't understand this case (any of it). --karl */ - case duplicate: - bufp->can_be_null = 1; - fastmap['\n'] = 1; - - - case anychar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (j != '\n') - fastmap[j] = 1; - if (bufp->can_be_null) - return 0; - - /* Don't return; check the alternative paths - so we can set can_be_null if appropriate. */ - break; - - - case wordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == Sword) - fastmap[j] = 1; - break; - - - case notwordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != Sword) - fastmap[j] = 1; - break; - - -#ifdef emacs - case before_dot: - case at_dot: - case after_dot: - continue; - - - case syntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == (enum syntaxcode) k) - fastmap[j] = 1; - break; - - - case notsyntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != (enum syntaxcode) k) - fastmap[j] = 1; - break; -#endif /* not emacs */ - - default: - abort (); + default: + abort (); /* We have listed all the cases. */ } /* switch *p++ */ - /* Getting here means we have successfully found the possible starting - characters of one path of the pattern. We need not follow this - path any farther. Instead, look at the next alternative - remembered in the stack, or quit. The test at the top of the - loop does these things. */ + /* Getting here means we have found the possible starting + characters for one path of the pattern -- and that the empty + string does not match. We need not follow this path further. + Instead, look at the next alternative (remembered on the + stack), or quit if no more. The test at the top of the loop + does these things. */ + path_can_be_null = false; p = pend; } /* while p */ + /* Set `can_be_null' for the last path (also the first path, if the + pattern is empty). */ + bufp->can_be_null |= path_can_be_null; return 0; -} /* re_compile_fastmap */ +} /* re_compile_fastmap */ + +/* Set REGS to hold NUM_REGS registers, storing them in STARTS and + ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use + this memory for recording register information. STARTS and ENDS + must be allocated using the malloc library routine, and must each + be at least NUM_REGS * sizeof (regoff_t) bytes long. + + If NUM_REGS == 0, then subsequent matches should allocate their own + register data. + + Unless this function is called, the first search or match using + PATTERN_BUFFER will allocate its own register data, without + freeing the old data. */ + +void +re_set_registers (bufp, regs, num_regs, starts, ends) + struct re_pattern_buffer *bufp; + struct re_registers *regs; + unsigned num_regs; + regoff_t *starts, *ends; +{ + if (num_regs) + { + bufp->regs_allocated = REGS_REALLOCATE; + regs->num_regs = num_regs; + regs->start = starts; + regs->end = ends; + } + else + { + bufp->regs_allocated = REGS_UNALLOCATED; + regs->num_regs = 0; + regs->start = regs->end = (regoff_t) 0; + } +} /* Searching routines. */ @@ -2642,8 +2874,7 @@ re_search (bufp, string, size, startpos, range, regs) stack overflow). */ int -re_search_2 (bufp, string1, size1, string2, size2, startpos, range, - regs, stop) +re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) struct re_pattern_buffer *bufp; const char *string1, *string2; int size1, size2; @@ -2669,15 +2900,9 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, else if (endpos > total_size) range = total_size - startpos; - /* Update the fastmap now if not correct already. */ - if (fastmap && !bufp->fastmap_accurate) - if (re_compile_fastmap (bufp) == -2) - return -2; - /* If the search isn't to be a backwards one, don't waste time in a - long search for a pattern that says it is anchored. */ - if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf - && range > 0) + search for a pattern that must be anchored. */ + if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) { if (startpos > 0) return -1; @@ -2685,12 +2910,18 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, range = 1; } + /* Update the fastmap now if not correct already. */ + if (fastmap && !bufp->fastmap_accurate) + if (re_compile_fastmap (bufp) == -2) + return -2; + + /* Loop through the string, looking for a place to start matching. */ for (;;) { /* If a fastmap is supplied, skip quickly over characters that cannot be the start of a match. If the pattern can match the - null string, however, we don't want to skip over characters; we - want the first null string. */ + null string, however, we don't need to skip characters; we want + the first null string. */ if (fastmap && startpos < total_size && !bufp->can_be_null) { if (range > 0) /* Searching forwards. */ @@ -2707,36 +2938,30 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, /* Written out as an if-else to avoid testing `translate' inside the loop. */ if (translate) - { - while (range > lim - && !fastmap[(unsigned char) translate[*d++]]) - range--; - } + while (range > lim + && !fastmap[(unsigned char) + translate[(unsigned char) *d++]]) + range--; else - { - while (range > lim && !fastmap[(unsigned char) *d++]) - range--; - } + while (range > lim && !fastmap[(unsigned char) *d++]) + range--; startpos += irange - range; } else /* Searching backwards. */ { - register char c - = (size1 == 0 || startpos >= size1 - ? string2[startpos - size1] - : string1[startpos]); - - if (translate - ? !fastmap[(unsigned char) translate[(unsigned char) c]] - : !fastmap[(unsigned char) c]) + register char c = (size1 == 0 || startpos >= size1 + ? string2[startpos - size1] + : string1[startpos]); + + if (!fastmap[(unsigned char) TRANSLATE (c)]) goto advance; } } /* If can't match the null string, and that's all we have left, fail. */ - if (range >= 0 && startpos == total_size - && fastmap && bufp->can_be_null == 0) + if (range >= 0 && startpos == total_size && fastmap + && !bufp->can_be_null) return -1; val = re_match_2 (bufp, string1, size1, string2, size2, @@ -2770,8 +2995,6 @@ static int bcmp_translate (); static boolean alt_match_null_string_p (), common_op_match_null_string_p (), group_match_null_string_p (); -static void pop_failure_point (); - /* Structure for per-register (a.k.a. per-group) information. This must not be longer than one word, because we push this value @@ -2786,12 +3009,12 @@ static void pop_failure_point (); failure stack. */ typedef union { - failure_stack_elt_t word; + fail_stack_elt_t word; struct { /* This field is one if this group can match the empty string, - zero if not. If not yet determined, `MATCH_NOTHING_UNSET_VALUE'. */ -#define MATCH_NOTHING_UNSET_VALUE 3 + zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ +#define MATCH_NULL_UNSET_VALUE 3 unsigned match_null_string_p : 2; unsigned is_active : 1; unsigned matched_something : 1; @@ -2805,12 +3028,9 @@ typedef union #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) -/* Call this when have matched something; it sets `matched' flags for the - registers corresponding to the group of which we currently are inside. - Also records whether this group ever matched something. We only care - about this information at `stop_memory', and then only about the - previous time through the loop (if the group is starred or whatever). - So it is ok to clear all the nonactive registers here. */ +/* Call this when have matched a real character; it sets `matched' flags + for the subexpressions which we are currently inside. Also records + that those subexprs have matched. */ #define SET_REGS_MATCHED() \ do \ { \ @@ -2825,14 +3045,12 @@ typedef union while (0) -/* This converts a pointer into one or the other of the strings into an - offset from the beginning of that string. */ -#define POINTER_TO_OFFSET(pointer) IS_IN_FIRST_STRING (pointer) \ - ? (pointer) - string1 \ - : (pointer) - string2 + size1 +/* This converts PTR, a pointer into one of the search strings `string1' + and `string2' into an offset from the beginning of that string. */ +#define POINTER_TO_OFFSET(ptr) \ + (FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1) -/* Registers are set to a sentinel value when they haven't yet matched - anything. */ +/* Registers are set to a sentinel when they haven't yet matched. */ #define REG_UNSET_VALUE ((char *) -1) #define REG_UNSET(e) ((e) == REG_UNSET_VALUE) @@ -2843,7 +3061,7 @@ typedef union /* Call before fetching a character with *d. This switches over to string2 if necessary. */ -#define PREFETCH \ +#define PREFETCH() \ while (d == dend) \ { \ /* End of string2 => fail. */ \ @@ -2856,48 +3074,46 @@ typedef union /* Test if at very beginning or at very end of the virtual concatenation - of string1 and string2. If there is only one string, we've put it in - string2. */ -#define AT_STRINGS_BEG (d == (size1 ? string1 : string2) || !size2) -#define AT_STRINGS_END (d == end2) + of `string1' and `string2'. If only one string, it's `string2'. */ +#define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) +#define AT_STRINGS_END(d) ((d) == end2) /* Test if D points to a character which is word-constituent. We have two special cases to check for: if past the end of string1, look at the first character in string2; and if before the beginning of - string2, look at the last character in string1. - - We assume there is a string1, so use this in conjunction with - AT_STRINGS_BEG. */ -#define LETTER_P(d) \ - (SYNTAX ((d) == end1 ? *string2 : (d) == string2 - 1 ? *(end1 - 1) : *(d))\ + string2, look at the last character in string1. */ +#define WORDCHAR_P(d) \ + (SYNTAX ((d) == end1 ? *string2 \ + : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \ == Sword) /* Test if the character before D and the one at D differ with respect to being word-constituent. */ #define AT_WORD_BOUNDARY(d) \ - (AT_STRINGS_BEG || AT_STRINGS_END || LETTER_P (d - 1) != LETTER_P (d)) + (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \ + || WORDCHAR_P (d - 1) != WORDCHAR_P (d)) /* Free everything we malloc. */ #ifdef REGEX_MALLOC +#define FREE_VAR(var) if (var) free (var); var = NULL #define FREE_VARIABLES() \ do { \ - free (failure_stack.stack); \ - free (regstart); \ - free (regend); \ - free (old_regstart); \ - free (old_regend); \ - free (reg_info); \ - free (best_regstart); \ - free (best_regend); \ - reg_info = NULL; \ - failure_stack.stack = NULL; \ - regstart = regend = old_regstart = old_regend \ - = best_regstart = best_regend = NULL; \ + FREE_VAR (fail_stack.stack); \ + FREE_VAR (regstart); \ + FREE_VAR (regend); \ + FREE_VAR (old_regstart); \ + FREE_VAR (old_regend); \ + FREE_VAR (best_regstart); \ + FREE_VAR (best_regend); \ + FREE_VAR (reg_info); \ + FREE_VAR (reg_dummy); \ + FREE_VAR (reg_info_dummy); \ } while (0) #else /* not REGEX_MALLOC */ -#define FREE_VARIABLES() /* As nothing, since we use alloca. */ +/* Some MIPS systems (at least) want this to free alloca'd storage. */ +#define FREE_VARIABLES() alloca (0) #endif /* not REGEX_MALLOC */ @@ -2914,12 +3130,11 @@ typedef union /* Matching routines. */ #ifndef emacs /* Emacs never uses this. */ - /* re_match is like re_match_2 except it takes only a single string. */ int re_match (bufp, string, size, pos, regs) - const struct re_pattern_buffer *bufp; + struct re_pattern_buffer *bufp; const char *string; int size, pos; struct re_registers *regs; @@ -2935,10 +3150,8 @@ re_match (bufp, string, size, pos, regs) matching at STOP. If REGS is non-null and the `no_sub' field of BUFP is nonzero, we - store offsets for the substring each group matched in REGS. (If - BUFP->caller_allocated_regs is nonzero, we fill REGS->num_regs - registers; if zero, we set REGS->num_regs to max (RE_NREGS, - re_nsub+1) and allocate the space with malloc before filling.) + store offsets for the substring each group matched in REGS. See the + documentation for exactly how many groups we fill. We return -1 if no match, -2 if an internal error (such as the failure stack overflowing). Otherwise, we return the length of the @@ -2946,7 +3159,7 @@ re_match (bufp, string, size, pos, regs) int re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) - const struct re_pattern_buffer *bufp; + struct re_pattern_buffer *bufp; const char *string1, *string2; int size1, size2; int pos; @@ -2974,23 +3187,24 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) /* We use this to map every character in the string. */ char *translate = bufp->translate; - /* Failure point stack. Each place that can handle a failure further - down the line pushes a failure point on this stack. It consists of - restart, regend, and reg_info for all registers corresponding to the - subexpressions we're currently inside, plus the number of such - registers, and, finally, two char *'s. The first char * is where to - resume scanning the pattern; the second one is where to resume - scanning the strings. If the latter is zero, the failure point is a - ``dummy''; if a failure happens and the failure point is a dummy, it - gets discarded and the next next one is tried. */ - failure_stack_type failure_stack; + /* Failure point stack. Each place that can handle a failure further + down the line pushes a failure point on this stack. It consists of + restart, regend, and reg_info for all registers corresponding to + the subexpressions we're currently inside, plus the number of such + registers, and, finally, two char *'s. The first char * is where + to resume scanning the pattern; the second one is where to resume + scanning the strings. If the latter is zero, the failure point is + a ``dummy''; if a failure happens and the failure point is a dummy, + it gets discarded and the next next one is tried. */ + fail_stack_type fail_stack; #ifdef DEBUG static unsigned failure_id = 0; + unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; #endif /* We fill all the registers internally, independent of what we return, for use in backreferences. The number here includes - register zero. */ + an element for register zero. */ unsigned num_regs = bufp->re_nsub + 1; /* The currently active registers. */ @@ -3004,20 +3218,14 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) matching and the regnum-th regend points to right after where we stopped matching the regnum-th subexpression. (The zeroth register keeps track of what the whole pattern matches.) */ - const char **regstart - = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *)); - const char **regend - = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *)); + const char **regstart, **regend; /* If a group that's operated upon by a repetition operator fails to match anything, then the register for its start will need to be restored because it will have been set to wherever in the string we are when we last see its open-group operator. Similarly for a register's end. */ - const char **old_regstart - = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *)); - const char **old_regend - = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *)); + const char **old_regstart, **old_regend; /* The is_active field of reg_info helps us keep track of which (possibly nested) subexpressions we are currently in. The matched_something @@ -3025,24 +3233,28 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) matched any of the pattern so far this time through the reg_num-th subexpression. These two fields get reset each time through any loop their register is in. */ - register_info_type *reg_info = (register_info_type *) - REGEX_ALLOCATE (num_regs * sizeof (register_info_type)); + register_info_type *reg_info; /* The following record the register info as found in the above variables when we find a match better than any we've seen before. This happens as we backtrack through the failure points, which in - turn happens only if we have not yet matched the entire string. */ - unsigned best_regs_set = 0; - const char **best_regstart - = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *)); - const char **best_regend - = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *)); + turn happens only if we have not yet matched the entire string. */ + unsigned best_regs_set = false; + const char **best_regstart, **best_regend; + + /* Logically, this is `best_regend[0]'. But we don't want to have to + allocate space for that if we're not allocating space for anything + else (see below). Also, we never need info about register 0 for + any of the other register vectors, and it seems rather a kludge to + treat `best_regend' differently than the rest. So we keep track of + the end of the best match so far in a separate variable. We + initialize this to NULL so that when we backtrack the first time + and need to test it, it's not garbage. */ + const char *match_end = NULL; /* Used when we pop values we don't care about. */ - const char **reg_dummy - = (const char **) REGEX_ALLOCATE (num_regs * sizeof (char *)); - register_info_type *reg_info_dummy = (register_info_type *) - REGEX_ALLOCATE (num_regs * sizeof (register_info_type)); + const char **reg_dummy; + register_info_type *reg_info_dummy; #ifdef DEBUG /* Counts the total number of registers pushed. */ @@ -3051,15 +3263,42 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) DEBUG_PRINT1 ("\n\nEntering re_match_2.\n"); - if (!INIT_FAILURE_STACK (failure_stack)) - return -2; - - if (!(regstart && regend && old_regstart && old_regend && reg_info - && best_regstart && best_regend)) + INIT_FAIL_STACK (); + + /* Do not bother to initialize all the register variables if there are + no groups in the pattern, as it takes a fair amount of time. If + there are groups, we include space for register 0 (the whole + pattern), even though we never use it, since it simplifies the + array indexing. We should fix this. */ + if (bufp->re_nsub) { - FREE_VARIABLES (); - return -2; + regstart = REGEX_TALLOC (num_regs, const char *); + regend = REGEX_TALLOC (num_regs, const char *); + old_regstart = REGEX_TALLOC (num_regs, const char *); + old_regend = REGEX_TALLOC (num_regs, const char *); + best_regstart = REGEX_TALLOC (num_regs, const char *); + best_regend = REGEX_TALLOC (num_regs, const char *); + reg_info = REGEX_TALLOC (num_regs, register_info_type); + reg_dummy = REGEX_TALLOC (num_regs, const char *); + reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); + + if (!(regstart && regend && old_regstart && old_regend && reg_info + && best_regstart && best_regend && reg_dummy && reg_info_dummy)) + { + FREE_VARIABLES (); + return -2; + } } +#ifdef REGEX_MALLOC + else + { + /* We must initialize all our variables to NULL, so that + `FREE_VARIABLES' doesn't try to free them. */ + regstart = regend = old_regstart = old_regend = best_regstart + = best_regend = reg_dummy = NULL; + reg_info = reg_info_dummy = (register_info_type *) NULL; + } +#endif /* REGEX_MALLOC */ /* The starting position is bogus. */ if (pos < 0 || pos > size1 + size2) @@ -3068,26 +3307,22 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) return -1; } - /* Initialize subexpression text positions to -1 to mark ones that no - \( or ( and \) or ) has been seen for. Also set all registers to - inactive and mark them as not having any inner groups, able to - match the empty string, matched anything so far, or ever failed. */ - for (mcnt = 0; mcnt < num_regs; mcnt++) + start_memory/stop_memory has been seen for. Also initialize the + register information struct. */ + for (mcnt = 1; mcnt < num_regs; mcnt++) { regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE; - REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NOTHING_UNSET_VALUE; + REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; IS_ACTIVE (reg_info[mcnt]) = 0; MATCHED_SOMETHING (reg_info[mcnt]) = 0; EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; } - IS_ACTIVE (reg_info[0]) = 1; - - /* We move string1 into string2 if the latter's empty---but not if - string1 is null. */ + /* We move `string1' into `string2' if the latter's empty -- but not if + `string1' is null. */ if (size2 == 0 && string1 != NULL) { string2 = string1; @@ -3110,9 +3345,9 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) end_match_2 = string2 + stop - size1; } - /* `p' scans through the pattern as `d' scans through the data. `dend' - is the end of the input string that `d' points within. `d' is - advanced into the following input string whenever necessary, but + /* `p' scans through the pattern as `d' scans through the data. + `dend' is the end of the input string that `d' points within. `d' + is advanced into the following input string whenever necessary, but this happens before fetching; therefore, at the beginning of the loop, `d' can be pointing at the end of a string, but it cannot equal `string2'. */ @@ -3128,9 +3363,9 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) } DEBUG_PRINT1 ("The compiled pattern is: "); - DEBUG_COMPILED_PATTERN_PRINTER (bufp, p, pend); + DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend); DEBUG_PRINT1 ("The string to match is: `"); - DEBUG_DOUBLE_STRING_PRINTER (d, string1, size1, string2, size2); + DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); DEBUG_PRINT1 ("'\n"); /* This loops over pattern commands. It exits by returning from the @@ -3142,26 +3377,28 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) if (p == pend) { /* End of pattern means we might have succeeded. */ - DEBUG_PRINT1 ("End of pattern: "); - /* If not end of string, try backtracking. Otherwise done. */ + DEBUG_PRINT1 ("end of pattern ... "); + + /* If we haven't matched the entire string, and we want the + longest match, try backtracking. */ if (d != end_match_2) { DEBUG_PRINT1 ("backtracking.\n"); - if (!FAILURE_STACK_EMPTY ()) + if (!FAIL_STACK_EMPTY ()) { /* More failure points to try. */ - - boolean in_same_string = - IS_IN_FIRST_STRING (best_regend[0]) - == MATCHING_IN_FIRST_STRING; + boolean same_str_p = (FIRST_STRING_P (match_end) + == MATCHING_IN_FIRST_STRING); /* If exceeds best match so far, save it. */ if (!best_regs_set - || (in_same_string && d > best_regend[0]) - || (!in_same_string && !MATCHING_IN_FIRST_STRING)) + || (same_str_p && d > match_end) + || (!same_str_p && !MATCHING_IN_FIRST_STRING)) { - best_regs_set = 1; - best_regend[0] = d; /* Never use regstart[0]. */ + best_regs_set = true; + match_end = d; + + DEBUG_PRINT1 ("\nSAVING match as best so far.\n"); for (mcnt = 1; mcnt < num_regs; mcnt++) { @@ -3176,13 +3413,18 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) else if (best_regs_set) { restore_best_regs: - /* Restore best match. */ - d = best_regend[0]; + /* Restore best match. It may happen that `dend == + end_match_1' while the restored d is in string2. + For example, the pattern `x.*y.*z' against the + strings `x-' and `y-z-', if the two strings are + not consecutive in memory. */ + DEBUG_PRINT1 ("Restoring best registers.\n"); - if (d >= string1 && d <= end1) - dend = end_match_1; + d = match_end; + dend = ((d >= string1 && d <= end1) + ? end_match_1 : end_match_2); - for (mcnt = 0; mcnt < num_regs; mcnt++) + for (mcnt = 1; mcnt < num_regs; mcnt++) { regstart[mcnt] = best_regstart[mcnt]; regend[mcnt] = best_regend[mcnt]; @@ -3190,35 +3432,51 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) } } /* d != end_match_2 */ - DEBUG_PRINT1 ("accepting match.\n"); + DEBUG_PRINT1 ("Accepting match.\n"); /* If caller wants register contents data back, do it. */ if (regs && !bufp->no_sub) { - /* If they haven't allocated it, we'll do it. */ - if (!bufp->caller_allocated_regs) - { + /* Have the register data arrays been allocated? */ + if (bufp->regs_allocated == REGS_UNALLOCATED) + { /* No. So allocate them with malloc. We need one + extra element beyond `num_regs' for the `-1' marker + GNU code uses. */ regs->num_regs = MAX (RE_NREGS, num_regs + 1); regs->start = TALLOC (regs->num_regs, regoff_t); regs->end = TALLOC (regs->num_regs, regoff_t); if (regs->start == NULL || regs->end == NULL) return -2; + bufp->regs_allocated = REGS_REALLOCATE; } - + else if (bufp->regs_allocated == REGS_REALLOCATE) + { /* Yes. If we need more elements than were already + allocated, reallocate them. If we need fewer, just + leave it alone. */ + if (regs->num_regs < num_regs + 1) + { + regs->num_regs = num_regs + 1; + RETALLOC (regs->start, regs->num_regs, regoff_t); + RETALLOC (regs->end, regs->num_regs, regoff_t); + if (regs->start == NULL || regs->end == NULL) + return -2; + } + } + else + assert (bufp->regs_allocated == REGS_FIXED); + /* Convert the pointer data in `regstart' and `regend' to indices. Register zero has to be set differently, since we haven't kept track of any info for it. */ if (regs->num_regs > 0) { regs->start[0] = pos; - regs->end[0] = MATCHING_IN_FIRST_STRING - ? d - string1 - : d - string2 + size1; + regs->end[0] = (MATCHING_IN_FIRST_STRING ? d - string1 + : d - string2 + size1); } - /* Go through the first min (num_regs, regs->num_regs) - registers, since that is all we initialized at the - beginning. */ + /* Go through the first `min (num_regs, regs->num_regs)' + registers, since that is all we initialized. */ for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++) { if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt])) @@ -3231,16 +3489,19 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) } /* If the regs structure we return has more elements than - it than were in the pattern, set the extra elements to - -1. If we allocated the registers, this is the case, - because we always allocate enough to have at least -1 - at the end. */ + were in the pattern, set the extra elements to -1. If + we (re)allocated the registers, this is the case, + because we always allocate enough to have at least one + -1 at the end. */ for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++) regs->start[mcnt] = regs->end[mcnt] = -1; } /* regs && !bufp->no_sub */ FREE_VARIABLES (); - DEBUG_PRINT2 ("%d registers pushed.\n", num_regs_pushed); + DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", + nfailure_points_pushed, nfailure_points_popped, + nfailure_points_pushed - nfailure_points_popped); + DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed); mcnt = d - pos - (MATCHING_IN_FIRST_STRING ? string1 @@ -3278,7 +3539,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) { do { - PREFETCH; + PREFETCH (); if (translate[(unsigned char) *d++] != (char) *p++) goto fail; } @@ -3288,7 +3549,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) { do { - PREFETCH; + PREFETCH (); if (*d++ != (char) *p++) goto fail; } while (--mcnt); @@ -3297,17 +3558,18 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) break; - /* Match anything but possibly a newline or a null. */ + /* Match any character except possibly a newline or a null. */ case anychar: DEBUG_PRINT1 ("EXECUTING anychar.\n"); - PREFETCH; + PREFETCH (); if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n') || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000')) goto fail; SET_REGS_MATCHED (); + DEBUG_PRINT2 (" Matched `%d'.\n", *d); d++; break; @@ -3320,10 +3582,12 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : ""); - PREFETCH; + PREFETCH (); c = TRANSLATE (*d); /* The character to match. */ - if (c < (unsigned char) (*p * BYTEWIDTH) + /* Cast to `unsigned' instead of `unsigned char' in case the + bit list is a full 32 bytes long. */ + if (c < (unsigned) (*p * BYTEWIDTH) && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) not = !not; @@ -3348,8 +3612,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) /* Find out if this group can match the empty string. */ p1 = p; /* To send to group_match_null_string_p. */ - if (REG_MATCH_NULL_STRING_P (reg_info[*p]) - == MATCH_NOTHING_UNSET_VALUE) + if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE) REG_MATCH_NULL_STRING_P (reg_info[*p]) = group_match_null_string_p (&p1, pend, reg_info); @@ -3419,32 +3682,28 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) (a(b)c(d(e)f)g). When group 3 ends, after the f), the new highest active register is 1. */ unsigned char r = *p - 1; - - /* This loop will always terminate, because register 0 is - always active. */ - assert (IS_ACTIVE (reg_info[0])); - while (!IS_ACTIVE (reg_info[r])) + while (r > 0 && !IS_ACTIVE (reg_info[r])) r--; /* If we end up at register zero, that means that we saved - the registers as the result of an on_failure_jump, not - a start_memory, and we jumped to past the innermost - stop_memory. For example, in ((.)*). We save + the registers as the result of an `on_failure_jump', not + a `start_memory', and we jumped to past the innermost + `stop_memory'. For example, in ((.)*) we save registers 1 and 2 as a result of the *, but when we pop back to the second ), we are at the stop_memory 1. Thus, nothing is active. */ - if (r != 0) - highest_active_reg = r; - else + if (r == 0) { lowest_active_reg = NO_LOWEST_ACTIVE_REG; highest_active_reg = NO_HIGHEST_ACTIVE_REG; } + else + highest_active_reg = r; } /* If just failed to match something this time around with a group that's operated on by a repetition operator, try to - force exit from the ``loop,'' and restore the register + force exit from the ``loop'', and restore the register information for this group that we had before trying this last match. */ if ((!MATCHED_SOMETHING (reg_info[*p]) @@ -3457,11 +3716,11 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) mcnt = 0; switch ((re_opcode_t) *p1++) { - case no_pop_jump_n: + case jump_n: is_a_jump_n = true; case pop_failure_jump: case maybe_pop_jump: - case no_pop_jump: + case jump: case dummy_failure_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p1); if (is_a_jump_n) @@ -3540,8 +3799,8 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) set to the place to stop, otherwise, for now have to use the end of the first string. */ - dend2 = ((IS_IN_FIRST_STRING (regstart[regno]) - == IS_IN_FIRST_STRING (regend[regno])) + dend2 = ((FIRST_STRING_P (regstart[regno]) + == FIRST_STRING_P (regend[regno])) ? regend[regno] : end_match_1); for (;;) { @@ -3560,7 +3819,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) if (d2 == dend2) break; /* If necessary, advance to next segment in data. */ - PREFETCH; + PREFETCH (); /* How many characters left in this segment to match. */ mcnt = dend - d; @@ -3588,11 +3847,11 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) case begline: DEBUG_PRINT1 ("EXECUTING begline.\n"); - if (AT_STRINGS_BEG) + if (AT_STRINGS_BEG (d)) { if (!bufp->not_bol) break; } - else if (d[-1] == '\n' && bufp->newline_anchor) + else if (d[-1] == '\n' && bufp->newline_anchor) { break; } @@ -3604,7 +3863,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) case endline: DEBUG_PRINT1 ("EXECUTING endline.\n"); - if (AT_STRINGS_END) + if (AT_STRINGS_END (d)) { if (!bufp->not_eol) break; } @@ -3621,7 +3880,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) /* Match at the very beginning of the data. */ case begbuf: DEBUG_PRINT1 ("EXECUTING begbuf.\n"); - if (AT_STRINGS_BEG) + if (AT_STRINGS_BEG (d)) break; goto fail; @@ -3629,27 +3888,27 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) /* Match at the very end of the data. */ case endbuf: DEBUG_PRINT1 ("EXECUTING endbuf.\n"); - if (AT_STRINGS_END) + if (AT_STRINGS_END (d)) break; goto fail; /* on_failure_keep_string_jump is used to optimize `.*\n'. It pushes NULL as the value for the string on the stack. Then - pop_failure_point will keep the current value for the string, - instead of restoring it. To see why, consider matching - `foo\nbar' against `.*\n'. The .* matches the foo; then the - . fails against the \n. But the next thing we want to do is - match the \n against the \n; if we restored the string value, - we would be back at the foo. + `pop_failure_point' will keep the current value for the + string, instead of restoring it. To see why, consider + matching `foo\nbar' against `.*\n'. The .* matches the foo; + then the . fails against the \n. But the next thing we want + to do is match the \n against the \n; if we restored the + string value, we would be back at the foo. Because this is used only in specific cases, we don't need to - go through the hassle of checking all the things that - on_failure_jump does, to make sure the right things get saved - on the stack. Hence we don't share its code. The only - reason to push anything on the stack at all is that otherwise - we would have to change anychar's code to do something - besides goto fail in this case; that seems worse than this. */ + check all the things that `on_failure_jump' does, to make + sure the right things get saved on the stack. Hence we don't + share its code. The only reason to push anything on the + stack at all is that otherwise we would have to change + `anychar's code to do something besides goto fail in this + case; that seems worse than this. */ case on_failure_keep_string_jump: DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); @@ -3683,7 +3942,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) the original * applied to a group), save the information for that group and all inner ones, so that if we fail back to this point, the group's information will be correct. - For example, in \(a*\)*\1, we only need the preceding group, + For example, in \(a*\)*\1, we need the preceding group, and in \(\(a*\)b*\)\2, we need the inner group. */ /* We can't use `p' to check ahead because we push @@ -3713,8 +3972,8 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) break; - /* A smart repeat ends with a maybe_pop_jump. - We change it either to a pop_failure_jump or a no_pop_jump. */ + /* A smart repeat ends with `maybe_pop_jump'. + We change it to either `pop_failure_jump' or `jump'. */ case maybe_pop_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); @@ -3726,7 +3985,13 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) is nothing that they would both match, i.e., that we would have to backtrack because of (as in, e.g., `a*a') then we can change to pop_failure_jump, because we'll - never have to backtrack. */ + never have to backtrack. + + This is not true in the case of alternatives: in + `(a|ab)*' we do need to backtrack to the `ab' alternative + (e.g., if the string was `ab'). But instead of trying to + detect that here, the alternative has put on a dummy + failure point which is what we will end up popping. */ /* Skip over open/close-group commands. */ while (p2 + 2 < pend @@ -3736,7 +4001,14 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) /* If we're at the end of the pattern, we can change. */ if (p2 == pend) - p[-3] = (unsigned char) pop_failure_jump; + { + /* Consider what happens when matching ":\(.*\)" + against ":/". I don't really understand this code + yet. */ + p[-3] = (unsigned char) pop_failure_jump; + DEBUG_PRINT1 + (" End of pattern: change to `pop_failure_jump'.\n"); + } else if ((re_opcode_t) *p2 == exactn || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) @@ -3745,11 +4017,16 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) = *p2 == (unsigned char) endline ? '\n' : p2[2]; p1 = p + mcnt; - /* p1[0] ... p1[2] are the on_failure_jump corresponding - to the maybe_finalize_jump of this case. Examine what - follows it. */ + /* p1[0] ... p1[2] are the `on_failure_jump' corresponding + to the `maybe_finalize_jump' of this case. Examine what + follows. */ if ((re_opcode_t) p1[3] == exactn && p1[5] != c) - p[-3] = (unsigned char) pop_failure_jump; + { + p[-3] = (unsigned char) pop_failure_jump; + DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", + c, p1[5]); + } + else if ((re_opcode_t) p1[3] == charset || (re_opcode_t) p1[3] == charset_not) { @@ -3762,15 +4039,19 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) /* `not' is equal to 1 if c would match, which means that we can't change to pop_failure_jump. */ if (!not) - p[-3] = (unsigned char) pop_failure_jump; + { + p[-3] = (unsigned char) pop_failure_jump; + DEBUG_PRINT1 (" No match => pop_failure_jump.\n"); + } } } } p -= 2; /* Point at relative address again. */ if ((re_opcode_t) p[-1] != pop_failure_jump) { - p[-1] = (unsigned char) no_pop_jump; - goto no_pop; + p[-1] = (unsigned char) jump; + DEBUG_PRINT1 (" Match => jump.\n"); + goto unconditional_jump; } /* Note fall through. */ @@ -3784,31 +4065,27 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) case pop_failure_jump: { /* We need to pass separate storage for the lowest and - highest registers, even though we aren't interested. - Otherwise, we will restore only one register from the - stack, since lowest will equal highest in - pop_failure_point (since they'll be the same memory - location). */ - unsigned dummy_low, dummy_high; - unsigned char *pdummy = NULL; + highest registers, even though we don't care about the + actual values. Otherwise, we will restore only one + register from the stack, since lowest will == highest in + `pop_failure_point'. */ + unsigned dummy_low_reg, dummy_high_reg; + unsigned char *pdummy; + const char *sdummy; DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n"); - pop_failure_point (bufp, pend, -#ifdef DEBUG - string1, size1, string2, size2, -#endif - &failure_stack, &pdummy, &pdummy, - &dummy_low, &dummy_high, - ®_dummy, ®_dummy, ®_info_dummy); + POP_FAILURE_POINT (sdummy, pdummy, + dummy_low_reg, dummy_high_reg, + reg_dummy, reg_dummy, reg_info_dummy); } /* Note fall through. */ - /* Jump without taking off any failure points. */ - case no_pop_jump: - no_pop: + /* Unconditionally jump (without popping any failure points). */ + case jump: + unconditional_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ - DEBUG_PRINT2 ("EXECUTING no_pop_jump %d ", mcnt); + DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); p += mcnt; /* Do the jump. */ DEBUG_PRINT2 ("(to 0x%x).\n", p); break; @@ -3816,9 +4093,9 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) /* We need this opcode so we can detect where alternatives end in `group_match_null_string_p' et al. */ - case jump_past_next_alt: - DEBUG_PRINT1 ("EXECUTING jump_past_next_alt.\n"); - goto no_pop; + case jump_past_alt: + DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n"); + goto unconditional_jump; /* Normally, the on_failure_jump pushes a failure point, which @@ -3831,17 +4108,30 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) /* It doesn't matter what we push for the string here. What the code at `fail' tests is the value for the pattern. */ PUSH_FAILURE_POINT (0, 0, -2); - goto no_pop; - + goto unconditional_jump; + + + /* At the end of an alternative, we need to push a dummy failure + point in case we are followed by a `pop_failure_jump', because + we don't want the failure point for the alternative to be + popped. For example, matching `(a|ab)*' against `aab' + requires that we match the `ab' alternative. */ + case push_dummy_failure: + DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n"); + /* See comments just above at `dummy_failure_jump' about the + two zeroes. */ + PUSH_FAILURE_POINT (0, 0, -2); + break; - /* Have to succeed matching what follows at least n times. Then - just handle like an on_failure_jump. */ + /* Have to succeed matching what follows at least n times. + After that, handle like `on_failure_jump'. */ case succeed_n: EXTRACT_NUMBER (mcnt, p + 2); DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); + assert (mcnt >= 0); /* Originally, this is how many times we HAVE to succeed. */ - if (mcnt) + if (mcnt > 0) { mcnt--; p += 2; @@ -3855,25 +4145,18 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) p[3] = (unsigned char) no_op; goto on_failure; } -#ifdef DEBUG - else - { - fprintf (stderr, "regex: negative n at succeed_n.\n"); - abort (); - } -#endif /* DEBUG */ break; - case no_pop_jump_n: + case jump_n: EXTRACT_NUMBER (mcnt, p + 2); - DEBUG_PRINT2 ("EXECUTING no_pop_jump_n %d.\n", mcnt); + DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); /* Originally, this is how many times we CAN jump. */ if (mcnt) { mcnt--; - STORE_NUMBER(p + 2, mcnt); - goto no_pop; + STORE_NUMBER (p + 2, mcnt); + goto unconditional_jump; } /* If don't have to jump any more, skip over the rest of command. */ else @@ -3887,6 +4170,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) EXTRACT_NUMBER_AND_INCR (mcnt, p); p1 = p + mcnt; EXTRACT_NUMBER_AND_INCR (mcnt, p); + DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p1, mcnt); STORE_NUMBER (p1, mcnt); break; } @@ -3905,14 +4189,14 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) case wordbeg: DEBUG_PRINT1 ("EXECUTING wordbeg.\n"); - if (LETTER_P (d) && (AT_STRINGS_BEG || !LETTER_P (d - 1))) + if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1))) break; goto fail; case wordend: DEBUG_PRINT1 ("EXECUTING wordend.\n"); - if (!AT_STRINGS_BEG && LETTER_P (d - 1) - && (!LETTER_P (d) || AT_STRINGS_END)) + if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1) + && (!WORDCHAR_P (d) || AT_STRINGS_END (d))) break; goto fail; @@ -3949,11 +4233,12 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) goto matchsyntax; case wordchar: - DEBUG_PRINT1 ("EXECUTING wordchar.\n"); + DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n"); mcnt = (int) Sword; matchsyntax: - PREFETCH; - if (SYNTAX (*d++) != (enum syntaxcode) mcnt) goto fail; + PREFETCH (); + if (SYNTAX (*d++) != (enum syntaxcode) mcnt) + goto fail; SET_REGS_MATCHED (); break; @@ -3963,29 +4248,32 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) goto matchnotsyntax; case notwordchar: - DEBUG_PRINT1 ("EXECUTING notwordchar.\n"); + DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n"); mcnt = (int) Sword; - matchnotsyntax: /* We goto here from notsyntaxspec. */ - PREFETCH; - if (SYNTAX (*d++) == (enum syntaxcode) mcnt) goto fail; + matchnotsyntax: + PREFETCH (); + if (SYNTAX (*d++) == (enum syntaxcode) mcnt) + goto fail; SET_REGS_MATCHED (); break; #else /* not emacs */ case wordchar: DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); - PREFETCH; - if (!LETTER_P (d)) + PREFETCH (); + if (!WORDCHAR_P (d)) goto fail; SET_REGS_MATCHED (); + d++; break; case notwordchar: DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); - PREFETCH; - if (LETTER_P (d)) + PREFETCH (); + if (WORDCHAR_P (d)) goto fail; SET_REGS_MATCHED (); + d++; break; #endif /* not emacs */ @@ -3997,16 +4285,12 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) /* We goto here if a matching operation fails. */ fail: - if (!FAILURE_STACK_EMPTY ()) + if (!FAIL_STACK_EMPTY ()) { /* A restart point is known. Restore to that state. */ DEBUG_PRINT1 ("\nFAIL:\n"); - pop_failure_point (bufp, pend, -#ifdef DEBUG - string1, size1, string2, size2, -#endif - &failure_stack, &p, &d, &lowest_active_reg, - &highest_active_reg, ®start, ®end, - ®_info); + POP_FAILURE_POINT (d, p, + lowest_active_reg, highest_active_reg, + regstart, regend, reg_info); /* If this failure point is a dummy, try the next one. */ if (!p) @@ -4022,11 +4306,11 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) loop, need to pop this failure point and use the next one. */ switch ((re_opcode_t) *p) { - case no_pop_jump_n: + case jump_n: is_a_jump_n = true; case maybe_pop_jump: case pop_failure_jump: - case no_pop_jump: + case jump: p1 = p + 1; EXTRACT_NUMBER_AND_INCR (mcnt, p1); p1 += mcnt; @@ -4059,89 +4343,6 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) /* Subroutine definitions for re_match_2. */ -/* Pops what PUSH_FAILURE_STACK pushes. */ - -static void -pop_failure_point (bufp, pattern_end, -#ifdef DEBUG - string1, size1, string2, size2, -#endif - failure_stack_ptr, pattern_place, string_place, - lowest_active_reg, highest_active_reg, - regstart, regend, reg_info) - const struct re_pattern_buffer *bufp; /* These not modified. */ - unsigned char *pattern_end; -#ifdef DEBUG - unsigned char *string1, *string2; - int size1, size2; -#endif - failure_stack_type *failure_stack_ptr; /* These get modified. */ - const unsigned char **pattern_place; - const unsigned char **string_place; - unsigned *lowest_active_reg, *highest_active_reg; - const unsigned char ***regstart; - const unsigned char ***regend; - register_info_type **reg_info; -{ -#ifdef DEBUG - /* Type is really unsigned; it's declared this way just to avoid a - compiler warning. */ - failure_stack_elt_t failure_id; -#endif - int this_reg; - const unsigned char *string_temp; - - assert (!FAILURE_STACK_PTR_EMPTY ()); - - /* Remove failure points and point to how many regs pushed. */ - DEBUG_PRINT1 ("pop_failure_point:\n"); - DEBUG_PRINT2 (" Before pop, next avail: %d\n", failure_stack_ptr->avail); - DEBUG_PRINT2 (" size: %d\n", failure_stack_ptr->size); - - assert (failure_stack_ptr->avail >= NUM_NONREG_ITEMS); - - DEBUG_POP (&failure_id); - DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); - - /* If the saved string location is NULL, it came from an - on_failure_keep_string_jump opcode, and we want to throw away the - saved NULL, thus retaining our current position in the string. */ - string_temp = POP_FAILURE_ITEM (); - if (string_temp != NULL) - *string_place = string_temp; - - DEBUG_PRINT2 (" Popping string 0x%x: `", *string_place); - DEBUG_DOUBLE_STRING_PRINTER (*string_place, string1, size1, string2, size2); - DEBUG_PRINT1 ("'\n"); - - *pattern_place = POP_FAILURE_ITEM (); - DEBUG_PRINT2 (" Popping pattern 0x%x: ", *pattern_place); - DEBUG_COMPILED_PATTERN_PRINTER (bufp, *pattern_place, pattern_end); - - /* Restore register info. */ - *highest_active_reg = (unsigned) POP_FAILURE_ITEM (); - DEBUG_PRINT2 (" Popping high active reg: %d\n", *highest_active_reg); - - *lowest_active_reg = (unsigned) POP_FAILURE_ITEM (); - DEBUG_PRINT2 (" Popping low active reg: %d\n", *lowest_active_reg); - - for (this_reg = *highest_active_reg; this_reg >= *lowest_active_reg; - this_reg--) - { - DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); - - (*reg_info)[this_reg].word = POP_FAILURE_ITEM (); - DEBUG_PRINT2 (" info: 0x%x\n", (*reg_info)[this_reg]); - - (*regend)[this_reg] = POP_FAILURE_ITEM (); - DEBUG_PRINT2 (" end: 0x%x\n", (*regend)[this_reg]); - - (*regstart)[this_reg] = POP_FAILURE_ITEM (); - DEBUG_PRINT2 (" start: 0x%x\n", (*regstart)[this_reg]); - } -} /* pop_failure_point */ - - /* We are passed P pointing to a register number after a start_memory. Return true if the pattern up to the corresponding stop_memory can @@ -4181,12 +4382,12 @@ group_match_null_string_p (p, end, reg_info) { /* Go through the on_failure_jumps of the alternatives, seeing if any of the alternatives cannot match nothing. - The last alternative starts with only a no_pop_jump, + The last alternative starts with only a jump, whereas the rest start with on_failure_jump and end - with a no_pop_jump, e.g., here is the pattern for `a|b|c': + with a jump, e.g., here is the pattern for `a|b|c': - /on_failure_jump/0/6/exactn/1/a/jump_past_next_alt/0/6 - /on_failure_jump/0/6/exactn/1/b/jump_past_next_alt/0/3 + /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6 + /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3 /exactn/1/c So, we have to first go through the first (n-1) @@ -4195,12 +4396,12 @@ group_match_null_string_p (p, end, reg_info) /* Deal with the first (n-1) alternatives, which start with an on_failure_jump (see above) that jumps to right - past a jump_past_next_alt. */ + past a jump_past_alt. */ - while ((re_opcode_t) p1[mcnt-3] == jump_past_next_alt) + while ((re_opcode_t) p1[mcnt-3] == jump_past_alt) { /* `mcnt' holds how many bytes long the alternative - is, including the ending `jump_past_next_alt' and + is, including the ending `jump_past_alt' and its number. */ if (!alt_match_null_string_p (p1, p1 + mcnt - 3, @@ -4208,7 +4409,7 @@ group_match_null_string_p (p, end, reg_info) return false; /* Move to right after this alternative, including the - jump_past_next_alt. */ + jump_past_alt. */ p1 += mcnt; /* Break if it's the beginning of an n-th alternative @@ -4220,7 +4421,7 @@ group_match_null_string_p (p, end, reg_info) alternative that starts with an on_failure_jump. */ p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if ((re_opcode_t) p1[mcnt-3] != jump_past_next_alt) + if ((re_opcode_t) p1[mcnt-3] != jump_past_alt) { /* Get to the beginning of the n-th alternative. */ p1 -= 3; @@ -4229,8 +4430,8 @@ group_match_null_string_p (p, end, reg_info) } /* Deal with the last alternative: go back and get number - of the jump_past_next_alt just before it. `mcnt' - contains how many bytes long the alternative is. */ + of the `jump_past_alt' just before it. `mcnt' contains + the length of the alternative. */ EXTRACT_NUMBER (mcnt, p1 - 2); if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info)) @@ -4328,13 +4529,13 @@ common_op_match_null_string_p (p, end, reg_info) case start_memory: reg_no = *p1; + assert (reg_no > 0 && reg_no <= MAX_REGNUM); ret = group_match_null_string_p (&p1, end, reg_info); /* Have to set this here in case we're checking a group which contains a group and a back reference to it. */ - if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) - == MATCH_NOTHING_UNSET_VALUE) + if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE) REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret; if (!ret) @@ -4342,7 +4543,7 @@ common_op_match_null_string_p (p, end, reg_info) break; /* If this is an optimized succeed_n for zero times, make the jump. */ - case no_pop_jump: + case jump: EXTRACT_NUMBER_AND_INCR (mcnt, p1); if (mcnt >= 0) p1 += mcnt; @@ -4420,9 +4621,9 @@ re_compile_pattern (pattern, length, bufp) { reg_errcode_t ret; - /* GNU code is written to assume RE_NREGS registers will be set - (and extraneous ones will be filled with -1). */ - bufp->caller_allocated_regs = 0; + /* GNU code is written to assume at least RE_NREGS registers will be set + (and at least one extra will be -1). */ + bufp->regs_allocated = REGS_UNALLOCATED; /* And GNU code determines whether or not to get register information by passing null for the REGS argument to re_match, etc., not by @@ -4432,19 +4633,20 @@ re_compile_pattern (pattern, length, bufp) /* Match anchors at newline. */ bufp->newline_anchor = 1; - ret = regex_compile (pattern, length, obscure_syntax, bufp); + ret = regex_compile (pattern, length, re_syntax_options, bufp); return re_error_msg[(int) ret]; } /* Entry points compatible with 4.2 BSD regex library. We don't define - them if this is an Emacs compilation. */ + them if this is an Emacs or POSIX compilation. */ -#if !defined (emacs) +#if !defined (emacs) && !defined (_POSIX_SOURCE) +/* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer re_comp_buf; -const char * +char * re_comp (s) const char *s; { @@ -4469,12 +4671,16 @@ re_comp (s) return "Memory exhausted"; } + /* Since `re_exec' always passes NULL for the `regs' argument, we + don't need to initialize the pattern buffer fields which affect it. */ + /* Match anchors at newlines. */ re_comp_buf.newline_anchor = 1; - ret = regex_compile (s, strlen (s), obscure_syntax, &re_comp_buf); + ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf); - return re_error_msg[(int) ret]; + /* Yes, we're discarding `const' here. */ + return (char *) re_error_msg[(int) ret]; } @@ -4483,13 +4689,12 @@ re_exec (s) const char *s; { const int len = strlen (s); - return 0 <= re_search (&re_comp_buf, s, len, 0, len, - (struct re_registers *) 0); + return + 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); } -#endif /* not emacs */ +#endif /* not emacs and not _POSIX_SOURCE */ -/* Entry points compatible with POSIX regex library. Don't define these - for Emacs. */ +/* POSIX.2 functions. Don't define these for Emacs. */ #ifndef emacs @@ -4535,10 +4740,12 @@ regcomp (preg, pattern, cflags) { reg_errcode_t ret; unsigned syntax - = cflags & REG_EXTENDED ? RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; + = (cflags & REG_EXTENDED) ? + RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; /* regex_compile will allocate the space for the compiled pattern. */ preg->buffer = 0; + preg->allocated = 0; /* Don't bother to use a fastmap when searching. This simplifies the REG_NEWLINE case: if we used a fastmap, we'd have to put all the @@ -4556,7 +4763,7 @@ regcomp (preg, pattern, cflags) /* Map uppercase characters to corresponding lowercase ones. */ for (i = 0; i < CHAR_SET_SIZE; i++) - preg->translate[i] = isupper (i) ? tolower (i) : i; + preg->translate[i] = ISUPPER (i) ? tolower (i) : i; } else preg->translate = NULL; @@ -4619,10 +4826,10 @@ regexec (preg, string, nmatch, pmatch, eflags) private_preg.not_bol = !!(eflags & REG_NOTBOL); private_preg.not_eol = !!(eflags & REG_NOTEOL); - /* The user has told us how many registers to return information - about, via `nmatch'. We have to pass that on to the matching - routines. */ - private_preg.caller_allocated_regs = 1; + /* The user has told us exactly how many registers to return + information about, via `nmatch'. We have to pass that on to the + matching routines. */ + private_preg.regs_allocated = REGS_FIXED; if (want_reg_info) { @@ -4636,7 +4843,7 @@ regexec (preg, string, nmatch, pmatch, eflags) /* Perform the searching operation. */ ret = re_search (&private_preg, string, len, /* start: */ 0, /* range: */ len, - want_reg_info ? ®s : NULL); + want_reg_info ? ®s : (struct re_registers *) 0); /* Copy the register information to the POSIX structure. */ if (want_reg_info) @@ -4663,7 +4870,7 @@ regexec (preg, string, nmatch, pmatch, eflags) /* Returns a message corresponding to an error code, ERRCODE, returned - from either regcomp or regexec. */ + from either regcomp or regexec. We don't use PREG here. */ size_t regerror (errcode, preg, errbuf, errbuf_size) @@ -4672,9 +4879,25 @@ regerror (errcode, preg, errbuf, errbuf_size) char *errbuf; size_t errbuf_size; { - const char *msg - = re_error_msg[errcode] == NULL ? "Success" : re_error_msg[errcode]; - size_t msg_size = strlen (msg) + 1; /* Includes the null. */ + const char *msg; + size_t msg_size; + + if (errcode < 0 + || errcode >= (sizeof (re_error_msg) / sizeof (re_error_msg[0]))) + /* Only error codes returned by the rest of the code should be passed + to this routine. If we are given anything else, or if other regex + code generates an invalid error code, then the program has a bug. + Dump core so we can fix it. */ + abort (); + + msg = re_error_msg[errcode]; + + /* POSIX doesn't require that we do anything in this case, but why + not be nice. */ + if (! msg) + msg = "Success"; + + msg_size = strlen (msg) + 1; /* Includes the null. */ if (errbuf_size != 0) { @@ -4716,148 +4939,6 @@ regfree (preg) #endif /* not emacs */ -#ifdef test - -#include <stdio.h> - -/* Indexed by a character, gives the upper case equivalent of the - character. */ - -char upcase[0400] = - { 000, 001, 002, 003, 004, 005, 006, 007, - 010, 011, 012, 013, 014, 015, 016, 017, - 020, 021, 022, 023, 024, 025, 026, 027, - 030, 031, 032, 033, 034, 035, 036, 037, - 040, 041, 042, 043, 044, 045, 046, 047, - 050, 051, 052, 053, 054, 055, 056, 057, - 060, 061, 062, 063, 064, 065, 066, 067, - 070, 071, 072, 073, 074, 075, 076, 077, - 0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137, - 0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177, - 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, - 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, - 0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, - 0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, - 0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, - 0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, - 0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, - 0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, - 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, - 0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, - 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327, - 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, - 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, - 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, - 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, - 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377 - }; - - -/* Use this to run interactive tests. */ - -void -main (argc, argv) - int argc; - char **argv; -{ - char pat[500]; - struct re_pattern_buffer buf; - int i; - char c; - char fastmap[(1 << BYTEWIDTH)]; - - /* Allow a command argument to specify the style of syntax. */ - if (argc > 1) - re_set_syntax (atoi (argv[1])); - - buf.allocated = 40; - buf.buffer = (unsigned char *) malloc (buf.allocated); - buf.fastmap = fastmap; - buf.translate = upcase; - - for (;;) - { - printf ("Pattern = "); - gets (pat); - - if (*pat) - { - void printchar (); - re_compile_pattern (pat, strlen (pat), &buf); - - for (i = 0; i < buf.used; i++) - printchar (buf.buffer[i]); - - putchar ('\n'); - - printf ("%d allocated, %d used.\n", buf.allocated, buf.used); - - re_compile_fastmap (&buf); - printf ("Allowed by fastmap: "); - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (fastmap[i]) printchar (i); - putchar ('\n'); - } - - printf ("String = "); - gets (pat); /* Now read the string to match against */ - - i = re_match (&buf, pat, strlen (pat), 0, 0); - printf ("Match value %d.\n\n", i); - } -} - - -#if 0 -/* We have a fancier version now, compiled_pattern_printer. */ -print_buf (bufp) - struct re_pattern_buffer *bufp; -{ - int i; - - printf ("buf is :\n----------------\n"); - for (i = 0; i < bufp->used; i++) - printchar (bufp->buffer[i]); - - printf ("\n%d allocated, %d used.\n", bufp->allocated, bufp->used); - - printf ("Allowed by fastmap: "); - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (bufp->fastmap[i]) - printchar (i); - printf ("\nAllowed by translate: "); - if (bufp->translate) - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (bufp->translate[i]) - printchar (i); - printf ("\nfastmap is%s accurate\n", bufp->fastmap_accurate ? "" : "n't"); - printf ("can %s be null\n----------", bufp->can_be_null ? "" : "not"); -} -#endif /* 0 */ - - -void -printchar (c) - char c; -{ - if (c < 040 || c >= 0177) - { - putchar ('\\'); - putchar (((c >> 6) & 3) + '0'); - putchar (((c >> 3) & 7) + '0'); - putchar ((c & 7) + '0'); - } - else - putchar (c); -} -#endif /* test */ - /* Local variables: make-backup-files: t diff --git a/gnu/usr.bin/cvs/lib/regex.h b/gnu/usr.bin/cvs/lib/regex.h index 211ad09..408dd21 100644 --- a/gnu/usr.bin/cvs/lib/regex.h +++ b/gnu/usr.bin/cvs/lib/regex.h @@ -1,7 +1,7 @@ /* Definitions for data structures and routines for the regular - expression library, version REPLACE-WITH-VERSION. + expression library, version 0.12. - Copyright (C) 1985, 1989, 1990, 1991, 1992 Free Software Foundation, Inc. + Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,7 +20,15 @@ #ifndef __REGEXP_LIBRARY_H__ #define __REGEXP_LIBRARY_H__ -/* POSIX says that <sys/types.h> must be included before <regex.h>. */ +/* POSIX says that <sys/types.h> must be included (by the caller) before + <regex.h>. */ + +#ifdef VMS +/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it + should be there. */ +#include <stddef.h> +#endif + /* The following bits are used to determine the regexp syntax we recognize. The set/not-set meanings are chosen so that Emacs syntax @@ -45,17 +53,17 @@ typedef unsigned reg_syntax_t; #define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) /* If this bit is set, then ^ and $ are always anchors (outside bracket - expressions). + expressions, of course). If this bit is not set, then it depends: ^ is an anchor if it is at the beginning of a regular expression or after an open-group or an alternation operator; $ is an anchor if it is at the end of a regular expression, or before a close-group or an alternation operator. + This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because - POSIX now says that the behavior of * etc. in leading positions is - undefined. We have already implemented a previous draft which - made those constructs invalid, so we may as well not change the code - back. */ + POSIX draft 11.2 says that * etc. in leading positions is undefined. + We already implemented a previous draft which made those constructs + invalid, though, so we haven't changed the code back. */ #define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) /* If this bit is set, then special characters are always special @@ -67,16 +75,14 @@ typedef unsigned reg_syntax_t; #define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) /* If this bit is set, then *, +, ?, and { cannot be first in an re or - immediately after an alternation or begin-group operator. - Furthermore, alternation cannot be first or last in an re, or - immediately follow another alternation or begin-group. */ + immediately after an alternation or begin-group operator. */ #define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) -/* If this bit is set, then . matches a newline. +/* If this bit is set, then . matches newline. If not set, then it doesn't. */ #define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) -/* If this bit is set, then period doesn't match a null. +/* If this bit is set, then . doesn't match NUL. If not set, then it does. */ #define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) @@ -89,7 +95,7 @@ typedef unsigned reg_syntax_t; If not set, \{, \}, {, and } are literals. */ #define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) -/* If this bit is set, +, ? and | aren't recognized as operators. +/* If this bit is set, +, ? and | aren't recognized as operators. If not set, they are. */ #define RE_LIMITED_OPS (RE_INTERVALS << 1) @@ -97,104 +103,112 @@ typedef unsigned reg_syntax_t; If not set, newline is literal. */ #define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) -/* If this bit is set, newline in the pattern is an ordinary character. - If not set, newline before ^ or after $ allows the ^ or $ to be an - anchor. */ -#define RE_NEWLINE_ORDINARY (RE_NEWLINE_ALT << 1) - -/* If this bit is not set, then \{ and \} defines an interval, - and { and } are literals. - If set, then { and } defines an interval, and \{ and \} are literals. */ -#define RE_NO_BK_BRACES (RE_NEWLINE_ORDINARY << 1) +/* If this bit is set, then `{...}' defines an interval, and \{ and \} + are literals. + If not set, then `\{...\}' defines an interval. */ +#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) /* If this bit is set, (...) defines a group, and \( and \) are literals. If not set, \(...\) defines a group, and ( and ) are literals. */ #define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) -/* If this bit is set, then back references (i.e., \<digit>) are not - recognized. - If not set, then they are. */ +/* If this bit is set, then \<digit> matches <digit>. + If not set, then \<digit> is a back-reference. */ #define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) /* If this bit is set, then | is an alternation operator, and \| is literal. If not set, then \| is an alternation operator, and | is literal. */ #define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) -/* If this bit is set, then you can't have empty alternatives. - If not set, then you can. */ -#define RE_NO_EMPTY_ALTS (RE_NO_BK_VBAR << 1) - -/* If this bit is set, then you can't have empty groups. - If not set, then you can. */ -#define RE_NO_EMPTY_GROUPS (RE_NO_EMPTY_ALTS << 1) - -/* If this bit is set, then an ending range point has to collate higher - than or equal to the starting range point. - If not set, then when the ending range point collates higher than the - starting range point, we consider such a range to be empty. */ -#define RE_NO_EMPTY_RANGES (RE_NO_EMPTY_GROUPS << 1) +/* If this bit is set, then an ending range point collating higher + than the starting range point, as in [z-a], is invalid. + If not set, then when ending range point collates higher than the + starting range point, the range is ignored. */ +#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) -/* If this bit is set, then all back references must refer to a preceding - subexpression. - If not set, then a back reference to a nonexistent subexpression is - treated as literal characters. */ -#define RE_NO_MISSING_BK_REF (RE_NO_EMPTY_RANGES << 1) - -/* If this bit is set, then Regex considers an unmatched close-group - operator to be the ordinary character parenthesis. - If not set, then an unmatched close-group operator is invalid. */ -#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_MISSING_BK_REF << 1) +/* If this bit is set, then an unmatched ) is ordinary. + If not set, then an unmatched ) is invalid. */ +#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) /* This global variable defines the particular regexp syntax to use (for some interfaces). When a regexp is compiled, the syntax used is stored in the pattern buffer, so changing this does not affect already-compiled regexps. */ -extern reg_syntax_t obscure_syntax; - - - +extern reg_syntax_t re_syntax_options; + /* Define combinations of the above bits for the standard possibilities. - (The [[[ comments delimit what gets put into the Texinfo file.) */ + (The [[[ comments delimit what gets put into the Texinfo file, so + don't delete them!) */ /* [[[begin syntaxes]]] */ #define RE_SYNTAX_EMACS 0 -#define RE_SYNTAX_POSIX_AWK \ - (RE_CONTEXT_INDEP_ANCHORS | RE_CONTEXT_INDEP_OPS | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - #define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_SYNTAX_POSIX_AWK) + (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ + | RE_NO_BK_PARENS | RE_NO_BK_REFS \ + | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ + | RE_UNMATCHED_RIGHT_PAREN_ORD) + +#define RE_SYNTAX_POSIX_AWK \ + (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) #define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_NEWLINE_ALT) + (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ + | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ + | RE_NEWLINE_ALT) #define RE_SYNTAX_EGREP \ - (RE_CONTEXT_INDEP_ANCHORS | RE_CONTEXT_INDEP_OPS \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS | RE_NO_BK_VBAR) + (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ + | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ + | RE_NO_BK_VBAR) + +#define RE_SYNTAX_POSIX_EGREP \ + (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) + +/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ +#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC + +#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC + +/* Syntax bits common to both basic and extended POSIX regex syntax. */ +#define _RE_SYNTAX_POSIX_COMMON \ + (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ + | RE_INTERVALS | RE_NO_EMPTY_RANGES) #define RE_SYNTAX_POSIX_BASIC \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE \ - | RE_DOT_NOT_NULL | RE_INTERVALS | RE_LIMITED_OPS \ - | RE_NEWLINE_ORDINARY | RE_NO_EMPTY_RANGES | RE_NO_MISSING_BK_REF) + (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) + +/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes + RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this + isn't minimal, since other operators, such as \`, aren't disabled. */ +#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ + (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) #define RE_SYNTAX_POSIX_EXTENDED \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NEWLINE_ORDINARY | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS | RE_NO_BK_VBAR \ - | RE_NO_EMPTY_ALTS | RE_NO_EMPTY_GROUPS | RE_NO_EMPTY_RANGES \ + (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ + | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ | RE_UNMATCHED_RIGHT_PAREN_ORD) -/* [[[end syntaxes]]] */ - - +/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS + replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ +#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ + (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ + | RE_NO_BK_PARENS | RE_NO_BK_REFS \ + | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) +/* [[[end syntaxes]]] */ -/* Maximum number of duplicates an interval can allow. */ +/* Maximum number of duplicates an interval can allow. Some systems + (erroneously) define this in other header files, but we want our + value, so remove any previous define. */ +#ifdef RE_DUP_MAX #undef RE_DUP_MAX -#define RE_DUP_MAX ((1 << 15) - 1) +#endif +#define RE_DUP_MAX ((1 << 15) - 1) -/* POSIX `cflags' bits (i.e., information for regcomp). */ +/* POSIX `cflags' bits (i.e., information for `regcomp'). */ /* If this bit is set, then use extended regular expression syntax. If not set, then use basic regular expression syntax. */ @@ -254,9 +268,6 @@ typedef enum REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ } reg_errcode_t; - - - /* This data structure represents a compiled pattern. Before calling the pattern compiler, the fields `buffer', `allocated', `fastmap', @@ -295,19 +306,28 @@ struct re_pattern_buffer /* Number of subexpressions found by the compiler. */ size_t re_nsub; - /* Set to 1 by re_compile_fastmap if this pattern can match the - null string; 0 prevents the searcher from matching it with - the null string. Set to 2 if it might match the null string - either at the end of a search range or just before a - character listed in the fastmap. */ - unsigned can_be_null : 2; - - /* Set to zero when regex_compile compiles a pattern; set to one - by re_compile_fastmap when it updates the fastmap, if any. */ + /* Zero if this pattern cannot match the empty string, one else. + Well, in truth it's used only in `re_search_2', to see + whether or not we should use the fastmap, so we don't set + this absolutely perfectly; see `re_compile_fastmap' (the + `duplicate' case). */ + unsigned can_be_null : 1; + + /* If REGS_UNALLOCATED, allocate space in the `regs' structure + for `max (RE_NREGS, re_nsub + 1)' groups. + If REGS_REALLOCATE, reallocate space if necessary. + If REGS_FIXED, use what's there. */ +#define REGS_UNALLOCATED 0 +#define REGS_REALLOCATE 1 +#define REGS_FIXED 2 + unsigned regs_allocated : 2; + + /* Set to zero when `regex_compile' compiles a pattern; set to one + by `re_compile_fastmap' if it updates the fastmap. */ unsigned fastmap_accurate : 1; - /* If set, regexec reports only success or failure and does not - return anything in pmatch. */ + /* If set, `re_match_2' does not return information about + subexpressions. */ unsigned no_sub : 1; /* If set, a beginning-of-line anchor doesn't match at the @@ -320,10 +340,6 @@ struct re_pattern_buffer /* If true, an anchor at a newline matches. */ unsigned newline_anchor : 1; - /* If set, re_match_2 assumes a non-null REGS argument is - initialized. If not set, REGS is initialized to the max of - RE_NREGS and re_nsub + 1 registers. */ - unsigned caller_allocated_regs : 1; /* [[[end pattern_buffer]]] */ }; @@ -333,12 +349,8 @@ typedef struct re_pattern_buffer regex_t; /* search.c (search_buffer) in Emacs needs this one opcode value. It is defined both in `regex.c' and here. */ #define RE_EXACTN_VALUE 1 - - - -/* Type for byte offsets within the string. POSIX mandates us defining - this. */ +/* Type for byte offsets within the string. POSIX mandates this. */ typedef int regoff_t; @@ -352,8 +364,9 @@ struct re_registers }; -/* If `caller_allocated_regs' is zero in the pattern buffer, re_match_2 - returns information about this many registers. */ +/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, + `re_match_2' returns information about at least this many registers + the first time a `regs' structure is passed. */ #ifndef RE_NREGS #define RE_NREGS 30 #endif @@ -367,29 +380,41 @@ typedef struct regoff_t rm_so; /* Byte offset from string's start to substring's start. */ regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ } regmatch_t; - - - /* Declarations for routines. */ +/* To avoid duplicating every routine declaration -- once with a + prototype (if we are ANSI), and once without (if we aren't) -- we + use the following macro to declare argument types. This + unfortunately clutters up the declarations a bit, but I think it's + worth it. */ + #if __STDC__ -/* Sets the current syntax to SYNTAX. You can also simply assign to the - `obscure_syntax' variable. */ -extern reg_syntax_t re_set_syntax (reg_syntax_t syntax); +#define _RE_ARGS(args) args + +#else /* not __STDC__ */ + +#define _RE_ARGS(args) () + +#endif /* not __STDC__ */ + +/* Sets the current default syntax to SYNTAX, and return the old syntax. + You can also simply assign to the `re_syntax_options' variable. */ +extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); /* Compile the regular expression PATTERN, with length LENGTH - and syntax given by the global `obscure_syntax', into the buffer + and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern (const char *pattern, int length, - struct re_pattern_buffer *buffer); +extern const char *re_compile_pattern + _RE_ARGS ((const char *pattern, int length, + struct re_pattern_buffer *buffer)); /* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ -extern int re_compile_fastmap (struct re_pattern_buffer *buffer); +extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); /* Search in the string STRING (with length LENGTH) for the pattern @@ -397,78 +422,64 @@ extern int re_compile_fastmap (struct re_pattern_buffer *buffer); characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern int re_search (struct re_pattern_buffer *buffer, - const char *string, int length, - int start, int range, - struct re_registers *regs); +extern int re_search + _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, + int length, int start, int range, struct re_registers *regs)); /* Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ -extern int re_search_2 (struct re_pattern_buffer *buffer, - const char *string1, int length1, - const char *string2, int length2, - int start, int range, - struct re_registers *regs, - int stop); +extern int re_search_2 + _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, + int length1, const char *string2, int length2, + int start, int range, struct re_registers *regs, int stop)); /* Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ -extern int re_match (const struct re_pattern_buffer *buffer, - const char *string, int length, - int start, struct re_registers *regs); +extern int re_match + _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, + int length, int start, struct re_registers *regs)); /* Relates to `re_match' as `re_search_2' relates to `re_search'. */ -extern int re_match_2 (const struct re_pattern_buffer *buffer, - const char *string1, int length1, - const char *string2, int length2, - int start, - struct re_registers *regs, - int stop); +extern int re_match_2 + _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, + int length1, const char *string2, int length2, + int start, struct re_registers *regs, int stop)); -#ifndef __386BSD__ -/* 4.2 bsd compatibility. */ -#ifndef bsdi -extern const char *re_comp (const char *); -#endif -extern int re_exec (const char *); -#endif +/* Set REGS to hold NUM_REGS registers, storing them in STARTS and + ENDS. Subsequent matches using BUFFER and REGS will use this memory + for recording register information. STARTS and ENDS must be + allocated with malloc, and must each be at least `NUM_REGS * sizeof + (regoff_t)' bytes long. -/* POSIX compatibility. */ -extern int regcomp (regex_t *preg, const char *pattern, int cflags); -extern int regexec (const regex_t *preg, const char *string, size_t nmatch, - regmatch_t pmatch[], int eflags); -extern size_t regerror (int errcode, const regex_t *preg, char *errbuf, - size_t errbuf_size); -extern void regfree (regex_t *preg); + If NUM_REGS == 0, then subsequent matches should allocate their own + register data. -#else /* not __STDC__ */ + Unless this function is called, the first search or match using + PATTERN_BUFFER will allocate its own register data, without + freeing the old data. */ +extern void re_set_registers + _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, + unsigned num_regs, regoff_t *starts, regoff_t *ends)); -/* Support old C compilers. */ -#define const - -extern reg_syntax_t re_set_syntax (); -extern char *re_compile_pattern (); -extern int re_search (), re_search_2 (); -extern int re_match (), re_match_2 (); - -/* 4.2 BSD compatibility. */ -extern char *re_comp (); -extern int re_exec (); +/* 4.2 bsd compatibility. */ +extern char *re_comp _RE_ARGS ((const char *)); +extern int re_exec _RE_ARGS ((const char *)); /* POSIX compatibility. */ -extern int regcomp (); -extern int regexec (); -extern size_t regerror (); -extern void regfree (); +extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags)); +extern int regexec + _RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch, + regmatch_t pmatch[], int eflags)); +extern size_t regerror + _RE_ARGS ((int errcode, const regex_t *preg, char *errbuf, + size_t errbuf_size)); +extern void regfree _RE_ARGS ((regex_t *preg)); -#endif /* not __STDC__ */ #endif /* not __REGEXP_LIBRARY_H__ */ - - /* Local variables: diff --git a/gnu/usr.bin/cvs/lib/rename.c b/gnu/usr.bin/cvs/lib/rename.c index 3e0b481..6c43cf6 100644 --- a/gnu/usr.bin/cvs/lib/rename.c +++ b/gnu/usr.bin/cvs/lib/rename.c @@ -15,6 +15,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> #include <sys/stat.h> #include <errno.h> diff --git a/gnu/usr.bin/cvs/lib/sighandle.c b/gnu/usr.bin/cvs/lib/sighandle.c index 1b73b93..1db4177 100644 --- a/gnu/usr.bin/cvs/lib/sighandle.c +++ b/gnu/usr.bin/cvs/lib/sighandle.c @@ -30,10 +30,14 @@ * must not themselves make calls to the signal handling * facilities. * - * @(#)sighandle.c 1.9 92/03/31 + * $CVSid: @(#)sighandle.c 1.13 94/10/07 $ * *************************************************************************/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/types.h> #include <stdio.h> #include <signal.h> @@ -54,18 +58,14 @@ char *malloc(); #undef POSIX /* Minix 1.6 doesn't support POSIX.1 sigaction yet */ #endif -#ifndef SIGTYPE -#define SIGTYPE void -#endif - /* Define the highest signal number (usually) */ #ifndef SIGMAX -#define SIGMAX 32 +#define SIGMAX 64 #endif /* Define linked list of signal handlers structure */ struct SIG_hlist { - SIGTYPE (*handler)(); + RETSIGTYPE (*handler)(); struct SIG_hlist *next; }; @@ -84,7 +84,7 @@ static struct sigaction *SIG_defaults; #ifdef BSD_SIGNALS static struct sigvec *SIG_defaults; #else -static SIGTYPE (**SIG_defaults)(); +static RETSIGTYPE (**SIG_defaults)(); #endif #endif @@ -112,11 +112,7 @@ static int SIG_init() #ifdef POSIX (void) sigfillset(&sigset_test); - for (i = 1; sigismember(&sigset_test, i) == 1; i++) -#ifdef BROKEN_SIGISMEMBER - if ( i >= NSIG ) - break -#endif + for (i = 1; i < SIGMAX && sigismember(&sigset_test, i) == 1; i++) ; if (i < SIGMAX) i = SIGMAX; @@ -133,8 +129,8 @@ static int SIG_init() calloc(i, sizeof(struct sigvec)); #else if (!SIG_defaults) - SIG_defaults = (SIGTYPE (**)()) - calloc(i, sizeof(SIGTYPE (**)())); + SIG_defaults = (RETSIGTYPE (**)()) + calloc(i, sizeof(RETSIGTYPE (**)())); #endif SIG_crSectMask = 0; #endif @@ -149,7 +145,7 @@ static int SIG_init() * they were registered. */ -static SIGTYPE SIG_handle(sig) +static RETSIGTYPE SIG_handle(sig) int sig; { struct SIG_hlist *this; @@ -175,7 +171,7 @@ int sig; int SIG_register(sig,fn) int sig; -SIGTYPE (*fn)(); +RETSIGTYPE (*fn)(); { int val; struct SIG_hlist *this; @@ -236,7 +232,7 @@ SIGTYPE (*fn)(); val = sigvec(sig, &vec, &SIG_defaults[sig]); #else if ((SIG_defaults[sig] = signal(sig, SIG_handle)) == - (SIGTYPE (*)()) -1) + (RETSIGTYPE (*)()) -1) val = -1; #endif #endif @@ -279,7 +275,7 @@ SIGTYPE (*fn)(); int SIG_deregister(sig,fn) int sig; -SIGTYPE (*fn)(); +RETSIGTYPE (*fn)(); { int val; struct SIG_hlist *this; @@ -341,7 +337,7 @@ SIGTYPE (*fn)(); #ifdef BSD_SIGNALS val = sigvec(sig, &SIG_defaults[sig], (struct sigvec *) NULL); #else - if (signal(sig, SIG_defaults[sig]) == (SIGTYPE (*)()) -1) + if (signal(sig, SIG_defaults[sig]) == (RETSIGTYPE (*)()) -1) val = -1; #endif #endif diff --git a/gnu/usr.bin/cvs/lib/strdup.c b/gnu/usr.bin/cvs/lib/strdup.c index 4e5af07..46fc8a0 100644 --- a/gnu/usr.bin/cvs/lib/strdup.c +++ b/gnu/usr.bin/cvs/lib/strdup.c @@ -15,6 +15,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifdef STDC_HEADERS #include <string.h> #include <stdlib.h> diff --git a/gnu/usr.bin/cvs/lib/strippath.c b/gnu/usr.bin/cvs/lib/strippath.c index 3d606a8..39687f9 100644 --- a/gnu/usr.bin/cvs/lib/strippath.c +++ b/gnu/usr.bin/cvs/lib/strippath.c @@ -15,14 +15,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if defined(STDC_HEADERS) || defined(USG) -#include <string.h> -#ifndef index -#define index strchr +#ifdef HAVE_CONFIG_H +#include "config.h" #endif -#else + +#if STDC_HEADERS || HAVE_STRING_H +#include <string.h> +/* An ANSI string.h and pre-ANSI memory.h might conflict. */ +#if !STDC_HEADERS && HAVE_MEMORY_H +#include <memory.h> +#endif /* not STDC_HEADERS and HAVE_MEMORY_H */ +#else /* not STDC_HJEADERS and not HAVE_STRING_H */ #include <strings.h> -#endif +/* memory.h and strings.h conflict on some systems. */ +#endif /* not STDC_HEADERS and not HAVE_STRING_H */ #include <stdio.h> @@ -43,7 +49,7 @@ strip_path (path) int stripped = 0; char *cp, *slash; - for (cp = path; (slash = index(cp, '/')) != NULL; cp = slash) + for (cp = path; (slash = strchr(cp, '/')) != NULL; cp = slash) { *slash = '\0'; if ((!*cp && (cp != path || stripped)) || diff --git a/gnu/usr.bin/cvs/lib/stripslash.c b/gnu/usr.bin/cvs/lib/stripslash.c index 0c26ac6..265950e 100644 --- a/gnu/usr.bin/cvs/lib/stripslash.c +++ b/gnu/usr.bin/cvs/lib/stripslash.c @@ -15,11 +15,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if defined(STDC_HEADERS) || defined(USG) +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#if STDC_HEADERS || HAVE_STRING_H #include <string.h> -#else +/* An ANSI string.h and pre-ANSI memory.h might conflict. */ +#if !STDC_HEADERS && HAVE_MEMORY_H +#include <memory.h> +#endif /* not STDC_HEADERS and HAVE_MEMORY_H */ +#else /* not STDC_HJEADERS and not HAVE_STRING_H */ #include <strings.h> -#endif +/* memory.h and strings.h conflict on some systems. */ +#endif /* not STDC_HEADERS and not HAVE_STRING_H */ /* Remove trailing slashes from PATH. */ diff --git a/gnu/usr.bin/cvs/lib/subr.c b/gnu/usr.bin/cvs/lib/subr.c index 2b728c2..d3d40b1 100644 --- a/gnu/usr.bin/cvs/lib/subr.c +++ b/gnu/usr.bin/cvs/lib/subr.c @@ -3,19 +3,24 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * Various useful functions for the CVS support code. */ #include "cvs.h" +#ifndef lint +static char rcsid[] = "$CVSid: @(#)subr.c 1.64 94/10/07 $"; +USE(rcsid) +#endif + #ifdef _MINIX #undef POSIX /* Minix 1.6 doesn't support POSIX.1 sigaction yet */ #endif -#ifndef VPRINTF_MISSING -#if __STDC__ +#ifdef HAVE_VPRINTF +#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) #include <stdarg.h> #define VA_START(args, lastarg) va_start(args, lastarg) #else @@ -27,17 +32,24 @@ #define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8; #endif -#ifndef lint -static char rcsid[] = "@(#)subr.c 1.52 92/03/31"; +/* + * I don't know of a convenient way to test this at configure time, or else + * I'd certainly do it there. + */ +#if defined(NeXT) +#define LOSING_TMPNAM_FUNCTION +#ifndef _POSIX_SOURCE +/* + * NeXT doesn't define these without _POSIX_SOURCE, + * but that changes a lot of things. + */ +#define WEXITSTATUS(x) ((x).w_retcode) +#define WTERMSIG(x) ((x).w_termsig) +#endif #endif -#if __STDC__ -static void run_add_arg (char *s); -static void run_init_prog (void); -#else -static void run_add_arg (); -static void run_init_prog (); -#endif /* __STDC__ */ +static void run_add_arg PROTO((char *s)); +static void run_init_prog PROTO((void)); extern char *getlogin (); extern char *strtok (); @@ -74,7 +86,7 @@ copy_file (from, to) if (read (fdin, buf, (int) sb.st_size) != (int) sb.st_size) error (1, errno, "cannot read file %s for copying", from); if (write (fdout, buf, (int) sb.st_size) != (int) sb.st_size -#ifndef FSYNC_MISSING +#ifdef HAVE_FSYNC || fsync (fdout) == -1 #endif ) @@ -88,11 +100,15 @@ copy_file (from, to) error (1, errno, "cannot close %s", to); /* now, set the times for the copied file to match those of the original */ + memset ((char *) &t, 0, sizeof (t)); t.actime = sb.st_atime; t.modtime = sb.st_mtime; (void) utime (to, &t); } +/* FIXME-krp: these functions would benefit from caching the char * & + stat buf. */ + /* * Returns non-zero if the argument file is a directory, or is a symbolic * link which points to a directory. @@ -202,25 +218,8 @@ make_directory (name) { struct stat buf; - if (stat (name, &buf) == 0) - { - if (S_ISDIR (buf.st_mode)) - { - if (access (name, (R_OK | W_OK | X_OK)) == 0) - { - error (0, 0, "Directory %s already exists", name); - return; - } - else - { - error (0, 0, - "Directory %s already exists but is protected from you", - name); - } - } - else + if (stat (name, &buf) == 0 && (!S_ISDIR (buf.st_mode))) error (0, 0, "%s already exists but is not a directory", name); - } if (!noexec && mkdir (name, 0777) < 0) error (1, errno, "cannot make directory %s", name); } @@ -245,7 +244,7 @@ make_directories (name) error (0, errno, "cannot make path to %s", name); return; } - if ((cp = rindex (name, '/')) == NULL) + if ((cp = strrchr (name, '/')) == NULL) return; *cp = '\0'; make_directories (name); @@ -260,14 +259,12 @@ make_directories (name) */ char * xmalloc (bytes) - int bytes; + size_t bytes; { char *cp; - if (bytes <= 0) - error (1, 0, "bad malloc size %d", bytes); - if ((cp = malloc ((unsigned) bytes)) == NULL) - error (1, 0, "malloc failed"); + if ((cp = malloc (bytes)) == NULL) + error (1, 0, "can not allocate %lu bytes", (unsigned long) bytes); return (cp); } @@ -279,17 +276,17 @@ xmalloc (bytes) char * xrealloc (ptr, bytes) char *ptr; - int bytes; + size_t bytes; { char *cp; if (!ptr) - return (xmalloc (bytes)); + cp = malloc (bytes); + else + cp = realloc (ptr, bytes); - if (bytes <= 0) - error (1, 0, "bad realloc size %d", bytes); - if ((cp = realloc (ptr, (unsigned) bytes)) == NULL) - error (1, 0, "realloc failed"); + if (cp == NULL) + error (1, 0, "can not reallocate %lu bytes", (unsigned long) bytes); return (cp); } @@ -320,7 +317,7 @@ xchmod (fname, writable) int writable; { struct stat sb; - int mode, oumask; + mode_t mode, oumask; if (stat (fname, &sb) < 0) { @@ -399,9 +396,12 @@ unlink_file (f) * Compare "file1" to "file2". Return non-zero if they don't compare exactly. * * mallocs a buffer large enough to hold the entire file and does two reads to - * load the buffer and calls bcmp to do the cmp. This is reasonable, since + * load the buffer and calls memcmp to do the cmp. This is reasonable, since * source files are typically not too large. */ + +/* richfix: this *could* exploit mmap. */ + int xcmp (file1, file2) char *file1; @@ -430,10 +430,10 @@ xcmp (file1, file2) buf1 = xmalloc ((int) size); buf2 = xmalloc ((int) size); if (read (fd1, buf1, (int) size) != (int) size) - error (1, errno, "cannot read file %s cor comparing", file1); + error (1, errno, "cannot read file %s for comparing", file1); if (read (fd2, buf2, (int) size) != (int) size) error (1, errno, "cannot read file %s for comparing", file2); - ret = bcmp (buf1, buf2, (int) size); + ret = memcmp(buf1, buf2, (int) size); free (buf1); free (buf2); } @@ -512,10 +512,10 @@ getcaller () static char uidname[20]; struct passwd *pw; char *name; - int uid; + uid_t uid; uid = getuid (); - if (uid == 0) + if (uid == (uid_t) 0) { /* super-user; try getlogin() to distinguish */ if (((name = getenv("LOGNAME")) || (name = getenv("USER")) || @@ -524,7 +524,7 @@ getcaller () } if ((pw = (struct passwd *) getpwuid (uid)) == NULL) { - (void) sprintf (uidname, "uid%d", uid); + (void) sprintf (uidname, "uid%d", (unsigned long) uid); return (uidname); } return (pw->pw_name); @@ -549,7 +549,7 @@ static int run_argc; static int run_argc_allocated; /* VARARGS */ -#if !defined (VPRINTF_MISSING) && __STDC__ +#if defined (HAVE_VPRINTF) && (defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)) void run_setup (char *fmt,...) #else @@ -560,7 +560,7 @@ run_setup (fmt, va_alist) #endif { -#ifndef VPRINTF_MISSING +#ifdef HAVE_VPRINTF va_list args; #endif @@ -581,7 +581,7 @@ run_setup (fmt, va_alist) run_argc = 0; /* process the varargs into run_prog */ -#ifndef VPRINTF_MISSING +#ifdef HAVE_VPRINTF VA_START (args, fmt); (void) vsprintf (run_prog, fmt, args); va_end (args); @@ -602,7 +602,7 @@ run_arg (s) } /* VARARGS */ -#if !defined (VPRINTF_MISSING) && __STDC__ +#if defined (HAVE_VPRINTF) && (defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)) void run_args (char *fmt,...) #else @@ -613,7 +613,7 @@ run_args (fmt, va_alist) #endif { -#ifndef VPRINTF_MISSING +#ifdef HAVE_VPRINTF va_list args; #endif @@ -621,7 +621,7 @@ run_args (fmt, va_alist) run_init_prog (); /* process the varargs into run_prog */ -#ifndef VPRINTF_MISSING +#ifdef HAVE_VPRINTF VA_START (args, fmt); (void) vsprintf (run_prog, fmt, args); va_end (args); @@ -668,7 +668,12 @@ run_exec (stin, stout, sterr, flags) { int shin, shout, sherr; int mode_out, mode_err; - int status = -1; +#if defined(NeXT) && !defined(_POSIX_SOURCE) + union wait status; +#else + int status; +#endif + int rc = -1; int rerrno = 0; int pid, w; @@ -682,7 +687,7 @@ run_exec (stin, stout, sterr, flags) struct sigvec vec, ivec, qvec; #else - SIGTYPE (*istat) (), (*qstat) (); + RETSIGTYPE (*istat) (), (*qstat) (); #endif #endif @@ -733,11 +738,15 @@ run_exec (stin, stout, sterr, flags) } } + /* Make sure we don't flush this twice, once in the subprocess. */ + fflush (stdout); + fflush (stderr); + /* The output files, if any, are now created. Do the fork and dups */ -#ifdef VFORK_MISSING - pid = fork (); -#else +#ifdef HAVE_VFORK pid = vfork (); +#else + pid = fork (); #endif if (pid == 0) { @@ -761,6 +770,7 @@ run_exec (stin, stout, sterr, flags) /* dup'ing is done. try to run it now */ (void) execvp (run_argv[0], run_argv); + error (0, errno, "cannot exec %s", run_argv[0]); _exit (127); } else if (pid == -1) @@ -790,7 +800,7 @@ run_exec (stin, stout, sterr, flags) #ifdef BSD_SIGNALS if (flags & RUN_SIGIGNORE) { - bzero ((char *) &vec, sizeof (vec)); + memset ((char *) &vec, 0, sizeof (vec)); vec.sv_handler = SIG_IGN; (void) sigvec (SIGINT, &vec, &ivec); (void) sigvec (SIGQUIT, &vec, &qvec); @@ -816,19 +826,19 @@ run_exec (stin, stout, sterr, flags) #endif if (w == -1) { - status = -1; + rc = -1; rerrno = errno; } else if (WIFEXITED (status)) - status = WEXITSTATUS (status); + rc = WEXITSTATUS (status); else if (WIFSIGNALED (status)) { if (WTERMSIG (status) == SIGPIPE) error (1, 0, "broken pipe"); - status = 2; + rc = 2; } else - status = 1; + rc = 1; /* restore the signals */ #ifdef POSIX @@ -868,7 +878,7 @@ run_exec (stin, stout, sterr, flags) out0: if (rerrno) errno = rerrno; - return (status); + return (rc); } void @@ -910,3 +920,130 @@ get_date (date, now) } #endif #endif + +/* Given two revisions, find their greatest common ancestor. If the + two input revisions exist, then rcs guarantees that the gca will + exist. */ + +char * +gca (rev1, rev2) + char *rev1; + char *rev2; +{ + int dots; + char gca[PATH_MAX]; + char *p[2]; + int j[2]; + + if (rev1 == NULL || rev2 == NULL) + { + error (0, 0, "sanity failure in gca"); + abort(); + } + + /* walk the strings, reading the common parts. */ + gca[0] = '\0'; + p[0] = rev1; + p[1] = rev2; + do + { + int i; + char c[2]; + char *s[2]; + + for (i = 0; i < 2; ++i) + { + /* swap out the dot */ + s[i] = strchr (p[i], '.'); + if (s[i] != NULL) { + c[i] = *s[i]; + } + + /* read an int */ + j[i] = atoi (p[i]); + + /* swap back the dot... */ + if (s[i] != NULL) { + *s[i] = c[i]; + p[i] = s[i] + 1; + } + else + { + /* or mark us at the end */ + p[i] = NULL; + } + + } + + /* use the lowest. */ + (void) sprintf (gca + strlen (gca), "%d.", + j[0] < j[1] ? j[0] : j[1]); + + } while (j[0] == j[1] + && p[0] != NULL + && p[1] != NULL); + + /* back up over that last dot. */ + gca[strlen(gca) - 1] = '\0'; + + /* numbers differ, or we ran out of strings. we're done with the + common parts. */ + + dots = numdots (gca); + if (dots == 0) + { + /* revisions differ in trunk major number. */ + + char *q; + char *s; + + s = (j[0] < j[1]) ? p[0] : p[1]; + + if (s == NULL) + { + /* we only got one number. this is strange. */ + error (0, 0, "bad revisions %s or %s", rev1, rev2); + abort(); + } + else + { + /* we have a minor number. use it. */ + q = gca + strlen (gca); + + *q++ = '.'; + for ( ; *s != '.' && *s != '\0'; ) + *q++ = *s++; + + *q = '\0'; + } + } + else if ((dots & 1) == 0) + { + /* if we have an even number of dots, then we have a branch. + remove the last number in order to make it a revision. */ + + char *s; + + s = strrchr(gca, '.'); + *s = '\0'; + } + + return (xstrdup (gca)); +} + +#ifdef LOSING_TMPNAM_FUNCTION +char *tmpnam(char *s) +{ + static char value[L_tmpnam+1]; + + if (s){ + strcpy(s,"/tmp/cvsXXXXXX"); + mktemp(s); + return s; + }else{ + strcpy(value,"/tmp/cvsXXXXXX"); + mktemp(s); + return value; + } +} +#endif diff --git a/gnu/usr.bin/cvs/lib/system.h b/gnu/usr.bin/cvs/lib/system.h index 6cfd68f..1f35065 100644 --- a/gnu/usr.bin/cvs/lib/system.h +++ b/gnu/usr.bin/cvs/lib/system.h @@ -15,7 +15,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* @(#)system.h 1.14 92/04/10 */ +/* $CVSid: @(#)system.h 1.18 94/09/25 $ */ #include <sys/types.h> #include <sys/stat.h> @@ -52,16 +52,13 @@ #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */ #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) #endif -#if defined(MKFIFO_MISSING) +#if !defined(HAVE_MKFIFO) #define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0)) #endif -#ifdef POSIX +#if defined(POSIX) || defined(HAVE_UNISTD_H) #include <unistd.h> #include <limits.h> -#ifndef PATH_MAX -#define PATH_MAX pathconf ("/", _PC_PATH_MAX) -#endif #else off_t lseek (); #endif @@ -72,7 +69,7 @@ off_t lseek (); #include <time.h> #endif -#ifdef TIMEB_H_MISSING +#ifndef HAVE_SYS_TIMEB_H struct timeb { time_t time; /* Seconds since the epoch */ unsigned short millitm; /* Field not used */ @@ -87,29 +84,66 @@ struct timeb { #include <sys/timeb.h> #endif -#if defined(FTIME_MISSING) && !defined(HAVE_TIMEZONE) +#if !defined(HAVE_FTIME) && !defined(HAVE_TIMEZONE) #if !defined(timezone) -extern char *timezone(); +extern long timezone; #endif #endif -#ifndef POSIX + +/* +** MAXPATHLEN and PATH_MAX +** +** On most systems MAXPATHLEN is defined in sys/param.h to be 1024. Of +** those that this is not true, again most define PATH_MAX in limits.h +** or sys/limits.h which usually gets included by limits.h. On the few +** remaining systems that neither statement is true, _POSIX_PATH_MAX +** is defined. +** +** So: +** 1. If PATH_MAX is defined just use it. +** 2. If MAXPATHLEN is defined but not PATH_MAX, then define +** PATH_MAX in terms of MAXPATHLEN. +** 3. If neither is defined, include limits.h and check for +** PATH_MAX again. +** 4. If PATH_MAX is still not defined but _POSIX_PATH_MAX is, +** then define PATH_MAX in terms of _POSIX_PATH_MAX. +** 5. And if even _POSIX_PATH_MAX doesn't exist just put in +** a reasonable value. +** +** This works on: +** Sun Sparc 10 SunOS 4.1.3 & Solaris 1.2 +** HP 9000/700 HP/UX 8.07 & HP/UX 9.01 +** Tektronix XD88/10 UTekV 3.2e +** IBM RS6000 AIX 3.2 +** Dec Alpha OSF 1 ???? +** Intel 386 BSDI BSD/386 +** Apollo Domain 10.4 +** NEC SVR4 +*/ + +/* On MOST systems this will get you MAXPATHLEN */ #include <sys/param.h> -#endif -#ifndef _POSIX_PATH_MAX -#define _POSIX_PATH_MAX 255 -#endif +#ifndef PATH_MAX +# ifdef MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# else +# include <limits.h> +# ifndef PATH_MAX +# ifdef _POSIX_PATH_MAX +# define PATH_MAX _POSIX_PATH_MAX +# else +# define PATH_MAX 1024 +# endif /* _POSIX_PATH_MAX */ +# endif /* PATH_MAX */ +# endif /* MAXPATHLEN */ +#endif /* PATH_MAX */ + -#ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX _POSIX_PATH_MAX -#endif -#endif -#ifdef POSIX + +#ifdef HAVE_UTIME_H #include <utime.h> #else #ifndef ALTOS @@ -122,29 +156,33 @@ struct utimbuf int utime (); #endif -#if defined(USG) || defined(STDC_HEADERS) +#if STDC_HEADERS || HAVE_STRING_H #include <string.h> -#ifndef STDC_HEADERS +/* An ANSI string.h and pre-ANSI memory.h might conflict. */ +#if !STDC_HEADERS && HAVE_MEMORY_H #include <memory.h> -#endif +#endif /* not STDC_HEADERS and HAVE_MEMORY_H */ + #ifndef index #define index strchr -#endif +#endif /* index */ + #ifndef rindex #define rindex strrchr -#endif -#ifndef bcopy -#define bcopy(from, to, len) memcpy ((to), (from), (len)) -#endif -#ifndef bzero -#define bzero(s, n) (void) memset ((s), 0, (n)) -#endif +#endif /* rindex */ + #ifndef bcmp -#define bcmp(s1, s2, n) memcmp((s1), (s2), (n)) -#endif -#else +#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) +#endif /* bcmp */ + +#ifndef bzero +#define bzero(s, n) memset ((s), 0, (n)) +#endif /* bzero */ + +#else /* not STDC_HJEADERS and not HAVE_STRING_H */ #include <strings.h> -#endif +/* memory.h and strings.h conflict on some systems. */ +#endif /* not STDC_HEADERS and not HAVE_STRING_H */ #include <errno.h> #ifdef STDC_HEADERS @@ -157,27 +195,16 @@ char *calloc (); extern int errno; #endif -#ifdef __GNUC__ -#ifdef bsdi -#define alloca __builtin_alloca -#endif -#else -#ifdef sparc -#include <alloca.h> +#if defined(USG) || defined(POSIX) +char *getcwd (); #else -#ifndef _AIX -/* AIX alloca decl has to be the first thing in the file, bletch! */ -char *alloca (); -#endif -#endif +char *getwd (); #endif -#if defined(USG) || defined(POSIX) +#ifdef HAVE_FCNTL_H #include <fcntl.h> -char *getcwd (); #else #include <sys/file.h> -char *getwd (); #endif #ifndef SEEK_SET @@ -185,6 +212,7 @@ char *getwd (); #define SEEK_CUR 1 #define SEEK_END 2 #endif + #ifndef F_OK #define F_OK 0 #define X_OK 1 @@ -192,23 +220,23 @@ char *getwd (); #define R_OK 4 #endif -#ifdef DIRENT +/* unistd.h defines _POSIX_VERSION on POSIX.1 systems. */ +#if defined(DIRENT) || defined(_POSIX_VERSION) #include <dirent.h> -#ifdef direct -#undef direct -#endif -#define direct dirent -#else -#ifdef SYSNDIR +#define NLENGTH(dirent) (strlen((dirent)->d_name)) +#else /* not (DIRENT or _POSIX_VERSION) */ +#define dirent direct +#define NLENGTH(dirent) ((dirent)->d_namlen) +#ifdef HAVE_SYS_NDIR_H #include <sys/ndir.h> -#else -#ifdef NDIR -#include <ndir.h> -#else /* must be BSD */ -#include <sys/dir.h> -#endif -#endif #endif +#ifdef HAVE_SYS_DIR_H +#include <sys/dir.h> +#endif +#ifdef HAVE_NDIR_H +#include <ndir.h> +#endif +#endif /* not (DIRENT or _POSIX_VERSION) */ /* Convert B 512-byte blocks to kilobytes if K is nonzero, otherwise return it unchanged. */ @@ -218,6 +246,17 @@ char *getwd (); #define lstat stat #endif -#ifndef SIGTYPE -#define SIGTYPE void +/* + * Some UNIX distributions don't include these in their stat.h Defined here + * because "config.h" is always included last. + */ +#ifndef S_IWRITE +#define S_IWRITE 0000200 /* write permission, owner */ #endif +#ifndef S_IWGRP +#define S_IWGRP 0000020 /* write permission, grougroup */ +#endif +#ifndef S_IWOTH +#define S_IWOTH 0000002 /* write permission, other */ +#endif + diff --git a/gnu/usr.bin/cvs/lib/wait.h b/gnu/usr.bin/cvs/lib/wait.h index 49cfb6d..2e47773 100644 --- a/gnu/usr.bin/cvs/lib/wait.h +++ b/gnu/usr.bin/cvs/lib/wait.h @@ -15,7 +15,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifdef POSIX +#ifdef HAVE_SYS_WAIT_H #include <sys/types.h> /* For pid_t. */ #include <sys/wait.h> #else diff --git a/gnu/usr.bin/cvs/lib/yesno.c b/gnu/usr.bin/cvs/lib/yesno.c index a705da7..7014803 100644 --- a/gnu/usr.bin/cvs/lib/yesno.c +++ b/gnu/usr.bin/cvs/lib/yesno.c @@ -15,6 +15,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> /* Read one line from standard input diff --git a/gnu/usr.bin/cvs/mkmodules/mkmodules.1 b/gnu/usr.bin/cvs/mkmodules/mkmodules.1 index 07ba3f5..8196a47 100644 --- a/gnu/usr.bin/cvs/mkmodules/mkmodules.1 +++ b/gnu/usr.bin/cvs/mkmodules/mkmodules.1 @@ -1,5 +1,5 @@ .\" -.\" @(#)mkmodules.1 1.3 92/01/30 +.\" $CVSid: @(#)mkmodules.1 1.3 92/01/30 $ .\" .TH MKMODULES 1 "12 October 1991" .SH "NAME" diff --git a/gnu/usr.bin/cvs/mkmodules/mkmodules.c b/gnu/usr.bin/cvs/mkmodules/mkmodules.c index 59ec13a..d5611de 100644 --- a/gnu/usr.bin/cvs/mkmodules/mkmodules.c +++ b/gnu/usr.bin/cvs/mkmodules/mkmodules.c @@ -3,7 +3,7 @@ * Copyright (c) 1989-1992, Brian Berliner * * You may distribute under the terms of the GNU General Public License as - * specified in the README file that comes with the CVS 1.3 kit. + * specified in the README file that comes with the CVS 1.4 kit. * * mkmodules * @@ -13,11 +13,9 @@ #include "cvs.h" -#undef PATH_MAX -#define PATH_MAX 1024 /* max number of bytes in pathname */ - #ifndef lint -static char rcsid[] = "@(#)mkmodules.c 1.39 92/03/31"; +static char rcsid[] = "$CVSid: @(#)mkmodules.c 1.45 94/09/30 $"; +USE(rcsid) #endif #ifndef DBLKSIZ @@ -30,30 +28,16 @@ char *Rcsbin = RCSBIN_DFLT; int noexec = 0; /* Here only to satisfy use in subr.c */ int trace = 0; /* Here only to satisfy use in subr.c */ -#if __STDC__ -static int checkout_file (char *file, char *temp); -static void make_tempfile (char *temp); -static void mkmodules_usage (void); -static void rename_rcsfile (char *temp, char *real); - -#ifndef MY_NDBM -static void rename_dbmfile (char *temp); -static void write_dbmfile (char *temp); -#endif /* !MY_NDBM */ - -#else /* !__STDC__ */ - -static void make_tempfile (); -static int checkout_file (); -static void rename_rcsfile (); -static void mkmodules_usage (); +static int checkout_file PROTO((char *file, char *temp)); +static void make_tempfile PROTO((char *temp)); +static void mkmodules_usage PROTO((void)); +static void rename_rcsfile PROTO((char *temp, char *real)); #ifndef MY_NDBM -static void write_dbmfile (); -static void rename_dbmfile (); +static void rename_dbmfile PROTO((char *temp)); +static void write_dbmfile PROTO((char *temp)); #endif /* !MY_NDBM */ -#endif /* __STDC__ */ int main (argc, argv) @@ -62,15 +46,34 @@ main (argc, argv) { extern char *getenv (); char temp[PATH_MAX]; - char *cp; + char *cp, *last, *fname; #ifdef MY_NDBM DBM *db; #endif + FILE *fp; + char line[512]; + static struct _checkout_file { + char *filename; + char *errormsg; + } *fileptr, filelist[] = { + {CVSROOTADM_LOGINFO, + "no logging of 'cvs commit' messages is done without a %s file"}, + {CVSROOTADM_RCSINFO, + "a %s file can be used to configure 'cvs commit' templates"}, + {CVSROOTADM_EDITINFO, + "a %s file can be used to validate log messages"}, + {CVSROOTADM_COMMITINFO, + "a %s file can be used to configure 'cvs commit' checking"}, + {CVSROOTADM_IGNORE, + "a %s file can be used to specify files to ignore"}, + {CVSROOTADM_CHECKOUTLIST, + "a %s file can specify extra CVSROOT files to auto-checkout"}, + {NULL, NULL}}; /* * Just save the last component of the path for error messages */ - if ((program_name = rindex (argv[0], '/')) == NULL) + if ((program_name = strrchr (argv[0], '/')) == NULL) program_name = argv[0]; else program_name++; @@ -127,7 +130,7 @@ main (argc, argv) /* NOTREACHED */ default: - error (0, 0, + error (0, 0, "'cvs checkout' is less functional without a %s file", CVSROOTADM_MODULES); break; @@ -135,57 +138,63 @@ main (argc, argv) (void) unlink_file (temp); - /* - * Now, check out the "loginfo" file, so that it is always up-to-date in - * the CVSROOT directory. - */ - make_tempfile (temp); - if (checkout_file (CVSROOTADM_LOGINFO, temp) == 0) - rename_rcsfile (temp, CVSROOTADM_LOGINFO); - else - error (0, 0, - "no logging of 'cvs commit' messages is done without a %s file", - CVSROOTADM_LOGINFO); - (void) unlink_file (temp); + /* Checkout the files that need it in CVSROOT dir */ + for (fileptr = filelist; fileptr && fileptr->filename; fileptr++) { + make_tempfile (temp); + if (checkout_file (fileptr->filename, temp) == 0) + rename_rcsfile (temp, fileptr->filename); +#if 0 + /* + * If there was some problem other than the file not existing, + * checkout_file already printed a real error message. If the + * file does not exist, it is harmless--it probably just means + * that the repository was created with an old version of CVS + * which didn't have so many files in CVSROOT. + */ + else if (fileptr->errormsg) + error (0, 0, fileptr->errormsg, fileptr->filename); +#endif + (void) unlink_file (temp); + } - /* - * Now, check out the "rcsinfo" file, so that it is always up-to-date in - * the CVSROOT directory. - */ - make_tempfile (temp); - if (checkout_file (CVSROOTADM_RCSINFO, temp) == 0) - rename_rcsfile (temp, CVSROOTADM_RCSINFO); - else - error (0, 0, - "a %s file can be used to configure 'cvs commit' templates", - CVSROOTADM_RCSINFO); - (void) unlink_file (temp); + /* Use 'fopen' instead of 'open_file' because we want to ignore error */ + fp = fopen (CVSROOTADM_CHECKOUTLIST, "r"); + if (fp) + { + /* + * File format: + * [<whitespace>]<filename><whitespace><error message><end-of-line> + */ + for (; fgets (line, sizeof (line), fp) != NULL;) + { + if ((last = strrchr (line, '\n')) != NULL) + *last = '\0'; /* strip the newline */ - /* - * Now, check out the "editinfo" file, so that it is always up-to-date in - * the CVSROOT directory. - */ - make_tempfile (temp); - if (checkout_file (CVSROOTADM_EDITINFO, temp) == 0) - rename_rcsfile (temp, CVSROOTADM_EDITINFO); - else - error (0, 0, - "a %s file can be used to validate log messages", - CVSROOTADM_EDITINFO); - (void) unlink_file (temp); + /* Skip leading white space. */ + for (fname = line; *fname && isspace(*fname); fname++) + ; + + /* Find end of filename. */ + for (cp = fname; *cp && !isspace(*cp); cp++) + ; + *cp = '\0'; + + make_tempfile (temp); + if (checkout_file (fname, temp) == 0) + { + rename_rcsfile (temp, fname); + } + else + { + for (cp++; cp < last && *last && isspace(*last); cp++) + ; + if (cp < last && *cp) + error (0, 0, cp, fname); + } + } + (void) fclose (fp); + } - /* - * Now, check out the "commitinfo" file, so that it is always up-to-date - * in the CVSROOT directory. - */ - make_tempfile (temp); - if (checkout_file (CVSROOTADM_COMMITINFO, temp) == 0) - rename_rcsfile (temp, CVSROOTADM_COMMITINFO); - else - error (0, 0, - "a %s file can be used to configure 'cvs commit' checking", - CVSROOTADM_COMMITINFO); - (void) unlink_file (temp); return (0); } @@ -251,7 +260,7 @@ write_dbmfile (temp) error (1, errno, "cannot open dbm file %s for creation", temp); for (cont = 0; fgets (line, sizeof (line), fp) != NULL;) { - if ((cp = rindex (line, '\n')) != NULL) + if ((cp = strrchr (line, '\n')) != NULL) *cp = '\0'; /* strip the newline */ /* @@ -370,8 +379,15 @@ rename_rcsfile (temp, real) char *real; { char bak[50]; + struct stat statbuf; + char rcs[PATH_MAX]; + + /* Set "x" bits if set in original. */ + (void) sprintf (rcs, "%s%s", real, RCSEXT); + statbuf.st_mode = 0; /* in case rcs file doesn't exist, but it should... */ + (void) stat (rcs, &statbuf); - if (chmod (temp, 0444) < 0) /* chmod 444 "temp" */ + if (chmod (temp, 0444 | (statbuf.st_mode & 0111)) < 0) error (0, errno, "warning: cannot chmod %s", temp); (void) sprintf (bak, "%s%s", BAKPREFIX, real); (void) unlink_file (bak); /* rm .#loginfo */ |