Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

how to expose a simple const char *array[]?



hello,

i need a little help in exposing an array from zsh.

i'm trying to wrap the contents of Src/zshpaths.h in a module, initial
smoke tests look ok except this one thing: FPATH_SUBDIRS as an array.
the other modules that expose arrays use array_gsu structures as the
values need to be generated on the fly.  my case should be simpler so i
thought i'd get away without any fanfare, but it segfaults on access.

#define FPATH_SUBDIRS { "Calendar", "Chpwd", "Completion" /* , ... */ }

#ifdef FPATH_SUBDIRS
static const char *fpath_subdirs[] = FPATH_SUBDIRS;
#else
static const char *fpath_subdirs[] = { NULL };
#endif

static struct paramdef patab[] = {
    PARAMDEF("module_dir",      PM_SCALAR|PM_READONLY, &module_dir, NULL),
    PARAMDEF("sitescript_dir",  PM_SCALAR|PM_READONLY, &sitescript_dir, NULL),
    PARAMDEF("script_dir",      PM_SCALAR|PM_READONLY, &script_dir, NULL),
    PARAMDEF("sitefpath_dir",   PM_SCALAR|PM_READONLY, &sitefpath_dir, NULL),
    PARAMDEF("fixed_fpath_dir", PM_SCALAR|PM_READONLY, &fixed_fpath_dir, NULL),
    PARAMDEF("fpath_dir",       PM_SCALAR|PM_READONLY, &fpath_dir, NULL),
    PARAMDEF("fpath_subdirs",   PM_ARRAY |PM_READONLY, &fpath_subdirs, NULL)
};

it's surely doing something stupid...

-- 
roman



Messages sorted by: Reverse Date, Date, Thread, Author