]> Savannah Git Hosting - gnulib.git/commitdiff
parse-datetime, tests: don't use "string" + int
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 May 2013 00:20:41 +0000 (17:20 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 May 2013 00:21:05 +0000 (17:21 -0700)
Recent versions of 'clang' complain about C source code that
uses expressions of the form '"string literal" + integer',
I guess on the theory that it's confusing for readers who are
used to C++.  On those grounds I suppose it's OK to make this
minor style change.
* lib/parse-datetime.y (parse_datetime):
* tests/test-fchdir.c (main):
* tests/test-snprintf-posix.h (test_function):
* tests/test-snprintf.c (main):
* tests/test-vasnprintf-posix.c (test_function):
* tests/test-vasnprintf.c (test_function):
* tests/test-vsnprintf.c (main):
* tests/unistdio/test-ulc-asnprintf1.h (test_function):
Rewrite '"str" + E' to '&"str"[E]'.

ChangeLog
lib/parse-datetime.y
tests/test-fchdir.c
tests/test-snprintf-posix.h
tests/test-snprintf.c
tests/test-vasnprintf-posix.c
tests/test-vasnprintf.c
tests/test-vsnprintf.c
tests/unistdio/test-ulc-asnprintf1.h

index de7f53993915cc378a38adb333c4a6a923ce356d..69639940e290a82d6dd9c7f23d05c65ff719f27e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2013-05-18  Paul Eggert  <eggert@cs.ucla.edu>
+
+       parse-datetime, tests: don't use "string" + int
+       Recent versions of 'clang' complain about C source code that
+       uses expressions of the form '"string literal" + integer',
+       I guess on the theory that it's confusing for readers who are
+       used to C++.  On those grounds I suppose it's OK to make this
+       minor style change.
+       * lib/parse-datetime.y (parse_datetime):
+       * tests/test-fchdir.c (main):
+       * tests/test-snprintf-posix.h (test_function):
+       * tests/test-snprintf.c (main):
+       * tests/test-vasnprintf-posix.c (test_function):
+       * tests/test-vasnprintf.c (test_function):
+       * tests/test-vsnprintf.c (main):
+       * tests/unistdio/test-ulc-asnprintf1.h (test_function):
+       Rewrite '"str" + E' to '&"str"[E]'.
+
 2013-05-17  Alexandre Duret-Lutz  <adl@lrde.epita.fr>
 
        argmatch: port to C++
index 77d95b70351552052cfdec7af9edb8ed6067619d..4dce7fa644c6513f8f48619a852776260a0f4b70 100644 (file)
@@ -1472,7 +1472,7 @@ parse_datetime (struct timespec *result, char const *p,
                           + sizeof pc.time_zone * CHAR_BIT / 3];
               if (!tz_was_altered)
                 tz0 = get_tz (tz0buf);
-              sprintf (tz1buf, "XXX%s%ld:%02d", "-" + (time_zone < 0),
+              sprintf (tz1buf, "XXX%s%ld:%02d", &"-"[time_zone < 0],
                        abs_time_zone_hour, abs_time_zone_min);
               if (setenv ("TZ", tz1buf, 1) != 0)
                 goto fail;
index 7ffc71baa7627c020082343ac78f175e331935a7..7a6de80494278e5289d59bf93b4abbb6c291faad 100644 (file)
@@ -70,7 +70,7 @@ main (void)
   /* Repeat test twice, once in '.' and once in '..'.  */
   for (i = 0; i < 2; i++)
     {
-      ASSERT (chdir (".." + 1 - i) == 0);
+      ASSERT (chdir (&".."[1 - i]) == 0);
       ASSERT (fchdir (fd) == 0);
       {
         size_t len = strlen (cwd) + 1;
index 72b8c4ae370f91dde3b5f349b80537aa864c899c..f71b3f73fcf4dd086c2782162008e0c22211fa6e 100644 (file)
@@ -96,7 +96,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
               ASSERT (memcmp (buf, "12345", size - 1) == 0);
               ASSERT (buf[size - 1] == '\0');
             }
-          ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+          ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0);
         }
       else
         {
index 805735769ea713ad2d4295cbb8dc90ab41af3862..108346e12902e524d8b2579c4124c913854eded5 100644 (file)
@@ -52,7 +52,7 @@ main (int argc, char *argv[])
 #if !CHECK_SNPRINTF_POSIX
           if (size > 0)
 #endif
-            ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+            ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0);
         }
       else
         {
index 70582b71224de56e0d1a822cfd1396f6854fe28b..af779cd727711b7c2da7b23fb3534d0e0da9e426 100644 (file)
@@ -118,7 +118,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
       ASSERT (length == 5);
       if (size < 6)
         ASSERT (result != buf);
-      ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+      ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0);
       if (result != buf)
         free (result);
     }
index f29b05aeb5df6c700b8962252118dfc75ceef374..4cce0a947af4e5c1e17224bb13c84a2639e9dac9 100644 (file)
@@ -55,7 +55,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
       ASSERT (length == 5);
       if (size < 6)
         ASSERT (result != buf);
-      ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+      ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0);
       if (result != buf)
         free (result);
     }
index 3353b2eb471b1a0c160003bb047b85a729d910de..84b5d896765078e75e5d2c2419d1c559297b6e7d 100644 (file)
@@ -65,7 +65,7 @@ main (int argc, char *argv[])
 #if !CHECK_VSNPRINTF_POSIX
           if (size > 0)
 #endif
-            ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+            ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0);
         }
       else
         {
index 9342f42049b7e4aab46a7e854fe4ac5305f921cc..905e9c6ae7fd5774eccc3be960edc8a9b86cdde7 100644 (file)
@@ -47,7 +47,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
       ASSERT (length == 5);
       if (size < 6)
         ASSERT (result != buf);
-      ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+      ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0);
       if (result != buf)
         free (result);
     }