Deleted Added
sdiff udiff text old ( 105826 ) new ( 106106 )
full compact
1/*-
2 * Copyright (c) 1988, 1989, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1989 by Berkeley Softworks
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor.

--- 25 unchanged lines hidden (view full) ---

34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)str.c 5.8 (Berkeley) 6/1/90
39 */
40
41#include <sys/cdefs.h>
42__FBSDID("$FreeBSD: head/usr.bin/make/str.c 106106 2002-10-28 23:33:57Z jmallett $");
43
44#include "make.h"
45
46static char **argv, *buffer;
47static int argmax, curlen;
48
49/*
50 * str_init --

--- 197 unchanged lines hidden (view full) ---

248 *t++ = (char) ch;
249 }
250done: argv[argc] = (char *)NULL;
251 *store_argc = argc;
252 return(argv);
253}
254
255/*
256 * Str_Match --
257 *
258 * See if a particular string matches a particular pattern.
259 *
260 * Results: Non-zero is returned if string matches pattern, 0 otherwise. The
261 * matching operation permits the following special characters in the
262 * pattern: *?\[] (see the man page for details on what these mean).
263 *
264 * Side effects: None.
265 */
266int
267Str_Match(const char *string, const char *pattern)
268{
269 char c2;
270
271 for (;;) {
272 /*
273 * See if we're at the end of both the pattern and the
274 * string. If, we succeeded. If we're at the end of the
275 * pattern but not at the end of the string, we failed.

--- 85 unchanged lines hidden (view full) ---

361 * Returns the beginning position of a match or null. The number
362 * of characters matched is returned in len.
363 *
364 * Side Effects:
365 * None
366 *
367 *-----------------------------------------------------------------------
368 */
369const char *
370Str_SYSVMatch(const char *word, const char *pattern, int *len)
371{
372 const char *m, *p, *w;
373
374 p = pattern;
375 w = word;
376
377 if (*w == '\0') {
378 /* Zero-length word cannot be matched against */
379 *len = 0;
380 return NULL;
381 }
382
383 if (*p == '\0') {
384 /* Null pattern is the whole string */

--- 41 unchanged lines hidden (view full) ---

426 * None
427 *
428 * Side Effects:
429 * Places result on buf
430 *
431 *-----------------------------------------------------------------------
432 */
433void
434Str_SYSVSubst(Buffer buf, const char *pat, const char *src, int len)
435{
436 const char *m;
437
438 if ((m = strchr(pat, '%')) != NULL) {
439 /* Copy the prefix */
440 Buf_AddBytes(buf, m - pat, (Byte *) pat);
441 /* skip the % */
442 pat = m + 1;
443 }
444
445 /* Copy the pattern */
446 Buf_AddBytes(buf, len, (Byte *) src);
447
448 /* append the rest */
449 Buf_AddBytes(buf, strlen(pat), (Byte *) pat);
450}