Project/Real_code/gnu/gawk-3.1.3/eval.c
const char *
genflags2str(int flagval, const struct flagtab *tab)
{
	static char buffer[BUFSIZ];
	char *sp;
	int i, space_left, space_needed;

	sp = buffer;
	space_left = BUFSIZ;
	for (i = 0; tab[i].name != NULL; i++) {
		/*
		 * note the trick, we want 1 or 0 for whether we need
		 * the '|' character.
		 */
		space_needed = (strlen(tab[i].name) + (sp != buffer));
		if (space_left < space_needed)
			fatal(_("buffer overflow in genflags2str"));

		if ((flagval & tab[i].val) != 0) {
			if (sp != buffer) {
				*sp++ = '|';
				space_left--;
			}
			strcpy(sp, tab[i].name);
			/* note ordering! */
			space_left -= strlen(sp);
			sp += strlen(sp);
		}
	}

	return buffer;
}
/* genflags2str --- general routine to convert a flag value to a string */
general routine to convert a flag value to a string
general routine to convert a flag value to a string
const char *
genflags2str(int flagval, const struct flagtab *tab)
{
	static char buffer[BUFSIZ];
	char *sp;
	int i, space_left, space_needed;
	sp = buffer;
	space_left = BUFSIZ;
	for (i = 0; tab[i].name != NULL; i++) {
		space_needed = (strlen(tab[i].name) + (sp != buffer));
		if (space_left < space_needed)
			fatal(_("buffer overflow in genflags2str"));
		if ((flagval & tab[i].val) != 0) {
			if (sp != buffer) {
				*sp++ = '|';
				space_left--;
			}
			strcpy(sp, tab[i].name);
			space_left -= strlen(sp);
			sp += strlen(sp);
		}
	}
	return buffer;
}
const char * genflags2str ( int flagval , const struct flagtab * tab ) { static char buffer [ BUFSIZ ] ; char * sp ; int i , space_left , space_needed ; sp = buffer ; space_left = BUFSIZ ; for ( i = 0 ; tab [ i ] . name != NULL ; i ++ ) { space_needed = ( strlen ( tab [ i ] . name ) + ( sp != buffer ) ) ; if ( space_left < space_needed ) fatal ( _ ( " " ) ) ; if ( ( flagval & tab [ i ] . val ) != 0 ) { if ( sp != buffer ) { * sp ++ = ' ' ; space_left -- ; } strcpy ( sp , tab [ i ] . name ) ; space_left -= strlen ( sp ) ; sp += strlen ( sp ) ; } } return buffer ; }
genflags2str --- general routine to convert a flag value to a string
genflags2str --- general routine to convert a flag value to a string
/*
		 * note the trick, we want 1 or 0 for whether we need
		 * the '|' character.
		 */ /* note ordering! */