projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pivot-table: Add more tests for category and dimension borders.
[pspp]
/
src
/
data
/
session.c
diff --git
a/src/data/session.c
b/src/data/session.c
index c6f5031a5379e79a33cd84e6428b3d8ed2eeca1a..90922f3b244e455b6b88b401b5bcf42ad549b8b4 100644
(file)
--- a/
src/data/session.c
+++ b/
src/data/session.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* 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
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
{
+ struct session *parent;
struct hmapx datasets;
struct dataset *active;
char *syntax_encoding; /* Default encoding for syntax files. */
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 *
const char *name);
struct session *
-session_create (
void
)
+session_create (
struct session *parent
)
{
struct session *s;
s = xmalloc (sizeof *s);
{
struct session *s;
s = xmalloc (sizeof *s);
+ s->parent = parent;
hmapx_init (&s->datasets);
s->active = NULL;
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;
}
s->n_dataset_names = 0;
return s;
}
@@
-66,6
+69,7
@@
session_destroy (struct session *s)
s->active = NULL;
HMAPX_FOR_EACH_SAFE (ds, node, next, &s->datasets)
dataset_destroy (ds);
s->active = NULL;
HMAPX_FOR_EACH_SAFE (ds, node, next, &s->datasets)
dataset_destroy (ds);
+ hmapx_destroy (&s->datasets);
free (s->syntax_encoding);
free (s);
}
free (s->syntax_encoding);
free (s);
}
@@
-93,7
+97,10
@@
session_add_dataset (struct session *s, struct dataset *ds)
if (old == s->active)
s->active = ds;
if (old != NULL)
if (old == s->active)
s->active = ds;
if (old != NULL)
- session_remove_dataset (s, old);
+ {
+ session_remove_dataset (s, old);
+ dataset_destroy (old);
+ }
hmapx_insert (&s->datasets, ds,
utf8_hash_case_string (dataset_name (ds), 0));
hmapx_insert (&s->datasets, ds,
utf8_hash_case_string (dataset_name (ds), 0));
@@
-115,7
+122,9
@@
struct dataset *
session_lookup_dataset (const struct session *s, const char *name)
{
struct hmapx_node *node = session_lookup_dataset__ (s, name);
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 *
}
struct dataset *
@@
-169,7
+178,7
@@
session_get_dataset_by_seqno (const struct session *s, unsigned int seqno)
return NULL;
}
return NULL;
}
-/* Returns an identifier that is
is
not currently in use as a dataset name.
+/* Returns an identifier that is not currently in use as a dataset name.
The caller must free the returned identifier, with free(). */
char *
session_generate_dataset_name (struct session *s)
The caller must free the returned identifier, with free(). */
char *
session_generate_dataset_name (struct session *s)