Parse user-defined macros before the global ones (closes: #5587). Index: man-1.6g/man2html/man2html.c =================================================================== --- man-1.6g.orig/man2html/man2html.c 2011-01-09 11:20:58.000000000 +0100 +++ man-1.6g/man2html/man2html.c 2011-01-09 11:21:22.000000000 +0100 @@ -1697,7 +1697,42 @@ c = scan_escape(c+1); } else { i=V(c[0],c[1]); - switch (i) { + /* search macro database of self-defined macros */ + owndef = find_longstrdef(defdef, i, c, NULL); + if (owndef) { + char **oldargument; + int deflen; + int onff; + sl=fill_words(c+strlen(owndef->longname), wordlist, SIZE(wordlist), &words, '\n'); + c=sl+1; + *sl=0; + for (i=1; i<words; i++) + wordlist[i][-1]=0; + for (i=0; i<words; i++) { + char *h=NULL; + if (mandoc_command) + scan_troff_mandoc(wordlist[i],1,&h); + else + scan_troff(wordlist[i],1,&h); + wordlist[i]=h; + } + for (i=words; i<SIZE(wordlist); i++) + wordlist[i]=NULL; + deflen = strlen(owndef->st); + owndef->st[deflen+1]='a'; + for (i=0; (owndef->st[deflen+2+i] = owndef->st[i]); i++); + oldargument=argument; + argument=wordlist; + onff=newline_for_fun; + if (mandoc_command) + scan_troff_mandoc(owndef->st+deflen+2, 0, NULL); + else + scan_troff(owndef->st+deflen+2, 0, NULL); + newline_for_fun=onff; + argument=oldargument; + for (i=0; i<words; i++) if (wordlist[i]) free(wordlist[i]); + *sl='\n'; + } else switch (i) { case V('a','b'): h=c+j; while (*h && *h !='\n') h++; @@ -2894,42 +2929,7 @@ /* ----- end of BSD mandoc stuff ----- */ default: - /* search macro database of self-defined macros */ - owndef = find_longstrdef(defdef, i, c, NULL); - if (owndef) { - char **oldargument; - int deflen; - int onff; - sl=fill_words(c+strlen(owndef->longname), wordlist, SIZE(wordlist), &words, '\n'); - c=sl+1; - *sl=0; - for (i=1; i<words; i++) - wordlist[i][-1]=0; - for (i=0; i<words; i++) { - char *h=NULL; - if (mandoc_command) - scan_troff_mandoc(wordlist[i],1,&h); - else - scan_troff(wordlist[i],1,&h); - wordlist[i]=h; - } - for (i=words; i<SIZE(wordlist); i++) - wordlist[i]=NULL; - deflen = strlen(owndef->st); - owndef->st[deflen+1]='a'; - for (i=0; (owndef->st[deflen+2+i] = owndef->st[i]); i++); - oldargument=argument; - argument=wordlist; - onff=newline_for_fun; - if (mandoc_command) - scan_troff_mandoc(owndef->st+deflen+2, 0, NULL); - else - scan_troff(owndef->st+deflen+2, 0, NULL); - newline_for_fun=onff; - argument=oldargument; - for (i=0; i<words; i++) if (wordlist[i]) free(wordlist[i]); - *sl='\n'; - } else if (mandoc_command && + if (mandoc_command && ((isupper(*c) && islower(c[1])) || (islower(*c) && isupper(c[1])))) { /*