usr.bin/rdist/lookup.c
void
define(char *name)
{
	char *cp, *s;
	struct namelist *nl;
	struct namelist *value;

	value = NULL;

	if (debug)
		printf("define(%s)\n", name);

	cp = index(name, '=');
	if (cp == NULL)
		value = NULL;
	else if (cp[1] == '\0') {
		*cp = '\0';
		value = NULL;
	} else if (cp[1] != '(') {
		*cp++ = '\0';
		value = makenl(cp);
	} else {
		nl = NULL;
		*cp++ = '\0';
		do
			cp++;
		while (*cp == ' ' || *cp == '\t');
		for (s = cp; ; s++) {
			switch (*s) {
			case ')':
				*s = '\0';
			case '\0':
				break;
			case ' ':
			case '\t':
				*s++ = '\0';
				while (*s == ' ' || *s == '\t')
					s++;
				if (*s == ')')
					*s = '\0';
				break;
			default:
				continue;
			}
			if (nl == NULL)
				value = nl = makenl(cp);
			else {
				nl->n_next = makenl(cp);
				nl = nl->n_next;
			}
			if (*s == '\0')
				break;
			cp = s;
		}
	}
	lookup(name, REPLACE, value);
}
/*
 * Define a variable from a command line argument.
 */
Define a variable from a command line argument.
Define a variable from a command line argument .
void
define(char *name)
{
	char *cp, *s;
	struct namelist *nl;
	struct namelist *value;
	value = NULL;
	if (debug)
		printf("define(%s)\n", name);
	cp = index(name, '=');
	if (cp == NULL)
		value = NULL;
	else if (cp[1] == '\0') {
		*cp = '\0';
		value = NULL;
	} else if (cp[1] != '(') {
		*cp++ = '\0';
		value = makenl(cp);
	} else {
		nl = NULL;
		*cp++ = '\0';
		do
			cp++;
		while (*cp == ' ' || *cp == '\t');
		for (s = cp; ; s++) {
			switch (*s) {
			case ')':
				*s = '\0';
			case '\0':
				break;
			case ' ':
			case '\t':
				*s++ = '\0';
				while (*s == ' ' || *s == '\t')
					s++;
				if (*s == ')')
					*s = '\0';
				break;
			default:
				continue;
			}
			if (nl == NULL)
				value = nl = makenl(cp);
			else {
				nl->n_next = makenl(cp);
				nl = nl->n_next;
			}
			if (*s == '\0')
				break;
			cp = s;
		}
	}
	lookup(name, REPLACE, value);
}
void define ( char * name ) { char * cp , * s ; struct namelist * nl ; struct namelist * value ; value = NULL ; if ( debug ) printf ( " \n " , name ) ; cp = index ( name , ' ' ) ; if ( cp == NULL ) value = NULL ; else if ( cp [ 1 ] == ' \0 ' ) { * cp = ' \0 ' ; value = NULL ; } else if ( cp [ 1 ] != ' ' ) { * cp ++ = ' \0 ' ; value = makenl ( cp ) ; } else { nl = NULL ; * cp ++ = ' \0 ' ; do cp ++ ; while ( * cp == ' ' || * cp == ' \t ' ) ; for ( s = cp ; ; s ++ ) { switch ( * s ) { case ' ' : * s = ' \0 ' ; case ' \0 ' : break ; case ' ' : case ' \t ' : * s ++ = ' \0 ' ; while ( * s == ' ' || * s == ' \t ' ) s ++ ; if ( * s == ' ' ) * s = ' \0 ' ; break ; default : continue ; } if ( nl == NULL ) value = nl = makenl ( cp ) ; else { nl -> n_next = makenl ( cp ) ; nl = nl -> n_next ; } if ( * s == ' \0 ' ) break ; cp = s ; } } lookup ( name , REPLACE , value ) ; }
Define a variable from a command line argument.
Define a variable from a command line argument .