Fix "map" processing in config files.

Trying to calculate the size of an extern array at runtime is fatal -- it's
also going to either evaluate to zero (if passed by pointer) or fail at
compilation, because sizeof is compile-time only.

Therefore, give the commands[] array a pre-calculated size -- which can
then be used properly when trying to set any "map" lines encountered in
Vimprobable's config file.
This commit is contained in:
Thomas Adam 2010-11-19 23:26:34 +00:00 committed by Hannes Schueller
parent da5394a5c4
commit 304ff1796b
3 changed files with 5 additions and 2 deletions

View File

@ -83,7 +83,7 @@ static Searchengine searchengines[] = {
static Searchengine *defsearch = &searchengines[0];
/* command mapping */
Command commands[] = {
Command commands[COMMANDSIZE] = {
/* command, function, argument */
{ "ba", navigate, {NavigationBack} },
{ "back", navigate, {NavigationBack} },

View File

@ -13,7 +13,7 @@
#include "utilities.h"
extern char commandhistory[COMMANDHISTSIZE][255];
extern Command *commands;
extern Command commands[COMMANDSIZE];
extern int lastcommand, maxcommands, commandpointer;
extern KeyList *keylistroot;
extern Key keys[];

View File

@ -168,5 +168,8 @@ typedef struct {
#define HISTORY_STORAGE_FILENAME "%s/.config/vimprobable/history", getenv("HOME")
#define CLOSED_URL_FILENAME "%s/.config/vimprobable/closed", getenv("HOME")
/* Command size */
#define COMMANDSIZE 1024
/* completion list size */
#define MAX_LIST_SIZE 40