X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fsession.c;h=56aa31a91cd581036890e312c04bb83bdd30de5b;hb=refs%2Fbuilds%2F20130924032641%2Fpspp;hp=c6f5031a5379e79a33cd84e6428b3d8ed2eeca1a;hpb=6f3865480503c571963d8a2d1af858a4d72d4e88;p=pspp diff --git a/src/data/session.c b/src/data/session.c index c6f5031a53..56aa31a91c 100644 --- a/src/data/session.c +++ b/src/data/session.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc. + Copyright (C) 2010, 2011, 2012, 2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ struct session { + struct session *parent; struct hmapx datasets; struct dataset *active; char *syntax_encoding; /* Default encoding for syntax files. */ @@ -43,14 +44,16 @@ static struct hmapx_node *session_lookup_dataset__ (const struct session *, const char *name); struct session * -session_create (void) +session_create (struct session *parent) { struct session *s; s = xmalloc (sizeof *s); + s->parent = parent; hmapx_init (&s->datasets); s->active = NULL; - s->syntax_encoding = xstrdup ("Auto"); + s->syntax_encoding = xstrdup (s->parent != NULL + ? s->parent->syntax_encoding : "Auto"); s->n_dataset_names = 0; return s; } @@ -115,7 +118,9 @@ struct dataset * session_lookup_dataset (const struct session *s, const char *name) { struct hmapx_node *node = session_lookup_dataset__ (s, name); - return node != NULL ? node->data : NULL; + return (node != NULL ? node->data + : s->parent != NULL ? session_lookup_dataset (s->parent, name) + : NULL); } struct dataset *