Calculate percentages - SCO

This is a discussion on Calculate percentages - SCO ; I am a beginner in UNIX and I want to write a shell script calculating the proportion of one-line comments in any C++ program. Could anyone help me please? Thanks!...

+ Reply to Thread
Results 1 to 9 of 9

Thread: Calculate percentages

  1. Calculate percentages

    I am a beginner in UNIX and I want to write a shell script calculating
    the proportion of one-line comments in any C++ program. Could anyone
    help me please? Thanks!


  2. Re: Calculate percentages

    Dion typed (on Sun, Oct 23, 2005 at 01:33:13PM -0700):
    | I am a beginner in UNIX and I want to write a shell script calculating
    | the proportion of one-line comments in any C++ program. Could anyone
    | help me please? Thanks!


    I daresay you haven't the least interest or purpose in knowing how many
    comments in a program are one-liners.

    Occam's razor tells me that your instructor has asked you to write such a
    script. Does your instructor approve of your getting help from us?
    Would that affect your grade?

    --
    JP

  3. Re: Calculate percentages

    If you have read my query, which I'm sure you haven't, I didn't ask for
    the solution but for advice. Sometimes is better to think before
    talking! Since you are not able to give any advice, stop pretending
    being a smart guy!


  4. Re: Calculate percentages

    In article <1130107967.316525.219700@g47g2000cwa.googlegroups. com>,
    "Dion" wrote:

    > If you have read my query, which I'm sure you haven't, I didn't ask for
    > the solution but for advice. Sometimes is better to think before
    > talking! Since you are not able to give any advice, stop pretending
    > being a smart guy!


    Apparently you aren't a reader of this group as JPR is a smart guy and
    has helped many people (for years I have read this group off and on).

    I don't see the point of your request either.. perhaps if you gave us a
    reason why you were looking to find out why the multiple comment lines
    were so important???

    T

  5. Re: Calculate percentages

    Dion wrote:



    > If you have read my query, which I'm sure you haven't, I didn't ask for
    > the solution but for advice. Sometimes is better to think before
    > talking! Since you are not able to give any advice, stop pretending
    > being a smart guy!
    >


    I expect most people would say Open Source evangelist and author Eric
    Raymond is a smart guy (i.e. intelligent, I've no idea if he is a snappy
    dresser).

    So here's some advice from a smart guy:

    http://www.catb.org/~esr/faqs/smart-...tml#not_losing

  6. Re: Calculate percentages

    Dion wrote:
    > If you have read my query, which I'm sure you haven't, I didn't ask for
    > the solution but for advice. Sometimes is better to think before
    > talking! Since you are not able to give any advice, stop pretending
    > being a smart guy!
    >


    That's great - be insulting.

    But just in case you aren't as stupid as you seem, I'll take the above
    as real.

    First, you need to know how to create a shell script. See
    http://aplawrence.com/Basics/scripting.html if you don't.

    Next, you need to count lines. Start with "man wc". You need to
    differentiate between comment lines and non-comment lines: "man grep".

    But if you really want to impress your professor, I'd suggest you
    submit an alternate solution using the shell's "read" function, and
    "test" and "expr" (or built in math if you are allowed to use bash or
    ksh). Finally, you should do one in awk and one in Perl.

    You should look at "man bc" and "man dc" also, just for completeness.
    If you really investigate all I've suggested here, you'll learn quite a bit.

    --
    Tony Lawrence
    Unix/Linux/Mac OS X resources: http://aplawrence.com
    Geek Yard Sale: http://geekyardsale.com

  7. Re: Calculate percentages


    ----- Original Message -----
    From: "Jean-Pierre Radley"
    Newsgroups: comp.unix.sco.misc
    To:
    Sent: Sunday, October 23, 2005 6:10 PM
    Subject: Re: Calculate percentages


    > Dion typed (on Sun, Oct 23, 2005 at 01:33:13PM -0700):
    > | I am a beginner in UNIX and I want to write a shell script calculating
    > | the proportion of one-line comments in any C++ program. Could anyone
    > | help me please? Thanks!
    >
    >
    > I daresay you haven't the least interest or purpose in knowing how many
    > comments in a program are one-liners.
    >
    > Occam's razor tells me that your instructor has asked you to write such a
    > script. Does your instructor approve of your getting help from us?
    > Would that affect your grade?


    Well, to be honest,

    There is a comment syntax for single lines that is valid in c++ that is not
    valid in c.
    And it would be both a simple "get report", and possibly legitimately
    useful, to find only those lines that would be invalid c syntax.

    But I won't divulge any more hint than I already have in case you are right,
    because it looks that way to me too.
    Besides, I've already seen his next post and someone apparently never
    figured out the kindergarden basic life lesson yet that you catch more flies
    with honey.
    Maybe he feels this makes me an jerk, but in the end, I know the answer, and
    he's dissuaded me from being generous with it.

    I only wish Tony hadn't sabotaged our plot to keep him in the dark forever
    muhahahahaha.....

    Brian K. White -- brian@aljex.com -- http://www.aljex.com/bkw/
    +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
    filePro BBx Linux SCO FreeBSD #callahans Satriani Filk!


  8. Re: Calculate percentages

    In article <06fb01c5d8da$fd373110$6600000a@venti>,
    Brian K. White wrote:
    >
    >----- Original Message -----
    >From: "Jean-Pierre Radley"
    >Newsgroups: comp.unix.sco.misc
    >To:
    >Sent: Sunday, October 23, 2005 6:10 PM
    >Subject: Re: Calculate percentages
    >
    >
    >> Dion typed (on Sun, Oct 23, 2005 at 01:33:13PM -0700):
    >> | I am a beginner in UNIX and I want to write a shell script calculating
    >> | the proportion of one-line comments in any C++ program. Could anyone
    >> | help me please? Thanks!
    >>
    >>
    >> I daresay you haven't the least interest or purpose in knowing how many
    >> comments in a program are one-liners.
    >>
    >> Occam's razor tells me that your instructor has asked you to write such a
    >> script. Does your instructor approve of your getting help from us?
    >> Would that affect your grade?

    >
    >Well, to be honest,
    >
    >There is a comment syntax for single lines that is valid in c++ that is not
    >valid in c.
    >And it would be both a simple "get report", and possibly legitimately
    >useful, to find only those lines that would be invalid c syntax.


    >But I won't divulge any more hint than I already have in case you
    >are right, because it looks that way to me too. Besides, I've
    >already seen his next post and someone apparently never figured
    >out the kindergarden basic life lesson yet that you catch more
    >flies with honey.


    You can kill a lot more with Black Flag (TM). :-)

    >Maybe he feels this makes me an jerk, but in the end, I know the
    >answer, and he's dissuaded me from being generous with it.


    >I only wish Tony hadn't sabotaged our plot to keep him in the
    >dark forever muhahahahaha.....


    And there is a flag in the gcc compiler that warns when you have
    a C syntax comment "start sequence", so that means you have to
    inspect things visually to find the end of the comment section.

    Bill

    --
    Bill Vermillion - bv @ wjv . com

  9. Re: Calculate percentages

    Brian K. White wrote:
    > ----- Original Message -----
    > From: "Jean-Pierre Radley"
    > Newsgroups: comp.unix.sco.misc
    > To:
    > Sent: Sunday, October 23, 2005 6:10 PM
    > Subject: Re: Calculate percentages
    >
    >
    >
    >>Dion typed (on Sun, Oct 23, 2005 at 01:33:13PM -0700):
    >>| I am a beginner in UNIX and I want to write a shell script calculating
    >>| the proportion of one-line comments in any C++ program. Could anyone
    >>| help me please? Thanks!
    >>
    >>
    >>I daresay you haven't the least interest or purpose in knowing how many
    >>comments in a program are one-liners.
    >>
    >>Occam's razor tells me that your instructor has asked you to write such a
    >>script. Does your instructor approve of your getting help from us?
    >>Would that affect your grade?

    >
    >
    > Well, to be honest,
    >
    > There is a comment syntax for single lines that is valid in c++ that is not
    > valid in c.
    > And it would be both a simple "get report", and possibly legitimately
    > useful, to find only those lines that would be invalid c syntax.
    >
    > But I won't divulge any more hint than I already have in case you are right,
    > because it looks that way to me too.
    > Besides, I've already seen his next post and someone apparently never
    > figured out the kindergarden basic life lesson yet that you catch more flies
    > with honey.
    > Maybe he feels this makes me an jerk, but in the end, I know the answer, and
    > he's dissuaded me from being generous with it.
    >
    > I only wish Tony hadn't sabotaged our plot to keep him in the dark forever
    > muhahahahaha.....


    Well, I like to try to give the benefit of the doubt. If he's a useless
    twit, he won't get anything from what I told him, but if not, maybe
    he'll really dig in and learn something.



    --
    Tony Lawrence
    Unix/Linux/Mac OS X resources: http://aplawrence.com
    Geek Yard Sale: http://geekyardsale.com

+ Reply to Thread