+\f/*
+** CLEAN -- clean out recreatable files
+**
+** Any file for which an "s." file exists but no "p." file
+** exists in the current directory is purged.
+**
+** Parameters:
+** none.
+**
+** Returns:
+** none.
+**
+** Side Effects:
+** removes files in the current directory.
+*/
+
+clean()
+{
+ struct direct dir;
+ struct stat stbuf;
+ char buf[100];
+ FILE *dirfd;
+
+ dirfd = fopen(SccsPath, "r");
+ if (dirfd == NULL)
+ {
+ fprintf(stderr, "Sccs: cannot open %s\n", SccsPath);
+ return;
+ }
+
+ /*
+ ** Scan the SCCS directory looking for s. files.
+ */
+
+ while (fread(&dir, sizeof dir, 1, dirfd) != NULL)
+ {
+ if (dir.d_ino == 0 || strcmpn(dir.d_name, "s.", 2) != 0)
+ continue;
+
+ /* got an s. file -- see if the p. file exists */
+ strcpy(buf, SccsPath);
+ strcat(buf, "/p.");
+ buf[strlen(buf) + sizeof dir.d_name - 2] = '\0';
+ strcatn(buf, &dir.d_name[2], sizeof dir.d_name - 2);
+ if (stat(buf, &stbuf) >= 0)
+ continue;
+
+ /* the s. file exists and no p. file exists -- unlink the g-file */
+ buf[sizeof dir.d_name - 2] = '\0';
+ strcpyn(buf, &dir.d_name[2], sizeof dir.d_name - 2);
+ unlink(buf);
+ }
+
+ fclose(dirfd);
+}