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;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/relic/test/relicense_inputs/need_to_relicense.h b/tools/relic/test/relicense_inputs/need_to_relicense.h
new file mode 100755
index 000000000000..5691db2b3e0d
--- /dev/null
+++ b/tools/relic/test/relicense_inputs/need_to_relicense.h
@@ -0,0 +1,413 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** 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.
+ *
+ * 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) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Original Author: Daniel Glazman
+ *
+ *
+ * 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 ***** */
+
+#ifndef nsHTMLCSSUtils_h__
+#define nsHTMLCSSUtils_h__
+
+#include "nsCOMPtr.h"
+#include "nsString.h"
+#include "nsIDOMViewCSS.h"
+#include "nsIDOMNode.h"
+#include "nsIDOMElement.h"
+#include "nsIHTMLEditor.h"
+#include "ChangeCSSInlineStyleTxn.h"
+#include "nsEditProperty.h"
+#include "nsIDOMCSSStyleDeclaration.h"
+
+#define SPECIFIED_STYLE_TYPE 1
+#define COMPUTED_STYLE_TYPE 2
+
+class nsHTMLEditor;
+
+typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
+ const char * aDefaultValueString,
+ const char * aPrependString, const char* aAppendString);
+
+class nsHTMLCSSUtils
+{
+public:
+ nsHTMLCSSUtils();
+ ~nsHTMLCSSUtils();
+
+ enum nsCSSEditableProperty {
+ eCSSEditableProperty_NONE=0,
+ eCSSEditableProperty_background_color,
+ eCSSEditableProperty_background_image,
+ eCSSEditableProperty_border,
+ eCSSEditableProperty_caption_side,
+ eCSSEditableProperty_color,
+ eCSSEditableProperty_float,
+ eCSSEditableProperty_font_family,
+ eCSSEditableProperty_font_size,
+ eCSSEditableProperty_font_style,
+ eCSSEditableProperty_font_weight,
+ eCSSEditableProperty_height,
+ eCSSEditableProperty_list_style_type,
+ eCSSEditableProperty_margin_left,
+ eCSSEditableProperty_margin_right,
+ eCSSEditableProperty_text_align,
+ eCSSEditableProperty_text_decoration,
+ eCSSEditableProperty_vertical_align,
+ eCSSEditableProperty_whitespace,
+ eCSSEditableProperty_width
+ };
+
+
+ struct CSSEquivTable {
+ nsCSSEditableProperty cssProperty;
+ nsProcessValueFunc processValueFunctor;
+ const char * defaultValue;
+ const char * prependValue;
+ const char * appendValue;
+ PRBool gettable;
+ PRBool caseSensitiveValue;
+ };
+
+public:
+ nsresult Init(nsHTMLEditor * aEditor);
+
+ /** answers true if the given combination element_name/attribute_name
+ * has a CSS equivalence in this implementation
+ *
+ * @return a boolean saying if the tag/attribute has a css equiv
+ * @param aNode [IN] a DOM node
+ * @param aProperty [IN] an atom containing a HTML tag name
+ * @param aAttribute [IN] a string containing the name of a HTML attribute carried by the element above
+ */
+ PRBool IsCSSEditableProperty(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString * aAttribute);
+
+ /** adds/remove a CSS declaration to the STYLE atrribute carried by a given element
+ *
+ * @param aElement [IN] a DOM element
+ * @param aProperty [IN] an atom containing the CSS property to set
+ * @param aValue [IN] a string containing the value of the CSS property
+ * @param aSuppressTransaction [IN] a boolean indicating, when true,
+ * that no transaction should be recorded
+ */
+ nsresult SetCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
+ const nsAString & aValue,
+ PRBool aSuppressTransaction);
+ nsresult RemoveCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
+ const nsAString & aPropertyValue, PRBool aSuppressTransaction);
+
+ /** directly adds/remove a CSS declaration to the STYLE atrribute carried by
+ * a given element without going through the txn manager
+ *
+ * @param aElement [IN] a DOM element
+ * @param aProperty [IN] a string containing the CSS property to set/remove
+ * @param aValue [IN] a string containing the new value of the CSS property
+ */
+ nsresult SetCSSProperty(nsIDOMElement * aElement,
+ const nsAString & aProperty,
+ const nsAString & aValue);
+ nsresult RemoveCSSProperty(nsIDOMElement * aElement,
+ const nsAString & aProperty);
+
+ /** gets the specified/computed style value of a CSS property for a given node (or its element
+ * ancestor if it is not an element)
+ *
+ * @param aNode [IN] a DOM node
+ * @param aProperty [IN] an atom containing the CSS property to get
+ * @param aPropertyValue [OUT] the retrieved value of the property
+ */
+ nsresult GetSpecifiedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
+ nsAString & aValue);
+ nsresult GetComputedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
+ nsAString & aValue);
+
+ /** Removes a CSS property from the specified declarations in STYLE attribute
+ ** and removes the node if it is an useless span
+ *
+ * @param aNode [IN] the specific node we want to remove a style from
+ * @param aProperty [IN] the CSS property atom to remove
+ * @param aPropertyValue [IN] the value of the property we have to rremove if the property
+ * accepts more than one value
+ */
+ nsresult RemoveCSSInlineStyle(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString & aPropertyValue);
+
+ /** Answers true is the property can be removed by setting a "none" CSS value
+ * on a node
+ *
+ * @return a boolean saying if the property can be remove by setting a "none" value
+ * @param aProperty [IN] an atom containing a CSS property
+ * @param aAttribute [IN] pointer to an attribute name or null if this information is irrelevant
+ */
+ PRBool IsCSSInvertable(nsIAtom * aProperty, const nsAString * aAttribute);
+
+ /** Get the default browser background color if we need it for GetCSSBackgroundColorState
+ *
+ * @param aColor [OUT] the default color as it is defined in prefs
+ */
+ nsresult GetDefaultBackgroundColor(nsAString & aColor);
+
+ /** Get the default length unit used for CSS Indent/Outdent
+ *
+ * @param aLengthUnit [OUT] the default length unit as it is defined in prefs
+ */
+ nsresult GetDefaultLengthUnit(nsAString & aLengthUnit);
+
+ /** asnwers true if the element aElement carries an ID or a class
+ *
+ * @param aElement [IN] a DOM element
+ * @param aReturn [OUT] the boolean answer
+ */
+ nsresult HasClassOrID(nsIDOMElement * aElement, PRBool & aReturn);
+
+ /** returns the list of values for the CSS equivalences to
+ * the passed HTML style for the passed node
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValueString [OUT] the list of css values
+ * @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
+ COMPUTED_STYLE_TYPE to query the computed style values
+ */
+ nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString * aAttribute,
+ nsAString & aValueString,
+ PRUint8 aStyleType);
+
+ /** Does the node aNode (or his parent if it is not an element node) carries
+ * the CSS equivalent styles to the HTML style for this node ?
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aIsSet [OUT] a boolean being true if the css properties are set
+ * @param aValueString [IN/OUT] the attribute value (in) the list of css values (out)
+ * @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
+ COMPUTED_STYLE_TYPE to query the computed style values
+ */
+ nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString * aAttribute,
+ PRBool & aIsSet,
+ nsAString & aValueString,
+ PRUint8 aStyleType);
+
+ /** Adds to the node the CSS inline styles equivalent to the HTML style
+ * and return the number of CSS properties set by the call
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValue [IN] the attribute value
+ * @param aCount [OUT] the number of CSS properties set by the call
+ * @param aSuppressTransaction [IN] a boolean indicating, when true,
+ * that no transaction should be recorded
+ */
+ nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString * aAttribute,
+ const nsAString * aValue,
+ PRInt32 * aCount,
+ PRBool aSuppressTransaction);
+
+ /** removes from the node the CSS inline styles equivalent to the HTML style
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValue [IN] the attribute value
+ * @param aSuppressTransaction [IN] a boolean indicating, when true,
+ * that no transaction should be recorded
+ */
+ nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
+ nsIAtom *aHTMLProperty,
+ const nsAString *aAttribute,
+ const nsAString *aValue,
+ PRBool aSuppressTransaction);
+
+ /** parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char
+ * we need such a parser because nsIDOMCSSStyleDeclaration::GetPropertyCSSValue() is not
+ * implemented
+ *
+ * @param aString [IN] input string to parse
+ * @param aValue [OUT] numeric part
+ * @param aUnit [OUT] unit part
+ */
+ void ParseLength(const nsAString & aString, float * aValue, nsIAtom ** aUnit);
+
+ /** sets the mIsCSSPrefChecked private member ; used as callback from observer when
+ * the css pref state is changed
+ *
+ * @param aIsCSSPrefChecked [IN] the new boolean state for the pref
+ */
+ nsresult SetCSSEnabled(PRBool aIsCSSPrefChecked);
+
+ /** retrieves the mIsCSSPrefChecked private member, true if the css pref is checked,
+ * false if it is not
+ *
+ * @return the boolean value of the css pref
+ */
+ PRBool IsCSSPrefChecked();
+
+ /** ElementsSameStyle compares two elements and checks if they have the same
+ * specified CSS declarations in the STYLE attribute
+ * The answer is always false if at least one of them carries an ID or a class
+ *
+ * @return true if the two elements are considered to have same styles
+ * @param aFirstNode [IN] a DOM node
+ * @param aSecondNode [IN] a DOM node
+ */
+ PRBool ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNode);
+
+ /** get the specified inline styles (style attribute) for an element
+ *
+ * @param aElement [IN] the element node
+ * @param aCssDecl [OUT] the CSS declaration corresponding to the style attr
+ * @param aLength [OUT] the number of declarations in aCssDecl
+ */
+ nsresult GetInlineStyles(nsIDOMElement * aElement, nsIDOMCSSStyleDeclaration ** aCssDecl,
+ PRUint32 * aLength);
+
+ /** returns aNode itself if it is an element node, or the first ancestors being an element
+ * node if aNode is not one itself
+ *
+ * @param aNode [IN] a node
+ * @param aElement [OUT] the deepest element node containing aNode (possibly aNode itself)
+ */
+ nsresult GetElementContainerOrSelf(nsIDOMNode * aNode, nsIDOMElement ** aElement);
+
+ /** Gets the default DOMView for a given node
+ *
+ * @param aNode the node we want the default DOMView for
+ * @param aViewCSS [OUT] the default DOMViewCSS
+ */
+ nsresult GetDefaultViewCSS(nsIDOMNode * aNode, nsIDOMViewCSS ** aViewCSS);
+
+
+private:
+
+ /** retrieves the css property atom from an enum
+ *
+ * @param aProperty [IN] the enum value for the property
+ * @param aAtom [OUT] the corresponding atom
+ */
+ void GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom);
+
+ /** retrieves the CSS declarations equivalent to a HTML style value for
+ * a given equivalence table
+ *
+ * @param aPropertyArray [OUT] the array of css properties
+ * @param aValueArray [OUT] the array of values for the css properties above
+ * @param aEquivTable [IN] the equivalence table
+ * @param aValue [IN] the HTML style value
+ * @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
+ * is made for GetCSSEquivalentToHTMLInlineStyleSet or
+ * RemoveCSSEquivalentToHTMLInlineStyleSet
+ */
+
+ void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
+ nsStringArray & cssValueArray,
+ const CSSEquivTable * aEquivTable,
+ const nsAString * aValue,
+ PRBool aGetOrRemoveRequest);
+
+ /** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
+ * for a given node
+ *
+ * @param aNode [IN] the DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValue [IN] the attribute value
+ * @param aPropertyArray [OUT] the array of css properties
+ * @param aValueArray [OUT] the array of values for the css properties above
+ * @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
+ * is made for GetCSSEquivalentToHTMLInlineStyleSet or
+ * RemoveCSSEquivalentToHTMLInlineStyleSet
+ */
+ void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString *aAttribute,
+ const nsAString *aValue,
+ nsVoidArray & aPropertyArray,
+ nsStringArray & aValueArray,
+ PRBool aGetOrRemoveRequest);
+
+ /** creates a Transaction for setting or removing a css property
+ *
+ * @param aElement [IN] a DOM element
+ * @param aProperty [IN] a CSS property
+ * @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
+ * @param aTxn [OUT] the created transaction
+ * @param aRemoveProperty [IN] true if we create a "remove" transaction, false for a "set"
+ */
+ nsresult CreateCSSPropertyTxn(nsIDOMElement * aElement,
+ nsIAtom * aProperty,
+ const nsAString & aValue,
+ ChangeCSSInlineStyleTxn ** aTxn,
+ PRBool aRemoveProperty);
+
+ /** back-end for GetSpecifiedProperty and GetComputedProperty
+ *
+ * @param aNode [IN] a DOM node
+ * @param aProperty [IN] a CSS property
+ * @param aValue [OUT] the retrieved value for this property
+ * @param aViewCSS [IN] the ViewCSS we need in case we query computed styles
+ * @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
+ COMPUTED_STYLE_TYPE to query the computed style values
+ */
+ nsresult GetCSSInlinePropertyBase(nsIDOMNode * aNode, nsIAtom * aProperty,
+ nsAString & aValue,
+ nsIDOMViewCSS * aViewCSS,
+ PRUint8 aStyleType);
+
+
+private:
+ nsHTMLEditor *mHTMLEditor;
+ PRBool mIsCSSPrefChecked;
+
+};
+
+nsresult NS_NewHTMLCSSUtils(nsHTMLCSSUtils** aInstancePtrResult);
+
+#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
+#define NS_EDITOR_INDENT_INCREMENT_CM 1.05f
+#define NS_EDITOR_INDENT_INCREMENT_MM 10.5f
+#define NS_EDITOR_INDENT_INCREMENT_PT 29.76f
+#define NS_EDITOR_INDENT_INCREMENT_PC 2.48f
+#define NS_EDITOR_INDENT_INCREMENT_EM 3
+#define NS_EDITOR_INDENT_INCREMENT_EX 6
+#define NS_EDITOR_INDENT_INCREMENT_PX 40
+#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
+
+#endif /* nsHTMLCSSUtils_h__ */
diff --git a/tools/relic/test/relicense_inputs/no_initialcopyrightyear_section.xml b/tools/relic/test/relicense_inputs/no_initialcopyrightyear_section.xml
new file mode 100755
index 000000000000..d58917af34ce
--- /dev/null
+++ b/tools/relic/test/relicense_inputs/no_initialcopyrightyear_section.xml
@@ -0,0 +1,118 @@
+
+
+
+
+
+
+
+
+thead_align_center.xml
+
+
+
+
+
+
+
+
+
+
In this test, the THEAD text should be center aligned
+
+
+
+
+
+
+
+
+
+
THEAD
+
+
+
+
+
+
+
+
+
+
+
+
This text is in the TFOOT
+
+
+
+
+
+
+
+
+
+
+
+
This text is in the TBODY
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/relic/test/relicense_inputs/no_initialcopyrightyear_section.xml.options b/tools/relic/test/relicense_inputs/no_initialcopyrightyear_section.xml.options
new file mode 100755
index 000000000000..b90b58ac05d6
--- /dev/null
+++ b/tools/relic/test/relicense_inputs/no_initialcopyrightyear_section.xml.options
@@ -0,0 +1 @@
+fallback_initial_copyright_date=2001
diff --git a/tools/relic/test/relicense_inputs/no_origcodeis_section.h b/tools/relic/test/relicense_inputs/no_origcodeis_section.h
new file mode 100755
index 000000000000..07d212101f02
--- /dev/null
+++ b/tools/relic/test/relicense_inputs/no_origcodeis_section.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * 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 Initial Developers of this code under the MPL are Owen Taylor
+ * and Christopher Blizzard .
+ * Portions created by the Initial Developers are Copyright (C) 1999
+ * Owen Taylor and Christopher Blizzard. All Rights Reserved. */
+
+#ifndef __GTK_MOZAREA_H__
+#define __GTK_MOZAREA_H__
+
+#include
+#include "gdksuperwin.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct _GtkMozArea GtkMozArea;
+typedef struct _GtkMozAreaClass GtkMozAreaClass;
+
+#define GTK_TYPE_MOZAREA (gtk_mozarea_get_type ())
+#define GTK_MOZAREA(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MOZAREA, GtkMozArea))
+#define GTK_MOZAREA_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MOZAREA, GtkMozAreaClass))
+#define GTK_IS_MOZAREA(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MOZAREA))
+#define GTK_IS_MOZAREA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MOZAREA))
+
+struct _GtkMozArea
+{
+ GtkWidget widget;
+ GdkSuperWin *superwin;
+ gboolean toplevel_focus;
+
+ /* store away the toplevel window */
+ GdkWindow *toplevel_window;
+};
+
+struct _GtkMozAreaClass
+{
+ GtkWindowClass window_class;
+
+ /* signals */
+ void (* toplevel_focus_in ) (GtkMozArea *area);
+ void (* toplevel_focus_out) (GtkMozArea *area);
+ void (* toplevel_configure) (GtkMozArea *area);
+};
+
+GtkType gtk_mozarea_get_type (void);
+GtkWidget *gtk_mozarea_new ();
+gboolean gtk_mozarea_get_toplevel_focus(GtkMozArea *area);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __GTK_MOZAREA_H__ */
diff --git a/tools/relic/test/relicense_inputs/no_origcodeis_section.h.options b/tools/relic/test/relicense_inputs/no_origcodeis_section.h.options
new file mode 100755
index 000000000000..9e6a8004e404
--- /dev/null
+++ b/tools/relic/test/relicense_inputs/no_origcodeis_section.h.options
@@ -0,0 +1 @@
+fallback_original_code_is=mozilla.org code
diff --git a/tools/relic/test/relicense_inputs/npl.h b/tools/relic/test/relicense_inputs/npl.h
new file mode 100755
index 000000000000..b71071e78bbb
--- /dev/null
+++ b/tools/relic/test/relicense_inputs/npl.h
@@ -0,0 +1,398 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** 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.
+ *
+ * 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) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Daniel Glazman , foo@bar.org
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsHTMLCSSUtils_h__
+#define nsHTMLCSSUtils_h__
+
+#include "nsCOMPtr.h"
+#include "nsString.h"
+#include "nsIDOMViewCSS.h"
+#include "nsIDOMNode.h"
+#include "nsIDOMElement.h"
+#include "nsIHTMLEditor.h"
+#include "ChangeCSSInlineStyleTxn.h"
+#include "nsEditProperty.h"
+#include "nsIDOMCSSStyleDeclaration.h"
+
+#define SPECIFIED_STYLE_TYPE 1
+#define COMPUTED_STYLE_TYPE 2
+
+class nsHTMLEditor;
+
+typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
+ const char * aDefaultValueString,
+ const char * aPrependString, const char* aAppendString);
+
+class nsHTMLCSSUtils
+{
+public:
+ nsHTMLCSSUtils();
+ ~nsHTMLCSSUtils();
+
+ enum nsCSSEditableProperty {
+ eCSSEditableProperty_NONE=0,
+ eCSSEditableProperty_background_color,
+ eCSSEditableProperty_background_image,
+ eCSSEditableProperty_border,
+ eCSSEditableProperty_caption_side,
+ eCSSEditableProperty_color,
+ eCSSEditableProperty_float,
+ eCSSEditableProperty_font_family,
+ eCSSEditableProperty_font_size,
+ eCSSEditableProperty_font_style,
+ eCSSEditableProperty_font_weight,
+ eCSSEditableProperty_height,
+ eCSSEditableProperty_list_style_type,
+ eCSSEditableProperty_margin_left,
+ eCSSEditableProperty_margin_right,
+ eCSSEditableProperty_text_align,
+ eCSSEditableProperty_text_decoration,
+ eCSSEditableProperty_vertical_align,
+ eCSSEditableProperty_whitespace,
+ eCSSEditableProperty_width
+ };
+
+
+ struct CSSEquivTable {
+ nsCSSEditableProperty cssProperty;
+ nsProcessValueFunc processValueFunctor;
+ const char * defaultValue;
+ const char * prependValue;
+ const char * appendValue;
+ PRBool gettable;
+ PRBool caseSensitiveValue;
+ };
+
+public:
+ nsresult Init(nsHTMLEditor * aEditor);
+
+ /** answers true if the given combination element_name/attribute_name
+ * has a CSS equivalence in this implementation
+ *
+ * @return a boolean saying if the tag/attribute has a css equiv
+ * @param aNode [IN] a DOM node
+ * @param aProperty [IN] an atom containing a HTML tag name
+ * @param aAttribute [IN] a string containing the name of a HTML attribute carried by the element above
+ */
+ PRBool IsCSSEditableProperty(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString * aAttribute);
+
+ /** adds/remove a CSS declaration to the STYLE atrribute carried by a given element
+ *
+ * @param aElement [IN] a DOM element
+ * @param aProperty [IN] an atom containing the CSS property to set
+ * @param aValue [IN] a string containing the value of the CSS property
+ * @param aSuppressTransaction [IN] a boolean indicating, when true,
+ * that no transaction should be recorded
+ */
+ nsresult SetCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
+ const nsAString & aValue,
+ PRBool aSuppressTransaction);
+ nsresult RemoveCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
+ const nsAString & aPropertyValue, PRBool aSuppressTransaction);
+
+ /** directly adds/remove a CSS declaration to the STYLE atrribute carried by
+ * a given element without going through the txn manager
+ *
+ * @param aElement [IN] a DOM element
+ * @param aProperty [IN] a string containing the CSS property to set/remove
+ * @param aValue [IN] a string containing the new value of the CSS property
+ */
+ nsresult SetCSSProperty(nsIDOMElement * aElement,
+ const nsAString & aProperty,
+ const nsAString & aValue);
+ nsresult RemoveCSSProperty(nsIDOMElement * aElement,
+ const nsAString & aProperty);
+
+ /** gets the specified/computed style value of a CSS property for a given node (or its element
+ * ancestor if it is not an element)
+ *
+ * @param aNode [IN] a DOM node
+ * @param aProperty [IN] an atom containing the CSS property to get
+ * @param aPropertyValue [OUT] the retrieved value of the property
+ */
+ nsresult GetSpecifiedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
+ nsAString & aValue);
+ nsresult GetComputedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
+ nsAString & aValue);
+
+ /** Removes a CSS property from the specified declarations in STYLE attribute
+ ** and removes the node if it is an useless span
+ *
+ * @param aNode [IN] the specific node we want to remove a style from
+ * @param aProperty [IN] the CSS property atom to remove
+ * @param aPropertyValue [IN] the value of the property we have to rremove if the property
+ * accepts more than one value
+ */
+ nsresult RemoveCSSInlineStyle(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString & aPropertyValue);
+
+ /** Answers true is the property can be removed by setting a "none" CSS value
+ * on a node
+ *
+ * @return a boolean saying if the property can be remove by setting a "none" value
+ * @param aProperty [IN] an atom containing a CSS property
+ * @param aAttribute [IN] pointer to an attribute name or null if this information is irrelevant
+ */
+ PRBool IsCSSInvertable(nsIAtom * aProperty, const nsAString * aAttribute);
+
+ /** Get the default browser background color if we need it for GetCSSBackgroundColorState
+ *
+ * @param aColor [OUT] the default color as it is defined in prefs
+ */
+ nsresult GetDefaultBackgroundColor(nsAString & aColor);
+
+ /** Get the default length unit used for CSS Indent/Outdent
+ *
+ * @param aLengthUnit [OUT] the default length unit as it is defined in prefs
+ */
+ nsresult GetDefaultLengthUnit(nsAString & aLengthUnit);
+
+ /** asnwers true if the element aElement carries an ID or a class
+ *
+ * @param aElement [IN] a DOM element
+ * @param aReturn [OUT] the boolean answer
+ */
+ nsresult HasClassOrID(nsIDOMElement * aElement, PRBool & aReturn);
+
+ /** returns the list of values for the CSS equivalences to
+ * the passed HTML style for the passed node
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValueString [OUT] the list of css values
+ * @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
+ COMPUTED_STYLE_TYPE to query the computed style values
+ */
+ nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString * aAttribute,
+ nsAString & aValueString,
+ PRUint8 aStyleType);
+
+ /** Does the node aNode (or his parent if it is not an element node) carries
+ * the CSS equivalent styles to the HTML style for this node ?
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aIsSet [OUT] a boolean being true if the css properties are set
+ * @param aValueString [IN/OUT] the attribute value (in) the list of css values (out)
+ * @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
+ COMPUTED_STYLE_TYPE to query the computed style values
+ */
+ nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString * aAttribute,
+ PRBool & aIsSet,
+ nsAString & aValueString,
+ PRUint8 aStyleType);
+
+ /** Adds to the node the CSS inline styles equivalent to the HTML style
+ * and return the number of CSS properties set by the call
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValue [IN] the attribute value
+ * @param aCount [OUT] the number of CSS properties set by the call
+ * @param aSuppressTransaction [IN] a boolean indicating, when true,
+ * that no transaction should be recorded
+ */
+ nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString * aAttribute,
+ const nsAString * aValue,
+ PRInt32 * aCount,
+ PRBool aSuppressTransaction);
+
+ /** removes from the node the CSS inline styles equivalent to the HTML style
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValue [IN] the attribute value
+ * @param aSuppressTransaction [IN] a boolean indicating, when true,
+ * that no transaction should be recorded
+ */
+ nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
+ nsIAtom *aHTMLProperty,
+ const nsAString *aAttribute,
+ const nsAString *aValue,
+ PRBool aSuppressTransaction);
+
+ /** parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char
+ * we need such a parser because nsIDOMCSSStyleDeclaration::GetPropertyCSSValue() is not
+ * implemented
+ *
+ * @param aString [IN] input string to parse
+ * @param aValue [OUT] numeric part
+ * @param aUnit [OUT] unit part
+ */
+ void ParseLength(const nsAString & aString, float * aValue, nsIAtom ** aUnit);
+
+ /** sets the mIsCSSPrefChecked private member ; used as callback from observer when
+ * the css pref state is changed
+ *
+ * @param aIsCSSPrefChecked [IN] the new boolean state for the pref
+ */
+ nsresult SetCSSEnabled(PRBool aIsCSSPrefChecked);
+
+ /** retrieves the mIsCSSPrefChecked private member, true if the css pref is checked,
+ * false if it is not
+ *
+ * @return the boolean value of the css pref
+ */
+ PRBool IsCSSPrefChecked();
+
+ /** ElementsSameStyle compares two elements and checks if they have the same
+ * specified CSS declarations in the STYLE attribute
+ * The answer is always false if at least one of them carries an ID or a class
+ *
+ * @return true if the two elements are considered to have same styles
+ * @param aFirstNode [IN] a DOM node
+ * @param aSecondNode [IN] a DOM node
+ */
+ PRBool ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNode);
+
+ /** get the specified inline styles (style attribute) for an element
+ *
+ * @param aElement [IN] the element node
+ * @param aCssDecl [OUT] the CSS declaration corresponding to the style attr
+ * @param aLength [OUT] the number of declarations in aCssDecl
+ */
+ nsresult GetInlineStyles(nsIDOMElement * aElement, nsIDOMCSSStyleDeclaration ** aCssDecl,
+ PRUint32 * aLength);
+
+ /** returns aNode itself if it is an element node, or the first ancestors being an element
+ * node if aNode is not one itself
+ *
+ * @param aNode [IN] a node
+ * @param aElement [OUT] the deepest element node containing aNode (possibly aNode itself)
+ */
+ nsresult GetElementContainerOrSelf(nsIDOMNode * aNode, nsIDOMElement ** aElement);
+
+ /** Gets the default DOMView for a given node
+ *
+ * @param aNode the node we want the default DOMView for
+ * @param aViewCSS [OUT] the default DOMViewCSS
+ */
+ nsresult GetDefaultViewCSS(nsIDOMNode * aNode, nsIDOMViewCSS ** aViewCSS);
+
+
+private:
+
+ /** retrieves the css property atom from an enum
+ *
+ * @param aProperty [IN] the enum value for the property
+ * @param aAtom [OUT] the corresponding atom
+ */
+ void GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom);
+
+ /** retrieves the CSS declarations equivalent to a HTML style value for
+ * a given equivalence table
+ *
+ * @param aPropertyArray [OUT] the array of css properties
+ * @param aValueArray [OUT] the array of values for the css properties above
+ * @param aEquivTable [IN] the equivalence table
+ * @param aValue [IN] the HTML style value
+ * @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
+ * is made for GetCSSEquivalentToHTMLInlineStyleSet or
+ * RemoveCSSEquivalentToHTMLInlineStyleSet
+ */
+
+ void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
+ nsStringArray & cssValueArray,
+ const CSSEquivTable * aEquivTable,
+ const nsAString * aValue,
+ PRBool aGetOrRemoveRequest);
+
+ /** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
+ * for a given node
+ *
+ * @param aNode [IN] the DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValue [IN] the attribute value
+ * @param aPropertyArray [OUT] the array of css properties
+ * @param aValueArray [OUT] the array of values for the css properties above
+ * @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
+ * is made for GetCSSEquivalentToHTMLInlineStyleSet or
+ * RemoveCSSEquivalentToHTMLInlineStyleSet
+ */
+ void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString *aAttribute,
+ const nsAString *aValue,
+ nsVoidArray & aPropertyArray,
+ nsStringArray & aValueArray,
+ PRBool aGetOrRemoveRequest);
+
+ /** creates a Transaction for setting or removing a css property
+ *
+ * @param aElement [IN] a DOM element
+ * @param aProperty [IN] a CSS property
+ * @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
+ * @param aTxn [OUT] the created transaction
+ * @param aRemoveProperty [IN] true if we create a "remove" transaction, false for a "set"
+ */
+ nsresult CreateCSSPropertyTxn(nsIDOMElement * aElement,
+ nsIAtom * aProperty,
+ const nsAString & aValue,
+ ChangeCSSInlineStyleTxn ** aTxn,
+ PRBool aRemoveProperty);
+
+ /** back-end for GetSpecifiedProperty and GetComputedProperty
+ *
+ * @param aNode [IN] a DOM node
+ * @param aProperty [IN] a CSS property
+ * @param aValue [OUT] the retrieved value for this property
+ * @param aViewCSS [IN] the ViewCSS we need in case we query computed styles
+ * @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
+ COMPUTED_STYLE_TYPE to query the computed style values
+ */
+ nsresult GetCSSInlinePropertyBase(nsIDOMNode * aNode, nsIAtom * aProperty,
+ nsAString & aValue,
+ nsIDOMViewCSS * aViewCSS,
+ PRUint8 aStyleType);
+
+
+private:
+ nsHTMLEditor *mHTMLEditor;
+ PRBool mIsCSSPrefChecked;
+
+};
+
+nsresult NS_NewHTMLCSSUtils(nsHTMLCSSUtils** aInstancePtrResult);
+
+#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
+#define NS_EDITOR_INDENT_INCREMENT_CM 1.05f
+#define NS_EDITOR_INDENT_INCREMENT_MM 10.5f
+#define NS_EDITOR_INDENT_INCREMENT_PT 29.76f
+#define NS_EDITOR_INDENT_INCREMENT_PC 2.48f
+#define NS_EDITOR_INDENT_INCREMENT_EM 3
+#define NS_EDITOR_INDENT_INCREMENT_EX 6
+#define NS_EDITOR_INDENT_INCREMENT_PX 40
+#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
+
+#endif /* nsHTMLCSSUtils_h__ */
diff --git a/tools/relic/test/relicense_inputs/separated_license_comment_blocks.pl b/tools/relic/test/relicense_inputs/separated_license_comment_blocks.pl
new file mode 100755
index 000000000000..879c90018566
--- /dev/null
+++ b/tools/relic/test/relicense_inputs/separated_license_comment_blocks.pl
@@ -0,0 +1,41 @@
+#!env perl
+
+# 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/
+
+# The Initial Developer of the Original Code is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 2002 Netscape Communications Corporation. All
+# Rights Reserved.
+
+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/relicense_inputs/separated_license_comment_blocks.pl.options b/tools/relic/test/relicense_inputs/separated_license_comment_blocks.pl.options
new file mode 100755
index 000000000000..9e6a8004e404
--- /dev/null
+++ b/tools/relic/test/relicense_inputs/separated_license_comment_blocks.pl.options
@@ -0,0 +1 @@
+fallback_original_code_is=mozilla.org code
diff --git a/tools/relic/test/relicense_inputs/trailing_orig_code_modified.pl b/tools/relic/test/relicense_inputs/trailing_orig_code_modified.pl
new file mode 100755
index 000000000000..de8412e0be67
--- /dev/null
+++ b/tools/relic/test/relicense_inputs/trailing_orig_code_modified.pl
@@ -0,0 +1,46 @@
+# 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.
+
+use strict;
+
+# snip ...
+
diff --git a/tools/relic/test/relicense_inputs/unknown_license.c b/tools/relic/test/relicense_inputs/unknown_license.c
new file mode 100755
index 000000000000..2e8eb2af86cf
--- /dev/null
+++ b/tools/relic/test/relicense_inputs/unknown_license.c
@@ -0,0 +1,6 @@
+
+// This is my own personal LiceNse.
+
+int main(void) {
+ return 0;
+}
diff --git a/tools/relic/test/relicense_outputs/bad_contributor_section.cpp.error b/tools/relic/test/relicense_outputs/bad_contributor_section.cpp.error
new file mode 100755
index 000000000000..143db05dd592
--- /dev/null
+++ b/tools/relic/test/relicense_outputs/bad_contributor_section.cpp.error
@@ -0,0 +1 @@
+This line is part of the 'Contributor(s):' paragraph but (1) is not indented and (2) does not look like it contains an email address: relicense_tmp/bad_contributor_section.cpp:20: ' * Keith Visco '
diff --git a/tools/relic/test/relicense_outputs/ibm_copyright_suffix.c b/tools/relic/test/relicense_outputs/ibm_copyright_suffix.c
new file mode 100755
index 000000000000..aa541afa8dda
--- /dev/null
+++ b/tools/relic/test/relicense_outputs/ibm_copyright_suffix.c
@@ -0,0 +1,65 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * ***** 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.
+ *
+ * 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 the Initial Developer are Copyright (C) 1998
+ * 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 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 *****
+ *
+ * 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_outputs/just_mpl.xul b/tools/relic/test/relicense_outputs/just_mpl.xul
new file mode 100755
index 000000000000..8bf452a073b6
--- /dev/null
+++ b/tools/relic/test/relicense_outputs/just_mpl.xul
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+ &certmgr.cas;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/relic/test/relicense_outputs/need_to_relicense.h b/tools/relic/test/relicense_outputs/need_to_relicense.h
new file mode 100755
index 000000000000..bafc5805c610
--- /dev/null
+++ b/tools/relic/test/relicense_outputs/need_to_relicense.h
@@ -0,0 +1,412 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** 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.
+ *
+ * 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) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Original Author: Daniel Glazman
+ *
+ * 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 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 ***** */
+
+#ifndef nsHTMLCSSUtils_h__
+#define nsHTMLCSSUtils_h__
+
+#include "nsCOMPtr.h"
+#include "nsString.h"
+#include "nsIDOMViewCSS.h"
+#include "nsIDOMNode.h"
+#include "nsIDOMElement.h"
+#include "nsIHTMLEditor.h"
+#include "ChangeCSSInlineStyleTxn.h"
+#include "nsEditProperty.h"
+#include "nsIDOMCSSStyleDeclaration.h"
+
+#define SPECIFIED_STYLE_TYPE 1
+#define COMPUTED_STYLE_TYPE 2
+
+class nsHTMLEditor;
+
+typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
+ const char * aDefaultValueString,
+ const char * aPrependString, const char* aAppendString);
+
+class nsHTMLCSSUtils
+{
+public:
+ nsHTMLCSSUtils();
+ ~nsHTMLCSSUtils();
+
+ enum nsCSSEditableProperty {
+ eCSSEditableProperty_NONE=0,
+ eCSSEditableProperty_background_color,
+ eCSSEditableProperty_background_image,
+ eCSSEditableProperty_border,
+ eCSSEditableProperty_caption_side,
+ eCSSEditableProperty_color,
+ eCSSEditableProperty_float,
+ eCSSEditableProperty_font_family,
+ eCSSEditableProperty_font_size,
+ eCSSEditableProperty_font_style,
+ eCSSEditableProperty_font_weight,
+ eCSSEditableProperty_height,
+ eCSSEditableProperty_list_style_type,
+ eCSSEditableProperty_margin_left,
+ eCSSEditableProperty_margin_right,
+ eCSSEditableProperty_text_align,
+ eCSSEditableProperty_text_decoration,
+ eCSSEditableProperty_vertical_align,
+ eCSSEditableProperty_whitespace,
+ eCSSEditableProperty_width
+ };
+
+
+ struct CSSEquivTable {
+ nsCSSEditableProperty cssProperty;
+ nsProcessValueFunc processValueFunctor;
+ const char * defaultValue;
+ const char * prependValue;
+ const char * appendValue;
+ PRBool gettable;
+ PRBool caseSensitiveValue;
+ };
+
+public:
+ nsresult Init(nsHTMLEditor * aEditor);
+
+ /** answers true if the given combination element_name/attribute_name
+ * has a CSS equivalence in this implementation
+ *
+ * @return a boolean saying if the tag/attribute has a css equiv
+ * @param aNode [IN] a DOM node
+ * @param aProperty [IN] an atom containing a HTML tag name
+ * @param aAttribute [IN] a string containing the name of a HTML attribute carried by the element above
+ */
+ PRBool IsCSSEditableProperty(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString * aAttribute);
+
+ /** adds/remove a CSS declaration to the STYLE atrribute carried by a given element
+ *
+ * @param aElement [IN] a DOM element
+ * @param aProperty [IN] an atom containing the CSS property to set
+ * @param aValue [IN] a string containing the value of the CSS property
+ * @param aSuppressTransaction [IN] a boolean indicating, when true,
+ * that no transaction should be recorded
+ */
+ nsresult SetCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
+ const nsAString & aValue,
+ PRBool aSuppressTransaction);
+ nsresult RemoveCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
+ const nsAString & aPropertyValue, PRBool aSuppressTransaction);
+
+ /** directly adds/remove a CSS declaration to the STYLE atrribute carried by
+ * a given element without going through the txn manager
+ *
+ * @param aElement [IN] a DOM element
+ * @param aProperty [IN] a string containing the CSS property to set/remove
+ * @param aValue [IN] a string containing the new value of the CSS property
+ */
+ nsresult SetCSSProperty(nsIDOMElement * aElement,
+ const nsAString & aProperty,
+ const nsAString & aValue);
+ nsresult RemoveCSSProperty(nsIDOMElement * aElement,
+ const nsAString & aProperty);
+
+ /** gets the specified/computed style value of a CSS property for a given node (or its element
+ * ancestor if it is not an element)
+ *
+ * @param aNode [IN] a DOM node
+ * @param aProperty [IN] an atom containing the CSS property to get
+ * @param aPropertyValue [OUT] the retrieved value of the property
+ */
+ nsresult GetSpecifiedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
+ nsAString & aValue);
+ nsresult GetComputedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
+ nsAString & aValue);
+
+ /** Removes a CSS property from the specified declarations in STYLE attribute
+ ** and removes the node if it is an useless span
+ *
+ * @param aNode [IN] the specific node we want to remove a style from
+ * @param aProperty [IN] the CSS property atom to remove
+ * @param aPropertyValue [IN] the value of the property we have to rremove if the property
+ * accepts more than one value
+ */
+ nsresult RemoveCSSInlineStyle(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString & aPropertyValue);
+
+ /** Answers true is the property can be removed by setting a "none" CSS value
+ * on a node
+ *
+ * @return a boolean saying if the property can be remove by setting a "none" value
+ * @param aProperty [IN] an atom containing a CSS property
+ * @param aAttribute [IN] pointer to an attribute name or null if this information is irrelevant
+ */
+ PRBool IsCSSInvertable(nsIAtom * aProperty, const nsAString * aAttribute);
+
+ /** Get the default browser background color if we need it for GetCSSBackgroundColorState
+ *
+ * @param aColor [OUT] the default color as it is defined in prefs
+ */
+ nsresult GetDefaultBackgroundColor(nsAString & aColor);
+
+ /** Get the default length unit used for CSS Indent/Outdent
+ *
+ * @param aLengthUnit [OUT] the default length unit as it is defined in prefs
+ */
+ nsresult GetDefaultLengthUnit(nsAString & aLengthUnit);
+
+ /** asnwers true if the element aElement carries an ID or a class
+ *
+ * @param aElement [IN] a DOM element
+ * @param aReturn [OUT] the boolean answer
+ */
+ nsresult HasClassOrID(nsIDOMElement * aElement, PRBool & aReturn);
+
+ /** returns the list of values for the CSS equivalences to
+ * the passed HTML style for the passed node
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValueString [OUT] the list of css values
+ * @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
+ COMPUTED_STYLE_TYPE to query the computed style values
+ */
+ nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString * aAttribute,
+ nsAString & aValueString,
+ PRUint8 aStyleType);
+
+ /** Does the node aNode (or his parent if it is not an element node) carries
+ * the CSS equivalent styles to the HTML style for this node ?
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aIsSet [OUT] a boolean being true if the css properties are set
+ * @param aValueString [IN/OUT] the attribute value (in) the list of css values (out)
+ * @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
+ COMPUTED_STYLE_TYPE to query the computed style values
+ */
+ nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString * aAttribute,
+ PRBool & aIsSet,
+ nsAString & aValueString,
+ PRUint8 aStyleType);
+
+ /** Adds to the node the CSS inline styles equivalent to the HTML style
+ * and return the number of CSS properties set by the call
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValue [IN] the attribute value
+ * @param aCount [OUT] the number of CSS properties set by the call
+ * @param aSuppressTransaction [IN] a boolean indicating, when true,
+ * that no transaction should be recorded
+ */
+ nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString * aAttribute,
+ const nsAString * aValue,
+ PRInt32 * aCount,
+ PRBool aSuppressTransaction);
+
+ /** removes from the node the CSS inline styles equivalent to the HTML style
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValue [IN] the attribute value
+ * @param aSuppressTransaction [IN] a boolean indicating, when true,
+ * that no transaction should be recorded
+ */
+ nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
+ nsIAtom *aHTMLProperty,
+ const nsAString *aAttribute,
+ const nsAString *aValue,
+ PRBool aSuppressTransaction);
+
+ /** parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char
+ * we need such a parser because nsIDOMCSSStyleDeclaration::GetPropertyCSSValue() is not
+ * implemented
+ *
+ * @param aString [IN] input string to parse
+ * @param aValue [OUT] numeric part
+ * @param aUnit [OUT] unit part
+ */
+ void ParseLength(const nsAString & aString, float * aValue, nsIAtom ** aUnit);
+
+ /** sets the mIsCSSPrefChecked private member ; used as callback from observer when
+ * the css pref state is changed
+ *
+ * @param aIsCSSPrefChecked [IN] the new boolean state for the pref
+ */
+ nsresult SetCSSEnabled(PRBool aIsCSSPrefChecked);
+
+ /** retrieves the mIsCSSPrefChecked private member, true if the css pref is checked,
+ * false if it is not
+ *
+ * @return the boolean value of the css pref
+ */
+ PRBool IsCSSPrefChecked();
+
+ /** ElementsSameStyle compares two elements and checks if they have the same
+ * specified CSS declarations in the STYLE attribute
+ * The answer is always false if at least one of them carries an ID or a class
+ *
+ * @return true if the two elements are considered to have same styles
+ * @param aFirstNode [IN] a DOM node
+ * @param aSecondNode [IN] a DOM node
+ */
+ PRBool ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNode);
+
+ /** get the specified inline styles (style attribute) for an element
+ *
+ * @param aElement [IN] the element node
+ * @param aCssDecl [OUT] the CSS declaration corresponding to the style attr
+ * @param aLength [OUT] the number of declarations in aCssDecl
+ */
+ nsresult GetInlineStyles(nsIDOMElement * aElement, nsIDOMCSSStyleDeclaration ** aCssDecl,
+ PRUint32 * aLength);
+
+ /** returns aNode itself if it is an element node, or the first ancestors being an element
+ * node if aNode is not one itself
+ *
+ * @param aNode [IN] a node
+ * @param aElement [OUT] the deepest element node containing aNode (possibly aNode itself)
+ */
+ nsresult GetElementContainerOrSelf(nsIDOMNode * aNode, nsIDOMElement ** aElement);
+
+ /** Gets the default DOMView for a given node
+ *
+ * @param aNode the node we want the default DOMView for
+ * @param aViewCSS [OUT] the default DOMViewCSS
+ */
+ nsresult GetDefaultViewCSS(nsIDOMNode * aNode, nsIDOMViewCSS ** aViewCSS);
+
+
+private:
+
+ /** retrieves the css property atom from an enum
+ *
+ * @param aProperty [IN] the enum value for the property
+ * @param aAtom [OUT] the corresponding atom
+ */
+ void GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom);
+
+ /** retrieves the CSS declarations equivalent to a HTML style value for
+ * a given equivalence table
+ *
+ * @param aPropertyArray [OUT] the array of css properties
+ * @param aValueArray [OUT] the array of values for the css properties above
+ * @param aEquivTable [IN] the equivalence table
+ * @param aValue [IN] the HTML style value
+ * @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
+ * is made for GetCSSEquivalentToHTMLInlineStyleSet or
+ * RemoveCSSEquivalentToHTMLInlineStyleSet
+ */
+
+ void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
+ nsStringArray & cssValueArray,
+ const CSSEquivTable * aEquivTable,
+ const nsAString * aValue,
+ PRBool aGetOrRemoveRequest);
+
+ /** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
+ * for a given node
+ *
+ * @param aNode [IN] the DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValue [IN] the attribute value
+ * @param aPropertyArray [OUT] the array of css properties
+ * @param aValueArray [OUT] the array of values for the css properties above
+ * @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
+ * is made for GetCSSEquivalentToHTMLInlineStyleSet or
+ * RemoveCSSEquivalentToHTMLInlineStyleSet
+ */
+ void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString *aAttribute,
+ const nsAString *aValue,
+ nsVoidArray & aPropertyArray,
+ nsStringArray & aValueArray,
+ PRBool aGetOrRemoveRequest);
+
+ /** creates a Transaction for setting or removing a css property
+ *
+ * @param aElement [IN] a DOM element
+ * @param aProperty [IN] a CSS property
+ * @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
+ * @param aTxn [OUT] the created transaction
+ * @param aRemoveProperty [IN] true if we create a "remove" transaction, false for a "set"
+ */
+ nsresult CreateCSSPropertyTxn(nsIDOMElement * aElement,
+ nsIAtom * aProperty,
+ const nsAString & aValue,
+ ChangeCSSInlineStyleTxn ** aTxn,
+ PRBool aRemoveProperty);
+
+ /** back-end for GetSpecifiedProperty and GetComputedProperty
+ *
+ * @param aNode [IN] a DOM node
+ * @param aProperty [IN] a CSS property
+ * @param aValue [OUT] the retrieved value for this property
+ * @param aViewCSS [IN] the ViewCSS we need in case we query computed styles
+ * @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
+ COMPUTED_STYLE_TYPE to query the computed style values
+ */
+ nsresult GetCSSInlinePropertyBase(nsIDOMNode * aNode, nsIAtom * aProperty,
+ nsAString & aValue,
+ nsIDOMViewCSS * aViewCSS,
+ PRUint8 aStyleType);
+
+
+private:
+ nsHTMLEditor *mHTMLEditor;
+ PRBool mIsCSSPrefChecked;
+
+};
+
+nsresult NS_NewHTMLCSSUtils(nsHTMLCSSUtils** aInstancePtrResult);
+
+#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
+#define NS_EDITOR_INDENT_INCREMENT_CM 1.05f
+#define NS_EDITOR_INDENT_INCREMENT_MM 10.5f
+#define NS_EDITOR_INDENT_INCREMENT_PT 29.76f
+#define NS_EDITOR_INDENT_INCREMENT_PC 2.48f
+#define NS_EDITOR_INDENT_INCREMENT_EM 3
+#define NS_EDITOR_INDENT_INCREMENT_EX 6
+#define NS_EDITOR_INDENT_INCREMENT_PX 40
+#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
+
+#endif /* nsHTMLCSSUtils_h__ */
diff --git a/tools/relic/test/relicense_outputs/no_initialcopyrightyear_section.xml b/tools/relic/test/relicense_outputs/no_initialcopyrightyear_section.xml
new file mode 100755
index 000000000000..c3e436d73b7d
--- /dev/null
+++ b/tools/relic/test/relicense_outputs/no_initialcopyrightyear_section.xml
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+thead_align_center.xml
+
+
+
+
+
+
+
+
+
+
In this test, the THEAD text should be center aligned
+
+
+
+
+
+
+
+
+
+
THEAD
+
+
+
+
+
+
+
+
+
+
+
+
This text is in the TFOOT
+
+
+
+
+
+
+
+
+
+
+
+
This text is in the TBODY
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/relic/test/relicense_outputs/no_origcodeis_section.h b/tools/relic/test/relicense_outputs/no_origcodeis_section.h
new file mode 100755
index 000000000000..b618e65cf135
--- /dev/null
+++ b/tools/relic/test/relicense_outputs/no_origcodeis_section.h
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 2; 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
+ * Owen Taylor and Christopher Blizzard .
+ * Portions created by the Initial Developer are Copyright (C) 1999
+ * 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 ***** */
+
+#ifndef __GTK_MOZAREA_H__
+#define __GTK_MOZAREA_H__
+
+#include
+#include "gdksuperwin.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct _GtkMozArea GtkMozArea;
+typedef struct _GtkMozAreaClass GtkMozAreaClass;
+
+#define GTK_TYPE_MOZAREA (gtk_mozarea_get_type ())
+#define GTK_MOZAREA(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MOZAREA, GtkMozArea))
+#define GTK_MOZAREA_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MOZAREA, GtkMozAreaClass))
+#define GTK_IS_MOZAREA(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MOZAREA))
+#define GTK_IS_MOZAREA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MOZAREA))
+
+struct _GtkMozArea
+{
+ GtkWidget widget;
+ GdkSuperWin *superwin;
+ gboolean toplevel_focus;
+
+ /* store away the toplevel window */
+ GdkWindow *toplevel_window;
+};
+
+struct _GtkMozAreaClass
+{
+ GtkWindowClass window_class;
+
+ /* signals */
+ void (* toplevel_focus_in ) (GtkMozArea *area);
+ void (* toplevel_focus_out) (GtkMozArea *area);
+ void (* toplevel_configure) (GtkMozArea *area);
+};
+
+GtkType gtk_mozarea_get_type (void);
+GtkWidget *gtk_mozarea_new ();
+gboolean gtk_mozarea_get_toplevel_focus(GtkMozArea *area);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __GTK_MOZAREA_H__ */
diff --git a/tools/relic/test/relicense_outputs/npl.h b/tools/relic/test/relicense_outputs/npl.h
new file mode 100755
index 000000000000..cdec11e2d53a
--- /dev/null
+++ b/tools/relic/test/relicense_outputs/npl.h
@@ -0,0 +1,412 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** 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.
+ *
+ * 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) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Daniel Glazman , foo@bar.org
+ *
+ * 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 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 ***** */
+
+#ifndef nsHTMLCSSUtils_h__
+#define nsHTMLCSSUtils_h__
+
+#include "nsCOMPtr.h"
+#include "nsString.h"
+#include "nsIDOMViewCSS.h"
+#include "nsIDOMNode.h"
+#include "nsIDOMElement.h"
+#include "nsIHTMLEditor.h"
+#include "ChangeCSSInlineStyleTxn.h"
+#include "nsEditProperty.h"
+#include "nsIDOMCSSStyleDeclaration.h"
+
+#define SPECIFIED_STYLE_TYPE 1
+#define COMPUTED_STYLE_TYPE 2
+
+class nsHTMLEditor;
+
+typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString,
+ const char * aDefaultValueString,
+ const char * aPrependString, const char* aAppendString);
+
+class nsHTMLCSSUtils
+{
+public:
+ nsHTMLCSSUtils();
+ ~nsHTMLCSSUtils();
+
+ enum nsCSSEditableProperty {
+ eCSSEditableProperty_NONE=0,
+ eCSSEditableProperty_background_color,
+ eCSSEditableProperty_background_image,
+ eCSSEditableProperty_border,
+ eCSSEditableProperty_caption_side,
+ eCSSEditableProperty_color,
+ eCSSEditableProperty_float,
+ eCSSEditableProperty_font_family,
+ eCSSEditableProperty_font_size,
+ eCSSEditableProperty_font_style,
+ eCSSEditableProperty_font_weight,
+ eCSSEditableProperty_height,
+ eCSSEditableProperty_list_style_type,
+ eCSSEditableProperty_margin_left,
+ eCSSEditableProperty_margin_right,
+ eCSSEditableProperty_text_align,
+ eCSSEditableProperty_text_decoration,
+ eCSSEditableProperty_vertical_align,
+ eCSSEditableProperty_whitespace,
+ eCSSEditableProperty_width
+ };
+
+
+ struct CSSEquivTable {
+ nsCSSEditableProperty cssProperty;
+ nsProcessValueFunc processValueFunctor;
+ const char * defaultValue;
+ const char * prependValue;
+ const char * appendValue;
+ PRBool gettable;
+ PRBool caseSensitiveValue;
+ };
+
+public:
+ nsresult Init(nsHTMLEditor * aEditor);
+
+ /** answers true if the given combination element_name/attribute_name
+ * has a CSS equivalence in this implementation
+ *
+ * @return a boolean saying if the tag/attribute has a css equiv
+ * @param aNode [IN] a DOM node
+ * @param aProperty [IN] an atom containing a HTML tag name
+ * @param aAttribute [IN] a string containing the name of a HTML attribute carried by the element above
+ */
+ PRBool IsCSSEditableProperty(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString * aAttribute);
+
+ /** adds/remove a CSS declaration to the STYLE atrribute carried by a given element
+ *
+ * @param aElement [IN] a DOM element
+ * @param aProperty [IN] an atom containing the CSS property to set
+ * @param aValue [IN] a string containing the value of the CSS property
+ * @param aSuppressTransaction [IN] a boolean indicating, when true,
+ * that no transaction should be recorded
+ */
+ nsresult SetCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
+ const nsAString & aValue,
+ PRBool aSuppressTransaction);
+ nsresult RemoveCSSProperty(nsIDOMElement * aElement, nsIAtom * aProperty,
+ const nsAString & aPropertyValue, PRBool aSuppressTransaction);
+
+ /** directly adds/remove a CSS declaration to the STYLE atrribute carried by
+ * a given element without going through the txn manager
+ *
+ * @param aElement [IN] a DOM element
+ * @param aProperty [IN] a string containing the CSS property to set/remove
+ * @param aValue [IN] a string containing the new value of the CSS property
+ */
+ nsresult SetCSSProperty(nsIDOMElement * aElement,
+ const nsAString & aProperty,
+ const nsAString & aValue);
+ nsresult RemoveCSSProperty(nsIDOMElement * aElement,
+ const nsAString & aProperty);
+
+ /** gets the specified/computed style value of a CSS property for a given node (or its element
+ * ancestor if it is not an element)
+ *
+ * @param aNode [IN] a DOM node
+ * @param aProperty [IN] an atom containing the CSS property to get
+ * @param aPropertyValue [OUT] the retrieved value of the property
+ */
+ nsresult GetSpecifiedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
+ nsAString & aValue);
+ nsresult GetComputedProperty(nsIDOMNode *aNode, nsIAtom *aProperty,
+ nsAString & aValue);
+
+ /** Removes a CSS property from the specified declarations in STYLE attribute
+ ** and removes the node if it is an useless span
+ *
+ * @param aNode [IN] the specific node we want to remove a style from
+ * @param aProperty [IN] the CSS property atom to remove
+ * @param aPropertyValue [IN] the value of the property we have to rremove if the property
+ * accepts more than one value
+ */
+ nsresult RemoveCSSInlineStyle(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString & aPropertyValue);
+
+ /** Answers true is the property can be removed by setting a "none" CSS value
+ * on a node
+ *
+ * @return a boolean saying if the property can be remove by setting a "none" value
+ * @param aProperty [IN] an atom containing a CSS property
+ * @param aAttribute [IN] pointer to an attribute name or null if this information is irrelevant
+ */
+ PRBool IsCSSInvertable(nsIAtom * aProperty, const nsAString * aAttribute);
+
+ /** Get the default browser background color if we need it for GetCSSBackgroundColorState
+ *
+ * @param aColor [OUT] the default color as it is defined in prefs
+ */
+ nsresult GetDefaultBackgroundColor(nsAString & aColor);
+
+ /** Get the default length unit used for CSS Indent/Outdent
+ *
+ * @param aLengthUnit [OUT] the default length unit as it is defined in prefs
+ */
+ nsresult GetDefaultLengthUnit(nsAString & aLengthUnit);
+
+ /** asnwers true if the element aElement carries an ID or a class
+ *
+ * @param aElement [IN] a DOM element
+ * @param aReturn [OUT] the boolean answer
+ */
+ nsresult HasClassOrID(nsIDOMElement * aElement, PRBool & aReturn);
+
+ /** returns the list of values for the CSS equivalences to
+ * the passed HTML style for the passed node
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValueString [OUT] the list of css values
+ * @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
+ COMPUTED_STYLE_TYPE to query the computed style values
+ */
+ nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString * aAttribute,
+ nsAString & aValueString,
+ PRUint8 aStyleType);
+
+ /** Does the node aNode (or his parent if it is not an element node) carries
+ * the CSS equivalent styles to the HTML style for this node ?
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aIsSet [OUT] a boolean being true if the css properties are set
+ * @param aValueString [IN/OUT] the attribute value (in) the list of css values (out)
+ * @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
+ COMPUTED_STYLE_TYPE to query the computed style values
+ */
+ nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString * aAttribute,
+ PRBool & aIsSet,
+ nsAString & aValueString,
+ PRUint8 aStyleType);
+
+ /** Adds to the node the CSS inline styles equivalent to the HTML style
+ * and return the number of CSS properties set by the call
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValue [IN] the attribute value
+ * @param aCount [OUT] the number of CSS properties set by the call
+ * @param aSuppressTransaction [IN] a boolean indicating, when true,
+ * that no transaction should be recorded
+ */
+ nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString * aAttribute,
+ const nsAString * aValue,
+ PRInt32 * aCount,
+ PRBool aSuppressTransaction);
+
+ /** removes from the node the CSS inline styles equivalent to the HTML style
+ *
+ * @param aNode [IN] a DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValue [IN] the attribute value
+ * @param aSuppressTransaction [IN] a boolean indicating, when true,
+ * that no transaction should be recorded
+ */
+ nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode,
+ nsIAtom *aHTMLProperty,
+ const nsAString *aAttribute,
+ const nsAString *aValue,
+ PRBool aSuppressTransaction);
+
+ /** parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char
+ * we need such a parser because nsIDOMCSSStyleDeclaration::GetPropertyCSSValue() is not
+ * implemented
+ *
+ * @param aString [IN] input string to parse
+ * @param aValue [OUT] numeric part
+ * @param aUnit [OUT] unit part
+ */
+ void ParseLength(const nsAString & aString, float * aValue, nsIAtom ** aUnit);
+
+ /** sets the mIsCSSPrefChecked private member ; used as callback from observer when
+ * the css pref state is changed
+ *
+ * @param aIsCSSPrefChecked [IN] the new boolean state for the pref
+ */
+ nsresult SetCSSEnabled(PRBool aIsCSSPrefChecked);
+
+ /** retrieves the mIsCSSPrefChecked private member, true if the css pref is checked,
+ * false if it is not
+ *
+ * @return the boolean value of the css pref
+ */
+ PRBool IsCSSPrefChecked();
+
+ /** ElementsSameStyle compares two elements and checks if they have the same
+ * specified CSS declarations in the STYLE attribute
+ * The answer is always false if at least one of them carries an ID or a class
+ *
+ * @return true if the two elements are considered to have same styles
+ * @param aFirstNode [IN] a DOM node
+ * @param aSecondNode [IN] a DOM node
+ */
+ PRBool ElementsSameStyle(nsIDOMNode *aFirstNode, nsIDOMNode *aSecondNode);
+
+ /** get the specified inline styles (style attribute) for an element
+ *
+ * @param aElement [IN] the element node
+ * @param aCssDecl [OUT] the CSS declaration corresponding to the style attr
+ * @param aLength [OUT] the number of declarations in aCssDecl
+ */
+ nsresult GetInlineStyles(nsIDOMElement * aElement, nsIDOMCSSStyleDeclaration ** aCssDecl,
+ PRUint32 * aLength);
+
+ /** returns aNode itself if it is an element node, or the first ancestors being an element
+ * node if aNode is not one itself
+ *
+ * @param aNode [IN] a node
+ * @param aElement [OUT] the deepest element node containing aNode (possibly aNode itself)
+ */
+ nsresult GetElementContainerOrSelf(nsIDOMNode * aNode, nsIDOMElement ** aElement);
+
+ /** Gets the default DOMView for a given node
+ *
+ * @param aNode the node we want the default DOMView for
+ * @param aViewCSS [OUT] the default DOMViewCSS
+ */
+ nsresult GetDefaultViewCSS(nsIDOMNode * aNode, nsIDOMViewCSS ** aViewCSS);
+
+
+private:
+
+ /** retrieves the css property atom from an enum
+ *
+ * @param aProperty [IN] the enum value for the property
+ * @param aAtom [OUT] the corresponding atom
+ */
+ void GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom);
+
+ /** retrieves the CSS declarations equivalent to a HTML style value for
+ * a given equivalence table
+ *
+ * @param aPropertyArray [OUT] the array of css properties
+ * @param aValueArray [OUT] the array of values for the css properties above
+ * @param aEquivTable [IN] the equivalence table
+ * @param aValue [IN] the HTML style value
+ * @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
+ * is made for GetCSSEquivalentToHTMLInlineStyleSet or
+ * RemoveCSSEquivalentToHTMLInlineStyleSet
+ */
+
+ void BuildCSSDeclarations(nsVoidArray & aPropertyArray,
+ nsStringArray & cssValueArray,
+ const CSSEquivTable * aEquivTable,
+ const nsAString * aValue,
+ PRBool aGetOrRemoveRequest);
+
+ /** retrieves the CSS declarations equivalent to the given HTML property/attribute/value
+ * for a given node
+ *
+ * @param aNode [IN] the DOM node
+ * @param aHTMLProperty [IN] an atom containing an HTML property
+ * @param aAttribute [IN] a pointer to an attribute name or nsnull if irrelevant
+ * @param aValue [IN] the attribute value
+ * @param aPropertyArray [OUT] the array of css properties
+ * @param aValueArray [OUT] the array of values for the css properties above
+ * @param aGetOrRemoveRequest [IN] a boolean value being true if the call to the current method
+ * is made for GetCSSEquivalentToHTMLInlineStyleSet or
+ * RemoveCSSEquivalentToHTMLInlineStyleSet
+ */
+ void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode,
+ nsIAtom * aHTMLProperty,
+ const nsAString *aAttribute,
+ const nsAString *aValue,
+ nsVoidArray & aPropertyArray,
+ nsStringArray & aValueArray,
+ PRBool aGetOrRemoveRequest);
+
+ /** creates a Transaction for setting or removing a css property
+ *
+ * @param aElement [IN] a DOM element
+ * @param aProperty [IN] a CSS property
+ * @param aValue [IN] the value to remove for this CSS property or the empty string if irrelevant
+ * @param aTxn [OUT] the created transaction
+ * @param aRemoveProperty [IN] true if we create a "remove" transaction, false for a "set"
+ */
+ nsresult CreateCSSPropertyTxn(nsIDOMElement * aElement,
+ nsIAtom * aProperty,
+ const nsAString & aValue,
+ ChangeCSSInlineStyleTxn ** aTxn,
+ PRBool aRemoveProperty);
+
+ /** back-end for GetSpecifiedProperty and GetComputedProperty
+ *
+ * @param aNode [IN] a DOM node
+ * @param aProperty [IN] a CSS property
+ * @param aValue [OUT] the retrieved value for this property
+ * @param aViewCSS [IN] the ViewCSS we need in case we query computed styles
+ * @param aStyleType [IN] SPECIFIED_STYLE_TYPE to query the specified style values
+ COMPUTED_STYLE_TYPE to query the computed style values
+ */
+ nsresult GetCSSInlinePropertyBase(nsIDOMNode * aNode, nsIAtom * aProperty,
+ nsAString & aValue,
+ nsIDOMViewCSS * aViewCSS,
+ PRUint8 aStyleType);
+
+
+private:
+ nsHTMLEditor *mHTMLEditor;
+ PRBool mIsCSSPrefChecked;
+
+};
+
+nsresult NS_NewHTMLCSSUtils(nsHTMLCSSUtils** aInstancePtrResult);
+
+#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
+#define NS_EDITOR_INDENT_INCREMENT_CM 1.05f
+#define NS_EDITOR_INDENT_INCREMENT_MM 10.5f
+#define NS_EDITOR_INDENT_INCREMENT_PT 29.76f
+#define NS_EDITOR_INDENT_INCREMENT_PC 2.48f
+#define NS_EDITOR_INDENT_INCREMENT_EM 3
+#define NS_EDITOR_INDENT_INCREMENT_EX 6
+#define NS_EDITOR_INDENT_INCREMENT_PX 40
+#define NS_EDITOR_INDENT_INCREMENT_PERCENT 4
+
+#endif /* nsHTMLCSSUtils_h__ */
diff --git a/tools/relic/test/relicense_outputs/separated_license_comment_blocks.pl b/tools/relic/test/relicense_outputs/separated_license_comment_blocks.pl
new file mode 100755
index 000000000000..6eb4684a7374
--- /dev/null
+++ b/tools/relic/test/relicense_outputs/separated_license_comment_blocks.pl
@@ -0,0 +1,67 @@
+#!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) 2002
+# 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 *****
+
+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/relicense_outputs/trailing_orig_code_modified.pl b/tools/relic/test/relicense_outputs/trailing_orig_code_modified.pl
new file mode 100755
index 000000000000..e3d3d49eba00
--- /dev/null
+++ b/tools/relic/test/relicense_outputs/trailing_orig_code_modified.pl
@@ -0,0 +1,52 @@
+# ***** 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.
+#
+# 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 the Initial Developer are Copyright (C) 1998
+# 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 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 *****
+#
+# 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.
+
+use strict;
+
+# snip ...
+
diff --git a/tools/relic/test/relicense_outputs/unknown_license.c.error b/tools/relic/test/relicense_outputs/unknown_license.c.error
new file mode 100755
index 000000000000..2ee8e9607570
--- /dev/null
+++ b/tools/relic/test/relicense_outputs/unknown_license.c.error
@@ -0,0 +1 @@
+relicense_tmp/unknown_license.c: unknown license (possibly) found
diff --git a/tools/relic/test/test.py b/tools/relic/test/test.py
new file mode 100755
index 000000000000..1bf41cb7530b
--- /dev/null
+++ b/tools/relic/test/test.py
@@ -0,0 +1,169 @@
+#!python
+
+# Copyright (c) 2004 Trent Mick
+
+"""
+ relic.py Regression Test Suite Harness
+
+ Usage:
+ python test.py [...] [...]
+
+ Options:
+ -x , --exclude=
+ Exclude the named test from the set of tests to be
+ run. This can be used multiple times to specify
+ multiple exclusions.
+ -v, --verbose run tests in verbose mode with output to stdout
+ -q, --quiet don't print anything except if a test fails
+ -h, --help print this text and exit
+
+ This will find all modules whose name is "test_*" in the test
+ directory, and run them. Various command line options provide
+ additional facilities.
+
+ If non-option arguments are present, they are names for tests to run.
+ If no test names are given, all tests are run.
+
+ Test Setup Options:
+ -c, --clean Don't setup, just clean up the test workspace.
+ -n, --no-clean Don't clean up after setting up and running the
+ test suite.
+"""
+
+import os
+import sys
+import getopt
+import glob
+import time
+import types
+import tempfile
+import unittest
+
+
+
+#---- exceptions
+
+class TestError(Exception):
+ pass
+
+
+#---- globals
+
+gVerbosity = 2
+
+
+#---- utility routines
+
+def _rmtreeOnError(rmFunction, filePath, excInfo):
+ if excInfo[0] == OSError:
+ # presuming because file is read-only
+ os.chmod(filePath, 0777)
+ rmFunction(filePath)
+
+def _rmtree(dirname):
+ import shutil
+ shutil.rmtree(dirname, 0, _rmtreeOnError)
+
+
+def _getAllTests(testDir):
+ """Return a list of all tests to run."""
+ testPyFiles = glob.glob(os.path.join(testDir, "test_*.py"))
+ modules = [f[:-3] for f in testPyFiles if f and f.endswith(".py")]
+
+ packages = []
+ for f in glob.glob(os.path.join(testDir, "test_*")):
+ if os.path.isdir(f) and "." not in f:
+ if os.path.isfile(os.path.join(testDir, f, "__init__.py")):
+ packages.append(f)
+
+ return modules + packages
+
+
+def _setUp():
+ # Ensure the *development* check is tested.
+ topDir = os.path.abspath(os.pardir)
+ sys.path.insert(0, topDir)
+ print "Setup to test:"
+ import relic
+ ver = "%s.%s.%s" % relic._version_
+ print "relic %s at '%s'" % (ver, relic.__file__)
+ print "-"*70 + '\n'
+
+
+def _tearDown():
+ pass
+
+
+def test(testModules, testDir=os.curdir, exclude=[]):
+ """Run the given regression tests and report the results."""
+ # Determine the test modules to run.
+ if not testModules:
+ testModules = _getAllTests(testDir)
+ testModules = [t for t in testModules if t not in exclude]
+
+ # Aggregate the TestSuite's from each module into one big one.
+ allSuites = []
+ for moduleFile in testModules:
+ module = __import__(moduleFile, globals(), locals(), [])
+ suite = getattr(module, "suite", None)
+ if suite is not None:
+ allSuites.append(suite())
+ else:
+ if gVerbosity >= 2:
+ print "WARNING: module '%s' did not have a suite() method."\
+ % moduleFile
+ suite = unittest.TestSuite(allSuites)
+
+ # Run the suite.
+ runner = unittest.TextTestRunner(sys.stdout, verbosity=gVerbosity)
+ result = runner.run(suite)
+
+
+#---- mainline
+
+def main(argv):
+ testDir = os.path.dirname(sys.argv[0])
+
+ # parse options
+ global gVerbosity
+ try:
+ opts, testModules = getopt.getopt(sys.argv[1:], 'hvqx:cn',
+ ['help', 'verbose', 'quiet', 'exclude=', 'clean',
+ 'no-clean'])
+ except getopt.error, ex:
+ print "%s: ERROR: %s" % (argv[0], ex)
+ print __doc__
+ sys.exit(2)
+ exclude = []
+ setupOpts = {}
+ justClean = 0
+ clean = 1
+ for opt, optarg in opts:
+ if opt in ("-h", "--help"):
+ print __doc__
+ sys.exit(0)
+ elif opt in ("-v", "--verbose"):
+ gVerbosity += 1
+ elif opt in ("-q", "--quiet"):
+ gVerbosity -= 1
+ elif opt in ("-x", "--exclude"):
+ exclude.append(optarg)
+ elif opt in ("-c", "--clean"):
+ justClean = 1
+ elif opt in ("-n", "--no-clean"):
+ clean = 0
+
+ retval = None
+ if not justClean:
+ _setUp(**setupOpts)
+ try:
+ if not justClean:
+ retval = test(testModules, testDir=testDir, exclude=exclude)
+ finally:
+ if clean:
+ _tearDown(**setupOpts)
+ return retval
+
+if __name__ == '__main__':
+ sys.exit( main(sys.argv) )
+
diff --git a/tools/relic/test/test_addlicense_inputs.py b/tools/relic/test/test_addlicense_inputs.py
new file mode 100755
index 000000000000..905eec998401
--- /dev/null
+++ b/tools/relic/test/test_addlicense_inputs.py
@@ -0,0 +1,147 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2004 Trent Mick
+
+"""Test adding licenses to addlicense_inputs/... with relic.py."""
+
+import sys
+import os
+import unittest
+import difflib
+import pprint
+import shutil
+import StringIO
+
+import testsupport
+
+#---- globals
+
+gInputsDir = "addlicense_inputs"
+gOutputsDir = "addlicense_outputs"
+gTmpDir = "addlicense_tmp"
+
+
+#----- test cases
+
+class RelicInputsTestCase(unittest.TestCase):
+ def setUp(self):
+ if not os.path.exists(gTmpDir):
+ os.mkdir(gTmpDir)
+
+ def tearDown(self):
+ testsupport.rmtree(gTmpDir)
+
+
+def _testOneInputFile(self, fname):
+ import relic
+ _debug = 0 # Set to true to dump status info for each test run.
+
+ infile = os.path.join(gInputsDir, fname) # input
+ outfile = os.path.join(gOutputsDir, fname) # expected output
+ tmpfile = os.path.join(gTmpDir, fname) # actual output
+ errfile = os.path.join(gOutputsDir, fname+'.error') # expected error
+ # An options file is a set of kwargs for the relic.addlicense()
+ # method call. One key-value pair per-line like this:
+ # key=value
+ # Whitespace is stripped off the value.
+ optsfile = os.path.join(gInputsDir, fname+'.options') # input options
+
+ if _debug:
+ print
+ print "*"*50, "relic '%s'" % fname
+
+ # Determine input options to use, if any.
+ opts = {}
+ if os.path.exists(optsfile):
+ for line in open(optsfile, 'r').read().splitlines(0):
+ name, value = line.split('=', 1)
+ value = value.strip()
+ try: # allow value to be a type other than string
+ value = eval(value)
+ except Exception:
+ pass
+ opts[name] = value
+ if _debug:
+ print "*"*50, "options"
+ pprint.pprint(opts)
+ else:
+ # If no options were specified, we presume the equivalent of the
+ # command-line --defaults option.
+ opts = {
+ "original_code_is": "mozilla.org Code",
+ "initial_copyright_date": "2001",
+ "initial_developer": "Netscape Communications Corporation",
+ }
+
+ # Copy the input file to the tmp location where relicensing is done.
+ shutil.copy(infile, tmpfile)
+
+ # Relicense the file, capturing stdout and stderr and any possible
+ # error.
+ oldStdout = sys.stdout
+ oldStderr = sys.stderr
+ sys.stdout = StringIO.StringIO()
+ sys.stderr = StringIO.StringIO()
+ try:
+ try:
+ relic.addlicense([tmpfile], **opts)
+ except relic.RelicError, ex:
+ error = ex
+ else:
+ error = None
+ finally:
+ stdout = sys.stdout.getvalue()
+ stderr = sys.stderr.getvalue()
+ sys.stdout = oldStdout
+ sys.stderr = oldStderr
+ if _debug:
+ print "*"*50, "stdout"
+ print stdout
+ print "*"*50, "stderr"
+ print stderr
+ print "*"*50, "error"
+ print str(error)
+ print "*" * 50
+
+ # Verify that the results are as expected.
+ if os.path.exists(outfile) and error:
+ self.fail("adding license '%s' raised an error but success was "
+ "expected: error='%s'" % (fname, str(error)))
+ elif os.path.exists(outfile):
+ expected = open(outfile, 'r').readlines()
+ actual = open(tmpfile, 'r').readlines()
+ if expected != actual:
+ diff = list(difflib.ndiff(expected, actual))
+ self.fail("%r != %r:\n%s"\
+ % (outfile, tmpfile, pprint.pformat(diff)))
+ elif os.path.exists(errfile):
+ # There is no reference output file. This means that processing
+ # this file is expected to fail.
+ expectedError = open(errfile, 'r').read()
+ actualError = str(error)
+ self.failUnlessEqual(actualError.strip(), expectedError.strip())
+ else:
+ self.fail("No reference ouput file or error file for '%s'." % infile)
+
+ # Ensure next test file gets a clean relic.
+ del sys.modules['relic']
+
+
+#for fname in ["separated_license_comment_blocks.pl"]:
+for fname in os.listdir(gInputsDir):
+ if fname.endswith(".options"): continue # skip input option files
+ testFunction = lambda self, fname=fname: _testOneInputFile(self, fname)
+ name = 'test_addlicense_'+fname
+ setattr(RelicInputsTestCase, name, testFunction)
+
+
+#---- mainline
+
+def suite():
+ """Return a unittest.TestSuite to be used by test.py."""
+ return unittest.makeSuite(RelicInputsTestCase)
+
+if __name__ == "__main__":
+ runner = unittest.TextTestRunner(sys.stdout, verbosity=2)
+ result = runner.run(suite())
+
diff --git a/tools/relic/test/test_relicense_inputs.py b/tools/relic/test/test_relicense_inputs.py
new file mode 100755
index 000000000000..2158fc9552f1
--- /dev/null
+++ b/tools/relic/test/test_relicense_inputs.py
@@ -0,0 +1,139 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2004 Trent Mick
+
+"""Test relicensing of inputs/... with relic.py."""
+
+import sys
+import os
+import unittest
+import difflib
+import pprint
+import shutil
+import StringIO
+
+import testsupport
+
+#---- globals
+
+gInputsDir = "relicense_inputs"
+gOutputsDir = "relicense_outputs"
+gTmpDir = "relicense_tmp"
+
+
+#----- test cases
+
+class RelicInputsTestCase(unittest.TestCase):
+ def setUp(self):
+ if not os.path.exists(gTmpDir):
+ os.mkdir(gTmpDir)
+
+ def tearDown(self):
+ testsupport.rmtree(gTmpDir)
+
+
+def _testOneInputFile(self, fname):
+ import relic
+ _debug = 0 # Set to true to dump status info for each test run.
+
+ infile = os.path.join(gInputsDir, fname) # input
+ outfile = os.path.join(gOutputsDir, fname) # expected output
+ tmpfile = os.path.join(gTmpDir, fname) # actual output
+ errfile = os.path.join(gOutputsDir, fname+'.error') # expected error
+ # An options file is a set of kwargs for the relic.relicense()
+ # method call. One key-value pair per-line like this:
+ # key=value
+ # Whitespace is stripped off the value.
+ optsfile = os.path.join(gInputsDir, fname+'.options') # input options
+
+ if _debug:
+ print
+ print "*"*50, "relic '%s'" % fname
+
+ # Determine input options to use, if any.
+ opts = {}
+ if os.path.exists(optsfile):
+ for line in open(optsfile, 'r').read().splitlines(0):
+ name, value = line.split('=', 1)
+ value = value.strip()
+ try: # allow value to be a type other than string
+ value = eval(value)
+ except Exception:
+ pass
+ opts[name] = value
+ if _debug:
+ print "*"*50, "options"
+ pprint.pprint(opts)
+
+ # Copy the input file to the tmp location where relicensing is done.
+ shutil.copy(infile, tmpfile)
+
+ # Relicense the file, capturing stdout and stderr and any possible
+ # error.
+ oldStdout = sys.stdout
+ oldStderr = sys.stderr
+ sys.stdout = StringIO.StringIO()
+ sys.stderr = StringIO.StringIO()
+ try:
+ try:
+ relic.relicense([tmpfile], **opts)
+ except relic.RelicError, ex:
+ error = ex
+ else:
+ error = None
+ finally:
+ stdout = sys.stdout.getvalue()
+ stderr = sys.stderr.getvalue()
+ sys.stdout = oldStdout
+ sys.stderr = oldStderr
+ if _debug:
+ print "*"*50, "stdout"
+ print stdout
+ print "*"*50, "stderr"
+ print stderr
+ print "*"*50, "error"
+ print str(error)
+ print "*" * 50
+
+ # Verify that the results are as expected.
+ if os.path.exists(outfile) and error:
+ self.fail("relicensing '%s' raised an error but success was "
+ "expected: error='%s'" % (fname, str(error)))
+ elif os.path.exists(outfile):
+ expected = open(outfile, 'r').readlines()
+ actual = open(tmpfile, 'r').readlines()
+ if expected != actual:
+ diff = list(difflib.ndiff(expected, actual))
+ self.fail("%r != %r:\n%s"\
+ % (outfile, tmpfile, pprint.pformat(diff)))
+ elif os.path.exists(errfile):
+ # There is no reference output file. This means that processing
+ # this file is expected to fail.
+ expectedError = open(errfile, 'r').read()
+ actualError = str(error)
+ self.failUnlessEqual(actualError.strip(), expectedError.strip())
+ else:
+ self.fail("No reference ouput file or error file for '%s'." % infile)
+
+ # Ensure next test file gets a clean relic.
+ del sys.modules['relic']
+
+
+#for fname in ["separated_license_comment_blocks.pl"]:
+for fname in os.listdir(gInputsDir):
+ if fname.endswith(".options"): continue # skip input option files
+ testFunction = lambda self, fname=fname: _testOneInputFile(self, fname)
+ name = 'test_relicense_'+fname
+ setattr(RelicInputsTestCase, name, testFunction)
+
+
+#---- mainline
+
+def suite():
+ """Return a unittest.TestSuite to be used by test.py."""
+ return unittest.makeSuite(RelicInputsTestCase)
+
+if __name__ == "__main__":
+ runner = unittest.TextTestRunner(sys.stdout, verbosity=2)
+ result = runner.run(suite())
+
diff --git a/tools/relic/test/testsupport.py b/tools/relic/test/testsupport.py
new file mode 100755
index 000000000000..e2e5107e31a3
--- /dev/null
+++ b/tools/relic/test/testsupport.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import types
+import shutil
+
+
+#---- Support routines
+
+def _escapeArg(arg):
+ """Escape the given command line argument for the shell."""
+ #XXX There is a *lot* more that we should escape here.
+ return arg.replace('"', r'\"')
+
+
+def _joinArgv(argv):
+ r"""Join an arglist to a string appropriate for running.
+ >>> import os
+ >>> _joinArgv(['foo', 'bar "baz'])
+ 'foo "bar \\"baz"'
+ """
+ cmdstr = ""
+ for arg in argv:
+ if ' ' in arg:
+ cmdstr += '"%s"' % _escapeArg(arg)
+ else:
+ cmdstr += _escapeArg(arg)
+ cmdstr += ' '
+ if cmdstr.endswith(' '): cmdstr = cmdstr[:-1] # strip trailing space
+ return cmdstr
+
+
+def run(argv):
+ """Prepare and run the given arg vector, 'argv', and return the
+ results. Returns (, , ).
+ Note: 'argv' may also just be the command string.
+ """
+ if type(argv) in (types.ListType, types.TupleType):
+ cmd = _joinArgv(argv)
+ else:
+ cmd = argv
+ if sys.platform.startswith('win'):
+ i, o, e = os.popen3(cmd)
+ output = o.read()
+ error = e.read()
+ i.close()
+ e.close()
+ try:
+ retval = o.close()
+ except IOError:
+ # IOError is raised iff the spawned app returns -1. Go
+ # figure.
+ retval = -1
+ if retval is None:
+ retval = 0
+ else:
+ import popen2
+ p = popen2.Popen3(cmd, 1)
+ i, o, e = p.tochild, p.fromchild, p.childerr
+ output = o.read()
+ error = e.read()
+ i.close()
+ o.close()
+ e.close()
+ retval = (p.wait() & 0xFF00) >> 8
+ if retval > 2**7: # 8-bit signed 1's-complement conversion
+ retval -= 2**8
+ return output, error, retval
+
+
+def _rmtreeOnError(rmFunction, filePath, excInfo):
+ if excInfo[0] == OSError:
+ # presuming because file is read-only
+ os.chmod(filePath, 0777)
+ rmFunction(filePath)
+
+def rmtree(dirname):
+ import shutil
+ shutil.rmtree(dirname, 0, _rmtreeOnError)
+
+