🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.bugs
Article #2221

Athena delete patch number 2

#2221
From: Jonathan I. Kamens
Date: Thu, 04 May 1989 19:01
492 lines
15498 bytes
The following is patch number two to the Athena delete software package posted
in comp.sources.unix.  It fixes some problems with wildcard matching and the
handling of current-working-directory searching, and fixes a small bug in
expunge which caused it to ask about the status of some files twice.  Further,
I have stopped assuming that '.' and '..' will always be the first two entries
in every directory.

Jonathan Kamens			              USnail:
MIT Project Athena				410 Memorial Drive, No. 223F
jik@Athena.MIT.EDU				Cambridge, MA 02139-4318
Office: 617-253-4261			      Home: 617-225-8218

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  delete.patch2
# Wrapped by jik@pit-manager on Thu May  4 14:58:25 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'delete.patch2' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'delete.patch2'\"
else
echo shar: Extracting \"'delete.patch2'\" \(12677 characters\)
sed "s/^X//" >'delete.patch2' <<'END_OF_FILE'
X*** /tmp/,RCSt1015809	Thu May  4 14:35:45 1989
X--- Makefile	Thu May  4 14:06:17 1989
X***************
X*** 5,11 ****
X  #
X  #     $Source: /mit/jik/src/delete/RCS/Makefile,v $
X  #     $Author: jik $
X! #     $Header: Makefile,v 1.8 89/03/27 12:03:33 jik Exp $
X  #
X  
X  DESTDIR =
X--- 5,11 ----
X  #
X  #     $Source: /mit/jik/src/delete/RCS/Makefile,v $
X  #     $Author: jik $
X! #     $Header: Makefile,v 1.9 89/05/04 14:05:48 jik Exp $
X  #
X  
X  DESTDIR =
X***************
X*** 15,20 ****
X--- 15,25 ----
X  CFLAGS = -O
X  SRCS = delete.c undelete.c directories.c pattern.c util.c expunge.c \
X  	lsdel.c col.c
X+ INCS = col.h delete.h directories.h expunge.h lsdel.h mit-copyright.h\
X+ 	pattern.h undelete.h util.h
X+ MANS = man1 man1/delete.1 man1/expunge.1 man1/lsdel.1 man1/purge.1\
X+ 	man1/undelete.1
X+ ARCHIVE = README Makefile MANIFEST PATCHLEVEL $(SRCS) $(INCS) $(MANS)
X  
X  all: $(TARGETS)
X  
X***************
X*** 61,66 ****
X--- 66,112 ----
X  	#alias s step
X  	#alias n next
X  	#load lsdel.c util.c directories.c pattern.c col.c
X+ 
X+ tar: $(ARCHIVE)
X+ 	@echo "Checking to see if everything's checked in...."
X+ 	@for i in $(ARCHIVE) ;\
X+ 	do \
X+ 	if [ -w $$i ] ; then \
X+ 		echo "$$i isn't checked in.  Check it in before making"; \
X+ 		echo "an archive."; \
X+ 		exit 1; \
X+ 	fi ; \
X+ 	exit 0; \
X+ 	done
X+ 	tar cvf - $(ARCHIVE) | compress > delete.tar.Z
X+ 
X+ shar: $(ARCHIVE)
X+ 	@echo "Checking to see if everything's checked in...."
X+ 	@for i in $(ARCHIVE) ;\
X+ 	do \
X+ 	if [ -w $$i ] ; then \
X+ 		echo "$$i isn't checked in.  Check it in before making"; \
X+ 		echo "an archive."; \
X+ 		exit 1; \
X+ 	fi ; \
X+ 	exit 0; \
X+ 	done
X+ 	makekit -oMANIFEST -h2 MANIFEST $(ARCHIVE)
X+ 
X+ patch: $(ARCHIVE)
X+ 	@echo "Checking to see if everything's checked in...."
X+ 	@for i in $(ARCHIVE) ;\
X+ 	do \
X+ 	if [ -w $$i ] ; then \
X+ 		echo "$$i isn't checked in.  Check it in before making"; \
X+ 		echo "an archive."; \
X+ 		exit 1; \
X+ 	fi ; \
X+ 	exit 0; \
X+ 	done
X+ 	makepatch $(ARCHIVE)
X+ 	mv patch delete.patch`cat PATCHLEVEL`
X+ 	shar delete.patch`cat PATCHLEVEL` > delete.patch`cat PATCHLEVEL`.shar
X  
X  clean:
X  	-rm -f *~ *.bak *.o delete undelete lsdel expunge purge
X*** /dev/null   Thu May  4 14:54:50 1989
X--- PATCHLEVEL  Thu May  4 14:31:31 1989
X***************
X*** 0 ****
X--- 1 ----
X+ 2
X*** /tmp/,RCSt1015851	Thu May  4 14:40:41 1989
X--- pattern.c	Thu May  4 14:23:31 1989
X***************
X*** 11,17 ****
X   */
X  
X  #if (!defined(lint) && !defined(SABER))
X!      static char rcsid_pattern_c[] = "$Header: pattern.c,v 1.8 89/03/27 12:07:48 jik Exp $";
X  #endif
X  
X  #include <stdio.h>
X--- 11,17 ----
X   */
X  
X  #if (!defined(lint) && !defined(SABER))
X!      static char rcsid_pattern_c[] = "$Header: pattern.c,v 1.9 89/05/04 14:21:39 jik Exp $";
X  #endif
X  
X  #include <stdio.h>
X***************
X*** 207,218 ****
X       if (! dirp)
X  	  return(found);
X  
X-      readdir(dirp); readdir(dirp); /* get rid of . and .. */
X-      
X       strcpy(first, reg_firstpart(expression, rest));
X       re_comp(first);
X  
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X  	  if (re_exec(dp->d_name) && *rest) {
X  	       strcpy(new, append(base, dp->d_name));
X  	       next = find_deleted_matches(new, rest, &num_next);
X--- 207,218 ----
X       if (! dirp)
X  	  return(found);
X  
X       strcpy(first, reg_firstpart(expression, rest));
X       re_comp(first);
X  
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X+ 	  if (is_dotfile(dp->d_name)) /* skip dot files */
X+ 	       continue;
X  	  if (re_exec(dp->d_name) && *rest) {
X  	       strcpy(new, append(base, dp->d_name));
X  	       next = find_deleted_matches(new, rest, &num_next);
X***************
X*** 265,270 ****
X--- 265,272 ----
X       strcpy(first, reg_firstpart(expression, rest));
X  
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X+ 	  if (is_dotfile(dp->d_name))
X+ 	       continue;
X  	  re_comp(first);
X  	  if (re_exec(dp->d_name)) {
X  	       if (*rest) {
X***************
X*** 321,329 ****
X       if (! dirp)
X  	  return(found);
X  
X-      readdir(dirp); readdir(dirp); /* get rid of . and .. */
X- 
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X  	  strcpy(newname, append(base, dp->d_name));
X  	  found = add_str(found, found_num, newname);
X  	  found_num++;
X--- 323,331 ----
X       if (! dirp)
X  	  return(found);
X  
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X+ 	  if (is_dotfile(dp->d_name))
X+ 	       continue;
X  	  strcpy(newname, append(base, dp->d_name));
X  	  found = add_str(found, found_num, newname);
X  	  found_num++;
X***************
X*** 362,370 ****
X       if (! dirp)
X  	  return(found);
X  
X-      readdir(dirp); readdir(dirp); /* get rid of . and .. */
X- 
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X  	  strcpy(newname, append(base, dp->d_name));
X  	  
X  	  if (is_deleted(dp->d_name)) {
X--- 364,373 ----
X       if (! dirp)
X  	  return(found);
X  
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X+ 	  if (is_dotfile(dp->d_name))
X+ 	       continue;
X+ 
X  	  strcpy(newname, append(base, dp->d_name));
X  	  
X  	  if (is_deleted(dp->d_name)) {
X***************
X*** 408,416 ****
X       if (! dirp)
X  	  return(found);
X  
X-      readdir(dirp); readdir(dirp); /* get rid of . and .. */
X- 
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X  	  found = add_str(found, num, append(base, dp->d_name));
X  	  num += 1;
X       }
X--- 411,419 ----
X       if (! dirp)
X  	  return(found);
X  
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X+ 	  if (is_dotfile(dp->d_name))
X+ 	       continue;
X  	  found = add_str(found, num, append(base, dp->d_name));
X  	  num += 1;
X       }
X***************
X*** 440,448 ****
X       if (! dirp)
X  	  return(found);
X  
X-      readdir(dirp); readdir(dirp); /* get rid of . and .. */
X- 
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X  	  if (is_deleted(dp->d_name)) {
X  	       found = add_str(found, num, append(base, dp->d_name));
X  	       num += 1;
X--- 443,451 ----
X       if (! dirp)
X  	  return(found);
X  
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X+ 	  if (is_dotfile(dp->d_name))
X+ 	       continue;
X  	  if (is_deleted(dp->d_name)) {
X  	       found = add_str(found, num, append(base, dp->d_name));
X  	       num += 1;
X***************
X*** 479,487 ****
X       if (! dirp)
X  	  return(found);
X  
X-      readdir(dirp); readdir(dirp); /* get rid of . and .. */
X- 
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X  	  if (is_deleted(dp->d_name)) {
X  	       strcpy(newname, append(base, dp->d_name));
X  	       found = add_str(found, num, newname);
X--- 482,490 ----
X       if (! dirp)
X  	  return(found);
X  
X       for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
X+ 	  if (is_dotfile(dp->d_name))
X+ 	       continue;
X  	  if (is_deleted(dp->d_name)) {
X  	       strcpy(newname, append(base, dp->d_name));
X  	       found = add_str(found, num, newname);
X*** /tmp/,RCSt1015862	Thu May  4 14:41:29 1989
X--- util.c	Thu May  4 14:28:40 1989
X***************
X*** 11,17 ****
X   */
X  
X  #if (!defined(lint) && !defined(SABER))
X!      static char rcsid_util_c[] = "$Header: util.c,v 1.7 89/03/27 12:08:34 jik Exp $";
X  #endif
X  
X  #include <stdio.h>
X--- 11,17 ----
X   */
X  
X  #if (!defined(lint) && !defined(SABER))
X!      static char rcsid_util_c[] = "$Header: util.c,v 1.8 89/05/04 14:28:11 jik Exp $";
X  #endif
X  
X  #include <stdio.h>
X***************
X*** 84,106 ****
X  }
X       
X       
X- is_dotfile(filename)
X- char *filename;
X- {
X-      return (! (strcmp(filename, ".") && strcmp(filename, "..")));
X- }
X- 
X- 
X- 
X- int is_deleted(filename)
X- char *filename;
X- {
X-      return(! strncmp(filename, ".#", 2));
X- }
X- 
X- 
X- 
X- 
X  /*
X   * NOTE: Append uses a static array, so its return value must be
X   * copied immediately.
X--- 84,89 ----
X*** /tmp/,RCSt1015869	Thu May  4 14:42:24 1989
X--- expunge.c	Thu May  4 14:12:05 1989
X***************
X*** 11,17 ****
X   */
X  
X  #if (!defined(lint) && !defined(SABER))
X!      static char rcsid_expunge_c[] = "$Header: expunge.c,v 1.8 89/04/06 23:25:20 jik Exp $";
X  #endif
X  
X  /*
X--- 11,17 ----
X   */
X  
X  #if (!defined(lint) && !defined(SABER))
X!      static char rcsid_expunge_c[] = "$Header: expunge.c,v 1.9 89/05/04 14:10:54 jik Exp $";
X  #endif
X  
X  /*
X***************
X*** 185,191 ****
X  	  }
X  	  else {
X  	       start_dir = "";
X! 	       file_re = parse_pattern(files[num - 1]);
X  	  }
X  	  if (! file_re)
X  	       return(ERROR_MASK);
X--- 185,194 ----
X  	  }
X  	  else {
X  	       start_dir = "";
X! 	       if ((*files[num - 1] == '.') && (! *(files[num - 1] + 1)))
X! 		    file_re = parse_pattern("*");
X! 	       else
X! 		    file_re = parse_pattern(files[num - 1]);
X  	  }
X  	  if (! file_re)
X  	       return(ERROR_MASK);
X***************
X*** 247,256 ****
X  {
X       int status = 0;
X  
X!      if ((leaf->specified) && ((leaf->specs.st_mode & S_IFMT) == S_IFDIR))
X  	  status = do_directory_expunge(leaf);
X!      /* the "do_directory_expunge" really only asks the user if he */
X!      /* wants to expunge the directory, it doesn't do any deleting. */
X       if (! status) {
X  	  if (leaf->dirs)
X  	       status |= expunge_specified(leaf->dirs);
X--- 250,269 ----
X  {
X       int status = 0;
X  
X!      if ((leaf->specified) && ((leaf->specs.st_mode & S_IFMT) == S_IFDIR)) {
X  	  status = do_directory_expunge(leaf);
X! 	  /* the "do_directory_expunge" really only asks the user if he */
X! 	  /* wants to expunge the directory, it doesn't do any deleting. */
X!      }
X!      /* "But wait," you're saying to yourself as you ponder this code, */
X!      /* "Why isn't this next if statement included inside the if       */
X!      /* statement above, since they both refer to directories."  Well, */
X!      /* I wondered about the same thing a week after I wrote the code. */
X!      /* Keep in mind that a directory passed to this function may not  */
X!      /* be specified, but some of its children may be.  Therefore, we  */
X!      /* have to recursively descend even unspecified directories to    */
X!      /* find specified files, hence this is outside of the if          */
X!      /* statement above.					       */
X       if (! status) {
X  	  if (leaf->dirs)
X  	       status |= expunge_specified(leaf->dirs);
X***************
X*** 257,263 ****
X  	  if (leaf->files)
X  	       status |= expunge_specified(leaf->files);
X       }
X!      if (leaf->specified)
X  	  status |= really_do_expunge(leaf);
X       if (leaf->next)
X  	  status |= expunge_specified(leaf->next);
X--- 270,276 ----
X  	  if (leaf->files)
X  	       status |= expunge_specified(leaf->files);
X       }
X!      if ((leaf->specified) && (! status))
X  	  status |= really_do_expunge(leaf);
X       if (leaf->next)
X  	  status |= expunge_specified(leaf->next);
X*** /tmp/,RCSt1015882	Thu May  4 14:43:25 1989
X--- lsdel.c	Thu May  4 14:18:38 1989
X***************
X*** 11,17 ****
X   */
X  
X  #if (!defined(lint) && !defined(SABER))
X!      static char rcsid_lsdel_c[] = "$Header: lsdel.c,v 1.4 89/03/27 12:07:13 jik Exp $";
X  #endif
X  
X  #include <stdio.h>
X--- 11,17 ----
X   */
X  
X  #if (!defined(lint) && !defined(SABER))
X!      static char rcsid_lsdel_c[] = "$Header: lsdel.c,v 1.5 89/05/04 14:18:18 jik Exp $";
X  #endif
X  
X  #include <stdio.h>
X***************
X*** 115,121 ****
X  	  }
X  	  else {
X  	       start_dir = "";
X! 	       file_re = parse_pattern(args[num - 1]);
X  	  }
X  	  if (! file_re)
X  	       return(ERROR_MASK);
X--- 115,124 ----
X  	  }
X  	  else {
X  	       start_dir = "";
X! 	       if ((*args[num - 1] == '.') && (! *(args[num - 1] + 1)))
X! 		    file_re = parse_pattern("*");
X! 	       else
X! 		    file_re = parse_pattern(args[num - 1]);
X  	  }
X  	  if (! file_re)
X  	       return(ERROR_MASK);
X*** /tmp/,RCSt1016005	Thu May  4 14:53:53 1989
X--- util.h	Thu May  4 14:29:45 1989
X***************
X*** 1,7 ****
X  /*
X   * $Source: /mit/jik/src/delete/RCS/util.h,v $
X   * $Author: jik $
X!  * $Header: util.h,v 1.4 89/03/27 12:08:41 jik Exp $
X   * 
X   * This file is part of a package including delete, undelete,
X   * lsdel, expunge and purge.  The software suite is meant as a
X--- 1,7 ----
X  /*
X   * $Source: /mit/jik/src/delete/RCS/util.h,v $
X   * $Author: jik $
X!  * $Header: util.h,v 1.5 89/05/04 14:29:19 jik Exp $
X   * 
X   * This file is part of a package including delete, undelete,
X   * lsdel, expunge and purge.  The software suite is meant as a
X***************
X*** 19,21 ****
X--- 19,28 ----
X  char *reg_firstpart();
X  char *strindex();
X  char *strrindex();
X+ 
X+ #define is_dotfile(A) ((*A == '.') && \
X+ 		       ((*(A + 1) == '\0') || \
X+ 			((*(A + 1) == '.') && \
X+ 			 (*(A + 2) == '\0'))))
X+ 
X+ #define is_deleted(A) ((*A == '.') && (*(A + 1) == '#'))
END_OF_FILE
if test 12677 -ne `wc -c <'delete.patch2'`; then
    echo shar: \"'delete.patch2'\" unpacked with wrong size!
fi
# end of 'delete.patch2'
fi
echo shar: End of shell archive.
exit 0
Technical Details
Message-ID: <11121@bloom-beacon.MIT.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!Athena.MIT.EDU!jik

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!Athena.MIT.EDU!jik
From: jik@Athena.MIT.EDU (Jonathan I. Kamens)
Newsgroups: comp.sources.bugs
Subject: Athena delete patch number 2
Message-ID: <11121@bloom-beacon.MIT.EDU>
Date: 4 May 89 19:01:28 GMT
Sender: daemon@bloom-beacon.MIT.EDU
Lines: 492