-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add support for multiple assignment on a single line #49
Comments
Multiple declaration on a single line isn't supported (feel free to add it yourself if you want that feature). Declaration and assignment on the same line should work: int main()
{
int a = 1;
return 0;
} $ c_formatter_42 < t.c
int main(void)
{
int a;
a = 1;
return (0);
} Please provide minimal examples of code that isn't formatted property for those two cases because it seems to work for me. Variable declaration followed by a newline (I guess newline means an empty line) should work aswell: int main()
{
int a;
int b;
return 0;
} $ c_formatter_42 < t.c
int main(void)
{
int a;
int b;
return (0);
} |
|
The first example works fine for me: $ c_formatter_42 < t.c
char *get_next_line(int fd)
{
char *buffer;
char *line;
static char *storage;
if (fd < 0 || BUFFER_SIZE <= 0)
return (0);
buffer = (char *)malloc(sizeof(char) * (BUFFER_SIZE + 1));
line = read_all(fd, buffer, storage);
free(buffer);
if (!line)
{
free(storage);
storage = 0;
return (storage);
}
storage = ft_trim(line);
return (line);
} The second one (please don't ever take screenshot of code ever again) doesn't work indeed but that's only because of multiple assignments on a single line, if I put them on multiple lines, you get the expected behavior: $ c_formatter_42 < t.c
#include <stdio.h>
int main(void)
{
int a;
int b;
a = 0;
b = 0;
while (1000)
a += b * 100;
} |
#include <stdio.h>
int main(void)
{
int a;
int b;
a = 0;
b = 0;
while (1000)
a += b;
} Same issue. But yes multiple assignments when written in separate lines could work. |
Do you have the latest version? That example works for me: $ c_formatter_42 < t.c
#include <stdio.h>
int main(void)
{
int a;
int b;
a = 0;
b = 0;
while (1000)
a += b;
}
$ cat t.c
#include <stdio.h>
int main(void)
{
int a;
int b;
a = 0;
b = 0;
while (1000)
a += b;
} |
Yes I do. I used it today only. I installed it manually though . let me try the extension version :) |
Maybe the latest version on pypi.org isnt' the same as the one on this repo: git clone [email protected]:dawnbeen/c_formatter_42.git
cd c_formatter_42
python -m venv venv
. venv/bin/activate
pip install -e .
c_formatter -h |
I looked at the clang-format documentation and this stackoverflow thread but it doesn't seem possible to fix this with clang-format 😕 |
I don't think those options do what we want (look at the examples): The clang-format configuration is at https://github.com/dawnbeen/c_formatter_42/blob/master/c_formatter_42/data/.clang-format |
I used the c_formatter manually and was looking at it with different examples. I found it doesn't work with
Probable Solution :
The text was updated successfully, but these errors were encountered: