Skip to content
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

Runs together identifiers across linebreaks #13

Open
clsn opened this issue Oct 30, 2018 · 3 comments
Open

Runs together identifiers across linebreaks #13

clsn opened this issue Oct 30, 2018 · 3 comments

Comments

@clsn
Copy link

clsn commented Oct 30, 2018

Input:
`#include <stdio.h>

int
main(int argc, char **argv) {
printf("hello world\n");
}
`

Output:
#include<stdio.h> intmain(int argc,char**argv){printf("hello world\n");}
Note "intmain". Placing the return type of a function on the line before is often useful, since it lets you search for the definition of the function by searching for it at the beginning of a line.

@catb0t
Copy link

catb0t commented Oct 30, 2018

Yes, cminify is quite buggy, but search for the definition of a function could be attained with a regex like ^(?:static)\s+(int|bool|char|...)\s+\**\s+[a-zA-Z0-9_]+\s+\(... etc

@clsn
Copy link
Author

clsn commented Oct 31, 2018

Sure, but how easy is that to type in on a command line or in an editor search when you're trying to find where in all the dozens of files and thousands of lines you defined the function? The point is that some people (incl. me) do like to split the return-type from the function, for this reason (whether or not it's important for everyone), so it isn't such a bizarre and unheard-of formatting, and cminify is liable to make it into a syntax error.
I was tinkering with a patch for this, involving joining up lines with spaces instead of null-strings (which, yes, got me a lot more spaces than needed) and also not storing null-strings for removed lines, but it wasn't really right. I guess I should do it properly and submit a PR.

@catb0t
Copy link

catb0t commented Oct 31, 2018

(I use a regex like that in my editors everyday, but I can understand not wanting to ;)

As you can tell, this program isn't really actively maintained anymore, and I would maintain a fork except that --

from trying it myself I will say, unless you want to spend a week completely rewriting this library, it's very hard or impossible to fix these kinds of problems due to the very fundamental, wrong assertions that cminify makes about the actual limits of the C grammar.

And if one were to mostly re-write cminify, one might as well write a replacement entirely, and fix the other glaring bugs...

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

No branches or pull requests

2 participants