libctf, binutils, include, ld: gettextize and improve error handling
[deliverable/binutils-gdb.git] / libctf / ctf-open-bfd.c
index 9fcce2fa9cdc7d98c4f2f8c312c2080c8de9e6fb..5541c9dd4dcbae868a5b9b8d65886c609e9556e4 100644 (file)
@@ -40,7 +40,8 @@ ctf_bfdclose (struct ctf_archive_internal *arci)
 {
   if (arci->ctfi_abfd != NULL)
     if (!bfd_close_all_done (arci->ctfi_abfd))
-      ctf_dprintf ("Cannot close BFD: %s\n", bfd_errmsg (bfd_get_error()));
+      ctf_err_warn (NULL, 0, 0, _("cannot close BFD: %s"),
+                   bfd_errmsg (bfd_get_error ()));
 }
 
 /* Open a CTF file given the specified BFD.  */
@@ -62,8 +63,9 @@ ctf_bfdopen (struct bfd *abfd, int *errp)
 
   if (!bfd_malloc_and_get_section (abfd, ctf_asect, &contents))
     {
-      ctf_dprintf ("ctf_bfdopen(): cannot malloc CTF section: %s\n",
-                  bfd_errmsg (bfd_get_error()));
+      ctf_err_warn (NULL, 0, 0, _("ctf_bfdopen(): cannot malloc "
+                                 "CTF section: %s"),
+                   bfd_errmsg (bfd_get_error ()));
       return (ctf_set_open_errno (errp, ECTF_FMT));
     }
 
@@ -112,7 +114,7 @@ ctf_bfdopen_ctfsect (struct bfd *abfd _libctf_unused_,
       symcount = symhdr->sh_size / symhdr->sh_entsize;
       if ((symtab = malloc (symhdr->sh_size)) == NULL)
        {
-         bfderrstr = "Cannot malloc symbol table";
+         bfderrstr = N_("cannot malloc symbol table");
          goto err;
        }
 
@@ -121,7 +123,7 @@ ctf_bfdopen_ctfsect (struct bfd *abfd _libctf_unused_,
       free (isymbuf);
       if (isymbuf == NULL)
        {
-         bfderrstr = "Cannot read symbol table";
+         bfderrstr = N_("cannot read symbol table");
          goto err_free_sym;
        }
 
@@ -135,7 +137,7 @@ ctf_bfdopen_ctfsect (struct bfd *abfd _libctf_unused_,
            {
              if ((strtab = bfd_elf_get_str_section (abfd, symhdr->sh_link)) == NULL)
                {
-                 bfderrstr = "Cannot read string table";
+                 bfderrstr = N_("cannot read string table");
                  goto err_free_sym;
                }
            }
@@ -199,7 +201,7 @@ ctf_bfdopen_ctfsect (struct bfd *abfd _libctf_unused_,
 err: _libctf_unused_;
   if (bfderrstr)
     {
-      ctf_dprintf ("ctf_bfdopen(): %s: %s\n", bfderrstr,
+      ctf_err_warn (NULL, 0, 0, "ctf_bfdopen(): %s: %s", gettext (bfderrstr),
                   bfd_errmsg (bfd_get_error()));
       ctf_set_open_errno (errp, ECTF_FMT);
     }
@@ -283,18 +285,18 @@ ctf_fdopen (int fd, const char *filename, const char *target, int *errp)
 
   if ((abfd = bfd_fdopenr (filename, target, nfd)) == NULL)
     {
-      ctf_dprintf ("Cannot open BFD from %s: %s\n",
-                  filename ? filename : "(unknown file)",
-                  bfd_errmsg (bfd_get_error()));
+      ctf_err_warn (NULL, 0, 0, _("cannot open BFD from %s: %s"),
+                   filename ? filename : _("(unknown file)"),
+                   bfd_errmsg (bfd_get_error ()));
       return (ctf_set_open_errno (errp, ECTF_FMT));
     }
   bfd_set_cacheable (abfd, 1);
 
   if (!bfd_check_format (abfd, bfd_object))
     {
-      ctf_dprintf ("BFD format problem in %s: %s\n",
-                  filename ? filename : "(unknown file)",
-                  bfd_errmsg (bfd_get_error()));
+      ctf_err_warn (NULL, 0, 0, _("BFD format problem in %s: %s"),
+                   filename ? filename : _("(unknown file)"),
+                   bfd_errmsg (bfd_get_error ()));
       if (bfd_get_error() == bfd_error_file_ambiguously_recognized)
        return (ctf_set_open_errno (errp, ECTF_BFD_AMBIGUOUS));
       else
@@ -304,7 +306,8 @@ ctf_fdopen (int fd, const char *filename, const char *target, int *errp)
   if ((arci = ctf_bfdopen (abfd, errp)) == NULL)
     {
       if (!bfd_close_all_done (abfd))
-       ctf_dprintf ("Cannot close BFD: %s\n", bfd_errmsg (bfd_get_error()));
+       ctf_err_warn (NULL, 0, 0, _("cannot close BFD: %s"),
+                     bfd_errmsg (bfd_get_error ()));
       return NULL;                     /* errno is set for us.  */
     }
   arci->ctfi_bfd_close = ctf_bfdclose;
This page took 0.026149 seconds and 4 git commands to generate.