Is there a size where you can copy under fair use for code you don't have a license for the purpose? For example, what if I copy a snippet that is (normally) 3 lines of code? Is that fair use? If it is fair use, what length is required before I need a license?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
In the US, the legal doctrine of Fair Use does not apply to embedding excerpts of copyrighted works into source code. How such doctrine is applied by the laws of your jurisdiction may vary.
I will excerpt from a US Copyright Office article on Fair Use, and of copyrights generally:
It summarizes the legal limits of copyright, which Fair Use further limits, like so:
What the limits of what copyright protects tells us is though you cannot copy "snippets" of code via Fair Use, you can rewrite the way ideas, systems (including algorithms), or factual information are expressed in those snippets.
In short, 3 lines of code should be small enough for you to rewrite it so as not to violate the original work's copyright. It probably took longer to write your question than it will to do the rewrite.
I am not a lawyer.
However, you are absolutely free to use the following 3 lines of code in anything that you write:
In all seriousness, your question is quite broad and highly subjective. Ten lines of code from what? A highly specialized sorting algorithm? Some kind of firmware? One of the millions of configuration file parsers that have been floating around since the dawn of usenet?
The golden rule, really, follow the license from which the snippet came. If that is not available, use your best judgement.
I participate in several free/open source projects, some of them require a copyright assignment for anything not 'trivial'. All of them that have this requirement define 'trivial' to be ten lines of code added or modified. That is no way a substitute for competent legal advice from someone in your country, however.
My snippet gallery consists of hundreds of functions, all of them have the original author's information in doxygen style comments, as well as license info (if any, most are just public domain).
Unless clearly trivial (as in my humorous example), I would not re-use code unless I know that I have permission to do so. I also, always, follow the rules of whatever license applies.