-
Notifications
You must be signed in to change notification settings - Fork 7
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
[Feature Request] Remove blank lines from stripped comments #3
Comments
Thanks for the feedback. Multi-line comments inside /* … */ are already
squished by default with an option to preserve the newlines (which is
important to me). Reducing consecutive single line comments to a minimum is
a good suggestion.
…On Thu, Sep 7, 2023 at 13:34 Asuna ***@***.***> wrote:
For example:
#include <stdio.h>
// Let's say// If we have multiple comments// Like the example shown// After using scc// This will leave a lot of blank lines
int main() {
printf("hello, world\n");
}
Run ./scc example.c, get result:
#include <stdio.h>
int main() {
printf("hello, world\n");
}
It would be nice to add an option (or even by default) to remove these
blank lines, for the example, I would expect more of this:
#include <stdio.h>
int main() {
printf("hello, world\n");
}
Anyways, this is a great tool, it has helped me a lot! Thank you!
—
Reply to this email directly, view it on GitHub
<#3>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCAHBSM64LLDMEVBORPG43XZG5OXANCNFSM6AAAAAA4O2RZXM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
QQ: In the example code, the desired output has one blank line where there
was originally a blank line, 5 comment lines, and another blank line.
Should the output simply reduce all sequences of 2 or more consecutive
blank lines (3 or more consecutive newline characters) to one blank line (2
newline characters)? Or should there be two blank lines because they were
both there originally.
Suppose the input was like this (line numbers added for clarity):
1 #include <stdio.h>
2
3 // Let's say
4 // If we have multiple comments
5 /* Like the */ /* example shown */
6 // After using scc
7 // This will leave a lot of blank lines
8
9 int main() {
10
11
12 printf("hello, world\n");
13 }
Should the middle comment line (line 5) be eliminated, even though
there's a space in that line?
ATM, SCC reduces that to an empty line, which I think is the correct
behaviour, and the 'compressing newlines' code should eliminate it
too.
Also, should one of lines 10 and 11 be eliminated?
I think it is going to be easier to reduce all occurrences of multiple
adjacent blank lines to a single blank line than to do it only when
there was a comment eliminated.
Thus, it would be fairly easy to eliminates lines 3-8 and 11 and
harder to only eliminate lines 3-7. Or, at least, there's a technique
that makes it fairly easy.
Any thoughts?
…On Thu, Sep 7, 2023 at 6:34 AM Asuna ***@***.***> wrote:
For example:
#include <stdio.h>
// Let's say// If we have multiple comments// Like the example shown// After using scc// This will leave a lot of blank lines
int main() {
printf("hello, world\n");
}
Run ./scc example.c, get result:
#include <stdio.h>
int main() {
printf("hello, world\n");
}
It would be nice to add an option (or even by default) to remove these
blank lines, for the example, I would expect more of this:
#include <stdio.h>
int main() {
printf("hello, world\n");
}
Anyways, this is a great tool, it has helped me a lot! Thank you!
—
Reply to this email directly, view it on GitHub
<#3>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCAHBSM64LLDMEVBORPG43XZG5OXANCNFSM6AAAAAA4O2RZXM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Jonathan Leffler ***@***.***> #include <disclaimer.h>
Guardian of DBD::Informix - v2018.1031 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."
|
I haven't read
As a user, I would want only 1 blank line to be kept in my example because the blocks in the original (with comments) are also separated by only 1 blank line.
I agree with that. Keeping spaces between them doesn't make much sense to me.
IMO, I think
What about we add a new CLI option to "squash blank lines around deleted comments"? If the option is not specified, the original blank lines will be kept, otherwise the original blank lines will be squashed into only 1 blank lines. To demonstrate what I mean, for example 1: #include <stdio.h>
2:
3:
4: // This is a comment, above are 2 blank lines
5: // This is a comment, below are 3 blank lines
6:
7:
8:
9: int main() {
10:
11:
12: printf("hello, world\n");
13: } If the new CLI option is not specified, the 5 blank lines around the comments are still kept, the 2 blank lines that are not around the comment are always kept whether or not the CLI option is specified. 1: #include <stdio.h>
2:
3:
4:
5:
6:
7: int main() {
8:
9:
10: printf("hello, world\n");
11: } If the new CLI option is specified, the 5 blank lines will be squashed into 1 blank line. 1: #include <stdio.h>
2:
3: int main() {
4:
5:
6: printf("hello, world\n");
7: } I'm not sure how hard it would be, since I'm not thinking specifically about implementation details. But if you have more questions feel free to discuss them with me, I'd be happy to help in some way. |
For example:
Run
./scc example.c
, get result:It would be nice to add an option (or even by default) to remove these blank lines, for the example, I would expect more of this:
Anyways, this is a great tool, it has helped me a lot! Thank you!
The text was updated successfully, but these errors were encountered: