Project/Real_code/gnu/gawk-3.1.3/main.c
int
arg_assign(char *arg, int initing)
{
	char *cp, *cp2;
	int badvar;
	Func_ptr after_assign = NULL;
	NODE *var;
	NODE *it;
	NODE **lhs;

	cp = strchr(arg, '=');

	if (cp == NULL) {
		if (! initing)
			return FALSE;	/* This is file name, not assignment. */

		fprintf(stderr,
			_("%s: `%s' argument to `-v' not in `var=value' form\n\n"),
			myname, arg);
		usage(1, stderr);
	}

	*cp++ = '\0';

	/* first check that the variable name has valid syntax */
	badvar = FALSE;
	if (! ISALPHA(arg[0]) && arg[0] != '_')
		badvar = TRUE;
	else
		for (cp2 = arg+1; *cp2; cp2++)
			if (! ISALNUM(*cp2) && *cp2 != '_') {
				badvar = TRUE;
				break;
			}

	if (badvar) {
		if (initing)
			fatal(_("`%s' is not a legal variable name"), arg);

		if (do_lint)
			lintwarn(_("`%s' is not a variable name, looking for file `%s=%s'"),
				arg, arg, cp);
	} else {
		/*
		 * Recent versions of nawk expand escapes inside assignments.
		 * This makes sense, so we do it too.
		 */
		it = make_str_node(cp, strlen(cp), SCAN);
		it->flags |= MAYBE_NUM;
#ifdef LC_NUMERIC
		setlocale(LC_NUMERIC, "C");
		(void) force_number(it);
		setlocale(LC_NUMERIC, "");
#endif /* LC_NUMERIC */
		var = variable(arg, FALSE, Node_var);
		lhs = get_lhs(var, &after_assign, FALSE);
		unref(*lhs);
		*lhs = it;
		if (after_assign != NULL)
			(*after_assign)();
	}

	*--cp = '=';	/* restore original text of ARGV */

	return ! badvar;
}
/* arg_assign --- process a command-line assignment */
process a command-line assignment
process a command - line assignment
int
arg_assign(char *arg, int initing)
{
	char *cp, *cp2;
	int badvar;
	Func_ptr after_assign = NULL;
	NODE *var;
	NODE *it;
	NODE **lhs;
	cp = strchr(arg, '=');
	if (cp == NULL) {
		if (! initing)
			return FALSE;	
		fprintf(stderr,
			_("%s: `%s' argument to `-v' not in `var=value' form\n\n"),
			myname, arg);
		usage(1, stderr);
	}
	*cp++ = '\0';
	badvar = FALSE;
	if (! ISALPHA(arg[0]) && arg[0] != '_')
		badvar = TRUE;
	else
		for (cp2 = arg+1; *cp2; cp2++)
			if (! ISALNUM(*cp2) && *cp2 != '_') {
				badvar = TRUE;
				break;
			}
	if (badvar) {
		if (initing)
			fatal(_("`%s' is not a legal variable name"), arg);
		if (do_lint)
			lintwarn(_("`%s' is not a variable name, looking for file `%s=%s'"),
				arg, arg, cp);
	} else {
		it = make_str_node(cp, strlen(cp), SCAN);
		it->flags |= MAYBE_NUM;
#ifdef LC_NUMERIC
		setlocale(LC_NUMERIC, "C");
		(void) force_number(it);
		setlocale(LC_NUMERIC, "");
#endif 
		var = variable(arg, FALSE, Node_var);
		lhs = get_lhs(var, &after_assign, FALSE);
		unref(*lhs);
		*lhs = it;
		if (after_assign != NULL)
			(*after_assign)();
	}
	*--cp = '=';	
	return ! badvar;
}
int arg_assign ( char * arg , int initing ) { char * cp , * cp2 ; int badvar ; Func_ptr after_assign = NULL ; NODE * var ; NODE * it ; NODE * * lhs ; cp = strchr ( arg , ' ' ) ; if ( cp == NULL ) { if ( ! initing ) return FALSE ; fprintf ( stderr , _ ( " \n \n " ) , myname , arg ) ; usage ( 1 , stderr ) ; } * cp ++ = ' \0 ' ; badvar = FALSE ; if ( ! ISALPHA ( arg [ 0 ] ) && arg [ 0 ] != ' ' ) badvar = TRUE ; else for ( cp2 = arg + 1 ; * cp2 ; cp2 ++ ) if ( ! ISALNUM ( * cp2 ) && * cp2 != ' ' ) { badvar = TRUE ; break ; } if ( badvar ) { if ( initing ) fatal ( _ ( " " ) , arg ) ; if ( do_lint ) lintwarn ( _ ( " " ) , arg , arg , cp ) ; } else { it = make_str_node ( cp , strlen ( cp ) , SCAN ) ; it -> flags |= MAYBE_NUM ; #ifdef LC_NUMERIC setlocale ( LC_NUMERIC , " " ) ; ( void ) force_number ( it ) ; setlocale ( LC_NUMERIC , " " ) ; #endif var = variable ( arg , FALSE , Node_var ) ; lhs = get_lhs ( var , & after_assign , FALSE ) ; unref ( * lhs ) ; * lhs = it ; if ( after_assign != NULL ) ( * after_assign ) ( ) ; } * -- cp = ' ' ; return ! badvar ; }
arg_assign --- process a command-line assignment
arg_assign --- process a command - line assignment
/* This is file name, not assignment. */ /* first check that the variable name has valid syntax */ /*
		 * Recent versions of nawk expand escapes inside assignments.
		 * This makes sense, so we do it too.
		 */ /* LC_NUMERIC */ /* restore original text of ARGV */