summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-04-30 21:12:26 -0400
committermidipix <writeonce@midipix.org>2016-04-30 23:59:56 -0400
commitd0f5ac36408555384026cb7ae9b3952104b4b9bf (patch)
tree3e202ffd65c4630f531eeaaddd6d0cbbd44ba5be /src
parent59a248c4e2bc12912766414254d880f43050b469 (diff)
downloadapimagic-d0f5ac36408555384026cb7ae9b3952104b4b9bf.tar.bz2
apimagic-d0f5ac36408555384026cb7ae9b3952104b4b9bf.tar.xz
argv.h: usage screen generator: remove the paradigm-supporting implementation.
The idea was nice, the functionality was helpful for development, yet the resulting layout and overall appearance were rather awful. Regardless of the effort that was put into this sophisticated flavor of the usage screen generator, and despite it's utility for debugging, it is now being replaced with a simpler, two-field-only variant.
Diffstat (limited to 'src')
-rw-r--r--src/internal/argv/argv.h331
1 files changed, 0 insertions, 331 deletions
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h
index 21d1271..994b79f 100644
--- a/src/internal/argv/argv.h
+++ b/src/internal/argv/argv.h
@@ -735,337 +735,6 @@ static void argv_usage(
const struct argv_option options[],
const char * mode)
{
- const struct argv_option * option;
- bool fshort,flong;
- bool fnewline;
- size_t len,optlen;
- size_t paralen,rparalen,mparalen;
- size_t desclen,rdesclen;
-
- char * para;
- char * next_para;
- char * desc;
- char * next_desc;
- char * paradigm;
- char * buf;
- size_t buflen;
- const char * sdescription;
- const char * sargname;
-
- const char indent[] = " ";
- const int rblen = sizeof("}") - sizeof(char);
- const int rbblen = sizeof("{]") - sizeof(char);
- const int brcklen= sizeof("[]") - sizeof(char);
- const int solen = sizeof("-") - sizeof(char);
- const int lolen = sizeof("--") - sizeof(char);
- const int slolen = sizeof("-X,--") - sizeof(char);
-
- fshort = mode ? !strcmp(mode,"short") : 0;
- flong = fshort ? 0 : mode && !strcmp(mode,"long");
-
- if (header)
- fprintf(stdout,"%s",header);
-
- optlen = 0;
- paralen = 0;
-
- for (option=options; option->short_name || option->long_name; option++) {
- if (fshort)
- len = option->short_name ? sizeof(char) + solen : 0;
- else if (flong)
- len = option->long_name ? strlen(option->long_name) + lolen : 0;
- else
- len = option->long_name ? strlen(option->long_name) + slolen : 0;
-
- if (len) {
- if (len > optlen)
- optlen = len;
-
- if (option->argname)
- len = strlen(option->argname);
- else if (option->paradigm)
- len = strlen(option->paradigm) + strlen("{}");
- else if (option->optarg != ARGV_OPTARG_NONE)
- len = strlen("<val>");
-
- if (option->optarg == ARGV_OPTARG_OPTIONAL)
- len += strlen("[]");
-
- if (len > paralen)
- paralen = len;
- }
- }
-
- optlen += ARGV_TAB_WIDTH;
- optlen &= (~(ARGV_TAB_WIDTH-1));
-
- paradigm = next_para = buf = 0;
- fnewline = false;
- rparalen = 0;
- mparalen = 0;
-
- if (paralen) {
- paralen += (ARGV_TAB_WIDTH);
- paralen &= (~(ARGV_TAB_WIDTH-1));
- mparalen = paralen + 2*rbblen;
-
- if (optlen + paralen > 64)
- paralen = 32;
- }
-
- /* account for ' ','\t', try to fit in 80 or 96 columns */
- if (optlen+paralen+2+ARGV_TAB_WIDTH < 80-32)
- desclen = 80 - (optlen+paralen+2+ARGV_TAB_WIDTH);
- else if (optlen+paralen+2+ARGV_TAB_WIDTH < 96-32)
- desclen = 96 - (optlen+paralen+2+ARGV_TAB_WIDTH);
- else
- desclen = 32;
-
- buflen = 0;
- rdesclen = 1;
-
- for (option=options; option->short_name || option->long_name; option++) {
- if (fshort && !option->short_name)
- continue;
- else if (flong && !option->long_name)
- continue;
-
- if (option->paradigm) {
- if (option->optarg == ARGV_OPTARG_OPTIONAL)
- rparalen = strlen(option->paradigm) - 2*rbblen;
- else
- rparalen = strlen(option->paradigm) - 2*rblen;
- }
-
- sdescription = option->description ? option->description : "";
- sargname = option->argname ? option->argname : "";
-
- if (option->paradigm)
- rdesclen = snprintf(buf,buflen,sdescription,option->paradigm);
- else
- rdesclen = snprintf(buf,buflen,sdescription,sargname);
-
- if (fnewline)
- (void)0;
-
- if ((rparalen > paralen) || (rdesclen > desclen)) {
- if (!fnewline) {
- (void)0;
- fnewline = true;
- }
- } else
- fnewline = false;
-
- if (fshort)
- fprintf(file,"%s-%-*c",indent,(int)(optlen-solen),option->short_name);
- else if (flong)
- fprintf(file,
- (option->flags & ARGV_OPTION_HYBRID_ONLY)
- ? "%s -%-*s"
- : "%s--%-*s",
- indent,(int)(optlen-lolen),option->long_name);
- else {
- if (option->short_name && option->long_name)
- fprintf(file,
- (option->flags & ARGV_OPTION_HYBRID_ONLY)
- ? "%s-%c, -%-*s"
- : "%s-%c,--%-*s",
- indent,option->short_name,
- (int)(optlen-slolen),option->long_name);
- else if (option->short_name)
- fprintf(file,"%s-%-*c",
- indent,(int)(optlen-solen),option->short_name);
- else
- fprintf(file,
- (option->flags & ARGV_OPTION_HYBRID_ONLY)
- ? "%s%3s -%-*s"
- : "%s%3s--%-*s",
- indent,"",
- (int)(optlen-slolen),option->long_name);
- }
-
- if (rdesclen > buflen) {
- if (buf) {
- free(buf);
- buf = 0;
- }
-
- len = rdesclen + 512;
- len &= (~511);
-
- if ((buf = calloc(1,len))) {
- buflen = len;
-
- if (option->paradigm)
- rdesclen = snprintf(buf,buflen,
- option->description,
- option->paradigm);
- else
- rdesclen = snprintf(buf,buflen,
- option->description,
- option->argname);
- } else {
- buflen = 0;
- continue;
- }
- }
-
- para = 0;
- next_para = 0;
-
- if (option->argname) {
- if (option->optarg == ARGV_OPTARG_OPTIONAL)
- fprintf(file,"[%s]%-*c",
- option->argname,
- (int)(paralen-strlen(option->argname)-brcklen),' ');
- else
- fprintf(file,"%s%-*c",
- option->argname,
- (int)(paralen-strlen(option->argname)),' ');
- } else if (option->paradigm && (rparalen <= paralen)) {
- if (option->optarg == ARGV_OPTARG_OPTIONAL)
- fprintf(file,"[{%s}]%-*c",
- option->paradigm,
- (int)(paralen-strlen(option->paradigm)-2*rbblen),' ');
- else
- fprintf(file,"{%s}%-*c",
- option->paradigm,
- (int)(paralen-strlen(option->paradigm)-rbblen),' ');
- } else if (option->paradigm) {
- if (!paradigm && !(paradigm = calloc(1,mparalen))) {
- fputc('\n',file);
- continue;
- } else
- para = strcpy(paradigm,option->paradigm);
-
- if (option->optarg == ARGV_OPTARG_OPTIONAL) {
- fputs("[{",file);
- rparalen = paralen - rbblen;
- } else {
- fputc('{',file);
- rparalen = paralen - rblen;
- }
- } else
- fprintf(file,"%-*c",(int)paralen,' ');
-
-
- if (!para && option->description && rdesclen <= desclen) {
- fputc('\t',file);
- fputs(buf,file);
- desc = (char *)0;
- } else if (option->description)
- desc = buf;
- else
- desc = (char *)0;
-
- while (para || desc) {
- if (para && next_para) {
- if (option->optarg == ARGV_OPTARG_OPTIONAL) {
- if (rparalen+2*rbblen <= paralen) {
- fprintf(file," %s}]%-*c",para,
- (int)(paralen-rparalen)
- - 2*rbblen,' ');
- para = (char *)0;
- }
- } else {
- if (rparalen+2*rblen <= paralen) {
- fprintf(file," %s}%-*c",para,
- (int)(paralen-rparalen)
- - 2*rblen,' ');
- para = (char *)0;
- }
- }
- }
-
- if (para) {
- next_para = para+rparalen-1;
-
- for (; (next_para>para) && (*next_para!='|'); )
- next_para--;
-
- if (para > paradigm) {
- if (option->optarg == ARGV_OPTARG_OPTIONAL)
- fputs(" ",file);
- else
- fputc(' ',file);
- }
-
- if (*next_para != '|') {
- fprintf(file,"%s",para);
- para = (char *)0;
- } else if (next_para > para) {
- *next_para = '\0';
- fprintf(file,"%-*s",(int)rparalen,para);
- *next_para = '|';
- para = next_para;
- rparalen = strlen(para);
-
- /* 2*rbblen,2*rblen, etc.: account for indentation */
- if (option->optarg == ARGV_OPTARG_OPTIONAL)
- rparalen = (rparalen+2*rbblen > paralen)
- ? paralen-rbblen
- : rparalen;
- else
- rparalen = (rparalen+2*rblen > paralen)
- ? paralen-rblen
- : rparalen;
- } else {
- if (option->optarg == ARGV_OPTARG_OPTIONAL)
- fprintf(file,"%s}]%-*c",para,
- (int)(paralen-strlen(para)-rbblen),' ');
- else
- fprintf(file,"%s}%-*c",para,
- (int)(paralen-strlen(para)-rblen),' ');
- para = (char *)0;
- }
- } else if (next_para && (desc > buf))
- next_para = (char *)0;
- else if (desc > buf)
- fprintf(file,"%-*c",(int)paralen,' ');
-
- if (desc) {
- if (desc > buf)
- fputs("\t ",file);
- else
- fputc('\t',file);
-
- if ((rdesclen = strlen(desc)+(desc>buf)) <= desclen) {
- fputs(desc,file);
- desc = (char *)0;
- } else {
- next_desc = desc + desclen - 1;
-
- for (; (next_desc > desc)
- && (*next_desc != ' ')
- && (*next_desc != '\n'); )
- next_desc--;
-
- if ((*next_desc != ' ') && (*next_desc!='\n')) {
- fputs(desc,file);
- desc = (char *)0;
- } else if (next_desc > desc) {
- *next_desc = '\0';
- fputs(desc,file);
- desc = ++next_desc;
- } else {
- fputs(desc,file);
- desc = (char *)0;
- }
- }
- }
-
- if (para || desc)
- fprintf(file,"\n%s%-*c",indent,(int)optlen,' ');
- }
-
- fputc('\n',file);
- }
-
- if (paradigm)
- free(paradigm);
-
- if (buf)
- free(buf);
}
#endif