[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 07/22] tools/utils: merge contents of libxlu_cfg_i.h to libxlu_cfg_y.y



Bison has added the ability to emit declarations in its header.  As such
everything can instead be dumped in Bison's header instead of having a
private one.

This resolves the mixed up situation with the libxlu headers.  Problem is
libxlu_cfg_i.h was trying to function as a wrapper for libxlu_cfg_y.h.
Issue is libxlu_cfg.c's #include order didn't match and thus everything
was fragile.

Fixes: b104c3762d ('Replace config file parser for "xl"')
Signed-off-by: Elliott Mitchell <ehem+xen@xxxxxxx>
---
The bug @b104c3762d was the incorrect ordering of #includes in
libxlu_cfg.c.  It should instead have been:
 #include "libxlu_cfg_i.h"
 #include "libxlu_cfg_l.h"

Had this bug not been present, later commits might have looked deeper and
chosen correct solutions.  Instead this resulted in all the ripples which
this series fixes.

I'm unsure whether Bison had implemented the %code feature by this point
in time.

The one and a half remaining issues are whether to convert the %{ %}
section to %code and move it after the %union.  The %union construct ends
up in libxlu_cfg_y.h, whereas the %{ %}/%code construct ends up in
libxlu_cfg_y.c.
---
 tools/libs/util/libxlu_cfg.c   |  1 -
 tools/libs/util/libxlu_cfg_i.h | 53 ----------------------------------
 tools/libs/util/libxlu_cfg_l.l |  2 +-
 tools/libs/util/libxlu_cfg_y.y | 29 ++++++++++++++++++-
 4 files changed, 29 insertions(+), 56 deletions(-)
 delete mode 100644 tools/libs/util/libxlu_cfg_i.h

diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c
index 87ac8c4b41..7e9eec550d 100644
--- a/tools/libs/util/libxlu_cfg.c
+++ b/tools/libs/util/libxlu_cfg.c
@@ -22,7 +22,6 @@
 #include "libxlu_internal.h"
 #include "libxlu_cfg_y.h"
 #include "libxlu_cfg_l.h"
-#include "libxlu_cfg_i.h"
 
 XLU_Config *xlu_cfg_init(FILE *report, const char *report_source) {
     XLU_Config *cfg;
diff --git a/tools/libs/util/libxlu_cfg_i.h b/tools/libs/util/libxlu_cfg_i.h
deleted file mode 100644
index 3717b9460c..0000000000
--- a/tools/libs/util/libxlu_cfg_i.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * libxlu_cfg_i.h - xl configuration file parsing: parser-internal declarations
- *
- * Copyright (C) 2010      Citrix Ltd.
- * Author Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * 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 Lesser General Public License for more details.
- */
-
-#ifndef LIBXLU_CFG_I_H
-#define LIBXLU_CFG_I_H
-
-#include "libxlu_internal.h"
-#include "libxlu_cfg_y.h"
-
-void xlu__cfg_set_free(XLU_ConfigSetting *set);
-void xlu__cfg_set_store(CfgParseContext*, char *name,
-                        enum XLU_Operation op,
-                        XLU_ConfigValue *val, int lineno);
-XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx,
-                                    char *atom, YYLTYPE *loc);
-XLU_ConfigValue *xlu__cfg_list_mk(CfgParseContext *ctx,
-                                  XLU_ConfigValue *val,
-                                  YYLTYPE *loc);
-void xlu__cfg_list_append(CfgParseContext *ctx,
-                          XLU_ConfigValue *list,
-                          XLU_ConfigValue *val);
-void xlu__cfg_value_free(XLU_ConfigValue *value);
-char *xlu__cfgl_strdup(CfgParseContext*, const char *src);
-char *xlu__cfgl_dequote(CfgParseContext*, const char *src);
-
-void xlu__cfg_yyerror(YYLTYPE *locp, CfgParseContext*, char const *msg);
-void xlu__cfgl_lexicalerror(CfgParseContext*, char const *msg);
-
-void xlu__cfgl_likely_python(CfgParseContext *ctx);
-
-#endif /*LIBXLU_CFG_I_H*/
-
-/*
- * Local variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/tools/libs/util/libxlu_cfg_l.l b/tools/libs/util/libxlu_cfg_l.l
index 390d6e2c2b..ba023fd679 100644
--- a/tools/libs/util/libxlu_cfg_l.l
+++ b/tools/libs/util/libxlu_cfg_l.l
@@ -17,7 +17,7 @@
  */
 
 %{
-#include "libxlu_cfg_i.h"
+#include "libxlu_cfg_y.h"
 
 #define ctx ((CfgParseContext*)yyextra)
 #define YY_NO_INPUT
diff --git a/tools/libs/util/libxlu_cfg_y.y b/tools/libs/util/libxlu_cfg_y.y
index e53d8ed337..e796066941 100644
--- a/tools/libs/util/libxlu_cfg_y.y
+++ b/tools/libs/util/libxlu_cfg_y.y
@@ -16,9 +16,36 @@
  * GNU Lesser General Public License for more details.
  */
 
+%code requires {
+#include "libxlu_internal.h"
+}
+
+%code provides {
+void xlu__cfg_set_free(XLU_ConfigSetting *set);
+void xlu__cfg_set_store(CfgParseContext*, char *name,
+                        enum XLU_Operation op,
+                        XLU_ConfigValue *val, int lineno);
+XLU_ConfigValue *xlu__cfg_string_mk(CfgParseContext *ctx,
+                                    char *atom, YYLTYPE *loc);
+XLU_ConfigValue *xlu__cfg_list_mk(CfgParseContext *ctx,
+                                  XLU_ConfigValue *val,
+                                  YYLTYPE *loc);
+void xlu__cfg_list_append(CfgParseContext *ctx,
+                          XLU_ConfigValue *list,
+                          XLU_ConfigValue *val);
+void xlu__cfg_value_free(XLU_ConfigValue *value);
+char *xlu__cfgl_strdup(CfgParseContext*, const char *src);
+char *xlu__cfgl_dequote(CfgParseContext*, const char *src);
+
+void xlu__cfg_yyerror(YYLTYPE *locp, CfgParseContext*, char const *msg);
+void xlu__cfgl_lexicalerror(CfgParseContext*, char const *msg);
+
+void xlu__cfgl_likely_python(CfgParseContext *ctx);
+}
+
 %{
 #define ctx_scanner ctx->scanner
-#include "libxlu_cfg_i.h"
+#include "libxlu_cfg_y.h"
 #include "libxlu_cfg_l.h"
 %}
 
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |       ehem+sigmsg@xxxxxxx      PGP 87145445       |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445






 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.