Closed jpco closed 10 months ago
In fairness, the bug report has been sitting there for that long and I haven't done anything about it :)
Thanks! Hopefully it won't take be 5-6 years to review this...
Do we care about mixing declarations and code? I'm not sure which version of C we target, but I was under impression the rest of the code base doesn't mix them. The splitstring_r function is not reentrant in the conventional sense of the word (and doesn't need to be), so the comment that says it is might be misleading. Other than that it looks okay to me and seems to be fixing what it claims to be fixing in a reasonable way.
Admittedly, I've always been really sloppy with C versions. It would be a good idea to start compiling with something like -ansi
if folks agree that's the flag to set (Well, actually -- I just tried it and the compiler immediately barfed on S_IFREG
and friends in access.c. Hmm. I'll just use -Wdeclaration-after-statement
for now.)
I agree splitstring_r
was incorrect. I renamed it to stepsplit
, to correspond with startsplit
and endsplit
.
Regarding C versions, it has probably been C with compiler extensions for a while.
I downloaded the version 0.84 tarball for example, and the code for $&access
declares a new list near the end of the function; the mailing list archives indicate that version was announced in April 1993, only 3-4 years after C89/C90 was ratified and 6 years before C99.
@memreflect: Ref macro starts a new block.
@mwgamera: Of course it does... Thank you for pointing out my mistake.
@wryun , would you be willing to take a look at this? I addressed everything in https://github.com/wryun/es-shell/pull/52#issuecomment-1509860293.
Ok, if you're confident! I'm generally terrified of C string handling bugs, and even with you cleaning it up (nice) it still has a few too many conditionals for my liking, but without a proper test suite...
Three classes of error with GCDEBUG (or just GCALWAYS), which probably represent latent memory unsafety:
It's unbelievable that I've taken 5-6 years to actually submit this pull request. Also sorry for being bad at Github and sending this a couple times.
Fixes https://github.com/wryun/es-shell/issues/18