1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-09-26 22:10:45 +02:00

20695: Fix Cygwin problem with initialising from pointer to imported variable

This commit is contained in:
Peter Stephenson 2005-01-12 12:18:58 +00:00
parent 43ac170305
commit 77166e259e
5 changed files with 54 additions and 6 deletions

View File

@ -3,6 +3,11 @@
* unposted: Config/version.mk, README, Etc/FAQ.yo: release
zsh version 4.2.2.
* 20695: Src/module.c, Src/zsh.h, Src/Modules/parameter.c,
Src/Zle/zleparameter.c: Cygwin barfs on an attempt to
use a pointer to an imported variable in a compile-time
initialiser.
* unposted: Fix .distfiles and .cvsignore for distribution.
* unposted: Completion/Unix/Command/_perforce: minor comment

View File

@ -1812,6 +1812,13 @@ struct pardef {
Param pm;
};
/*
* This is a duplicate of nullsethash_gsu. On some systems
* (such as Cygwin) we can't put a pointer to an imported variable
* in a compile-time initialiser, so we use this instead.
*/
static const struct gsu_hash pmnullsethash_gsu =
{ hashgetfn, nullsethashfn, NULL };
static const struct gsu_hash pmcommands_gsu =
{ hashgetfn, setpmcommands, stdunsetfn };
static const struct gsu_hash pmfunctions_gsu =
@ -1848,7 +1855,7 @@ static const struct gsu_array historywords_gsu =
static struct pardef partab[] = {
{ "parameters", PM_READONLY,
getpmparameter, scanpmparameters, &nullsethash_gsu,
getpmparameter, scanpmparameters, &pmnullsethash_gsu,
NULL, NULL },
{ "commands", 0,
getpmcommand, scanpmcommands, &pmcommands_gsu,

View File

@ -167,12 +167,19 @@ struct pardef {
Param pm;
};
/*
* This is a duplicate of stdhash_gsu. On some systems
* (such as Cygwin) we can't put a pointer to an imported variable
* in a compile-time initialiser, so we use this instead.
*/
static const struct gsu_hash zlestdhash_gsu =
{ hashgetfn, hashsetfn, stdunsetfn };
static const struct gsu_array keymaps_gsu =
{ keymapsgetfn, arrsetfn, stdunsetfn };
static struct pardef partab[] = {
{ "widgets", PM_READONLY,
getpmwidgets, scanpmwidgets, &stdhash_gsu,
getpmwidgets, scanpmwidgets, &zlestdhash_gsu,
NULL, NULL },
{ "keymaps", PM_ARRAY|PM_SPECIAL|PM_READONLY,
NULL, NULL, NULL,

View File

@ -1894,7 +1894,31 @@ addparamdef(Paramdef d)
pm->level = 0;
pm->u.data = d->var;
pm->gsu.i = (GsuInteger) d->gsu;
if (d->gsu)
pm->gsu.i = (GsuInteger) d->gsu;
else {
/*
* If no get/set/unset class, use the appropriate
* variable type.
*/
switch (PM_TYPE(pm->flags)) {
case PM_SCALAR:
pm->gsu.s = &varscalar_gsu;
break;
case PM_INTEGER:
pm->gsu.i = &varinteger_gsu;
break;
case PM_ARRAY:
pm->gsu.a = &vararray_gsu;
break;
default:
unsetparam_pm(pm, 0, 1);
return 1;
}
}
return 0;
}

View File

@ -1316,12 +1316,17 @@ struct paramdef {
#define PARAMDEF(name, flags, var, gsu) \
{ name, flags, (void *) var, (void *) gsu, }
/*
* Note that the following definitions are appropriate for defining
* parameters that reference a variable (var). Hence the get/set/unset
* methods used will assume var needs dereferencing to get the value.
*/
#define INTPARAMDEF(name, var) \
{ name, PM_INTEGER, (void *) var, (void *) &stdinteger_gsu }
{ name, PM_INTEGER, (void *) var, NULL }
#define STRPARAMDEF(name, var) \
{ name, PM_SCALAR, (void *) var, (void *) &varscalar_gsu }
{ name, PM_SCALAR, (void *) var, NULL }
#define ARRPARAMDEF(name, var) \
{ name, PM_ARRAY, (void *) var, (void *) &vararray_gsu }
{ name, PM_ARRAY, (void *) var, NULL }
#define setsparam(S,V) assignsparam(S,V,0)
#define setaparam(S,V) assignaparam(S,V,0)