bug-indent
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

double const in C++


From: Santiago Vila
Subject: double const in C++
Date: Tue, 13 Apr 2010 19:29:39 +0200 (CEST)
User-agent: Alpine 1.10 (DEB 962 2008-03-14)

Hello.

In src/handletoken.c there is the following comment:

    /* handle C++ const function declarations like
     * const MediaDomainList PVR::get_itsMediaDomainList() const
     * {
     * return itsMediaDomainList;
     * }
     * by ignoring "const" just after a parameter list */

but unfortunately it does not seem to work. Trying to indent


const MediaDomainList
PVR::get_itsMediaDomainList () const
{
  return itsMediaDomainList;
}


gives this as a result:


const MediaDomainList
PVR::get_itsMediaDomainList () const const
{
  return itsMediaDomainList;
}


This has been reported to Debian twice:

http://bugs.debian.org/349065
http://bugs.debian.org/507173

and two different patches have been proposed.

In the first report the following patch (adapted to 2.2.11) is proposed:

diff -ru indent-2.2.11.orig/src/handletoken.c indent-2.2.11/src/handletoken.c
--- indent-2.2.11.orig/src/handletoken.c        2009-02-15 12:20:42.000000000 
+0100
+++ indent-2.2.11/src/handletoken.c     2010-04-13 19:05:31.102380877 +0200
@@ -1452,7 +1452,7 @@
     if ((parser_state_tos->last_token == rparen) &&
         parser_state_tos->in_parameter_declaration &&
         parser_state_tos->saw_double_colon &&
-        !strncmp (token, "const", 5))
+        ! (strncmp (token, "const", 5)==0))
     {
         char           * t_ptr;
         set_buf_break (bb_const_qualifier, paren_target);


In the second report the following patch is proposed:


diff -ru -U 5 indent-2.2.11.orig/src/handletoken.c 
indent-2.2.11/src/handletoken.c
--- indent-2.2.11.orig/src/handletoken.c        2009-02-15 12:20:42.000000000 
+0100
+++ indent-2.2.11/src/handletoken.c     2010-04-13 19:12:49.090379797 +0200
@@ -1454,19 +1454,21 @@
         parser_state_tos->saw_double_colon &&
         !strncmp (token, "const", 5))
     {
         char           * t_ptr;
         set_buf_break (bb_const_qualifier, paren_target);
+#if 0  /* fix doubling of C++ tokens */
         *(e_code++) = ' ';
 
         for (t_ptr = token; t_ptr < token_end; ++t_ptr)
         {
             check_code_size();
             *(e_code++) = *t_ptr;
         }
 
         *e_code = '\0';     /* null terminate code sect */
+#endif /* fix doubling of C++ tokens */
     }
     else
     {
         
         if (!parser_state_tos->sizeof_mask)


Could the author please tell me if any of those patches is correct?

Thanks.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]