FreeBSD/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
/*
 * GCC and DevPro use different names for the base types.  While the terms are
 * the same, they are arranged in a different order.  Some terms, such as int,
 * are implied in one, and explicitly named in the other.  Given a base type
 * as input, this routine will return a common name, along with an intr_t
 * that reflects said name.
 */
GCC and DevPro use different names for the base types.  While the terms are
the same, they are arranged in a different order.  Some terms, such as int,
are implied in one, and explicitly named in the other.  Given a base type
as input, this routine will return a common name, along with an intr_t
that reflects said name.
GCC and DevPro use different names for the base types . While the terms are the same they are arranged in a different order . Some terms such as int are implied in one and explicitly named in the other . Given a base type as input this routine will return a common name along with an intr_t that reflects said name .
static intr_t *
die_base_name_parse(const char *name, char **newp)
{
	char buf[100];
	char const *base;
	char *c;
	int nlong = 0, nshort = 0, nchar = 0, nint = 0;
	int sign = 1;
	char fmt = '\0';
	intr_t *intr;
	if (strlen(name) > sizeof (buf) - 1)
		terminate("base type name \"%s\" is too long\n", name);
	strncpy(buf, name, sizeof (buf));
	for (c = strtok(buf, " "); c != NULL; c = strtok(NULL, " ")) {
		if (strcmp(c, "signed") == 0)
			sign = 1;
		else if (strcmp(c, "unsigned") == 0)
			sign = 0;
		else if (strcmp(c, "long") == 0)
			nlong++;
		else if (strcmp(c, "char") == 0) {
			nchar++;
			fmt = 'c';
		} else if (strcmp(c, "short") == 0)
			nshort++;
		else if (strcmp(c, "int") == 0)
			nint++;
		else {
			return (NULL);
		}
	}
	if (nchar > 1 || nshort > 1 || nint > 1 || nlong > 2)
		return (NULL);
	if (nchar > 0) {
		if (nlong > 0 || nshort > 0 || nint > 0)
			return (NULL);
		base = "char";
	} else if (nshort > 0) {
		if (nlong > 0)
			return (NULL);
		base = "short";
	} else if (nlong > 0) {
		base = "long";
	} else {
		base = "int";
	}
	intr = xcalloc(sizeof (intr_t));
	intr->intr_type = INTR_INT;
	intr->intr_signed = sign;
	intr->intr_iformat = fmt;
	snprintf(buf, sizeof (buf), "%s%s%s",
	    (sign ? "" : "unsigned "),
	    (nlong > 1 ? "long " : ""),
	    base);
	*newp = xstrdup(buf);
	return (intr);
}
static intr_t * die_base_name_parse ( const char * name , char * * newp ) { char buf [ 100 ] ; char const * base ; char * c ; int nlong = 0 , nshort = 0 , nchar = 0 , nint = 0 ; int sign = 1 ; char fmt = ' \0 ' ; intr_t * intr ; if ( strlen ( name ) > sizeof ( buf ) - 1 ) terminate ( " \" \" \n " , name ) ; strncpy ( buf , name , sizeof ( buf ) ) ; for ( c = strtok ( buf , " " ) ; c != NULL ; c = strtok ( NULL , " " ) ) { if ( strcmp ( c , " " ) == 0 ) sign = 1 ; else if ( strcmp ( c , " " ) == 0 ) sign = 0 ; else if ( strcmp ( c , " " ) == 0 ) nlong ++ ; else if ( strcmp ( c , " " ) == 0 ) { nchar ++ ; fmt = ' ' ; } else if ( strcmp ( c , " " ) == 0 ) nshort ++ ; else if ( strcmp ( c , " " ) == 0 ) nint ++ ; else { return ( NULL ) ; } } if ( nchar > 1 || nshort > 1 || nint > 1 || nlong > 2 ) return ( NULL ) ; if ( nchar > 0 ) { if ( nlong > 0 || nshort > 0 || nint > 0 ) return ( NULL ) ; base = " " ; } else if ( nshort > 0 ) { if ( nlong > 0 ) return ( NULL ) ; base = " " ; } else if ( nlong > 0 ) { base = " " ; } else { base = " " ; } intr = xcalloc ( sizeof ( intr_t ) ) ; intr -> intr_type = INTR_INT ; intr -> intr_signed = sign ; intr -> intr_iformat = fmt ; snprintf ( buf , sizeof ( buf ) , " " , ( sign ? " " : " " ) , ( nlong > 1 ? " " : " " ) , base ) ; * newp = xstrdup ( buf ) ; return ( intr ) ; }
GCC and DevPro use different names for the base types.
GCC and DevPro use different names for the base types .
/*
			 * If we don't recognize any of the tokens, we'll tell
			 * the caller to fall back to the dwarf-provided
			 * encoding information.
			 */