mksh/mksh.logging/exec.c
int
define(const char *name, struct op *t)
{
	uint32_t nhash;
	struct tbl *tp;
	bool was_set = false;

	atrshmlog_time_t starttime;
	atrshmlog_time_t endtime;

	ATRSHMLOG_GETTIME(290,starttime);

	int atrshmlogline = 0;
	if (t)
	  atrshmlogline = t->lineno;
	else
	  atrshmlogline = g_linehint;

	
	nhash = hash(name);

	while (/* CONSTCOND */ 1) {
		tp = findfunc(name, nhash, true);

		if (tp->flag & ISSET)
			was_set = true;
		/*
		 * If this function is currently being executed, we zap
		 * this table entry so findfunc() won't see it
		 */
		if (tp->flag & FINUSE) {
			tp->name[0] = '\0';
			/* ensure it won't be found */
			tp->flag &= ~DEFINED;
			tp->flag |= FDELETE;
		} else
			break;
	}

	if (tp->flag & ALLOC) {
		tp->flag &= ~(ISSET|ALLOC);
		tfree(tp->val.t, tp->areap);
	}

	if (t == NULL) {
		/* undefine */
		ktdelete(tp);
		ATRSHMLOG_GETTIME(291,endtime);
		{
		  if (name)
		    {
		  const char *largv[] = {name, NULL};
		  
		    ATRSHMLOG_WRITE2(291, 'I',
				atrshmlogline,
			      starttime,
			      endtime,
				 "undefine",
				 sizeof("undefine") - 1 ,
				    largv,
				    -1);

		    }
		  else
		    ATRSHMLOG_WRITE(291, 'I',
				atrshmlogline,
			      starttime,
			      endtime,
				"undefine empty",
				sizeof("undefine empty") - 1

				);
		    
		}
		return (was_set ? 0 : 1);
	}

	tp->val.t = tcopy(t->left, tp->areap);
	tp->flag |= (ISSET|ALLOC);
	if (t->u.ksh_func)
		tp->flag |= FKSH;

		ATRSHMLOG_GETTIME(292,endtime);
		{
		  if (name)
		    {

		      const char* largv[] = { name, NULL };
		    ATRSHMLOG_WRITE2(292, 'I',
				atrshmlogline,
			      starttime,
			      endtime,
				 "define function",
				 sizeof("define function") - 1,
				    largv,
				    -1
				);
		    }
		  else
		    ATRSHMLOG_WRITE(292, 'I',
				atrshmlogline,
			      starttime,
			      endtime,
				"define empty",
				sizeof("define empty") - 1 

				);
		}
	return (0);
}
/*
 * define function. Returns 1 if function is being undefined (t == 0) and
 * function did not exist, returns 0 otherwise.
 */
define function. Returns 1 if function is being undefined (t == 0) and
function did not exist, returns 0 otherwise.
define function . Returns 1 if function is being undefined ( t == 0 ) and function did not exist returns 0 otherwise .
int
define(const char *name, struct op *t)
{
	uint32_t nhash;
	struct tbl *tp;
	bool was_set = false;
	atrshmlog_time_t starttime;
	atrshmlog_time_t endtime;
	ATRSHMLOG_GETTIME(290,starttime);
	int atrshmlogline = 0;
	if (t)
	  atrshmlogline = t->lineno;
	else
	  atrshmlogline = g_linehint;
	nhash = hash(name);
	while ( 1) {
		tp = findfunc(name, nhash, true);
		if (tp->flag & ISSET)
			was_set = true;
		if (tp->flag & FINUSE) {
			tp->name[0] = '\0';
			tp->flag &= ~DEFINED;
			tp->flag |= FDELETE;
		} else
			break;
	}
	if (tp->flag & ALLOC) {
		tp->flag &= ~(ISSET|ALLOC);
		tfree(tp->val.t, tp->areap);
	}
	if (t == NULL) {
		ktdelete(tp);
		ATRSHMLOG_GETTIME(291,endtime);
		{
		  if (name)
		    {
		  const char *largv[] = {name, NULL};
		    ATRSHMLOG_WRITE2(291, 'I',
				atrshmlogline,
			      starttime,
			      endtime,
				 "undefine",
				 sizeof("undefine") - 1 ,
				    largv,
				    -1);
		    }
		  else
		    ATRSHMLOG_WRITE(291, 'I',
				atrshmlogline,
			      starttime,
			      endtime,
				"undefine empty",
				sizeof("undefine empty") - 1
				);
		}
		return (was_set ? 0 : 1);
	}
	tp->val.t = tcopy(t->left, tp->areap);
	tp->flag |= (ISSET|ALLOC);
	if (t->u.ksh_func)
		tp->flag |= FKSH;
		ATRSHMLOG_GETTIME(292,endtime);
		{
		  if (name)
		    {
		      const char* largv[] = { name, NULL };
		    ATRSHMLOG_WRITE2(292, 'I',
				atrshmlogline,
			      starttime,
			      endtime,
				 "define function",
				 sizeof("define function") - 1,
				    largv,
				    -1
				);
		    }
		  else
		    ATRSHMLOG_WRITE(292, 'I',
				atrshmlogline,
			      starttime,
			      endtime,
				"define empty",
				sizeof("define empty") - 1 
				);
		}
	return (0);
}
int define ( const char * name , struct op * t ) { uint32_t nhash ; struct tbl * tp ; bool was_set = false ; atrshmlog_time_t starttime ; atrshmlog_time_t endtime ; ATRSHMLOG_GETTIME ( 290 , starttime ) ; int atrshmlogline = 0 ; if ( t ) atrshmlogline = t -> lineno ; else atrshmlogline = g_linehint ; nhash = hash ( name ) ; while ( 1 ) { tp = findfunc ( name , nhash , true ) ; if ( tp -> flag & ISSET ) was_set = true ; if ( tp -> flag & FINUSE ) { tp -> name [ 0 ] = ' \0 ' ; tp -> flag &= ~ DEFINED ; tp -> flag |= FDELETE ; } else break ; } if ( tp -> flag & ALLOC ) { tp -> flag &= ~ ( ISSET | ALLOC ) ; tfree ( tp -> val . t , tp -> areap ) ; } if ( t == NULL ) { ktdelete ( tp ) ; ATRSHMLOG_GETTIME ( 291 , endtime ) ; { if ( name ) { const char * largv [ ] = { name , NULL } ; ATRSHMLOG_WRITE2 ( 291 , ' ' , atrshmlogline , starttime , endtime , " " , sizeof ( " " ) - 1 , largv , -1 ) ; } else ATRSHMLOG_WRITE ( 291 , ' ' , atrshmlogline , starttime , endtime , " " , sizeof ( " " ) - 1 ) ; } return ( was_set ? 0 : 1 ) ; } tp -> val . t = tcopy ( t -> left , tp -> areap ) ; tp -> flag |= ( ISSET | ALLOC ) ; if ( t -> u . ksh_func ) tp -> flag |= FKSH ; ATRSHMLOG_GETTIME ( 292 , endtime ) ; { if ( name ) { const char * largv [ ] = { name , NULL } ; ATRSHMLOG_WRITE2 ( 292 , ' ' , atrshmlogline , starttime , endtime , " " , sizeof ( " " ) - 1 , largv , -1 ) ; } else ATRSHMLOG_WRITE ( 292 , ' ' , atrshmlogline , starttime , endtime , " " , sizeof ( " " ) - 1 ) ; } return ( 0 ) ; }
define function.
define function .
/* CONSTCOND */ /*
		 * If this function is currently being executed, we zap
		 * this table entry so findfunc() won't see it
		 */ /* ensure it won't be found */ /* undefine */