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

trying dputs




int
bin_whence(char *nam, char **argv, Options ops, int func)
{
    HashNode hn;
    Patprog pprog;
    int returnval = 0;
    int printflags = 0;
    int aliasflags;
    int csh, all, v, wd;
    int informed;
    char *cnam, **allmatched = 0;


If I steal 'opts->args' with a test string like this:

//char *garbage = "utter garbage";
//ops->args = &garbage;

... I get what I expect from this:

dputs("\nargs: %s", *(ops->args));

... but if I leave the pointer unmolested, I get a zsh
segmentation fault. Why is that? I'd expect to either
get a real string, or NULL. It's as if 'ops->args' is
dangling.

The function works fine even with the dummy string, so
I'm pretty sure 'ops->args' isn't needed. Still, I'd
say it shouldn't barf if I try to print it.


    /* Check some option information */
    csh = OPT_ISSET(ops,'c');
    v   = OPT_ISSET(ops,'v');
    all = OPT_ISSET(ops,'a');
    wd  = OPT_ISSET(ops,'w');

    if (OPT_ISSET(ops,'w'))



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