3 ms·
Tbh it's been a while since I've seen anyone manually format code. Automatically formatted code definitely does help avoid certain kinds of bugs. Does C not ha
by stevage 1y ago
Tbh it's been a while since I've seen anyone manually format code. Automatically formatted code definitely does help avoid certain kinds of bugs.
Does C not have the equivalent of Prettier?
I am curious what their editing process was that changed:
> assert(isxdigit((src+1)));
to
> if (!isxdigit(src+1)) return '\0';
- commandersaki 1y agoDoes C not have the equivalent of Prettier? There is clang-format, but it is not always easy to use on a code base because you don't want to have it run on imported/3rd party source which may mix in with your regular source tree. I've been meaning to use it on a project but only have run on an explicit list of files.
- ciupicri 1y agoThere's the good old GNU indent https://www.gnu.org/software/indent/ https://www.gnu.org/software/indent/ > But even if you fail in getting emacs to do sane formatting, not everything is lost: use indent. > Now, again, GNU indent has the same brain-dead settings that GNU emacs has, which is why you need to give it a few command line options. However, that’s not too bad, because even the makers of GNU indent recognize the authority of K&R (the GNU people aren’t evil, they are just severely misguided in this matter), so you just give indent the options -kr -i8 (stands for K&R, 8 character indents), or use scripts/Lindent, which indents in the latest style. > indent has a lot of options, and especially when it comes to comment re-formatting you may want to take a look at the man page. But remember: indent is not a fix for bad programming. (Linux kernel coding style, https://www.kernel.org/doc/html/latest/process/coding-style.html#you-ve-made-a-mess-of-it https://www.kernel.org/doc/html/latest/process/coding-style....)
- 9029 1y ago> I am curious what their editing process was They said: > I typed in the new code as that's faster than modifying the existing code
- stevage 1y agoAh. I bet there's a lot of vim users violently disagreeing...