xargs.c (113045) | xargs.c (113136) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * John B. Roll Jr. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 35 unchanged lines hidden (view full) --- 44 45#if 0 46#ifndef lint 47static char sccsid[] = "@(#)xargs.c 8.1 (Berkeley) 6/6/93"; 48#endif /* not lint */ 49#endif 50 51#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * John B. Roll Jr. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 35 unchanged lines hidden (view full) --- 44 45#if 0 46#ifndef lint 47static char sccsid[] = "@(#)xargs.c 8.1 (Berkeley) 6/6/93"; 48#endif /* not lint */ 49#endif 50 51#include <sys/cdefs.h> |
52__FBSDID("$FreeBSD: head/usr.bin/xargs/xargs.c 113045 2003-04-04 04:39:29Z imp $"); | 52__FBSDID("$FreeBSD: head/usr.bin/xargs/xargs.c 113136 2003-04-05 20:30:30Z imp $"); |
53 54#include <sys/param.h> | 53 54#include <sys/param.h> |
55#if (__FreeBSD_version >= 450002 && __FreeBSD_version < 500000) || \ 56 __FreeBSD_version >= 500017 57#define HAS_LANGINFO 58#endif 59 | |
60#include <sys/wait.h> 61 62#include <err.h> 63#include <errno.h> 64#include <fcntl.h> | 55#include <sys/wait.h> 56 57#include <err.h> 58#include <errno.h> 59#include <fcntl.h> |
65#ifdef HAS_LANGINFO | |
66#include <langinfo.h> | 60#include <langinfo.h> |
67#endif | |
68#include <locale.h> 69#include <paths.h> 70#include <regex.h> 71#include <stdio.h> 72#include <stdlib.h> 73#include <string.h> 74#include <unistd.h> 75 --- 509 unchanged lines hidden (view full) --- 585 char *response; 586 FILE *ttyfp; 587 588 if ((ttyfp = fopen(_PATH_TTY, "r")) == NULL) 589 return (2); /* Indicate that the TTY failed to open. */ 590 (void)fprintf(stderr, "?..."); 591 (void)fflush(stderr); 592 if ((response = fgetln(ttyfp, &rsize)) == NULL || | 61#include <locale.h> 62#include <paths.h> 63#include <regex.h> 64#include <stdio.h> 65#include <stdlib.h> 66#include <string.h> 67#include <unistd.h> 68 --- 509 unchanged lines hidden (view full) --- 578 char *response; 579 FILE *ttyfp; 580 581 if ((ttyfp = fopen(_PATH_TTY, "r")) == NULL) 582 return (2); /* Indicate that the TTY failed to open. */ 583 (void)fprintf(stderr, "?..."); 584 (void)fflush(stderr); 585 if ((response = fgetln(ttyfp, &rsize)) == NULL || |
593 regcomp(&cre, 594#ifdef HAS_LANGINFO 595 nl_langinfo(YESEXPR), 596#else 597 "^[yY]", 598#endif 599 REG_BASIC) != 0) { | 586 regcomp(&cre, nl_langinfo(YESEXPR), REG_BASIC) != 0) { |
600 (void)fclose(ttyfp); 601 return (0); 602 } 603 match = regexec(&cre, response, 0, NULL, 0); 604 (void)fclose(ttyfp); 605 regfree(&cre); 606 return (match == 0); 607} 608 609static void 610usage(void) 611{ 612 fprintf(stderr, 613"usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]\n" 614" [-L number] [-n number [-x]] [-P maxprocs] [-s size]\n" 615" [utility [argument ...]]\n"); 616 exit(1); 617} | 587 (void)fclose(ttyfp); 588 return (0); 589 } 590 match = regexec(&cre, response, 0, NULL, 0); 591 (void)fclose(ttyfp); 592 regfree(&cre); 593 return (match == 0); 594} 595 596static void 597usage(void) 598{ 599 fprintf(stderr, 600"usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]\n" 601" [-L number] [-n number [-x]] [-P maxprocs] [-s size]\n" 602" [utility [argument ...]]\n"); 603 exit(1); 604} |