]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - libio/tst-widetext.c
RISC-V: Fix `test' operand error with soft-float ABI being configured
[thirdparty/glibc.git] / libio / tst-widetext.c
index 472e6ca204c78a23e7c10fe3eb5d52081a767fd7..3d63e642c5fefc6eb2f9f0c3e30639cb98c9fed0 100644 (file)
@@ -1,23 +1,22 @@
 /* Test program for the wide character stream functions handling larger
    amounts of text.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>.
 
    The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
    The GNU C Library 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
-   Library General Public License for more details.
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <assert.h>
 #include <iconv.h>
@@ -32,8 +31,8 @@
 #define SIZE 210000
 
 
-int
-main (void)
+static int
+do_test (void)
 {
   char name[] = "/tmp/widetext.out.XXXXXX";
   char mbbuf[SIZE];
@@ -56,7 +55,7 @@ main (void)
   mbsize = fread (mbbuf, 1, SIZE, stdin);
   if (mbsize == 0)
     {
-      printf ("%Zd: cannot read input file from standard input: %m\n",
+      printf ("%u: cannot read input file from standard input: %m\n",
              __LINE__);
       exit (1);
     }
@@ -75,7 +74,7 @@ main (void)
     cd = iconv_open ("WCHAR_T", "UTF-8");
     if (cd == (iconv_t) -1)
       {
-       printf ("%Zd: cannot get iconv descriptor for conversion to UCS4\n",
+       printf ("%u: cannot get iconv descriptor for conversion to UCS4\n",
                __LINE__);
        exit (1);
       }
@@ -84,22 +83,22 @@ main (void)
     nonr = iconv (cd, &inbuf, &inleft, &outbuf, &outleft);
     if (nonr != 0 && nonr != (size_t) -1)
       {
-       printf ("%Zd: iconv performed %Zd nonreversible conversions\n",
+       printf ("%u: iconv performed %Zd nonreversible conversions\n",
                __LINE__, nonr);
        exit (1);
       }
 
-    if  ((size_t) nonr == -1 )
+    if  (nonr == (size_t) -1)
       {
        printf ("\
-%Zd: iconv returned with %Zd and errno = %m (inleft: %Zd, outleft: %Zd)\n",
+%u: iconv returned with %Zd and errno = %m (inleft: %Zd, outleft: %Zd)\n",
                __LINE__, nonr, inleft, outleft);
        exit (1);
       }
 
     if (inleft != 0)
       {
-       printf ("%Zd: iconv didn't convert all input\n", __LINE__);
+       printf ("%u: iconv didn't convert all input\n", __LINE__);
        exit (1);
       }
 
@@ -107,7 +106,7 @@ main (void)
 
     if ((sizeof (wcbuf) - outleft) % sizeof (wchar_t) != 0)
       {
-       printf ("%Zd: iconv converted not complete wchar_t\n", __LINE__);
+       printf ("%u: iconv converted not complete wchar_t\n", __LINE__);
        exit (1);
       }
 
@@ -122,7 +121,7 @@ main (void)
   fd = mkstemp (name);
   if (fd == -1)
     {
-      printf ("%Zd: cannot open temporary file: %m\n", __LINE__);
+      printf ("%u: cannot open temporary file: %m\n", __LINE__);
       exit (1);
     }
 
@@ -131,7 +130,7 @@ main (void)
   fp = fdopen (dup (fd), "w");
   if (fp == NULL)
     {
-      printf ("%Zd: fdopen of temp file for writing failed: %m\n", __LINE__);
+      printf ("%u: fdopen of temp file for writing failed: %m\n", __LINE__);
       exit (1);
     }
 
@@ -139,7 +138,7 @@ main (void)
     {
       if (fputwc (wcbuf[n], fp) == WEOF)
        {
-         printf ("%Zd: fputwc failed: %m\n", __LINE__);
+         printf ("%u: fputwc failed: %m\n", __LINE__);
          exit (1);
        }
     }
@@ -147,7 +146,7 @@ main (void)
   res = fclose (fp);
   if (res != 0)
     {
-      printf ("%Zd: fclose after single-character writing failed (%d): %m\n",
+      printf ("%u: fclose after single-character writing failed (%d): %m\n",
              __LINE__, res);
       exit (1);
     }
@@ -156,7 +155,7 @@ main (void)
   fp = fdopen (dup (fd), "r");
   if (fp == NULL)
     {
-      printf ("%Zd: fdopen of temp file for reading failed: %m\n", __LINE__);
+      printf ("%u: fdopen of temp file for reading failed: %m\n", __LINE__);
       exit (1);
     }
 
@@ -165,7 +164,7 @@ main (void)
       wint_t wch = fgetwc (fp);
       if (wch == WEOF)
        {
-         printf ("%Zd: fgetwc failed (idx %Zd): %m\n", __LINE__, n);
+         printf ("%u: fgetwc failed (idx %Zd): %m\n", __LINE__, n);
          exit (1);
        }
       wc2buf[n] = wch;
@@ -174,19 +173,19 @@ main (void)
   /* There should be nothing else.  */
   if (fgetwc (fp) != WEOF)
     {
-      printf ("%Zd: too many characters available with fgetwc\n", __LINE__);
+      printf ("%u: too many characters available with fgetwc\n", __LINE__);
       status = 1;
     }
   else if (wmemcmp (wcbuf, wc2buf, wcsize) != 0)
     {
-      printf ("%Zd: buffer read with fgetwc differs\n", __LINE__);
+      printf ("%u: buffer read with fgetwc differs\n", __LINE__);
       status = 1;
     }
 
   res = fclose (fp);
   if (res != 0)
     {
-      printf ("%Zd: fclose after single-character reading failed (%d): %m\n",
+      printf ("%u: fclose after single-character reading failed (%d): %m\n",
              __LINE__, res);
       exit (1);
     }
@@ -198,13 +197,13 @@ main (void)
   fp = fdopen (fd, "r");
   if (fp == NULL)
     {
-      printf ("%Zd: fdopen of temp file for reading failed: %m\n", __LINE__);
+      printf ("%u: fdopen of temp file for reading failed: %m\n", __LINE__);
       exit (1);
     }
 
   if (fread (mb2buf, 1, mbsize, fp) != mbsize)
     {
-      printf ("%Zd: cannot read all of the temp file\n", __LINE__);
+      printf ("%u: cannot read all of the temp file\n", __LINE__);
       status = 1;
     }
   else
@@ -212,13 +211,13 @@ main (void)
       /* Make sure there is nothing left.  */
       if (fgetc (fp) != EOF)
        {
-         printf ("%Zd: more input avilable", __LINE__);
+         printf ("%u: more input available\n", __LINE__);
          status = 1;
        }
 
       if (memcmp (mb2buf, mbbuf, mbsize) != 0)
        {
-         printf ("%Zd: buffer written with fputwc differs\n", __LINE__);
+         printf ("%u: buffer written with fputwc differs\n", __LINE__);
          status = 1;
        }
     }
@@ -226,7 +225,7 @@ main (void)
   res = fclose (fp);
   if (res != 0)
     {
-      printf ("%Zd: fclose after single-character reading failed (%d): %m\n",
+      printf ("%u: fclose after single-character reading failed (%d): %m\n",
              __LINE__, res);
       exit (1);
     }
@@ -236,7 +235,7 @@ main (void)
   fd = mkstemp (strcpy (name, "/tmp/widetext.out.XXXXXX"));
   if (fd == -1)
     {
-      printf ("%Zd: cannot open temporary file: %m\n", __LINE__);
+      printf ("%u: cannot open temporary file: %m\n", __LINE__);
       exit (1);
     }
 
@@ -245,7 +244,7 @@ main (void)
   fp = fdopen (dup (fd), "w");
   if (fp == NULL)
     {
-      printf ("%Zd: fdopen of temp file for writing failed: %m\n", __LINE__);
+      printf ("%u: fdopen of temp file for writing failed: %m\n", __LINE__);
       exit (1);
     }
 
@@ -275,7 +274,7 @@ main (void)
   res = fclose (fp);
   if (res != 0)
     {
-      printf ("%Zd: fclose after line-wise writing failed (%d): %m\n",
+      printf ("%u: fclose after line-wise writing failed (%d): %m\n",
              __LINE__, res);
       exit (1);
     }
@@ -284,7 +283,7 @@ main (void)
   fp = fdopen (dup (fd), "r");
   if (fp == NULL)
     {
-      printf ("%Zd: fdopen of temp file for reading failed: %m\n", __LINE__);
+      printf ("%u: fdopen of temp file for reading failed: %m\n", __LINE__);
       exit (1);
     }
 
@@ -292,7 +291,7 @@ main (void)
     {
       if (fgetws (wcp, &wc2buf[wcsize] - wcp + 1, fp) == NULL)
        {
-         printf ("%Zd: short read using fgetws (only %Zd of %Zd)\n",
+         printf ("%u: short read using fgetws (only %td of %Zd)\n",
                  __LINE__, wcp - wc2buf, wcsize);
          status = 1;
          break;
@@ -302,26 +301,26 @@ main (void)
 
   if (wcp > &wc2buf[wcsize])
     {
-      printf ("%Zd: fgetws read too much\n", __LINE__);
+      printf ("%u: fgetws read too much\n", __LINE__);
       status = 1;
     }
   else if (fgetwc (fp) != WEOF)
     {
       /* There should be nothing else.  */
-      printf ("%Zd: too many characters available with fgetws\n", __LINE__);
+      printf ("%u: too many characters available with fgetws\n", __LINE__);
       status = 1;
     }
 
   if (wcp >= &wc2buf[wcsize] && wmemcmp (wcbuf, wc2buf, wcsize) != 0)
     {
-      printf ("%Zd: buffer read with fgetws differs\n", __LINE__);
+      printf ("%u: buffer read with fgetws differs\n", __LINE__);
       status = 1;
     }
 
   res = fclose (fp);
   if (res != 0)
     {
-      printf ("%Zd: fclose after single-character reading failed (%d): %m\n",
+      printf ("%u: fclose after single-character reading failed (%d): %m\n",
              __LINE__, res);
       exit (1);
     }
@@ -333,13 +332,13 @@ main (void)
   fp = fdopen (fd, "r");
   if (fp == NULL)
     {
-      printf ("%Zd: fdopen of temp file for reading failed: %m\n", __LINE__);
+      printf ("%u: fdopen of temp file for reading failed: %m\n", __LINE__);
       exit (1);
     }
 
   if (fread (mb2buf, 1, mbsize, fp) != mbsize)
     {
-      printf ("%Zd: cannot read all of the temp file\n", __LINE__);
+      printf ("%u: cannot read all of the temp file\n", __LINE__);
       status = 1;
     }
   else
@@ -347,13 +346,13 @@ main (void)
       /* Make sure there is nothing left.  */
       if (fgetc (fp) != EOF)
        {
-         printf ("%Zd: more input avilable", __LINE__);
+         printf ("%u: more input available\n", __LINE__);
          status = 1;
        }
 
       if (memcmp (mb2buf, mbbuf, mbsize) != 0)
        {
-         printf ("%Zd: buffer written with fputws differs\n", __LINE__);
+         printf ("%u: buffer written with fputws differs\n", __LINE__);
          status = 1;
        }
     }
@@ -361,10 +360,13 @@ main (void)
   res = fclose (fp);
   if (res != 0)
     {
-      printf ("%Zd: fclose after single-character reading failed (%d): %m\n",
+      printf ("%u: fclose after single-character reading failed (%d): %m\n",
              __LINE__, res);
       exit (1);
     }
 
   return status;
 }
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"