do_target_wait_1: Clear TARGET_WNOHANG if the target isn't async.
[binutils-gdb.git] / gdb / xml-support.c
index c906b69fda0b6d79817296b6b54e9020d9a1a1da..8b514950bb417c7db4c26b244102e0e242c47a86 100644 (file)
@@ -1,6 +1,6 @@
 /* Helper routines for parsing XML using Expat.
 
-   Copyright (C) 2006-2020 Free Software Foundation, Inc.
+   Copyright (C) 2006-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -745,13 +745,12 @@ gdb_xml_parse_attr_enum (struct gdb_xml_parser *parser,
 struct xinclude_parsing_data
 {
   xinclude_parsing_data (std::string &output_,
-                        xml_fetch_another fetcher_, void *fetcher_baton_,
+                        xml_fetch_another fetcher_,
                         int include_depth_)
     : output (output_),
       skip_depth (0),
       include_depth (include_depth_),
-      fetcher (fetcher_),
-      fetcher_baton (fetcher_baton_)
+      fetcher (fetcher_)
   {}
 
   /* Where the output goes.  */
@@ -770,7 +769,6 @@ struct xinclude_parsing_data
   /* A function to call to obtain additional features, and its
      baton.  */
   xml_fetch_another fetcher;
-  void *fetcher_baton;
 };
 
 static void
@@ -789,14 +787,12 @@ xinclude_start_include (struct gdb_xml_parser *parser,
     gdb_xml_error (parser, _("Maximum XInclude depth (%d) exceeded"),
                   MAX_XINCLUDE_DEPTH);
 
-  gdb::optional<gdb::char_vector> text
-    = data->fetcher (href, data->fetcher_baton);
+  gdb::optional<gdb::char_vector> text = data->fetcher (href);
   if (!text)
     gdb_xml_error (parser, _("Could not load XML document \"%s\""), href);
 
   if (!xml_process_xincludes (data->output, parser->name (),
                              text->data (), data->fetcher,
-                             data->fetcher_baton,
                              data->include_depth + 1))
     gdb_xml_error (parser, _("Parsing \"%s\" failed"), href);
 
@@ -878,10 +874,9 @@ const struct gdb_xml_element xinclude_elements[] = {
 bool
 xml_process_xincludes (std::string &result,
                       const char *name, const char *text,
-                      xml_fetch_another fetcher, void *fetcher_baton,
-                      int depth)
+                      xml_fetch_another fetcher, int depth)
 {
-  xinclude_parsing_data data (result, fetcher, fetcher_baton, depth);
+  xinclude_parsing_data data (result, fetcher, depth);
 
   gdb_xml_parser parser (name, xinclude_elements, &data);
   parser.set_is_xinclude (true);
@@ -968,17 +963,16 @@ show_debug_xml (struct ui_file *file, int from_tty,
 }
 
 gdb::optional<gdb::char_vector>
-xml_fetch_content_from_file (const char *filename, void *baton)
+xml_fetch_content_from_file (const char *filename, const char *dirname)
 {
-  const char *dirname = (const char *) baton;
   gdb_file_up file;
 
-  if (dirname && *dirname)
+  if (dirname != nullptr && *dirname != '\0')
     {
-      char *fullname = concat (dirname, "/", filename, (char *) NULL);
+      gdb::unique_xmalloc_ptr<char> fullname
+       (concat (dirname, "/", filename, (char *) NULL));
 
-      file = gdb_fopen_cloexec (fullname, FOPEN_RB);
-      xfree (fullname);
+      file = gdb_fopen_cloexec (fullname.get (), FOPEN_RB);
     }
   else
     file = gdb_fopen_cloexec (filename, FOPEN_RB);