From: Nguyen Thai Ngoc Duy Date: Wed, 06 Jun 2007 11:07:35 GMT Subject: Re: [PATCH 1/2] Show html help with git-help --html Message-ID: In-Reply-To: <7vzm3e9lui.fsf@assigned-by-dhcp.cox.net> On 6/5/07, Junio C Hamano wrote: > Nguyen Thai Ngoc Duy writes: > > > This patch was inspired by ClearCase command 'ct man',... > > > diff --git a/help.c b/help.c > > index 6a9af4d..78b1023 100644 > > --- a/help.c > > +++ b/help.c > > @@ -9,6 +9,14 @@ > > #include "common-cmds.h" > > #include > > > > +#ifndef HTML_DIR > > +#define HTML_DIR "/usr/share/html/" > > +#endif > > + > > +#ifndef HTML_PROGRAM > > +#define HTML_PROGRAM "xdg-open" > > +#endif > > + > > /* most GUI terminals set COLUMNS (although some don't export it) */ > > static int term_columns(void) > > { > > @@ -183,6 +191,145 @@ static void show_man_page(const char *git_cmd) > > execlp("man", "man", page, NULL); > > } > > > > +static void show_html_page(const char *git_cmd) > > +{ > > + const char *html_dir; > > + int len, ret, nr_quotes; > > + char *p, *p2; > > + const char *cp, *cp2; > > + struct stat st; > > + char *quoted_git_cmd; > > + char *default_command = NULL; > > + const char *command; > >... > > + /* append %p if there is not any %x */ > > + if (!strchr(command, '%')) { > > + len = strlen(command); > > + default_command = xmalloc(len + 3 + 1); /* space %p */ > > + strcpy(default_command, command); > > + strcat(default_command, " %p"); > > + command = default_command; > > + } > > + > > + /* first pass, calculate command length */ > > ... > > Hmmm. Makes one wonder why interpolate is not used.... Sorry for my ignorant. I have no idea where to use interpolate :( Did you mean to pretend adding %p to command without alloc new buffer (default_command) ? -- Duy