default search url [Re: here's 3.0.4.1 RC1]

eocene <[email protected]>
Newsgroups gmane.comp.web.dillo.devel
Message-ID <[email protected]>
Jorge wrote:
> On Mon, Dec 08, 2014 at 12:40:48PM +0100, Sebastian Geerken wrote:
> > It seems that this change fixes it:
> > 
> > ----------------------------------------------------------------------
> > diff -r 9aa37b81c609 src/prefs.c
> > --- a/src/prefs.c       Tue Dec 02 16:33:49 2014 +0100
> > +++ b/src/prefs.c       Mon Dec 08 12:37:15 2014 +0100
> > @@ -18,7 +18,7 @@
> >  #define PREFS_FONT_CURSIVE    "URW Chancery L"
> >  #define PREFS_FONT_FANTASY    "DejaVu Sans" /* TODO: find good default */
> >  #define PREFS_FONT_MONOSPACE  "DejaVu Sans Mono"
> > -#define PREFS_SEARCH_URL      "http://duckduckgo.com/lite/?kp=-1&q=%s"
> > +#define PREFS_SEARCH_URL      "dd http://duckduckgo.com/lite/?kp=-1&q=%s"
> >  #define PREFS_NO_PROXY        "localhost 127.0.0.1"
> >  #define PREFS_SAVE_DIR        "/tmp/"
> >  #define PREFS_HTTP_REFERER    "host"
> > @@ -82,7 +82,6 @@
> >     prefs.save_dir = dStrdup(PREFS_SAVE_DIR);
> >     prefs.search_urls = dList_new(16);
> >     dList_append(prefs.search_urls, dStrdup(PREFS_SEARCH_URL));
> > -   dList_append(prefs.search_urls, NULL); /* flags a default search URL */
> >     prefs.search_url_idx = 0;
> >     prefs.show_back = TRUE;
> >     prefs.show_bookmarks = TRUE;
> > ----------------------------------------------------------------------
> > 
> > Not committed yet, since I'm not sure about the rationale.
> 
>   I'd also add:
> 
> diff -r 978377ed5605 src/uicmd.cc
> --- a/src/uicmd.cc      Mon Dec 08 15:32:25 2014 +0100
> +++ b/src/uicmd.cc      Mon Dec 08 22:58:53 2014 -0300
> @@ -682,7 +682,7 @@ static char *UIcmd_find_search_str(const
>        for (p = 0; p < dList_length(prefs.search_urls); p++) {
>           const char *search =
>              (const char *)dList_nth_data(prefs.search_urls, p);
> -         if (strncasecmp(str, search, len) == 0) {
> +         if (search && strncasecmp(str, search, len) == 0) {
>              prefs.search_url_idx = p;
>              url = UIcmd_make_search_str(str + len + 1);
>              break;
> 
>   (which solves the problem alone), but the cleanups above look
> OK to me since AFAICS:
> 
>   * dd as default prefix for the DDG URL is fine.
>   * the NULL flag item is not used anymore.
>   * dialog.cc explicitly adds the extra item for menu building (n_it+1),
>     so the decreased number of elements is safe.

I was thinking how I would prefer it if the built-in "dd" item would go away
when I have search URLs in dillorc. Looking at prefsparser.cc, there's

      if (dList_length(lp) == 2 && !dList_nth_data(lp, 1)) {
         /* override the default */
         void *data = dList_nth_data(lp, 0);
         dList_remove(lp, data);
         dList_remove(lp, NULL);
         dFree(data);
      }

...so I guess the NULL item was doing something.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.