Take for example the Numerical Recipes code distribution. They have copyrighted their work and do not allow for general public use of their code. http://numerical.recipes/aboutNR3license.html
Would an academic be allowed to use some of their routines in a publicly available code? Say the inserted routines make up a relatively small portion of the total project (say less than 5% of the code). To me it seems from a quick review of the four factors taken into consideration for fair use it would likely come out as fair use.
1) The work is academic in nature and of a noncommercial pursuit
2) The copyrighted work is of a technical manner
3) Depending on how they. would argue their copyright, either thousands of individual copyrights for each routine, or a single copyright for the entire library—using one or two routines of the hundreds copyrighted could be considering not very substantial.
4) Use in an academic setting would likely have next to no impact on their commercial licensing
They already allow you to publicly disseminate their code in precompiled forms (i.e. their base routines are not directly accessible to the end user). But an academic needing to open up their code to peer review and public scrutiny would post the source code online. I believe this is essentially why there was an academia exception carved into the copyright laws.