xref: /original-bsd/usr.bin/find/oldsyntax.c (revision 3b6250d9)
1 /*-
2  * Copyright (c) 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)oldsyntax.c	5.2 (Berkeley) 11/15/90";
10 #endif /* not lint */
11 
12 #include <stdio.h>
13 
14 /*
15  * oldsyntax --
16  *	move the path names to the beginning of the argv array, and return
17  *	a pointer to them.  The old find syntax assumes all command arguments
18  *	up to the first one beginning with a '-', '(' or '!' are pathnames.
19  */
20 void
21 oldsyntax(argvp)
22 	char ***argvp;
23 {
24 	register char **argv;
25 
26 	/*
27 	 * find first '-', '(' or '!' to delimit paths; if no paths, it's
28 	 * an error.  Shift the array back one at the same time, creating
29 	 * a separate array of pathnames.
30 	 */
31 	for (argv = *argvp + 1;; ++argv) {
32 		argv[-1] = argv[0];
33 		if (!*argv || **argv == '-' || **argv == '!' || **argv == '(')
34 			break;
35 	}
36 
37 	if (argv == *argvp + 1)
38 		usage();
39 
40 	argv[-1] = NULL;
41 	*argvp = argv;			/* move argv value */
42 }
43