Source Code with Line Numbers

Discussion in 'Mac Programming' started by Senor Cuete, Jan 14, 2014.

  1. Senor Cuete macrumors regular

    Nov 9, 2011
    After a long search, I found some open source .c code to do something that would be very helpful to me in developing a program. The problem is that it has line numbers. No C code that I've ever seen uses these. I tried to remove these with BBEdit but couldn't. There's a line that looks like environmental variables for a Unix machine. Did some ancient Unix compiler use line numbers? I've only seen this in BASIC. Is there any convenient way to remove these or am I going to have to edit them out by hand?
  2. ArtOfWarfare macrumors G3


    Nov 26, 2007
    Regex to match a line number would be:


    I think. I don't have a reference sheet in front of me so I'm not 100% sure that $ matches a line start. Anyways, you can either use grep and sed with that if you're comfortable with the command line, or get Sublime (it's totally free) and do a regex find and replace with that pattern (the replace would obviously be blank.)
  3. willieva macrumors 6502

    Mar 12, 2010
  4. gnasher729 macrumors P6


    Nov 25, 2005
    Take it as an opportunity to find out more about the Xcode editor, and how "Find & Replace" works with regular expressions.

    No C / C++ / Objective C / Java compiler ever used line numbers. Most likely the source that you got is the output of a tool that produced code with line numbers from plain source code, intended purely for viewing the code.
  5. robvas macrumors 68030

    Mar 29, 2009
    Why not show us the code instead of trying to describe it to us?
  6. subsonix macrumors 68040

    Feb 2, 2008
  7. mrichmon macrumors 6502a

    Jun 17, 2003
    You should also be aware that you do not automatically have the rights to copy and use the code. By writing the code in a permanent form (such as a digital file) the author has established copyright protections.

    It is quite possible that the author will grant you the rights to use the code, but nothing on that site explicitly or implicitly allows you to copy the content.
  8. Senor Cuete thread starter macrumors regular

    Nov 9, 2011
    Or forbids it - including the header of the file where one usually sees a copyright. In addition, the astronomical constants, algorithms, arrays etc. in these files are taken from published academic sources, mostly Jean Meeus (based on the uncopyrighted the work of others) who's intent is to encourage development of high quality astronomy software. For this reason, Meeus has never tried to patent his algorithms or constants. If it was the authors' intent to copyright it, they would have done so and they wouldn't have posted it to an open source site.


  9. subsonix, Jan 16, 2014
    Last edited: Jan 16, 2014

    subsonix macrumors 68040

    Feb 2, 2008
    Not sure what your point is, you said you had found C code with line numbers. When asked to show an example, you showed Doxygen generated output where the line numbers is not part of the C source code.

  10. mrichmon, Jan 16, 2014
    Last edited: Jan 16, 2014

    mrichmon macrumors 6502a

    Jun 17, 2003
    Copyright rights exist at the time of creation. In a strict sense, the author must explicitly relinquish copyright for those rights to be removed. A work does not require a copyright statement to be protected by copyright. No action is required by an author to create copyright rights other than the actual creation of the work in a completed form.

    See: and link to explanatory pdf.
  11. chown33 macrumors 604

    Aug 9, 2009
    How do you know it's an open source site?

    I haven't found anything in my browsing of it that leads me to think that's so.

    I even started at the username root:
    and found lots more stuff (PDFs, DOCs, etc.) but saw nothing specifically stating any of it is open source.

    If it were me, I'd use the Contact Details link on the home page to contact the author(s) and find out for sure. He might even give you the URL for the git repo so you can get the actual source rather than scraping HTML docs.
  12. gnasher729 macrumors P6


    Nov 25, 2005
    If there is nothing that allows copying then it is forbidden. That's it.

    If there are things derived from public sources, then the derivation (the difference between the publicly available data, and the text that you see), is still copyrighted. And the intent of the original author doesn't matter. Even if the source says you have the permission to copy it, you don't know that whoever put the source there had the right to give you permission.

Share This Page