Determine system tab stop length





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















My issue:
I'm attempting to process the contents of a file to find errors, like a compiler would (technically I am making a compiler, but this is a minor detail). I need to know the length of a tab stop on a given system or platform in order to correctly calculate the column of characters. However everywhere I've looked has not given me a way to get the system tab stop length. How can I get it, is this even possible, or is it 8 on every system?



I do not want to assume that the tab stop is every 8 characters because this seems to be different for each system and it's even configurable on most systems. And I understand that editors usually define the length of a tab stop but compilers do not and cannot use the editor to determine the length of the tab. So... what the hell do I do?



EDIT:
So if there is no simple or actual reliant way to tell how long the tab will be, (besides taking an arbitrary guess) is there an intuitive way to determine this length so that it's accurate 50% of the time or more?










share|improve this question

























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Nov 27 '18 at 0:23











  • You control the output, of the compiler, yes? You can output the error messages as you see fit. If this means you substitute the tab with a known and consistent number of characters, is the user in any position to complain? If they don't like it they can write their own dang compiler.

    – user4581301
    Nov 27 '18 at 0:33











  • That was the point I was trying to make in my answer

    – SoraKatadzuma
    Nov 27 '18 at 0:35


















2















My issue:
I'm attempting to process the contents of a file to find errors, like a compiler would (technically I am making a compiler, but this is a minor detail). I need to know the length of a tab stop on a given system or platform in order to correctly calculate the column of characters. However everywhere I've looked has not given me a way to get the system tab stop length. How can I get it, is this even possible, or is it 8 on every system?



I do not want to assume that the tab stop is every 8 characters because this seems to be different for each system and it's even configurable on most systems. And I understand that editors usually define the length of a tab stop but compilers do not and cannot use the editor to determine the length of the tab. So... what the hell do I do?



EDIT:
So if there is no simple or actual reliant way to tell how long the tab will be, (besides taking an arbitrary guess) is there an intuitive way to determine this length so that it's accurate 50% of the time or more?










share|improve this question

























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Nov 27 '18 at 0:23











  • You control the output, of the compiler, yes? You can output the error messages as you see fit. If this means you substitute the tab with a known and consistent number of characters, is the user in any position to complain? If they don't like it they can write their own dang compiler.

    – user4581301
    Nov 27 '18 at 0:33











  • That was the point I was trying to make in my answer

    – SoraKatadzuma
    Nov 27 '18 at 0:35














2












2








2


1






My issue:
I'm attempting to process the contents of a file to find errors, like a compiler would (technically I am making a compiler, but this is a minor detail). I need to know the length of a tab stop on a given system or platform in order to correctly calculate the column of characters. However everywhere I've looked has not given me a way to get the system tab stop length. How can I get it, is this even possible, or is it 8 on every system?



I do not want to assume that the tab stop is every 8 characters because this seems to be different for each system and it's even configurable on most systems. And I understand that editors usually define the length of a tab stop but compilers do not and cannot use the editor to determine the length of the tab. So... what the hell do I do?



EDIT:
So if there is no simple or actual reliant way to tell how long the tab will be, (besides taking an arbitrary guess) is there an intuitive way to determine this length so that it's accurate 50% of the time or more?










share|improve this question
















My issue:
I'm attempting to process the contents of a file to find errors, like a compiler would (technically I am making a compiler, but this is a minor detail). I need to know the length of a tab stop on a given system or platform in order to correctly calculate the column of characters. However everywhere I've looked has not given me a way to get the system tab stop length. How can I get it, is this even possible, or is it 8 on every system?



I do not want to assume that the tab stop is every 8 characters because this seems to be different for each system and it's even configurable on most systems. And I understand that editors usually define the length of a tab stop but compilers do not and cannot use the editor to determine the length of the tab. So... what the hell do I do?



EDIT:
So if there is no simple or actual reliant way to tell how long the tab will be, (besides taking an arbitrary guess) is there an intuitive way to determine this length so that it's accurate 50% of the time or more?







c++ c file






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 23:57







SoraKatadzuma

















asked Nov 26 '18 at 23:46









SoraKatadzumaSoraKatadzuma

397




397













  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Nov 27 '18 at 0:23











  • You control the output, of the compiler, yes? You can output the error messages as you see fit. If this means you substitute the tab with a known and consistent number of characters, is the user in any position to complain? If they don't like it they can write their own dang compiler.

    – user4581301
    Nov 27 '18 at 0:33











  • That was the point I was trying to make in my answer

    – SoraKatadzuma
    Nov 27 '18 at 0:35



















  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Nov 27 '18 at 0:23











  • You control the output, of the compiler, yes? You can output the error messages as you see fit. If this means you substitute the tab with a known and consistent number of characters, is the user in any position to complain? If they don't like it they can write their own dang compiler.

    – user4581301
    Nov 27 '18 at 0:33











  • That was the point I was trying to make in my answer

    – SoraKatadzuma
    Nov 27 '18 at 0:35

















Comments are not for extended discussion; this conversation has been moved to chat.

– Samuel Liew
Nov 27 '18 at 0:23





Comments are not for extended discussion; this conversation has been moved to chat.

– Samuel Liew
Nov 27 '18 at 0:23













You control the output, of the compiler, yes? You can output the error messages as you see fit. If this means you substitute the tab with a known and consistent number of characters, is the user in any position to complain? If they don't like it they can write their own dang compiler.

– user4581301
Nov 27 '18 at 0:33





You control the output, of the compiler, yes? You can output the error messages as you see fit. If this means you substitute the tab with a known and consistent number of characters, is the user in any position to complain? If they don't like it they can write their own dang compiler.

– user4581301
Nov 27 '18 at 0:33













That was the point I was trying to make in my answer

– SoraKatadzuma
Nov 27 '18 at 0:35





That was the point I was trying to make in my answer

– SoraKatadzuma
Nov 27 '18 at 0:35












3 Answers
3






active

oldest

votes


















2














In my opinion, you should (a) assume that tabstops are every 8 spaces and (b) not even waste any time making this configurable.



Yes, there are people who like indents which are multiples of other than 8 spaces. Yes, there are text editors which let you set tabstops at other than 8 spaces. But (again in my opinion), neither of those facts change the interpretation of the t character. If someone wants an indent of 18 spaces, they (and/or their text editor) can achieve that by inserting 18 spaces, or two tabs and two spaces (or maybe even one tab and 10 spaces). But they should not go and insert two tabs, and declare that they're 9-space tabs, or something.



So if you write your code that assumes 8-space tabs, and if someone who believes they've "reconfigured" t finds that your code doesn't (and can't) share that belief, maybe -- just maybe -- you'll help convince that person of the folly of their belief. (It won't help, of course. But we can always hope.)



(But, yes, this is an old and flamboyant debate, that will probably never be resolved to everyone's satisfaction.)






share|improve this answer
























  • I'll definitely take this into consideration ^_^

    – SoraKatadzuma
    Nov 27 '18 at 1:26



















2














I think you're misunderstanding how tabs work. A tab is not equal to 'x' number of spaces, where 'x' is unique to the platform. A tab is equal to a tab. They are fundamentally different. To process a tab, the character is 't'.






share|improve this answer































    2














    I guess at this point I should answer my own question with something reasonable. Thank you to @ZDF and @Swordfish for your comments.



    My solution is:




    • Provide a compiler option for setting the length of a tab stop specifically.

    • If not defined by the user, use a length that will be the compiler default, and any time the compiler needs to print something, replace tabs with that many number of spaces.


    With this system, I can have accurate column counting, even if it doesn't reflect the user file properly.






    share|improve this answer
























    • I usually set my tab stops at columns 16, 40, 80 and 100.

      – Eljay
      Nov 27 '18 at 0:26











    • Better solution: exclude the TAB character from the source code character set. It's your compiler, so you get to write the rules. Do the world a favor and forbid the use of TAB characters.

      – user3386109
      Nov 27 '18 at 0:28













    • It's still a character that needs to be processed, it not a token or anything like that. It's just skipped (like all whitespace) and the column count would be incremented accordingly, however you make a point, but I think many people would be perturbed by not being able to have tabs

      – SoraKatadzuma
      Nov 27 '18 at 0:29








    • 1





      F# treats the tab character in a source file as a character which makes the entire file invalid. Python (as per PEP 8) establishes "no tabs!" (even though they are supported) by convention, such that Pythonistas instead use 4 spaces for indentation levels.

      – Eljay
      Nov 27 '18 at 0:32












    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53490769%2fdetermine-system-tab-stop-length%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    In my opinion, you should (a) assume that tabstops are every 8 spaces and (b) not even waste any time making this configurable.



    Yes, there are people who like indents which are multiples of other than 8 spaces. Yes, there are text editors which let you set tabstops at other than 8 spaces. But (again in my opinion), neither of those facts change the interpretation of the t character. If someone wants an indent of 18 spaces, they (and/or their text editor) can achieve that by inserting 18 spaces, or two tabs and two spaces (or maybe even one tab and 10 spaces). But they should not go and insert two tabs, and declare that they're 9-space tabs, or something.



    So if you write your code that assumes 8-space tabs, and if someone who believes they've "reconfigured" t finds that your code doesn't (and can't) share that belief, maybe -- just maybe -- you'll help convince that person of the folly of their belief. (It won't help, of course. But we can always hope.)



    (But, yes, this is an old and flamboyant debate, that will probably never be resolved to everyone's satisfaction.)






    share|improve this answer
























    • I'll definitely take this into consideration ^_^

      – SoraKatadzuma
      Nov 27 '18 at 1:26
















    2














    In my opinion, you should (a) assume that tabstops are every 8 spaces and (b) not even waste any time making this configurable.



    Yes, there are people who like indents which are multiples of other than 8 spaces. Yes, there are text editors which let you set tabstops at other than 8 spaces. But (again in my opinion), neither of those facts change the interpretation of the t character. If someone wants an indent of 18 spaces, they (and/or their text editor) can achieve that by inserting 18 spaces, or two tabs and two spaces (or maybe even one tab and 10 spaces). But they should not go and insert two tabs, and declare that they're 9-space tabs, or something.



    So if you write your code that assumes 8-space tabs, and if someone who believes they've "reconfigured" t finds that your code doesn't (and can't) share that belief, maybe -- just maybe -- you'll help convince that person of the folly of their belief. (It won't help, of course. But we can always hope.)



    (But, yes, this is an old and flamboyant debate, that will probably never be resolved to everyone's satisfaction.)






    share|improve this answer
























    • I'll definitely take this into consideration ^_^

      – SoraKatadzuma
      Nov 27 '18 at 1:26














    2












    2








    2







    In my opinion, you should (a) assume that tabstops are every 8 spaces and (b) not even waste any time making this configurable.



    Yes, there are people who like indents which are multiples of other than 8 spaces. Yes, there are text editors which let you set tabstops at other than 8 spaces. But (again in my opinion), neither of those facts change the interpretation of the t character. If someone wants an indent of 18 spaces, they (and/or their text editor) can achieve that by inserting 18 spaces, or two tabs and two spaces (or maybe even one tab and 10 spaces). But they should not go and insert two tabs, and declare that they're 9-space tabs, or something.



    So if you write your code that assumes 8-space tabs, and if someone who believes they've "reconfigured" t finds that your code doesn't (and can't) share that belief, maybe -- just maybe -- you'll help convince that person of the folly of their belief. (It won't help, of course. But we can always hope.)



    (But, yes, this is an old and flamboyant debate, that will probably never be resolved to everyone's satisfaction.)






    share|improve this answer













    In my opinion, you should (a) assume that tabstops are every 8 spaces and (b) not even waste any time making this configurable.



    Yes, there are people who like indents which are multiples of other than 8 spaces. Yes, there are text editors which let you set tabstops at other than 8 spaces. But (again in my opinion), neither of those facts change the interpretation of the t character. If someone wants an indent of 18 spaces, they (and/or their text editor) can achieve that by inserting 18 spaces, or two tabs and two spaces (or maybe even one tab and 10 spaces). But they should not go and insert two tabs, and declare that they're 9-space tabs, or something.



    So if you write your code that assumes 8-space tabs, and if someone who believes they've "reconfigured" t finds that your code doesn't (and can't) share that belief, maybe -- just maybe -- you'll help convince that person of the folly of their belief. (It won't help, of course. But we can always hope.)



    (But, yes, this is an old and flamboyant debate, that will probably never be resolved to everyone's satisfaction.)







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 27 '18 at 1:22









    Steve SummitSteve Summit

    17.9k22450




    17.9k22450













    • I'll definitely take this into consideration ^_^

      – SoraKatadzuma
      Nov 27 '18 at 1:26



















    • I'll definitely take this into consideration ^_^

      – SoraKatadzuma
      Nov 27 '18 at 1:26

















    I'll definitely take this into consideration ^_^

    – SoraKatadzuma
    Nov 27 '18 at 1:26





    I'll definitely take this into consideration ^_^

    – SoraKatadzuma
    Nov 27 '18 at 1:26













    2














    I think you're misunderstanding how tabs work. A tab is not equal to 'x' number of spaces, where 'x' is unique to the platform. A tab is equal to a tab. They are fundamentally different. To process a tab, the character is 't'.






    share|improve this answer




























      2














      I think you're misunderstanding how tabs work. A tab is not equal to 'x' number of spaces, where 'x' is unique to the platform. A tab is equal to a tab. They are fundamentally different. To process a tab, the character is 't'.






      share|improve this answer


























        2












        2








        2







        I think you're misunderstanding how tabs work. A tab is not equal to 'x' number of spaces, where 'x' is unique to the platform. A tab is equal to a tab. They are fundamentally different. To process a tab, the character is 't'.






        share|improve this answer













        I think you're misunderstanding how tabs work. A tab is not equal to 'x' number of spaces, where 'x' is unique to the platform. A tab is equal to a tab. They are fundamentally different. To process a tab, the character is 't'.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 26 '18 at 23:50









        Brandon LyonsBrandon Lyons

        41119




        41119























            2














            I guess at this point I should answer my own question with something reasonable. Thank you to @ZDF and @Swordfish for your comments.



            My solution is:




            • Provide a compiler option for setting the length of a tab stop specifically.

            • If not defined by the user, use a length that will be the compiler default, and any time the compiler needs to print something, replace tabs with that many number of spaces.


            With this system, I can have accurate column counting, even if it doesn't reflect the user file properly.






            share|improve this answer
























            • I usually set my tab stops at columns 16, 40, 80 and 100.

              – Eljay
              Nov 27 '18 at 0:26











            • Better solution: exclude the TAB character from the source code character set. It's your compiler, so you get to write the rules. Do the world a favor and forbid the use of TAB characters.

              – user3386109
              Nov 27 '18 at 0:28













            • It's still a character that needs to be processed, it not a token or anything like that. It's just skipped (like all whitespace) and the column count would be incremented accordingly, however you make a point, but I think many people would be perturbed by not being able to have tabs

              – SoraKatadzuma
              Nov 27 '18 at 0:29








            • 1





              F# treats the tab character in a source file as a character which makes the entire file invalid. Python (as per PEP 8) establishes "no tabs!" (even though they are supported) by convention, such that Pythonistas instead use 4 spaces for indentation levels.

              – Eljay
              Nov 27 '18 at 0:32
















            2














            I guess at this point I should answer my own question with something reasonable. Thank you to @ZDF and @Swordfish for your comments.



            My solution is:




            • Provide a compiler option for setting the length of a tab stop specifically.

            • If not defined by the user, use a length that will be the compiler default, and any time the compiler needs to print something, replace tabs with that many number of spaces.


            With this system, I can have accurate column counting, even if it doesn't reflect the user file properly.






            share|improve this answer
























            • I usually set my tab stops at columns 16, 40, 80 and 100.

              – Eljay
              Nov 27 '18 at 0:26











            • Better solution: exclude the TAB character from the source code character set. It's your compiler, so you get to write the rules. Do the world a favor and forbid the use of TAB characters.

              – user3386109
              Nov 27 '18 at 0:28













            • It's still a character that needs to be processed, it not a token or anything like that. It's just skipped (like all whitespace) and the column count would be incremented accordingly, however you make a point, but I think many people would be perturbed by not being able to have tabs

              – SoraKatadzuma
              Nov 27 '18 at 0:29








            • 1





              F# treats the tab character in a source file as a character which makes the entire file invalid. Python (as per PEP 8) establishes "no tabs!" (even though they are supported) by convention, such that Pythonistas instead use 4 spaces for indentation levels.

              – Eljay
              Nov 27 '18 at 0:32














            2












            2








            2







            I guess at this point I should answer my own question with something reasonable. Thank you to @ZDF and @Swordfish for your comments.



            My solution is:




            • Provide a compiler option for setting the length of a tab stop specifically.

            • If not defined by the user, use a length that will be the compiler default, and any time the compiler needs to print something, replace tabs with that many number of spaces.


            With this system, I can have accurate column counting, even if it doesn't reflect the user file properly.






            share|improve this answer













            I guess at this point I should answer my own question with something reasonable. Thank you to @ZDF and @Swordfish for your comments.



            My solution is:




            • Provide a compiler option for setting the length of a tab stop specifically.

            • If not defined by the user, use a length that will be the compiler default, and any time the compiler needs to print something, replace tabs with that many number of spaces.


            With this system, I can have accurate column counting, even if it doesn't reflect the user file properly.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 27 '18 at 0:25









            SoraKatadzumaSoraKatadzuma

            397




            397













            • I usually set my tab stops at columns 16, 40, 80 and 100.

              – Eljay
              Nov 27 '18 at 0:26











            • Better solution: exclude the TAB character from the source code character set. It's your compiler, so you get to write the rules. Do the world a favor and forbid the use of TAB characters.

              – user3386109
              Nov 27 '18 at 0:28













            • It's still a character that needs to be processed, it not a token or anything like that. It's just skipped (like all whitespace) and the column count would be incremented accordingly, however you make a point, but I think many people would be perturbed by not being able to have tabs

              – SoraKatadzuma
              Nov 27 '18 at 0:29








            • 1





              F# treats the tab character in a source file as a character which makes the entire file invalid. Python (as per PEP 8) establishes "no tabs!" (even though they are supported) by convention, such that Pythonistas instead use 4 spaces for indentation levels.

              – Eljay
              Nov 27 '18 at 0:32



















            • I usually set my tab stops at columns 16, 40, 80 and 100.

              – Eljay
              Nov 27 '18 at 0:26











            • Better solution: exclude the TAB character from the source code character set. It's your compiler, so you get to write the rules. Do the world a favor and forbid the use of TAB characters.

              – user3386109
              Nov 27 '18 at 0:28













            • It's still a character that needs to be processed, it not a token or anything like that. It's just skipped (like all whitespace) and the column count would be incremented accordingly, however you make a point, but I think many people would be perturbed by not being able to have tabs

              – SoraKatadzuma
              Nov 27 '18 at 0:29








            • 1





              F# treats the tab character in a source file as a character which makes the entire file invalid. Python (as per PEP 8) establishes "no tabs!" (even though they are supported) by convention, such that Pythonistas instead use 4 spaces for indentation levels.

              – Eljay
              Nov 27 '18 at 0:32

















            I usually set my tab stops at columns 16, 40, 80 and 100.

            – Eljay
            Nov 27 '18 at 0:26





            I usually set my tab stops at columns 16, 40, 80 and 100.

            – Eljay
            Nov 27 '18 at 0:26













            Better solution: exclude the TAB character from the source code character set. It's your compiler, so you get to write the rules. Do the world a favor and forbid the use of TAB characters.

            – user3386109
            Nov 27 '18 at 0:28







            Better solution: exclude the TAB character from the source code character set. It's your compiler, so you get to write the rules. Do the world a favor and forbid the use of TAB characters.

            – user3386109
            Nov 27 '18 at 0:28















            It's still a character that needs to be processed, it not a token or anything like that. It's just skipped (like all whitespace) and the column count would be incremented accordingly, however you make a point, but I think many people would be perturbed by not being able to have tabs

            – SoraKatadzuma
            Nov 27 '18 at 0:29







            It's still a character that needs to be processed, it not a token or anything like that. It's just skipped (like all whitespace) and the column count would be incremented accordingly, however you make a point, but I think many people would be perturbed by not being able to have tabs

            – SoraKatadzuma
            Nov 27 '18 at 0:29






            1




            1





            F# treats the tab character in a source file as a character which makes the entire file invalid. Python (as per PEP 8) establishes "no tabs!" (even though they are supported) by convention, such that Pythonistas instead use 4 spaces for indentation levels.

            – Eljay
            Nov 27 '18 at 0:32





            F# treats the tab character in a source file as a character which makes the entire file invalid. Python (as per PEP 8) establishes "no tabs!" (even though they are supported) by convention, such that Pythonistas instead use 4 spaces for indentation levels.

            – Eljay
            Nov 27 '18 at 0:32


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53490769%2fdetermine-system-tab-stop-length%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Tonle Sap (See)

            I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

            Guatemaltekische Davis-Cup-Mannschaft