static void getopts_usage_line( const tr_option * opt, int longWidth, int shortWidth, int argWidth ) { int len; const char * longName = opt->longName ? opt->longName : ""; const char * shortName = opt->shortName ? opt->shortName : ""; const char * arg = getArgName( opt ); const int d_indent = shortWidth + longWidth + argWidth + 7; const int d_width = 80 - d_indent; const char * d = opt->description; printf( " %s%-*s %s%-*s %-*s ", (shortName && *shortName ? "-" : " "), shortWidth, shortName, (longName && *longName ? "--" : " "), longWidth, longName, argWidth, arg ); len = get_next_line_len( d, d_width ); printf( "%*.*s\n", len, len, d ); d += len; while( isspace( *d ) ) ++d; while(( len = get_next_line_len( d, d_width ))) { printf( "%*.*s%*.*s\n", d_indent, d_indent, "", len, len, d ); d += len; while( isspace( *d ) ) ++d; } }
static void getopts_usage_line(tr_option const* opt, int longWidth, int shortWidth, int argWidth) { int len; char const* longName = opt->longName != NULL ? opt->longName : ""; char const* shortName = opt->shortName != NULL ? opt->shortName : ""; char const* arg = getArgName(opt); int const d_indent = shortWidth + longWidth + argWidth + 7; int const d_width = 80 - d_indent; char const* d = opt->description; printf(" %s%-*s %s%-*s %-*s ", (shortName != NULL && *shortName != '\0') ? "-" : " ", shortWidth, shortName, (longName != NULL && *longName != '\0') ? "--" : " ", longWidth, longName, argWidth, arg); len = get_next_line_len(d, d_width); printf("%*.*s\n", len, len, d); d += len; while (isspace(*d)) { ++d; } while ((len = get_next_line_len(d, d_width)) != 0) { printf("%*.*s%*.*s\n", d_indent, d_indent, "", len, len, d); d += len; while (isspace(*d)) { ++d; } } }
static void maxWidth( const struct tr_option * o, int * longWidth, int * shortWidth, int * argWidth ) { const char * arg; if( o->longName ) *longWidth = MAX( *longWidth, (int)strlen( o->longName ) ); if( o->shortName ) *shortWidth = MAX( *shortWidth, (int)strlen( o->shortName ) ); if( ( arg = getArgName( o ) ) ) *argWidth = MAX( *argWidth, (int)strlen( arg ) ); }
static void maxWidth(struct tr_option const* o, int* longWidth, int* shortWidth, int* argWidth) { char const* arg; if (o->longName != NULL) { *longWidth = MAX(*longWidth, (int)strlen(o->longName)); } if (o->shortName != NULL) { *shortWidth = MAX(*shortWidth, (int)strlen(o->shortName)); } if ((arg = getArgName(o)) != NULL) { *argWidth = MAX(*argWidth, (int)strlen(arg)); } }