Mac Source Code with Line Numbers

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
288
12
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?
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
8,615
4,086
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?
Regex to match a line number would be:

$\d+

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.)
 
Comment

gnasher729

macrumors P6
Nov 25, 2005
16,699
3,440
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?
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.
 
Comment

mrichmon

macrumors 6502a
Jun 17, 2003
873
2
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.
 
Comment

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
288
12
...nothing on that site explicitly or implicitly allows you to copy the content.
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.

----------

The line numbers is not part of the source code, they are part of the html presentation only to make reading in the browser easier, the same with the syntax coloring.
Duh.
 
Comment

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
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.


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.
 
Last edited:
Comment

mrichmon

macrumors 6502a
Jun 17, 2003
873
2
Or forbids it
...
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.
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: http://www.copyright.gov/help/faq/faq-general.html#register and link to explanatory pdf.
 
Last edited:
Comment

chown33

Moderator
Staff member
Aug 9, 2009
8,671
4,942
vertical
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.
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:
http://www.mmto.org/~dclark/
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.
 
Comment

gnasher729

macrumors P6
Nov 25, 2005
16,699
3,440
Or forbids it - including the header of the file where one usually sees a copyright.
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.
 
Comment

Similar threads

  • jasnw
2
Replies
2
Views
857
  • BootLoxes
9
Replies
9
Views
2K
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.