getresponse.c revision c536b1f93b31eba539c635a91be8ee2ab0fcb15a
1N/A * The contents of this file are subject to the terms of the 1N/A * Common Development and Distribution License (the "License"). 1N/A * You may not use this file except in compliance with the License. 1N/A * See the License for the specific language governing permissions 1N/A * and limitations under the License. 1N/A * When distributing Covered Code, include this CDDL HEADER in each 1N/A * If applicable, add the following below this CDDL HEADER, with the 1N/A * fields enclosed by brackets "[]" replaced with your own identifying 1N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 1N/A * Use is subject to license terms. 1N/A/* defaults - C locale values for yesstr, nostr, yesexpr (LC_MESSAGES) */ 1N/A/* variables used by getresponse functions */ 1N/A/* for regcomp()/regexec() yesexpr and noexpr */ 1N/A * This function compiles a regular expression that is used to match an * affirmative response from the user, and also assigns the strings used * in the prompts that request affirmative or negative responses. The * locale's values for YESEXPR, NOEXPR, YESSTR and NOSTR are used. * If there are any problems using the locale's YESEXPR, NOEXPR, YESSTR or NOSTR * values, default values of YESEXPR, YESSTR and NOSTR will be used * as a fallback. The default values are the same as the C locale values. /* get yes expression and strings for yes/no prompts */ /* if problem with locale strings, use default values */ /* Compile the yes and no expressions */ /* The fallback yesexpr failed, so exit */ /* The locale's yesexpr or noexpr failed so use fallback */ if (b ==
'\n' || b ==
'\0' || b ==
EOF)
/* Both Expressions Match (reg2 conservative) */ * yes_check() returns 1 if the input string is matched by yesexpr and is * not matched by noexpr; otherwise yes_check() returns 0. * no_check() returns 1 if the input string is matched by noexpr and is * not matched by yesexpr; otherwise no_check() returns 0.