Skip to content

Commit 6e2cad3

Browse files
Add libxml files as unknown license reference test
Also fix other test failures. Reference: #3112 Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent 08afdfd commit 6e2cad3

20 files changed

+3898
-276
lines changed

tests/licensedcode/data/plugin_license/license_reference/scan-unknown-reference-copyright.expected.json

Lines changed: 365 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Except where otherwise noted in the source code (e.g. the files hash.c,
2+
list.c and the trio files, which are covered by a similar licence but
3+
with different Copyright notices) all the files are:
4+
5+
Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved.
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is fur-
12+
nished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
19+
NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
22+
NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
24+
Except as contained in this notice, the name of Daniel Veillard shall not
25+
be used in advertising or otherwise to promote the sale, use or other deal-
26+
ings in this Software without prior written authorization from him.
27+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#! /usr/bin/env python
2+
###
3+
#
4+
# build_glob.py : Build the global_functions.h and global_functions.c
5+
# files which are required to implement the user
6+
# interface to global variables now that thread specific
7+
# data (TSD) is used to emulate global state.
8+
#
9+
# See Copyright for the status of this software.
10+
# Gary.Pennington@sun.com
11+
###
12+
import os, string
13+
14+
class globvar:
15+
def __init__(self, type, name):
16+
self.type=type
17+
self.name=name
18+
19+
def striplinesep(line):
20+
while line and line[-1] in ('\r','\n'):
21+
line = line[:-1]
22+
return line
23+
24+
def writeline(file, line=None):
25+
if line:
26+
file.write(line)
27+
file.write("\n")
28+
29+
if __name__ == "__main__":
30+
globals={}
31+
global_data=open("global.data").readlines()
32+
global_code=open("globals.c").readlines()
33+
global_hdr=open("include/libxml/globals.h").readlines()
34+
global_functions_hdr=open("include/libxml/globals.h", "w+")
35+
global_functions_impl=open("globals.c", "w+")
36+
37+
#
38+
# Rebuild the beginning of the file up to the
39+
# Automatically generated string
40+
#
41+
for line in global_hdr:
42+
line = striplinesep(line)
43+
if line == " * Automatically generated by build_glob.py.":
44+
break
45+
writeline(global_functions_hdr, line)
46+
47+
writeline(global_functions_hdr, " * Automatically generated by build_glob.py.")
48+
writeline(global_functions_hdr, " * Do not modify the previous line.")
49+
writeline(global_functions_hdr, " */")
50+
writeline(global_functions_hdr)
51+
52+
for line in global_code:
53+
line = striplinesep(line)
54+
if line == " * Automatically generated by build_glob.py.":
55+
break
56+
writeline(global_functions_impl, line)
57+
58+
writeline(global_functions_impl, " * Automatically generated by build_glob.py.")
59+
writeline(global_functions_impl, " * Do not modify the previous line.")
60+
writeline(global_functions_impl, " */")
61+
writeline(global_functions_impl)
62+
63+
# Now process the data and write it to the appropriate output file
64+
for line in global_data:
65+
if line[0]=='#':
66+
continue
67+
line = striplinesep(line)
68+
fields = string.split(line, ",")
69+
# Update the header file
70+
writeline(global_functions_hdr)
71+
global_functions_hdr.write("extern "+fields[0]+" *")
72+
if fields[2]:
73+
global_functions_hdr.write("(*")
74+
global_functions_hdr.write("__"+fields[1]+"(void)")
75+
if fields[2]:
76+
global_functions_hdr.write(")"+fields[2])
77+
writeline(global_functions_hdr,";")
78+
writeline(global_functions_hdr, "#ifdef LIBXML_THREAD_ENABLED")
79+
writeline(global_functions_hdr,"#define "+fields[1]+" \\")
80+
writeline(global_functions_hdr,"(*(__"+fields[1]+"()))")
81+
writeline(global_functions_hdr,"#else")
82+
if fields[2]:
83+
writeline(global_functions_hdr,"LIBXML_DLL_IMPORT extern "+fields[0]+" "+fields[1]+fields[2]+";")
84+
else:
85+
writeline(global_functions_hdr,"LIBXML_DLL_IMPORT extern "+fields[0]+" "+fields[1]+";")
86+
writeline(global_functions_hdr,"#endif")
87+
# set/get for per-thread global defaults
88+
if fields[3]:
89+
writeline(global_functions_hdr,fields[0]+" "+fields[1][:3]+"ThrDef"+fields[1][3:]+"("+fields[0]+" v);")
90+
# Update the implementation file
91+
writeline(global_functions_impl)
92+
# writeline(global_functions_impl, "extern "+fields[0]+" "+fields[1]+";")
93+
writeline(global_functions_impl, "#undef\t"+fields[1])
94+
writeline(global_functions_impl, fields[0]+" *")
95+
if fields[2]:
96+
global_functions_impl.write("(*")
97+
global_functions_impl.write("__"+fields[1]+"(void)")
98+
if fields[2]:
99+
writeline(global_functions_impl, ")[]")
100+
writeline(global_functions_impl, " {")
101+
writeline(global_functions_impl, " if (IS_MAIN_THREAD)")
102+
writeline(global_functions_impl, "\treturn (&"+fields[1]+");")
103+
writeline(global_functions_impl, " else")
104+
writeline(global_functions_impl, "\treturn (&xmlGetGlobalState()->"+fields[1]+");")
105+
writeline(global_functions_impl, "}")
106+
# set/get for per-thread global defaults
107+
if fields[3]:
108+
writeline(global_functions_impl,fields[0]+" "+fields[1][:3]+"ThrDef"+fields[1][3:]+"("+fields[0]+" v) {")
109+
writeline(global_functions_impl," "+fields[0]+" ret;");
110+
writeline(global_functions_impl," xmlMutexLock(xmlThrDefMutex);")
111+
writeline(global_functions_impl," ret = "+fields[1][:3]+fields[1][3:]+"ThrDef;")
112+
writeline(global_functions_impl," "+fields[1][:3]+fields[1][3:]+"ThrDef = v;")
113+
writeline(global_functions_impl," xmlMutexUnlock(xmlThrDefMutex);")
114+
writeline(global_functions_impl," return ret;")
115+
writeline(global_functions_impl,"}")
116+
# Terminate the header file with appropriate boilerplate
117+
writeline(global_functions_hdr)
118+
writeline(global_functions_hdr, "#ifdef __cplusplus")
119+
writeline(global_functions_hdr, "}")
120+
writeline(global_functions_hdr, "#endif")
121+
writeline(global_functions_hdr)
122+
writeline(global_functions_hdr, "#endif /* __XML_GLOBALS_H */")

0 commit comments

Comments
 (0)