Skip to content

malformed utf8 message: small cleanups #21616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

happy-barney
Copy link

  • use symbol names instead of magic number with comment
  • transpose die/warn argument into symbol (macro name)
  • make flags argument optional
  • encapsulate lookup-and-die combo into single symbol (macro)

@iabyn
Copy link
Contributor

iabyn commented Nov 6, 2023

I'm really not keen on the second commit. Most of the macros don't really add value, so instead they just make things more obscure - someone reading the code has to look up the source of the macro to understand what it's doing. For the one macro ENSURE_NOT_MALFORMED_UTF8 which actually does something substantial, it's only used once, so it seems to me that a simple code comment along the lines of '/* ensure the the utf8 is not malformed */' would be more useful. Unless you envisage this macro subsequently used in multiple places?
But in any case, things like this should be done as static functions these days rather than macros.

@happy-barney
Copy link
Author

For the one macro ENSURE_NOT_MALFORMED_UTF8 which actually does something substantial, it's only used once

It is actually used 4 times.

I've created this macros to pinpoint calling differences for now. In my experience when programmers see such small differences they usually come up with subsequent cleanups leading to less code - but you have to formalize intention first.

@iabyn
Copy link
Contributor

iabyn commented Nov 7, 2023 via email

@happy-barney
Copy link
Author

So I don't object now to ENSURE_NOT_MALFORMED_UTF8() being added, but as an inline function rather than than a macro.

located where ?

I still don't like the other proposed macros.

inline functions?

As a long-running code-base, we've learned to become cautious about code churn. More often that not, attempts to "tidy up the code" etc just risk introducing new bugs for relatively little potential gain.

depends on approach, small changes like this vs few hundreds commits modifying thousands of lines ...

@iabyn
Copy link
Contributor

iabyn commented Nov 9, 2023 via email

@happy-barney
Copy link
Author

On Tue, Nov 07, 2023 at 04:25:48AM -0800, Branislav Zahradník wrote: > So I don't object now to ENSURE_NOT_MALFORMED_UTF8() being added, but as an inline function rather than than a macro. located where ?
inline.h usually.

there is one issue ... macro generates NOT_REACHED, currently it is used in caller

@iabyn
Copy link
Contributor

iabyn commented Nov 10, 2023 via email

@jkeenan
Copy link
Contributor

jkeenan commented Nov 22, 2023

@happy-barney, before we go further with this pull request, could you investigate the test failure being reported by our CI here? Please run make test_porting and get a PASS before re-pushing your branch. Thanks.

@happy-barney
Copy link
Author

@jkeenan I pushed because I had problem to run tests at all (complains about missing Math-BigRat)

Now I'm looking into what is causing this - somewhere this check is called on zero-length string (quickfix - skip generated assert(length))

@jkeenan
Copy link
Contributor

jkeenan commented Aug 26, 2024

@jkeenan I pushed because I had problem to run tests at all (complains about missing Math-BigRat)

Now I'm looking into what is causing this - somewhere this check is called on zero-length string (quickfix - skip generated assert(length))

There has been no discussion in this ticket in approximately 9 months. It has acquired merge conflicts in the interim. The code reviewer was skeptical of several parts of the code changes. I doubt we're going to move forward with this, so I'm labeling it 'Closable?' for now.

@jkeenan jkeenan added the Closable? We might be able to close this ticket, but we need to check with the reporter label Aug 26, 2024
@happy-barney
Copy link
Author

I can fix conflict, but question is, will it be merged then?

@khwilliamson
Copy link
Contributor

@happy-barney I would merge the first commit, and work with you on the second

@happy-barney
Copy link
Author

@khwilliamson ok, so rebasing with first commit only

symbols expressing meaning are easier to understand, easier to grep,
as well as resistant to change value without changing comment
@jkeenan jkeenan removed the Closable? We might be able to close this ticket, but we need to check with the reporter label Aug 26, 2024
@khwilliamson
Copy link
Contributor

It's still showing conflicts

@khwilliamson khwilliamson merged commit 319f5a3 into Perl:blead Aug 26, 2024
@khwilliamson
Copy link
Contributor

@happy-barney please create a new P.R. with the other commit, and we can work on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants