From hpdeifel at gmx.de Tue Apr 12 15:08:32 2011 From: hpdeifel at gmx.de (Hans-Peter Deifel) Date: Tue, 12 Apr 2011 17:08:32 +0200 Subject: [Vimprobable-users] [PATCH 2/5] Make search engines configurable In-Reply-To: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> References: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> Message-ID: <1302620915-28950-3-git-send-email-hpdeifel@gmx.de> - The new search engines configuration file is read and validated on startup - These search engines take precedence over those from config.h, when looking up shortcuts --- main.c | 40 +++++++++++++++---- utilities.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ utilities.h | 10 +++++ 3 files changed, 163 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 4a1caf8..6de2be4 100644 --- a/main.c +++ b/main.c @@ -1079,6 +1079,7 @@ open_arg(const Arg *arg) { char *s = arg->s, *p = NULL, *new; Arg a = { .i = NavigationReload }; int len, i; + char *search_uri, *search_term; if (embed) { argv[0] = *args; @@ -1103,14 +1104,16 @@ open_arg(const Arg *arg) { *(p + 1) = '\0'; len = strlen(s); new = NULL, p = strchr(s, ' '); - if (p) /* check for search engines */ - for (i = 0; i < LENGTH(searchengines); i++) - if (!strncmp(s, searchengines[i].handle, p - s)) { - p = soup_uri_encode(++p, "&"); - new = g_strdup_printf(searchengines[i].uri, p); - g_free(p); - break; - } + if (p) { /* check for search engines */ + *p = '\0'; + search_uri = find_uri_for_searchengine(s); + if (search_uri != NULL) { + search_term = soup_uri_encode(p+1, "&"); + new = g_strdup_printf(search_uri, search_term); + g_free(search_term); + } + *p = ' '; + } if (!new) { if (len > 3 && strstr(s, "://")) { /* valid url? */ p = new = g_malloc(len + 1); @@ -2312,6 +2315,7 @@ main(int argc, char *argv[]) { static gboolean ver = false; static gboolean configfile_exists = FALSE; static const char *cfile = NULL; + char *searchengines_file; static GOptionEntry opts[] = { { "version", 'v', 0, G_OPTION_ARG_NONE, &ver, "print version", NULL }, { "embed", 'e', 0, G_OPTION_ARG_STRING, &winid, "embedded", NULL }, @@ -2372,6 +2376,26 @@ main(int argc, char *argv[]) { g_free(configfile); } + make_searchengines_list(searchengines, LENGTH(searchengines)); + + /* read searchengines. */ + searchengines_file = g_strdup_printf(SEARCHENGINES_STORAGE_FILENAME); + switch (read_searchengines(searchengines_file)) { + case SYNTAX_ERROR: + a.i = Error; + a.s = g_strdup_printf("Syntax error in searchengines file '%s'", searchengines_file); + echo(&a); + break; + case READING_FAILED: + a.i = Error; + a.s = g_strdup_printf("Could not read searchengines file '%s'", searchengines_file); + echo(&a); + break; + default: + break; + } + g_free(searchengines_file); + /* command line argument: URL */ if (argc > 1) { strncpy(url, argv[argc - 1], 255); diff --git a/utilities.c b/utilities.c index 74d0883..636ba4b 100644 --- a/utilities.c +++ b/utilities.c @@ -19,6 +19,7 @@ extern KeyList *keylistroot; extern Key keys[]; extern char *error_msg; extern gboolean complete_case_sensitive; +static GList *dynamic_searchengines = NULL; gboolean read_rcfile(const char *config) { @@ -639,3 +640,123 @@ count_list(Listelement *elementlist) return n; } + +/* return TRUE, if the string contains exactly one unescaped %s and no other + * printf directives */ +static gboolean sanity_check_search_url(const char *string) +{ + int was_percent_char = 0, percent_s_count = 0; + + for (; *string; string++) { + switch (*string) { + case '%': + was_percent_char = !was_percent_char; + break; + case 's': + if (was_percent_char) + percent_s_count++; + was_percent_char = 0; + break; + default: + if (was_percent_char) + return FALSE; + was_percent_char = 0; + break; + } + } + + return !was_percent_char && percent_s_count == 1; +} + +enum ConfigFileError +read_searchengines(const char *filename) +{ + FILE *file; + char buffer[BUFFERSIZE]; + char *name_ptr, *url_ptr; + gboolean found_malformed_lines = FALSE, + line_too_long = FALSE; + int length; + Searchengine *new; + + if (access(filename, F_OK) != 0) + return FILE_NOT_FOUND; + + file = fopen(filename, "r"); + if (file == NULL) + return READING_FAILED; + + while (fgets(buffer, BUFFERSIZE, file)){ + /* ignore lines longer then BUFFERSIZE */ + length = strlen(buffer); + if (length == 0 || buffer[length-1] != '\n') { + line_too_long = TRUE; + found_malformed_lines = TRUE; + continue; + } + + /* continuation of long line */ + if (line_too_long) { + line_too_long = FALSE; + continue; + } + + name_ptr = strtok(buffer, " \t\n"); + url_ptr = strtok(NULL, "\n"); + if (url_ptr) + g_strstrip(url_ptr); + + if (name_ptr == NULL || url_ptr == NULL + || !sanity_check_search_url(url_ptr)) { + found_malformed_lines = TRUE; + continue; + } + + new = malloc(sizeof(Searchengine)); + if (new == NULL) { + fprintf(stderr, "Memory exhausted while loading search engines.\n"); + exit(EXIT_FAILURE); + } + + new->handle = g_strdup(name_ptr); + new->uri = g_strdup(url_ptr); + + dynamic_searchengines = g_list_prepend(dynamic_searchengines, new); + } + + if (ferror(file)) { + fclose(file); + return READING_FAILED; + } + + fclose(file); + + return found_malformed_lines ? SYNTAX_ERROR : SUCCESS; +} + +void make_searchengines_list(Searchengine *searchengines, int length) +{ + int i; + for (i = 0; i < length; i++, searchengines++) { + dynamic_searchengines = g_list_prepend(dynamic_searchengines, searchengines); + } +} + +/* find a searchengine with a given handle and return its URI or NULL if + * nothing is found. + * The returned string is internal and must not be freed or modified. */ +char *find_uri_for_searchengine(const char *handle) +{ + GList *l; + + if (dynamic_searchengines != NULL) { + for (l = dynamic_searchengines; l; l = g_list_next(l)) { + Searchengine *s = (Searchengine*)l->data; + if (!strcmp(s->handle, handle)) { + return s->uri; + } + } + } + + return NULL; +} diff --git a/utilities.h b/utilities.h index 261d213..dc1ef96 100644 --- a/utilities.h +++ b/utilities.h @@ -30,3 +30,13 @@ Listelement * complete_list(const char *searchfor, const int mode, Listelement * Listelement * add_list(const char *element, Listelement *elementlist); int count_list(Listelement *elementlist); void free_list(Listelement *elementlist); + +enum ConfigFileError { + SUCCESS = 0, + FILE_NOT_FOUND = -1, + READING_FAILED = -2, + SYNTAX_ERROR = -3 +}; +enum ConfigFileError read_searchengines(const char *filename); +char *find_uri_for_searchengine(const char *handle); +void make_searchengines_list(Searchengine *searchengines, int length); -- 1.7.3.4 From hpdeifel at gmx.de Tue Apr 12 15:08:33 2011 From: hpdeifel at gmx.de (Hans-Peter Deifel) Date: Tue, 12 Apr 2011 17:08:33 +0200 Subject: [Vimprobable-users] [PATCH 3/5] Mention search engines in the man page In-Reply-To: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> References: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> Message-ID: <1302620915-28950-4-git-send-email-hpdeifel@gmx.de> --- vimprobable2.1 | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/vimprobable2.1 b/vimprobable2.1 index 71f2c49..576524b 100644 --- a/vimprobable2.1 +++ b/vimprobable2.1 @@ -265,6 +265,36 @@ Store current URI as quickmark 4 q4 Recall quickmark 4 +.SH SEARCHENGINES + +Searchengines let you submit queries to web search engines and similar sites +without having to type the complete URL or visit the page first. + +For example, if +.I ex +is defined as the shortcut for the search at example.com, you can use "ex +search term" instead of an URL to search there for "search term". + +Some search engines (and thus shortcuts) are already defined in config.h, but +you can always overwrite them or define your own in +.I $HOME/.config/vimprobable/searchengines. + +In this file, every line defines one shortcut for one URL in this format +(without the angle brackets): + +.RS 4 + +.RE + +where the %s serves as a placeholder for the search term\&. + +.B Default search engine + +If Vimprobable doesn't recognize an address as a valid URL or query to one of the +defined search engines, it will use the default search engine instead. See +.BR vimprobablerc (1) +on how to set this default. + .SH FILES Please make sure you create these files before running the browser. @@ -275,6 +305,8 @@ file is required if you want to use cookies. .I $HOME/.config/vimprobable/bookmarks +.I $HOME/.config/vimprobable/searchengines + .I $HOME/.config/vimprobable/cookies .I $HOME/.config/vimprobable/history -- 1.7.3.4 From hpdeifel at gmx.de Tue Apr 12 15:08:34 2011 From: hpdeifel at gmx.de (Hans-Peter Deifel) Date: Tue, 12 Apr 2011 17:08:34 +0200 Subject: [Vimprobable-users] [PATCH 4/5] Make the default search engine configurable In-Reply-To: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> References: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> Message-ID: <1302620915-28950-5-git-send-email-hpdeifel@gmx.de> This introduces the new setting 'defaultsearch' --- config.h | 4 +++- main.c | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config.h b/config.h index 04af99c..78f32e8 100644 --- a/config.h +++ b/config.h @@ -86,7 +86,8 @@ static Searchengine searchengines[] = { { "w", "https://secure.wikimedia.org/wikipedia/en/w/index.php?title=Special%%3ASearch&search=%s&go=Go" }, { "wd", "https://secure.wikimedia.org/wikipedia/de/w/index.php?title=Special%%3ASearch&search=%s&go=Go" }, }; -static Searchengine *defsearch = &searchengines[0]; + +static char defaultsearch[1024] = "i"; /* command mapping */ Command commands[COMMANDSIZE] = { @@ -176,6 +177,7 @@ static Setting browsersettings[] = { { "sslbgcolor", sslbgcolor, "", FALSE, FALSE, TRUE, TRUE }, { "sslcolor", sslcolor, "", FALSE, FALSE, TRUE, TRUE }, { "acceptlanguage", acceptlanguage, "", FALSE, FALSE, FALSE, FALSE }, + { "defaultsearch", defaultsearch, "", FALSE, FALSE, FALSE, FALSE }, { "qmark", NULL, "", FALSE, FALSE, FALSE, FALSE }, { "proxy", NULL, "", FALSE, TRUE, FALSE, FALSE }, { "scrollbars", NULL, "", FALSE, TRUE, FALSE, FALSE }, diff --git a/main.c b/main.c index 6de2be4..d0495a5 100644 --- a/main.c +++ b/main.c @@ -1128,9 +1128,12 @@ open_arg(const Arg *arg) { strcpy(new, "file://"); memcpy(&new[sizeof("file://") - 1], s, len + 1); } else if (p || !strchr(s, '.')) { /* whitespaces or no dot? */ - p = soup_uri_encode(s, "&"); - new = g_strdup_printf(defsearch->uri, p); - g_free(p); + search_uri = find_uri_for_searchengine(defaultsearch); + if (search_uri != NULL) { + search_term = soup_uri_encode(s, "&"); + new = g_strdup_printf(search_uri, search_term); + g_free(search_term); + } } else { /* prepend "http://" */ new = g_malloc(sizeof("http://") + len); strcpy(new, "http://"); -- 1.7.3.4 From hpdeifel at gmx.de Tue Apr 12 15:08:30 2011 From: hpdeifel at gmx.de (Hans-Peter Deifel) Date: Tue, 12 Apr 2011 17:08:30 +0200 Subject: [Vimprobable-users] [PATCH 0/5] Configurable search engines Message-ID: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> Hi all, This took a little longer than expected, but here we go: I've tried to implement the comments on the previous iteration of this patch series. Here is an overview of what I changed: - A new function 'make_searchengines_list' takes the searchengines array from config.h and adds its content to the search engines list. - The lookup function now only looks at the dynamic search engines list. - Better error handling. The return value of 'read_searchengines' is now an enum with error conditions. - Rewritten documentation. - Many small fixes and some code cleanup. The config file is still meant to be modified by the user because vimprobable can not really help with the search engine URLs. The user has to figure out where to insert %s and edit the URL accordingly. This is easier with a text editor. There are some features, that would be nice to have, such as completion, a way to display all defined search engines or a way to define them at runtime. But these can easily be added later. Also, the internal search engines list can be trivially replaced by a hashtable, if it proves worthy. As usual, comments are appreciated. Regards, HP Hans-Peter Deifel (5): Define storage location for searchengines Make search engines configurable Mention search engines in the man page Make the default search engine configurable Add the 'defaultsearch' setting to the manpage config.h | 4 +- main.c | 49 +++++++++++++++++----- utilities.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ utilities.h | 10 +++++ vimprobable.h | 3 + vimprobable2.1 | 32 ++++++++++++++ vimprobablerc.1 | 3 + 7 files changed, 210 insertions(+), 12 deletions(-) -- 1.7.3.4 From hpdeifel at gmx.de Tue Apr 12 15:08:31 2011 From: hpdeifel at gmx.de (Hans-Peter Deifel) Date: Tue, 12 Apr 2011 17:08:31 +0200 Subject: [Vimprobable-users] [PATCH 1/5] Define storage location for searchengines In-Reply-To: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> References: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> Message-ID: <1302620915-28950-2-git-send-email-hpdeifel@gmx.de> --- vimprobable.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/vimprobable.h b/vimprobable.h index 72fe819..9732bc9 100644 --- a/vimprobable.h +++ b/vimprobable.h @@ -168,6 +168,9 @@ typedef struct { #define HISTORY_STORAGE_FILENAME "%s/.config/vimprobable/history", getenv("HOME") #define CLOSED_URL_FILENAME "%s/.config/vimprobable/closed", getenv("HOME") +/* searchengines */ +#define SEARCHENGINES_STORAGE_FILENAME "%s/.config/vimprobable/searchengines", getenv("HOME") + /* Command size */ #define COMMANDSIZE 1024 -- 1.7.3.4 From hpdeifel at gmx.de Tue Apr 12 15:08:35 2011 From: hpdeifel at gmx.de (Hans-Peter Deifel) Date: Tue, 12 Apr 2011 17:08:35 +0200 Subject: [Vimprobable-users] [PATCH 5/5] Add the 'defaultsearch' setting to the manpage In-Reply-To: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> References: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> Message-ID: <1302620915-28950-6-git-send-email-hpdeifel@gmx.de> --- vimprobablerc.1 | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/vimprobablerc.1 b/vimprobablerc.1 index cef3adc..de338c6 100644 --- a/vimprobablerc.1 +++ b/vimprobablerc.1 @@ -94,6 +94,9 @@ Replace the default encoding .IP defaultfont=default-font-family Replace the default font family +.IP defaultsearch=searchengine-shortcut +Replace the default search engine + .IP fontsize=integer Replace the default fontsize -- 1.7.3.4 From tyler at monkeypox.org Thu Apr 21 19:44:30 2011 From: tyler at monkeypox.org (R. Tyler Croy) Date: Thu, 21 Apr 2011 12:44:30 -0700 Subject: [Vimprobable-users] vimprobable2 package for openSUSE Message-ID: <20110421194430.GY27418@kiwi.sharlinx.com> Just a heads up, I've packaged vimprobable2 for openSUSE. Once I've tested it a bit more rigorously, I'll submit it to the X11:Utilities repository, but for now it's located in my home:agentdero:utils repository: It's currently only built for openSUSE 11.4, to add my repo you can use the following command: # zypper ar -f http://download.opensuse.org/repositories/home:/agentdero:/utils/openSUSE_11.4/home:agentdero:utils.repo Or you can download the RPMs directly and install them from here: Look forward to hearing your feedback and getting more folks using vimprobable2 :) Cheers - R. Tyler Croy -------------------------------------- Code: http://github.com/rtyler Chatter: http://identi.ca/agentdero http://twitter.com/agentdero -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From hannes at yllr.net Thu Apr 21 19:50:34 2011 From: hannes at yllr.net (Hannes =?UTF-8?B?U2Now7xsbGVy?=) Date: Thu, 21 Apr 2011 21:50:34 +0200 Subject: [Vimprobable-users] vimprobable2 package for openSUSE In-Reply-To: <20110421194430.GY27418@kiwi.sharlinx.com> References: <20110421194430.GY27418@kiwi.sharlinx.com> Message-ID: <20110421215034.218edfe9@workstation> Hi! "R. Tyler Croy" wrote: > Just a heads up, I've packaged vimprobable2 for openSUSE. That's great news - thanks a lot! Hannes -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From hannes at yllr.net Sat Apr 23 12:09:30 2011 From: hannes at yllr.net (Hannes =?UTF-8?B?U2Now7xsbGVy?=) Date: Sat, 23 Apr 2011 14:09:30 +0200 Subject: [Vimprobable-users] [PATCH 0/5] Configurable search engines In-Reply-To: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> References: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> Message-ID: <20110423140930.05cf216b@workstation> Sorry, Hans-Peter, for not responding so far. I will use the subsequent holidays to dig into the code, test it etc. Hannes -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From tyler at monkeypox.org Mon Apr 25 02:20:31 2011 From: tyler at monkeypox.org (R. Tyler Croy) Date: Sun, 24 Apr 2011 19:20:31 -0700 Subject: [Vimprobable-users] vimprobable2 package for openSUSE In-Reply-To: <20110421215034.218edfe9@workstation> References: <20110421194430.GY27418@kiwi.sharlinx.com> <20110421215034.218edfe9@workstation> Message-ID: <20110425022031.GN17455@kiwi.sharlinx.com> On Thu, 21 Apr 2011, Hannes Sch?ller wrote: > Hi! > > "R. Tyler Croy" wrote: > > Just a heads up, I've packaged vimprobable2 for openSUSE. > > That's great news - thanks a lot! Just a quick weekend update on my work here. I've moved some of my packaging work out of my "home:agentdero:utils" repository into "home:agentdero:browsers": My reasoning for this is so I can focus more on packaging up vimprobable2 and surf (and potentially other libwebkitgtk browsers) with their dependencies in one repository across multiple versions of openSUSE 11.x and perhaps even Fedora and Ubuntu. I've added a couple of patches which will likely never make it upstream as well: yellow_hinting.patch : disable_java.patch : The first is mostly for me (to be entirely honest), I find black on yellow far easier to identify than white on red. This borrows from the hinting style of Vimium (Chrome Extension) instead of following Vimperator. The second patch is to explicitly avoid Java dependencies (and Java entirely to be honest). I've caught up on the backlogged patches, and I'm really looking forward to packaging up the search engine customizations and newer hinting changes :) I won't bother the list with my vimprobable2 packaging exploits until I have finished packages up for more platforms :) Cheers - R. Tyler Croy -------------------------------------- Code: http://github.com/rtyler Chatter: http://identi.ca/agentdero http://twitter.com/agentdero -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From hannes at yllr.net Mon Apr 25 08:05:14 2011 From: hannes at yllr.net (Hannes =?UTF-8?B?U2Now7xsbGVy?=) Date: Mon, 25 Apr 2011 10:05:14 +0200 Subject: [Vimprobable-users] vimprobable2 package for openSUSE In-Reply-To: <20110425022031.GN17455@kiwi.sharlinx.com> References: <20110421194430.GY27418@kiwi.sharlinx.com> <20110421215034.218edfe9@workstation> <20110425022031.GN17455@kiwi.sharlinx.com> Message-ID: <20110425100514.31c6be3d@laptop2.lan.localhost> Hi! "R. Tyler Croy" wrote: > The second patch is to explicitly avoid Java dependencies (and Java > entirely to be honest). This setting doesn't influence the build dependencies. If you've got it enabled, but Java not installed, nothing bad will happen - the browser will still run. Personally, I have Java, Plugins and Javascript all disabled, but I wouldn't dream of pushing these settings into the repository as default :) > I've caught up on the backlogged patches, and I'm really looking > forward to packaging up the search engine customizations and newer > hinting changes :) Search engine customisation is currently being tested by me, it looks good. The hinting changes, unfortunately, seem to have been abandoned by the patch's author. In case anyone wants to pick it up again...? Hannes -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: not available URL: From hannes at yllr.net Tue Apr 26 20:37:21 2011 From: hannes at yllr.net (Hannes =?UTF-8?B?U2Now7xsbGVy?=) Date: Tue, 26 Apr 2011 22:37:21 +0200 Subject: [Vimprobable-users] [PATCH 0/5] Configurable search engines In-Reply-To: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> References: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> Message-ID: <20110426223721.0cec72e3@workstation> Hi! Since most of this looks absolutely fine, I'm going to consolidate my comments in this one mail. - The config file syntax is very picky with regards to entries ending with a newline character. It would make sense to let at least the final one end without a new line. My first test failed, because I had only entered one single line, logically without a linefeed - this should work. - Why does the function make_searchengines_list take the length as argument? At the moment, it only ever seems to be called once, but this might lead to problems later on. Especially since it seems unnecessary: Since the list itself is passed to the function anyway, why not read its length within the function directly? Then, there can be no out of boundary problems due to an inconsistent function call. Letting the caller specify the list length is like asking for trouble. - The function find_uri_for_searchengine uses the insecure strcmp function. Please first check that the length is identical and then use strncmp. - The ConfigFileError enum would be better placed in vimprobable.h, in my opinion. You wisely made it completely generic, so it might be useful for other files, too. - On the man page, it would maybe be a good idea to mention the default search engines and their shortcuts? Hannes -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available URL: From hpdeifel at gmx.de Fri Apr 29 22:00:40 2011 From: hpdeifel at gmx.de (Hans-Peter Deifel) Date: Sat, 30 Apr 2011 00:00:40 +0200 Subject: [Vimprobable-users] [PATCH 0/5] Configurable search engines In-Reply-To: <20110426223721.0cec72e3@workstation> References: <1302620915-28950-1-git-send-email-hpdeifel@gmx.de> <20110426223721.0cec72e3@workstation> Message-ID: <20110429220039.GA18329@deepsilver> Hi, On 22:37 Tue 26 Apr , Hannes Sch?ller wrote: > Hi! > > Since most of this looks absolutely fine, I'm going to consolidate my > comments in this one mail. > > - The config file syntax is very picky with regards to entries ending > with a newline character. It would make sense to let at least the > final one end without a new line. My first test failed, because I had > only entered one single line, logically without a linefeed - this > should work. Makes the fgets code even uglier :) But I will certainly fix it. > - Why does the function make_searchengines_list take the length as > argument? At the moment, it only ever seems to be called once, but > this might lead to problems later on. Especially since it seems > unnecessary: Since the list itself is passed to the function anyway, > why not read its length within the function directly? Then, there can > be no out of boundary problems due to an inconsistent function call. > Letting the caller specify the list length is like asking for trouble. Because config.h is not included in utilities.c and therefore the size of the 'searchengines' array is not known at compile time. The keylist solves this by including a sentinel at the end of the array. But the searchengines array is in the config.h file and some users may not notice such a subtle change and continue to use an array without sentinel, which would of course lead to horrible breakage. > - The function find_uri_for_searchengine uses the insecure strcmp > function. Please first check that the length is identical and then > use strncmp. I don't think that int len1 = strlen(str1), len2 = strlen(str2); return len1 == len2 && !strncmp(str1, str2, len1); is more secure than return !strcmp(str1, str2); because strlen also just uses the 0-byte to determine the length of the string. > - The ConfigFileError enum would be better placed in vimprobable.h, in > my opinion. You wisely made it completely generic, so it might be > useful for other files, too. Yep, will do. > - On the man page, it would maybe be a good idea to mention the default > search engines and their shortcuts? Yes. I thought it would lead to discrepancy between the manpage and the executable when users change their config.h. But since that's the case for settings and key bindings as well, it should probably be added. HP -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 230 bytes Desc: not available URL: