Refactoring code stripping trailing \n and \r from strings

Started by Michael Paquierover 6 years ago4 messageshackers
Jump to latest
#1Michael Paquier
michael@paquier.xyz

Hi Tom,

b654714 has reworked the way we handle removal of CLRF for several
code paths, and has repeated the same code patterns to do that in 8
different places. Could it make sense to refactor things as per the
attached with a new routine in common/string.c?

Thanks,
--
Michael

Attachments:

stringt-crlf-refactor-v1.patchtext/x-diff; charset=us-asciiDownload+47-48
#2Bruce Momjian
bruce@momjian.us
In reply to: Michael Paquier (#1)
Re: Refactoring code stripping trailing \n and \r from strings

On Thu, Aug 1, 2019 at 12:18:20PM +0900, Michael Paquier wrote:

Hi Tom,

b654714 has reworked the way we handle removal of CLRF for several
code paths, and has repeated the same code patterns to do that in 8
different places. Could it make sense to refactor things as per the
attached with a new routine in common/string.c?

Yes, I think this is a good idea.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +
#3Michael Paquier
michael@paquier.xyz
In reply to: Bruce Momjian (#2)
Re: Refactoring code stripping trailing \n and \r from strings

On Tue, Aug 06, 2019 at 03:10:33PM -0400, Bruce Momjian wrote:

On Thu, Aug 1, 2019 at 12:18:20PM +0900, Michael Paquier wrote:

b654714 has reworked the way we handle removal of CLRF for several
code paths, and has repeated the same code patterns to do that in 8
different places. Could it make sense to refactor things as per the
attached with a new routine in common/string.c?

Yes, I think this is a good idea.

Thanks for the review, Bruce! Tom, do you have any objections?
--
Michael

#4Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#3)
Re: Refactoring code stripping trailing \n and \r from strings

On Wed, Aug 07, 2019 at 10:10:36AM +0900, Michael Paquier wrote:

Thanks for the review, Bruce! Tom, do you have any objections?

hearing nothing but cicadas from outside, applied. There were some
warnings I missed with the first version, which are fixed.
--
Michael