Disclaimer: I know you're not a lawyer! :)
This question is for university assignments, not work nor personal.
Say I'm looking for the implementation of something very very specific, and I find that in an open source project (say, using google code search).
The thing itself is about 20 ~ 30 lines of code, and constitutes less than 10% of one file from the project which contains tens of other files.
Also, say the license is Free, but mandates that you don't remove the license.
Something like:
Permission to use, copy, modify, and distribute this software for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both the copyright notice and this permission notice appear in supporting documentation
...
etc etc ..
In that case, would I be violating the license if I just copy those lines, cite the source, but without copying the entire license text along with it?
Given that I do cite the source of these lines in a comment right above them.
In other words, what should I do in order to avoid violating the license without cluttering my code with legalese?
Most of the time this very specific implementation is of some mathematical formula (involving things like fft, quaternions, etc), where I know for sure that the author of this code didn't "invent" the math behind it. It's no where near a substantial part of the software.
UPDATE
This is not about GPL specifically. I apologize for the confusion (I removed the gpl tag).
UPDATE 2
I'm not trying to argue whether it's ok or not, I'm asking because I'm pretty much clueless about these kinds of things.
I'm essentially assuming/hoping that if I put a link to the source and the link contains the license information, then it would be ok.
Also, my understanding is that, the point of the license, is to prevent people from "leeching" these files and removing the license notice at the top. Where as I'm not copying the file itself, only a small part of it.
Essentially what I would leave is something like:
/*
The following function has been taken from <project name>
<url to the original file>
*/
The file pointed to by the url contains the license of course.
UPDATE 3
I just wanted to add, it's not really 20~30 lines, more like 5~15, (I wanted to make the question a bit general) and this is not about a specific case that happened to me now, it's happened more than once, and I assume it could happen to any university/college student.
You're working on your assignment, and you need this helper function or that, and it's not even in the core of your assignment. google code search, and, great, you find this helper function, and it's open source!! but you're not sure the best way to properly cite it, and not sure whether you really need to put that license in the middle of your code.