You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm manually expanding tabs in a code base (git clone https://github.com/LegalizeAdulthood/trn.git; git checkout a34a4b0120ee729aad8a13920fde4af1cf037c05) and it's quite tedious.
First of all, you might think that an IDE would do this for you, but it turns out that Visual Studio will only untabify the indentation at the beginning of a line, so the tabs between statements and comments don't get expanded.
Secondly, you might think "Why don't you use the unix expand command?" and while that's good for files containing plain text, it isn't so good for code that might contain embedded tab characters in string or character literals. For character literals, you don't want the tab character expanded at all, as that would introduce a syntax error. For string literals, you don't want tabs expanded to modulo 8 column (or whatever your tab size is) in the source file because the start of the string literal can be at any column, and you have to worry about the presence of escaped newline characters and so-on. You can't guarantee that expanding the tabs in a string literal is a behavior-preserving transformation.
So what we're left with is the need for a tool that understands the difference between string literals and source code. You might think that clang-format would be the right tool for the job, but I don't think you can get clang-format to leave your code alone EXCEPT for expanding tabs, so we're back to the need for a tool to do this one, single operation.
The text was updated successfully, but these errors were encountered:
I'm manually expanding tabs in a code base (`git clone https://github.com/LegalizeAdulthood/trn.git`; `git checkout a34a4b0120ee729aad8a13920fde4af1cf037c05`) and it's quite tedious.
First of all, you might think that an IDE would do this for you, but it turns out that Visual Studio will only untabify the indentation at the beginning of a line, so the tabs between statements and comments don't get expanded.
Secondly, you might think "Why don't you use the unix expand command?" and while that's good for files containing plain text, it isn't so good for code that might contain embedded tab characters in string or character literals. For character literals, you don't want the tab character expanded at all, as that would introduce a syntax error. For string literals, you don't want tabs expanded to modulo 8 column (or whatever your tab size is) in the source file because the start of the string literal can be at any column, and you have to worry about the presence of escaped newline characters and so-on. You can't guarantee that expanding the tabs in a string literal is a behavior-preserving transformation.
So what we're left with is the need for a tool that understands the difference between string literals and source code. You might think that clang-format would be the right tool for the job, but I don't think you can get clang-format to leave your code alone EXCEPT for expanding tabs, so we're back to the need for a tool to do this one, single operation.
I'm manually expanding tabs in a code base (
git clone https://github.com/LegalizeAdulthood/trn.git
;git checkout a34a4b0120ee729aad8a13920fde4af1cf037c05
) and it's quite tedious.First of all, you might think that an IDE would do this for you, but it turns out that Visual Studio will only untabify the indentation at the beginning of a line, so the tabs between statements and comments don't get expanded.
Secondly, you might think "Why don't you use the unix
expand
command?" and while that's good for files containing plain text, it isn't so good for code that might contain embedded tab characters in string or character literals. For character literals, you don't want the tab character expanded at all, as that would introduce a syntax error. For string literals, you don't want tabs expanded to modulo 8 column (or whatever your tab size is) in the source file because the start of the string literal can be at any column, and you have to worry about the presence of escaped newline characters and so-on. You can't guarantee that expanding the tabs in a string literal is a behavior-preserving transformation.So what we're left with is the need for a tool that understands the difference between string literals and source code. You might think that
clang-format
would be the right tool for the job, but I don't think you can get clang-format to leave your code alone EXCEPT for expanding tabs, so we're back to the need for a tool to do this one, single operation.The text was updated successfully, but these errors were encountered: