Sort NOTICE entries.
Also make sure we get the whole of any copyright header, in case
there's text before the "Copyright" line.
Change-Id: Iabcc5e0931a39c0107b833539fec7c5a3d134592
diff --git a/libc/tools/generate-NOTICE.py b/libc/tools/generate-NOTICE.py
index eaae328..46152b9 100755
--- a/libc/tools/generate-NOTICE.py
+++ b/libc/tools/generate-NOTICE.py
@@ -34,9 +34,16 @@
def ExtractCopyrightAt(lines, i):
hash = lines[i].startswith("#")
+ # Do we need to back up to find the start of the copyright header?
+ start = i
+ if not hash:
+ while start > 0:
+ if "/*" in lines[start - 1]:
+ break
+ start -= 1
+
# Read comment lines until we hit something that terminates a
# copyright header.
- start = i
while i < len(lines):
if "*/" in lines[i]:
break
@@ -138,7 +145,7 @@
#print path
-for copyright in copyrights:
+for copyright in sorted(copyrights):
print copyright.encode('utf-8')
print
print '-------------------------------------------------------------------'