Changeset View
Changeset View
Standalone View
Standalone View
head/usr.bin/xargs/xargs.c
Show First 20 Lines • Show All 776 Lines • ▼ Show 20 Lines | prompt(void) | ||||
char *response; | char *response; | ||||
FILE *ttyfp; | FILE *ttyfp; | ||||
if ((ttyfp = fopen(_PATH_TTY, "r")) == NULL) | if ((ttyfp = fopen(_PATH_TTY, "r")) == NULL) | ||||
return (2); /* Indicate that the TTY failed to open. */ | return (2); /* Indicate that the TTY failed to open. */ | ||||
(void)fprintf(stderr, "?..."); | (void)fprintf(stderr, "?..."); | ||||
(void)fflush(stderr); | (void)fflush(stderr); | ||||
if ((response = fgetln(ttyfp, &rsize)) == NULL || | if ((response = fgetln(ttyfp, &rsize)) == NULL || | ||||
regcomp(&cre, nl_langinfo(YESEXPR), REG_BASIC) != 0) { | regcomp(&cre, nl_langinfo(YESEXPR), REG_EXTENDED) != 0) { | ||||
(void)fclose(ttyfp); | (void)fclose(ttyfp); | ||||
return (0); | return (0); | ||||
} | } | ||||
response[rsize - 1] = '\0'; | response[rsize - 1] = '\0'; | ||||
match = regexec(&cre, response, 0, NULL, 0); | match = regexec(&cre, response, 0, NULL, 0); | ||||
(void)fclose(ttyfp); | (void)fclose(ttyfp); | ||||
regfree(&cre); | regfree(&cre); | ||||
return (match == 0); | return (match == 0); | ||||
Show All 12 Lines |