From MAILER-DAEMON Fri Mar 20 16:41:04 2020 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jFOS0-0000Yx-AQ for mharc-bug-indent@gnu.org; Fri, 20 Mar 2020 16:41:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59742) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFLNN-0003pG-99 for bug-indent@gnu.org; Fri, 20 Mar 2020 13:24:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jFLNM-0000dT-7Y for bug-indent@gnu.org; Fri, 20 Mar 2020 13:24:05 -0400 Received: from p3plsmtpa07-09.prod.phx3.secureserver.net ([173.201.192.238]:49088) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jFLNM-0000d8-29 for bug-indent@gnu.org; Fri, 20 Mar 2020 13:24:04 -0400 Received: from [192.168.0.5] ([24.130.69.223]) by :SMTPAUTH: with ESMTPSA id FLNKji4rrpuo9FLNKj0Htu; Fri, 20 Mar 2020 10:24:02 -0700 X-CMAE-Analysis: v=2.3 cv=HYtqsRM8 c=1 sm=1 tr=0 a=WG7lOHKARwAfRwNMMpK8Bg==:117 a=WG7lOHKARwAfRwNMMpK8Bg==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=1Y4rCF6rAAAA:8 a=K4ZnvHA07PBGN7cMr3gA:9 a=QEXdDO2ut3YA:10 a=oiTXgvufkUkA:10 a=dLhjMjanz3J4r2Btc4AA:9 a=Z1GOiw8Q7CcPwxQ6:21 a=_W_S_7VecoQA:10 a=L_0VFsciKLuZpDht6ITv:22 a=pHzHmUro8NiASowvMSCR:22 a=Ew2E2A-JSTLzCXPT_086:22 X-SECURESERVER-ACCT: david@paktor.biz From: "David L. Paktor" Subject: Indent version 2.2.12; One other question... To: bug-indent@gnu.org Message-ID: <3da6c803-af41-7e90-abef-54daa07c58fe@paktor.biz> Date: Fri, 20 Mar 2020 10:24:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 Content-Language: en-US X-CMAE-Envelope: MS4wfP/lUdullPIY+av7TEWXg1tMwGE2oSAtHbqKOmHVX+TsRSKH16VNeCMjSICZKmOKpBRyMVYOF/v9kgAkTIb7zs4eycBWqTC1K0wjlUBZLVGdGIzqDhMB rfJwyIoUEj8C8U0m5L8eIqfOV8darcOQNWHUv/rTivk/GLLF/9/8Ijb0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 173.201.192.238 X-Mailman-Approved-At: Fri, 20 Mar 2020 16:41:02 -0400 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: bug-indent@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "GNU indent discussion, bug reports, suggestions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2020 17:24:06 -0000 Also, one other question... There is a passage that has me somewhat confused. It is in handletoken.c  now lines 1200 .. 1206. It goes like this: |    do|| ||    {|| ||        if (parse (lbrace) != total_success)|| ||        {|| ||            *file_exit_value = indent_error;|| ||        }|| ||    } while(0);| The part that confuses me is the enclosing *do {* // *} while(0);* My understanding is that this simply means that the enclosed /||/   will be done, unconditionally, once only, in a manner that is exactly equivalent to simply ///||/ (or maybe |*{* // *}*| if the enclosure gives some meaningful scope, which, in this instance, it does not) without the enclosing *|do {  } while(0);|* Is there something subtle going on that somehow escapes me? Please advise... -- David L. Paktor Sr Firmware Engineer — Embedded Software Mail: David@Paktor.biz Mobil: 408 761 3220 From MAILER-DAEMON Fri Mar 20 16:41:04 2020 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jFOS0-0000Z8-Fz for mharc-bug-indent@gnu.org; Fri, 20 Mar 2020 16:41:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59753) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFLNP-0003pO-MP for bug-indent@gnu.org; Fri, 20 Mar 2020 13:24:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jFLNM-0000dh-Sl for bug-indent@gnu.org; Fri, 20 Mar 2020 13:24:07 -0400 Received: from p3plsmtpa07-08.prod.phx3.secureserver.net ([173.201.192.237]:51256) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jFLNL-0000cz-Vr for bug-indent@gnu.org; Fri, 20 Mar 2020 13:24:04 -0400 Received: from [192.168.0.5] ([24.130.69.223]) by :SMTPAUTH: with ESMTPSA id FLNJjCnPDgF1jFLNJjvBMY; Fri, 20 Mar 2020 10:24:01 -0700 X-CMAE-Analysis: v=2.3 cv=FMRlONgs c=1 sm=1 tr=0 a=WG7lOHKARwAfRwNMMpK8Bg==:117 a=WG7lOHKARwAfRwNMMpK8Bg==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=1Y4rCF6rAAAA:8 a=bDcIOtlaIHeMFfFSgHgA:9 a=N3fElBIoOLMs1Ae9:21 a=9yiuIQYUKNJjx9c3:21 a=QEXdDO2ut3YA:10 a=oiTXgvufkUkA:10 a=kvJhug4ar7TKRTEH-3AA:9 a=SylEAmZB_3EDCZat:21 a=MGb4JHhVkhyFj2KH:21 a=-82HnECNmpoypMoK:21 a=_W_S_7VecoQA:10 a=fLnOVQkgnJZ-N_lCWxsA:9 a=49ladYHvHUoA:10 a=HiLRGq3uS_oA:10 a=L_0VFsciKLuZpDht6ITv:22 a=pHzHmUro8NiASowvMSCR:22 a=xoEH_sTeL_Rfw54TyV31:22 X-SECURESERVER-ACCT: david@paktor.biz From: "David L. Paktor" Subject: Indent version 2.2.12; cuddle-else does not work as described To: bug-indent@gnu.org Message-ID: <114a2339-259f-c0bb-efaf-41e28a8befb7@paktor.biz> Date: Fri, 20 Mar 2020 10:24:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2CC21460ED269304AFD99396" Content-Language: en-US X-CMAE-Envelope: MS4wfFrS+dqnPEpNKv/XlW1C0GbJRhfkM40KnstPLRohKIZsxcX+z3itoSp4BAKrxUQvvkAB30O19UaHm5WyBcLRmNKCdnOlCUr++wLzoMg69mNdaTxwxZjx FUOI4/Q4bGD4sdIdDTHQzO2M6G/HLBcO0ws/QdbsnupWxujvHXnvyeuQ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 173.201.192.237 X-Mailman-Approved-At: Fri, 20 Mar 2020 16:41:02 -0400 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: bug-indent@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "GNU indent discussion, bug reports, suggestions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2020 17:24:10 -0000 This is a multi-part message in MIME format. --------------2CC21460ED269304AFD99396 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Greetings. I hope there are still people who still support and maintain indent It is a very useful tool for many things, including managing and untangling "legacy" code, which is what recently brought it back to my attention. I was somewhat frustrated, though, to find that, in version 2.2.12, the  "cuddle-else"  option does not work as expected. Using the options |*-npro -st -ce -bl -bli0 -blf -cdw -i4 -nut -sc -npsl -ts4*|   , it generated: *|    } else|** ****||**|{|* instead of *|    } else {|*| | which is what the man-page promises. So I directed my attentions to the  indent  program itself. The attached file contains my proposed fix, in  diff  format: Each file named in the form *foobar.x_diffs*  contains the diff between the released *foobar.x*  and my changes. I hope that whoever is supporting and maintaining this useful tool will incorporate my changes into a new release, and will do so in short order. Thank you in advance. I will now explain my changes, below: There are six categories of changes: 1. The ones essential to the fix 2. Bringing some variables out of local scope to global, in order to facilitate tracing during debug. This had other ramifications, which needed to be accommodated. 3. Declaring those variables as "extern"s caused some naming conflict ("shadow"ing) errors. I made some changes to mitigate the errors, then found found that they were too numerous to overcome, so I left a large comment for future reference. 4. There was a passage of dead code that was not obvious, so I made it obvious 5. Changing the version number (You might want to change it again; I used  2.2.13Beta ) 6. Punctuation, capitalization and coding nit-picks. ------------------------------------------------------------------------ |::::::::::::::|| ||src/indent.c_diffs|| ||::::::::::::::|| ||134a135,138|| ||> codes_ty       type_code       = start_token;|| ||> BOOLEAN        force_nl        = false;|| ||> || ||> || | These are the variables I brought out of local scope to global, to more easily follow during debug ------------------------------------------------------------------------ |159,160d162|| ||<     codes_ty       * type_code,|| ||<     BOOLEAN        * force_nl,| These are the variables I brought out of local scope to global, to more easily follow during debug ------------------------------------------------------------------------ |159,160d162|| ||<     codes_ty       * type_code,|| ||<     BOOLEAN        * force_nl,| Eliminate pointers to the now-global variables, which had been passed as parameters to the  search_brace()  function. These caused some of the "shadow"ing errors, and (at first...) interfered with tracing during debug ------------------------------------------------------------------------ |187c189|| ||<         cur_token = *type_code;|| ||---|| ||>         cur_token = type_code;| No longer being pointers, we could access the globals directly. ------------------------------------------------------------------------ |198c200,204|| ||<             /* Ignore buffering if no comment stored. */|| ||---|| ||>             if ( (parser_state_tos->last_token == sp_else )|| ||>                && settings.cuddle_else )|| ||>             {|| ||>                  force_nl = false;|| ||>             }|| ||199a206|| ||>             /* Ignore buffering if no comment stored. */| This was one essential part of the fix. If we are here, we know the current token is a left-bracket. If the previous token was an "else", and  cuddle_else  is in effect, we do not want to force the next line out until the left-bracket is incorporated into the output line. ------------------------------------------------------------------------ |320c327|| ||<             if (((*type_code == sp_paren) && (*token == 'i') &&    /* "if" statement */|| ||---|| ||>             if (((type_code == sp_paren) && (*token == 'i') &&    /* "if" statement */|| ||322c329|| ||<                 ((*type_code == sp_else) &&     /* "else" statement */|| ||---|| ||>                 ((type_code == sp_else) &&     /* "else" statement */|| ||327c334|| ||<                 *force_nl = false;|| ||---|| ||>                 force_nl = false;|| ||331c338|| ||<                 *force_nl = true;|| ||---|| ||>                 force_nl = true;|| ||346c353|| ||<             if (*force_nl)|| ||---|| ||>             if (force_nl)|| ||348c355|| ||<                 *force_nl = false;|| ||---|| ||>                 force_nl = false;|| ||384c391|| ||<         if (*type_code != code_eof)|| ||---|| ||>         if (type_code != code_eof)|| ||387c394|| ||<             *type_code = lexi();|| ||---|| ||>             type_code = lexi();|| ||412c419|| ||<                 (*type_code == newline || *type_code == comment) &&|| ||---|| ||>                 (type_code == newline || type_code == comment) &&|| ||418c425|| ||<                 } else if (*type_code == newline) {|| ||---|| ||>                 } else if (type_code == newline) {|| ||428c435|| ||<         if ((*type_code == ident) && *flushed_nl &&|| ||---|| ||>         if ((type_code == ident) && *flushed_nl &&||| All of the above are in the *search_brace()*  function; no longer pointers, we're accessing the global variables directly. ------------------------------------------------------------------------ |451d457|| ||<     codes_ty         type_code       = start_token;|| ||462,463d467|| ||<     BOOLEAN          force_nl        = false;|| ||< | These are where the now-global variables had been in local scope ------------------------------------------------------------------------ |548c552|| ||<         if (!search_brace(&type_code, &force_nl, &flushed_nl, &last_else,|| ||---|| ||>         if (!search_brace(&flushed_nl, &last_else,| No longer parameters to  search_brace() ------------------------------------------------------------------------ |581c585|| ||<             return file_exit_value; /* RETURN */|| ||---|| ||>             return file_exit_value;                                /* RETURN */|| ||610c614|| ||< * indentation. this is|| ||---|| ||> * indentation. This is| The punctuation and capitalization nit-picks ------------------------------------------------------------------------ |::::::::::::::|| ||src/handletoken.c_diffs|| ||::::::::::::::|| ||1121c1121,1123|| ||<         if ((!parser_state_tos->in_decl && !settings.btype_2) |||| ||---|| ||>         if ( !((parser_state_tos->last_token == sp_else ) &&|| ||>                 settings.cuddle_else ) &&|| ||>            ((!parser_state_tos->in_decl && !settings.btype_2) |||| ||1124c1126|| ||< !settings.braces_on_func_def_line))|| ||---|| ||> !settings.braces_on_func_def_line)) )|| | The other essential part of the fix. Similar explanation... ------------------------------------------------------------------------ |1313a1316|| ||>     *e_code = '\0';| The coding nit-pick. ------------------------------------------------------------------------ |1373,1381c1376,1384|| ||<         else if (!settings.braces_on_struct_decl_line &&|| ||< (parser_state_tos->block_init != 1))|| ||<         {|| ||<             *force_nl = true;|| ||<         }|| ||<         else|| ||<         {|| ||<           /* what ? */|| ||<         }|| ||---|| ||> //      else if (!settings.braces_on_struct_decl_line &&|| ||> // (parser_state_tos->block_init != 1))|| ||> //      {|| ||> //          *force_nl = true;|| ||> //      }|| ||> //      else|| ||> //      {|| ||> //        /* what ? */|| ||> //      }| This is the dead-code passage, killed by the surrounding  #if 0 ... #endif ------------------------------------------------------------------------ |::::::::::::::|| ||src/output.h_diffs|| ||::::::::::::::|| ||55c55|| ||<     int       force_nl,|| ||---|| ||>     BOOLEAN   dump_nl,| This was another place that caused some of the "shadow"ing errors. The *dump_line()*  function is only ever called with a *true*  for that parameter; technically, if could have been eliminated completely, but that would have required chasing down all the places where it is called. It was easier to just rename the parameter. (Not that it helped, ultimately, but it's a start...). ------------------------------------------------------------------------ |::::::::::::::|| ||src/output.c_diffs|| ||::::::::::::::|| ||997c997|| ||<     int          force_nl,|| ||---|| ||>     BOOLEAN      dump_nl,|| ||1010c1010|| ||<     else if (force_nl)|| ||---|| ||>     else if (dump_nl)|| ||1293c1293|| ||<     if (buf_break_used && (s_code != e_code) && force_nl)|| ||---|| ||>     if (buf_break_used && (s_code != e_code) && dump_nl)| Renaming the parameter to mitigate the "shadow"ing errors. ------------------------------------------------------------------------ |::::::::::::::|| ||src/indent.h_diffs|| ||::::::::::::::|| ||350a351,363|| ||> /*|| ||>  *    We moved these two from local scope to global to facilitate tracing|| ||>  *        during debug. We would have liked to declare them "extern"s, but|| ||>  *        we ran into naming conflict ("shadow"ing) errors, and they were|| ||>  *        too numerous to overcome at the time. We reluctantly leave this|| ||>  *        notation while we comment-out the "extern" declarations we would|| ||>  *        have liked to have here, and hope some future maintainer will|| ||>  *        diligently fix them.   DLP, 20 Mar 2020|| ||>  */|| ||> /* extern codes_ty type_code;|| ||>  * extern BOOLEAN  force_nl ;|| ||>  */|| ||> || | Comment explains it all... ------------------------------------------------------------------------ |::::::::::::::|| ||configure_diffs|| ||::::::::::::::|| ||583,584c583,584|| ||< PACKAGE_VERSION='2.2.12'|| ||< PACKAGE_STRING='GNU Indent 2.2.12'|| ||---|| ||> PACKAGE_VERSION='2.2.13Beta'|| ||> PACKAGE_STRING='GNU Indent 2.2.13Beta'|| ||3063c3063|| ||<  VERSION='2.2.12'|| ||---|| ||>  VERSION='2.2.13Beta'| Version number change. ------------------------------------------------------------------------ Again, please incorporate my changes into a new release, and in short order. Thank you in advance. Of course, if you have any questions, please reply to this letter. -- David L. Paktor Sr Firmware Engineer — Embedded Software Mail: David@Paktor.biz Mobil: 408 761 3220 --------------2CC21460ED269304AFD99396 Content-Type: application/gzip; name="CuddleElseBugFix.tar.gz" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="CuddleElseBugFix.tar.gz" H4sICAOmdF4AA0N1ZGRsZUVsc2VCdWdGaXgudGFyAO1ZW2/bNhTOc37FSR7iCxxHFCXZRpsO 3RYUwbq0SNvtZYAgU1QsRJYCiaqTtfnvO6QUSZbkOsnSeMV8kPgiHn7nQvLwI53E7MgPXR6K IbNd3/OSnScXDcWyDPlORqZWfZdimCN9h1CLmkTXTWu0oxGDWuYOaE/vSlPSRDgxwI7ruHEa /L1Sb137DyqEGg6h5oDQ8e4rYJHLE1vcQCbi5orb8ln+/RhksoQtoksevkD9n9+9e3vy+ixv Bi+KGbfDAAp9zwkSLjXlHzEnA2JpLrH03ZdKoWavX1oc5Bo1C/3CxmCXjEeMjCe5ooJL48w3 tNwvoF7sHh4eov02rYoSmYyZrmkDXTMqkFKO+nB6EUYxh2nqeTz2wwvwPQgj9H8+x6WDacFW dwj9o5otKajahe6VEyc8tjGBgqP55PBV4CTizhHM7JXNMVfQq/VGOTiAhAuBZpMhS1034O2q X5pdK2NSGYyq3G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