unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libio/tst-fopenloc: Use xsetlocale, xfopen, and xfclose
@ 2019-11-11 14:40 Arjun Shankar
  2019-11-11 15:15 ` Florian Weimer
  0 siblings, 1 reply; 2+ messages in thread
From: Arjun Shankar @ 2019-11-11 14:40 UTC (permalink / raw)
  To: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 142 bytes --]

From: Arjun Shankar <arjun@redhat.com>
---
 libio/tst-fopenloc.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)


[-- Attachment #2: 0002-libio-tst-fopenloc-Use-xsetlocale-xfopen-and-xfclose.patch --]
[-- Type: text/x-patch, Size: 1106 bytes --]

diff --git a/libio/tst-fopenloc.c b/libio/tst-fopenloc.c
index e9548c57ac..797540da04 100644
--- a/libio/tst-fopenloc.c
+++ b/libio/tst-fopenloc.c
@@ -25,14 +25,11 @@
 #include <string.h>
 #include <wchar.h>
 #include <sys/resource.h>
+#include <support/support.h>
+#include <support/xstdio.h>
 
 static const char inputfile[] = "../iconvdata/testdata/ISO-8859-1";
 
-static int do_test(void);
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
-
 static int
 do_bz17916 (void)
 {
@@ -66,14 +63,9 @@ do_test (void)
 
   mtrace ();
 
-  setlocale (LC_ALL, "de_DE.UTF-8");
+  xsetlocale (LC_ALL, "de_DE.UTF-8");
 
-  fp = fopen (inputfile, "r,ccs=ISO-8859-1");
-  if (fp == NULL)
-    {
-      printf ("cannot open \"%s\": %s\n", inputfile, strerror (errno));
-      exit (1);
-    }
+  fp = xfopen (inputfile, "r,ccs=ISO-8859-1");
 
   while (! feof_unlocked (fp))
     {
@@ -85,7 +77,9 @@ do_test (void)
       fputws (buf, stdout);
     }
 
-  fclose (fp);
+  xfclose (fp);
 
   return do_bz17916 ();
 }
+
+#include <support/test-driver.c>

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] libio/tst-fopenloc: Use xsetlocale, xfopen, and xfclose
  2019-11-11 14:40 [PATCH] libio/tst-fopenloc: Use xsetlocale, xfopen, and xfclose Arjun Shankar
@ 2019-11-11 15:15 ` Florian Weimer
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2019-11-11 15:15 UTC (permalink / raw)
  To: Arjun Shankar; +Cc: libc-alpha

* Arjun Shankar:

> diff --git a/libio/tst-fopenloc.c b/libio/tst-fopenloc.c
> index e9548c57ac..797540da04 100644
> --- a/libio/tst-fopenloc.c
> +++ b/libio/tst-fopenloc.c
> @@ -25,14 +25,11 @@
>  #include <string.h>
>  #include <wchar.h>
>  #include <sys/resource.h>
> +#include <support/support.h>
> +#include <support/xstdio.h>
>  
>  static const char inputfile[] = "../iconvdata/testdata/ISO-8859-1";
>  
> -static int do_test(void);
> -
> -#define TEST_FUNCTION do_test ()
> -#include "../test-skeleton.c"
> -
>  static int
>  do_bz17916 (void)
>  {
> @@ -66,14 +63,9 @@ do_test (void)
>  
>    mtrace ();
>  
> -  setlocale (LC_ALL, "de_DE.UTF-8");
> +  xsetlocale (LC_ALL, "de_DE.UTF-8");
>  
> -  fp = fopen (inputfile, "r,ccs=ISO-8859-1");
> -  if (fp == NULL)
> -    {
> -      printf ("cannot open \"%s\": %s\n", inputfile, strerror (errno));
> -      exit (1);
> -    }
> +  fp = xfopen (inputfile, "r,ccs=ISO-8859-1");
>  
>    while (! feof_unlocked (fp))
>      {
> @@ -85,7 +77,9 @@ do_test (void)
>        fputws (buf, stdout);
>      }
>  
> -  fclose (fp);
> +  xfclose (fp);
>  
>    return do_bz17916 ();
>  }
> +
> +#include <support/test-driver.c>

This patch looks good to me.

(Lack of error checking in setlocale can lead to weird test failures.)

Thanks,
Florian


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-11 15:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 14:40 [PATCH] libio/tst-fopenloc: Use xsetlocale, xfopen, and xfclose Arjun Shankar
2019-11-11 15:15 ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).