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 de7f539..6963994 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 77d95b7..4dce7fa 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 7ffc71b..7a6de80 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 72b8c4a..f71b3f7 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 8057357..108346e 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 70582b7..af779cd 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 f29b05a..4cce0a9 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 3353b2e..84b5d89 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 9342f42..905e9c6 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);
     }