Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

htdig: core problem with modified htsearch :(

3 views
Skip to first unread message

Doug

unread,
Jan 21, 1999, 3:00:00 AM1/21/99
to
Well I'm getting closer to my goal, but I have an (what I'm hoping is a
small) error in my code that causes htsearch to "work" in the sense that
sending it a fake test on the command line outputs the desired html, but
it cores every time it runs.

I'm a decent C programmer, but my C++ leaves a lot to be desired. Here
is what I've done:


*** htdig-3.1.0b4/htsearch/Display.cc Tue Dec 22 18:15:39 1998
--- htdig-3.1.0b4-mod/htsearch/Display.cc Wed Jan 20 13:13:22 1999
***************
*** 265,272 ****
{
vars.Add("EXCERPT", excerpt(ref));
}
char *url = match->getURL();
! vars.Add("URL", new String(url));
vars.Add("SCORE", new String(form("%d", match->getScore())));
vars.Add("CURRENT", new String(form("%d", current)));
char *title = ref->DocTitle();
--- 265,280 ----
{
vars.Add("EXCERPT", excerpt(ref));
}
+
char *url = match->getURL();
!
! size_t sn_max_qs_size = 128;
! char *sn_query_string =
"?track=00101.00015.005.00012.001-99010613001212638\0";
!
! char *new_url = strncat(url, sn_query_string, sn_max_qs_size);
!
! vars.Add("URL", new String(new_url));
!
vars.Add("SCORE", new String(form("%d", match->getScore())));
vars.Add("CURRENT", new String(form("%d", current)));
char *title = ref->DocTitle();


This code compiles clean and runs, but produces a core. Here's a look at
the core file with gdb:

#0 0xef64bfcc in t_splay ()
(gdb) where
#0 0xef64bfcc in t_splay ()
#1 0xef64be24 in t_delete ()
#2 0xef64bab8 in realfree ()
#3 0xef64c28c in _free_unlocked ()
#4 0xef64c1c0 in free ()
#5 0xbf100 in ___builtin_delete (ptr=0x125538)
#6 0x37ba8 in Object::~Object (this=0x125538, __in_chrg=3) at
Object.cc:34
#7 0x38af0 in String::~String (this=0x125538, __in_chrg=3) at
String.cc:120
#8 0x374c0 in List::Destroy (this=0xefffef4c) at List.cc:69
#9 0x37428 in List::~List (this=0xefffef4c, __in_chrg=2) at List.cc:35
#10 0x295d0 in TemplateList::~TemplateList (this=0xefffef30,
__in_chrg=2) at TemplateList.cc:31
#11 0x238b4 in Display::~Display (this=0xefffea88, __in_chrg=2) at
Display.cc:158
#12 0x2b094 in main (ac=1, av=0xeffffcec) at htsearch.cc:298

As always I'm grateful for any help.

Doug
----------------------------------------------------------------------
To unsubscribe from the htdig mailing list, send a message to
htdig-...@sdsu.edu containing the single word "unsubscribe" in
the body of the message.

Gilles Detillieux

unread,
Jan 21, 1999, 3:00:00 AM1/21/99
to
According to Doug:

Yikes! NO! You can't just overwrite the string returned by
match->getURL(), as you're doing with strncat(), because you have no idea
how much extra memory is available in the string. I haven't tested this,
but I think what you want is something more like:

char *url = match->getURL();

String *new_url = new String(url);
*new_url << "?track=00101.00015.005.00012.001-99010613001212638";
vars.Add("URL", new_url);


--
Gilles R. Detillieux E-mail: <grd...@scrc.umanitoba.ca>
Spinal Cord Research Centre WWW: http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba Phone: (204)789-3766
Winnipeg, MB R3E 3J7 (Canada) Fax: (204)789-3930

Doug

unread,
Jan 21, 1999, 3:00:00 AM1/21/99
to
Gilles Detillieux wrote:

> Yikes! NO! You can't just overwrite the string returned by
> match->getURL(), as you're doing with strncat(), because you have no idea
> how much extra memory is available in the string. I haven't tested this,
> but I think what you want is something more like:
>
> char *url = match->getURL();
> String *new_url = new String(url);
> *new_url << "?track=00101.00015.005.00012.001-99010613001212638";
> vars.Add("URL", new_url);

As I expressed to him in a private reply, Gilles is a lifesaver. :)
This was indeed my problem, and after long experimentation I finally hit
on a slightly different solution that works very well, but I wouldn't
have gotten where I am were it not for the help I received.

What I ended up doing is passing the string I want to append as a CGI
variable, sucking that into htsearch.cc, then setting up a htdig
variable in Display.cc with that value. Now I can use my tracking number
string in the header/footer/syntax/nomatch documents, and I've created a
template for the results that does exactly what I want. If there is
interest I will post a patch, but as all good solutions are *after* you
arrive at them it turned out to be very simple. :)

many many thanks,

Doug

0 new messages