diff --git a/tools/relic/README b/tools/relic/README new file mode 100755 index 000000000000..8f6b991ca52a --- /dev/null +++ b/tools/relic/README @@ -0,0 +1,205 @@ + ReadMe for relic.py (a Mozilla relicensing tool) + + + This script is intended to facilitate re-licensing the Mozilla source + tree pursuant to . It cannot do the full job + automatically but handles most of the grunt work. + +Table of Contents: + + The Problem + Getting Started + Basic Usage + What Files are Processed + Error Handling (--force) + Unfinished Business + Contributors + + +The Problem: + + The basic problem is that Mozilla has a lot of files. The goal is to have + all the files (with a few minor exceptions) contain a leading license + block that is either the MPL/GPL/LGPL tri-license or the NPL/GPL/LGPL + tri-license. Because this was never rigorously enforced a lot of cleanup + is necessary to correct license blocks in Mozilla's files. This script + will traverse the given directory(s)/file(s) and fixup the leading + license block, or give an error message explaining why it cannot. (It + also has modes to just scan for and summarize license info.) + + +Getting Started: + + While 'relic.py' is probably quite portable to Windows it has not been + tested there. There may be some hidden path-delimiter bugs. It is + probably best to just run this script on Linux. + + To use: + - crack the relic-.tar.gz tarball in some directory + - call './relic.py --help' to learn the basic usage + - play with './relic.py ...' as desired. + + +Basic Usage: + + 'relic.py' has a --help option that explains the basic usage but I'll go + through some examples here. In our examples we will work on re-licensing + the mozilla/js/src directory tree. + + 'relic.py' has three modes. + (1) List license info on each file processed (the default) + + $ ./relic.py mozilla/js/src/jsapi.h + /js/src/jsapi.h + ... npl/gpl found + ... license block lines: 2-32 + ... original code is: Mozilla Communicator client code + ... initially by: Original Code is Netscape Communications Corporation (1998) + + (2) Gather and dump statistics on the processed files: + + $ ./relic.py -s mozilla/js/src/jsapi.h + Summary of Licenses in Files + ============================ + Number Percent License + ------- -------- ----------- + 1 100.00% npl/gpl + ---------------------------- + 1 files processed + + Licensed files with complete tri-license block: 0 + Licensed files with no 'Initial Developer...' info: 0 + Licensed files with no 'Original Code is...' info: 0 + Licensed files with improperly indented 'Contributor(s):' line(s): 0 + + (3) Re-licensing the given files that need it (i.e. files with a complete + and correct license block are changed). + + $ ./relic.py -r mozilla/js/src/jsapi.h + mozilla/js/src/jsapi.h + ... npl/gpl found, need to relicense + ... original code is: Mozilla Communicator client code + ... initially by: Original Code is Netscape Communications Corporation (1998) + ... replacing lines 2-32 with NPL/GPL/LGPL tri-license + ... backing up to 'mozilla/js/src/jsapi.h~0' + ... done relicensing 'mozilla/js/src/jsapi.h' + + --------------------- Summary of Results ------------------------ + Files skipped b/c they are binary: 0 + Files skipped b/c they already had proper license: 0 + Files skipped b/c they had no license: 0 + Files re-licensed: 1 + ----------------------------------------------------------------- + + If you are trying this as you read this, run the following command to see + the changes made to jsapi.h: + + $ diff -c mozilla/js/src/jsapi.h~0 mozilla/js/src/jsapi.h + + +What Files are Processed: + + 'relic.py' will process any files listed on the command line and will + recursively process all files in any given directories: + + $ ./relic.py -s mozilla/js/src + Summary of Licenses in Files + ============================ + Number Percent License + ------- -------- ----------- + 324 74.14% npl/gpl + 71 16.25% + 23 5.26% mpl/gpl/lgpl + 4 0.92% npl/gpl/lgpl + 4 0.92% mpl + 4 0.92% ibm + 3 0.69% mpl/gpl + 2 0.46% npl + 2 0.46% + ---------------------------- + 437 files processed + + Licensed files with complete tri-license block: 27 + Licensed files with no 'Initial Developer...' info: 1 + Licensed files with no 'Original Code is...' info: 27 + Licensed files with improperly indented 'Contributor(s):' line(s): 2 + + The following files are automatically skipped: + - CVS control directories; + - files listed in .cvsignore files; + - all *.s files (there usage of comment delimiters is all over the map); + - binary files; and + - any files included in the following global variables in relic.py: + _g_skip_file_basenames, _g_skip_files, _g_skip_dir_basenames, + _g_skip_dirs, _g_skip_ext. + + +Error Handling (--force): + + There are some situations that relic.py cannot handle. E.g., a file with + no license block to start with, an IBM license block, a license block + sufficiently strange enough to baffle relic.py regular expressions. In + normal operation, when an error is encoutered on any file processing + stops. This can be annoying, so a --force|-f option was added to force + relic.py to continue processing files after an error with a file is + encountered. In all modes of operation errors are summarized at the end. + + $ ./relic.py -s mozilla/extensions/transformiix/source/xml + ERROR:relic:This is line is part of the 'Contributor(s):' paragraph but (1) is not indented and (2) does not look like it contains an email address: mozilla/extensions/transformiix/source/xml/XMLDOMUtils.h:20: ' * Keith Visco' (the --force option can be used to skip problematic files and continue processing rather than aborting) + + $ ./relic.py -sf mozilla/extensions/transformiix/source/xml + Summary of Licenses in Files + ============================ + Number Percent License + ------- -------- ----------- + 24 100.00% mpl + ---------------------------- + 24 files processed + + Licensed files with complete tri-license block: 0 + Licensed files with no 'Initial Developer...' info: 16 + Licensed files with no 'Original Code is...' info: 15 + Licensed files with improperly indented 'Contributor(s):' line(s): 3 + + + =================== Summary of Errors =========================== + Files with processing errors: 3 + ================================================================= + mozilla/extensions/transformiix/source/xml/XMLDOMUtils.cpp: This is line is part of the 'Contributor(s):' paragraph but (1) is not indented and (2) does not look like it contains an email address: mozilla/extensions/transformiix/source/xml/XMLDOMUtils.cpp:20: ' * Keith Visco ' + + mozilla/extensions/transformiix/source/xml/XMLDOMUtils.h: This is line is part of the 'Contributor(s):' paragraph but (1) is not indented and (2) does not look like it contains an email address: mozilla/extensions/transformiix/source/xml/XMLDOMUtils.h:20: ' * Keith Visco ' + + mozilla/extensions/transformiix/source/xml/parser/txXMLParser.h: This is line is part of the 'Contributor(s):' paragraph but (1) is not indented and (2) does not look like it contains an email address: mozilla/extensions/transformiix/source/xml/parser/txXMLParser.h:20: ' * Tom Kneeland' + + ================================================================= + + +Unfinished Business: + + The following is a list of issues that should be sorted out before this + should be used to start making patches to the Mozilla tree: + + - What to do for files that have no 'Initial Developer...' block? + - What to do for files that have no 'Original Code is...' block? + - Are there specific files or parts of the mozilla tree that should be + skipped always, i.e. generated files, files not meant to have leading + license blocks? + - What to do for files with the IBM license? + - Should *.uf be ignored (there are 87 of them in the mozilla tree)? + - The 'ripl' and lick' scripts' "include licenses" configuration option + is not supported in anyway by relic.py. Is it necessary? I don't see a + useful use case. + - test/x_thread_align_center.xml and test/abs2rel.pl are examples of + files that are not handled correctly. In the former there is some data + loss. In the latter the is some cruft left over. + + +Contributors: + + Trent Mick (TrentM@ActiveState.com) originally wrote this script, + borrowing some from earlier attempts in the name of 'lick', 'lutils.py', + and 'ripl' (see ). + If you have problems with the script please let me know and hopefully I + can help you out. + + diff --git a/tools/relic/relic b/tools/relic/relic new file mode 100755 index 000000000000..5e5361f92b5c --- /dev/null +++ b/tools/relic/relic @@ -0,0 +1,2369 @@ +#!/usr/bin/env python +# +# Written by: Trent Mick (TrentM@ActiveState.com), July 2003 +# +# Adapted from the 'lick' and 'ripl' Python scripts. (See: +# ) + +""" + relic - RE-LICense a given file, set of files, or directory of files + from the Mozilla source tree + + Usage: + relic [options...] [files...] + relic [options...] < files... + + Options to Select Mode (use one): + List the licenses in each file. + -s, --statistics Should a summary table of licenses in each file. + The -x, --extended option may be added to show + some additional detail to the stats. + -r, --relicense Modify the given files to include to + appropriate Mozilla license, where + "appropriate" is either the NPL/GPL/LPGL + tri-license if was already under the NPL or + the MPL/LPGL/GPL license in all other cases. + -R, --force-relicense + Relicenses files (as -r|--relicense), but + does NOT skip files that already appear to + have a complete license. + -A, --add Add a license to files that do not appear to + have one. + + General Options: + -h, --help dump this help and exit + -V, --version dump this script's version and exit + -v, --verbose verbose output + -d, --debug more verbose output + + -f, --force Continue processing after an error. (Errors + are summarized at end.) + -M, --MPL Replace NPL licenses with MPL ones. + -a, --all Check all files (only skip CVS directories). + --dry-run Go through motions but don't actually change + any files. + --backup Make backups of changes files with + relicensing. Backup filenames are the + original filename suffixed with a ~# where + "#" is the lowest number to avoid a file + conflict. + -o Provide fallback value for the "Original + Code is" block. + -D Provide fallback value for the date + that is part of the "Original Code is" block. + -i Provide fallback value for the "Initial + Developer of the Original Code is" block. + -y Provide fallback value for "Initial + Developer" copyright year. + --defaults Use the following default fallback values: + original_code_is: "mozilla.org Code" + initial_copyright_date: "2001" + initial_developer: "Netscape Communications + Corporation" + Note: the "Original Code" date is generally + not required, so a default is not included + here. + + Examples: + # List license in files under mozilla/js/src. + relic mozilla/js/src # list licenses in files + relic -s mozilla/js/src # show summary stats on licenses + relic -r mozilla/js/src # re-license files + +""" +# Backward incompatibilities with 'lick' and 'ripl': +# - The configuration file support from 'lick' and 'ripl' is currently +# not implemented. Here is a defense for each of the supported +# configuration items: +# - "exclude paths": I suppose this might be useful for repeated +# runs but I wouldn't call it critical. +# - "exclude dirs": What dirs other that CVS should always be +# excluded? CVS is excluded by default here. +# - "exclude extensions": .cvsignore is used here for this. Are +# there other extensions that should be ignored that are not +# part of .cvsignore? If so can those not just be hardcoded? +# - "include only extensions": Is this if one wants to do a run +# including only some specific files? 'lick' and 'ripl' did not +# support passing specific files (only dirs) on stdin. This +# config option can be better done with relic.py via: +# find . -blah blah | relic +# - "include licenses": This is a feature regression. But is it +# truly necessary to differentiate the different license combos +# if the 'ripl' functionality is smart enough to know what to do +# with what combo? +# - "setup extensions": An internal registry of content types is +# used for this. Is there any reason this registry needs to be +# in a configuration file? Does it differ from user to user? +# +# Possible TODOs: +# - Perhaps try to infer the comment delimiter from the file is it is +# not known. This would help for .s files, though I don't know if that +# is sufficient to bother. +# + + +import os +import sys +import re +import getopt +import pprint +import shutil + + +class RelicError(Exception): + pass + + +#---- setup logging + +try: + # This package will be std in Python 2.3, but many Python 2.2 + # installation will not have it. + import logging + logging.basicConfig() +except ImportError: + # Local fallback logging module. + try: + import _logging as logging + except ImportError: + sys.stderr.write("Your Python installation does not have the logging " + "package, nor could the fallback _logging module be " + "found. One of the two is required to run this " + "script.\n\n") + raise + +log = logging.getLogger("relic") + + + +#---- globals + +_version_ = (0, 6, 8) + +# When processing files, 'relic' skips files and directories according +# to these settings. Note: files identified in .cvsignore files are also +# skipped. +_g_skip_exts = [".mdp", ".order", ".dsp", ".dsw", ".uf"] +_g_skip_file_basenames = [ + ".cvsignore", + # GPL with autoconf exception + "config.guess", + "config.sub", + # Auto-generated from other files + "configure", + # Public Domain + "nspr.m4", +] +_g_skip_files = [ + # GRM 2004-12-26 - these are the files we don't have full permissions for + # yet. See problem-file-list.txt. + + # Files containing copies of the licence which confuse the script + # Last act is to update them all. + "LICENSE", + "COPYING", + "extensions/xmlterm/doc/MPL", + "xpfe/global/resources/content/NPL-1.1.html", + "xpinstall/wizard/unix/src2/MPL-1.1.txt", + "xpfe/global/resources/content/MPL-1.1.html", + "parser/htmlparser/tests/html/bug23680.html", + "nsprpub/pkg/solaris/common_files/copyright", + "security/nss/pkg/solaris/common_files/copyright", + "security/jss/pkg/solaris/common_files/copyright", + "toolkit/content/NPL-1.1.html", + "toolkit/content/MPL-1.1.html", + "security/nss/lib/freebl/mpi/utils/LICENSE-MPL", # Currently MPL/GPL + "security/nss/lib/freebl/mpi/tests/LICENSE-MPL", # Currently MPL/GPL + "security/nss/lib/freebl/mpi/doc/LICENSE-MPL", # Currently MPL/GPL + + # Need to update with MPL block; exclude until then + "tools/wizards/templates/licenses/MPL/lic.mak", + "tools/wizards/templates/licenses/MPL/lic.pl", + + ########################################################################### + # Everything in _g_skip_files below this line needs no further work for + # relicensing to be completed. + ########################################################################### + + # Ben Bucksch - files are tri-licensed with an extra clause. + "netwerk/streamconv/converters/mozTXTToHTMLConv.cpp", + "netwerk/streamconv/converters/mozTXTToHTMLConv.h", + "netwerk/streamconv/public/mozITXTToHTMLConv.idl", + + # License files which are not to be updated + "gfx/cairo/cairo/COPYING-LGPL-2.1", + "gfx/cairo/cairo/COPYING-MPL-1.1", + + # GPLed build tools + "config/preprocessor.pl", + "intl/uconv/tools/parse-mozilla-encoding-table.pl", + "intl/uconv/tools/gen-big5hkscs-2001-mozilla.pl", + "js2/missing", + + # Text files which the script can't handle. All have been relicensed + # manually. + "xpinstall/wizard/windows/builder/readme.txt", + "xpfe/bootstrap/icons/windows/readme.txt", + "embedding/qa/testembed/README.TXT", + "security/nss/lib/freebl/ecl/README.FP", + "nsprpub/pkg/linux/sun-nspr.spec", + "security/nss/pkg/linux/sun-nss.spec", + "security/jss/pkg/linux/sun-jss.spec", + "security/nss/lib/freebl/mpi/utils/README", + "security/nss/lib/freebl/ecl/README", + "security/nss/lib/freebl/mpi/README", + "lib/mac/UserInterface/Tables/TableClasses.doc", + + # XXX Not sure what to do with these... + "gfx/cairo/stdint.diff", + + # Same license as files distributed with + "build/autoconf/codeset.m4", + + # GSSAPI has BSD-like licence requiring some attribution + "extensions/auth/gssapi.h", +] +_g_skip_dir_basenames = [ + "CVS", +] + +_g_skip_dir_basenames_cvs_only = [ + "CVS", +] + +# Complete path from mozilla dir to a dir to skip. +_g_skip_dirs = [ + # As per the "New Original Source Files" section of: + # http://www.mozilla.org/MPL/license-policy.html + "dbm", # XXX 4-clause BSD; need to remove clause 3. Bug 331603. + + # XXX This may be a problem - it's MPLed only. James Clark has given + # permission to change it back to MIT. Bug 331604. + "modules/xml/expat", + + ########################################################################### + # Everything in_g_skip_dirs below this line needs no further work for + # relicensing to be completed. + ########################################################################### + + "apache", # Obsolete mod_gzip code + "cck", # Don't know what mkaply is doing, but it's not core code anyway. + "directory/java-sdk", # Java LDAP SDK + "directory/perldap", # Perl LDAP SDK + "ef", # Multi-platform Java JIT + "grendel", # Mail client in Java + "js/rhino", # Currently under discussion - may end up BSD + "mstone", # Mail server performance testing tool + "webtools", # Various MPLed webtools + + # These could be done, but no-one's clamouring for it, and it's a hassle + # sorting it all out, so let sleeping dogs lie. + "msgsdk", + "java", + "privacy", + + "jpeg", + "modules/libimg/mng", + + # The following are not supposed to be relicensed, but they do have a + # few files in we care about (like makefiles) + "modules/libimg/png", + "modules/zlib", + "gc/boehm", + "other-licenses", + + # Other directories we want to exclude + "embedding/tests", # Agreed as BSD + "calendar/libical", # LGPL/MPL + "gfx/cairo/cairo/src", # LGPL/MPL +] + +_g_basename_to_comment_info = { + "Makefile": (["#"], ), + "makefile": (["#"], ), + "configure": (["dnl"], ), + "nfspwd": (["#"], ), + "typemap": (["#"], ), + "xmplflt.conf": (["#"], ), + "ldapfriendly": (["#"], ), + "ldaptemplates.conf": (["#"], ), + "ldapsearchprefs.conf": (["#"], ), + "ldapfilter.conf": (["#"], ), + "README.configure": (["#"], ), + "Options.txt": (["#"], ), + "fdsetsize.txt": (["#"], ), + "prototype": (["#"], ), + "prototype_i386": (["#"], ), + "prototype3_i386": (["#"], ), + "prototype_com": (["#"], ), + "prototype3_com": (["#"], ), + "prototype_sparc": (["#"], ), + "prototype3_sparc": (["#"], ), + "nglayout.mac": (["#"], ), + "pkgdepend": (["#"], ), + "Maketests": (["#"], ), + "depend": (["#"], ), + "csh-aliases": (["#"], ), + "csh-env": (["#"], ), + ".cshrc": (["#"], ), + "MANIFEST": (["#"], ), + + "README": ([""], ["#"]), + "copyright": ([""], ), + + # Special cases in mozilla/xpcom/reflect/xptcall/src/md/unix/ + "xptcstubs_asm_ppc_darwin.s.m4": (["/*", " *", "*/"], ), + "xptcstubs_asm_mips.s.m4": (["/*", " *", "*/"], ), + + "WIN32": (["#"], ), + "WIN16": (["#"], ), + "nsIDocCharsetTest.txt": ([""], ), + "nsIFontListTest.txt": ([""], ), + "ComponentListTest.txt": ([""], ), + "nsIWebBrowserPersistTest1.txt": ([""], ), + "nsIWebBrowserPersistTest2.txt": ([""], ), + "nsIWebBrowserPersistTest3.txt": ([""], ), + "lineterm_LICENSE": (["/*", " *", "*/"], ), + "XMLterm_LICENSE": (["/*", " *", "*/"], ), + "Makefile.linux": (["#"], ), + "BrowserView.cpp.mod": (["/*", " *", "*/"], ), + "header_template": (["/*", " *", "*/"], ), + "cpp_template": (["/*", " *", "*/"], ), + "plugins.txt": ([""], ), + "NsISHistoryTestCase1.txt": ([""], ), + "EmbedSmokeTest.txt": ([""], ), +} + +_g_ext_to_comment_info = { + ".txt": (["##"], ["#"], []), + ".TXT": (["##"], ["#"], []), + ".doc": ([""], ), + ".build": ([""], ), + ".1st": ([""], ), + ".lsm": ([""], ), + ".FP": ([""], ), + ".spec": ([""], ), + + ".CPP": (["/*", " *", "*/"], ), + ".cpp": (["/*", " *", "*/"], ), + ".H": (["/*", " *", "*/"], ), + ".h": (["/*", " *", "*/"], ), + ".c": (["/*", " *", "*/"], ), + ".css": (["/*", " *", "*/"], ['#']), + ".js": (["/*", " *", "*/"], ['#']), + ".idl": (["/*", " *", "*/"], ), + ".ut": (["/*", " *", "*/"], ), + ".rc": (["/*", " *", "*/"], ), + ".rc2": (["/*", " *", "*/"], ), + ".RC": (["/*", " *", "*/"], ), + ".Prefix": (["/*", " *", "*/"], ), + ".prefix": (["/*", " *", "*/"], ), + ".cfg": (["/*", " *", "*/"], ), + ".cp": (["/*", " *", "*/"], ), + ".cs": (["/*", " *", "*/"], ), + ".java": (["/*", " *", "*/"], ), + ".jst": (["/*", " *", "*/"], ), + ".tbl": (["/*", " *", "*/"], ), + ".tab": (["/*", " *", "*/"], ), + ".cc": (["/*", " *", "*/"], ), + ".msg": (["/*", " *", "*/"], ), + ".y": (["/*", " *", "*/"], ), + ".r": (["/*", " *", "*/"], ), + ".mm": (["/*", " *", "*/"], ), + ".x-ccmap":(["/*", " *", "*/"], ), + ".ccmap": (["/*", " *", "*/"], ), + ".sql": (["/*", " *", "*/"], ), + ".pch++": (["/*", " *", "*/"], ), + ".xpm": (["/*", " *", "*/"], ), + ".uih": (["/*", " *", "*/"], ), + ".uil": (["/*", " *", "*/"], ), + ".ccmap": (["/*", " *", "*/"], ), + ".map": (["/*", " *", "*/"], ), + ".win98": (["/*", " *", "*/"], ), + ".php": (["/*", " *", "*/"], ), + ".m": (["/*", " *", "*/"], ), + ".jnot": (["/*", " *", "*/"], ), + ".l": (["/*", " *", "*/"], ), + ".htp": (["/*", " *", "*/"], ), + ".xs": (["/*", " *", "*/"], ), + ".api": (["/*", " *", "*/"], ['#']), + + ".html": ([""], ["#"]), + ".xml": ([""], ["#"]), + ".xbl": ([""], ["#"]), + ".xsl": ([""], ), + ".xul": ([""], ["#"]), + ".dtd": ([""], ["#"]), + + ".rdf": ([""], ["#"]), + ".htm": ([""], ), + ".out": ([""], ), + ".resx": ([""], ), + ".bl": ([""], ), + ".xif": ([""], ), + ".xhtml":([""], ["#"]), + + ".inc": ([""], + ["#"], + ["@!"], + ["/*", " *", "*/"]), + + ".properties": (["#"], ), + ".win": (["#"], ), + ".s": (["#"], ), + ".dsp": (["#"], ), + ".exp": (["#"], ), + ".mk": (["#"], ), + ".mn": (["#"], ), + ".mak": (["#"], ), + ".MAK": (["#"], ), + ".perl": (["#"], ), + ".pl": (["#"], ), + ".sh": (["#"], ), + ".dsw": (["#"], ), + ".cgi": (["#"], ), + ".pm": (["#"], ), + ".pod": (["#"], ), + ".src": (["#"], ), + ".csh": (["#"], ), + ".DLLs": (["#"], ), + ".ksh": (["#"], ), + ".toc": (["#"], ), + ".am": (["#"], ), + ".df": (["#"], ), + ".client": (["#"], ), + ".ref": (["#"], ), # all of them "Makefile.ref" + ".ldif": (["#"], ), + ".ex": (["#"], ), + ".reg": (["#"], ), + ".py": (["#"], ), + ".adb": (["#"], ), + ".dtksh": (["#"], ), + ".pkg": (["#"], ), + ".et": (["#"], ), + ".stub": (["#"], ), + ".nss": (["#"], ), + ".os2": (["#"], ), + ".Solaris": (["#"], ), + ".rep": (["#"], ), + ".NSS": (["#"], ), + ".server": (["#"], ), + ".awk": (["#"], ), + ".targ": (["#"], ), + ".gnuplot": (["#"], ), + ".bash": (["#"], ), + ".tmpl": (["#"], ), + ".com": (["#"], ), + ".dat": (["#"], ), + ".rpm": (["#"], ), + + ".tdf": ([";"], ), + ".def": ([";+#"], [";"]), + ".DEF": ([";+#"], [";"]), + ".ini": ([";"], ), + ".it": ([";"], ), + ".lisp": ([";;;"], ), + + ".cmd": (["rem"], ["REM"]), + ".bat": (["rem"], ["REM"]), + + ".tex": (["%"], ), + ".texi": (["%"], ), + + ".m4": (["dnl"], ), + + ".asm": ([";"], ), + ".vbs": (["'"], ), + ".il": (["!"], ), + ".ad": (["!"], ), + + ".script": (["(*", " *", "*)"], ), + + ".3x": (['.\\"'], ), +} +_g_shebang_pattern_to_comment_info = [ + (re.compile(ur'\A#!.*/bin/sh.*$', re.IGNORECASE), (["#"], )), + (re.compile(ur'\A#!.*perl.*$', re.IGNORECASE), (["#"], )), + (re.compile(ur'\A#!.*php.*$', re.IGNORECASE), (["#"], )), + (re.compile(ur'\A#!.*python.*$', re.IGNORECASE), (["#"], )), + (re.compile(ur'\A#!.*ruby.*$', re.IGNORECASE), (["#"], )), + (re.compile(ur'\A#!.*tclsh.*$', re.IGNORECASE), (["#"], )), + (re.compile(ur'\A#!.*wish.*$', re.IGNORECASE), (["#"], )), + (re.compile(ur'\A#!.*expect.*$', re.IGNORECASE), (["#"], )), +] + + +_g_trilicense_parts = { + "mpl": """\ +***** BEGIN LICENSE BLOCK ***** +Version: MPL 1.1/GPL 2.0/LGPL 2.1 + +The contents of this file are subject to the Mozilla Public License Version +1.1 (the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +for the specific language governing rights and limitations under the +License. + +""", + "npl": """\ +***** BEGIN LICENSE BLOCK ***** +Version: NPL 1.1/GPL 2.0/LGPL 2.1 + +The contents of this file are subject to the Netscape Public License +Version 1.1 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/NPL/ + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +for the specific language governing rights and limitations under the +License. + +""", + "original_code_is": """\ +The Original Code is %(original_code_is)s. + +""", + "original_code_is_with_date": """\ +The Original Code is %(original_code_is)s, released +%(original_code_date)s. + +""", + "initial_developer": """\ +The Initial Developer of the Original Code is +%(initial_developer)s. +Portions created by the Initial Developer are Copyright (C) %(initial_copyright_date)s +the Initial Developer. All Rights Reserved. + +""", + "contributors": """\ +Contributor(s): +%s +""", + "gpl/lgpl for mpl": """\ +Alternatively, the contents of this file may be used under the terms of +either the GNU General Public License Version 2 or later (the "GPL"), or +the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +in which case the provisions of the GPL or the LGPL are applicable instead +of those above. If you wish to allow use of your version of this file only +under the terms of either the GPL or the LGPL, and not to allow others to +use your version of this file under the terms of the MPL, indicate your +decision by deleting the provisions above and replace them with the notice +and other provisions required by the GPL or the LGPL. If you do not delete +the provisions above, a recipient may use your version of this file under +the terms of any one of the MPL, the GPL or the LGPL. + +***** END LICENSE BLOCK *****""", + "gpl/lgpl for npl": """\ +Alternatively, the contents of this file may be used under the terms of +either the GNU General Public License Version 2 or later (the "GPL"), or +the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +in which case the provisions of the GPL or the LGPL are applicable instead +of those above. If you wish to allow use of your version of this file only +under the terms of either the GPL or the LGPL, and not to allow others to +use your version of this file under the terms of the NPL, indicate your +decision by deleting the provisions above and replace them with the notice +and other provisions required by the GPL or the LGPL. If you do not delete +the provisions above, a recipient may use your version of this file under +the terms of any one of the NPL, the GPL or the LGPL. + +***** END LICENSE BLOCK *****""", +} + +_g_dry_run = 0 # iff true, don't modify any files +_g_force = 0 +_g_check_all = 0 + + +#---- internal support routines + +def _is_binary(filename): + """Return true iff the given filename is binary. + + Raises an EnvironmentError if the file does not exist or cannot be + accessed. + """ + fin = open(filename, 'rb') + try: + CHUNKSIZE = 1024 + while 1: + chunk = fin.read(CHUNKSIZE) + if '\0' in chunk: # found null byte + return 1 + if len(chunk) < CHUNKSIZE: + break # done + finally: + fin.close() + + return 0 + + +_g_cvsignore_cache = {} # optimization: keep a cache of .cvsignore content +def _should_skip_according_to_cvsignore(path): + dirname, basename = os.path.split(path) + cvsignore = os.path.join(dirname, ".cvsignore") + if not os.path.exists(cvsignore): + return 0 + elif cvsignore not in _g_cvsignore_cache: + fin = open(cvsignore, 'r') + to_ignore = [] + try: + for f in fin: + if f[-1] == "\n": f = f[:-1] # chomp + if not f: continue # skip empty lines + to_ignore.append(f) + finally: + fin.close() + _g_cvsignore_cache[cvsignore] = to_ignore + + # At this point .cvsignore exists and its contents are in the cache. + to_ignore = _g_cvsignore_cache[cvsignore] + if basename in to_ignore: + return 1 + else: + return 0 + +_g_backup_pattern = re.compile("~\d+$") +def _should_skip_file(path): + log.debug("_should_skip_file(path='%s')", path) + if _g_check_all: + return 0 + ext = os.path.splitext(path)[1] + if ext == ".s": + # '.s' file comment delimiters are all over the map. + log.info("Skipping '%s' ('.s' files are wacky)", path) + return 1 + elif ext in _g_skip_exts: + log.info("Skipping '%s' (according to '_g_skip_exts').", path) + return 1 + xpath = '/'.join(path.split(os.sep)) # use same sep as in _g_skip_files + for sf in _g_skip_files: + if xpath.endswith(sf): + log.info("Skipping '%s' (according to '_g_skip_files').", path) + return 1 + if os.path.basename(path) in _g_skip_file_basenames: + log.info("Skipping '%s' (according to '_g_skip_file_basenames').", path) + return 1 + if _should_skip_according_to_cvsignore(path): + log.info("Skipping '%s' (according to .cvsignore).", path) + return 1 + if _g_backup_pattern.search(path): + log.info("Skipping '%s' (looks like backup file).", path) + return 1 + return 0 + +def _should_skip_dir(path): + log.debug("_should_skip_dir(path='%s')", path) + if _g_check_all: + if os.path.basename(path) in _g_skip_dir_basenames_cvs_only: + return 1 + return 0 + if os.path.basename(path) in _g_skip_dir_basenames: + log.info("Skipping '%s' (according to _g_skip_dir_basenames).", path) + return 1 + xpath = '/'.join(path.split(os.sep)) # use same sep as in _g_skip_dirs + # These could do with being a proper path canonicalisation function... + if xpath[-1] == '/': xpath = xpath[:-1] # treat "calendar/" the same as "calendar" + if xpath[0:2] == './': xpath = xpath[2:] # treat "./calendar" the same as "calendar" + for sd in _g_skip_dirs: + # Changed by gerv to make skip_dirs require whole path + if xpath == sd: + log.info("Skipping '%s' (according to _g_skip_dirs).", path) + return 1 + if _should_skip_according_to_cvsignore(path): + log.info("Skipping '%s' (according to .cvsignore).", path) + return 1 + return 0 + + +def _get_license_info(filename, quick=0): + """Return license block information for the given file. + + "filename" is the path to the file to scan. + "quick" is a boolean that can be set for a quick scan. In this + case, only the "parts" field of the return dictionary will + be filled out. + + Returns a dictionary adequately describing the license block in the + given file for the purpose of determining whether to patch the + license block and how. Returns a dictionary of the following form: + {"parts": , + # if necessary, the following keys are included as well + "begin_line": <(0-based) index at which license block starts>, + "end_line": <(0-based) index at which license block ends>, + "first_prefix": , + "subsequent_prefix": , + "last_suffix": , + # The following fields are correspond to the file specific + # portions of the license template as described here: + # http://www.mozilla.org/MPL/relicensing-faq.html#new-license + # If the associated block is not found, then the value is None. + "original_code_is": ..., + "original_code_date": ..., + "initial_developer": ..., + "initial_copyright_date": ..., + "contributors": ..., + } + + precondition: should not be called on binary files + """ + lic_info = { + "parts": [], + } + + fin = open(filename, 'r') + try: + content = fin.read() + finally: + fin.close() + + # do quick search to see if any of the desired licenses is in here + # - if it looks like all the parts are there, good, done + # - if some but not all parts, continue + parts_pattern = re.compile("""( + (?P\*\*\*\*\*\ BEGIN\ LICENSE\ BLOCK\ \*\*\*\*\*) + | (?PThe\ contents\ of\ this\ file\ are\ subject\ to\ the\ Mozilla) + | (?PThe\ contents\ of\ this\ file\ are\ subject\ to\ the\ Netscape) + | (?PGNU\ (General\ )?Public\ License) + | (?P(Library|Lesser)\ General\ Public\ License) + | (?P\*\*\*\*\*\ END\ LICENSE\ BLOCK\ \*\*\*\*\*) + )""", + re.VERBOSE) + parts = [] # found license parts in this file + start = 0 + while 1: + match = parts_pattern.search(content, start) + if match: + parts = match.groupdict() + for part in parts: + if parts[part]: + lic_info["parts"].append(part) + log.info("%s license/delimeter found", part) + start = match.end() + break + else: + raise RelicError("unexpected license part: %r" % parts) + else: + break + if not parts: + # - if not, check to see if License or Copyright shows up in the + # file; if so, then error out; if not, skip out + any_lic_pattern = re.compile("(Copyright|Licen[sc]e)", re.IGNORECASE) + match = any_lic_pattern.search(content) + if match: + lic_info["parts"].append("unknown") + log.info("unknown license found: %r", + content[max(match.start()-20,0):match.end()+20]) + else: + log.info("no license found") + return lic_info + elif (parts == ["block_begin", "mpl", "gpl", "lgpl", "block_end"] or + parts == ["block_begin", "npl", "gpl", "lgpl", "block_end"]): + log.info("license looks good, no changes necessary") + return lic_info + + if quick: + return lic_info + + # Otherwise, the license needs to be fixed, so gather more detailed + # information. Here is the algorithm we will use: + # - find first license line + # - find the end of this comment block (assumption: from the first + # license line to the end of the comment block is the full + # license block) + # This is a bad assumption in two cases and steps have been taken + # to try to deal with those cases: + # - There could be a trailing part bit of comment that is + # NOT part of the license but is part of the same comment + # block. A common example are the: + # This Original Code has been modified by IBM... + # files (about 130 of them in the moz tree). + # (c.f. test_relicense_ibm_copyright_suffix.c) + # - Some files have split up the license paragraphs into + # multiple comment blocks, e.g. + # "mozilla/build/unix/abs2rel.pl": + # # The contents of this file are subject to the + # # ... + # # the License at http://www.mozilla.org/MPL/ + # + # # The Initial Developer of the Original Code + # # ... + # # Rights Reserved. + # (c.f. test_relicense_separated_license_comment_blocks.pl) + # - these are the lines to replace + # - gather embedded lic data + # - use second line to determine line prefix + # ? Should we only allow processing of unknown-delimiter-files with + # an option? + + # Get comment delimiter info for this file. + comment_delim_sets = _get_comment_delim_sets(filename) + + # - find first license line (and determine which set of comment + # delimiters are in use) + lines = content.splitlines() + for comment_delims in comment_delim_sets: + if len(comment_delims) == 3: + prefix_pattern = "%s|%s|" % (re.escape(comment_delims[0]), + re.escape(comment_delims[1])) + suffix_pattern = "%s" % re.escape(comment_delims[2]) + elif len(comment_delims) == 2: + prefix_pattern = "%s|" % re.escape(comment_delims[0]) + suffix_pattern = "%s" % re.escape(comment_delims[1]) + elif len(comment_delims) == 1: + prefix_pattern = re.escape(comment_delims[-1]) + suffix_pattern = "" + else: # len(comment_delims) == 0 + prefix_pattern = "" + suffix_pattern = "" + + lic_begin_pattern = re.compile(""" + ^(?P%s) + (?P\s*) + (\*+\ BEGIN\ LICENSE\ BLOCK\ \*+ + |\-+\ BEGIN\ LICENSE\ BLOCK\ \-+ + | Version:\ MPL\ \d+\.\d+/GPL\ \d+\.\d+/LGPL\ \d+\.\d+ + | The\ contents\ of\ this\ file\ are\ subject\ to\ the\ Mozilla[\w ]* + | The\ contents\ of\ this\ file\ are\ subject\ to\ the\ Netscape[\w ]* + | Alternatively,\ the\ contents\ of\ this\ file\ may\ be\ used\ under\ the[\w ]*) + (?P%s|)\s*?$ + """ % (prefix_pattern, suffix_pattern), re.VERBOSE) + + for i in range(len(lines)): + match = lic_begin_pattern.search(lines[i]) + if match: + beginline = { + "content": lines[i], + "linenum": i, + "prefix": match.group("prefix"), + "space": match.group("space"), + "suffix": match.group("suffix") + } + # Optimization: If the line before the "beginline" is simply + # a block comment open the include that line in parsed out + # license block. E.g., + # + + + + + + + + + + + + + diff --git a/tools/relic/test/addlicense_outputs/emacs_local_vars_line.c b/tools/relic/test/addlicense_outputs/emacs_local_vars_line.c new file mode 100755 index 000000000000..038d98d7d8dc --- /dev/null +++ b/tools/relic/test/addlicense_outputs/emacs_local_vars_line.c @@ -0,0 +1,143 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org Code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + +#include +#include + +#if defined(VMS) +#include +#elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS) +#include +#elif defined(WIN32) +#include +#elif defined(XP_OS2_VACPP) +#include +#else +#error "Architecture not supported" +#endif + + +int main(int argc, char **argv) +{ +#if defined(OMIT_LIB_BUILD_TIME) + /* + * Some platforms don't have any 64-bit integer type + * such as 'long long'. Because we can't use NSPR's + * PR_snprintf in this program, it is difficult to + * print a static initializer for PRInt64 (a struct). + * So we print nothing. The makefiles that build the + * shared libraries will detect the empty output string + * of this program and omit the library build time + * in PRVersionDescription. + */ +#elif defined(VMS) + long long now; + struct timeb b; + ftime(&b); + now = b.time; + now *= 1000000; + now += (1000 * b.millitm); + fprintf(stdout, "%Ld", now); +#elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS) + long long now; + struct timeval tv; +#ifdef HAVE_SVID_GETTOD + gettimeofday(&tv); +#else + gettimeofday(&tv, NULL); +#endif + now = ((1000000LL) * tv.tv_sec) + (long long)tv.tv_usec; +#if defined(OSF1) + fprintf(stdout, "%ld", now); +#elif defined(BEOS) && defined(__POWERPC__) + fprintf(stdout, "%Ld", now); /* Metroworks on BeOS PPC */ +#else + fprintf(stdout, "%lld", now); +#endif + +#elif defined(WIN32) + __int64 now; + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + CopyMemory(&now, &ft, sizeof(now)); + /* + * 116444736000000000 is the number of 100-nanosecond intervals + * between Jan. 1, 1601 and Jan. 1, 1970. + */ +#ifdef __GNUC__ + now = (now - 116444736000000000LL) / 10LL; + fprintf(stdout, "%lld", now); +#else + now = (now - 116444736000000000i64) / 10i64; + fprintf(stdout, "%I64d", now); +#endif + +#elif defined(XP_OS2_VACPP) +/* no long long or i64 so we use a string */ +#include + char buf[24]; + char tbuf[7]; + time_t now; + long mtime; + int i; + + struct timeb b; + ftime(&b); + now = b.time; + _ltoa(now, buf, 10); + + mtime = b.millitm * 1000; + if (mtime == 0){ + ++now; + strcat(buf, "000000"); + } else { + _ltoa(mtime, tbuf, 10); + for (i = strlen(tbuf); i < 6; ++i) + strcat(buf, "0"); + strcat(buf, tbuf); + } + fprintf(stdout, "%s", buf); + +#else +#error "Architecture not supported" +#endif + + return 0; +} /* main */ + +/* now.c */ diff --git a/tools/relic/test/addlicense_outputs/shebang_and_emacs_line.pl b/tools/relic/test/addlicense_outputs/shebang_and_emacs_line.pl new file mode 100755 index 000000000000..6057b7bc8896 --- /dev/null +++ b/tools/relic/test/addlicense_outputs/shebang_and_emacs_line.pl @@ -0,0 +1,69 @@ +#!env perl +# -*- Mode: Perl; tab-width: 4; -*- +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org Code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 2001 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +# Blah blah blah + +use File::Spec::Unix; +use strict; + +print "Usage: $0 dest_path start_path\n" if ($#ARGV+1 != 2); +my $finish = my_canonpath(shift); +my $start = my_canonpath(shift); + +my $res = File::Spec::Unix->abs2rel($finish, $start); + +#print STDERR "abs2rel($finish,$start) = $res\n"; +print "$res\n"; + +sub my_canonpath($) { + my ($file) = @_; + my (@inlist, @outlist, $dir); + + # Do what File::Spec::Unix->no_upwards should do + my @inlist = split(/\//, File::Spec::Unix->canonpath($file)); + foreach $dir (@inlist) { + if ($dir eq '..') { + pop @outlist; + } else { + push @outlist, $dir; + } + } + $file = join '/',@outlist; + return $file; +} + diff --git a/tools/relic/test/addlicense_outputs/shebang_line.pl b/tools/relic/test/addlicense_outputs/shebang_line.pl new file mode 100755 index 000000000000..51961fc6d92f --- /dev/null +++ b/tools/relic/test/addlicense_outputs/shebang_line.pl @@ -0,0 +1,68 @@ +#!env perl +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org Code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 2001 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +# Blah blah blah + +use File::Spec::Unix; +use strict; + +print "Usage: $0 dest_path start_path\n" if ($#ARGV+1 != 2); +my $finish = my_canonpath(shift); +my $start = my_canonpath(shift); + +my $res = File::Spec::Unix->abs2rel($finish, $start); + +#print STDERR "abs2rel($finish,$start) = $res\n"; +print "$res\n"; + +sub my_canonpath($) { + my ($file) = @_; + my (@inlist, @outlist, $dir); + + # Do what File::Spec::Unix->no_upwards should do + my @inlist = split(/\//, File::Spec::Unix->canonpath($file)); + foreach $dir (@inlist) { + if ($dir eq '..') { + pop @outlist; + } else { + push @outlist, $dir; + } + } + $file = join '/',@outlist; + return $file; +} + diff --git a/tools/relic/test/addlicense_outputs/utf8_xml_file.xml b/tools/relic/test/addlicense_outputs/utf8_xml_file.xml new file mode 100755 index 000000000000..e0b84d82341e --- /dev/null +++ b/tools/relic/test/addlicense_outputs/utf8_xml_file.xml @@ -0,0 +1,44 @@ + + + + + + + + + + diff --git a/tools/relic/test/addlicense_outputs/xml_file.rdf b/tools/relic/test/addlicense_outputs/xml_file.rdf new file mode 100755 index 000000000000..0ee5a3b700a7 --- /dev/null +++ b/tools/relic/test/addlicense_outputs/xml_file.rdf @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tools/relic/test/relicense_inputs/bad_contributor_section.cpp b/tools/relic/test/relicense_inputs/bad_contributor_section.cpp new file mode 100755 index 000000000000..df9757b47d19 --- /dev/null +++ b/tools/relic/test/relicense_inputs/bad_contributor_section.cpp @@ -0,0 +1,75 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is TransforMiiX XSLT processor. + * + * The Initial Developer of the Original Code is The MITRE Corporation. + * Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation. + * + * Portions created by Keith Visco as a Non MITRE employee, + * (C) 1999 Keith Visco. All Rights Reserved. + * + * Contributor(s): + * Keith Visco + * -- original author. + * + */ + +#include "XMLDOMUtils.h" +#include "dom.h" +#include "nsString.h" + +void XMLDOMUtils::getNodeValue(Node* aNode, nsAString& aResult) +{ + if (!aNode) + return; + + unsigned short nodeType = aNode->getNodeType(); + + switch (nodeType) { + case Node::ATTRIBUTE_NODE: + case Node::CDATA_SECTION_NODE: + case Node::COMMENT_NODE: + case Node::PROCESSING_INSTRUCTION_NODE: + case Node::TEXT_NODE: + { + nsAutoString nodeValue; + aNode->getNodeValue(nodeValue); + aResult.Append(nodeValue); + break; + } + case Node::DOCUMENT_NODE: + { + getNodeValue(((Document*)aNode)->getDocumentElement(), + aResult); + break; + } + case Node::DOCUMENT_FRAGMENT_NODE: + case Node::ELEMENT_NODE: + { + Node* tmpNode = aNode->getFirstChild(); + while (tmpNode) { + nodeType = tmpNode->getNodeType(); + if ((nodeType == Node::TEXT_NODE) || + (nodeType == Node::CDATA_SECTION_NODE)) { + nsAutoString nodeValue; + tmpNode->getNodeValue(nodeValue); + aResult.Append(nodeValue); + } + else if (nodeType == Node::ELEMENT_NODE) { + getNodeValue(tmpNode, aResult); + } + tmpNode = tmpNode->getNextSibling(); + } + break; + } + } +} diff --git a/tools/relic/test/relicense_inputs/ibm_copyright_suffix.c b/tools/relic/test/relicense_inputs/ibm_copyright_suffix.c new file mode 100755 index 000000000000..faed4b8b2d48 --- /dev/null +++ b/tools/relic/test/relicense_inputs/ibm_copyright_suffix.c @@ -0,0 +1,59 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU Public License (the "GPL"), in which case the + * provisions of the GPL are applicable instead of those above. + * If you wish to allow use of your version of this file only + * under the terms of the GPL and not to allow others to use your + * version of this file under the NPL, indicate your decision by + * deleting the provisions above and replace them with the notice + * and other provisions required by the GPL. If you do not delete + * the provisions above, a recipient may use your version of this + * file under either the NPL or the GPL. + * + * This Original Code has been modified by IBM Corporation. + * Modifications made by IBM described herein are + * Copyright (c) International Business Machines + * Corporation, 2000 + * + * Modifications to Mozilla code or documentation + * identified per MPL Section 3.3 + * + * Date Modified by Description of modification + * 04/20/2000 IBM Corp. OS/2 VisualAge build. + */ + +/* + * This file is part of the Java-vendor-neutral implementation of LiveConnect + * + * It contains the native code implementation of JS's JavaObject class. + * + * An instance of JavaObject is the JavaScript reflection of a Java object. + * + */ + +#include +#include + +/* snip ... */ + diff --git a/tools/relic/test/relicense_inputs/just_mpl.xul b/tools/relic/test/relicense_inputs/just_mpl.xul new file mode 100755 index 000000000000..56e7011851bc --- /dev/null +++ b/tools/relic/test/relicense_inputs/just_mpl.xul @@ -0,0 +1,64 @@ + + + + + + + + + + + &certmgr.cas; + + + + + + + + + + + +