Bruno Haible wrote:
> Jim Meyering wrote:
>> @@ -77,7 +77,7 @@ main (int argc, char **argv)
>>
>>    if (STREQ (delim, "\\0"))
>>      {
>> -      delim = "";
>> +      delim = (char *) "";
>>        delim_len = 1;
>>      }
>>
>
> Instead of introducing this cast, how about making 'delim' a 'const char *'?
> I see no code that writes into 'delim'.

Definitely.  Thanks.

>From 4a325d4e3177e2072bf9eb4c327c75f98a52efa4 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Thu, 8 Mar 2012 12:04:16 +0100
Subject: [PATCH] test-readtokens.c: use const; remove unwarranted cast

* tests/test-readtokens.c: Declare delim to be const, to avoid a cast.
---
 ChangeLog               |    5 +++++
 tests/test-readtokens.c |    4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c616363..5b0f4ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-03-08  Bruno Haible  <br...@clisp.org>
+
+       test-readtokens.c: use const; remove unwarranted cast
+       * tests/test-readtokens.c: Declare delim to be const, to avoid a cast.
+
 2012-03-08  Jim Meyering  <meyer...@redhat.com>

        test-readtokens.c: avoid const-related compilation warnings
diff --git a/tests/test-readtokens.c b/tests/test-readtokens.c
index f12d39e..309dd9c 100644
--- a/tests/test-readtokens.c
+++ b/tests/test-readtokens.c
@@ -56,7 +56,7 @@ int
 main (int argc, char **argv)
 {
   token_buffer tb;
-  char *delim;
+  char const *delim;
   size_t delim_len;

   atexit (close_stdout);
@@ -77,7 +77,7 @@ main (int argc, char **argv)

   if (STREQ (delim, "\\0"))
     {
-      delim = (char *) "";
+      delim = "";
       delim_len = 1;
     }

--
1.7.9.3.363.g121f0

Reply via email to