From: Ben Pfaff Date: Sun, 9 Feb 2020 19:02:59 +0000 (+0000) Subject: start moving vizml parsing into a new file X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5a259c64afe0c976709d8ffde7a70e7c76ef7ad;p=pspp start moving vizml parsing into a new file --- diff --git a/src/output/spv/automake.mk b/src/output/spv/automake.mk index ed952f254c..cfbe0d4e19 100644 --- a/src/output/spv/automake.mk +++ b/src/output/spv/automake.mk @@ -37,7 +37,9 @@ src_output_liboutput_la_SOURCES += \ src/output/spv/spvbin-helpers.c \ src/output/spv/spvbin-helpers.h \ src/output/spv/spvxml-helpers.c \ - src/output/spv/spvxml-helpers.h + src/output/spv/spvxml-helpers.h \ + src/output/spv/vizml-decoder.c \ + src/output/spv/vizml-decoder.h light_binary_in = \ src/output/spv/binary-parser-generator \ diff --git a/src/output/spv/spv.c b/src/output/spv/spv.c index 1d347fd1ad..c3d8ac6dcd 100644 --- a/src/output/spv/spv.c +++ b/src/output/spv/spv.c @@ -40,7 +40,7 @@ #include "output/spv/spv-legacy-decoder.h" #include "output/spv/spv-light-decoder.h" #include "output/spv/structure-xml-parser.h" -#include "output/spv/vizml-parser.h" +#include "output/spv/vizml-decoder.h" #include "gl/c-ctype.h" #include "gl/intprops.h" @@ -840,7 +840,7 @@ pivot_table_open_legacy (struct spv_item *item) struct spvxml_context ctx = SPVXML_CONTEXT_INIT (ctx); struct spvdx_visualization *v; spvdx_parse_visualization (&ctx, xmlDocGetRootElement (doc), &v); - error = spvxml_context_finish (&ctx, &v->node_); + error = spvxml_context_finish (&ctx, v ? &v->node_ : NULL); if (!error) error = decode_spvdx_table (v, item->subtype, item->legacy_properties, @@ -915,10 +915,8 @@ spv_open_graph (struct spv_item *item) return error; } - struct spvxml_context ctx = SPVXML_CONTEXT_INIT (ctx); - struct vizml_visualization *v; - vizml_parse_visualization (&ctx, xmlDocGetRootElement (doc), &v); - error = spvxml_context_finish (&ctx, &v->node_); + if (!error) + error = decode_vizml (xmlDocGetRootElement (doc), &data); if (error) { @@ -931,7 +929,6 @@ spv_open_graph (struct spv_item *item) } spv_data_uninit (&data); - vizml_free_visualization (v); if (doc) xmlFreeDoc (doc); @@ -1140,7 +1137,7 @@ spv_heading_read (struct spv_reader *spv, struct spvxml_context ctx = SPVXML_CONTEXT_INIT (ctx); struct spvsx_root_heading *root; spvsx_parse_root_heading (&ctx, xmlDocGetRootElement (doc), &root); - error = spvxml_context_finish (&ctx, &root->node_); + error = spvxml_context_finish (&ctx, root ? &root->node_ : NULL); if (!error && root->page_setup) spv->page_setup = decode_page_setup (root->page_setup, file_name); diff --git a/src/output/spv/vizml-decoder.c b/src/output/spv/vizml-decoder.c new file mode 100644 index 0000000000..7bb0ace9d2 --- /dev/null +++ b/src/output/spv/vizml-decoder.c @@ -0,0 +1,37 @@ +/* PSPP - a program for statistical analysis. + Copyright (C) 2020 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#include "output/spv/vizml-decoder.h" + +#include "output/spv/spvxml-helpers.h" +#include "output/spv/vizml-parser.h" + +char * WARN_UNUSED_RESULT +decode_vizml (xmlNode *input, struct spv_data *data UNUSED) +{ + struct spvxml_context ctx = SPVXML_CONTEXT_INIT (ctx); + struct vizml_visualization *v; + vizml_parse_visualization (&ctx, input, &v); + char *error = spvxml_context_finish (&ctx, v ? &v->node_ : NULL); + if (error) + return error; + + vizml_free_visualization (v); + + return NULL; +} diff --git a/src/output/spv/vizml-decoder.h b/src/output/spv/vizml-decoder.h new file mode 100644 index 0000000000..9e8d29c8da --- /dev/null +++ b/src/output/spv/vizml-decoder.h @@ -0,0 +1,32 @@ +/* PSPP - a program for statistical analysis. + Copyright (C) 2020 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef OUTPUT_VIZML_DECODER_H +#define OUTPUT_VIZML_DECODER_H 1 + +/* Visualization Markup Language (VizML) decoder. + + Used by spv.h, not useful directly. */ + +#include +#include "libpspp/compiler.h" + +struct spv_data; + +char *decode_vizml (xmlNode *input, struct spv_data *) + WARN_UNUSED_RESULT; + +#endif /* output/spv/vizml-decoder.h */