Esempio n. 1
0
char *fmt_build(char *fmt,attribute att) {
/* fmt_build
 * Builds a format string for printing out an attribute or value of
 * specified size
 */
	int tabs=0;
	char *spacing_var;

    spacing_var=resolve_variable("width");
    if (spacing_var!=NULL) {
        if (strcmp(spacing_var,"auto")==0) {
            tabs=0;
        } else if (strcmp(spacing_var,"tab")==0) {
            tabs=-1;
        } else {
            tabs=atoi(spacing_var);
        }
    }

	if ( (att->attrib_size>0) && (tabs==0) )
		if ( (attribute_type(att)==DT_BOOLEAN) ) {
			sprintf(fmt,"%%-5.5s ");
		} else {
			sprintf(fmt,"%%-%d.%ds ",att->attrib_size,att->attrib_size);
		}
	else if  ( (att->attrib_size<=0)
			 || (tabs==-1) ) {
		sprintf(fmt,"%%s \t");
	} else {
		sprintf(fmt,"%%-%d.%ds ",tabs,tabs);
	}

	return(fmt);

}
Esempio n. 2
0
/******************************************************************************
    num_op := num rest_num_op
              ( expr ) rest_num_op
 *****************************************************************************/
void
parse_num_op( val_t* val )
{
    printtab();
    dprintf("parse_num_op()\n");
    level++;

    if ( match_num( val ) ) {
        parse_rest_num_op( val );
    } else if ( match_variable( val ) ) {
        resolve_variable( val );
        parse_rest_num_op( val );
    } else if ( match_char( '(' ) ) {
        parse_expr( val );
        if ( !match_char( ')' ) ) {
            buffer[bpos] = 0;
            printf("Missing bracket: %s\n", buffer);
            longjmp( env, 1 );
        }
        parse_rest_num_op( val );
    } else {
        buffer[bpos] = 0;
        printf("Parse error: %s\n", buffer);
        longjmp( env, 1 );
    }
    
    level--;

    return;
}