Dev zjl #2

Merged
sethub merged 3 commits from dev_zjl into dev 2026-07-26 17:12:26 +08:00
3790 changed files with 668255 additions and 0 deletions
+11
View File
@@ -1,2 +1,13 @@
# template
## GIT
### clone
git clone http://sethub.club/sethub/XML_Data_Parsing.git
git checkout -b dev_xxx origin/dev
### pull
git pull origin dev
## push
git push origin dev_xxx -u
+11
View File
@@ -0,0 +1,11 @@
# EditorConfig : http://EditorConfig.org
root = true
[*]
indent_style = space
indent_size = 4
tab_width = 8
[Makefile*]
indent_style = tab
+1
View File
@@ -0,0 +1 @@
ref: refs/heads/master
+13
View File
@@ -0,0 +1,13 @@
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = https://gitlab.gnome.org/GNOME/libxml2.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
+1
View File
@@ -0,0 +1 @@
Unnamed repository; edit this file 'description' to name the repository.
@@ -0,0 +1,15 @@
#!/bin/sh
#
# An example hook script to check the commit log message taken by
# applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
# To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
:
@@ -0,0 +1,74 @@
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines and messages that
# would confuse 'git am'.
ret=0
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
ret=1
}
comment_re="$(
{
git config --get-regexp "^core\.comment(char|string)\$" ||
echo '#'
} | sed -n -e '
${
s/^[^ ]* //
s|[][*./\]|\\&|g
s/^auto$/[#;@!$%^&|:]/
p
}'
)"
scissors_line="^${comment_re} -\{8,\} >8 -\{8,\}\$"
comment_line="^${comment_re}.*"
blank_line='^[ ]*$'
# Disallow lines starting with "diff -" or "Index: " in the body of the
# message. Stop looking if we see a scissors line.
line="$(sed -n -e "
# Skip comments and blank lines at the start of the file.
/${scissors_line}/q
/${comment_line}/d
/${blank_line}/d
# The first paragraph will become the subject header so
# does not need to be checked.
: subject
n
/${scissors_line}/q
/${blank_line}/!b subject
# Check the body of the message for problematic
# prefixes.
: body
n
/${scissors_line}/q
/${comment_line}/b body
/^diff -/{p;q;}
/^Index: /{p;q;}
b body
" "$1")"
if test -n "$line"
then
echo >&2 "Message contains a diff that will confuse 'git am'."
echo >&2 "To fix this indent the diff."
ret=1
fi
exit $ret
@@ -0,0 +1,168 @@
#!/usr/bin/perl
use strict;
use warnings;
use IPC::Open2;
# An example hook script to integrate Watchman
# (https://facebook.github.io/watchman/) with git to speed up detecting
# new and modified files.
#
# The hook is passed a version (currently 2) and last update token
# formatted as a string and outputs to stdout a new update token and
# all files that have been modified since the update token. Paths must
# be relative to the root of the working tree and separated by a single NUL.
#
# To enable this hook, rename this file to "query-watchman" and set
# 'git config core.fsmonitor .git/hooks/query-watchman'
#
my ($version, $last_update_token) = @ARGV;
# Uncomment for debugging
# print STDERR "$0 $version $last_update_token\n";
# Check the hook interface version
if ($version ne 2) {
die "Unsupported query-fsmonitor hook version '$version'.\n" .
"Falling back to scanning...\n";
}
my $git_work_tree = get_working_dir();
my $json_pkg;
eval {
require JSON::XS;
$json_pkg = "JSON::XS";
1;
} or do {
require JSON::PP;
$json_pkg = "JSON::PP";
};
launch_watchman();
sub launch_watchman {
my $o = watchman_query();
if (is_work_tree_watched($o)) {
output_result($o->{clock}, @{$o->{files}});
}
}
sub output_result {
my ($clockid, @files) = @_;
# Uncomment for debugging watchman output
# open (my $fh, ">", ".git/watchman-output.out");
# binmode $fh, ":utf8";
# print $fh "$clockid\n@files\n";
# close $fh;
binmode STDOUT, ":utf8";
print $clockid;
print "\0";
local $, = "\0";
print @files;
}
sub watchman_clock {
my $response = qx/watchman clock "$git_work_tree"/;
die "Failed to get clock id on '$git_work_tree'.\n" .
"Falling back to scanning...\n" if $? != 0;
return $json_pkg->new->utf8->decode($response);
}
sub watchman_query {
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
or die "open2() failed: $!\n" .
"Falling back to scanning...\n";
# In the query expression below we're asking for names of files that
# changed since $last_update_token but not from the .git folder.
#
# To accomplish this, we're using the "since" generator to use the
# recency index to select candidate nodes and "fields" to limit the
# output to file names only. Then we're using the "expression" term to
# further constrain the results.
my $last_update_line = "";
if (substr($last_update_token, 0, 1) eq "c") {
$last_update_token = "\"$last_update_token\"";
$last_update_line = qq[\n"since": $last_update_token,];
}
my $query = <<" END";
["query", "$git_work_tree", {$last_update_line
"fields": ["name"],
"expression": ["not", ["dirname", ".git"]]
}]
END
# Uncomment for debugging the watchman query
# open (my $fh, ">", ".git/watchman-query.json");
# print $fh $query;
# close $fh;
print CHLD_IN $query;
close CHLD_IN;
my $response = do {local $/; <CHLD_OUT>};
# Uncomment for debugging the watch response
# open ($fh, ">", ".git/watchman-response.json");
# print $fh $response;
# close $fh;
die "Watchman: command returned no output.\n" .
"Falling back to scanning...\n" if $response eq "";
die "Watchman: command returned invalid output: $response\n" .
"Falling back to scanning...\n" unless $response =~ /^\{/;
return $json_pkg->new->utf8->decode($response);
}
sub is_work_tree_watched {
my ($output) = @_;
my $error = $output->{error};
if ($error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
my $response = qx/watchman watch "$git_work_tree"/;
die "Failed to make watchman watch '$git_work_tree'.\n" .
"Falling back to scanning...\n" if $? != 0;
$output = $json_pkg->new->utf8->decode($response);
$error = $output->{error};
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
# Uncomment for debugging watchman output
# open (my $fh, ">", ".git/watchman-output.out");
# close $fh;
# Watchman will always return all files on the first query so
# return the fast "everything is dirty" flag to git and do the
# Watchman query just to get it over with now so we won't pay
# the cost in git to look up each individual file.
my $o = watchman_clock();
$error = $o->{error};
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
output_result($o->{clock}, ("/"));
return 0;
}
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
return 1;
}
sub get_working_dir {
my $working_dir;
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
$working_dir = Win32::GetCwd();
$working_dir =~ tr/\\/\//;
} else {
require Cwd;
$working_dir = Cwd::cwd();
}
return $working_dir;
}
@@ -0,0 +1,8 @@
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
exec git update-server-info
@@ -0,0 +1,14 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed
# by applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup
precommit="$(git rev-parse --git-path hooks/pre-commit)"
test -x "$precommit" && exec "$precommit" ${1+"$@"}
:
@@ -0,0 +1,49 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --type=bool hooks.allownonascii)
# Redirect output to stderr.
exec 1>&2
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff-index --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
@@ -0,0 +1,13 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git merge" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message to
# stderr if it wants to stop the merge commit.
#
# To enable this hook, rename this file to "pre-merge-commit".
. git-sh-setup
test -x "$GIT_DIR/hooks/pre-commit" &&
exec "$GIT_DIR/hooks/pre-commit"
:
+53
View File
@@ -0,0 +1,53 @@
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local oid> <remote ref> <remote oid>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
remote="$1"
url="$2"
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
while read local_ref local_oid remote_ref remote_oid
do
if test "$local_oid" = "$zero"
then
# Handle delete
:
else
if test "$remote_oid" = "$zero"
then
# New branch, examine all commits
range="$local_oid"
else
# Update to existing branch, examine new commits
range="$remote_oid..$local_oid"
fi
# Check for WIP commit
commit=$(git rev-list -n 1 --grep '^WIP' "$range")
if test -n "$commit"
then
echo >&2 "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0
+169
View File
@@ -0,0 +1,169 @@
#!/bin/sh
#
# Copyright (c) 2006, 2008 Junio C Hamano
#
# The "pre-rebase" hook is run just before "git rebase" starts doing
# its job, and can prevent the command from running by exiting with
# non-zero status.
#
# The hook is called with the following parameters:
#
# $1 -- the upstream the series was forked from.
# $2 -- the branch being rebased (or empty when rebasing the current branch).
#
# This sample shows how to prevent topic branches that are already
# merged to 'next' branch from getting rebased, because allowing it
# would result in rebasing already published history.
publish=next
basebranch="$1"
if test "$#" = 2
then
topic="refs/heads/$2"
else
topic=`git symbolic-ref HEAD` ||
exit 0 ;# we do not interrupt rebasing detached HEAD
fi
case "$topic" in
refs/heads/??/*)
;;
*)
exit 0 ;# we do not interrupt others.
;;
esac
# Now we are dealing with a topic branch being rebased
# on top of master. Is it OK to rebase it?
# Does the topic really exist?
git show-ref -q "$topic" || {
echo >&2 "No such branch $topic"
exit 1
}
# Is topic fully merged to master?
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
if test -z "$not_in_master"
then
echo >&2 "$topic is fully merged to master; better remove it."
exit 1 ;# we could allow it, but there is no point.
fi
# Is topic ever merged to next? If so you should not be rebasing it.
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
only_next_2=`git rev-list ^master ${publish} | sort`
if test "$only_next_1" = "$only_next_2"
then
not_in_topic=`git rev-list "^$topic" master`
if test -z "$not_in_topic"
then
echo >&2 "$topic is already up to date with master"
exit 1 ;# we could allow it, but there is no point.
else
exit 0
fi
else
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
/usr/bin/perl -e '
my $topic = $ARGV[0];
my $msg = "* $topic has commits already merged to public branch:\n";
my (%not_in_next) = map {
/^([0-9a-f]+) /;
($1 => 1);
} split(/\n/, $ARGV[1]);
for my $elem (map {
/^([0-9a-f]+) (.*)$/;
[$1 => $2];
} split(/\n/, $ARGV[2])) {
if (!exists $not_in_next{$elem->[0]}) {
if ($msg) {
print STDERR $msg;
undef $msg;
}
print STDERR " $elem->[1]\n";
}
}
' "$topic" "$not_in_next" "$not_in_master"
exit 1
fi
<<\DOC_END
This sample hook safeguards topic branches that have been
published from being rewound.
The workflow assumed here is:
* Once a topic branch forks from "master", "master" is never
merged into it again (either directly or indirectly).
* Once a topic branch is fully cooked and merged into "master",
it is deleted. If you need to build on top of it to correct
earlier mistakes, a new topic branch is created by forking at
the tip of the "master". This is not strictly necessary, but
it makes it easier to keep your history simple.
* Whenever you need to test or publish your changes to topic
branches, merge them into "next" branch.
The script, being an example, hardcodes the publish branch name
to be "next", but it is trivial to make it configurable via
$GIT_DIR/config mechanism.
With this workflow, you would want to know:
(1) ... if a topic branch has ever been merged to "next". Young
topic branches can have stupid mistakes you would rather
clean up before publishing, and things that have not been
merged into other branches can be easily rebased without
affecting other people. But once it is published, you would
not want to rewind it.
(2) ... if a topic branch has been fully merged to "master".
Then you can delete it. More importantly, you should not
build on top of it -- other people may already want to
change things related to the topic as patches against your
"master", so if you need further changes, it is better to
fork the topic (perhaps with the same name) afresh from the
tip of "master".
Let's look at this example:
o---o---o---o---o---o---o---o---o---o "next"
/ / / /
/ a---a---b A / /
/ / / /
/ / c---c---c---c B /
/ / / \ /
/ / / b---b C \ /
/ / / / \ /
---o---o---o---o---o---o---o---o---o---o---o "master"
A, B and C are topic branches.
* A has one fix since it was merged up to "next".
* B has finished. It has been fully merged up to "master" and "next",
and is ready to be deleted.
* C has not merged to "next" at all.
We would want to allow C to be rebased, refuse A, and encourage
B to be deleted.
To compute (1):
git rev-list ^master ^topic next
git rev-list ^master next
if these match, topic has not merged in next at all.
To compute (2):
git rev-list master..topic
if this is empty, it is fully merged to "master".
DOC_END
@@ -0,0 +1,24 @@
#!/bin/sh
#
# An example hook script to make use of push options.
# The example simply echoes all push options that start with 'echoback='
# and rejects all pushes when the "reject" push option is used.
#
# To enable this hook, rename this file to "pre-receive".
if test -n "$GIT_PUSH_OPTION_COUNT"
then
i=0
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
do
eval "value=\$GIT_PUSH_OPTION_$i"
case "$value" in
echoback=*)
echo "echo from the pre-receive-hook: ${value#*=}" >&2
;;
reject)
exit 1
esac
i=$((i + 1))
done
fi
@@ -0,0 +1,42 @@
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
# This hook includes three examples. The first one removes the
# "# Please enter the commit message..." help message.
#
# The second includes the output of "git diff --name-status -r"
# into the message, just before the "git status" output. It is
# commented because it doesn't cope with --amend or with squashed
# commits.
#
# The third example adds a Signed-off-by line to the message, that can
# still be edited. This is rarely a good idea.
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
# case "$COMMIT_SOURCE,$SHA1" in
# ,|template,)
# /usr/bin/perl -i.bak -pe '
# print "\n" . `git diff --cached --name-status -r`
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
# *) ;;
# esac
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
# if test -z "$COMMIT_SOURCE"
# then
# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
# fi
@@ -0,0 +1,78 @@
#!/bin/sh
# An example hook script to update a checked-out tree on a git push.
#
# This hook is invoked by git-receive-pack(1) when it reacts to git
# push and updates reference(s) in its repository, and when the push
# tries to update the branch that is currently checked out and the
# receive.denyCurrentBranch configuration variable is set to
# updateInstead.
#
# By default, such a push is refused if the working tree and the index
# of the remote repository has any difference from the currently
# checked out commit; when both the working tree and the index match
# the current commit, they are updated to match the newly pushed tip
# of the branch. This hook is to be used to override the default
# behaviour; however the code below reimplements the default behaviour
# as a starting point for convenient modification.
#
# The hook receives the commit with which the tip of the current
# branch is going to be updated:
commit=$1
# It can exit with a non-zero status to refuse the push (when it does
# so, it must not modify the index or the working tree).
die () {
echo >&2 "$*"
exit 1
}
# Or it can make any necessary changes to the working tree and to the
# index to bring them to the desired state when the tip of the current
# branch is updated to the new commit, and exit with a zero status.
#
# For example, the hook can simply run git read-tree -u -m HEAD "$1"
# in order to emulate git fetch that is run in the reverse direction
# with git push, as the two-tree form of git read-tree -u -m is
# essentially the same as git switch or git checkout that switches
# branches while keeping the local changes in the working tree that do
# not interfere with the difference between the branches.
# The below is a more-or-less exact translation to shell of the C code
# for the default behaviour for git's push-to-checkout hook defined in
# the push_to_deploy() function in builtin/receive-pack.c.
#
# Note that the hook will be executed from the repository directory,
# not from the working tree, so if you want to perform operations on
# the working tree, you will have to adapt your code accordingly, e.g.
# by adding "cd .." or using relative paths.
if ! git update-index -q --ignore-submodules --refresh
then
die "Up-to-date check failed"
fi
if ! git diff-files --quiet --ignore-submodules --
then
die "Working directory has unstaged changes"
fi
# This is a rough translation of:
#
# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX
if git cat-file -e HEAD 2>/dev/null
then
head=HEAD
else
head=$(git hash-object -t tree --stdin </dev/null)
fi
if ! git diff-index --quiet --cached --ignore-submodules $head --
then
die "Working directory has staged changes"
fi
if ! git read-tree -u -m "$commit"
then
die "Could not update working tree to new HEAD"
fi
@@ -0,0 +1,77 @@
#!/bin/sh
# An example hook script to validate a patch (and/or patch series) before
# sending it via email.
#
# The hook should exit with non-zero status after issuing an appropriate
# message if it wants to prevent the email(s) from being sent.
#
# To enable this hook, rename this file to "sendemail-validate".
#
# By default, it will only check that the patch(es) can be applied on top of
# the default upstream branch without conflicts in a secondary worktree. After
# validation (successful or not) of the last patch of a series, the worktree
# will be deleted.
#
# The following config variables can be set to change the default remote and
# remote ref that are used to apply the patches against:
#
# sendemail.validateRemote (default: origin)
# sendemail.validateRemoteRef (default: HEAD)
#
# Replace the TODO placeholders with appropriate checks according to your
# needs.
validate_cover_letter () {
file="$1"
# TODO: Replace with appropriate checks (e.g. spell checking).
true
}
validate_patch () {
file="$1"
# Ensure that the patch applies without conflicts.
git am -3 "$file" || return
# TODO: Replace with appropriate checks for this patch
# (e.g. checkpatch.pl).
true
}
validate_series () {
# TODO: Replace with appropriate checks for the whole series
# (e.g. quick build, coding style checks, etc.).
true
}
# main -------------------------------------------------------------------------
if test "$GIT_SENDEMAIL_FILE_COUNTER" = 1
then
remote=$(git config --default origin --get sendemail.validateRemote) &&
ref=$(git config --default HEAD --get sendemail.validateRemoteRef) &&
worktree=$(mktemp --tmpdir -d sendemail-validate.XXXXXXX) &&
git worktree add -fd --checkout "$worktree" "refs/remotes/$remote/$ref" &&
git config --replace-all sendemail.validateWorktree "$worktree"
else
worktree=$(git config --get sendemail.validateWorktree)
fi || {
echo "sendemail-validate: error: failed to prepare worktree" >&2
exit 1
}
unset GIT_DIR GIT_WORK_TREE
cd "$worktree" &&
if grep -q "^diff --git " "$1"
then
validate_patch "$1"
else
validate_cover_letter "$1"
fi &&
if test "$GIT_SENDEMAIL_FILE_COUNTER" = "$GIT_SENDEMAIL_FILE_TOTAL"
then
git config --unset-all sendemail.validateWorktree &&
trap 'git worktree remove -ff "$worktree"' EXIT &&
validate_series
fi
+128
View File
@@ -0,0 +1,128 @@
#!/bin/sh
#
# An example hook script to block unannotated tags from entering.
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
#
# To enable this hook, rename this file to "update".
#
# Config
# ------
# hooks.allowunannotated
# This boolean sets whether unannotated tags will be allowed into the
# repository. By default they won't be.
# hooks.allowdeletetag
# This boolean sets whether deleting tags will be allowed in the
# repository. By default they won't be.
# hooks.allowmodifytag
# This boolean sets whether a tag may be modified after creation. By default
# it won't be.
# hooks.allowdeletebranch
# This boolean sets whether deleting branches will be allowed in the
# repository. By default they won't be.
# hooks.denycreatebranch
# This boolean sets whether remotely creating branches will be denied
# in the repository. By default this is allowed.
#
# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"
# --- Safety check
if [ -z "$GIT_DIR" ]; then
echo "Don't run this script from the command line." >&2
echo " (if you want, you could supply GIT_DIR then run" >&2
echo " $0 <ref> <oldrev> <newrev>)" >&2
exit 1
fi
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
exit 1
fi
# --- Config
allowunannotated=$(git config --type=bool hooks.allowunannotated)
allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch)
denycreatebranch=$(git config --type=bool hooks.denycreatebranch)
allowdeletetag=$(git config --type=bool hooks.allowdeletetag)
allowmodifytag=$(git config --type=bool hooks.allowmodifytag)
# check for no description
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
case "$projectdesc" in
"Unnamed repository"* | "")
echo "*** Project description file hasn't been set" >&2
exit 1
;;
esac
# --- Check types
# if $newrev is 0000...0000, it's a commit to delete a ref.
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
if [ "$newrev" = "$zero" ]; then
newrev_type=delete
else
newrev_type=$(git cat-file -t $newrev)
fi
case "$refname","$newrev_type" in
refs/tags/*,commit)
# un-annotated tag
short_refname=${refname##refs/tags/}
if [ "$allowunannotated" != "true" ]; then
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
exit 1
fi
;;
refs/tags/*,delete)
# delete tag
if [ "$allowdeletetag" != "true" ]; then
echo "*** Deleting a tag is not allowed in this repository" >&2
exit 1
fi
;;
refs/tags/*,tag)
# annotated tag
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
then
echo "*** Tag '$refname' already exists." >&2
echo "*** Modifying a tag is not allowed in this repository." >&2
exit 1
fi
;;
refs/heads/*,commit)
# branch
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
echo "*** Creating a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/heads/*,delete)
# delete branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/remotes/*,commit)
# tracking branch
;;
refs/remotes/*,delete)
# delete tracking branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
exit 1
fi
;;
*)
# Anything else (is there anything else?)
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
exit 1
;;
esac
# --- Finished
exit 0
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
+1
View File
@@ -0,0 +1 @@
0000000000000000000000000000000000000000 ddcb79dc9934fd8a26263f6368c4eb7aa43f6d49 unknown <Administrator@PC-202504292023.(none)> 1785055843 +0800 clone: from https://gitlab.gnome.org/GNOME/libxml2.git
@@ -0,0 +1 @@
0000000000000000000000000000000000000000 ddcb79dc9934fd8a26263f6368c4eb7aa43f6d49 unknown <Administrator@PC-202504292023.(none)> 1785055843 +0800 clone: from https://gitlab.gnome.org/GNOME/libxml2.git
@@ -0,0 +1 @@
0000000000000000000000000000000000000000 ddcb79dc9934fd8a26263f6368c4eb7aa43f6d49 unknown <Administrator@PC-202504292023.(none)> 1785055843 +0800 clone: from https://gitlab.gnome.org/GNOME/libxml2.git
+491
View File
@@ -0,0 +1,491 @@
# pack-refs with: peeled fully-peeled sorted
ee0520e097d5d5eabc355041f350558fadd07492 refs/remotes/origin/2.10
0740a367a570c40246fe8077c2d172b63693f105 refs/remotes/origin/2.11
d7657811964eac1cb9743bb98649278ad948f0d2 refs/remotes/origin/2.12
04af2cabb9f859c198b8a553c028a87481199410 refs/remotes/origin/2.13
d23960a130c5bb82779c9405fbbf85e65fb3c57c refs/remotes/origin/2.14
c94eb0210183b9d7cb43f8e7fddc6be55843ef49 refs/remotes/origin/2.15
7846b0a677f8d3ce72486125fa281e92ac9970e8 refs/remotes/origin/2.9
0b348def38d88a639dae39870a23757dfdc4d4b7 refs/remotes/origin/LIB_XML_1_BRANCH
05a8ffeada05501f7a0288454e79c21203a31dd1 refs/remotes/origin/copy-entities
ddcb79dc9934fd8a26263f6368c4eb7aa43f6d49 refs/remotes/origin/master
163dc10dc51629c2ff9c027598a1a788213aadd4 refs/tags/CVE-2013-2877
^e50ba8164eee06461c73cd8abb9b46aa0be81869
fd5fad283f439e6711ac6c6cbba1e5eb4e7f9dc7 refs/tags/CVE-2014-0191
^9cd1c3cfbd32655d60572c0a413e017260c854df
e0dbd9dfe4c93a326c88b917a388d29795b5f296 refs/tags/CVE-2014-3660
^be2a7edaf289c5da74a4f9ed3a0b6c733e775230
e1f895952796c7e1e264bee4bc6bb1195d2279ab refs/tags/CVE-2015-1819
^213f1fe0d76d30eaed6e5853057defc43e6df2c9
c4c966b3841b775cd7d6719aa7fcaa0f345264e2 refs/tags/CVE-2015-5312
^69030714cde66d525a8884bda01b9e8f0abf8e1e
8f8bd7c77eba811e0566bfbe1f36a3d3837c59c2 refs/tags/CVE-2015-7497
^6360a31a84efe69d155ed96306b9a931a40beab9
b70d6d6dcf442e8769d2d290218ab75f2413e920 refs/tags/CVE-2015-7498
^afd27c21f6b36e22682b7da20d726bce2dcb2f43
ceaa9b17834d2986e93d304972e8c72380c602a8 refs/tags/CVE-2015-7499-1
^28cd9cb747a94483f4aea7f0968d202c20bb4cfc
a5ec74ac392aac86fba093ecd0136ae6245cb2d5 refs/tags/CVE-2015-7499-2
^35bcb1d758ed70aa7b257c9c3b3ff55e54e3d0da
b2a2bcfca4e09dbdc06cce57e19f14313590052e refs/tags/CVE-2015-7500
^f1063fdbe7fa66332bbb76874101c2a7b51b519f
e892062051dd4bf2f18c1388f68d3fa6207fca99 refs/tags/CVE-2015-7941_1
^a7dfab7411cbf545f359dd3157e5df1eb0e7ce31
943170f1d822aa50ae4bbf37cfef56b2116735b7 refs/tags/CVE-2015-7941_2
^9b8512337d14c8ddf662fcb98b0135f225a1c489
4bafc7d56574333a7b865eef5a1d89484e9af453 refs/tags/CVE-2015-7942
^bd0526e66a56e75a18da8c15c4750db8f801c52d
62f98ac9b842635e5874383c5cd1f91691443a9a refs/tags/CVE-2015-7942-2
^41ac9049a27f52e7a1f3b341f8714149fc88d450
c41fcb5c6e928a91dd4b29225b866baee7f687a7 refs/tags/CVE-2015-8035
^f0709e3ca8f8947f2d91ed34e92e38a4c23eae63
b27782bf51e7190816f62460bbe6d39fbba86caa refs/tags/CVE-2015-8242
^8fb4a770075628d6441fb17a1e435100e2f3b1a2
3293785cecdd5cc99a9c6d528f34826ba0868be4 refs/tags/CVE-2015-8317
^709a952110e98621c9b78c4f26462a9d8333102e
294a51cccca59b83ded6337150dafc4b35f7adb7 refs/tags/CVE-2016-1762
^a7a94612aa3b16779e2c74e1fa353b5d9786c602
158f6d9604e60f1b0b742e83082ff725f87168fa refs/tags/CVE-2016-1833
^0bcd05c5cd83dec3406c8f68b769b1d610c72f76
4a189503c845360fd6c5004a4e696ac4e69505c7 refs/tags/CVE-2016-1834
^8fbbf5513d609c1770b391b99e33314cd0742704
9cad8ce3d3e8f426bb98046b983a6ff103321d00 refs/tags/CVE-2016-1835
^38eae571111db3b43ffdeb05487c9f60551906fb
67dd1fda4bcaf457f922b2e0bb3169382ec3baf2 refs/tags/CVE-2016-1836
^45752d2c334b50016666d8f0ec3691e2d680f0a0
275b9f71a2c77fc76dec38b3e97a1d4dad497a17 refs/tags/CVE-2016-1837
^11ed4a7a90d5ce156a18980a4ad4e53e77384852
970aa35a0c96ec6dd44eb9e16b6ed7598a4c1702 refs/tags/CVE-2016-1838
^db07dd613e461df93dde7902c6505629bf0734e9
e804274a08ea2d5b7be5172dd05faeee9bb1dc7f refs/tags/CVE-2016-1839
^a820dbeac29d330bae4be05d9ecd939ad6b4aa33
bb9d3ea8b9b81bea178ef01e5e7092d40819c1ed refs/tags/CVE-2016-1840
^cbb271655cadeb8dbb258a64701d9a3a0c4835b4
82a7217b1c6eb37b9daca1dedd4c49618f0e7ac6 refs/tags/CVE-2016-3627
^bdd66182ef53fe1f7209ab6535fda56366bd7ac9
5f089881420bcd86034f3dba89935712b5491d83 refs/tags/CVE-2016-3705
^8f30bdff69edac9075f4663ce3b56b0c52d48ce6
d606f2da652964a79d86a7b920bde4e9a8863bfa refs/tags/CVE-2016-4449
^b1d34de46a11323fccffa9fadeb33be670d602f5
80dc44d75773a8f5d122ddf5e33ba7656fd43ce7 refs/tags/CVE-2016-4483
^c97750d11bb8b6f3303e7131fe526a61ac65bcfd
33c656c8cfa423aa5c0f40421b84ae3c3b523060 refs/tags/CVE-2021-3541
^8598060bacada41a0eb09d95c97744ff4e428f8e
6f67896efe30c2c748a77fa152fa318fdd31863c refs/tags/ChangeLog
^30fbd3f40eb514294b0f1a32f73db30a86c5b2e4
6278cf2922e700a5122943e4a9d3b8e0f08e599b refs/tags/EAZEL-NAUTILUS-MS-AUG07
^76234da1520f108588bbec7428f7d7f663e4b96e
58f71630e32934536da0b122e839853fcb213f00 refs/tags/FOR_GNOME_0_99_1
^8f8b4c80f6dfcc5d3985367cfd078c8b6d6e3f4b
069c04b1511d99804f72e3dcbe876001e2806984 refs/tags/GNOME_0_30
^8e0137ced4d14942286fe9ff8d423d986973795d
bcb6b9d6261a3f831ec611a433ab7e6f938dac24 refs/tags/GNOME_PRINT_0_24
^4b0755c68b0182809a7db5b6ab1478cb2767abfb
555474d5bf57162b5bbef8d11c4d1cb615a8ffe3 refs/tags/GNUMERIC_FIRST_PUBLIC_RELEASE
^8e0137ced4d14942286fe9ff8d423d986973795d
5fef2815562c67e6367f15f5aefb50c91548f85a refs/tags/LIBXML2.6.31
^216850b27ecf0a48bff5802f04760f5bdf027bfc
f4e1fc182582ff420cf8b7d2aa52b4c5085a1cd6 refs/tags/LIBXML2.6.32
^596da973eb47ae1c5fcec9e0085994a689648868
0461a0c499a6a58ad1a6732f2f76e38789b31e6b refs/tags/LIBXML2.7.0
^1572425c2774b3fef6af062b87351a0e42c3e172
2d3852c8072758184e8d1ef084cd8f2f0fc81236 refs/tags/LIBXML2.7.1
^a7036d93a0fd81c34e1d1f25b9a099454c8b8ac5
d9e71cf4744d527b6f27ef3b8f51afa8155ca924 refs/tags/LIBXML2.7.2
^7f4547cdbd76a2931553759fb433df88b8b99452
a30f67e606819120fa84931004eacb45db9e716d refs/tags/LIBXML2.7.3
^97ff9b367a6428f7703aa7938595c03ad39652e0
493ecdf13794c5c28b2cb5997932e53bd744af44 refs/tags/LIBXML2_2_4_21
^fc57b41cb14a9920fa73cbb9fa1e495047970f2b
98b6e2e0ad4133df54ea9e6ba11aec5693930a65 refs/tags/LIBXML2_2_5_0
^7b4b2f9d8fc712c49beaf75985161a130c77d13a
ae174f24106a3faee155f4ac363943e05c423547 refs/tags/LIBXML2_2_5_10
^cfba2fe0bbbdd1158666fc1090c7f48c0fdb00e1
ef1152a1bb47d73162ebb169f2187010e78853e8 refs/tags/LIBXML2_2_5_11
^b42dc2bb2d66d31d2f811ad72880b4ba655a8f58
594a62a749038ccfeddb97090526c81e92902a5f refs/tags/LIBXML2_2_5_7
^92fc02cc52326430de4d7009b177e845fb69dba0
0e641fffb721aadb23c4221b8c0cd7f5e0bb2e58 refs/tags/LIBXML2_2_5_8
^560c2a441bf27f5b9d55252a70f3d5952d9ae351
dbd8be27bbd3f3c1fd0502e3bbd6ffc43bf984f8 refs/tags/LIBXML2_2_5_9
^83ee40de7569cf3e4cb45080fc9c9cb337a1e8cd
945d471f5eae6adb42841e57f6df34d7cbf478d6 refs/tags/LIBXML2_2_5_x
^cfba2fe0bbbdd1158666fc1090c7f48c0fdb00e1
1866f526ba0d9dc85fe68d77657c42fb54579354 refs/tags/LIBXML2_2_6_1
^ceffd451992ced3747ecd7477d74e3c88d3ad681
d621edb6f28d8a91ba066b17c7eda5b5170e07a3 refs/tags/LIBXML2_2_6_11
^45cb0f41e457439d508f03a19d7a6c98d9803d9f
fadd1eaf40a8960444cc078c4193ced10756ac80 refs/tags/LIBXML2_2_6_12
^b331fffbb90064c98e4e6ec5c08bfbe8efa17ffd
1351130ccb631fc0c60a1be9d128145f3850442c refs/tags/LIBXML2_2_6_13
^d1de4a3da9e5364a37469108b932e5ad66055a5e
6e4939285c4ca104695a45d78caf29e98011f378 refs/tags/LIBXML2_2_6_14
^210818b18aec4674f43b45143f4f4eed850c9e50
6070cd3f5d98c15ee39f6b3b8d0b7fec6c6cc33c refs/tags/LIBXML2_2_6_15
^c2f83d1fad48c4483f34213dcf6935e308e0c596
deea881c69a077adbe6289f22511f116f097846a refs/tags/LIBXML2_2_6_16
^c3d7cb4e582da89a442d6da32b13950af4cf7067
31398af43568e5dd3a216f54147e83c1c8694564 refs/tags/LIBXML2_2_6_18
^57c000e33d0f970846aaa35d47a2b7faf5262032
82466b40494d537d2c050dd96ca5a8d92714f385 refs/tags/LIBXML2_2_6_19
^771971f2e5077482fce3d9c234455118f2352f73
3a1b40aba764c9319781c4535b404b95036e7470 refs/tags/LIBXML2_2_6_2
^6d373a26fff17281ac1c872adae95b14727ca959
2ff310f0463982c9ed9ec2b6fc2fc8771437c399 refs/tags/LIBXML2_2_6_20
^e4aaae2640843b4e1453f57c62a64d70faf95edb
1144760805ea47e56ce26556cccb9281db8e7e69 refs/tags/LIBXML2_2_6_21
^0bcc7f6ae97a8bd8615dfd9d3acf8188ab66580e
83f982c60e1abf40ed98a1ba242629ec6e422077 refs/tags/LIBXML2_2_6_22
^33b20b70e2b0cc036bd23909fe262f816228f305
7ccf4c8f185a87d846e48385cdaf2bc244e34344 refs/tags/LIBXML2_2_6_23
^6795260135a78da60182504a2d7efb4e3177eb57
76ae427a860d53da573126c5d3defd1fbb1ae2a4 refs/tags/LIBXML2_2_6_24
^b2f8f1de7a02900f3e62a8170618ac35bd189269
6990c2948bab125fb3216e58981be116b9af5d90 refs/tags/LIBXML2_2_6_26
^7cb3fa9d51a0a57d1e538854e4be84db82b75098
4093371c160d427494f2b459e34762ca49cad824 refs/tags/LIBXML2_2_6_27
^c8338f1a52e7712dbba5e7c2fd5f76ecf01bf14f
c23b0423f20e59dc2eeaf3913bef1c78b9404705 refs/tags/LIBXML2_2_6_28
^e61d75f11e1e061d0394db395937cd8cdad7d689
3283d0df55d21811897074b757cf32746a75f030 refs/tags/LIBXML2_2_6_29
^9049c1c50a9e2454f2b43c988c6069631d313c1e
3d508f7d89b6c069f3d730a55e01e0ddf4fdf09d refs/tags/LIBXML2_2_6_3
^c480c4ea56bbb5aad5ac991dafef5702dabb6360
bba1bb9e7ca47ca5a3e73ccecede542da47f3964 refs/tags/LIBXML2_2_6_30
^22f476e0f2f5549e0a246be62a3affba276f4b75
d3e8c95b24821db0a34332f877e2f1f4919391f0 refs/tags/LIBXML2_2_6_4
^e6e59cdf33e02648fc8f33c357accadf2a657668
e5e563aa3507fc2d1c708b8d2bfe17869cf103f4 refs/tags/LIBXML2_2_6_5
^189f46b18cf94b0c941f34138611dc56a16cc6f1
f9548bdf541a0a1261034dee1749e9ba255858f9 refs/tags/LIBXML2_2_6_6
^5c9547e4f3173e92501d735193767705eab9ac31
cd9ffc78f627bda4b38322e4994873b80711ec24 refs/tags/LIBXML2_2_6_7
^9291449d9e7ca7179a2b26182ef1ab375ff4731e
954f4c261bcf5e7b0e33076198886867b79895ee refs/tags/LIBXML2_2_6_8
^252004df14b680d40c29e2ab479660162e15431e
c292b6aeacf7a0d17f7e938e548b704d6840dd36 refs/tags/LIBXML2_2_6_9
^f70f7b2da92c10e551724fdc955c8b668e5ec0b6
d1b1f19d55e17a37afa91f87909366f4bfd01788 refs/tags/LIBXML2_6_0
^2189b59b1005976970ebadb65edbb289f9e091ff
f5210f2ab3bd0d3030d19b904421e905fcd79a03 refs/tags/LIBXML_0_99
^29fb727eb480f10010f37ca9e0b984bbd4dcae3b
6e7609f2a73f3633f6e090e27c9ce0d7420e0f6a refs/tags/LIBXML_1_5_0
^424af3912493b654c46e569b06b7cd58cb2947c9
f64eef45b0dec07ef6e69d277aeb430f8d05da47 refs/tags/LIBXML_1_8_10
^7cb7a77c30b4d64a276c43f9c446be165e5b6b1e
7872d3ee8561df9a75937b5762077c73fea74a54 refs/tags/LIBXML_1_8_10_REAL
^c0408519798f2e10497cb46e4d01b53cc7a08ce6
a05e695a83ae96dda7712fd63614714992324952 refs/tags/LIBXML_1_8_12
^73a4bfe95229a0f89ac9335a4f5f3960561d0158
42344bf524ffced12be408577a1b78095350b72a refs/tags/LIBXML_1_8_14
^146f50561fa2ad63cbf81571887b1e26101d64be
66cab196da7c222b0cb26e4de7812cb6806e1c8c refs/tags/LIBXML_1_8_16
^a1ac9b0c7a23734d77fdd9235cb385f0e8b70025
bb50ea3628cbd82f2869b5f27e2b63726277dec2 refs/tags/LIBXML_1_8_17
^ead1ea69da2cceea4018cb411971261f8952444c
09e31436c4e938f3eba2b3f726c1da83d62dcb65 refs/tags/LIBXML_1_8_5
^461a66c9428af63ee8de68fbb45deaf58c0f79fc
501e80104894e407e267da087f4a488cdc4a4163 refs/tags/LIBXML_1_8_6
^e41f2b74c53d9d97b51dfc1d20aa201e4b2c9201
b22494c4ada06e09e2aeed3be32b249291e277e2 refs/tags/LIBXML_1_8_8
^08746ae6f0fe219b8c760ff6e85bddf9f39ac1ab
7ba7b81be0b6f52564a7395d5c87e02d3b7561b2 refs/tags/LIBXML_1_8_9
^e98991955c4e6661ed1bfe8c84951ff6fd2ed1d6
8d86f6fc6a5ef306638ae0bb59bac7cbe2750886 refs/tags/LIBXML_2_0_0
^18b0ef6d41fdc3905e60fce0123f9ff5f48581da
1270f021d26d5ec3f8fba2fd932cc27fa2634518 refs/tags/LIBXML_2_1_0
^c230410eadbada15092c04f92d01068af8a19f8d
ca834ba122b807fb2ce88142385a1475de22de5e refs/tags/LIBXML_2_1_1
^663a607aa40e095a2e43a78a950a73a8ac1299dd
f8457304220ac4e34b0343d82d589ab9e1108409 refs/tags/LIBXML_2_2_1
^69f94a3b722e33fc980ee9e59a78f5ec26863d26
30a3c2d958db6a20c783cb87b2282a7911aad603 refs/tags/LIBXML_2_2_3
^04698d9e1c56467007fcbb9472e5db67cf5938f5
360a48b58ccbb9beddb707e6a0a3db237283d954 refs/tags/LIBXML_2_2_4
^3bff2b0e5d2428cff9778ae60d38476f6c58c43b
1c168bcf814a286a761f3652b4ea0ca5bcb51b30 refs/tags/LIBXML_2_2_6
^29a11cc696655f9ac841a5ca28b272e4150aafa1
2da5a07b0b3bc69c9d74b310e27e6248a66b313d refs/tags/LIBXML_2_2_7
^a4964b75003d138d4643ab03e3e116a8453f8308
7e3278760ac64a94adcacfbb1837b6e175410e58 refs/tags/LIBXML_2_2_8
^4e19074bc26bac984de1d8eb3e54a5aeee421af1
a7ed8d41e2498fca91da0fe05b2245a2dd288c67 refs/tags/LIBXML_2_3_0
^6a2e40604393375cf4c42c464a532dee0be82845
b92adf88125b7e9d3a88b58fb004fc54d73bfa2e refs/tags/LIBXML_2_3_10
^b3a182e53326cce1438bc2951372ffc1ca4eb18c
ec28ff67eb27b33d3a025d8675ed5be7373f787b refs/tags/LIBXML_2_3_11
^6d473ed349020894228f29d334cba4749f9a7cea
e8544c76a86f17d33c7e6cd62ea43b530e27e40d refs/tags/LIBXML_2_3_12
^823a77f8f9effd47b22715f66883bfd889c771ff
1aa09dd44d790f3583f000cbc4ade9ed5908a181 refs/tags/LIBXML_2_3_13
^b37ecd0e51908bc9922fa37d1ec0aaaf9dc9d8e8
a445536c5a474948ef1ac271be3f4d201fbfc298 refs/tags/LIBXML_2_3_14
^5b43fde43de0b9a507f25238ad6ff3aec7cdafb2
8accf226f0600685d5ed2127153ef5d329b572c2 refs/tags/LIBXML_2_3_2
^59a3bd3744b5e46e30ab63dc772bfe924ad81469
bf5e305a26c27f3a72a61430a49c563a972438e8 refs/tags/LIBXML_2_3_3
^b402c07ca541924d89cd6ff49f99bd1b59097278
00943a4a2de3546bf14b913378883103c023cee4 refs/tags/LIBXML_2_3_4
^e356c280069914f0052891861a55fdfaff6dcf65
72d74b776193484557d6a649685b26d22c154085 refs/tags/LIBXML_2_3_5
^c7ad7ce598261a447cfceb7837219fcd93151336
e21e54203aeef732dfa459cf4838e9040542e9d2 refs/tags/LIBXML_2_3_6
^fac26a1f9330f404a90a8f347c8d13fdf08dbba1
adbdbc4f8f746f02f38c99112864abf4cefa2278 refs/tags/LIBXML_2_3_7
^393df01cac24c7344ddcdc3b6968f893790c5e67
e3847ae4bcdb6e4e258bfa651a52dccb561018f9 refs/tags/LIBXML_2_3_8
^3bbbe6fa2a16ce1e1c1ff08725cf09857d7c0428
68fb039bfda99e6f4c2576bf70b5735914aa0e17 refs/tags/LIBXML_2_3_9
^bed7b052a318695f5e0856f12fc0c86f66472cb3
deade41e955fb930d0bc528bba8087b88e249f6a refs/tags/LIBXML_2_4_0
^09ab7e1c1c943a6ba160037208c58a0dda3fe8ec
fade9185f8862bf496e6c35f900f6eadcd453eac refs/tags/LIBXML_2_4_11
^bd9b0e8eedacd57d26bbe655d76a6bc858ab95ec
703a08b6efa6d902a8c3ba83801fe76d3c53b32a refs/tags/LIBXML_2_4_12
^ef90ba7e3b530a8eb9ed27f57f0ced139b839780
6543d5679b5ffeda3ffb311db4b4f9ef39888b24 refs/tags/LIBXML_2_4_13
^af43f63aaabf0dc4b4a070773875d0927da3d8a2
d74637c3f6dbfe3249ba01f79a0c056e6975b9b7 refs/tags/LIBXML_2_4_14
^07be19bb1e73b86bdd1014eb1d9f84cb7d08e9fa
5baae18ca7ece6da7809840dcf26c1b95ebca10c refs/tags/LIBXML_2_4_16
^5f4b5999b4eeda2ca68e6d9f54a3c534a8474b38
13ba6f67deac547beaa954065cfd2a63e4388b78 refs/tags/LIBXML_2_4_18
^34ce8bece2f22cc99d25221b77315cd008f4866b
991e738a986bd7af093489d4051d65fd6df12859 refs/tags/LIBXML_2_4_2
^9a0b3d63c152fd11e2e49a308f4f102dc6043d97
cb220ae9180fb44709c2aa1f0dbf510d49f33906 refs/tags/LIBXML_2_4_20
^a7084cd57e055ac5f768c0d2aacd1bdab952798c
2d9fad9527c5a9c902d8cd774b1307933e728f8a refs/tags/LIBXML_2_4_22
^d5e22ef5802bc1d2d730cded59a700a88abfa47a
17fb73c4b80399cf37ad2762d4ef2152b0b82995 refs/tags/LIBXML_2_4_23
^539638ba2359774d184bd87cf713c7e2afc23a8c
690c9d30526aabcf0a22e2f8bcb9bf716afa139c refs/tags/LIBXML_2_4_24
^42766c0eea0fa40c7b721fa4c9cf56b4c484b4c7
ea847274005ee18c78f93fdf3b9f4354881f71f0 refs/tags/LIBXML_2_4_25
^e16b57406a96297a6ce39e509e06511c3c8a200e
7a13ab487e54688b5f4f490e7dfa5a9457c18258 refs/tags/LIBXML_2_4_26
^4826743d1643bd01d5ceaeaf627b0d71b60beb2f
4a8a33fe201084427668e814cfd7b160c98728cd refs/tags/LIBXML_2_4_27
^dad3f680e504b25b3bfd30a411adb55b4d0efe09
3996c4428a894592c28422c18c306e551976e2ff refs/tags/LIBXML_2_4_29
^9b4bb4d07ab8f820fdc19a4fc7e8d7a39e159c66
7b7a8929f92402ae6bd73cd82823870efe22481c refs/tags/LIBXML_2_4_3
^e8f379330e16fcfae7d2737bbc22007b69cc3704
fdad8d1875fb14da9dbd6b322cfc4915c3833d33 refs/tags/LIBXML_2_4_30
^2d45f52c14fe508f003b42dca81264147a0fcabc
a5fa03e1a93ef1d8d5f79509d3000629d978dc65 refs/tags/LIBXML_2_4_4
^baa8854e4e005f7a58ee1b0aa306c978247da9a7
c94b7df0bdd68d94545575b7edf88cb797b106c3 refs/tags/LIBXML_2_4_6
^60087f30f3b4cf21de48f39181736e7d71e7a661
898487ecf5beb7047e1671aedfcb09276fc55699 refs/tags/LIBXML_2_4_7
^52dcab3999cc9c480b275bc3ddf66dbb66f92d68
6d315cb263e6b956fadf65a421061e7b20303921 refs/tags/LIBXML_2_5_1
^e2830f1e65ddef63fc74a22addfea30d97ef8d65
dae9a5a6fb8fde389d693a854e8033a14414aea3 refs/tags/LIBXML_2_5_2
^72fef16e5c05224a81425b2ada12f4147b5194be
74d430bf12c9422842cdb70f7c9191d5c70ad3d4 refs/tags/LIBXML_2_5_3
^869fb32050e8e89c0c4848087970a58df9966f51
4672f42c45796bb9c56ecabce4a4be7625a33e74 refs/tags/LIBXML_2_5_4
^17bed98106ac388a6eae80515aae6957782d6029
1d4de4b34555e0b3fca79e6a589a42901449536a refs/tags/LIBXML_2_5_5
^9adc0469d4691e798ea4ad59b84c874cdea8b38d
9ff4a158ebe9ece4bb03b4f2f77c4e35c3f58774 refs/tags/LIBXML_2_5_6
^c2d4a93d4f6ecc658e63ddc416be918318cea7a9
11fb419f2b9ddc4e661e400f3a836415ed87c75c refs/tags/LIBXML_2_6_10
^4e6fef4dab062b22d2e0386415a5218070952faa
b8d74ccc2f8da503e9526d7d03143f7402342cb8 refs/tags/LIBXML_TEST_2_0_0
^5d211f4c7a150e45a301cec55426a7ed7edb7f50
080725036cf5184d3fcc3a218b83a4801a3c56e2 refs/tags/LIB_XML_1_1
^011b63cb2034476017dde1d4ad5a6aea43b94066
cefebfc541511ae9689fe6974fbca23e3e4c3dd1 refs/tags/LIB_XML_1_3
^97fea18b7138caf76bf17d003f4985d8797d26f9
dc13fa6616f650c4883e5d4dcd60361119e50755 refs/tags/LIB_XML_1_4
^1566d3a91b50e08f8bd928da5a06d9c53a99747f
0b62127e46dd8131fe7ce0f1c1ba38d3c9393b4e refs/tags/LIB_XML_1_6_1
^d2d38e9ab3691d11755857b87d83f2322b85d93d
7b0dc286b7b99b0e7e5cc3e7a1094844544cf9b9 refs/tags/LIB_XML_1_6_2
^c08a2c6fd41773f55853c5d93a67a932c61511e9
71da3e0339adb75e12fa5dd643e85ae90c3a53d5 refs/tags/LIB_XML_1_7_0
^4ecf39f3e3e51df736cbb7bdc3d24739a786fb3b
5000182a4ff1c18fb16dfbbcce18408c9a471b5f refs/tags/LIB_XML_1_7_1
^dd6b36766fb1cc83020cc12f226452ba2d640e35
b41926302ec35da1c0009a4dcf493cc1edcd0600 refs/tags/LIB_XML_1_7_3
^ad21944c30f85761a9339fe054e1f93e176b7152
42ce4e01ec843426c961900a710d7c24edd33a0d refs/tags/LIB_XML_1_8_3
^f3a7358dcae937caacd7149d080bf275e920ba69
6b2edc001df59352a92d9e124c085b508f050ded refs/tags/LIB_XML_1_X
^76234da1520f108588bbec7428f7d7f663e4b96e
9942b0f93d22dc8e4b081f0907365616c8da976a refs/tags/PRE_MUCKUP
^4b637079f26d8f5879ed45eb18cd249cad261951
d95c7184373f24ab680fea530aed57d2775993d9 refs/tags/PRE_MUCKUP2
^4b637079f26d8f5879ed45eb18cd249cad261951
48b237e1d5e319fe7473f11037884f58931b1646 refs/tags/PRE_MUCKUP3
^4b637079f26d8f5879ed45eb18cd249cad261951
8b3ff3d64c7bef4d4e3b2c7f65013d0136ba343b refs/tags/help
^3ed155fcdf123a94ac885923a9262f250bdb3301
82936c45494bb1336b19b2cc456204ddc0d7506a refs/tags/v2.10.0
^ae383bdb74523ddaf831d7db0690173c25e483b3
3fdcf0b4150a6e8b2df3189568b810e46dcdafc5 refs/tags/v2.10.1
^d85c4a01407b75eb4005256df106d121e766a1d8
b8965a6c8994b19cf360d3f35b97c5b0399c17ca refs/tags/v2.10.2
^21b24b51608d471bb9f7c4225e23d0db2acecc52
096ae438216478f676df7ea7a8532d565132d22d refs/tags/v2.10.3
^f507d167f1755b7eaea09fb1a44d29aab828b6d1
9ddf8ecda72891d1bbe8517be1a59153e8ae944d refs/tags/v2.10.4
^223cb03a5d27b1b2393b266a8657443d046139d6
4f14180cc7066c06735cb8a4a7cc7ab1d8817a5d refs/tags/v2.11.0
^f296934ade688baab79caf1c62a82149ad78accf
777ca04136443748218d3aeca79442f103af2d4a refs/tags/v2.11.1
^ab9fea4ac0d494bcf68864e9be0574137e48a80e
752811ac559fcd72e518c144c328a6a90e66154a refs/tags/v2.11.2
^838bf42d54f94c8ff99b6e5022899a32875ed5d7
11b9961d22c1bc72e651b07c3c542e9b64d19be5 refs/tags/v2.11.3
^787ae0390a3b90a76c2c54d6a18d7f1abe888c64
be5448432faaf7b108665fb2f4336c407dcecee9 refs/tags/v2.11.4
^2e9f7860a9cb8be29eca90b7409ef0278d30ef10
0884fd4019dcca3b57be83ae15272eec10519370 refs/tags/v2.11.5
^2b998a4ffbdfea04fc6a620721abc690a15743af
2ee598b7bf849ee7ee990977fe5d17ec63f651bd refs/tags/v2.11.6
^93f0179d9d0bcd0d053d2df3e2fd382e6dac6954
8651f4757b6a6855ea322dd49af1c5a77842bf34 refs/tags/v2.11.7
^8711320065405c4bb08aaccd4bd2881450b5ce41
5ca98838f76cb3791df01b5d2cbc8cd1c40463a4 refs/tags/v2.11.8
^58a973c40ba927e5ad941789723da7c47a2d60e3
81517a021421977c185c4ebb970e372f6301a9c9 refs/tags/v2.11.9
^954e851e1d8d1f4c1dfbdf043623b3c11a1c723c
a816094b4370aebb48ed8a8015b7ef89603fdc1e refs/tags/v2.12.0
^5e9b167dce73bd6a804ab107ae4c4b95e6849597
ad035cb0a2872f8bbc2f936c25b16b4d6a0f5a23 refs/tags/v2.12.1
^f4ac9926a463ecb628f73049e4fd7ecced8fb7cf
ede4fc0a676c47c40612d26ef93b0cd973df319d refs/tags/v2.12.10
^02d577715e1951cf114ca4e9adaf5605156c4f4c
3772809730ffdc1b58f2e0474daa39d1c1823779 refs/tags/v2.12.2
^4d8fa5b292fc902268217fa0f7031e77e5437b5a
e6d5e1ca18550f26eb864e267798f1304cbb8f74 refs/tags/v2.12.3
^30d22bec03893ad646907050959bdfe9e8000146
8992d2c17dba0b1842935bc626a3108b0844e509 refs/tags/v2.12.4
^8292f361458fcffe0bff515a385be02e9d35582c
906253a1d2d6dea0bf53cd8228746a163b21f221 refs/tags/v2.12.5
^e189e9945317ad4c8603fa2300d11d11f5e2e335
583f84988ae976b2683addce4107fd4afaab66f4 refs/tags/v2.12.6
^505e2e872e767405be565aa9d47ae9d6d5677f79
87d84ef5ab9dc42e31d31a9ee5929f89b1908191 refs/tags/v2.12.7
^0b6d8130737125ba45981d54be7f15fe398ad2e0
251d8617d7768e81d00d57a6257e8668deb19285 refs/tags/v2.12.8
^83fce0a3f9ef22c90a980b03bb90cbd364d5c9ab
94175bb9217a889e0d287962e6a0a8f4b658371e refs/tags/v2.12.9
^00301f0fe8bccdb9945fb684e9bbd72449b961a5
b51780c6ba0bb92d70093935bda36ccffff66039 refs/tags/v2.13.0
^cdd2575f7fbab1d8162600f4048bc37503c80e28
5c0a632451b7442a606fbe1b2ad8e6cbb431ee97 refs/tags/v2.13.1
^48dba1e21f8f1a7d8a817eaf65831396e74b78d2
9fc170941a355569b252470e4ede6846b9d8074d refs/tags/v2.13.2
^4b3f860e5420ade19a825dc7f4d75789489535ba
72c519a5220e5ed2d50d3092ad32264c58f6b021 refs/tags/v2.13.3
^3b1742b8391e966be780bdc43fdf959f7b3a118c
5d08d498f89e857756978ce092b7e4af2b74c62b refs/tags/v2.13.4
^60d3056c97067e6cb2125284878ed7c99c90ed81
912cb0a6552b5dd099e283a234447208638c2209 refs/tags/v2.13.5
^de918d45e1b2276a28a4cd32bcf556bef65284e4
8e7a3f7643aeb3f00c5d8480cfd9907e218f253a refs/tags/v2.13.6
^66453240c94b5cbd3e9ae9b32016fdafb13cdf18
92013f5e380c7027f89002d1fa150a656bb5cb66 refs/tags/v2.13.7
^9b8fbe99ad14fe32c5dd5913743046d80cf347fe
c1a40ead7b592be7112cd1a9e60cc7d31bf4b595 refs/tags/v2.13.8
^eb0a2f2b91566384f378d870ffcd69c0a24162cc
01d801ed453402320ca67f28bd7b71ca07d473d9 refs/tags/v2.13.9
^04af2cabb9f859c198b8a553c028a87481199410
8f31df3715c794325282f91e06836808ec0e3e25 refs/tags/v2.14.0
^a372cbf5821302ebaf757235b29ba812df78204d
103391ea91479da9b918448dc707001b3114a2bb refs/tags/v2.14.1
^0f10a05d2e1043dcc178736b82277223a76eacc9
718a140a367cb89192587d3dc80bf389f5aca531 refs/tags/v2.14.2
^0e145ae4881c2a05ae00128a3bd90d76d4dadc4b
514a3a41e7e273fb5642cde2dbd53a76e4aebf63 refs/tags/v2.14.3
^8d509f483dd5ce268b2fded9c738132c47d820d8
2f93c7b32890525107153c8920398058d33f17b4 refs/tags/v2.14.4
^4c6b2c3096b1da0d0780fe0b4f147e837140468d
97bd75ab83e6c2c2596cc520abe80d6779e4a69c refs/tags/v2.14.5
^74f3154320df8950eceae4951975cc9dfc3a254d
20f532eb52155e0657858712823f5908d1022a6d refs/tags/v2.14.6
^d23960a130c5bb82779c9405fbbf85e65fb3c57c
1b21b6c77bc1860e1a2b732bd2d9bff304d112c3 refs/tags/v2.15.0
^0bea77c8289324483c0504d36ac730bb03f6a70b
c36a6d572993da7e72a95fc8d6bbe4d371b57a72 refs/tags/v2.15.1
^b7fa62cbe8ef0df5869e000d5b690bdedd07f33e
580f6350dcb08d07723069c8a0163b9f7961eb84 refs/tags/v2.15.2
^3d840e17858de03a09fba8b202e3a89267d5795a
5e0a659ebe62aec93c518135d669404e108c7593 refs/tags/v2.15.3
^c94eb0210183b9d7cb43f8e7fddc6be55843ef49
32c00ab1f275a5cb405984b9d05074f0220c51b2 refs/tags/v2.7.4
^293416828e1467f877d9dd928f174dcf81b103bc
16d832067a0cd91c872bddcbaaa333ecfde4e21f refs/tags/v2.7.5
^7a896ce260d2447d405b4ae683bf9d643eef6cda
09722218f6b34cf7956b9d783b6c4c22245ae0cf refs/tags/v2.7.6
^96bb740e2102f103777f0a630d29ba88996dd80c
d87cd23dc35db8e3740278437b9788e04842ee8a refs/tags/v2.7.7
^bb5055f3875c5a3c45f4daa8058e35aab8c5ac3f
dfb55d16be9160f47c2d975787c51e542317bf98 refs/tags/v2.7.8
^4c2e7c651f6c2f0d1a74f350cbda95f7df3e7017
60f2ea93af9cf5fb703619b1f70b6efe44e72a68 refs/tags/v2.8.0
^c943f708f1853de4eb15e5a94cf0b35d108da87a
33ea7b311ab9ef2876f6f637d9d3070168097d6d refs/tags/v2.8.0-rc1
^9d9685ad88c17d35b6688695af3ceba7c7309b13
873af1e595d9d38161713173abe886c2f964ecf3 refs/tags/v2.8.0-rc2
^ee8f1d4cda8dc1a6f2c515fe234f7bc89cdc9f80
64ff9c0b6c1428b22139e96e9c8a6073cb13621c refs/tags/v2.9.0
^38bbd3412d1c2a2016cf5a1a221ad4010216d28e
68dbd0731a531c518af3119fd28fd76d358cb0fe refs/tags/v2.9.0-rc2
^f933c898132f20a50ba39ac6116378b71a01c700
3c5a219589cd29e14cc98ff3888782f3b4d44fc1 refs/tags/v2.9.1
^f4e5a6994ed230dfa3fb5b5c3fd94c4993ef1ba7
f1840421fcb591dac8da7ca337687f9901e7a6f2 refs/tags/v2.9.10
^41a34e1f4ffae2ce401600dbb5fe43f8fe402641
bf8ef642e5628ae14d6e08af901266ddea34e397 refs/tags/v2.9.10-rc1
^9acef289285008f81b4b66b4880baf600773cf67
45d730733714c9845dc9dc703dac896c6e8ee778 refs/tags/v2.9.11
^e1bcffea180d6cc0651757bb64284a763e0e2239
adf8e7ce9659c5d7e8401b1962fdbd3183413970 refs/tags/v2.9.12
^b48e77cf4f6fa0792c5f4b639707a2b0675e461b
0d2678b55df8165c9957d727f65ea7bc5db45394 refs/tags/v2.9.13
^a075d256fd9ff15590b86d981b75a50ead124fca
bd61cd3e2641f73dfeb1477cc96f4fce66695441 refs/tags/v2.9.14
^7846b0a677f8d3ce72486125fa281e92ac9970e8
1981966910ce8b9fccbe2d389539cc9d4a0f2b8b refs/tags/v2.9.2
^726f67e2f140f8d936dfe993bf9ded3180d750d2
a0be0ee781ee75068ed09e3689cedb86bb3fc6f8 refs/tags/v2.9.2-rc1
^f985ada79027570d5e3f0d1b29c8ecf23921044a
a7ee9ac2c9501a0bc19fecc79835e88ee3a0fb8b refs/tags/v2.9.2-rc2
^af62eb4fabda119f12c53da2e68cf0decb68b0d8
9393796f3d9fe9c3695bb04d04c4d63115201dc1 refs/tags/v2.9.3
^6657afe83a38278f124ace71dc85f60420beb2d5
56a6e1aebed937941d2960cc5012665a5ca0115e refs/tags/v2.9.4
^bdec2183f34b37ee89ae1d330c6ad2bb4d76605f
497393910ff3b586deaa497bc4a2e9f26eb0bdc0 refs/tags/v2.9.4-rc1
^a1dca81df7c352cd9a14ab678750b1623f8f8ed7
c1cda08208d5d5f5799e08a0b94dec639b99afe8 refs/tags/v2.9.4-rc2
^8effcb578e0590cc01bbcab0f9dccefc6bdbcdbd
f3ec1e3f525ac665f35d5f08013b30b9988cd2ad refs/tags/v2.9.5
^2960178fe8f9fe690b7f8c1c49093ff54bb56934
aecbb680b62a451695faa0058125c036eda308f9 refs/tags/v2.9.5-rc1
^e29e50e54f471c7019059e5358b2739442266246
ac79e63dc73782adf84b7cac4ea4884cf8082652 refs/tags/v2.9.5-rc2
^69936b129fedcda3514fee1a0d6b39521923cbac
60937cf0a9bf4f7c2e85fde7311d2faa9509a3b2 refs/tags/v2.9.6
^4b4d3d85165e6bfca23893cf98834c4bc747a96c
088e58814aab32e5a52fff33e5b8b5cc28988a0b refs/tags/v2.9.6-rc1
^0f3b843b3534784ef57a4f9b874238aa1fda5a73
6b6c944506736ab8c1e026b0bc7dcf39f5dedd17 refs/tags/v2.9.7
^bc5a5d658320c37e206fe4e7b525b4a24466d0c6
8bb75f1fd0d7060127851da63330e5a7805f01ae refs/tags/v2.9.7-rc1
^09f51ecbc5b8ea418bacca4ad43a4d2d1e3ccdfb
8b595673b8fcb5d5769e38bb40fde00ac8ddba0b refs/tags/v2.9.8
^18890f471c420411aa3c989e104d090966ec9dbf
d6d2d9a1413638f2c98a5404665e8071917ae3d0 refs/tags/v2.9.8-rc1
^ab362ab0ad3af54406ae8237a525405c6e2a705b
e555d28c1c16469b396d44827c1b8e2d59bf92bc refs/tags/v2.9.9
^f8a8c1f59db355b46962577e7b74f1a1e8149dc6
11a505b2d5d3778c39759e1a16c5a58546a2a058 refs/tags/v2.9.9-rc1
^c8e5f9588b986c6e81c9028825aeff8151375d28
f67b2a86b67d8fcadc1b9f25ae3cebbfdb0c9cb6 refs/tags/v2.9.9-rc2
^a71b98ec9dee2d44e16a74ab8472868891bbc7b4
+1
View File
@@ -0,0 +1 @@
ddcb79dc9934fd8a26263f6368c4eb7aa43f6d49
@@ -0,0 +1 @@
ref: refs/remotes/origin/master
+2
View File
@@ -0,0 +1,2 @@
/result/** -text
/test/** -text
+70
View File
@@ -0,0 +1,70 @@
*.exe
*.o
*.la
*.lo
*.pyc
# local build directories
/build
/install
# Executables
/xmlcatalog
/xmllint
# Test executables
/runsuite
/runtest
/runxmlconf
/testModule
/testapi
/testchar
/testdict
/testlimits
/testparser
/testrecurse
# Tests
/missing.lst
/runsuite.log
/runxmlconf.log
/test.out
/xmlconf
/xstc/Tests
# Generated by build system
/config.h
/include/libxml/xmlversion.h
/libxml-2.0.pc
/libxml2-config.cmake
/xml2-config
# Autotools
.deps
.libs
Makefile
Makefile.in
/INSTALL
/aclocal.m4
/autom4te.cache
/compile
/config.guess
/config.guess~
/config.h.in
/config.h.in~
/config.log
/config.status
/config.sub
/config.sub~
/configure
/configure~
/depcomp
/install-sh
/install-sh~
/libtool
/ltmain.sh
/missing
/m4/libtool.m4
/m4/lt*.m4
/py-compile
/stamp-h1
+355
View File
@@ -0,0 +1,355 @@
include:
- component: "gitlab.gnome.org/GNOME/citemplates/release-service@master"
inputs:
dist-job-name: "dist"
tarball-artifact-path: "${TARBALL_ARTIFACT_PATH}"
install:
image: registry.gitlab.gnome.org/gnome/libxml2/docs
before_script:
- rm -rf libxml2-build
- mkdir libxml2-build
- ln -s /tests/xmlconf .
script:
- sh .gitlab-ci/install.sh
variables:
CFLAGS: "-O2"
DOXYGEN_WARN_AS_ERROR: "FAIL_ON_WARNINGS"
artifacts:
expire_in: 2 hrs
paths:
- install
.test:
image: registry.gitlab.gnome.org/gnome/libxml2
variables:
BASE_CONFIG: "--with-http --with-schematron --with-zlib --with-python"
before_script:
- rm -rf libxml2-build
- mkdir libxml2-build
- ln -s /tests/xmlconf .
script:
- sh .gitlab-ci/test.sh
gcc:
extends: .test
variables:
CFLAGS: "-O2"
gcc:c89:
extends: .test
variables:
CONFIG: "--without-python"
CFLAGS: "-O2 -std=c89 -D_XOPEN_SOURCE=600 -Wno-error=unused-function -Wno-error=overlength-strings"
gcc:minimum:
extends: .test
variables:
BASE_CONFIG: "--with-minimum"
CFLAGS: "-O2"
gcc:medium:
extends: .test
variables:
BASE_CONFIG: "--with-minimum"
CONFIG: "--with-threads --with-tree --with-xpath --with-output --with-html --with-iso8859x --with-valid"
CFLAGS: "-O2"
gcc:legacy:
extends: .test
only:
- schedules
variables:
BASE_CONFIG: "--with-legacy --with-python"
CFLAGS: "-O2"
gcc:static:
extends: .test
variables:
CONFIG: "--disable-shared --without-python --without-modules"
CFLAGS: "-O2"
clang:asan:
extends: .test
tags:
- asan
variables:
CONFIG: "--without-python"
CC: clang
CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=address,undefined,integer -fno-sanitize-recover=all"
UBSAN_OPTIONS: "print_stacktrace=1"
ASAN_SYMBOLIZER_PATH: "$CI_PROJECT_DIR/.gitlab-ci/llvm-symbolizer"
clang:msan:
extends: .test
# only:
# - schedules
variables:
CONFIG: "--without-python --without-zlib"
CC: clang
CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=memory"
MSAN_SYMBOLIZER_PATH: "$CI_PROJECT_DIR/.gitlab-ci/llvm-symbolizer"
.mingw:
tags:
- win32-ps
variables:
BASE_CONFIG: "--with-http --with-schematron --with-zlib --with-python"
# Python is disabled for now, see #658
CONFIG: "--with-docs --without-python"
CHERE_INVOKING: "yes"
before_script:
- $Env:Path="C:\msys64\usr\bin;$Env:Path"
- bash -lc 'sh .gitlab-ci/setup_mingw.sh autotools'
script:
- bash -lc 'sh .gitlab-ci/test.sh'
cache:
key: "$MSYSTEM"
paths:
- xmlconf/
mingw:w64-x86_64:shared:
extends: .mingw
variables:
CFLAGS: "-O2"
MSYSTEM: MINGW64
mingw:w64-i686:shared:
extends: .mingw
only:
- schedules
variables:
CFLAGS: "-O2"
MSYSTEM: MINGW32
# Disabled, GCC missing?
.mingw:msys:shared:
extends: .mingw
variables:
CFLAGS: "-O2"
MSYSTEM: MSYS
.cmake:linux:
image: registry.gitlab.gnome.org/gnome/libxml2
before_script:
- rm -rf libxml2-build
- mkdir libxml2-build
- ln -s /tests/xmlconf .
script:
- sh .gitlab-ci/test_cmake.sh
artifacts:
paths:
- libxml2-$CI_COMMIT_SHORT_SHA-$SUFFIX.tar.gz
expire_in: 1 day
cmake:linux:gcc:shared:
extends: .cmake:linux
variables:
BUILD_SHARED_LIBS: "ON"
CONFIG: "-DLIBXML2_WITH_DOCS=ON"
CC: gcc
SUFFIX: linux-gcc-shared
cmake:linux:gcc:static:
extends: .cmake:linux
only:
- schedules
variables:
BUILD_SHARED_LIBS: "OFF"
CC: gcc
SUFFIX: linux-gcc-static
cmake:linux:clang:shared:
extends: .cmake:linux
only:
- schedules
variables:
BUILD_SHARED_LIBS: "ON"
CC: clang
SUFFIX: linux-clang-shared
cmake:linux:clang:static:
extends: .cmake:linux
only:
- schedules
variables:
BUILD_SHARED_LIBS: "OFF"
CC: clang
SUFFIX: linux-clang-static
.cmake:mingw:
tags:
- win32-ps
variables:
CHERE_INVOKING: "yes"
before_script:
- $Env:Path="C:\msys64\usr\bin;$Env:Path"
- bash -lc 'sh .gitlab-ci/setup_mingw.sh cmake ninja'
script:
- bash -lc 'sh .gitlab-ci/test_cmake.sh -G Ninja'
cache:
key: "$MSYSTEM"
paths:
- xmlconf/
artifacts:
paths:
- libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:SUFFIX.tar.gz
expire_in: 1 day
cmake:mingw:w64-i686:shared:
extends: .cmake:mingw
only:
- schedules
variables:
BUILD_SHARED_LIBS: "ON"
CONFIG: "-DLIBXML2_WITH_DOCS=ON"
MSYSTEM: MINGW32
SUFFIX: mingw-w64-i686-shared
cmake:mingw:w64-i686:static:
extends: .cmake:mingw
# only:
# - schedules
variables:
BUILD_SHARED_LIBS: "OFF"
MSYSTEM: MINGW32
SUFFIX: mingw-w64-i686-static
cmake:mingw:w64-x86_64:shared:
extends: .cmake:mingw
# only:
# - schedules
variables:
BUILD_SHARED_LIBS: "ON"
MSYSTEM: MINGW64
SUFFIX: mingw-w64-x86_64-shared
cmake:mingw:w64-x86_64:static:
extends: .cmake:mingw
only:
- schedules
variables:
BUILD_SHARED_LIBS: "OFF"
MSYSTEM: MINGW64
SUFFIX: mingw-w64-x86_64-static
.cmake:msvc:
tags:
- win32-ps
variables:
# MSVC warns when casting `const char **` to `void *` which is wrong.
# Disable warning C4090.
CFLAGS: /WX /wd4090
CMAKE_VERSION: 3.19.4
script:
- .gitlab-ci/Test-Msvc
cache:
key: "msvc"
paths:
- cmake-$Env:CMAKE_VERSION-win64-x64/
- xmlconf/
- 7za.exe
artifacts:
paths:
- libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:CMAKE_GENERATOR_TOOLSET-$Env:CMAKE_GENERATOR_PLATFORM-$Env:SUFFIX.7z
expire_in: 1 day
.cmake:msvc:v141:
extends: .cmake:msvc
variables:
CMAKE_GENERATOR: Visual Studio 15 2017
CMAKE_GENERATOR_TOOLSET: v141
.cmake:msvc:v141:x64:
extends: .cmake:msvc:v141
variables:
CMAKE_GENERATOR_PLATFORM: x64
cmake:msvc:v141:x64:shared:
extends: .cmake:msvc:v141:x64
variables:
BUILD_SHARED_LIBS: "ON"
SUFFIX: shared
cmake:msvc:v141:x64:static:
extends: .cmake:msvc:v141:x64
only:
- schedules
variables:
BUILD_SHARED_LIBS: "OFF"
SUFFIX: static
.cmake:msvc:v141:x86:
extends: .cmake:msvc:v141
only:
- schedules
variables:
CMAKE_GENERATOR_PLATFORM: Win32
cmake:msvc:v141:x86:shared:
extends: .cmake:msvc:v141:x86
only:
- schedules
variables:
BUILD_SHARED_LIBS: "ON"
SUFFIX: shared
cmake:msvc:v141:x86:static:
extends: .cmake:msvc:v141:x86
variables:
BUILD_SHARED_LIBS: "OFF"
SUFFIX: static
meson:
image: registry.gitlab.gnome.org/gnome/libxml2
before_script:
- ln -s /tests/xmlconf .
script:
- sh .gitlab-ci/test_meson.sh
cmake:linux:gcc:shared:
extends: .cmake:linux
variables:
BUILD_SHARED_LIBS: "ON"
CC: gcc
SUFFIX: linux-gcc-shared
dist:
image: registry.gitlab.gnome.org/gnome/libxml2
script:
- sh .gitlab-ci/dist.sh
- echo "TARBALL_ARTIFACT_PATH=$(ls libxml2-dist/*.tar.xz)" >> build.env
artifacts:
paths:
- libxml2-dist/*.tar.xz
reports:
dotenv: build.env
pages:
needs: [install]
script:
- cp -r install/share/doc/libxml2 public
- cp doc/_redirects public
artifacts:
paths:
- public
only:
- master@GNOME/libxml2
downstream-lxml:
image: registry.gitlab.gnome.org/gnome/libxml2
needs: [install]
script:
- sh .gitlab-ci/downstream-lxml.sh
downstream-nokogiri:
# owner: @flavorjones
image: ghcr.io/sparklemotion/nokogiri-test:upstream-libxml
script:
- .gitlab-ci/downstream-nokogiri.sh
downstream-php:
image: registry.gitlab.gnome.org/gnome/libxml2
needs: [install]
script:
- sh .gitlab-ci/downstream-php.sh
+58
View File
@@ -0,0 +1,58 @@
# The image is also used for libxslt.
#
# package required for
# ------------------------------------------------------------
# libclang-rt-dev sanitizer runtimes
# llvm llvm-symbolizer (for sanitizer backtraces)
# git libxslt, downstream projects
# libgcrypt-dev libxslt
# xz-utils make dist
# doxygen documentation
# xsltproc documentation
# docbook-xsl documentation
FROM ubuntu:26.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
curl git ca-certificates \
autoconf automake libtool pkg-config \
make gcc clang llvm libclang-rt-dev \
zlib1g-dev libgcrypt-dev \
python3-dev \
cmake meson \
xz-utils \
doxygen xsltproc docbook-xsl
WORKDIR /tests
RUN curl https://www.w3.org/XML/Test/xmlts20080827.tar.gz |tar xz
# XML::LibXML uses Alien::Libxml2 which has a huge dependency chain.
# We try to install most dependencies with apt. We also require
# libxml2-dev to stop Alien::Libxml2 from downloading and building
# libxml2 on its own.
RUN apt-get install -y --no-install-recommends \
libperl-dev libxml2-dev cpanminus \
libalien-build-perl \
libio-socket-ssl-perl \
libsort-versions-perl \
liburi-perl \
libxml-namespacesupport-perl \
libxml-sax-perl \
libyaml-perl
RUN cpanm -n Alien::Libxml2
RUN apt-get remove -y libxml2-dev
# PHP
RUN apt-get install -y --no-install-recommends \
bison re2c libsqlite3-dev
# lxml
# ubuntu cython3 is too old, so we install using pip
RUN apt-get install -y --no-install-recommends \
python3-pip
RUN pip3 install Cython --break-system-packages
# xmlstarlet
RUN apt-get install -y --no-install-recommends \
docbook-xsl-ns
+5
View File
@@ -0,0 +1,5 @@
# Image used to generate documentation with a recent version of Doxygen.
# 1.14.0 fixes an important bug.
FROM archlinux:base-devel
RUN pacman -Syu --noconfirm doxygen libxslt docbook-xsl git
+46
View File
@@ -0,0 +1,46 @@
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-not (Test-Path 7za.exe)) {
Invoke-WebRequest `
-Uri https://www.7-zip.org/a/7z1900-extra.7z `
-OutFile 7z1900-extra.7z
cmake -E tar xf 7z1900-extra.7z 7za.exe
}
if (-not (Test-Path xmlconf)) {
Invoke-WebRequest `
-Uri https://www.w3.org/XML/Test/xmlts20080827.tar.gz `
-OutFile xmlts20080827.tar.gz ;
.\7za.exe x xmlts20080827.tar.gz
.\7za.exe x xmlts20080827.tar
}
cmake `
-G "Visual Studio 16 2019" `
-DBUILD_SHARED_LIBS="$Env:BUILD_SHARED_LIBS" `
-DCMAKE_INSTALL_PREFIX=libxml2-install `
-DLIBXML2_WITH_SCHEMATRON=ON `
-DLIBXML2_WITH_ICONV=OFF `
-DLIBXML2_WITH_PYTHON=OFF `
-DLIBXML2_WITH_ZLIB=OFF `
-S . -B libxml2-build
if ($LastExitCode -ne 0) {
throw "cmake failed"
}
cmake --build libxml2-build --config Debug --target install
cmake --build libxml2-build --config Release --target install
New-Item -ItemType Directory libxml2-install\share\libxml2
Copy-Item Copyright libxml2-install\share\libxml2
cd libxml2-build
ctest -C Debug -VV
if ($LastExitCode -ne 0) {
throw "ctest failed"
}
ctest -C Release -VV
if ($LastExitCode -ne 0) {
throw "ctest failed"
}
cd ..
.\7za.exe a libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:CMAKE_GENERATOR_TOOLSET-$Env:CMAKE_GENERATOR_PLATFORM-$Env:SUFFIX.7z .\libxml2-install\*
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
set -e
mkdir -p libxml2-dist
cd libxml2-dist
sh ../autogen.sh --with-docs --with-legacy
VERSION=$(cat libxml-2.0.pc | grep Version | cut -d" " -f2)
# Build doc into the dist: https://gitlab.gnome.org/GNOME/libxml2/-/issues/1048
cd doc
make
cd ..
make distcheck V=1 DISTCHECK_CONFIGURE_FLAGS='--with-docs --with-legacy'
tar xJvf libxml2-$VERSION.tar.xz
cp -rf doc libxml2-$VERSION/dist-doc
tar cJvf libxml2-$VERSION.tar.xz libxml2-$VERSION
if [ -z "$CI_COMMIT_TAG" ]; then
mv libxml2-$VERSION.tar.xz libxml2-git-$CI_COMMIT_SHORT_SHA.tar.xz
fi
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
set -e
srcdir=$(pwd)
installdir="$srcdir/install"
export PKG_CONFIG_PATH="$installdir/lib/pkgconfig"
git clone --depth 1 https://github.com/lxml/lxml.git
cd lxml
make
LD_LIBRARY_PATH="$installdir/lib" make TESTFLAGS='' test
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e
export LIBXML_DIR=$(pwd)
export MAKEFLAGS=-j$(nproc)
export NOCONFIGURE=1
./autogen.sh
git clone https://github.com/sparklemotion/nokogiri
cd nokogiri
gem install bundler:2.7.2
bundle _2.7.2_ install
bundle exec rake compile -- --with-xml2-source-dir=${LIBXML_DIR} --disable-xml2-legacy
bundle exec rake test
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
set -e
srcdir=$(pwd)
installdir="$srcdir/install"
export PKG_CONFIG_PATH="$installdir/lib/pkgconfig"
git clone --depth 1 https://github.com/php/php-src.git
cd php-src
./buildconf
./configure --with-xsl --enable-soap --enable-debug
make -j$(nproc)
make TESTS=" \
-g FAIL \
--show-diff \
--no-progress \
ext/dom \
ext/libxml \
ext/simplexml \
ext/soap \
ext/xml \
ext/xmlreader \
ext/xmlwriter \
ext/xsl \
" test
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
set -e
srcdir=$(pwd)
mkdir -p install
installdir="$srcdir/install"
export PKG_CONFIG_PATH="$installdir/lib/pkgconfig"
sh autogen.sh "--prefix=$installdir" --with-docs --with-schematron --with-zlib
make -j$(nproc)
make install
# Make system XML catalog available
ln -s /etc install/etc
git clone --depth 1 https://gitlab.gnome.org/GNOME/libxslt.git
cd libxslt
sh autogen.sh \
"--prefix=$installdir" \
--without-python
make -j$(nproc)
make install
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
# Newer versions of llvm-symbolizer require libxml2 themselves. Running
# a test program with LD_LIBRARY_PATH set to .libs makes llvm-symbolizer
# pick up the tested development version of libxml2 which breaks
# completely if the build is instrumented with ASan. This wrapper script
# invokes llvm-symbolizer with an empty LD_LIBRARY_PATH.
LD_LIBRARY_PATH='' llvm-symbolizer "$@"
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
pacman --noconfirm -Syu
prefix=
if [ -n "$MINGW_PACKAGE_PREFIX" ]; then
prefix="${MINGW_PACKAGE_PREFIX}-"
fi
for module in docbook-xsl doxygen libiconv python xsltproc xz zlib "$@"; do
pacman --noconfirm -S --needed ${prefix}$module
done
mkdir -p libxml2-build
if [ ! -e xmlconf ]; then
wget https://www.w3.org/XML/Test/xmlts20080827.tar -O - |
tar -x
fi
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
cd libxml2-build
sh ../autogen.sh $BASE_CONFIG $CONFIG || cat config.log
make -j$(nproc) V=1 CFLAGS="$CFLAGS -Werror"
make CFLAGS="$CFLAGS -Werror" check
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
set -e
CFLAGS="-Werror $CFLAGS" \
cmake "$@" \
-DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \
-DCMAKE_INSTALL_PREFIX=libxml2-install \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DLIBXML2_WITH_HTTP=ON \
-DLIBXML2_WITH_SCHEMATRON=ON \
-DLIBXML2_WITH_ZLIB=ON \
-DLIBXML2_WITH_PYTHON=ON \
$CONFIG \
-S . -B libxml2-build
cmake --build libxml2-build --target install
(cd libxml2-build && ctest -VV)
mkdir -p libxml2-install/share/libxml2
cp Copyright libxml2-install/share/libxml2
(cd libxml2-install &&
tar -czf ../libxml2-$CI_COMMIT_SHORT_SHA-$SUFFIX.tar.gz *)
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
set -e
# compile with the following warnings:
# --warnlevel 3 : passes to the compiler -Wall -Wextra -Wpedantic
# --werror : passes to the compiler -Werror
# --default-library : can be 'shared', 'static' or 'both'
meson setup \
--warnlevel 3 \
--werror \
--buildtype=debugoptimized \
--default-library shared \
-Ddocs=enabled \
-Dhttp=enabled \
-Dschematron=enabled \
-Dzlib=enabled \
-Dpython=enabled \
builddir
ninja -C builddir
meson test --verbose -C builddir
+847
View File
@@ -0,0 +1,847 @@
cmake_minimum_required(VERSION 3.18)
file(READ "VERSION" VERSION)
string(STRIP ${VERSION} VERSION)
if(${VERSION} MATCHES [[([0-9]+)\.([0-9]+)\.([0-9]+)]])
set(LIBXML_MAJOR_VERSION ${CMAKE_MATCH_1})
set(LIBXML_MINOR_VERSION ${CMAKE_MATCH_2})
set(LIBXML_MICRO_VERSION ${CMAKE_MATCH_3})
endif()
project(libxml2 VERSION ${VERSION} LANGUAGES C)
set(CMAKE_C_STANDARD 11)
include(CheckCSourceCompiles)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CMakeDependentOption)
include(CMakePackageConfigHelpers)
include(CMakePushCheckState)
include(FindPkgConfig)
include(GNUInstallDirs)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(LIBXML2_WITH_CATALOG "Add the Catalog support" ON)
option(LIBXML2_WITH_DEBUG "Add the debugging module" ON)
option(LIBXML2_WITH_DOCS "Build documentation" OFF)
option(LIBXML2_WITH_HTML "Add the HTML support" ON)
option(LIBXML2_WITH_HTTP "ABI compatibility for removed HTTP support" OFF)
option(LIBXML2_WITH_ICONV "Add ICONV support" ON)
option(LIBXML2_WITH_ICU "Add ICU support" OFF)
option(LIBXML2_WITH_ISO8859X "Add ISO8859X support if no iconv" ON)
option(LIBXML2_WITH_LEGACY "Add deprecated APIs for compatibility" OFF)
option(LIBXML2_WITH_MODULES "Add the dynamic modules support" ON)
option(LIBXML2_WITH_OUTPUT "Add the serialization support" ON)
option(LIBXML2_WITH_PATTERN "Add the xmlPattern selection interface" ON)
option(LIBXML2_WITH_PROGRAMS "Build programs" ON)
option(LIBXML2_WITH_PUSH "Add the PUSH parser interfaces" ON)
option(LIBXML2_WITH_PYTHON "Build Python bindings" OFF)
option(LIBXML2_WITH_READLINE "readline support for xmllint shell" OFF)
option(LIBXML2_WITH_REGEXPS "Add Regular Expressions support" ON)
option(LIBXML2_WITH_SAX1 "Add the older SAX1 interface" ON)
option(LIBXML2_WITH_TESTS "Build tests" ON)
option(LIBXML2_WITH_THREADS "Add multithread support" ON)
option(LIBXML2_WITH_TLS "Enable thread-local storage" OFF)
option(LIBXML2_WITH_VALID "Add the DTD validation support" ON)
if(WIN32 OR CYGWIN)
option(LIBXML2_WITH_WINPATH "Handle Windows-styled path" ON)
else()
option(LIBXML2_WITH_WINPATH "Handle Windows-styled path" OFF)
endif()
option(LIBXML2_WITH_XINCLUDE "Add the XInclude support" ON)
option(LIBXML2_WITH_XPATH "Add the XPATH support" ON)
cmake_dependent_option(
LIBXML2_WITH_ZLIB "Use libz" OFF
"NOT LIBXML2_WITH_LEGACY" ON)
cmake_dependent_option(
LIBXML2_WITH_C14N "Add the Canonicalization support" ON
"LIBXML2_WITH_OUTPUT;LIBXML2_WITH_XPATH" OFF)
cmake_dependent_option(
LIBXML2_WITH_HISTORY "history support for xmllint shell" OFF
"LIBXML2_WITH_READLINE" OFF)
cmake_dependent_option(
LIBXML2_WITH_READER "Add the xmlReader parsing interface" ON
"LIBXML2_WITH_PUSH" OFF)
cmake_dependent_option(
LIBXML2_WITH_SCHEMAS "Add XML Schemas 1.0 support" ON
"LIBXML2_WITH_PATTERN;LIBXML2_WITH_REGEXPS" OFF)
cmake_dependent_option(
LIBXML2_WITH_SCHEMATRON "Add Schematron support" OFF
"LIBXML2_WITH_PATTERN;LIBXML2_WITH_XPATH" OFF)
cmake_dependent_option(
LIBXML2_WITH_THREAD_ALLOC "Add per-thread malloc hooks" OFF
"LIBXML2_WITH_THREADS" OFF)
cmake_dependent_option(
LIBXML2_WITH_WRITER "Add the xmlWriter saving interface" ON
"LIBXML2_WITH_OUTPUT;LIBXML2_WITH_PUSH" OFF)
cmake_dependent_option(
LIBXML2_WITH_XPTR "Add the XPointer support" ON
"LIBXML2_WITH_XPATH" OFF)
cmake_dependent_option(
LIBXML2_WITH_RELAXNG "Add Relax-NG support" ON
"LIBXML2_WITH_REGEXPS;LIBXML2_WITH_SCHEMAS" OFF)
if(LIBXML2_WITH_PYTHON)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
#set(LIBXML2_PYTHON_INSTALL_DIR ${Python3_SITEARCH} CACHE PATH "Python bindings install directory")
set(LIBXML2_PYTHON_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/python"
CACHE PATH "Python bindings install directory")
endif()
foreach(VARIABLE IN ITEMS WITH_C14N WITH_CATALOG WITH_DEBUG WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_RELAXNG WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_VALID WITH_WINPATH WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_ZLIB)
if(LIBXML2_${VARIABLE})
set(${VARIABLE} 1)
else()
set(${VARIABLE} 0)
endif()
endforeach()
set(LIBXML_VERSION ${VERSION})
set(LIBXML_VERSION_EXTRA "")
math(EXPR LIBXML_VERSION_NUMBER "
${LIBXML_MAJOR_VERSION} * 10000 +
${LIBXML_MINOR_VERSION} * 100 +
${LIBXML_MICRO_VERSION}
")
set(MODULE_EXTENSION "${CMAKE_SHARED_LIBRARY_SUFFIX}")
if(LIBXML2_WITH_ICONV)
find_package(Iconv REQUIRED)
endif()
if(LIBXML2_WITH_ICU)
find_package(ICU REQUIRED COMPONENTS uc)
endif()
if(LIBXML2_WITH_THREADS)
find_package(Threads REQUIRED)
set(THREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
list(APPEND CMAKE_REQUIRED_LIBRARIES Threads::Threads)
endif()
if(LIBXML2_WITH_ZLIB)
find_package(ZLIB REQUIRED)
endif()
check_c_source_compiles("
void __attribute__((destructor))
f(void) {}
int main(void) { return 0; }
" HAVE_FUNC_ATTRIBUTE_DESTRUCTOR)
check_symbol_exists(getentropy "sys/random.h" HAVE_DECL_GETENTROPY)
check_symbol_exists(glob "glob.h" HAVE_DECL_GLOB)
check_symbol_exists(mmap "sys/mman.h" HAVE_DECL_MMAP)
check_include_files(stdint.h HAVE_STDINT_H)
if(LIBXML2_WITH_READLINE)
check_library_exists(readline readline "" HAVE_LIBREADLINE)
if (LIBXML2_WITH_HISTORY)
check_library_exists(history append_history "" HAVE_LIBHISTORY)
endif()
endif()
if(LIBXML2_WITH_TLS)
check_c_source_compiles(
"_Thread_local int v; int main(){return 0;}"
XML_THREAD_LOCAL_C11
)
if (XML_THREAD_LOCAL_C11)
set(XML_THREAD_LOCAL "_Thread_local")
else()
check_c_source_compiles(
"__thread int v; int main(){return 0;}"
XML_THREAD_LOCAL_THREAD
)
if (XML_THREAD_LOCAL_THREAD)
set(XML_THREAD_LOCAL "__thread")
else()
check_c_source_compiles(
"__declspec(thread) int v; int main(){return 0;}"
XML_THREAD_LOCAL_DECLSPEC
)
if (XML_THREAD_LOCAL_DECLSPEC)
set(XML_THREAD_LOCAL "__declspec(thread)")
endif()
endif()
endif()
endif()
# Headers which are private.
set(
LIBXML2_PRIVATE_HDRS
include/private/buf.h
include/private/cata.h
include/private/dict.h
include/private/enc.h
include/private/entities.h
include/private/error.h
include/private/globals.h
include/private/html.h
include/private/io.h
include/private/lint.h
include/private/memory.h
include/private/parser.h
include/private/regexp.h
include/private/save.h
include/private/string.h
include/private/threads.h
include/private/tree.h
include/private/xinclude.h
include/private/xpath.h
)
set(
LIBXML2_HDRS
include/libxml/c14n.h
include/libxml/catalog.h
include/libxml/chvalid.h
include/libxml/debugXML.h
include/libxml/dict.h
include/libxml/encoding.h
include/libxml/entities.h
include/libxml/globals.h
include/libxml/hash.h
include/libxml/HTMLparser.h
include/libxml/HTMLtree.h
include/libxml/list.h
include/libxml/nanoftp.h
include/libxml/nanohttp.h
include/libxml/parser.h
include/libxml/parserInternals.h
include/libxml/pattern.h
include/libxml/relaxng.h
include/libxml/SAX.h
include/libxml/SAX2.h
include/libxml/schemasInternals.h
include/libxml/schematron.h
include/libxml/threads.h
include/libxml/tree.h
include/libxml/uri.h
include/libxml/valid.h
include/libxml/xinclude.h
include/libxml/xlink.h
include/libxml/xmlIO.h
include/libxml/xmlautomata.h
include/libxml/xmlerror.h
include/libxml/xmlexports.h
include/libxml/xmlmemory.h
include/libxml/xmlmodule.h
include/libxml/xmlreader.h
include/libxml/xmlregexp.h
include/libxml/xmlsave.h
include/libxml/xmlschemas.h
include/libxml/xmlschemastypes.h
include/libxml/xmlstring.h
include/libxml/xmlunicode.h
include/libxml/xmlwriter.h
include/libxml/xpath.h
include/libxml/xpathInternals.h
include/libxml/xpointer.h
)
set(
LIBXML2_SRCS
buf.c
chvalid.c
dict.c
encoding.c
entities.c
error.c
globals.c
hash.c
list.c
parser.c
parserInternals.c
SAX2.c
threads.c
tree.c
uri.c
valid.c
xmlIO.c
xmlmemory.c
xmlstring.c
)
if(LIBXML2_WITH_C14N)
list(APPEND LIBXML2_SRCS c14n.c)
endif()
if(LIBXML2_WITH_CATALOG)
list(APPEND LIBXML2_SRCS catalog.c)
endif()
if(LIBXML2_WITH_DEBUG)
list(APPEND LIBXML2_SRCS debugXML.c)
endif()
if(LIBXML2_WITH_HTML)
list(APPEND LIBXML2_SRCS HTMLparser.c HTMLtree.c)
endif()
if(LIBXML2_WITH_HTTP)
list(APPEND LIBXML2_SRCS nanohttp.c)
endif()
if(LIBXML2_WITH_MODULES)
list(APPEND LIBXML2_SRCS xmlmodule.c)
endif()
if(LIBXML2_WITH_OUTPUT)
list(APPEND LIBXML2_SRCS xmlsave.c)
endif()
if(LIBXML2_WITH_PATTERN)
list(APPEND LIBXML2_SRCS pattern.c)
endif()
if(LIBXML2_WITH_READER)
list(APPEND LIBXML2_SRCS xmlreader.c)
endif()
if(LIBXML2_WITH_REGEXPS)
list(APPEND LIBXML2_SRCS xmlregexp.c)
endif()
if(LIBXML2_WITH_RELAXNG)
list(APPEND LIBXML2_SRCS relaxng.c)
endif()
if(LIBXML2_WITH_SCHEMAS)
list(APPEND LIBXML2_SRCS xmlschemas.c xmlschemastypes.c)
endif()
if(LIBXML2_WITH_SCHEMATRON)
list(APPEND LIBXML2_SRCS schematron.c)
endif()
if(LIBXML2_WITH_WRITER)
list(APPEND LIBXML2_SRCS xmlwriter.c)
endif()
if(LIBXML2_WITH_XINCLUDE)
list(APPEND LIBXML2_SRCS xinclude.c)
endif()
if(LIBXML2_WITH_XPATH)
list(APPEND LIBXML2_SRCS xpath.c)
endif()
if(LIBXML2_WITH_XPTR)
list(APPEND LIBXML2_SRCS xlink.c xpointer.c)
endif()
if(WIN32)
list(APPEND LIBXML2_SRCS win32/libxml2.rc)
file(
WRITE
${CMAKE_CURRENT_BINARY_DIR}/rcVersion.h
"#define LIBXML_MAJOR_VERSION ${LIBXML_MAJOR_VERSION}\n"
"#define LIBXML_MINOR_VERSION ${LIBXML_MINOR_VERSION}\n"
"#define LIBXML_MICRO_VERSION ${LIBXML_MICRO_VERSION}\n"
"#define LIBXML_DOTTED_VERSION \"${VERSION}\"\n"
)
endif()
add_library(LibXml2 ${LIBXML2_HDRS} ${LIBXML2_SRCS} ${LIBXML2_PRIVATE_HDRS})
add_library(LibXml2::LibXml2 ALIAS LibXml2)
target_include_directories(
LibXml2
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/libxml2>
)
if(LIBXML2_WITH_MODULES)
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN)
cmake_pop_check_state()
if(HAVE_DLOPEN)
target_link_libraries(LibXml2 PRIVATE ${CMAKE_DL_LIBS})
list(TRANSFORM CMAKE_DL_LIBS PREPEND "-l" REGEX "^[^-]" OUTPUT_VARIABLE MODULE_LIBS)
else()
check_library_exists(dld shl_load "" HAVE_SHLLOAD)
if(HAVE_SHLLOAD)
target_link_libraries(LibXml2 PRIVATE dld)
set(MODULE_LIBS "-ldld")
endif()
endif()
endif()
if(UNIX)
target_link_libraries(LibXml2 PRIVATE m)
set(LIBM "-lm")
endif()
if(WIN32)
target_link_libraries(LibXml2 PRIVATE bcrypt)
set(CRYPTO_LIBS "-lbcrypt")
endif()
if(LIBXML2_WITH_ICONV)
target_link_libraries(LibXml2 PRIVATE Iconv::Iconv)
if(NOT Iconv_IS_BUILT_IN)
set(ICONV_LIBS "-liconv")
endif()
endif()
if(LIBXML2_WITH_ICU)
target_link_libraries(LibXml2 PRIVATE ICU::uc)
set(ICU_LDFLAGS "-licuuc")
list(APPEND XML_PRIVATE_LIBS "${ICU_LDFLAGS}")
pkg_check_modules(ICU_PC IMPORTED_TARGET icu-uc)
if(ICU_PC_FOUND)
list(APPEND XML_PC_REQUIRES icu-uc)
else()
list(APPEND XML_PC_LIBS "${ICU_LDFLAGS}")
endif()
endif()
if(LIBXML2_WITH_THREADS)
target_link_libraries(LibXml2 PRIVATE Threads::Threads)
endif()
if(LIBXML2_WITH_ZLIB)
target_link_libraries(LibXml2 PRIVATE ZLIB::ZLIB)
set(ZLIB_LDFLAGS "-lz")
list(APPEND XML_PRIVATE_LIBS "${ZLIB_LDFLAGS}")
pkg_check_modules(ZLIB_PC IMPORTED_TARGET zlib)
if(ZLIB_PC_FOUND)
list(APPEND XML_PC_REQUIRES zlib)
else()
list(APPEND XML_PC_LIBS "${ZLIB_LDFLAGS}")
endif()
endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
# These compiler flags can break the checks above so keep them here.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -Wshadow \
-Wpointer-arith -Wcast-align -Wwrite-strings \
-Wstrict-prototypes -Wmissing-prototypes \
-Wno-long-long -Wno-format-extra-args -Wno-array-bounds")
endif()
set(LIBXML_MINOR_COMPAT 14)
math(EXPR LIBXML_SOVERSION "${LIBXML_MAJOR_VERSION} + ${LIBXML_MINOR_COMPAT}")
math(EXPR LIBXML_AGE "${LIBXML_MINOR_VERSION} - ${LIBXML_MINOR_COMPAT}")
math(EXPR LIBXML_MACHO_COMPAT "${LIBXML_MAJOR_VERSION} + ${LIBXML_MINOR_VERSION} + 1")
set_target_properties(
LibXml2
PROPERTIES
IMPORT_PREFIX lib
OUTPUT_NAME xml2
POSITION_INDEPENDENT_CODE ON
PREFIX lib
VERSION "${LIBXML_SOVERSION}.${LIBXML_AGE}.${LIBXML_MICRO_VERSION}"
SOVERSION ${LIBXML_SOVERSION}
MACHO_COMPATIBILITY_VERSION ${LIBXML_MACHO_COMPAT}
MACHO_CURRENT_VERSION "${LIBXML_MACHO_COMPAT}.${LIBXML_MICRO_VERSION}"
)
if(MSVC)
if(BUILD_SHARED_LIBS)
set_target_properties(
LibXml2
PROPERTIES
DEBUG_POSTFIX d
)
else()
set_target_properties(
LibXml2
PROPERTIES
DEBUG_POSTFIX sd
MINSIZEREL_POSTFIX s
RELEASE_POSTFIX s
RELWITHDEBINFO_POSTFIX s
)
endif()
endif()
set(XML_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}")
install(FILES ${LIBXML2_HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libxml2/libxml COMPONENT development)
install(
TARGETS LibXml2
EXPORT LibXml2
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime NAMELINK_COMPONENT development
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
)
if(MSVC AND BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:LibXml2> DESTINATION ${CMAKE_INSTALL_BINDIR} CONFIGURATIONS Debug RelWithDebInfo COMPONENT debug)
endif()
if(LIBXML2_WITH_PROGRAMS)
add_executable(xmllint xmllint.c shell.c lintmain.c)
set(PROGRAMS xmllint)
if(LIBXML2_WITH_CATALOG AND LIBXML2_WITH_OUTPUT)
add_executable(xmlcatalog xmlcatalog.c)
list(APPEND PROGRAMS xmlcatalog)
endif()
foreach(PROGRAM ${PROGRAMS})
add_executable(LibXml2::${PROGRAM} ALIAS ${PROGRAM})
target_link_libraries(${PROGRAM} LibXml2)
if(HAVE_LIBHISTORY)
target_link_libraries(${PROGRAM} history)
endif()
if(HAVE_LIBREADLINE)
target_link_libraries(${PROGRAM} readline)
endif()
install(TARGETS ${PROGRAM} EXPORT LibXml2 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT programs)
endforeach()
if(LIBXML2_WITH_ZLIB)
target_link_libraries(xmllint ZLIB::ZLIB)
endif()
endif()
if(LIBXML2_WITH_TESTS)
enable_testing()
set(
TESTS
runtest
runxmlconf
runsuite
testapi
testcatalog
testchar
testdict
testModule
testlimits
testparser
testrecurse
)
foreach(TEST ${TESTS})
add_executable(${TEST} ${TEST}.c)
target_link_libraries(${TEST} LibXml2)
endforeach()
if(Threads_FOUND)
foreach(TEST runtest)
if(LIBXML2_WITH_ZLIB)
target_link_libraries(${TEST} ZLIB::ZLIB Threads::Threads)
else()
target_link_libraries(${TEST} Threads::Threads)
endif()
endforeach()
endif()
add_test(NAME runtest COMMAND runtest --out ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_test(NAME runsuite COMMAND runsuite WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/xmlconf/xmlconf.xml)
add_test(NAME runxmlconf COMMAND runxmlconf WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
add_test(NAME testapi COMMAND testapi)
add_test(NAME testcatalog COMMAND testcatalog)
add_test(NAME testchar COMMAND testchar)
add_test(NAME testdict COMMAND testdict)
add_test(NAME testparser COMMAND testparser WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_test(NAME testrecurse COMMAND testrecurse WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
function(ADD_SUITE test_dir program)
file(GLOB_RECURSE files_to_process CONFIGURE_DEPENDS "./test/${test_dir}/*.script")
foreach(file_path ${files_to_process})
file(RELATIVE_PATH file_relative "${CMAKE_CURRENT_SOURCE_DIR}" "${file_path}")
get_filename_component(dir_path ${file_relative} DIRECTORY)
get_filename_component(base_name ${file_relative} NAME_WE)
get_filename_component(extension ${file_relative} EXT)
set(actual_stdout "${CMAKE_CURRENT_BINARY_DIR}/result/${test_dir}/${base_name}")
set(actual_stderr "${CMAKE_CURRENT_BINARY_DIR}/result/${test_dir}/${base_name}.err")
set(expected_stdout "${CMAKE_CURRENT_SOURCE_DIR}/result/${test_dir}/${base_name}")
set(expected_stderr "${CMAKE_CURRENT_SOURCE_DIR}/result/${test_dir}/${base_name}.err")
set(xml_path "${CMAKE_CURRENT_SOURCE_DIR}/${dir_path}/${base_name}.xml")
set(sgml_path "${CMAKE_CURRENT_SOURCE_DIR}/${dir_path}/${base_name}.sgml")
if(EXISTS "${xml_path}")
set(input_file "./${dir_path}/${base_name}.xml")
elseif(EXISTS "${sgml_path}")
set(input_file "./${dir_path}/${base_name}.sgml")
else()
message(FATAL_ERROR "Neither XML nor SGML exists for: ${dir_path}/${base_name}")
endif()
add_test(
NAME ${test_dir}_${base_name}
COMMAND ${CMAKE_COMMAND}
-DPROG=$<TARGET_FILE:${program}>
-DSTDIN=./${dir_path}/${base_name}.script
-DXML=${input_file}
-DSTDOUT=${actual_stdout}
-DSTDERR=${actual_stderr}
-DEXPECTED_STDOUT=${expected_stdout}
-DEXPECTED_STDERR=${expected_stderr}
-DWORKDIR=${CMAKE_CURRENT_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/run_and_diff.cmake
)
endforeach()
endfunction()
if(LIBXML2_WITH_PROGRAMS)
add_suite("scripts" xmllint)
add_suite("catalogs" xmlcatalog)
add_test(
NAME catalog_add_del
COMMAND ${CMAKE_COMMAND}
-DXMLCAT=$<TARGET_FILE:xmlcatalog>
-DEXPECTED_FULL=${CMAKE_CURRENT_SOURCE_DIR}/result/catalogs/mycatalog.full
-DEXPECTED_EMPTY=${CMAKE_CURRENT_SOURCE_DIR}/result/catalogs/mycatalog.empty
-P ${CMAKE_CURRENT_SOURCE_DIR}/test_xmlcatalog_add_del.cmake
)
endif()
endif()
if(LIBXML2_WITH_DOCS OR LIBXML2_WITH_PYTHON)
set(DOXYFILE ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile)
add_custom_command(
OUTPUT doc/html doc/xml
COMMAND ${CMAKE_COMMAND} -E env
SOURCE_ROOT=${CMAKE_CURRENT_SOURCE_DIR}/
BUILD_ROOT=${CMAKE_CURRENT_BINARY_DIR}/
doxygen -q ${DOXYFILE}
MAIN_DEPENDENCY ${DOXYFILE}
DEPENDS ${LIBXML2_HDRS} ${LIBXML2_SRCS}
)
add_custom_target(Doxygen ALL DEPENDS doc/html doc/xml)
endif()
if(LIBXML2_WITH_PYTHON)
add_custom_command(
OUTPUT
libxml2-py.c
libxml2-py.h
libxml2.py
COMMAND
${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/python/generator.py
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
python/generator.py
Doxygen
)
Python3_add_library(
LibXml2Mod MODULE WITH_SOABI
libxml2-py.c
libxml2-py.h
python/libxml.c
python/libxml_wrap.h
python/types.c
)
target_include_directories(
LibXml2Mod
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/python>
)
target_link_libraries(LibXml2Mod PRIVATE LibXml2)
set_target_properties(
LibXml2Mod
PROPERTIES
IMPORT_PREFIX lib
OUTPUT_NAME xml2mod
PREFIX lib
)
install(
TARGETS LibXml2Mod
ARCHIVE DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT development
LIBRARY DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime NAMELINK_COMPONENT development
RUNTIME DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime
)
if(MSVC AND BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:LibXml2Mod> DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} CONFIGURATIONS Debug RelWithDebInfo COMPONENT debug)
endif()
install(FILES python/drv_libxml2.py DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2.py DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime)
endif()
if (LIBXML2_WITH_DOCS)
set(MAN_PAGES doc/xml2-config.1)
if(LIBXML2_WITH_PROGRAMS)
set(PROGNAMES xmllint)
if(LIBXML2_WITH_CATALOG AND LIBXML2_WITH_OUTPUT)
list(APPEND PROGNAMES xmlcatalog)
endif()
foreach(PROG IN ITEMS ${PROGNAMES})
set(XML_SRC ${CMAKE_CURRENT_SOURCE_DIR}/doc/${PROG}.xml)
add_custom_command(
OUTPUT ${PROG}.1
COMMAND xsltproc
--nonet --novalid
--param man.output.quietly 1
-o ${PROG}.1
http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
${XML_SRC}
MAIN_DEPENDENCY ${XML_SRC}
)
list(APPEND MAN_PAGES ${CMAKE_CURRENT_BINARY_DIR}/${PROG}.1)
add_custom_command(
OUTPUT ${PROG}.html
COMMAND xsltproc
--nonet --novalid
-o ${PROG}.html
http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl
${XML_SRC}
MAIN_DEPENDENCY ${XML_SRC}
)
list(APPEND HTML_PAGES ${CMAKE_CURRENT_BINARY_DIR}/${PROG}.html)
endforeach()
add_custom_target(DocBook ALL DEPENDS ${MAN_PAGES} ${HTML_PAGES})
install(
FILES ${HTML_PAGES}
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT documentation
)
endif()
install(
FILES ${MAN_PAGES}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
COMPONENT documentation
)
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT documentation
)
endif()
configure_package_config_file(
libxml2-config.cmake.cmake.in libxml2-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2
COMPONENT development
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/libxml2-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2
COMPONENT development
)
install(
EXPORT LibXml2
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2
NAMESPACE LibXml2::
FILE libxml2-export.cmake
COMPONENT development
)
configure_file(config.h.cmake.in config.h)
configure_file(include/libxml/xmlversion.h.in libxml/xmlversion.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml/xmlversion.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libxml2/libxml COMPONENT development)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}
FILES ${LIBXML2_SRCS} ${LIBXML2_HDRS} ${LIBXML2_PRIVATE_HDRS})
if(LIBXML2_WITH_PYTHON)
set(prefix "${CMAKE_INSTALL_PREFIX}")
configure_file(python/setup.py.in setup.py @ONLY)
endif()
set(NON_PC_LIBS "${THREAD_LIBS} ${ICONV_LIBS} ${LIBM} ${WINSOCK_LIBS} ${CRYPTO_LIBS} ${MODULE_LIBS}")
list(APPEND XML_PC_LIBS "${NON_PC_LIBS}")
list(APPEND XML_PRIVATE_LIBS "${NON_PC_LIBS}")
list(REMOVE_DUPLICATES XML_PC_LIBS)
list(REMOVE_DUPLICATES XML_PRIVATE_LIBS)
list(JOIN XML_PC_REQUIRES " " XML_PC_REQUIRES)
list(JOIN XML_PC_LIBS " " XML_PC_LIBS)
list(JOIN XML_PRIVATE_LIBS " " XML_PRIVATE_LIBS)
set(XML_INCLUDEDIR "-I\${includedir}/libxml2")
set(XML_LIBDIR "-L\${libdir}")
set(XML_LIBS "-lxml2")
if(BUILD_SHARED_LIBS)
set(XML_PC_PRIVATE ".private")
set(XML_PC_LIBS_PRIVATE "
Libs.private:")
else()
set(XML_PRIVATE_LIBS_NO_SHARED "${XML_PRIVATE_LIBS}")
endif()
if(WIN32)
set(XML_STATIC_CFLAGS "-DLIBXML_STATIC")
if (BUILD_SHARED_LIBS)
set(XML_PC_CFLAGS_PRIVATE "
Cflags.private:")
else()
target_compile_definitions(LibXml2 PUBLIC LIBXML_STATIC)
set(XML_CFLAGS "${XML_STATIC_CFLAGS}")
endif()
endif()
file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_PREFIX}")
string(REGEX REPLACE "/$" "" PACKAGE_RELATIVE_PATH "${PACKAGE_RELATIVE_PATH}")
if(WIN32)
set(prefix "\${pcfiledir}/${PACKAGE_RELATIVE_PATH}")
else()
set(prefix "${CMAKE_INSTALL_PREFIX}")
endif()
set(exec_prefix "\${prefix}")
set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
configure_file(libxml-2.0.pc.in libxml-2.0.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml-2.0.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT development)
if(WIN32)
set(prefix "\$(cd \"\$(dirname \"\$0\")\"; pwd -P)/..")
endif()
configure_file(xml2-config.in xml2-config @ONLY)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/xml2-config DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT development)
set(XML_INCLUDEDIR "-I${CMAKE_INSTALL_FULL_INCLUDEDIR}/libxml2")
set(XML_LIBDIR "-L${CMAKE_INSTALL_FULL_LIBDIR}")
set(CPACK_COMPONENT_DEVELOPMENT_DEPENDS runtime)
set(CPACK_COMPONENT_PROGRAMS_DEPENDS runtime)
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_DEPENDS "${PACKAGE_TARNAME}")
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_NAME "${PACKAGE_TARNAME}-dev")
set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_SECTION "libdevel")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${PACKAGE_URL})
set(CPACK_DEBIAN_PACKAGE_NAME ${PACKAGE_TARNAME})
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
set(CPACK_DEBIAN_PROGRAMS_PACKAGE_DEPENDS "${PACKAGE_TARNAME}")
set(CPACK_DEBIAN_PROGRAMS_PACKAGE_NAME "${PACKAGE_TARNAME}-utils")
set(CPACK_DEBIAN_PROGRAMS_PACKAGE_SECTION "utils")
set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME ${PACKAGE_TARNAME})
set(CPACK_DEBIAN_RUNTIME_PACKAGE_RECOMMENDS "${PACKAGE_TARNAME}-utils")
set(CPACK_DEBIAN_RUNTIME_PACKAGE_SECTION "libs")
set(CPACK_NSIS_PACKAGE_NAME ${PACKAGE_STRING})
set(CPACK_NSIS_URL_INFO_ABOUT ${PACKAGE_URL})
set(CPACK_PACKAGE_DISPLAY_NAME ${PACKAGE_STRING})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PACKAGE_TARNAME}-${PACKAGE_VERSION}")
set(CPACK_PACKAGE_NAME ${PACKAGE_TARNAME})
set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${LIBXML_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${LIBXML_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${LIBXML_MICRO_VERSION})
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/Copyright)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_RPM_development_PACKAGE_NAME "${PACKAGE_NAME}-devel")
set(CPACK_RPM_development_PACKAGE_REQUIRES "${PACKAGE_NAME}")
set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
set(CPACK_RPM_PACKAGE_NAME ${PACKAGE_TARNAME})
set(CPACK_RPM_PACKAGE_URL ${PACKAGE_URL})
set(CPACK_RPM_programs_PACKAGE_NAME "${PACKAGE_NAME}-utils")
set(CPACK_RPM_programs_PACKAGE_REQUIRES "${PACKAGE_NAME}")
set(CPACK_RPM_runtime_PACKAGE_NAME "${PACKAGE_NAME}")
set(CPACK_RPM_runtime_PACKAGE_SUGGESTS "${PACKAGE_NAME}-utils")
include(CPack)
+24
View File
@@ -0,0 +1,24 @@
Except where otherwise noted in the source code (e.g. the files dict.c and
list.c, which are covered by a similar licence but with different Copyright
notices) all the files are:
Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved.
Copyright (C) The Libxml2 Contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is fur-
nished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+6004
View File
File diff suppressed because it is too large Load Diff
+1314
View File
File diff suppressed because it is too large Load Diff
+130
View File
@@ -0,0 +1,130 @@
# Maintainer's Guide
## Working with the test suite
Most of the tests are contained in the `runtest` executable which
generally reads test cases from the `test` directory and compares output
to files in the `result` directory.
You can simply add new test cases and run `runtest -u` to update the
results. If you debug test failures, it's also useful to execute
`runtest -u` and then `git diff result` to get a diff between actual and
expected results. You can restore the original results by running
`git restore result` and `git clean -xd result`.
## Generated files
Some source code is generated with Python scripts in the `tools`
directory.
- `tools/genChRanges.py` generates code to handle character ranges
from chvalid.def:
- `chvalid.c`
- `include/libxml/chvalid.h`
- `tools/genEscape prints lookup tables for serialization.
- `tools/genHtml5LibTests.py` creates test cases and expected results
from the html5lib test suite:
- `test/html-tokenizer`
- `result/html-tokenizer`
- `tools/genHtmlEnt.py` prints lookup tables for HTML5 named character
references (predefined entities):
- `html5ent.inc`
- `tools/gentest.py` generates test code using the Doxygen XML output:
- `testapi.c`
- `tools/genUnicode.py` generates code to handle Unicode ranges
from Unicode data files:
- `xmlunicode.c`
## Making a release
### Update the NEWS file
You can get started by running
git log --format='- %s (%an)' [previous-release-tag]..
### Bump the version number
Update the version number in `VERSION` if you haven't done so already.
### Commit and verify tarball
Release tarballs are generated with a CI job and the `.gitlab-ci/dist.sh`
script. Push the release commit and inspect the tarball artifact generated
by Gitlab CI.
### Tag the release
Create an annotated tag and push it:
git tag -a [version] -m 'Release [version]'
git push origin [version]
This will upload the release to the downloads server using the GNOME
Release Service. For more details, see
<https://handbook.gnome.org/maintainers/release-pipeline.html>
### Create a GitLab release
Create or update a GitLab release on
<https://gitlab.gnome.org/GNOME/libxml2/-/releases>.
### Announce the release
Announce the release on https://discourse.gnome.org under topics 'libxml2'
and 'announcements'.
## Removing public API functions
General process to remove public API functions (or variables):
- Make sure that there's a reasonable alternative.
- Mark the function as deprecated in the documentation and mention
alternatives.
- Mark the function as XML_DEPRECATED in the header files.
- For whole modules: disable the module by default and only enable
it in "legacy mode".
- Remove the function body and make the function return an error code
or a no-op. Make sure that the symbol is kept and exported. This
should only be done after allowing users enough time to adjust.
- At the next ABI bump, remove the symbol completely.
You can wait for the next feature release between some of the steps to
make the process more gradual.
## Breaking the ABI
Unfortunately, libxml2 exposes many internal structs which makes some
beneficial changes impossible without breaking the ABI.
The following changes are allowed (after careful consideration):
- Appending members to structs which client code should never allocate
directly. A notable example is xmlParserCtxt. Other structs like
xmlError are allocated directly by client code and must not be changed.
- Making a void function return a value.
- Making functions accept const pointers unless it's a typedef for a
callback.
- Changing signedness of struct members or function arguments.
## Updating the CI Docker image
Note that the CI image is used for libxslt as well. First create a
GitLab access token with maintainer role and `read_registry` and
`write_registry` permissions. Then run the following commands with the
Dockerfile in the .gitlab-ci directory:
docker login -u <username> -p <access_token> \
registry.gitlab.gnome.org
docker build -t registry.gitlab.gnome.org/gnome/libxml2 - \
< .gitlab-ci/Dockerfile
docker push registry.gitlab.gnome.org/gnome/libxml2
+234
View File
@@ -0,0 +1,234 @@
## Process this file with automake to produce Makefile.in
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = include . example
if WITH_DOXYGEN
SUBDIRS += doc
endif
if WITH_PYTHON
SUBDIRS += python
endif
if WITH_GLOB
SUBDIRS += fuzz
endif
DIST_SUBDIRS = include . doc example fuzz python
AM_CPPFLAGS = -I$(builddir)/include -I$(srcdir)/include
check_PROGRAMS = \
runsuite \
runtest \
runxmlconf \
testModule \
testapi \
testcatalog \
testchar \
testdict \
testlimits \
testparser \
testrecurse
bin_PROGRAMS = xmllint
bin_SCRIPTS = xml2-config
lib_LTLIBRARIES = libxml2.la
libxml2_la_CFLAGS = $(AM_CFLAGS) $(XML_PRIVATE_CFLAGS)
libxml2_la_LIBADD = $(XML_PRIVATE_LIBS)
libxml2_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined \
-version-info $(LIBXML_VERSION_INFO)
libxml2_la_SOURCES = buf.c chvalid.c dict.c entities.c encoding.c error.c \
globals.c hash.c list.c parser.c parserInternals.c \
SAX2.c threads.c tree.c uri.c valid.c xmlIO.c \
xmlmemory.c xmlstring.c
if WITH_C14N_SOURCES
libxml2_la_SOURCES += c14n.c
endif
if WITH_CATALOG_SOURCES
if WITH_OUTPUT_SOURCES
bin_PROGRAMS += xmlcatalog
xmlcatalog_SOURCES = xmlcatalog.c
xmlcatalog_CFLAGS = $(AM_CFLAGS) $(RDL_CFLAGS)
xmlcatalog_DEPENDENCIES = $(DEPS)
xmlcatalog_LDADD = $(RDL_LIBS) $(LDADDS)
endif
libxml2_la_SOURCES += catalog.c
endif
if WITH_DEBUG_SOURCES
libxml2_la_SOURCES += debugXML.c
endif
if WITH_HTML_SOURCES
libxml2_la_SOURCES += HTMLparser.c HTMLtree.c
endif
if WITH_HTTP_SOURCES
libxml2_la_SOURCES += nanohttp.c
endif
if WITH_MODULES_SOURCES
libxml2_la_SOURCES += xmlmodule.c
endif
if WITH_OUTPUT_SOURCES
libxml2_la_SOURCES += xmlsave.c
endif
if WITH_PATTERN_SOURCES
libxml2_la_SOURCES += pattern.c
endif
if WITH_READER_SOURCES
libxml2_la_SOURCES += xmlreader.c
endif
if WITH_REGEXPS_SOURCES
libxml2_la_SOURCES += xmlregexp.c
endif
if WITH_RELAXNG_SOURCES
libxml2_la_SOURCES += relaxng.c
endif
if WITH_SCHEMAS_SOURCES
libxml2_la_SOURCES += xmlschemas.c xmlschemastypes.c
endif
if WITH_SCHEMATRON_SOURCES
libxml2_la_SOURCES += schematron.c
endif
if WITH_WRITER_SOURCES
libxml2_la_SOURCES += xmlwriter.c
endif
if WITH_XINCLUDE_SOURCES
libxml2_la_SOURCES += xinclude.c
endif
if WITH_XPATH_SOURCES
libxml2_la_SOURCES += xpath.c
endif
if WITH_XPTR_SOURCES
libxml2_la_SOURCES += xlink.c xpointer.c
endif
DEPS = libxml2.la
LDADDS = libxml2.la
runtest_SOURCES=runtest.c
runtest_DEPENDENCIES = $(DEPS)
runtest_LDADD= $(THREAD_LIBS) $(Z_LIBS) $(LDADDS)
testrecurse_SOURCES=testrecurse.c
testrecurse_DEPENDENCIES = $(DEPS)
testrecurse_LDADD= $(LDADDS)
testlimits_SOURCES=testlimits.c
testlimits_DEPENDENCIES = $(DEPS)
testlimits_LDADD= $(LDADDS)
testcatalog_SOURCES=testcatalog.c
testcatalog_DEPENDENCIES = $(DEPS)
testcatalog_LDADD= $(LDADDS)
testchar_SOURCES=testchar.c
testchar_DEPENDENCIES = $(DEPS)
testchar_LDADD= $(LDADDS)
testdict_SOURCES=testdict.c
testdict_DEPENDENCIES = $(DEPS)
testdict_LDADD= $(LDADDS)
testparser_SOURCES=testparser.c
testparser_DEPENDENCIES = $(DEPS)
testparser_LDADD= $(LDADDS)
runsuite_SOURCES=runsuite.c
runsuite_DEPENDENCIES = $(DEPS)
runsuite_LDADD= $(LDADDS)
xmllint_SOURCES = xmllint.c shell.c lintmain.c
xmllint_CFLAGS = $(AM_CFLAGS) $(RDL_CFLAGS) $(Z_CFLAGS)
xmllint_DEPENDENCIES = $(DEPS)
xmllint_LDADD = $(RDL_LIBS) $(Z_LIBS) $(LDADDS)
testModule_SOURCES=testModule.c
testModule_DEPENDENCIES = $(DEPS)
testModule_LDADD= $(LDADDS)
check_LTLIBRARIES = testdso.la
testdso_la_SOURCES = testdso.c
testdso_la_LDFLAGS = $(AM_LDFLAGS) \
-module -no-undefined -avoid-version -rpath $(libdir)
rebuild_testapi:
cd $(srcdir) && python3 codegen/genTestApi.py $(abs_builddir)
testapi_SOURCES=testapi.c
testapi_DEPENDENCIES = $(DEPS)
testapi_LDADD= $(LDADDS)
runxmlconf_SOURCES=runxmlconf.c
runxmlconf_DEPENDENCIES = $(DEPS)
runxmlconf_LDADD= $(LDADDS)
check-local:
[ -d test ] || $(LN_S) $(srcdir)/test .
[ -d result ] || $(LN_S) $(srcdir)/result .
$(CHECKER) ./runtest$(EXEEXT)
$(CHECKER) ./testrecurse$(EXEEXT)
$(CHECKER) ./testapi$(EXEEXT)
$(CHECKER) ./testcatalog$(EXEEXT)
$(CHECKER) ./testchar$(EXEEXT)
$(CHECKER) ./testdict$(EXEEXT)
$(CHECKER) ./testparser$(EXEEXT)
$(CHECKER) ./testModule$(EXEEXT)
$(CHECKER) ./runxmlconf$(EXEEXT) -d $(srcdir)/xmlconf
$(CHECKER) ./runsuite$(EXEEXT)
if WITH_OUTPUT_SOURCES
if WITH_DEBUG_SOURCES
test/scripts/test.sh ./xmllint$(EXEEXT)
endif
if WITH_CATALOG_SOURCES
ASAN_OPTIONS=detect_leaks=0 test/catalogs/test.sh ./xmlcatalog$(EXEEXT)
ASAN_OPTIONS=detect_leaks=0 test/catalogs/test_sgml.sh ./xmlcatalog$(EXEEXT)
endif
endif
# Compatibility name of the check target
runtests: check
VALGRIND = valgrind -q --leak-check=full --error-exitcode=1
check-valgrind valgrind:
@echo '## Running the regression tests under Valgrind'
@echo '## Go get a cup of coffee it is gonna take a while ...'
$(MAKE) check CHECKER="$(LIBTOOL) --mode=execute $(VALGRIND)"
dist-hook:
(cd $(srcdir) ; tar -cf - --exclude .git win32 test result) | (cd $(distdir); tar xf -)
CLEANFILES = missing.lst runsuite.log runxmlconf.log test.out \
*.gcda *.gcno *.res
EXTRA_DIST = Copyright libxml2-config.cmake.in autogen.sh \
libxml.h \
codegen/charset.inc \
codegen/escape.inc \
codegen/genCharset.py \
codegen/genEscape.py \
codegen/genHtml5Ent.py \
codegen/genHtml5LibTests.py \
codegen/genRanges.py \
codegen/genTestApi.py \
codegen/genUnicode.py \
codegen/html5ent.inc \
codegen/ranges.def \
codegen/ranges.inc \
codegen/rangetab.py \
codegen/unicode.inc \
codegen/xmlmod.py \
timsort.h \
README.zOS README.md \
CMakeLists.txt config.h.cmake.in libxml2-config.cmake.cmake.in \
meson.build meson_options.txt xml2-config-meson
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libxml-2.0.pc
cmakedir = $(libdir)/cmake/libxml2
cmake_DATA = libxml2-config.cmake
+5309
View File
File diff suppressed because it is too large Load Diff
+213
View File
@@ -0,0 +1,213 @@
# libxml2
libxml2 is an XML toolkit implemented in C, originally developed for
the GNOME Project.
Official releases can be downloaded from
<https://download.gnome.org/sources/libxml2/>
The git repository is hosted on GNOME's GitLab server:
<https://gitlab.gnome.org/GNOME/libxml2>
Bugs should be reported at
<https://gitlab.gnome.org/GNOME/libxml2/-/issues>.
Documentation is available at
<https://gitlab.gnome.org/GNOME/libxml2/-/wikis>
## License
This code is released under the MIT License, see the Copyright file.
## Security
This is open-source software written by hobbyists and maintained by
volunteers.
It's NOT recommended to use this software to process **untrusted data**.
There is a lot of ways that a malicious crafted xml could exploit a
hidden vulnerability in the software.
The software is provided "as is", without warranty of any kind,
express or implied. Use this software at your own risk.
To **report security bugs**, you can create a confidential issue with
the "security" label. We will review and work on it as a best effort.
But remember that this is a community project, maintained by volunteer
developers, so if you are concern about any important security bug
that's critical for you, feel free to collaborate and provide a patch.
The main rule is to be kind. Do not pressure developers to fix a CVE
or to work on a functionality that you need, because that won't work.
This is a community project, developers will work in the issues that
they consider interesting and when they want. All contributions are
welcome, so if something is important for you, you can always get
involved, implement it yourself and be part of the open source
community.
## Build instructions
libxml2 can be built with GNU Autotools, CMake or meson.
### Autotools (for POSIX systems like Linux, BSD, macOS)
If you build from a Git tree, you have to install Autotools and start
by generating the configuration files with:
./autogen.sh [configuration options]
If you build from a source tarball, extract the archive with:
tar xf libxml2-xxx.tar.gz
cd libxml2-xxx
Then you can configure and build the library:
./configure [configuration options]
make
The following options disable or enable code modules and relevant symbols:
--with-c14n Canonical XML 1.0 support (on)
--with-catalog XML Catalogs support (on)
--with-debug debugging module (on)
--with-docs Build documentation (off)
--with-history history support for xmllint shell (off)
--with-readline[=DIR] use readline in DIR for shell (off)
--with-html HTML parser (on)
--with-http ABI compatibility for removed HTTP support (off)
--with-iconv[=DIR] iconv support (on)
--with-icu ICU support (off)
--with-iso8859x ISO-8859-X support if no iconv (on)
--with-modules dynamic modules support (on)
--with-output serialization support (on)
--with-pattern xmlPattern selection interface (on)
--with-push push parser interfaces (on)
--with-python Python bindings (off)
--with-reader xmlReader parsing interface (on)
--with-regexps regular expressions support (on)
--with-relaxng RELAX NG support (on)
--with-sax1 older SAX1 interface (on)
--with-schemas XML Schemas 1.0 support (on)
--with-schematron Schematron support (off)
--with-threads multithreading support (on)
--with-thread-alloc per-thread malloc hooks (off)
--with-valid DTD validation support (on)
--with-winpath Windows path support (on for Windows)
--with-writer xmlWriter serialization interface (on)
--with-xinclude XInclude 1.0 support (on)
--with-xpath XPath 1.0 support (on)
--with-xptr XPointer support (on)
--with-zlib[=DIR] use libz in DIR (off)
Other options:
--prefix=DIR set installation prefix
--with-minimum build a minimally sized library (off)
--with-legacy maximum ABI compatibility (off)
Note that by default, no optimization options are used. You have to
enable them manually, for example with:
CFLAGS='-O2 -fno-semantic-interposition' ./configure
Now you can run the test suite with:
make check
Please report test failures to the bug tracker.
Then you can install the library:
make install
At that point you may have to rerun ldconfig or a similar utility to
update your list of installed shared libs.
### CMake (mainly for Windows)
Example commands:
cmake -E tar xf libxml2-xxx.tar.xz
cmake -S libxml2-xxx -B builddir [options]
cmake --build builddir
ctest --test-dir builddir
cmake --install builddir
Common CMake options include:
-D BUILD_SHARED_LIBS=OFF # build static libraries
-D CMAKE_BUILD_TYPE=Release # specify build type (single-config)
--config Release # specify build type (multi-config)
-D CMAKE_INSTALL_PREFIX=/usr/local # specify the install path
-D LIBXML2_WITH_ICONV=OFF # disable iconv
-D LIBXML2_WITH_ZLIB=ON # enable zlib
You can also open the libxml source directory with its CMakeLists.txt
directly in various IDEs such as CLion, QtCreator, or Visual Studio.
### Meson
Example commands:
meson setup [options] builddir
ninja -C builddir
meson test -C builddir
ninja -C builddir install
See the `meson_options.txt` file for options. For example:
-Dprefix=$prefix
-Dhistory=enabled
-Dschemas=disabled
-Dzlib=enabled
## Dependencies
libxml2 supports POSIX and Windows operating systems.
The iconv function is required for conversion of character encodings.
This function is part of POSIX.1-2001. If your platform doesn't provide
iconv, you need an external libiconv library, for example
[GNU libiconv](https://www.gnu.org/software/libiconv/). Using
[ICU](https://icu.unicode.org/) is also supported but discouraged.
The xmllint executable uses libreadline and libhistory if enabled.
### Build requirements
Besides build system tools, only a C compiler should be required.
Reconfiguration of the Autotools build requires the pkg.m4 macro from
pkg-config. Building the documentation requires Doxygen, xsltproc and the
DocBook 4 XSLT stylesheets. Building the Python bindings requires Doxygen.
## Contributing
The current version of the code can be found in GNOME's GitLab at
<https://gitlab.gnome.org/GNOME/libxml2>. The best way to get involved
is by creating issues and merge requests on GitLab.
All code must conform to C89 and pass the GitLab CI tests. Add regression
tests if possible.
### Strict No LLM / No AI Policy
No LLMs for issues.
No LLMs for patches / pull requests.
No LLMs for comments on the bug tracker, including translation.
English is encouraged, but not required. You are welcome to post in
your native language and rely on others to have their own translation
tools of choice to interpret your words.
## Authors
- Daniel Veillard
- Bjorn Reese
- William Brack
- Igor Zlatkovic for the Windows port
- Aleksey Sanin
- Nick Wellnhofer
+212
View File
@@ -0,0 +1,212 @@
Notes for compiling on zOS:
- since testapi.c file is huge (over 52000 lines), it's compilation
fails: I skipped the problem by removing all references to testapi in the
Makefile.in, but it would be neater if one can build without test files
(I didn't find an option in configure...)
- since the name of files (or qualifier) in PDS are limited to 8 I had to
rename xmlschemas.c and xmlschemastypes.c in (resp.) xmlsche.c xmlschet.c
(and I had to modify all occurrences of these files accordingly in the
rest of the Makefile !!!).
- in order to copy objects to PDS, I had the cp command at line 860
of Makefile.in
libxml2.la: $(libxml2_la_OBJECTS) $(libxml2_la_DEPENDENCIES)
$(AM_V_CCLD)$(libxml2_la_LINK) -rpath $(libdir) $(libxml2_la_OBJECTS) $(libxml2_la_LIBADD) $(LIBS)
# Copy objects to PDS
@list='$(libxml2_OBJECTS)' ; for p in $$list; do \
cp -ACMv $$p "//'<PDS NAME>'"; \
done
with <PDS NAME> stands for the name of my PDS and
libxml2_OBJECTS = SAX.o entities.o encoding.o error.o \
parserInternals.o parser.o tree.o hash.o list.o xmlIO.o \
xmlmemory.o uri.o valid.o xlink.o HTMLparser.o \
HTMLtree.o debugXML.o xpath.o xpointer.o xinclude.o \
nanohttp.o nanoftp.o triostr.o trio.o catalog.o globals.o \
threads.o c14n.o xmlstring.o buf.o xmlregexp.o \
xmlsche.o xmlschet.o xmlunicode.o \
xmlreader.o relaxng.o dict.o SAX2.o \
xmlwriter.o legacy.o chvalid.o pattern.o xmlsave.o \
xmlmodule.o schematron.o xzlib.o
In order to handle the support of zOS without breaking the existing
Makefile maybe a new option/flag zOs would copy xmlschemas.c and
xmlschemastypes.c files and use specifics targets rather than existing
ones with the longer names... A variable to handle the PDS name has to
be provided also...
See patch below for set of changes to Makefile.in
Stéphane Michaut <smichaut@axway.com>
July 2017
--- Makefile.in 2017-08-01 08:17:15.000000000 +0200
+++ Makefile-new.in 2017-08-01 08:07:26.000000000 +0200
@@ -41,7 +41,7 @@
testSAX$(EXEEXT) testHTML$(EXEEXT) testXPath$(EXEEXT) \
testURI$(EXEEXT) testThreads$(EXEEXT) testC14N$(EXEEXT) \
testAutomata$(EXEEXT) testRegexp$(EXEEXT) testReader$(EXEEXT) \
- testapi$(EXEEXT) testModule$(EXEEXT) runtest$(EXEEXT) \
+ testModule$(EXEEXT) runtest$(EXEEXT) \
runsuite$(EXEEXT) testchar$(EXEEXT) testdict$(EXEEXT) \
runxmlconf$(EXEEXT) testrecurse$(EXEEXT) testlimits$(EXEEXT)
bin_PROGRAMS = xmllint$(EXEEXT) xmlcatalog$(EXEEXT)
@@ -106,6 +106,7 @@
debugXML.c xpath.c xpointer.c xinclude.c nanohttp.c nanoftp.c \
DOCBparser.c catalog.c globals.c threads.c c14n.c xmlstring.c \
buf.c xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
+ xmlsche.c xmlschet.c \
triostr.c trio.c xmlreader.c relaxng.c dict.c SAX2.c \
xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c xmlmodule.c \
schematron.c xzlib.c
@@ -118,10 +119,24 @@
nanohttp.lo nanoftp.lo $(am__objects_1) catalog.lo globals.lo \
threads.lo c14n.lo xmlstring.lo buf.lo xmlregexp.lo \
xmlschemas.lo xmlschemastypes.lo xmlunicode.lo \
+ xmlsche.lo xmlschet.lo \
$(am__objects_2) xmlreader.lo relaxng.lo dict.lo SAX2.lo \
xmlwriter.lo legacy.lo chvalid.lo pattern.lo xmlsave.lo \
xmlmodule.lo schematron.lo xzlib.lo
libxml2_la_OBJECTS = $(am_libxml2_la_OBJECTS)
+
+libxml2_OBJECTS = SAX.o entities.o encoding.o error.o \
+ parserInternals.o parser.o tree.o hash.o list.o xmlIO.o \
+ xmlmemory.o uri.o valid.o xlink.o HTMLparser.o \
+ HTMLtree.o debugXML.o xpath.o xpointer.o xinclude.o \
+ nanohttp.o nanoftp.o triostr.o trio.o catalog.o globals.o \
+ threads.o c14n.o xmlstring.o buf.o xmlregexp.o \
+ xmlschemas.o xmlschemastypes.o xmlunicode.o \
+ xmlsche.o xmlschemast.o \
+ xmlreader.o relaxng.o dict.o SAX2.o \
+ xmlwriter.o legacy.o chvalid.o pattern.o xmlsave.o \
+ xmlmodule.o schematron.o xzlib.o
+
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
am__v_lt_0 = --silent
@@ -216,11 +231,6 @@
testXPath_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(testXPath_LDFLAGS) $(LDFLAGS) -o $@
-am_testapi_OBJECTS = testapi.$(OBJEXT)
-testapi_OBJECTS = $(am_testapi_OBJECTS)
-testapi_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(testapi_LDFLAGS) $(LDFLAGS) -o $@
am_testchar_OBJECTS = testchar.$(OBJEXT)
testchar_OBJECTS = $(am_testchar_OBJECTS)
testchar_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -285,7 +295,7 @@
$(testReader_SOURCES) $(testRegexp_SOURCES) \
$(testRelax_SOURCES) $(testSAX_SOURCES) $(testSchemas_SOURCES) \
$(testThreads_SOURCES) $(testURI_SOURCES) $(testXPath_SOURCES) \
- $(testapi_SOURCES) $(testchar_SOURCES) $(testdict_SOURCES) \
+ $(testchar_SOURCES) $(testdict_SOURCES) \
$(testlimits_SOURCES) $(testrecurse_SOURCES) \
$(xmlcatalog_SOURCES) $(xmllint_SOURCES)
DIST_SOURCES = $(am__libxml2_la_SOURCES_DIST) $(testdso_la_SOURCES) \
@@ -295,7 +305,7 @@
$(testReader_SOURCES) $(testRegexp_SOURCES) \
$(testRelax_SOURCES) $(testSAX_SOURCES) $(testSchemas_SOURCES) \
$(am__testThreads_SOURCES_DIST) $(testURI_SOURCES) \
- $(testXPath_SOURCES) $(testapi_SOURCES) $(testchar_SOURCES) \
+ $(testXPath_SOURCES) $(testchar_SOURCES) \
$(testdict_SOURCES) $(testlimits_SOURCES) \
$(testrecurse_SOURCES) $(xmlcatalog_SOURCES) \
$(xmllint_SOURCES)
@@ -700,11 +710,6 @@
noinst_LTLIBRARIES = testdso.la
testdso_la_SOURCES = testdso.c
testdso_la_LDFLAGS = -module -no-undefined -avoid-version -rpath $(libdir)
-BUILT_SOURCES = testapi.c
-testapi_SOURCES = testapi.c
-testapi_LDFLAGS =
-testapi_DEPENDENCIES = $(DEPS)
-testapi_LDADD = $(LDADDS)
runxmlconf_SOURCES = runxmlconf.c
runxmlconf_LDFLAGS =
runxmlconf_DEPENDENCIES = $(DEPS)
@@ -854,6 +859,12 @@
done
libxml2.la: $(libxml2_la_OBJECTS) $(libxml2_la_DEPENDENCIES)
$(AM_V_CCLD)$(libxml2_la_LINK) -rpath $(libdir) $(libxml2_la_OBJECTS) $(libxml2_la_LIBADD) $(LIBS)
+ # Copie des obj
+ @list='$(libxml2_OBJECTS)' ; for p in $$list; do \
+ echo "copy to PDS: $$p"; \
+ cp -ACMv $$p "//'A009153.XRDEV230.FIC.OBJLIB.LIBXML'"; \
+ done
+
testdso.la: $(testdso_la_OBJECTS) $(testdso_la_DEPENDENCIES)
$(AM_V_CCLD)$(testdso_la_LINK) $(testdso_la_OBJECTS) $(testdso_la_LIBADD) $(LIBS)
install-binPROGRAMS: $(bin_PROGRAMS)
@@ -953,9 +964,6 @@
testXPath$(EXEEXT): $(testXPath_OBJECTS) $(testXPath_DEPENDENCIES)
@rm -f testXPath$(EXEEXT)
$(AM_V_CCLD)$(testXPath_LINK) $(testXPath_OBJECTS) $(testXPath_LDADD) $(LIBS)
-testapi$(EXEEXT): $(testapi_OBJECTS) $(testapi_DEPENDENCIES)
- @rm -f testapi$(EXEEXT)
- $(AM_V_CCLD)$(testapi_LINK) $(testapi_OBJECTS) $(testapi_LDADD) $(LIBS)
testchar$(EXEEXT): $(testchar_OBJECTS) $(testchar_DEPENDENCIES)
@rm -f testchar$(EXEEXT)
$(AM_V_CCLD)$(testchar_LINK) $(testchar_OBJECTS) $(testchar_LDADD) $(LIBS)
@@ -1056,7 +1064,6 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testThreadsWin32.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testURI.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testXPath.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testapi.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testchar.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testdict.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testdso.Plo@am__quote@
@@ -1755,18 +1762,6 @@
uninstall-local uninstall-m4dataDATA uninstall-man \
uninstall-man1 uninstall-man3 uninstall-pkgconfigDATA
-
-# that one forces the rebuild when "make rebuild" is run on doc/
-rebuild_testapi:
- -@(if [ "$(PYTHON)" != "" ] ; then \
- $(PYTHON) $(srcdir)/gentest.py $(srcdir) ; fi )
-
-# that one is just to make sure it is rebuilt if missing
-# but adding the dependances generate mess
-testapi.c: $(srcdir)/gentest.py
- -@(if [ "$(PYTHON)" != "" ] ; then \
- $(PYTHON) $(srcdir)/gentest.py $(srcdir) ; fi )
-
#testOOM_SOURCES=testOOM.c testOOMlib.h testOOMlib.c
#testOOM_LDFLAGS =
#testOOM_DEPENDENCIES = $(DEPS)
@@ -1775,7 +1770,7 @@
runtests:
[ -d test ] || $(LN_S) $(srcdir)/test .
[ -d result ] || $(LN_S) $(srcdir)/result .
- $(CHECKER) ./runtest$(EXEEXT) && $(CHECKER) ./testrecurse$(EXEEXT) &&$(CHECKER) ./testapi$(EXEEXT) && $(CHECKER) ./testchar$(EXEEXT)&& $(CHECKER) ./testdict$(EXEEXT) && $(CHECKER) ./runxmlconf$(EXEEXT)
+ $(CHECKER) ./runtest$(EXEEXT) && $(CHECKER) ./testrecurse$(EXEEXT) &&$(CHECKER) && $(CHECKER) ./testchar$(EXEEXT)&& $(CHECKER) ./testdict$(EXEEXT) && $(CHECKER) ./runxmlconf$(EXEEXT)
@(if [ "$(PYTHON_SUBDIR)" != "" ] ; then cd python ; \
$(MAKE) tests ; fi)
@@ -1797,10 +1792,6 @@
$(MAKE) tests ; fi)
@(cd doc/examples ; $(MAKE) tests)
-APItests: testapi$(EXEEXT)
- @echo "## Running the API regression tests this may take a little while"
- -@($(CHECKER) $(top_builddir)/testapi -q)
-
HTMLtests : testHTML$(EXEEXT)
@(echo > .memdump)
@echo "## HTML regression tests"
@@ -2746,7 +2737,7 @@
dist-test: distdir
(mkdir -p $(distdir))
(cd $(srcdir) ; tar -cf - --exclude CVS --exclude .svn --exclude .git xstc/Tests) | (cd $(distdir); tar xf -)
- tar -cf - $(distdir)/test $(distdir)/result $(distdir)/xstc/Tests $(distdir)/Makefile.tests $(distdir)/README $(distdir)/README.tests $(distdir)/AUTHORS $(distdir)/testapi.c $(distdir)/runtest.c $(distdir)/runsuite.c | GZIP=$(GZIP_ENV) gzip -c >`echo "$(distdir)" | sed "s+libxml2+libxml2-tests+"`.tar.gz
+ tar -cf - $(distdir)/test $(distdir)/result $(distdir)/xstc/Tests $(distdir)/Makefile.tests $(distdir)/README $(distdir)/README.tests $(distdir)/AUTHORS $(distdir)/runtest.c $(distdir)/runsuite.c | GZIP=$(GZIP_ENV) gzip -c >`echo "$(distdir)" | sed "s+libxml2+libxml2-tests+"`.tar.gz
@(rm -rf $(distdir)/xstc/Test)
cleantar:
+2842
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
2.16.0
+97
View File
@@ -0,0 +1,97 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
THEDIR=`pwd`
cd `dirname $0`
srcdir=`pwd`
DIE=0
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have autoconf installed to compile libxml."
echo "Download the appropriate package for your distribution,"
echo "or see http://www.gnu.org/software/autoconf"
DIE=1
}
(libtoolize --version) < /dev/null > /dev/null 2>&1 ||
(glibtoolize --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have libtool installed to compile libxml."
echo "Download the appropriate package for your distribution,"
echo "or see http://www.gnu.org/software/libtool"
DIE=1
}
(automake --version) < /dev/null > /dev/null 2>&1 || {
echo
DIE=1
echo "You must have automake installed to compile libxml."
echo "Download the appropriate package for your distribution,"
echo "or see http://www.gnu.org/software/automake"
}
if test "$DIE" -eq 1; then
exit 1
fi
test -f entities.c || {
echo "You must run this script in the top-level libxml directory"
exit 1
}
EXTRA_ARGS=
if test "x$1" = "x--system"; then
shift
prefix=/usr
libdir=$prefix/lib
sysconfdir=/etc
localstatedir=/var
if [ -d /usr/lib64 ]; then
libdir=$prefix/lib64
fi
EXTRA_ARGS="--prefix=$prefix --sysconfdir=$sysconfdir --localstatedir=$localstatedir --libdir=$libdir"
echo "Running ./configure with $EXTRA_ARGS $@"
else
if test -z "$NOCONFIGURE" && test -z "$*"; then
echo "I am going to run ./configure with no arguments - if you wish "
echo "to pass any to it, please specify them on the $0 command line."
fi
fi
if [ ! -d $srcdir/m4 ]; then
mkdir $srcdir/m4
fi
aclocal
if ! grep -q pkg.m4 aclocal.m4; then
cat <<EOF
Couldn't find pkg.m4 from pkg-config. Install the appropriate package for
your distribution or set ACLOCAL_PATH to the directory containing pkg.m4.
EOF
exit 1
fi
autoreconf -if -Wall || exit 1
cd $THEDIR
if test x$OBJ_DIR != x; then
mkdir -p "$OBJ_DIR"
cd "$OBJ_DIR"
fi
if test -z "$NOCONFIGURE"; then
$srcdir/configure $EXTRA_ARGS "$@"
if test "$?" -ne 0; then
echo
echo "Configure script failed, check config.log for more info."
exit 1
else
echo
echo "Now type 'make' to compile libxml2."
fi
fi
+1164
View File
File diff suppressed because it is too large Load Diff
+2170
View File
File diff suppressed because it is too large Load Diff
+3899
View File
File diff suppressed because it is too large Load Diff
+174
View File
@@ -0,0 +1,174 @@
/*
* chvalid.c: this module implements the character range
* validation APIs
*/
#define IN_LIBXML
#include "libxml.h"
#include <libxml/chvalid.h>
#include <stddef.h>
/*
* The initial tables ({func_name}_tab) are used to validate whether a
* single-byte character is within the specified group. Each table
* contains 256 bytes, with each byte representing one of the 256
* possible characters. If the table byte is set, the character is
* allowed.
*
*/
#include "codegen/ranges.inc"
/**
* Does a binary search of the range table to determine if char
* is valid
*
* @param val character to be validated
* @param rptr pointer to range to be used to validate
* @returns true if character valid, false otherwise
*/
int
xmlCharInRange (unsigned int val, const xmlChRangeGroup *rptr) {
int low, high, mid;
const xmlChSRange *sptr;
const xmlChLRange *lptr;
if (rptr == NULL) return(0);
if (val < 0x10000) { /* is val in 'short' or 'long' array? */
if (rptr->nbShortRange == 0)
return 0;
low = 0;
high = rptr->nbShortRange - 1;
sptr = rptr->shortRange;
while (low <= high) {
mid = (low + high) / 2;
if ((unsigned short) val < sptr[mid].low) {
high = mid - 1;
} else {
if ((unsigned short) val > sptr[mid].high) {
low = mid + 1;
} else {
return 1;
}
}
}
} else {
if (rptr->nbLongRange == 0) {
return 0;
}
low = 0;
high = rptr->nbLongRange - 1;
lptr = rptr->longRange;
while (low <= high) {
mid = (low + high) / 2;
if (val < lptr[mid].low) {
high = mid - 1;
} else {
if (val > lptr[mid].high) {
low = mid + 1;
} else {
return 1;
}
}
}
}
return 0;
}
/**
* @deprecated Use #xmlIsBaseChar_ch or #xmlIsBaseCharQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsBaseChar(unsigned int ch) {
return(xmlIsBaseCharQ(ch));
}
/**
* @deprecated Use #xmlIsBlank_ch or #xmlIsBlankQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsBlank(unsigned int ch) {
return(xmlIsBlankQ(ch));
}
/**
* @deprecated Use #xmlIsChar_ch or #xmlIsCharQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsChar(unsigned int ch) {
return(xmlIsCharQ(ch));
}
/**
* @deprecated Use #xmlIsCombiningQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsCombining(unsigned int ch) {
return(xmlIsCombiningQ(ch));
}
/**
* @deprecated Use #xmlIsDigit_ch or #xmlIsDigitQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsDigit(unsigned int ch) {
return(xmlIsDigitQ(ch));
}
/**
* @deprecated Use #xmlIsExtender_ch or #xmlIsExtenderQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsExtender(unsigned int ch) {
return(xmlIsExtenderQ(ch));
}
/**
* @deprecated Use #xmlIsIdeographicQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsIdeographic(unsigned int ch) {
return(xmlIsIdeographicQ(ch));
}
/**
* @deprecated Use #xmlIsPubidChar_ch or #xmlIsPubidCharQ.
*
* @param ch character to validate
* @returns true if argument valid, false otherwise
*/
int
xmlIsPubidChar(unsigned int ch) {
return(xmlIsPubidCharQ(ch));
}
File diff suppressed because it is too large Load Diff
+66
View File
@@ -0,0 +1,66 @@
static const char xmlEscapeContent[] = {
8, '&', '#', 'x', 'F', 'F', 'F', 'D', ';', 4, '&', '#',
'9', ';', 5, '&', '#', '1', '0', ';', 5, '&', '#', '1',
'3', ';', 6, '&', 'q', 'u', 'o', 't', ';', 5, '&', 'a',
'm', 'p', ';', 4, '&', 'l', 't', ';', 4, '&', 'g', 't',
';',
};
static const signed char xmlEscapeTab[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 20, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 39, -1, 44, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};
static const signed char xmlEscapeTabQuot[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 20, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, -1, 26, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 39, -1, 44, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};
static const signed char xmlEscapeTabAttr[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 14, 0, 0, 20, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, -1, 26, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 39, -1, 44, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};
#ifdef LIBXML_HTML_ENABLED
static const signed char htmlEscapeTab[128] = {
0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 39, -1, 44, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};
static const signed char htmlEscapeTabAttr[128] = {
0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, 26, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 39, -1, 44, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};
#endif /* LIBXML_HTML_ENABLED */
+379
View File
@@ -0,0 +1,379 @@
#!/usr/bin/env python3
def printHexTable(out, width, data):
s = ''
for i in range(len(data)):
if i % 8 == 0:
s += ' '
else:
s += ' '
s += f'0x{data[i]:{f"0{width}x"}},'
if i % 8 == 7:
out.write(s + '\n')
s = ''
def genTranscodeTable(out, name, chars):
# For two-byte sequences, we look up a row with 64 entries.
row_ids = [ 0 ] * 32
# For three-byte sequences, we look up a plane with 64 entries,
# indexing into rows.
plane_ids = [ 0 ] * 16
data = [ 0 ] * 64
o = 0x80
for cp in chars:
if cp != 0:
if cp < 0x0800:
# The lower five bits of the first byte in a
# two-byte sequence are used to find the row.
i = cp // 64
index = row_ids[i]
if index == 0:
index = len(data) // 64
data += [ 0 ] * 64
row_ids[i] = index
else:
# The lower four bits of the first byte in a
# three-byte sequence are used to find the plane.
i = cp // (64 * 64)
index2 = plane_ids[i]
if index2 == 0:
index2 = len(data) // 64
data += [ 0 ] * 64
plane_ids[i] = index2
# The lower six bits of the second byte in a
# three-byte sequence are used to find the row.
i = index2 * 64 + cp // 64 % 64
index = data[i]
if index == 0:
index = len(data) // 64
data += [ 0 ] * 64
data[i] = index
# The lower six bits in the last byte are
# used to lookup the codepoint.
data[index * 64 + cp % 64] = o
o += 1
out.write('static const unsigned short ')
out.write(f'xmlunicodetable_{name} [128] = {{\n')
printHexTable(out, 4, chars)
out.write('};\n\n')
num_chunks = len(data) // 64
out.write('static const unsigned char ')
out.write(f'xmltranscodetable_{name} [48 + {num_chunks} * 64] = {{\n')
printHexTable(out, 2, row_ids)
printHexTable(out, 2, plane_ids)
printHexTable(out, 2, data)
out.write('};\n\n')
out = open(f'codegen/charset.inc', 'w')
out.write('''/*
* Lookup tables for transcoding of 8-bit character sets.
*
* Generated with tools/genTranscode.py.
*/
''')
genTranscodeTable(out, 'windows_1252', [
0x20ac, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008d, 0x017d, 0x008f,
0x0090, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x009d, 0x017e, 0x0178,
0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
])
out.write(r'''#if !defined(LIBXML_ICONV_ENABLED) && \
!defined(LIBXML_ICU_ENABLED) && \
defined(LIBXML_ISO8859X_ENABLED)
''')
genTranscodeTable(out, 'ISO8859_2', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7,
0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b,
0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7,
0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c,
0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7,
0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7,
0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7,
0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7,
0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9,
])
genTranscodeTable(out, 'ISO8859_3', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x0126, 0x02d8, 0x00a3, 0x00a4, 0x0000, 0x0124, 0x00a7,
0x00a8, 0x0130, 0x015e, 0x011e, 0x0134, 0x00ad, 0x0000, 0x017b,
0x00b0, 0x0127, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x0125, 0x00b7,
0x00b8, 0x0131, 0x015f, 0x011f, 0x0135, 0x00bd, 0x0000, 0x017c,
0x00c0, 0x00c1, 0x00c2, 0x0000, 0x00c4, 0x010a, 0x0108, 0x00c7,
0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x0000, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x0120, 0x00d6, 0x00d7,
0x011c, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x016c, 0x015c, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x0000, 0x00e4, 0x010b, 0x0109, 0x00e7,
0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x0000, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x0121, 0x00f6, 0x00f7,
0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9,
])
genTranscodeTable(out, 'ISO8859_4', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x0104, 0x0138, 0x0156, 0x00a4, 0x0128, 0x013b, 0x00a7,
0x00a8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00ad, 0x017d, 0x00af,
0x00b0, 0x0105, 0x02db, 0x0157, 0x00b4, 0x0129, 0x013c, 0x02c7,
0x00b8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014a, 0x017e, 0x014b,
0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x012a,
0x0110, 0x0145, 0x014c, 0x0136, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x0168, 0x016a, 0x00df,
0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x012b,
0x0111, 0x0146, 0x014d, 0x0137, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9,
])
genTranscodeTable(out, 'ISO8859_5', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x00ad, 0x040e, 0x040f,
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f,
])
genTranscodeTable(out, 'ISO8859_6', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x0000, 0x0000, 0x0000, 0x00a4, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x060c, 0x00ad, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x061b, 0x0000, 0x0000, 0x0000, 0x061f,
0x0000, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f,
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637,
0x0638, 0x0639, 0x063a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647,
0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f,
0x0650, 0x0651, 0x0652, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
])
genTranscodeTable(out, 'ISO8859_7', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x2018, 0x2019, 0x00a3, 0x0000, 0x0000, 0x00a6, 0x00a7,
0x00a8, 0x00a9, 0x0000, 0x00ab, 0x00ac, 0x00ad, 0x0000, 0x2015,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x0384, 0x0385, 0x0386, 0x00b7,
0x0388, 0x0389, 0x038a, 0x00bb, 0x038c, 0x00bd, 0x038e, 0x038f,
0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f,
0x03a0, 0x03a1, 0x0000, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7,
0x03a8, 0x03a9, 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af,
0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7,
0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7,
0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0x0000,
])
genTranscodeTable(out, 'ISO8859_8', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x0000, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2017,
0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
0x05e8, 0x05e9, 0x05ea, 0x0000, 0x0000, 0x200e, 0x200f, 0x0000,
])
genTranscodeTable(out, 'ISO8859_9', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff,
])
genTranscodeTable(out, 'ISO8859_10', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x0104, 0x0112, 0x0122, 0x012a, 0x0128, 0x0136, 0x00a7,
0x013b, 0x0110, 0x0160, 0x0166, 0x017d, 0x00ad, 0x016a, 0x014a,
0x00b0, 0x0105, 0x0113, 0x0123, 0x012b, 0x0129, 0x0137, 0x00b7,
0x013c, 0x0111, 0x0161, 0x0167, 0x017e, 0x2015, 0x016b, 0x014b,
0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x00cf,
0x00d0, 0x0145, 0x014c, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x0168,
0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x00ef,
0x00f0, 0x0146, 0x014d, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x0169,
0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x0138,
])
genTranscodeTable(out, 'ISO8859_11', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07,
0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f,
0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17,
0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f,
0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27,
0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f,
0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37,
0x0e38, 0x0e39, 0x0e3a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0e3f,
0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47,
0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f,
0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57,
0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0x0000, 0x0000, 0x0000, 0x0000,
])
genTranscodeTable(out, 'ISO8859_13', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x201d, 0x00a2, 0x00a3, 0x00a4, 0x201e, 0x00a6, 0x00a7,
0x00d8, 0x00a9, 0x0156, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00c6,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x201c, 0x00b5, 0x00b6, 0x00b7,
0x00f8, 0x00b9, 0x0157, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00e6,
0x0104, 0x012e, 0x0100, 0x0106, 0x00c4, 0x00c5, 0x0118, 0x0112,
0x010c, 0x00c9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012a, 0x013b,
0x0160, 0x0143, 0x0145, 0x00d3, 0x014c, 0x00d5, 0x00d6, 0x00d7,
0x0172, 0x0141, 0x015a, 0x016a, 0x00dc, 0x017b, 0x017d, 0x00df,
0x0105, 0x012f, 0x0101, 0x0107, 0x00e4, 0x00e5, 0x0119, 0x0113,
0x010d, 0x00e9, 0x017a, 0x0117, 0x0123, 0x0137, 0x012b, 0x013c,
0x0161, 0x0144, 0x0146, 0x00f3, 0x014d, 0x00f5, 0x00f6, 0x00f7,
0x0173, 0x0142, 0x015b, 0x016b, 0x00fc, 0x017c, 0x017e, 0x2019,
])
genTranscodeTable(out, 'ISO8859_14', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x1e02, 0x1e03, 0x00a3, 0x010a, 0x010b, 0x1e0a, 0x00a7,
0x1e80, 0x00a9, 0x1e82, 0x1e0b, 0x1ef2, 0x00ad, 0x00ae, 0x0178,
0x1e1e, 0x1e1f, 0x0120, 0x0121, 0x1e40, 0x1e41, 0x00b6, 0x1e56,
0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61,
0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x0174, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x1e6a,
0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x0176, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x0175, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x1e6b,
0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0177, 0x00ff,
])
genTranscodeTable(out, 'ISO8859_15', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x0160, 0x00a7,
0x0161, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x017d, 0x00b5, 0x00b6, 0x00b7,
0x017e, 0x00b9, 0x00ba, 0x00bb, 0x0152, 0x0153, 0x0178, 0x00bf,
0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
])
genTranscodeTable(out, 'ISO8859_16', [
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
0x00a0, 0x0104, 0x0105, 0x0141, 0x20ac, 0x201e, 0x0160, 0x00a7,
0x0161, 0x00a9, 0x0218, 0x00ab, 0x0179, 0x00ad, 0x017a, 0x017b,
0x00b0, 0x00b1, 0x010c, 0x0142, 0x017d, 0x201d, 0x00b6, 0x00b7,
0x017e, 0x010d, 0x0219, 0x00bb, 0x0152, 0x0153, 0x0178, 0x017c,
0x00c0, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0106, 0x00c6, 0x00c7,
0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
0x0110, 0x0143, 0x00d2, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x015a,
0x0170, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0118, 0x021a, 0x00df,
0x00e0, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x0107, 0x00e6, 0x00e7,
0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
0x0111, 0x0144, 0x00f2, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x015b,
0x0171, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0119, 0x021b, 0x00ff,
])
out.write('#endif /* LIBXML_ISO8859X_ENABLED */\n')
out.close()
+69
View File
@@ -0,0 +1,69 @@
#!/usr/bin/env python3
entities = [
[ '', '&#xFFFD;' ],
[ '\t', '&#9;' ],
[ '\n', '&#10;' ],
[ '\r', '&#13;' ],
[ '"', '&quot;' ],
[ '&', '&amp;' ],
[ '<', '&lt;' ],
[ '>', '&gt;' ],
]
offset = [ None ] * 128
def gen_content(out):
pos = 0
r = ''
for rec in entities:
char, repl = rec
if char:
offset[ord(char)] = pos
if pos % 12 == 0: r += '\n '
else: r += ' '
r += '%3d,' % len(repl)
pos += 1
for c in repl:
if pos % 12 == 0: r += '\n '
else: r += ' '
r += "'%s'," % c
pos += 1
out.write('static const char xmlEscapeContent[] = {%s\n};\n\n' % r)
def gen_tab(out, name, escape, is_xml):
r = ''
for i in range(0x80):
if chr(i) in escape:
v = offset[i]
elif i == 0:
v = 0
elif is_xml and i < 32 and i != 9 and i != 10:
v = 0
else:
v = -1
if i % 16 == 0: r += '\n '
else: r += ' '
r += '%2d,' % v
out.write('static const signed char %s[128] = {%s\n};\n\n' % (name, r))
with open('codegen/escape.inc', 'w') as out:
gen_content(out)
gen_tab(out, 'xmlEscapeTab', '\r&<>', True)
gen_tab(out, 'xmlEscapeTabQuot', '\r"&<>', True)
gen_tab(out, 'xmlEscapeTabAttr', '\t\n\r"&<>', True)
out.write('#ifdef LIBXML_HTML_ENABLED\n\n')
gen_tab(out, 'htmlEscapeTab', '&<>', False)
gen_tab(out, 'htmlEscapeTabAttr', '"&<>', False)
out.write('#endif /* LIBXML_HTML_ENABLED */\n')
+170
View File
@@ -0,0 +1,170 @@
#!/usr/bin/env python3
import json
import sys
from dataclasses import dataclass
# The basic idea is to find named character references using binary
# search. Since entity strings may not have a terminator, this doesn't
# work if one entity string is a prefix of another. In this case,
# we branch to a subtable after matching the prefix.
#
# We create separate initial tables based on the first character
# of the entity name.
#
# The following tables are generated:
#
# htmlEntAlpha: start and end of initial tables, indexing into
# htmlEntValues
# htmlEntValues: concatenation of all table values, which index into
# htmlEntStrings
# htmlEntStrings: variable sized records containing entity name,
# replacement and optionally the position of a
# subtable
try:
with open('entities.json') as json_data:
ents = json.load(json_data)
except FileNotFoundError:
print('entities.json not found, try curl -LJO',
'https://html.spec.whatwg.org/entities.json')
sys.exit(1)
def to_cchars(s):
r = []
for c in s.encode():
if c >= 0x20 and c <= 0x7E and c != ord("'") and c != ord('\\'):
v = f"'{chr(c)}'"
else:
v = c
r += [ v ]
return r
@dataclass
class PrefixStackEntry:
prefix: str
table_id: int
@dataclass
class AlphaFixup:
table_id: int
char: int
@dataclass
class StringFixup:
table_id: int
string_index: int
super_table_id: int
super_offset: int
# Remove entity strings without trailing semicolon
keys = (key for key in ents.keys() if key.endswith(';'))
# Sort entity strings
keys = sorted(keys, key=lambda k: k[1:-1])
strings = []
tables = []
prefix_stack = []
alpha_fixups = []
string_fixups = []
for i in range(64):
tables.append([])
for i, key in enumerate(keys):
name = key[1:-1]
next_name = None
if i + 1 < len(keys):
next_name = keys[i+1][1:-1]
while prefix_stack and not name.startswith(prefix_stack[-1].prefix):
prefix_stack.pop()
# First character is initial prefix
if not prefix_stack:
table_id = len(tables)
tables.append([])
prefix_stack.append(PrefixStackEntry(name[0], table_id))
alpha_fixups.append(AlphaFixup(table_id, ord(name[0]) % 64))
string_index = len(strings)
table = tables[prefix_stack[-1].table_id]
table_index = len(table)
table.append(string_index)
name_offset = len(prefix_stack[-1].prefix)
name_chars = to_cchars(name[name_offset:])
repl_chars = to_cchars(ents[key]['characters'])
semicolon_flag = 0
if key[:-1] in ents:
semicolon_flag = 0x80
if next_name and next_name.startswith(name):
# Create subtable
strings += [
len(name_chars) | semicolon_flag | 0x40, *name_chars,
0, 0, # subtable position, to be fixed up
len(repl_chars), *repl_chars,
]
table_id = len(tables)
tables.append([])
fixup_index = string_index + 1 + len(name_chars)
string_fixups.append(StringFixup(
table_id, fixup_index, prefix_stack[-1].table_id, table_index,
))
prefix_stack.append(PrefixStackEntry(name, table_id))
else:
strings += [
len(name_chars) | semicolon_flag, *name_chars,
len(repl_chars), *repl_chars,
]
# Concat tables and record ranges
ranges = [ 0 ]
values = []
for table in tables:
values += table
ranges.append(len(values))
# Create alpha table
alpha = [ 0 ] * (59 * 3)
for fixup in alpha_fixups:
table_id, c = fixup.table_id, fixup.char
start = ranges[table_id]
end = ranges[table_id+1]
alpha[c*3:c*3+3] = [ start & 0xFF, start >> 8, end - start ]
# Fix up subtable positions
for fixup in string_fixups:
table_id, i = fixup.table_id, fixup.string_index
start = ranges[table_id]
end = ranges[table_id+1]
super_index = ranges[fixup.super_table_id] + fixup.super_offset
strings[i:i+2] = [ start - super_index, end - start ]
# Print tables
def gen_table(ctype, cname, values, fmt, elems_per_line):
count = len(values)
r = ''
for i in range(count):
if i != 0: r += ','
if i % elems_per_line == 0: r += '\n '
else: r += ' '
r += fmt % values[i]
return f'static const {ctype} {cname}[{count}] = {{{r}\n}};\n\n'
with open('codegen/html5ent.inc', 'w') as out:
out.write(gen_table('unsigned char', 'htmlEntAlpha', alpha, '%3d', 15))
out.write(gen_table('unsigned short', 'htmlEntValues', values, '%5d', 10))
out.write(gen_table('unsigned char', 'htmlEntStrings', strings, '%3s', 15))
+93
View File
@@ -0,0 +1,93 @@
#!/usr/bin/env python3
import glob
import json
import re
state_map = {
'Data state': 0,
'RCDATA state': 1,
'RAWTEXT state': 2,
'PLAINTEXT state': 3,
'Script data state': 4,
'CDATA section state': 5,
}
for filename in sorted(glob.glob('../html5lib-tests/tokenizer/*.test')):
match = re.search('/([^/]*).test$', filename)
if match is None:
continue
testname = match[1]
if testname == 'xmlViolation':
continue
with open(filename) as json_data:
root = json.load(json_data)
test_out = open(f'test/html-tokenizer/{testname}.test', 'w')
result_out = open(f'result/html-tokenizer/{testname}.test', 'w')
counter = 0
for tests in root.values():
for test in tests:
input = test['input']
# Skip surrogate tests
if re.search(r'\\uD[89A-F]', input, re.I):
continue
input = re.sub(r'\\u([A-Fa-f0-9]{4})',
lambda m: chr(int(m[1], 16)),
input)
output = ''
for token in test['output']:
if token[1] == '\0':
continue
output += token[0] + '\n'
if token[0] == 'DOCTYPE':
for i in range(1, 4):
if token[i] is None:
output += '<none>\n'
else:
output += token[i] + '\n'
else:
output += token[1]
if token[0] == 'StartTag':
for name, value in token[2].items():
output += f' {name}={value}'
output += '\n'
output = re.sub(r'\\u([A-Fa-f0-9]{4})',
lambda m: chr(int(m[1], 16)),
output)
# The HTML5 spec splits handling of U+0000 across
# tokenizer and tree builder. We already ignore
# U+0000 in body text when tokenizing.
output = re.sub(r'\x00', '', output)
for state in test.get('initialStates', ['Data state']):
state_no = state_map.get(state)
if state_no is None:
raise Exception(f'{filename}: unknown state: {state}')
if state_no == 5:
continue
start_tag = test.get('lastStartTag', '-')
test_out.write(f'{counter} {start_tag} {state_no} '
f'{len(input.encode())}\n')
test_out.write(input)
test_out.write('\n')
result_out.write(f'{counter}\n')
result_out.write(output)
counter += 1
test_out.close()
result_out.close()
+222
View File
@@ -0,0 +1,222 @@
#!/usr/bin/env python3
#
# Portions of this script have been (shamelessly) stolen from the
# prior work of Daniel Veillard (genUnicode.py)
#
# I, however, take full credit for any bugs, errors or difficulties :-)
#
# William Brack
# October 2003
#
# 18 October 2003
# Modified to maintain binary compatibility with previous library versions
# by adding a suffix 'Q' ('quick') to the macro generated for the original,
# function, and adding generation of a function (with the original name) which
# instantiates the macro.
#
import sys
import rangetab
#
# A routine to take a list of yes/no (1, 0) values and turn it
# into a list of ranges. This will later be used to determine whether
# to generate single-byte lookup tables, or inline comparisons
#
def makeRange(lst):
ret = []
pos = 0
while pos < len(lst):
try: # index generates exception if not present
s = lst[pos:].index(1) # look for start of next range
except:
break # if no more, finished
pos += s # pointer to start of possible range
try:
e = lst[pos:].index(0) # look for end of range
e += pos
except: # if no end, set to end of list
e = len(lst)
ret.append((pos, e-1)) # append range tuple to list
pos = e + 1 # ready to check for next range
return ret
# minTableSize gives the minimum number of ranges which must be present
# before a 256-byte lookup table is produced. If there are less than this
# number, a macro with inline comparisons is generated
minTableSize = 6
# dictionary of functions, key=name, element contains char-map and range-list
Functs = {}
state = 0
try:
defines = open("codegen/ranges.def", "r")
except:
print("Missing codegen/ranges.def, aborting ...")
sys.exit(1)
#
# The lines in the .def file have three types:-
# name: Defines a new function block
# ur: Defines individual or ranges of unicode values
# end: Indicates the end of the function block
#
# These lines are processed below.
#
for line in defines.readlines():
# ignore blank lines, or lines beginning with '#'
if line[0] == '#':
continue
line = line.strip()
if line == '':
continue
# split line into space-separated fields, then split on type
try:
fields = line.split(' ')
#
# name line:
# validate any previous function block already ended
# validate this function not already defined
# initialize an entry in the function dicitonary
# including a mask table with no values yet defined
#
if fields[0] == 'name':
name = fields[1]
if state != 0:
print("'name' %s found before previous name" \
"completed" % (fields[1]))
continue
state = 1
if name in Functs:
print("name '%s' already present - may give" \
" wrong results" % (name))
else:
# dict entry with two list elements (chdata, rangedata)
Functs[name] = [ [], [] ]
for v in range(256):
Functs[name][0].append(0)
#
# end line:
# validate there was a preceding function name line
# set state to show no current function active
#
elif fields[0] == 'end':
if state == 0:
print("'end' found outside of function block")
continue
state = 0
#
# ur line:
# validate function has been defined
# process remaining fields on the line, which may be either
# individual unicode values or ranges of values
#
elif fields[0] == 'ur':
if state != 1:
raise Exception("'ur' found outside of 'name' block")
for el in fields[1:]:
pos = el.find('..')
# pos <=0 means not a range, so must be individual value
if pos <= 0:
# cheap handling of hex or decimal values
if el[0:2] == '0x':
value = int(el[2:],16)
elif el[0] == "'":
value = ord(el[1])
else:
value = int(el)
if ((value < 0) | (value > 0x1fffff)):
raise Exception('Illegal value (%s) in ch for'\
' name %s' % (el,name))
# for ur we have only ranges (makes things simpler),
# so convert val to range
currange = (value, value)
# pos > 0 means this is a range, so isolate/validate
# the interval
else:
# split the range into it's first-val, last-val
(first, last) = el.split("..")
# convert values from text into binary
if first[0:2] == '0x':
start = int(first[2:],16)
elif first[0] == "'":
start = ord(first[1])
else:
start = int(first)
if last[0:2] == '0x':
end = int(last[2:],16)
elif last[0] == "'":
end = ord(last[1])
else:
end = int(last)
if (start < 0) | (end > 0x1fffff) | (start > end):
raise Exception("Invalid range '%s'" % el)
currange = (start, end)
# common path - 'currange' has the range, now take care of it
# We split on single-byte values vs. multibyte
if currange[1] < 0x100: # single-byte
for ch in range(currange[0],currange[1]+1):
# validate that value not previously defined
if Functs[name][0][ch]:
msg = "Duplicate ch value '%s' for name '%s'" % (el, name)
raise Exception(msg)
Functs[name][0][ch] = 1
else: # multi-byte
if currange in Functs[name][1]:
raise Exception("range already defined in" \
" function")
else:
Functs[name][1].append(currange)
except:
print("Failed to process line: %s" % (line))
raise
try:
output = open("codegen/ranges.inc", "w")
except:
print("Failed to open codegen/ranges.inc")
sys.exit(1)
#
# Now output the generated data.
#
fkeys = sorted(Functs.keys())
for f in fkeys:
# First we convert the specified single-byte values into a group of ranges.
if max(Functs[f][0]) > 0: # only check if at least one entry
rangeTable = makeRange(Functs[f][0])
numRanges = len(rangeTable)
if numRanges >= minTableSize: # table is worthwhile
# write the constant data to the code file
output.write("const unsigned char %s_tab[256] = {\n" % f)
pline = " "
for n in range(255):
pline += " 0x%02x," % Functs[f][0][n]
if len(pline) > 72:
output.write(pline + "\n")
pline = " "
output.write(pline + " 0x%02x };\n\n" % Functs[f][0][255])
#
# Next we do the unicode ranges
#
for f in fkeys:
if len(Functs[f][1]) > 0: # only generate if unicode ranges present
rangeTable = Functs[f][1]
rangeTable.sort() # ascending tuple sequence
group = rangetab.gen_range_tables(output, f, '_srng', '_lrng',
rangeTable)
output.write("const xmlChRangeGroup %sGroup =\n\t%s;\n\n" %
(f, group))
output.close()
+285
View File
@@ -0,0 +1,285 @@
#!/usr/bin/env python3
#
# generate a test program for the API
#
import xml.etree.ElementTree as etree
import os
import re
import sys
import xmlmod
# Globals
dtors = {
'htmlDoc *': 'xmlFreeDoc',
'htmlParserCtxt *': 'htmlFreeParserCtxt',
'xmlAutomata *': 'xmlFreeAutomata',
'xmlBuffer *': 'xmlBufferFree',
'xmlCatalog *': 'xmlFreeCatalog',
'xmlChar *': 'xmlFree',
'xmlDOMWrapCtxt *': 'xmlDOMWrapFreeCtxt',
'xmlDict *': 'xmlDictFree',
'xmlDoc *': 'xmlFreeDoc',
'xmlDtd *': 'xmlFreeDtd',
'xmlEntitiesTable *': 'xmlFreeEntitiesTable',
'xmlElementContent *': 'xmlFreeElementContent',
'xmlEnumeration *': 'xmlFreeEnumeration',
'xmlList *': 'xmlListDelete',
'xmlModule *': 'xmlModuleFree',
'xmlMutex *': 'xmlFreeMutex',
'xmlNode *': 'xmlFreeNode',
'xmlNodeSet *': 'xmlXPathFreeNodeSet',
'xmlNs *': 'xmlFreeNs',
'xmlOutputBuffer *': 'xmlOutputBufferClose',
'xmlParserCtxt *': 'xmlFreeParserCtxt',
'xmlParserInputBuffer *': 'xmlFreeParserInputBuffer',
'xmlParserInput *': 'xmlFreeInputStream',
'xmlRMutex *': 'xmlFreeRMutex',
'xmlRelaxNGValidCtxt *': 'xmlRelaxNGFreeValidCtxt',
'xmlSaveCtxt *': 'xmlSaveClose',
'xmlSchemaFacet *': 'xmlSchemaFreeFacet',
'xmlSchemaVal *': 'xmlSchemaFreeValue',
'xmlSchemaValidCtxt *': 'xmlSchemaFreeValidCtxt',
'xmlTextWriter *': 'xmlFreeTextWriter',
'xmlURI *': 'xmlFreeURI',
'xmlValidCtxt *': 'xmlFreeValidCtxt',
'xmlXPathContext *': 'xmlXPathFreeContext',
'xmlXPathParserContext *': 'xmlXPathFreeParserContext',
'xmlXPathObject *': 'xmlXPathFreeObject',
}
blockList = {
# init/cleanup
'xmlCleanupParser': True,
'xmlInitParser': True,
# arg must be non-NULL
'xmlMemStrdupLoc': True,
'xmlMemoryStrdup': True,
# Returns void pointer which must be freed
'xmlMallocAtomicLoc': True,
'xmlMallocLoc': True,
'xmlMemMalloc': True,
'xmlMemRealloc': True,
'xmlReallocLoc': True,
# Would reset the error handler
'xmlSetStructuredErrorFunc': True,
# Prints errors
'xmlCatalogGetPublic': True,
'xmlCatalogGetSystem': True,
'xmlDebugDumpDTD': True,
'xmlDebugDumpDocument': True,
'xmlDebugDumpNode': True,
'xmlDebugDumpString': True,
'xmlParserError': True,
'xmlParserWarning': True,
'xmlParserValidityError': True,
'xmlParserValidityWarning': True,
# Internal parser unctions, ctxt must be non-NULL
'xmlParseAttribute': True,
'xmlParseAttributeListDecl': True,
'xmlParseAttributeType': True,
'xmlParseCDSect': True,
'xmlParseCharData': True,
'xmlParseCharRef': True,
'xmlParseComment': True,
'xmlParseDefaultDecl': True,
'xmlParseDocTypeDecl': True,
'xmlParseEndTag': True,
'xmlParseElement': True,
'xmlParseElementChildrenContentDecl': True,
'xmlParseElementContentDecl': True,
'xmlParseElementDecl': True,
'xmlParseElementMixedContentDecl': True,
'xmlParseEncName': True,
'xmlParseEncodingDecl': True,
'xmlParseEntityDecl': True,
'xmlParseEntityValue': True,
'xmlParseEnumeratedType': True,
'xmlParseEnumerationType': True,
'xmlParseExternalID': True,
'xmlParseExternalSubset': True,
'xmlParseMarkupDecl': True,
'xmlParseMisc': True,
'xmlParseName': True,
'xmlParseNmtoken': True,
'xmlParseNotationDecl': True,
'xmlParseNotationType': True,
'xmlParsePEReference': True,
'xmlParsePI': True,
'xmlParsePITarget': True,
'xmlParsePubidLiteral': True,
'xmlParseReference': True,
'xmlParseSDDecl': True,
'xmlParseStartTag': True,
'xmlParseSystemLiteral': True,
'xmlParseTextDecl': True,
'xmlParseVersionInfo': True,
'xmlParseVersionNum': True,
'xmlParseXMLDecl': True,
'xmlParserHandlePEReference': True,
'xmlSkipBlankChars': True,
# reads from stdin
'htmlReadFd': True,
'xmlReadFd': True,
'xmlReaderForFd': True,
}
# Parse document
if len(sys.argv) > 1:
buildDir = sys.argv[1]
else:
buildDir = '.'
xmlDocDir = buildDir + '/doc/xml'
filenames = {}
functions = {}
for file in os.listdir(xmlDocDir):
if not file.endswith('_8h.xml'):
continue
doc = etree.parse(xmlDocDir + '/' + file)
compound = doc.find('compounddef')
module = compound.find('compoundname').text
if not module.endswith('.h'):
continue
module = module[:-2]
for section in compound.findall('sectiondef'):
if section.get('kind') != 'func':
continue
for func in section.findall('memberdef'):
name = func.find('name').text
if name in blockList:
continue
module1, module2 = xmlmod.findModules(module, name)
cargs = []
skip = False
for arg in func.findall('param'):
atype = etree.tostring(arg.find('type'),
method='text', encoding='unicode').rstrip()
if atype == 'void':
continue
if atype == 'va_list':
skip = True
break
if re.search(r'(Ptr|\*)$', atype):
cargs.append('NULL')
else:
cargs.append('0')
if skip:
continue
mfunc = functions.get(module1)
if mfunc is None:
mfunc = {}
functions[module1] = mfunc
mmfunc = mfunc.get(module2)
if mmfunc is None:
mmfunc = {}
mfunc[module2] = mmfunc
code = f'{name}({', '.join(cargs)})'
rtype = etree.tostring(func.find('type'),
method='text', encoding='unicode').rstrip()
dtor = dtors.get(rtype)
if dtor is not None:
code = f'{dtor}({code})'
elif rtype == 'xmlHashTable *':
code = f'xmlHashFree({code}, NULL)'
mmfunc[name] = f' {code};\n'
# Write output
test = open('testapi.c', 'w')
test.write("""/*
* testapi.c: libxml2 API tester program.
*
* Automatically generated by gentest.py
*
* See Copyright for the status of this software.
*/
/* Disable deprecation warnings */
#define XML_DEPRECATED
#include "libxml.h"
#include <libxml/HTMLparser.h>
#include <libxml/HTMLtree.h>
#include <libxml/c14n.h>
#include <libxml/catalog.h>
#include <libxml/debugXML.h>
#include <libxml/parserInternals.h>
#include <libxml/pattern.h>
#include <libxml/relaxng.h>
#include <libxml/schematron.h>
#include <libxml/uri.h>
#include <libxml/xinclude.h>
#include <libxml/xlink.h>
#include <libxml/xmlmodule.h>
#include <libxml/xmlreader.h>
#include <libxml/xmlsave.h>
#include <libxml/xmlschemas.h>
#include <libxml/xmlschemastypes.h>
#include <libxml/xmlwriter.h>
#include <libxml/xpathInternals.h>
#include <libxml/xpointer.h>
static void
ignoreError(void *userData ATTRIBUTE_UNUSED,
const xmlError *error ATTRIBUTE_UNUSED) {
}
int
main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
xmlInitParser();
xmlSetStructuredErrorFunc(NULL, ignoreError);
""")
for module1 in sorted(functions.keys()):
mfunc = functions[module1]
if module1 != '':
test.write(f'#ifdef LIBXML_{module1}_ENABLED\n')
for module2 in sorted(mfunc.keys()):
mmfunc = mfunc[module2]
if module2 != '':
test.write(f'#ifdef LIBXML_{module2}_ENABLED\n')
for name in sorted(mmfunc.keys()):
test.write(mmfunc[name])
if module2 != '':
test.write(f'#endif /* LIBXML_{module2}_ENABLED */\n')
if module1 != '':
test.write(f'#endif /* LIBXML_{module1}_ENABLED */\n')
test.write('\n')
test.write(""" xmlCleanupParser();
return 0;
}
""")
+252
View File
@@ -0,0 +1,252 @@
#!/usr/bin/env python3
#
# Original script modified in November 2003 to take advantage of
# the character-validation range routines, and updated to the
# current Unicode information (Version 4.0.1)
#
# NOTE: there is an 'alias' facility for blocks which are not present in
# the current release, but are needed for ABI compatibility. This
# must be accomplished MANUALLY! Please see the comments below under
# 'blockAliases'
#
import sys
import string
import rangetab
#
# blockAliases is a small hack - it is used for mapping block names which
# were were used in the 3.1 release, but are missing or changed in the current
# release. The format is "OldBlockName:NewBlockName1[,NewBlockName2[,...]]"
blockAliases = []
blockAliases.append("CombiningMarksforSymbols:CombiningDiacriticalMarksforSymbols")
blockAliases.append("Greek:GreekandCoptic")
blockAliases.append("PrivateUse:PrivateUseArea,SupplementaryPrivateUseArea-A," +
"SupplementaryPrivateUseArea-B")
# minTableSize gives the minimum number of ranges which must be present
# before a range table is produced. If there are less than this
# number, inline comparisons are generated
minTableSize = 8
blockfile = "Blocks-4.0.1.txt"
catfile = "UnicodeData-4.0.1.txt"
#
# Now process the "blocks" file, reducing it to a dictionary
# indexed by blockname, containing a tuple with the applicable
# block range
#
BlockNames = {}
try:
blocks = open(blockfile, "r")
except:
print("Missing %s, aborting ..." % blockfile)
sys.exit(1)
for line in blocks.readlines():
if line[0] == '#':
continue
line = line.strip()
if line == '':
continue
try:
fields = line.split(';')
range = fields[0].strip()
(start, end) = range.split("..")
name = fields[1].strip()
name = name.replace(' ', '')
except:
print("Failed to process line: %s" % (line))
continue
start = int(start, 16)
end = int(end, 16)
try:
BlockNames[name].append((start, end))
except:
BlockNames[name] = [(start, end)]
blocks.close()
print("Parsed %d blocks descriptions" % (len(BlockNames.keys())))
for block in blockAliases:
alias = block.split(':')
alist = alias[1].split(',')
for comp in alist:
if comp in BlockNames:
if alias[0] not in BlockNames:
BlockNames[alias[0]] = []
for r in BlockNames[comp]:
BlockNames[alias[0]].append(r)
else:
print("Alias %s: %s not in Blocks" % (alias[0], comp))
continue
#
# Next process the Categories file. This is more complex, since
# the file is in code sequence, and we need to invert it. We use
# a dictionary with index category-name, with each entry containing
# all the ranges (codepoints) of that category. Note that category
# names comprise two parts - the general category, and the "subclass"
# within that category. Therefore, both "general category" (which is
# the first character of the 2-character category-name) and the full
# (2-character) name are entered into this dictionary.
#
try:
data = open(catfile, "r")
except:
print("Missing %s, aborting ..." % catfile)
sys.exit(1)
nbchar = 0;
Categories = {}
for line in data.readlines():
if line[0] == '#':
continue
line = line.strip()
if line == '':
continue
try:
fields = line.split(';')
point = fields[0].strip()
value = 0
while point != '':
value = value * 16
if point[0] >= '0' and point[0] <= '9':
value = value + ord(point[0]) - ord('0')
elif point[0] >= 'A' and point[0] <= 'F':
value = value + 10 + ord(point[0]) - ord('A')
elif point[0] >= 'a' and point[0] <= 'f':
value = value + 10 + ord(point[0]) - ord('a')
point = point[1:]
name = fields[2]
except:
print("Failed to process line: %s" % (line))
continue
nbchar = nbchar + 1
# update entry for "full name"
try:
Categories[name].append(value)
except:
try:
Categories[name] = [value]
except:
print("Failed to process line: %s" % (line))
# update "general category" name
try:
Categories[name[0]].append(value)
except:
try:
Categories[name[0]] = [value]
except:
print("Failed to process line: %s" % (line))
data.close()
print("Parsed %d char generating %d categories" % (nbchar, len(Categories.keys())))
#
# The data is now all read. Time to process it into a more useful form.
#
# reduce the number list into ranges
for cat in Categories.keys():
list = Categories[cat]
start = -1
prev = -1
end = -1
ranges = []
for val in list:
if start == -1:
start = val
prev = val
continue
elif val == prev + 1:
prev = val
continue
elif prev == start:
ranges.append((prev, prev))
start = val
prev = val
continue
else:
ranges.append((start, prev))
start = val
prev = val
continue
if prev == start:
ranges.append((prev, prev))
else:
ranges.append((start, prev))
Categories[cat] = ranges
#
# Assure all data is in alphabetic order, since we will be doing binary
# searches on the tables.
#
bkeys = sorted(BlockNames.keys())
ckeys = sorted(Categories.keys())
#
# Generate the resulting files
#
try:
output = open("codegen/unicode.inc", "w")
except:
print("Failed to open codegen/unicode.inc")
sys.exit(1)
#
# For any categories with more than minTableSize ranges we generate
# a range table suitable for xmlCharInRange
#
for name in ckeys:
if len(Categories[name]) <= minTableSize or name == 'Cs':
continue
ranges = Categories[name]
group = rangetab.gen_range_tables(output, 'xml' + name, 'S', 'L', ranges)
output.write("static const xmlChRangeGroup xml%sG = %s;\n\n" %
(name, group))
for name in ckeys:
if name == 'Cs':
continue
ranges = Categories[name]
output.write("static int\nxmlUCSIsCat%s(int code) {\n" % name)
if len(Categories[name]) > minTableSize:
output.write(" return(xmlCharInRange((unsigned int)code, &xml%sG)"
% name)
else:
start = 1
for range in ranges:
(begin, end) = range;
if start:
output.write(" return(");
start = 0
else:
output.write(" ||\n ");
if (begin == end):
output.write("(code == %s)" % (hex(begin)))
else:
output.write("((code >= %s) && (code <= %s))" % (
hex(begin), hex(end)))
output.write(");\n}\n\n")
#
# Range tables for blocks
#
blockGroups = ''
for block in bkeys:
name = block.replace('-', '')
ranges = BlockNames[block]
group = rangetab.gen_range_tables(output, 'xml' + name, 'S', 'L', ranges)
output.write("\n")
if blockGroups != '':
blockGroups += ",\n"
blockGroups += ' {"%s",\n %s}' % (block, group)
output.write("static const xmlUnicodeRange xmlUnicodeBlocks[] = {\n")
output.write(blockGroups)
output.write("\n};\n\n")
output.close()
File diff suppressed because it is too large Load Diff
+361
View File
@@ -0,0 +1,361 @@
name xmlIsChar
ur 0x9
ur 0xA
ur 0xD
ur 0x20..0xFF
ur 0x0100..0xD7FF
ur 0xE000..0xFFFD
ur 0x10000..0x10FFFF
end xmlIsChar
name xmlIsPubidChar
ur 0x20 0x0d 0x0a 'a'..'z' 'A'..'Z' '0'..'9'
ur '-' 0x27 '(' ')' '+' ',' '.' '/'
ur ':' '=' '?' ';' '!' '*' '#' '@'
ur '$' '_' '%'
end
name xmlIsBlank
ur 0x09 0x0a 0x0d 0x20
end xmlIsBlank
name xmlIsBaseChar
ur 0x0041..0x005A
ur 0x0061..0x007A
ur 0x00C0..0x00D6
ur 0x00D8..0x00F6
ur 0x00F8..0x00FF
ur 0x0100..0x0131
ur 0x0134..0x013E
ur 0x0141..0x0148
ur 0x014A..0x017E
ur 0x0180..0x01C3
ur 0x01CD..0x01F0
ur 0x01F4..0x01F5
ur 0x01FA..0x0217
ur 0x0250..0x02A8
ur 0x02BB..0x02C1
ur 0x0386
ur 0x0388..0x038A
ur 0x038C
ur 0x038E..0x03A1
ur 0x03A3..0x03CE
ur 0x03D0..0x03D6
ur 0x03DA
ur 0x03DC
ur 0x03DE
ur 0x03E0
ur 0x03E2..0x03F3
ur 0x0401..0x040C
ur 0x040E..0x044F
ur 0x0451..0x045C
ur 0x045E..0x0481
ur 0x0490..0x04C4
ur 0x04C7..0x04C8
ur 0x04CB..0x04CC
ur 0x04D0..0x04EB
ur 0x04EE..0x04F5
ur 0x04F8..0x04F9
ur 0x0531..0x0556
ur 0x0559
ur 0x0561..0x0586
ur 0x05D0..0x05EA
ur 0x05F0..0x05F2
ur 0x0621..0x063A
ur 0x0641..0x064A
ur 0x0671..0x06B7
ur 0x06BA..0x06BE
ur 0x06C0..0x06CE
ur 0x06D0..0x06D3
ur 0x06D5
ur 0x06E5..0x06E6
ur 0x0905..0x0939
ur 0x093D
ur 0x0958..0x0961
ur 0x0985..0x098C
ur 0x098F..0x0990
ur 0x0993..0x09A8
ur 0x09AA..0x09B0
ur 0x09B2
ur 0x09B6..0x09B9
ur 0x09DC..0x09DD
ur 0x09DF..0x09E1
ur 0x09F0..0x09F1
ur 0x0A05..0x0A0A
ur 0x0A0F..0x0A10
ur 0x0A13..0x0A28
ur 0x0A2A..0x0A30
ur 0x0A32..0x0A33
ur 0x0A35..0x0A36
ur 0x0A38..0x0A39
ur 0x0A59..0x0A5C
ur 0x0A5E
ur 0x0A72..0x0A74
ur 0x0A85..0x0A8B
ur 0x0A8D
ur 0x0A8F..0x0A91
ur 0x0A93..0x0AA8
ur 0x0AAA..0x0AB0
ur 0x0AB2..0x0AB3
ur 0x0AB5..0x0AB9
ur 0x0ABD
ur 0x0AE0
ur 0x0B05..0x0B0C
ur 0x0B0F..0x0B10
ur 0x0B13..0x0B28
ur 0x0B2A..0x0B30
ur 0x0B32..0x0B33
ur 0x0B36..0x0B39
ur 0x0B3D
ur 0x0B5C..0x0B5D
ur 0x0B5F..0x0B61
ur 0x0B85..0x0B8A
ur 0x0B8E..0x0B90
ur 0x0B92..0x0B95
ur 0x0B99..0x0B9A
ur 0x0B9C
ur 0x0B9E..0x0B9F
ur 0x0BA3..0x0BA4
ur 0x0BA8..0x0BAA
ur 0x0BAE..0x0BB5
ur 0x0BB7..0x0BB9
ur 0x0C05..0x0C0C
ur 0x0C0E..0x0C10
ur 0x0C12..0x0C28
ur 0x0C2A..0x0C33
ur 0x0C35..0x0C39
ur 0x0C60..0x0C61
ur 0x0C85..0x0C8C
ur 0x0C8E..0x0C90
ur 0x0C92..0x0CA8
ur 0x0CAA..0x0CB3
ur 0x0CB5..0x0CB9
ur 0x0CDE
ur 0x0CE0..0x0CE1
ur 0x0D05..0x0D0C
ur 0x0D0E..0x0D10
ur 0x0D12..0x0D28
ur 0x0D2A..0x0D39
ur 0x0D60..0x0D61
ur 0x0E01..0x0E2E
ur 0x0E30
ur 0x0E32..0x0E33
ur 0x0E40..0x0E45
ur 0x0E81..0x0E82
ur 0x0E84
ur 0x0E87..0x0E88
ur 0x0E8A
ur 0x0E8D
ur 0x0E94..0x0E97
ur 0x0E99..0x0E9F
ur 0x0EA1..0x0EA3
ur 0x0EA5
ur 0x0EA7
ur 0x0EAA..0x0EAB
ur 0x0EAD..0x0EAE
ur 0x0EB0
ur 0x0EB2..0x0EB3
ur 0x0EBD
ur 0x0EC0..0x0EC4
ur 0x0F40..0x0F47
ur 0x0F49..0x0F69
ur 0x10A0..0x10C5
ur 0x10D0..0x10F6
ur 0x1100
ur 0x1102..0x1103
ur 0x1105..0x1107
ur 0x1109
ur 0x110B..0x110C
ur 0x110E..0x1112
ur 0x113C
ur 0x113E
ur 0x1140
ur 0x114C
ur 0x114E
ur 0x1150
ur 0x1154..0x1155
ur 0x1159
ur 0x115F..0x1161
ur 0x1163
ur 0x1165
ur 0x1167
ur 0x1169
ur 0x116D..0x116E
ur 0x1172..0x1173
ur 0x1175
ur 0x119E
ur 0x11A8
ur 0x11AB
ur 0x11AE..0x11AF
ur 0x11B7..0x11B8
ur 0x11BA
ur 0x11BC..0x11C2
ur 0x11EB
ur 0x11F0
ur 0x11F9
ur 0x1E00..0x1E9B
ur 0x1EA0..0x1EF9
ur 0x1F00..0x1F15
ur 0x1F18..0x1F1D
ur 0x1F20..0x1F45
ur 0x1F48..0x1F4D
ur 0x1F50..0x1F57
ur 0x1F59
ur 0x1F5B
ur 0x1F5D
ur 0x1F5F..0x1F7D
ur 0x1F80..0x1FB4
ur 0x1FB6..0x1FBC
ur 0x1FBE
ur 0x1FC2..0x1FC4
ur 0x1FC6..0x1FCC
ur 0x1FD0..0x1FD3
ur 0x1FD6..0x1FDB
ur 0x1FE0..0x1FEC
ur 0x1FF2..0x1FF4
ur 0x1FF6..0x1FFC
ur 0x2126
ur 0x212A..0x212B
ur 0x212E
ur 0x2180..0x2182
ur 0x3041..0x3094
ur 0x30A1..0x30FA
ur 0x3105..0x312C
ur 0xAC00..0xD7A3
end xmlIsBaseChar
name xmlIsIdeographic
ur 0x4E00..0x9FA5
ur 0x3007
ur 0x3021..0x3029
end xmlIsIdeographic
name xmlIsCombining
ur 0x0300..0x0345
ur 0x0360..0x0361
ur 0x0483..0x0486
ur 0x0591..0x05A1
ur 0x05A3..0x05B9
ur 0x05BB..0x05BD
ur 0x05BF
ur 0x05C1..0x05C2
ur 0x05C4
ur 0x064B..0x0652
ur 0x0670
ur 0x06D6..0x06DC
ur 0x06DD..0x06DF
ur 0x06E0..0x06E4
ur 0x06E7..0x06E8
ur 0x06EA..0x06ED
ur 0x0901..0x0903
ur 0x093C
ur 0x093E..0x094C
ur 0x094D
ur 0x0951..0x0954
ur 0x0962..0x0963
ur 0x0981..0x0983
ur 0x09BC
ur 0x09BE
ur 0x09BF
ur 0x09C0..0x09C4
ur 0x09C7..0x09C8
ur 0x09CB..0x09CD
ur 0x09D7
ur 0x09E2..0x09E3
ur 0x0A02
ur 0x0A3C
ur 0x0A3E
ur 0x0A3F
ur 0x0A40..0x0A42
ur 0x0A47..0x0A48
ur 0x0A4B..0x0A4D
ur 0x0A70..0x0A71
ur 0x0A81..0x0A83
ur 0x0ABC
ur 0x0ABE..0x0AC5
ur 0x0AC7..0x0AC9
ur 0x0ACB..0x0ACD
ur 0x0B01..0x0B03
ur 0x0B3C
ur 0x0B3E..0x0B43
ur 0x0B47..0x0B48
ur 0x0B4B..0x0B4D
ur 0x0B56..0x0B57
ur 0x0B82..0x0B83
ur 0x0BBE..0x0BC2
ur 0x0BC6..0x0BC8
ur 0x0BCA..0x0BCD
ur 0x0BD7
ur 0x0C01..0x0C03
ur 0x0C3E..0x0C44
ur 0x0C46..0x0C48
ur 0x0C4A..0x0C4D
ur 0x0C55..0x0C56
ur 0x0C82..0x0C83
ur 0x0CBE..0x0CC4
ur 0x0CC6..0x0CC8
ur 0x0CCA..0x0CCD
ur 0x0CD5..0x0CD6
ur 0x0D02..0x0D03
ur 0x0D3E..0x0D43
ur 0x0D46..0x0D48
ur 0x0D4A..0x0D4D
ur 0x0D57
ur 0x0E31
ur 0x0E34..0x0E3A
ur 0x0E47..0x0E4E
ur 0x0EB1
ur 0x0EB4..0x0EB9
ur 0x0EBB..0x0EBC
ur 0x0EC8..0x0ECD
ur 0x0F18..0x0F19
ur 0x0F35
ur 0x0F37
ur 0x0F39
ur 0x0F3E
ur 0x0F3F
ur 0x0F71..0x0F84
ur 0x0F86..0x0F8B
ur 0x0F90..0x0F95
ur 0x0F97
ur 0x0F99..0x0FAD
ur 0x0FB1..0x0FB7
ur 0x0FB9
ur 0x20D0..0x20DC
ur 0x20E1
ur 0x302A..0x302F
ur 0x3099
ur 0x309A
end xmlIsCombining
name xmlIsDigit
ur 0x0030..0x0039
ur 0x0660..0x0669
ur 0x06F0..0x06F9
ur 0x0966..0x096F
ur 0x09E6..0x09EF
ur 0x0A66..0x0A6F
ur 0x0AE6..0x0AEF
ur 0x0B66..0x0B6F
ur 0x0BE7..0x0BEF
ur 0x0C66..0x0C6F
ur 0x0CE6..0x0CEF
ur 0x0D66..0x0D6F
ur 0x0E50..0x0E59
ur 0x0ED0..0x0ED9
ur 0x0F20..0x0F29
end xmlIsDigit
name xmlIsExtender
ur 0x00B7
ur 0x02D0
ur 0x02D1
ur 0x0387
ur 0x0640
ur 0x0E46
ur 0x0EC6
ur 0x3005
ur 0x3031..0x3035
ur 0x309D..0x309E
ur 0x30FC..0x30FE
end xmlIsExtender
+131
View File
@@ -0,0 +1,131 @@
const unsigned char xmlIsPubidChar_tab[256] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01,
0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };
static const xmlChSRange xmlIsBaseChar_srng[] = {{0x100, 0x131},
{0x134, 0x13e}, {0x141, 0x148}, {0x14a, 0x17e}, {0x180, 0x1c3},
{0x1cd, 0x1f0}, {0x1f4, 0x1f5}, {0x1fa, 0x217}, {0x250, 0x2a8},
{0x2bb, 0x2c1}, {0x386, 0x386}, {0x388, 0x38a}, {0x38c, 0x38c},
{0x38e, 0x3a1}, {0x3a3, 0x3ce}, {0x3d0, 0x3d6}, {0x3da, 0x3da},
{0x3dc, 0x3dc}, {0x3de, 0x3de}, {0x3e0, 0x3e0}, {0x3e2, 0x3f3},
{0x401, 0x40c}, {0x40e, 0x44f}, {0x451, 0x45c}, {0x45e, 0x481},
{0x490, 0x4c4}, {0x4c7, 0x4c8}, {0x4cb, 0x4cc}, {0x4d0, 0x4eb},
{0x4ee, 0x4f5}, {0x4f8, 0x4f9}, {0x531, 0x556}, {0x559, 0x559},
{0x561, 0x586}, {0x5d0, 0x5ea}, {0x5f0, 0x5f2}, {0x621, 0x63a},
{0x641, 0x64a}, {0x671, 0x6b7}, {0x6ba, 0x6be}, {0x6c0, 0x6ce},
{0x6d0, 0x6d3}, {0x6d5, 0x6d5}, {0x6e5, 0x6e6}, {0x905, 0x939},
{0x93d, 0x93d}, {0x958, 0x961}, {0x985, 0x98c}, {0x98f, 0x990},
{0x993, 0x9a8}, {0x9aa, 0x9b0}, {0x9b2, 0x9b2}, {0x9b6, 0x9b9},
{0x9dc, 0x9dd}, {0x9df, 0x9e1}, {0x9f0, 0x9f1}, {0xa05, 0xa0a},
{0xa0f, 0xa10}, {0xa13, 0xa28}, {0xa2a, 0xa30}, {0xa32, 0xa33},
{0xa35, 0xa36}, {0xa38, 0xa39}, {0xa59, 0xa5c}, {0xa5e, 0xa5e},
{0xa72, 0xa74}, {0xa85, 0xa8b}, {0xa8d, 0xa8d}, {0xa8f, 0xa91},
{0xa93, 0xaa8}, {0xaaa, 0xab0}, {0xab2, 0xab3}, {0xab5, 0xab9},
{0xabd, 0xabd}, {0xae0, 0xae0}, {0xb05, 0xb0c}, {0xb0f, 0xb10},
{0xb13, 0xb28}, {0xb2a, 0xb30}, {0xb32, 0xb33}, {0xb36, 0xb39},
{0xb3d, 0xb3d}, {0xb5c, 0xb5d}, {0xb5f, 0xb61}, {0xb85, 0xb8a},
{0xb8e, 0xb90}, {0xb92, 0xb95}, {0xb99, 0xb9a}, {0xb9c, 0xb9c},
{0xb9e, 0xb9f}, {0xba3, 0xba4}, {0xba8, 0xbaa}, {0xbae, 0xbb5},
{0xbb7, 0xbb9}, {0xc05, 0xc0c}, {0xc0e, 0xc10}, {0xc12, 0xc28},
{0xc2a, 0xc33}, {0xc35, 0xc39}, {0xc60, 0xc61}, {0xc85, 0xc8c},
{0xc8e, 0xc90}, {0xc92, 0xca8}, {0xcaa, 0xcb3}, {0xcb5, 0xcb9},
{0xcde, 0xcde}, {0xce0, 0xce1}, {0xd05, 0xd0c}, {0xd0e, 0xd10},
{0xd12, 0xd28}, {0xd2a, 0xd39}, {0xd60, 0xd61}, {0xe01, 0xe2e},
{0xe30, 0xe30}, {0xe32, 0xe33}, {0xe40, 0xe45}, {0xe81, 0xe82},
{0xe84, 0xe84}, {0xe87, 0xe88}, {0xe8a, 0xe8a}, {0xe8d, 0xe8d},
{0xe94, 0xe97}, {0xe99, 0xe9f}, {0xea1, 0xea3}, {0xea5, 0xea5},
{0xea7, 0xea7}, {0xeaa, 0xeab}, {0xead, 0xeae}, {0xeb0, 0xeb0},
{0xeb2, 0xeb3}, {0xebd, 0xebd}, {0xec0, 0xec4}, {0xf40, 0xf47},
{0xf49, 0xf69}, {0x10a0, 0x10c5}, {0x10d0, 0x10f6}, {0x1100, 0x1100},
{0x1102, 0x1103}, {0x1105, 0x1107}, {0x1109, 0x1109}, {0x110b, 0x110c},
{0x110e, 0x1112}, {0x113c, 0x113c}, {0x113e, 0x113e}, {0x1140, 0x1140},
{0x114c, 0x114c}, {0x114e, 0x114e}, {0x1150, 0x1150}, {0x1154, 0x1155},
{0x1159, 0x1159}, {0x115f, 0x1161}, {0x1163, 0x1163}, {0x1165, 0x1165},
{0x1167, 0x1167}, {0x1169, 0x1169}, {0x116d, 0x116e}, {0x1172, 0x1173},
{0x1175, 0x1175}, {0x119e, 0x119e}, {0x11a8, 0x11a8}, {0x11ab, 0x11ab},
{0x11ae, 0x11af}, {0x11b7, 0x11b8}, {0x11ba, 0x11ba}, {0x11bc, 0x11c2},
{0x11eb, 0x11eb}, {0x11f0, 0x11f0}, {0x11f9, 0x11f9}, {0x1e00, 0x1e9b},
{0x1ea0, 0x1ef9}, {0x1f00, 0x1f15}, {0x1f18, 0x1f1d}, {0x1f20, 0x1f45},
{0x1f48, 0x1f4d}, {0x1f50, 0x1f57}, {0x1f59, 0x1f59}, {0x1f5b, 0x1f5b},
{0x1f5d, 0x1f5d}, {0x1f5f, 0x1f7d}, {0x1f80, 0x1fb4}, {0x1fb6, 0x1fbc},
{0x1fbe, 0x1fbe}, {0x1fc2, 0x1fc4}, {0x1fc6, 0x1fcc}, {0x1fd0, 0x1fd3},
{0x1fd6, 0x1fdb}, {0x1fe0, 0x1fec}, {0x1ff2, 0x1ff4}, {0x1ff6, 0x1ffc},
{0x2126, 0x2126}, {0x212a, 0x212b}, {0x212e, 0x212e}, {0x2180, 0x2182},
{0x3041, 0x3094}, {0x30a1, 0x30fa}, {0x3105, 0x312c}, {0xac00, 0xd7a3}};
const xmlChRangeGroup xmlIsBaseCharGroup =
{197,0,xmlIsBaseChar_srng,NULL};
static const xmlChSRange xmlIsChar_srng[] = {{0x100, 0xd7ff},
{0xe000, 0xfffd}};
static const xmlChLRange xmlIsChar_lrng[] = {{0x10000, 0x10ffff}};
const xmlChRangeGroup xmlIsCharGroup =
{2,1,xmlIsChar_srng,xmlIsChar_lrng};
static const xmlChSRange xmlIsCombining_srng[] = {{0x300, 0x345},
{0x360, 0x361}, {0x483, 0x486}, {0x591, 0x5a1}, {0x5a3, 0x5b9},
{0x5bb, 0x5bd}, {0x5bf, 0x5bf}, {0x5c1, 0x5c2}, {0x5c4, 0x5c4},
{0x64b, 0x652}, {0x670, 0x670}, {0x6d6, 0x6dc}, {0x6dd, 0x6df},
{0x6e0, 0x6e4}, {0x6e7, 0x6e8}, {0x6ea, 0x6ed}, {0x901, 0x903},
{0x93c, 0x93c}, {0x93e, 0x94c}, {0x94d, 0x94d}, {0x951, 0x954},
{0x962, 0x963}, {0x981, 0x983}, {0x9bc, 0x9bc}, {0x9be, 0x9be},
{0x9bf, 0x9bf}, {0x9c0, 0x9c4}, {0x9c7, 0x9c8}, {0x9cb, 0x9cd},
{0x9d7, 0x9d7}, {0x9e2, 0x9e3}, {0xa02, 0xa02}, {0xa3c, 0xa3c},
{0xa3e, 0xa3e}, {0xa3f, 0xa3f}, {0xa40, 0xa42}, {0xa47, 0xa48},
{0xa4b, 0xa4d}, {0xa70, 0xa71}, {0xa81, 0xa83}, {0xabc, 0xabc},
{0xabe, 0xac5}, {0xac7, 0xac9}, {0xacb, 0xacd}, {0xb01, 0xb03},
{0xb3c, 0xb3c}, {0xb3e, 0xb43}, {0xb47, 0xb48}, {0xb4b, 0xb4d},
{0xb56, 0xb57}, {0xb82, 0xb83}, {0xbbe, 0xbc2}, {0xbc6, 0xbc8},
{0xbca, 0xbcd}, {0xbd7, 0xbd7}, {0xc01, 0xc03}, {0xc3e, 0xc44},
{0xc46, 0xc48}, {0xc4a, 0xc4d}, {0xc55, 0xc56}, {0xc82, 0xc83},
{0xcbe, 0xcc4}, {0xcc6, 0xcc8}, {0xcca, 0xccd}, {0xcd5, 0xcd6},
{0xd02, 0xd03}, {0xd3e, 0xd43}, {0xd46, 0xd48}, {0xd4a, 0xd4d},
{0xd57, 0xd57}, {0xe31, 0xe31}, {0xe34, 0xe3a}, {0xe47, 0xe4e},
{0xeb1, 0xeb1}, {0xeb4, 0xeb9}, {0xebb, 0xebc}, {0xec8, 0xecd},
{0xf18, 0xf19}, {0xf35, 0xf35}, {0xf37, 0xf37}, {0xf39, 0xf39},
{0xf3e, 0xf3e}, {0xf3f, 0xf3f}, {0xf71, 0xf84}, {0xf86, 0xf8b},
{0xf90, 0xf95}, {0xf97, 0xf97}, {0xf99, 0xfad}, {0xfb1, 0xfb7},
{0xfb9, 0xfb9}, {0x20d0, 0x20dc}, {0x20e1, 0x20e1}, {0x302a, 0x302f},
{0x3099, 0x3099}, {0x309a, 0x309a}};
const xmlChRangeGroup xmlIsCombiningGroup =
{95,0,xmlIsCombining_srng,NULL};
static const xmlChSRange xmlIsDigit_srng[] = {{0x660, 0x669},
{0x6f0, 0x6f9}, {0x966, 0x96f}, {0x9e6, 0x9ef}, {0xa66, 0xa6f},
{0xae6, 0xaef}, {0xb66, 0xb6f}, {0xbe7, 0xbef}, {0xc66, 0xc6f},
{0xce6, 0xcef}, {0xd66, 0xd6f}, {0xe50, 0xe59}, {0xed0, 0xed9},
{0xf20, 0xf29}};
const xmlChRangeGroup xmlIsDigitGroup =
{14,0,xmlIsDigit_srng,NULL};
static const xmlChSRange xmlIsExtender_srng[] = {{0x2d0, 0x2d0},
{0x2d1, 0x2d1}, {0x387, 0x387}, {0x640, 0x640}, {0xe46, 0xe46},
{0xec6, 0xec6}, {0x3005, 0x3005}, {0x3031, 0x3035}, {0x309d, 0x309e},
{0x30fc, 0x30fe}};
const xmlChRangeGroup xmlIsExtenderGroup =
{10,0,xmlIsExtender_srng,NULL};
static const xmlChSRange xmlIsIdeographic_srng[] = {{0x3007, 0x3007},
{0x3021, 0x3029}, {0x4e00, 0x9fa5}};
const xmlChRangeGroup xmlIsIdeographicGroup =
{3,0,xmlIsIdeographic_srng,NULL};
+34
View File
@@ -0,0 +1,34 @@
def gen_range_tables(out, name, s_suffix, l_suffix, ranges):
numshort = 0
numlong = 0
sptr = "NULL"
lptr = "NULL"
for range in ranges:
(low, high) = range
if high < 0x10000:
if numshort == 0:
sptr = name + s_suffix
pline = "static const xmlChSRange %s[] = {" % sptr
else:
pline += ","
numshort += 1
else:
if numlong == 0:
if numshort > 0:
out.write(pline + "};\n")
lptr = name + l_suffix
pline = "static const xmlChLRange %s[] = {" % lptr
else:
pline += ","
numlong += 1
if len(pline) > 60:
out.write(pline + "\n")
pline = " "
elif pline[-1:] == ",":
pline += " "
pline += "{%s, %s}" % (hex(low), hex(high))
out.write(pline + "};\n")
return "{%s,%s,%s,%s}" % (numshort, numlong, sptr, lptr)
File diff suppressed because it is too large Load Diff
+146
View File
@@ -0,0 +1,146 @@
# Symbol to module mapping
#
# This relies on a few tables and some regexes.
import re
moduleMap = {
'HTMLtree': 'HTML',
'HTMLparser': 'HTML',
'c14n': 'C14N',
'catalog': 'CATALOG',
'debugXML': 'DEBUG',
'nanohttp': 'HTTP',
'pattern': 'PATTERN',
'relaxng': 'RELAXNG',
'schemasInternals': 'SCHEMAS',
'schematron': 'SCHEMATRON',
'xinclude': 'XINCLUDE',
'xlink': 'XPTR',
'xmlautomata': 'REGEXP',
'xmlmodule': 'MODULES',
'xmlreader': 'READER',
'xmlregexp': 'REGEXP',
'xmlsave': 'OUTPUT',
'xmlschemas': 'SCHEMAS',
'xmlschemastypes': 'SCHEMAS',
'xmlwriter': 'WRITER',
'xpath': 'XPATH',
'xpathInternals': 'XPATH',
'xpointer': 'XPTR',
}
symbolMap1 = {
# not VALID
'xmlValidateNCName': '',
'xmlValidateNMToken': '',
'xmlValidateName': '',
'xmlValidateQName': '',
'htmlDefaultSAXHandlerInit': 'HTML',
'xmlSAX2InitHtmlDefaultSAXHandler': 'HTML',
'xmlRegisterHTTPPostCallbacks': 'HTTP',
'__xmlOutputBufferCreateFilename': 'OUTPUT',
'xmlAttrSerializeTxtContent': 'OUTPUT',
'xmlUTF8ToIsolat1': 'OUTPUT',
'xmlSprintfElementContent': 'OUTPUT',
'xmlCreatePushParserCtxt': 'PUSH',
'xmlParseChunk': 'PUSH',
'xmlParseBalancedChunkMemory': 'SAX1',
'xmlParseBalancedChunkMemoryRecover': 'SAX1',
'xmlParseDoc': 'SAX1',
'xmlParseEntity': 'SAX1',
'xmlParseExternalEntity': 'SAX1',
'xmlParseFile': 'SAX1',
'xmlParseMemory': 'SAX1',
'xmlSAXDefaultVersion': 'SAX1',
'xmlSetupParserForBuffer': 'SAX1',
'xmlCtxtGetValidCtxt': 'VALID',
'xmlFreeValidCtxt': 'VALID',
'xmlNewValidCtxt': 'VALID',
'xmlCatalogConvert': 'SGML_CATALOG',
'xmlConvertSGMLCatalog': 'SGML_CATALOG',
'xmlLoadSGMLSuperCatalog': 'SGML_CATALOG',
}
symbolMap2 = {
# not OUTPUT (should be fixed in xmlIO.h)
'xmlOutputBufferCreateFilenameDefault': '',
'xmlXPathDebugDumpCompExpr': 'DEBUG',
'xmlXPathDebugDumpObject': 'DEBUG',
'xmlSchemaDump': 'DEBUG',
'xmlRelaxNGDump': 'DEBUG',
'xmlACatalogDump': 'OUTPUT',
'xmlCatalogDump': 'OUTPUT',
'xmlIOHTTPOpenW': 'OUTPUT',
'xmlNanoHTTPSave': 'OUTPUT',
'xmlRegisterHTTPPostCallbacks': 'OUTPUT',
'xmlRelaxNGDumpTree': 'OUTPUT',
'xmlTextReaderPreservePattern': 'PATTERN',
'htmlCreatePushParserCtxt': 'PUSH',
'htmlParseChunk': 'PUSH',
'xmlValidBuildContentModel': 'REGEXP',
'xmlValidatePopElement': 'REGEXP',
'xmlValidatePushCData': 'REGEXP',
'xmlValidatePushElement': 'REGEXP',
'xmlTextReaderRelaxNGSetSchema': 'RELAXNG',
'xmlTextReaderRelaxNGValidate': 'RELAXNG',
'xmlTextReaderRelaxNGValidateCtxt': 'RELAXNG',
'xmlTextReaderSchemaValidate': 'SCHEMAS',
'xmlTextReaderSchemaValidateCtxt': 'SCHEMAS',
'xmlTextReaderSetSchema': 'SCHEMAS',
'xmlTextReaderReadInnerXml': 'WRITER',
'xmlTextReaderReadOuterXml': 'WRITER',
}
outputRegex = '|'.join((
'^(html|xml(Buf)?)(Doc(Content|Format)?|Elem|Node)Dump',
'^(html|xml)Save(Format)?File',
'^xmlDump.*(Decl|Table)',
'^xml(Alloc)?OutputBuffer',
'^xml.*OutputCallbacks',
))
def findModules(filename, symbol):
module1 = symbolMap1.get(symbol)
if module1 is None:
module1 = moduleMap.get(filename)
if module1 is None:
if re.search('^xml(Ctxt)?Valid|Parse(DTD|Dtd)', symbol):
module1 = 'VALID'
elif re.search('^xml(Recover|SAX(User)?Parse)', symbol):
module1 = 'SAX1'
elif re.search('^xmlIOHTTP', symbol):
module1 = 'HTTP'
module2 = symbolMap2.get(symbol)
if module2 is None:
if re.search(outputRegex, symbol):
if module1 is None:
module1 = 'OUTPUT'
else:
module2 = 'OUTPUT'
if module1 is None:
module1 = ''
if module2 is None:
module2 = ''
return module1, module2
+35
View File
@@ -0,0 +1,35 @@
/* Define to 1 if you have the declaration of 'getentropy', and to 0 if you
don't. */
#cmakedefine01 HAVE_DECL_GETENTROPY
/* Define to 1 if you have the declaration of 'glob', and to 0 if you don't.
*/
#cmakedefine01 HAVE_DECL_GLOB
/* Define to 1 if you have the declaration of 'mmap', and to 0 if you don't.
*/
#cmakedefine01 HAVE_DECL_MMAP
/* Define if __attribute__((destructor)) is accepted */
#cmakedefine HAVE_FUNC_ATTRIBUTE_DESTRUCTOR 1
/* Have dlopen based dso */
#cmakedefine HAVE_DLOPEN 1
/* Define if history library is there (-lhistory) */
#cmakedefine HAVE_LIBHISTORY 1
/* Define if readline library is there (-lreadline) */
#cmakedefine HAVE_LIBREADLINE 1
/* Have shl_load based dso */
#cmakedefine HAVE_SHLLOAD 1
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H 1
/* System configuration directory (/etc) */
#cmakedefine XML_SYSCONFDIR "@XML_SYSCONFDIR@"
/* TLS specifier */
#cmakedefine XML_THREAD_LOCAL @XML_THREAD_LOCAL@
+1050
View File
File diff suppressed because it is too large Load Diff
+1523
View File
File diff suppressed because it is too large Load Diff
+1037
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -0,0 +1,2 @@
/html/
/xml/
+110
View File
@@ -0,0 +1,110 @@
PROJECT_NAME = libxml2
OUTPUT_DIRECTORY = $(BUILD_ROOT)doc
STRIP_FROM_PATH = $(SOURCE_ROOT)include/libxml \
$(BUILD_ROOT)include/libxml
JAVADOC_AUTOBRIEF = YES
OPTIMIZE_OUTPUT_FOR_C = YES
EXTRACT_LOCAL_CLASSES = NO
HIDE_UNDOC_MEMBERS = YES
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = YES
SHOW_INCLUDE_FILES = NO
WARN_NO_PARAMDOC = YES
WARN_AS_ERROR = $(DOXYGEN_WARN_AS_ERROR)
INPUT = $(SOURCE_ROOT)doc/mainpage.md \
$(SOURCE_ROOT)include/libxml/c14n.h \
$(SOURCE_ROOT)include/libxml/catalog.h \
$(SOURCE_ROOT)include/libxml/chvalid.h \
$(SOURCE_ROOT)include/libxml/debugXML.h \
$(SOURCE_ROOT)include/libxml/dict.h \
$(SOURCE_ROOT)include/libxml/encoding.h \
$(SOURCE_ROOT)include/libxml/entities.h \
$(SOURCE_ROOT)include/libxml/hash.h \
$(SOURCE_ROOT)include/libxml/HTMLparser.h \
$(SOURCE_ROOT)include/libxml/HTMLtree.h \
$(SOURCE_ROOT)include/libxml/list.h \
$(SOURCE_ROOT)include/libxml/parser.h \
$(SOURCE_ROOT)include/libxml/parserInternals.h \
$(SOURCE_ROOT)include/libxml/pattern.h \
$(SOURCE_ROOT)include/libxml/relaxng.h \
$(SOURCE_ROOT)include/libxml/SAX2.h \
$(SOURCE_ROOT)include/libxml/schemasInternals.h \
$(SOURCE_ROOT)include/libxml/schematron.h \
$(SOURCE_ROOT)include/libxml/threads.h \
$(SOURCE_ROOT)include/libxml/tree.h \
$(SOURCE_ROOT)include/libxml/uri.h \
$(SOURCE_ROOT)include/libxml/valid.h \
$(SOURCE_ROOT)include/libxml/xinclude.h \
$(SOURCE_ROOT)include/libxml/xlink.h \
$(SOURCE_ROOT)include/libxml/xmlautomata.h \
$(SOURCE_ROOT)include/libxml/xmlerror.h \
$(SOURCE_ROOT)include/libxml/xmlIO.h \
$(SOURCE_ROOT)include/libxml/xmlmemory.h \
$(SOURCE_ROOT)include/libxml/xmlmodule.h \
$(SOURCE_ROOT)include/libxml/xmlreader.h \
$(SOURCE_ROOT)include/libxml/xmlregexp.h \
$(SOURCE_ROOT)include/libxml/xmlsave.h \
$(SOURCE_ROOT)include/libxml/xmlschemas.h \
$(SOURCE_ROOT)include/libxml/xmlschemastypes.h \
$(SOURCE_ROOT)include/libxml/xmlstring.h \
$(BUILD_ROOT)include/libxml/xmlversion.h \
$(SOURCE_ROOT)include/libxml/xmlwriter.h \
$(SOURCE_ROOT)include/libxml/xpath.h \
$(SOURCE_ROOT)include/libxml/xpathInternals.h \
$(SOURCE_ROOT)include/libxml/xpointer.h \
$(SOURCE_ROOT)buf.c \
$(SOURCE_ROOT)c14n.c \
$(SOURCE_ROOT)catalog.c \
$(SOURCE_ROOT)chvalid.c \
$(SOURCE_ROOT)debugXML.c \
$(SOURCE_ROOT)dict.c \
$(SOURCE_ROOT)encoding.c \
$(SOURCE_ROOT)entities.c \
$(SOURCE_ROOT)error.c \
$(SOURCE_ROOT)globals.c \
$(SOURCE_ROOT)hash.c \
$(SOURCE_ROOT)HTMLparser.c \
$(SOURCE_ROOT)HTMLtree.c \
$(SOURCE_ROOT)list.c \
$(SOURCE_ROOT)parser.c \
$(SOURCE_ROOT)parserInternals.c \
$(SOURCE_ROOT)pattern.c \
$(SOURCE_ROOT)relaxng.c \
$(SOURCE_ROOT)SAX2.c \
$(SOURCE_ROOT)schematron.c \
$(SOURCE_ROOT)threads.c \
$(SOURCE_ROOT)tree.c \
$(SOURCE_ROOT)uri.c \
$(SOURCE_ROOT)valid.c \
$(SOURCE_ROOT)xinclude.c \
$(SOURCE_ROOT)xlink.c \
$(SOURCE_ROOT)xmlcatalog.c \
$(SOURCE_ROOT)xmlIO.c \
$(SOURCE_ROOT)xmlmemory.c \
$(SOURCE_ROOT)xmlmodule.c \
$(SOURCE_ROOT)xmlreader.c \
$(SOURCE_ROOT)xmlregexp.c \
$(SOURCE_ROOT)xmlsave.c \
$(SOURCE_ROOT)xmlschemas.c \
$(SOURCE_ROOT)xmlschemastypes.c \
$(SOURCE_ROOT)xmlstring.c \
$(SOURCE_ROOT)xmlwriter.c \
$(SOURCE_ROOT)xpath.c \
$(SOURCE_ROOT)xpointer.c
EXCLUDE_SYMLINKS = YES
USE_MDFILE_AS_MAINPAGE = $(SOURCE_ROOT)doc/mainpage.md
VERBATIM_HEADERS = NO
HTML_EXTRA_STYLESHEET = $(SOURCE_ROOT)doc/libxml2.css
DISABLE_INDEX = NO
GENERATE_TREEVIEW = NO
ENUM_VALUES_PER_LINE = 0
GENERATE_LATEX = NO
GENERATE_XML = YES
XML_PROGRAMLISTING = NO
MACRO_EXPANSION = YES
INCLUDE_PATH = $(SOURCE_ROOT). \
$(SOURCE_ROOT)include \
$(BUILD_ROOT). \
$(BUILD_ROOT)include
PREDEFINED = XML_TREE_INTERNALS
HAVE_DOT = NO
+56
View File
@@ -0,0 +1,56 @@
## Process this file with automake to produce Makefile.in
EXTRA_DIST = \
Doxyfile \
libxml2.css \
mainpage.md \
meson.build \
xml2-config.1 \
xmlcatalog.xml \
xmllint.xml
all-local: html.stamp
html.stamp: Doxyfile
SOURCE_ROOT=$(top_srcdir)/ BUILD_ROOT=$(top_builddir)/ \
$(DOXYGEN) -q $<
@touch $@
CLEANFILES = html.stamp
clean-local:
rm -rf html xml
if WITH_DOCS
man_MANS = xml2-config.1 xmllint.1
doc_DATA = xmllint.html
CLEANFILES += xmllint.1 xmllint.html
if WITH_CATALOG_SOURCES
if WITH_OUTPUT_SOURCES
man_MANS += xmlcatalog.1
doc_DATA += xmlcatalog.html
CLEANFILES += xmlcatalog.1 xmlcatalog.html
endif
endif
DOCBOOK_MAN = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
DOCBOOK_HTML = http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl
.xml.1:
$(XSLTPROC) --nonet --novalid --param man.output.quietly 1 \
-o $@ $(DOCBOOK_MAN) $<
.xml.html:
$(XSLTPROC) --nonet --novalid -o $@ $(DOCBOOK_HTML) $<
install-data-local:
$(MKDIR_P) "$(DESTDIR)$(docdir)/html/search"
$(INSTALL_DATA) html/*.* "$(DESTDIR)$(docdir)/html"
$(INSTALL_DATA) html/search/*.* "$(DESTDIR)$(docdir)/html/search"
uninstall-local:
-rm -rf "$(DESTDIR)$(docdir)/html"
endif
+50
View File
@@ -0,0 +1,50 @@
# Redirects for GitLab pages
# Start page
/libxml2/ /libxml2/html/index.html 302
# Old documentation
/libxml2/devhelp/libxml2-c14n.html /libxml2/html/c14n_8h.html
/libxml2/devhelp/libxml2-catalog.html /libxml2/html/catalog_8h.html
/libxml2/devhelp/libxml2-chvalid.html /libxml2/html/chvalid_8h.html
/libxml2/devhelp/libxml2-debugXML.html /libxml2/html/debugXML_8h.html
/libxml2/devhelp/libxml2-dict.html /libxml2/html/dict_8h.html
/libxml2/devhelp/libxml2-encoding.html /libxml2/html/encoding_8h.html
/libxml2/devhelp/libxml2-entities.html /libxml2/html/entities_8h.html
/libxml2/devhelp/libxml2-hash.html /libxml2/html/hash_8h.html
/libxml2/devhelp/libxml2-HTMLparser.html /libxml2/html/HTMLparser_8h.html
/libxml2/devhelp/libxml2-HTMLtree.html /libxml2/html/HTMLtree_8h.html
/libxml2/devhelp/libxml2-list.html /libxml2/html/list_8h.html
/libxml2/devhelp/libxml2-parser.html /libxml2/html/parser_8h.html
/libxml2/devhelp/libxml2-parserInternals.html /libxml2/html/parserInternals_8h.html
/libxml2/devhelp/libxml2-pattern.html /libxml2/html/pattern_8h.html
/libxml2/devhelp/libxml2-relaxng.html /libxml2/html/relaxng_8h.html
/libxml2/devhelp/libxml2-SAX2.html /libxml2/html/SAX2_8h.html
/libxml2/devhelp/libxml2-schemasInternals.html /libxml2/html/schemasInternals_8h.html
/libxml2/devhelp/libxml2-schematron.html /libxml2/html/schematron_8h.html
/libxml2/devhelp/libxml2-threads.html /libxml2/html/threads_8h.html
/libxml2/devhelp/libxml2-tree.html /libxml2/html/tree_8h.html
/libxml2/devhelp/libxml2-uri.html /libxml2/html/uri_8h.html
/libxml2/devhelp/libxml2-valid.html /libxml2/html/valid_8h.html
/libxml2/devhelp/libxml2-xinclude.html /libxml2/html/xinclude_8h.html
/libxml2/devhelp/libxml2-xlink.html /libxml2/html/xlink_8h.html
/libxml2/devhelp/libxml2-xmlautomata.html /libxml2/html/xmlautomata_8h.html
/libxml2/devhelp/libxml2-xmlerror.html /libxml2/html/xmlerror_8h.html
/libxml2/devhelp/libxml2-xmlIO.html /libxml2/html/xmlIO_8h.html
/libxml2/devhelp/libxml2-xmlmemory.html /libxml2/html/xmlmemory_8h.html
/libxml2/devhelp/libxml2-xmlmodule.html /libxml2/html/xmlmodule_8h.html
/libxml2/devhelp/libxml2-xmlreader.html /libxml2/html/xmlreader_8h.html
/libxml2/devhelp/libxml2-xmlregexp.html /libxml2/html/xmlregexp_8h.html
/libxml2/devhelp/libxml2-xmlsave.html /libxml2/html/xmlsave_8h.html
/libxml2/devhelp/libxml2-xmlschemas.html /libxml2/html/xmlschemas_8h.html
/libxml2/devhelp/libxml2-xmlschemastypes.html /libxml2/html/xmlschemastypes_8h.html
/libxml2/devhelp/libxml2-xmlstring.html /libxml2/html/xmlstring_8h.html
/libxml2/devhelp/libxml2-xmlversion.html /libxml2/html/xmlversion_8h.html
/libxml2/devhelp/libxml2-xmlwriter.html /libxml2/html/xmlwriter_8h.html
/libxml2/devhelp/libxml2-xpath.html /libxml2/html/xpath_8h.html
/libxml2/devhelp/libxml2-xpathInternals.html /libxml2/html/xpathInternals_8h.html
/libxml2/devhelp/libxml2-xpointer.html /libxml2/html/xpointer_8h.html
/libxml2/devhelp/general.html /libxml2/html/files.html
/libxml2/devhelp/* /libxml2/html/index.html
+9
View File
@@ -0,0 +1,9 @@
div.contents {
max-width: 60em;
}
h1 {
font-size: 1.5em;
}
h2 {
font-size: 1.25em;
}
+25
View File
@@ -0,0 +1,25 @@
# API Documentation
See [File List](files.html) for API documentation sorted by
public header files.
## About
libxml2 is an XML toolkit implemented in C, originally developed for
the GNOME Project.
Official releases can be downloaded from
<https://download.gnome.org/sources/libxml2/>
The git repository is hosted on GNOME's GitLab server:
<https://gitlab.gnome.org/GNOME/libxml2>
Bugs should be reported at
<https://gitlab.gnome.org/GNOME/libxml2/-/issues>
Other documentation is available at
<https://gitlab.gnome.org/GNOME/libxml2/-/wikis>
## License
This code is released under the MIT License, see the Copyright file.
+67
View File
@@ -0,0 +1,67 @@
# Doxygen
doxygen = find_program('doxygen')
# TODO: To make the xml directory work as dependency of the
# Python target, we must make sure that its timestamp changes
# whenever the docs are rebuilt. Either delete the directory
# before generating, or touch it afterward?
doxygen_docs = custom_target(
'Doxygen documentation',
input: [
xml_src_files, libxml_headers,
files('libxml2.css', 'mainpage.md'),
],
output: [ 'html', 'xml' ],
command: [ doxygen, '-q', files('Doxyfile') ],
env: {
'SOURCE_ROOT': meson.project_source_root() + '/',
'BUILD_ROOT': meson.project_build_root() + '/',
},
install: true,
install_dir: [ want_docs ? dir_doc : false, false ],
)
if want_docs
# xml2-config
install_man('xml2-config.1')
# Docbook
xsltproc = find_program('xsltproc')
types = [
[ 'manpages', '.1', dir_man / 'man1' ],
[ 'html', '.html', dir_doc ],
]
programs = [ 'xmllint' ]
if want_catalog and want_output
programs += 'xmlcatalog'
endif
foreach prog : programs
foreach type : types
format = type[0]
ext = type[1]
install_dir = type[2]
xsl = 'http://docbook.sourceforge.net' + \
f'/release/xsl/current/@format@/docbook.xsl'
output = prog + ext
custom_target(
output,
input: prog + '.xml',
output: output,
command: [xsltproc,
'--nonet', '--novalid',
'--param', 'man.output.quietly', '1',
'-o', '@OUTPUT@',
xsl, '@INPUT@'
],
install: true,
install_dir: install_dir
)
endforeach
endforeach
endif
+32
View File
@@ -0,0 +1,32 @@
.TH xml2-config 1 "3 April 2022" Version 1.2.0
.SH NAME
xml2-config - script to get information about the installed version of libxml2
.SH SYNOPSIS
.B xml2-config
[\-\-prefix\fI[=DIR]\fP] [\-\-libs] [\-\-cflags] [\-\-version] [\-\-help]
.SH DESCRIPTION
\fIxml2-config\fP is a tool that is used to determine the compile and
linker flags that should be used to compile and link programs that use
\fIlibxml2\fP.
.SH OPTIONS
\fIxml2-config\fP accepts the following options:
.TP 8
.B \-\-version
Print the currently installed version of \fIlibxml2\fP on the standard output.
.TP 8
.B \-\-libs
Print the linker flags that are necessary to link a \fIlibxml2\fP program.
Add \-\-dynamic after \-\-libs to print only shared library linking
information.
.TP 8
.B \-\-cflags
Print the compiler flags that are necessary to compile a \fIlibxml2\fP program.
.TP 8
.B \-\-prefix=PREFIX
If specified, use PREFIX instead of the installation prefix that
\fIlibxml2\fP was built with when computing the output for the
\-\-cflags and \-\-libs options. This option must be specified before
any \-\-libs or \-\-cflags options.
.SH AUTHOR
This manual page was written by Fredrik Hallenberg <hallon@lysator.liu.se>,
for the Debian GNU/linux system (but may be used by others).
+476
View File
@@ -0,0 +1,476 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl"
href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY xmlcatalog "<command>xmlcatalog</command>">
]>
<refentry>
<refentryinfo>
<title>xmlcatalog Manual</title>
<productname>libxml2</productname>
<copyright>
<year>2001</year>
<year>2004</year>
</copyright>
<author>
<firstname>John</firstname>
<surname>Fleck</surname>
<contrib></contrib>
<affiliation>
<address>
<email>jfleck@inkstain.net</email>
</address>
</affiliation>
</author>
<!-- still a bit buggy output, will talk to docbook-xsl upstream to fix this -->
<!-- <releaseinfo>This is release 0.3 of the xmlcatalog Manual.</releaseinfo> -->
<!-- <edition>0.3</edition> -->
</refentryinfo>
<refmeta>
<refentrytitle>xmlcatalog</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>xmlcatalog</refname>
<refpurpose>
Command line tool to parse and manipulate <acronym>XML</acronym>
or <acronym>SGML</acronym> catalog files.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>xmlcatalog</command>
<group choice="opt">
<arg choice="plain"><option>--sgml</option></arg>
<arg choice="plain"><option>--shell</option></arg>
<arg choice="plain"><option>--convert</option></arg>
<arg choice="plain"><option>--create</option></arg>
<arg choice="plain"><option>--del <replaceable>VALUE(S)</replaceable></option></arg>
<arg choice="plain">
<group choice="opt">
<arg choice="plain">
<option>--add
<replaceable>TYPE</replaceable>
<replaceable>ORIG</replaceable>
<replaceable>REPLACE</replaceable>
</option>
</arg>
<arg choice="plain"><option>--add <replaceable>FILENAME</replaceable></option></arg>
</group>
</arg>
<arg choice="plain"><option>--noout</option></arg>
<arg choice="plain"><option>--no-super-update</option></arg>
<arg choice="plain">
<group choice="opt">
<arg choice="plain"><option>-v</option></arg>
<arg choice="plain"><option>--verbose</option></arg>
</group>
</arg>
</group>
<arg choice="req" rep="norepeat"><replaceable>CATALOGFILE</replaceable></arg>
<arg choice="req" rep="repeat"><replaceable>ENTITIES</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1 id="description">
<title>DESCRIPTION</title>
<para>
&xmlcatalog; is a command line application allowing users to monitor and
manipulate <acronym>XML</acronym> and <acronym>SGML</acronym> catalogs. It
is included in <citerefentry>
<refentrytitle>libxml</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry>.
</para>
<para>
Its functions can be invoked from a single command from the command line,
or it can perform multiple functions in interactive mode. It can operate
on both <acronym>XML</acronym> and <acronym>SGML</acronym> files.
</para>
</refsect1>
<refsect1 id="options">
<title>OPTIONS</title>
<para>
&xmlcatalog; accepts the following options (in alphabetical order):
</para>
<variablelist>
<varlistentry>
<term>
<option>--add
<replaceable>TYPE</replaceable>
<replaceable>ORIG</replaceable>
<replaceable>REPLACE</replaceable>
</option>
</term>
<listitem>
<para>
Add an entry to <filename>CATALOGFILE</filename>. <replaceable>TYPE</replaceable>
indicates the type of entry. Possible types are: <simplelist type="inline">
<member><parameter>public</parameter></member>
<member><parameter>system</parameter></member>
<member><parameter>uri</parameter></member>
<member><parameter>rewriteSystem</parameter></member>
<member><parameter>rewriteURI</parameter></member>
<member><parameter>delegatePublic</parameter></member>
<member><parameter>delegateSystem</parameter></member>
<member><parameter>delegateURI</parameter></member>
<member><parameter>nextCatalog</parameter></member>
</simplelist>. <replaceable>ORIG</replaceable> is the original
reference to be replaced, and <replaceable>REPLACE</replaceable>
is the <acronym>URI</acronym> of the replacement entity to be
used. The <option>--add</option> option will not overwrite
<filename>CATALOGFILE</filename>, outputting
to <filename class="devicefile">stdout</filename>, unless
<option>--noout</option> is used. The <option>--add</option> will
always take three parameters even if some of the <acronym>XML</acronym>
catalog constructs will have only a single argument.
</para>
<!--
FIXME - Is my list of possible types correct? Are SGML types the same?
-->
</listitem>
</varlistentry>
<varlistentry>
<term><option>--add <replaceable>FILENAME</replaceable></option></term>
<listitem>
<para>
If the <option>--add</option> option is used following
the <option>--sgml</option> option, only a single argument,
a <replaceable>FILENAME</replaceable>, is used. This is used to add
the name of a catalog file to an <acronym>SGML</acronym> supercatalog,
a file that contains references to other included <acronym>SGML</acronym>
catalog files.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--convert</option></term>
<listitem>
<para>
Convert SGML catalog to XML.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--create</option></term>
<listitem>
<para>
Create a new <acronym>XML</acronym> catalog. Outputs
to <filename class="devicefile">stdout</filename>,
ignoring <replaceable>filename</replaceable> unless <option>--noout</option> is
used, in which case it creates a new catalog
file <replaceable>filename</replaceable>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--del <replaceable>VALUE(S)</replaceable></option></term>
<listitem>
<para>
Remove entries from <replaceable>CATALOGFILE</replaceable>
matching <replaceable>VALUE(S)</replaceable>. The <option>--del</option>
option will not overwrite <replaceable>CATALOGFILE</replaceable>,
outputting to <filename class="devicefile">stdout</filename>,
unless <option>--noout</option> is used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--noout</option></term>
<listitem>
<para>
Save output to the named file rather than outputting
to <filename class="devicefile">stdout</filename>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--no-super-update</option></term>
<listitem>
<para>
Do not update the <acronym>SGML</acronym> super catalog.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--shell</option></term>
<listitem>
<para>
Run a shell allowing interactive queries on catalog
file <replaceable>CATALOGFILE</replaceable>. For the set of available
commands see <xref linkend="shell"/>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--sgml</option></term>
<listitem>
<para>
Uses <acronym>SGML</acronym> super catalogs for <option>--add</option>
and <option>--del</option> options.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<term><option>--verbose</option></term>
<listitem>
<para>Output debugging information.</para>
</listitem>
</varlistentry>
</variablelist>
<para>
Invoking &xmlcatalog; non-interactively without a designated action
(imposed with options like <option>--add</option>) will result in a lookup
of the catalog entry for <replaceable>ENTITIES</replaceable> in the
catalog denoted with <replaceable>CATALOGFILE</replaceable>. The
corresponding entries will be output to the command line. This mode of
operation, together with <option>--shell</option> mode and non-modifying
(i.e. without <option>--noout</option>) direct actions, allows for
a special shortcut of the void <replaceable>CATALOGFILE</replaceable>
specification (possibly expressed as &quot;&quot; in the shell
environment) appointing the default system catalog. That simplifies the
handling when its exact location is irrelevant but the respective built-in
still needs to be consulted.
</para>
</refsect1>
<refsect1 id="shell">
<title>SHELL COMMANDS</title>
<para>
Invoking &xmlcatalog; with
the <option>--shell <replaceable>CATALOGFILE</replaceable></option> option opens
a command line shell allowing interactive access to the catalog file
identified by <replaceable>CATALOGFILE</replaceable>. Invoking the shell
provides a command line prompt after which the following commands (described in
alphabetical order) can be entered.
</para>
<variablelist>
<varlistentry>
<term>
<option>add
<replaceable>TYPE</replaceable>
<replaceable>ORIG</replaceable>
<replaceable>REPLACE</replaceable>
</option>
</term>
<listitem>
<para>
Add an entry to the catalog file. <replaceable>TYPE</replaceable>
indicates the type of entry. Possible types are: <simplelist type="inline">
<member><parameter>public</parameter></member>
<member><parameter>system</parameter></member>
<member><parameter>uri</parameter></member>
<member><parameter>rewriteSystem</parameter></member>
<member><parameter>rewriteURI</parameter></member>
<member><parameter>delegatePublic</parameter></member>
<member><parameter>delegateSystem</parameter></member>
<member><parameter>delegateURI</parameter></member>
<member><parameter>nextCatalog</parameter></member>
</simplelist>. <replaceable>ORIG</replaceable> is the original
reference to be replaced, and <replaceable>REPLACE</replaceable>
is the <acronym>URI</acronym> of the replacement entity to be
used. The <option>--add</option> option will not overwrite
<filename>CATALOGFILE</filename>, outputting
to <filename class="devicefile">stdout</filename>, unless
<option>--noout</option> is used. The <option>--add</option> will
always take three parameters even if some of the <acronym>XML</acronym>
catalog constructs will have only a single argument.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>debug</option></term>
<listitem>
<para>
Print debugging statements showing the steps &xmlcatalog; is executing.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>del <replaceable>VALUE(S)</replaceable></option></term>
<listitem>
<para>
Remove the catalog entry corresponding to <replaceable>VALUE(S)</replaceable>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>dump</option></term>
<listitem>
<para>Print the current catalog.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>exit</option></term>
<listitem>
<para>Quit the shell.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>public <replaceable>PUBLIC-ID</replaceable></option></term>
<listitem>
<para>
Execute a Formal Public Identifier lookup of the catalog entry
for <replaceable>PUBLIC-ID</replaceable>. The corresponding entry will be
output to the command line.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>quiet</option></term>
<listitem>
<para>Stop printing debugging statements.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>system <replaceable>SYSTEM-ID</replaceable></option></term>
<listitem>
<para>
Execute a Formal Public Identifier lookup of the catalog entry
for <replaceable>SYSTEM-ID</replaceable>. The corresponding entry will be
output to the command line.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="environment">
<title>ENVIRONMENT</title>
<variablelist>
<varlistentry>
<term><envar>XML_CATALOG_FILES</envar></term>
<listitem>
<para><acronym>XML</acronym> catalog behavior can be changed by redirecting
queries to the user's own set of catalogs. This can be done by setting
the <envar>XML_CATALOG_FILES</envar> environment variable to a space-separated
list of catalogs. Use percent-encoding to escape spaces or other characters.
An empty variable should deactivate loading the default catalog from
<filename>/etc/xml/catalog</filename> or, more specifically,
<filename>${sysconfdir}/xml/catalog</filename>.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="diagnostics">
<title>DIAGNOSTICS</title>
<para>
&xmlcatalog; return codes provide information that can be used when
calling it from scripts.
</para>
<variablelist>
<varlistentry>
<term><errorcode>0</errorcode></term>
<listitem>
<para>No error</para>
</listitem>
</varlistentry>
<varlistentry>
<term><errorcode>1</errorcode></term>
<listitem>
<para>Failed to remove an entry from the catalog</para>
</listitem>
</varlistentry>
<varlistentry>
<term><errorcode>2</errorcode></term>
<listitem>
<para>Failed to save to the catalog, check file permissions</para>
</listitem>
</varlistentry>
<varlistentry>
<term><errorcode>3</errorcode></term>
<listitem>
<para>Failed to add an entry to the catalog</para>
</listitem>
</varlistentry>
<varlistentry>
<term><errorcode>4</errorcode></term>
<listitem>
<para>Failed to look up an entry in the catalog</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="seealso">
<title>SEE ALSO</title>
<para><citerefentry>
<refentrytitle>libxml</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry>
</para>
<para>
More information can be found at
<itemizedlist>
<listitem>
<para><citerefentry>
<refentrytitle>libxml</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry> web page <ulink url="https://gitlab.gnome.org/GNOME/libxml2"/>
</para>
</listitem>
<listitem>
<para><citerefentry>
<refentrytitle>libxml</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry> catalog support web page
at <ulink url="https://gitlab.gnome.org/GNOME/libxml2/-/wikis/Catalog-support"/>
</para>
</listitem>
<listitem>
<para>James Clark's <acronym>SGML</acronym> catalog
page <ulink url="http://www.jclark.com/sp/catalog.htm"/>
</para>
</listitem>
<listitem>
<para><acronym>OASIS</acronym> <acronym>XML</acronym> catalog specification
<ulink url="http://www.oasis-open.org/committees/entity/spec.html"/>
</para>
</listitem>
</itemizedlist>
</para>
</refsect1>
</refentry>
File diff suppressed because it is too large Load Diff
+3003
View File
File diff suppressed because it is too large Load Diff
+728
View File
@@ -0,0 +1,728 @@
/*
* entities.c : implementation for the XML entities handling
*
* See Copyright for the status of this software.
*
* Author: Daniel Veillard
*/
/* To avoid EBCDIC trouble when parsing on zOS */
#if defined(__MVS__)
#pragma convert("ISO8859-1")
#endif
#define IN_LIBXML
#include "libxml.h"
#include <string.h>
#include <stdlib.h>
#include <libxml/xmlmemory.h>
#include <libxml/hash.h>
#include <libxml/entities.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlerror.h>
#include <libxml/dict.h>
#include <libxml/xmlsave.h>
#include "private/entities.h"
#include "private/error.h"
#include "private/io.h"
#include "private/tree.h"
#ifndef SIZE_MAX
#define SIZE_MAX ((size_t) -1)
#endif
/*
* The XML predefined entities.
*/
static xmlEntity xmlEntityLt = {
NULL, XML_ENTITY_DECL, BAD_CAST "lt",
NULL, NULL, NULL, NULL, NULL, NULL,
BAD_CAST "<", BAD_CAST "<", 1,
XML_INTERNAL_PREDEFINED_ENTITY,
NULL, NULL, NULL, NULL, 0, 0, 0
};
static xmlEntity xmlEntityGt = {
NULL, XML_ENTITY_DECL, BAD_CAST "gt",
NULL, NULL, NULL, NULL, NULL, NULL,
BAD_CAST ">", BAD_CAST ">", 1,
XML_INTERNAL_PREDEFINED_ENTITY,
NULL, NULL, NULL, NULL, 0, 0, 0
};
static xmlEntity xmlEntityAmp = {
NULL, XML_ENTITY_DECL, BAD_CAST "amp",
NULL, NULL, NULL, NULL, NULL, NULL,
BAD_CAST "&", BAD_CAST "&", 1,
XML_INTERNAL_PREDEFINED_ENTITY,
NULL, NULL, NULL, NULL, 0, 0, 0
};
static xmlEntity xmlEntityQuot = {
NULL, XML_ENTITY_DECL, BAD_CAST "quot",
NULL, NULL, NULL, NULL, NULL, NULL,
BAD_CAST "\"", BAD_CAST "\"", 1,
XML_INTERNAL_PREDEFINED_ENTITY,
NULL, NULL, NULL, NULL, 0, 0, 0
};
static xmlEntity xmlEntityApos = {
NULL, XML_ENTITY_DECL, BAD_CAST "apos",
NULL, NULL, NULL, NULL, NULL, NULL,
BAD_CAST "'", BAD_CAST "'", 1,
XML_INTERNAL_PREDEFINED_ENTITY,
NULL, NULL, NULL, NULL, 0, 0, 0
};
/**
* Frees the entity.
*
* @param entity an entity
*/
void
xmlFreeEntity(xmlEntity *entity)
{
xmlDictPtr dict = NULL;
if (entity == NULL)
return;
if (entity->doc != NULL)
dict = entity->doc->dict;
if ((entity->children) &&
(entity == (xmlEntityPtr) entity->children->parent))
xmlFreeNodeList(entity->children);
if ((entity->name != NULL) &&
((dict == NULL) || (!xmlDictOwns(dict, entity->name))))
xmlFree((char *) entity->name);
if (entity->ExternalID != NULL)
xmlFree((char *) entity->ExternalID);
if (entity->SystemID != NULL)
xmlFree((char *) entity->SystemID);
if (entity->URI != NULL)
xmlFree((char *) entity->URI);
if (entity->content != NULL)
xmlFree((char *) entity->content);
if (entity->orig != NULL)
xmlFree((char *) entity->orig);
xmlFree(entity);
}
/*
* internal routine doing the entity node structures allocations
*/
static xmlEntityPtr
xmlCreateEntity(xmlDocPtr doc, const xmlChar *name, int type,
const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *content) {
xmlEntityPtr ret;
ret = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
if (ret == NULL)
return(NULL);
memset(ret, 0, sizeof(xmlEntity));
ret->doc = doc;
ret->type = XML_ENTITY_DECL;
/*
* fill the structure.
*/
ret->etype = (xmlEntityType) type;
if ((doc == NULL) || (doc->dict == NULL))
ret->name = xmlStrdup(name);
else
ret->name = xmlDictLookup(doc->dict, name, -1);
if (ret->name == NULL)
goto error;
if (publicId != NULL) {
ret->ExternalID = xmlStrdup(publicId);
if (ret->ExternalID == NULL)
goto error;
}
if (systemId != NULL) {
ret->SystemID = xmlStrdup(systemId);
if (ret->SystemID == NULL)
goto error;
}
if (content != NULL) {
ret->length = xmlStrlen(content);
ret->content = xmlStrndup(content, ret->length);
if (ret->content == NULL)
goto error;
} else {
ret->length = 0;
ret->content = NULL;
}
ret->URI = NULL; /* to be computed by the layer knowing
the defining entity */
ret->orig = NULL;
return(ret);
error:
xmlFreeEntity(ret);
return(NULL);
}
/**
* Register a new entity for this document.
*
* @since 2.13.0
*
* @param doc the document
* @param extSubset add to the external or internal subset
* @param name the entity name
* @param type an xmlEntityType value
* @param publicId the publid identifier (optional)
* @param systemId the system identifier (URL) (optional)
* @param content the entity content
* @param out pointer to resulting entity (optional)
* @returns an xmlParserErrors error code.
*/
int
xmlAddEntity(xmlDoc *doc, int extSubset, const xmlChar *name, int type,
const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *content, xmlEntity **out) {
xmlDtdPtr dtd;
xmlDictPtr dict = NULL;
xmlEntitiesTablePtr table = NULL;
xmlEntityPtr ret, predef;
int res;
if (out != NULL)
*out = NULL;
if ((doc == NULL) || (name == NULL))
return(XML_ERR_ARGUMENT);
dict = doc->dict;
if (extSubset)
dtd = doc->extSubset;
else
dtd = doc->intSubset;
if (dtd == NULL)
return(XML_DTD_NO_DTD);
switch (type) {
case XML_INTERNAL_GENERAL_ENTITY:
case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
predef = xmlGetPredefinedEntity(name);
if (predef != NULL) {
int valid = 0;
/* 4.6 Predefined Entities */
if ((type == XML_INTERNAL_GENERAL_ENTITY) &&
(content != NULL)) {
int c = predef->content[0];
if (((content[0] == c) && (content[1] == 0)) &&
((c == '>') || (c == '\'') || (c == '"'))) {
valid = 1;
} else if ((content[0] == '&') && (content[1] == '#')) {
if (content[2] == 'x') {
xmlChar *hex = BAD_CAST "0123456789ABCDEF";
xmlChar ref[] = "00;";
ref[0] = hex[c / 16 % 16];
ref[1] = hex[c % 16];
if (xmlStrcasecmp(&content[3], ref) == 0)
valid = 1;
} else {
xmlChar ref[] = "00;";
ref[0] = '0' + c / 10 % 10;
ref[1] = '0' + c % 10;
if (xmlStrEqual(&content[2], ref))
valid = 1;
}
}
}
if (!valid)
return(XML_ERR_REDECL_PREDEF_ENTITY);
}
if (dtd->entities == NULL) {
dtd->entities = xmlHashCreateDict(0, dict);
if (dtd->entities == NULL)
return(XML_ERR_NO_MEMORY);
}
table = dtd->entities;
break;
case XML_INTERNAL_PARAMETER_ENTITY:
case XML_EXTERNAL_PARAMETER_ENTITY:
if (dtd->pentities == NULL) {
dtd->pentities = xmlHashCreateDict(0, dict);
if (dtd->pentities == NULL)
return(XML_ERR_NO_MEMORY);
}
table = dtd->pentities;
break;
default:
return(XML_ERR_ARGUMENT);
}
ret = xmlCreateEntity(dtd->doc, name, type, publicId, systemId, content);
if (ret == NULL)
return(XML_ERR_NO_MEMORY);
res = xmlHashAdd(table, name, ret);
if (res < 0) {
xmlFreeEntity(ret);
return(XML_ERR_NO_MEMORY);
} else if (res == 0) {
/*
* entity was already defined at another level.
*/
xmlFreeEntity(ret);
return(XML_WAR_ENTITY_REDEFINED);
}
/*
* Link it to the DTD
*/
ret->parent = dtd;
ret->doc = dtd->doc;
if (dtd->last == NULL) {
dtd->children = dtd->last = (xmlNodePtr) ret;
} else {
dtd->last->next = (xmlNodePtr) ret;
ret->prev = dtd->last;
dtd->last = (xmlNodePtr) ret;
}
if (out != NULL)
*out = ret;
return(0);
}
/**
* Look up a predefined entity.
*
* @param name the entity name
* @returns the entity, or NULL if not found.
*/
xmlEntity *
xmlGetPredefinedEntity(const xmlChar *name) {
if (name == NULL) return(NULL);
switch (name[0]) {
case 'l':
if (xmlStrEqual(name, BAD_CAST "lt"))
return(&xmlEntityLt);
break;
case 'g':
if (xmlStrEqual(name, BAD_CAST "gt"))
return(&xmlEntityGt);
break;
case 'a':
if (xmlStrEqual(name, BAD_CAST "amp"))
return(&xmlEntityAmp);
if (xmlStrEqual(name, BAD_CAST "apos"))
return(&xmlEntityApos);
break;
case 'q':
if (xmlStrEqual(name, BAD_CAST "quot"))
return(&xmlEntityQuot);
break;
default:
break;
}
return(NULL);
}
/**
* Add a new entity to the document's external subset.
*
* #xmlAddEntity offers better error handling.
*
* @param doc the document
* @param name the entity name
* @param type an xmlEntityType value
* @param publicId the publid identifier (optional)
* @param systemId the system identifier (URL) (optional)
* @param content the entity content
* @returns a pointer to the entity or NULL in case of error
*/
xmlEntity *
xmlAddDtdEntity(xmlDoc *doc, const xmlChar *name, int type,
const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *content) {
xmlEntityPtr ret;
xmlAddEntity(doc, 1, name, type, publicId, systemId, content, &ret);
return(ret);
}
/**
* Add a new entity to the document's internal subset.
*
* #xmlAddEntity offers better error handling.
*
* @param doc the document
* @param name the entity name
* @param type an xmlEntityType value
* @param publicId the publid identifier (optional)
* @param systemId the system identifier (URL) (optional)
* @param content the entity content
* @returns a pointer to the entity or NULL in case of error
*/
xmlEntity *
xmlAddDocEntity(xmlDoc *doc, const xmlChar *name, int type,
const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *content) {
xmlEntityPtr ret;
xmlAddEntity(doc, 0, name, type, publicId, systemId, content, &ret);
return(ret);
}
/**
* Create a new entity.
*
* Like #xmlAddDocEntity, but if `doc` is NULL or has no internal
* subset defined, an unlinked entity will be returned. It is then
* the responsibility of the caller to link it to the document later
* or free it when not needed anymore.
*
* @param doc the document (optional)
* @param name the entity name
* @param type an xmlEntityType value
* @param publicId the publid identifier (optional)
* @param systemId the system identifier (URL) (optional)
* @param content the entity content
* @returns a pointer to the entity or NULL in case of error
*/
xmlEntity *
xmlNewEntity(xmlDoc *doc, const xmlChar *name, int type,
const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *content) {
if ((doc != NULL) && (doc->intSubset != NULL)) {
return(xmlAddDocEntity(doc, name, type, publicId, systemId, content));
}
if (name == NULL)
return(NULL);
return(xmlCreateEntity(doc, name, type, publicId, systemId, content));
}
/**
* Look up an entity in a table.
*
* @param table an entity table
* @param name the entity name
* @returns a pointer to the entity or NULL if not found.
*/
static xmlEntityPtr
xmlGetEntityFromTable(xmlEntitiesTablePtr table, const xmlChar *name) {
return((xmlEntityPtr) xmlHashLookup(table, name));
}
/**
* Look up a paramater entity in the internal and external subset
* of `doc`.
*
* @param doc the document
* @param name the entity name
* @returns a pointer to the entity or NULL if not found.
*/
xmlEntity *
xmlGetParameterEntity(xmlDoc *doc, const xmlChar *name) {
xmlEntitiesTablePtr table;
xmlEntityPtr ret;
if (doc == NULL)
return(NULL);
if ((doc->intSubset != NULL) && (doc->intSubset->pentities != NULL)) {
table = (xmlEntitiesTablePtr) doc->intSubset->pentities;
ret = xmlGetEntityFromTable(table, name);
if (ret != NULL)
return(ret);
}
if ((doc->extSubset != NULL) && (doc->extSubset->pentities != NULL)) {
table = (xmlEntitiesTablePtr) doc->extSubset->pentities;
return(xmlGetEntityFromTable(table, name));
}
return(NULL);
}
/**
* Look up a general entity in the external subset of `doc`.
*
* @param doc the document
* @param name the entity name
* @returns a pointer to the entity or NULL if not found.
*/
xmlEntity *
xmlGetDtdEntity(xmlDoc *doc, const xmlChar *name) {
xmlEntitiesTablePtr table;
if (doc == NULL)
return(NULL);
if ((doc->extSubset != NULL) && (doc->extSubset->entities != NULL)) {
table = (xmlEntitiesTablePtr) doc->extSubset->entities;
return(xmlGetEntityFromTable(table, name));
}
return(NULL);
}
/**
* Look up a general entity in the internal and external subset
* of `doc`. Also checks for predefined entities.
*
* @param doc the document referencing the entity
* @param name the entity name
* @returns a pointer to the entity or NULL if not found.
*/
xmlEntity *
xmlGetDocEntity(const xmlDoc *doc, const xmlChar *name) {
xmlEntityPtr cur;
xmlEntitiesTablePtr table;
if (doc != NULL) {
if ((doc->intSubset != NULL) && (doc->intSubset->entities != NULL)) {
table = (xmlEntitiesTablePtr) doc->intSubset->entities;
cur = xmlGetEntityFromTable(table, name);
if (cur != NULL)
return(cur);
}
if (doc->standalone != 1) {
if ((doc->extSubset != NULL) &&
(doc->extSubset->entities != NULL)) {
table = (xmlEntitiesTablePtr) doc->extSubset->entities;
cur = xmlGetEntityFromTable(table, name);
if (cur != NULL)
return(cur);
}
}
}
return(xmlGetPredefinedEntity(name));
}
/**
* Replace special characters with predefined entities or numeric
* character references.
*
* If `doc` is NULL or an XML document, replaces `<`, `>` and `&`
* with predefined entities. Carriage return is replaced with
* `&#13;`. If `doc` or its encoding are NULL, non-ASCII
* characters are replaced with a hexadecimal character reference.
*
* If `doc` is an HTML document, follows the HTML serialization
* rules.
*
* Silently removes some invalid characters like ASCII control
* codes.
*
* See #xmlEncodeSpecialChars for an alternative.
*
* @param doc the document containing the string (optional)
* @param input A string to convert to XML.
* @returns a newly allocated string with substitutions.
*/
xmlChar *
xmlEncodeEntitiesReentrant(xmlDoc *doc, const xmlChar *input) {
int flags = 0;
if (input == NULL)
return(NULL);
if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE))
flags |= XML_ESCAPE_HTML;
else if ((doc == NULL) || (doc->encoding == NULL))
flags |= XML_ESCAPE_NON_ASCII;
return(xmlEscapeText(input, flags));
}
/**
* Replace special characters with predefined entities or numeric
* character references.
*
* Replaces `<`, `>`, `&` and `"` with predefined entities. Carriage
* return is replaced with `&#13;`.
*
* @param doc unused
* @param input A string to convert to XML.
* @returns a newly allocated string with substitutions.
*/
xmlChar *
xmlEncodeSpecialChars(const xmlDoc *doc ATTRIBUTE_UNUSED,
const xmlChar *input) {
if (input == NULL)
return(NULL);
return(xmlEscapeText(input, XML_ESCAPE_QUOT));
}
/**
* Create and initialize an empty entities hash table.
*
* @deprecated Internal function, don't use.
*
* @returns the xmlEntitiesTable just created or NULL in case of error.
*/
xmlEntitiesTable *
xmlCreateEntitiesTable(void) {
return((xmlEntitiesTablePtr) xmlHashCreate(0));
}
/**
* Deallocate the memory used by an entities in the hash table.
*
* @param entity An entity
* @param name its name
*/
static void
xmlFreeEntityWrapper(void *entity, const xmlChar *name ATTRIBUTE_UNUSED) {
if (entity != NULL)
xmlFreeEntity((xmlEntityPtr) entity);
}
/**
* Deallocate the memory used by an entities hash table.
*
* @deprecated Internal function, don't use.
*
* @param table An entity table
*/
void
xmlFreeEntitiesTable(xmlEntitiesTable *table) {
xmlHashFree(table, xmlFreeEntityWrapper);
}
/**
* Build a copy of an entity
*
* @param payload An entity
* @param name unused
* @returns the new xmlEntities or NULL in case of error.
*/
static void *
xmlCopyEntity(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
xmlEntityPtr ent = (xmlEntityPtr) payload;
xmlEntityPtr cur;
cur = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
if (cur == NULL)
return(NULL);
memset(cur, 0, sizeof(xmlEntity));
cur->type = XML_ENTITY_DECL;
cur->etype = ent->etype;
if (ent->name != NULL) {
cur->name = xmlStrdup(ent->name);
if (cur->name == NULL)
goto error;
}
if (ent->ExternalID != NULL) {
cur->ExternalID = xmlStrdup(ent->ExternalID);
if (cur->ExternalID == NULL)
goto error;
}
if (ent->SystemID != NULL) {
cur->SystemID = xmlStrdup(ent->SystemID);
if (cur->SystemID == NULL)
goto error;
}
if (ent->content != NULL) {
cur->content = xmlStrdup(ent->content);
if (cur->content == NULL)
goto error;
}
if (ent->orig != NULL) {
cur->orig = xmlStrdup(ent->orig);
if (cur->orig == NULL)
goto error;
}
if (ent->URI != NULL) {
cur->URI = xmlStrdup(ent->URI);
if (cur->URI == NULL)
goto error;
}
/* Handle XML_TEXT_NODE children for XML_ENTITY_DECL */
if (ent->children != NULL) {
cur->children = xmlStaticCopyNodeList(ent->children, cur->doc, (xmlNodePtr)cur);
/* Update last pointers */
cur->last = cur->children;
while (cur->last && cur->last->next) cur->last = cur->last->next;
}
return(cur);
error:
xmlFreeEntity(cur);
return(NULL);
}
/**
* Build a copy of an entity table.
*
* @deprecated Internal function, don't use.
*
* @param table An entity table
* @returns the new xmlEntitiesTable or NULL in case of error.
*/
xmlEntitiesTable *
xmlCopyEntitiesTable(xmlEntitiesTable *table) {
return(xmlHashCopySafe(table, xmlCopyEntity, xmlFreeEntityWrapper));
}
#ifdef LIBXML_OUTPUT_ENABLED
/**
* This will dump the content of the entity table as an XML DTD
* definition.
*
* @deprecated Internal function, don't use.
*
* @param buf An XML buffer.
* @param ent An entity table
*/
void
xmlDumpEntityDecl(xmlBuffer *buf, xmlEntity *ent) {
xmlSaveCtxtPtr save;
if ((buf == NULL) || (ent == NULL))
return;
save = xmlSaveToBuffer(buf, NULL, 0);
xmlSaveTree(save, (xmlNodePtr) ent);
if (xmlSaveFinish(save) != XML_ERR_OK)
xmlFree(xmlBufferDetach(buf));
}
/**
* When using the hash table scan function, arguments need to be
* reversed.
*
* @param ent an entity table
* @param save a save context
* @param name unused
*/
static void
xmlDumpEntityDeclScan(void *ent, void *save,
const xmlChar *name ATTRIBUTE_UNUSED) {
xmlSaveTree(save, ent);
}
/**
* This will dump the content of the entity table as an XML DTD
* definition.
*
* @deprecated Internal function, don't use.
*
* @param buf An XML buffer.
* @param table An entity table
*/
void
xmlDumpEntitiesTable(xmlBuffer *buf, xmlEntitiesTable *table) {
xmlSaveCtxtPtr save;
if ((buf == NULL) || (table == NULL))
return;
save = xmlSaveToBuffer(buf, NULL, 0);
xmlHashScan(table, xmlDumpEntityDeclScan, save);
if (xmlSaveFinish(save) != XML_ERR_OK)
xmlFree(xmlBufferDetach(buf));
}
#endif /* LIBXML_OUTPUT_ENABLED */
+1379
View File
File diff suppressed because it is too large Load Diff
+16
View File
@@ -0,0 +1,16 @@
/gjobread
/io1
/io2
/parse1
/parse2
/parse3
/parse4
/reader1
/reader2
/reader3
/reader4
/testWriter
/tree1
/tree2
/xpath1
/xpath2
+44
View File
@@ -0,0 +1,44 @@
EXTRA_DIST = \
gjobs.xml \
meson.build \
test1.xml \
test2.xml \
test3.xml
check_PROGRAMS = \
gjobread \
io1 \
io2 \
parse1 \
parse2 \
parse3 \
parse4 \
reader1 \
reader2 \
reader3 \
reader4 \
testWriter \
tree1 \
tree2 \
xpath1 \
xpath2
AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
LDADD = $(top_builddir)/libxml2.la
gjobread_SOURCES=gjobread.c
io1_SOURCES = io1.c
io2_SOURCES = io2.c
parse1_SOURCES = parse1.c
parse2_SOURCES = parse2.c
parse3_SOURCES = parse3.c
parse4_SOURCES = parse4.c
reader1_SOURCES = reader1.c
reader2_SOURCES = reader2.c
reader3_SOURCES = reader3.c
reader4_SOURCES = reader4.c
testWriter_SOURCES = testWriter.c
tree1_SOURCES = tree1.c
tree2_SOURCES = tree2.c
xpath1_SOURCES = xpath1.c
xpath2_SOURCES = xpath2.c
+301
View File
@@ -0,0 +1,301 @@
/*
* gjobread.c : a small test program for gnome jobs XML format
*
* See Copyright for the status of this software.
*
* Daniel.Veillard@w3.org
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/*
* This example should compile and run indifferently with libxml-1.8.8 +
* and libxml2-2.1.0 +
* Check the COMPAT comments below
*/
/*
* COMPAT using xml-config --cflags to get the include path this will
* work with both
*/
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#define DEBUG(x) printf(x)
/*
* A person record
* an xmlChar * is really an UTF8 encoded char string (0 terminated)
*/
typedef struct person {
xmlChar *name;
xmlChar *email;
xmlChar *company;
xmlChar *organisation;
xmlChar *smail;
xmlChar *webPage;
xmlChar *phone;
} person, *personPtr;
/*
* And the code needed to parse it
*/
static personPtr
parsePerson(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
personPtr ret = NULL;
DEBUG("parsePerson\n");
/*
* allocate the struct
*/
ret = (personPtr) malloc(sizeof(person));
if (ret == NULL) {
fprintf(stderr,"out of memory\n");
return(NULL);
}
memset(ret, 0, sizeof(person));
/* We don't care what the top level element name is */
/* COMPAT xmlChildrenNode is a macro unifying libxml1 and libxml2 names */
cur = cur->xmlChildrenNode;
while (cur != NULL) {
if ((!xmlStrcmp(cur->name, (const xmlChar *)"Person")) &&
(cur->ns == ns))
ret->name = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if ((!xmlStrcmp(cur->name, (const xmlChar *)"Email")) &&
(cur->ns == ns))
ret->email = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
cur = cur->next;
}
return(ret);
}
/*
* and to print it
*/
static void
printPerson(personPtr cur) {
if (cur == NULL) return;
printf("------ Person\n");
if (cur->name) printf(" name: %s\n", cur->name);
if (cur->email) printf(" email: %s\n", cur->email);
if (cur->company) printf(" company: %s\n", cur->company);
if (cur->organisation) printf(" organisation: %s\n", cur->organisation);
if (cur->smail) printf(" smail: %s\n", cur->smail);
if (cur->webPage) printf(" Web: %s\n", cur->webPage);
if (cur->phone) printf(" phone: %s\n", cur->phone);
printf("------\n");
}
/*
* a Description for a Job
*/
typedef struct job {
xmlChar *projectID;
xmlChar *application;
xmlChar *category;
personPtr contact;
int nbDevelopers;
personPtr developers[100]; /* using dynamic alloc is left as an exercise */
} job, *jobPtr;
/*
* And the code needed to parse it
*/
static jobPtr
parseJob(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
jobPtr ret = NULL;
DEBUG("parseJob\n");
/*
* allocate the struct
*/
ret = (jobPtr) malloc(sizeof(job));
if (ret == NULL) {
fprintf(stderr,"out of memory\n");
return(NULL);
}
memset(ret, 0, sizeof(job));
/* We don't care what the top level element name is */
cur = cur->xmlChildrenNode;
while (cur != NULL) {
if ((!xmlStrcmp(cur->name, (const xmlChar *) "Project")) &&
(cur->ns == ns)) {
ret->projectID = xmlGetProp(cur, (const xmlChar *) "ID");
if (ret->projectID == NULL) {
fprintf(stderr, "Project has no ID\n");
}
}
if ((!xmlStrcmp(cur->name, (const xmlChar *) "Application")) &&
(cur->ns == ns))
ret->application =
xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if ((!xmlStrcmp(cur->name, (const xmlChar *) "Category")) &&
(cur->ns == ns))
ret->category =
xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if ((!xmlStrcmp(cur->name, (const xmlChar *) "Contact")) &&
(cur->ns == ns))
ret->contact = parsePerson(doc, ns, cur);
cur = cur->next;
}
return(ret);
}
/*
* and to print it
*/
static void
printJob(jobPtr cur) {
int i;
if (cur == NULL) return;
printf("======= Job\n");
if (cur->projectID != NULL) printf("projectID: %s\n", cur->projectID);
if (cur->application != NULL) printf("application: %s\n", cur->application);
if (cur->category != NULL) printf("category: %s\n", cur->category);
if (cur->contact != NULL) printPerson(cur->contact);
printf("%d developers\n", cur->nbDevelopers);
for (i = 0;i < cur->nbDevelopers;i++) printPerson(cur->developers[i]);
printf("======= \n");
}
/*
* A pool of Gnome Jobs
*/
typedef struct gjob {
int nbJobs;
jobPtr jobs[500]; /* using dynamic alloc is left as an exercise */
} gJob, *gJobPtr;
static gJobPtr
parseGjobFile(char *filename) {
xmlDocPtr doc;
gJobPtr ret;
jobPtr curjob;
xmlNsPtr ns;
xmlNodePtr cur;
/*
* build an XML tree from a the file;
*/
doc = xmlReadFile(filename, NULL, XML_PARSE_NOBLANKS);
if (doc == NULL) return(NULL);
/*
* Check the document is of the right kind
*/
cur = xmlDocGetRootElement(doc);
if (cur == NULL) {
fprintf(stderr,"empty document\n");
xmlFreeDoc(doc);
return(NULL);
}
ns = xmlSearchNsByHref(doc, cur,
(const xmlChar *) "http://www.gnome.org/some-location");
if (ns == NULL) {
fprintf(stderr,
"document of the wrong type, GJob Namespace not found\n");
xmlFreeDoc(doc);
return(NULL);
}
if (xmlStrcmp(cur->name, (const xmlChar *) "Helping")) {
fprintf(stderr,"document of the wrong type, root node != Helping");
xmlFreeDoc(doc);
return(NULL);
}
/*
* Allocate the structure to be returned.
*/
ret = (gJobPtr) malloc(sizeof(gJob));
if (ret == NULL) {
fprintf(stderr,"out of memory\n");
xmlFreeDoc(doc);
return(NULL);
}
memset(ret, 0, sizeof(gJob));
/*
* Now, walk the tree.
*/
/* First level we expect just Jobs */
cur = cur->xmlChildrenNode;
while ( cur && xmlIsBlankNode ( cur ) ) {
cur = cur -> next;
}
if ( cur == 0 ) {
xmlFreeDoc(doc);
free(ret);
return ( NULL );
}
if ((xmlStrcmp(cur->name, (const xmlChar *) "Jobs")) || (cur->ns != ns)) {
fprintf(stderr,"document of the wrong type, was '%s', Jobs expected",
cur->name);
fprintf(stderr,"xmlDocDump follows\n");
#ifdef LIBXML_OUTPUT_ENABLED
xmlDocDump ( stderr, doc );
fprintf(stderr,"xmlDocDump finished\n");
#endif /* LIBXML_OUTPUT_ENABLED */
xmlFreeDoc(doc);
free(ret);
return(NULL);
}
/* Second level is a list of Job, but be laxist */
cur = cur->xmlChildrenNode;
while (cur != NULL) {
if ((!xmlStrcmp(cur->name, (const xmlChar *) "Job")) &&
(cur->ns == ns)) {
curjob = parseJob(doc, ns, cur);
if (curjob != NULL)
ret->jobs[ret->nbJobs++] = curjob;
if (ret->nbJobs >= 500) break;
}
cur = cur->next;
}
return(ret);
}
static void
handleGjob(gJobPtr cur) {
int i;
/*
* Do whatever you want and free the structure.
*/
printf("%d Jobs registered\n", cur->nbJobs);
for (i = 0; i < cur->nbJobs; i++) printJob(cur->jobs[i]);
}
int main(int argc, char **argv) {
int i;
gJobPtr cur;
/* COMPAT: Do not generate nodes for formatting spaces */
LIBXML_TEST_VERSION
for (i = 1; i < argc ; i++) {
cur = parseGjobFile(argv[i]);
if ( cur )
handleGjob(cur);
else
fprintf( stderr, "Error parsing file '%s'\n", argv[i]);
}
/* Clean up everything else before quitting. */
xmlCleanupParser();
return(0);
}
+57
View File
@@ -0,0 +1,57 @@
<?xml version="1.0"?>
<gjob:Helping xmlns:gjob="http://www.gnome.org/some-location">
<gjob:Jobs>
<gjob:Job>
<gjob:Project ID="3"/>
<gjob:Application>GBackup</gjob:Application>
<gjob:Category>Development</gjob:Category>
<gjob:Update>
<gjob:Status>Open</gjob:Status>
<gjob:Modified>Mon, 07 Jun 1999 20:27:45 -0400 MET DST</gjob:Modified>
<gjob:Salary>USD 0.00</gjob:Salary>
</gjob:Update>
<gjob:Developers>
<gjob:Developer>
</gjob:Developer>
</gjob:Developers>
<gjob:Contact>
<gjob:Person>Nathan Clemons</gjob:Person>
<gjob:Email>nathan@windsofstorm.net</gjob:Email>
<gjob:Company>
</gjob:Company>
<gjob:Organisation>
</gjob:Organisation>
<gjob:Webpage>
</gjob:Webpage>
<gjob:Snailmail>
</gjob:Snailmail>
<gjob:Phone>
</gjob:Phone>
</gjob:Contact>
<gjob:Requirements>
The program should be released as free software, under the GPL.
</gjob:Requirements>
<gjob:Skills>
</gjob:Skills>
<gjob:Details>
A GNOME based system that will allow a superuser to configure
compressed and uncompressed files and/or file systems to be backed
up with a supported media in the system. This should be able to
perform via find commands generating a list of files that are passed
to tar, dd, cpio, cp, gzip, etc., to be directed to the tape machine
or via operations performed on the filesystem itself. Email
notification and GUI status display very important.
</gjob:Details>
</gjob:Job>
</gjob:Jobs>
</gjob:Helping>
+241
View File
@@ -0,0 +1,241 @@
/*
* icu.c: Example how to use ICU for character encoding conversion
*
* This example shows how to use ICU by installing a custom character
* encoding converter with xmlCtxtSetCharEncConvImpl, available
* since libxml2 2.14.
*
* This approach makes it possible to use ICU even if libxml2 is
* compiled without ICU support. It also makes sure that *only* ICU
* is used. Many Linux distros currently ship libxml2 with support
* for both ICU and iconv which makes the library's behavior hard to
* predict.
*
* The long-term plan is to make libxml2 only support a single
* conversion library internally (iconv on POSIX).
*/
#include <stdio.h>
#include <libxml/parser.h>
#include <unicode/ucnv.h>
#define ICU_PIVOT_BUF_SIZE 1024
typedef struct {
UConverter *uconv; /* for conversion between an encoding and UTF-16 */
UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */
UChar *pivot_source;
UChar *pivot_target;
int isInput;
UChar pivot_buf[ICU_PIVOT_BUF_SIZE];
} myConvCtxt;
static xmlCharEncError
icuConvert(void *vctxt, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, int flush) {
myConvCtxt *cd = vctxt;
const char *ucv_in = (const char *) in;
char *ucv_out = (char *) out;
UConverter *target, *source;
UErrorCode err = U_ZERO_ERROR;
int ret;
if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL)) {
if (outlen != NULL)
*outlen = 0;
return XML_ENC_ERR_INTERNAL;
}
/*
* The ICU API can consume input, including partial sequences,
* even if the output buffer would overflow. The remaining input
* must be processed by calling ucnv_convertEx with a possibly
* empty input buffer.
*/
if (cd->isInput) {
source = cd->uconv;
target = cd->utf8;
} else {
source = cd->utf8;
target = cd->uconv;
}
ucnv_convertEx(target, source, &ucv_out, ucv_out + *outlen,
&ucv_in, ucv_in + *inlen, cd->pivot_buf,
&cd->pivot_source, &cd->pivot_target,
cd->pivot_buf + ICU_PIVOT_BUF_SIZE,
/* reset */ 0, flush, &err);
*inlen = ucv_in - (const char*) in;
*outlen = ucv_out - (char *) out;
if (U_SUCCESS(err)) {
ret = XML_ENC_ERR_SUCCESS;
} else {
switch (err) {
case U_TRUNCATED_CHAR_FOUND:
/* Should only happen with flush */
ret = XML_ENC_ERR_INPUT;
break;
case U_BUFFER_OVERFLOW_ERROR:
ret = XML_ENC_ERR_SPACE;
break;
case U_INVALID_CHAR_FOUND:
case U_ILLEGAL_CHAR_FOUND:
case U_ILLEGAL_ESCAPE_SEQUENCE:
case U_UNSUPPORTED_ESCAPE_SEQUENCE:
ret = XML_ENC_ERR_INPUT;
break;
case U_MEMORY_ALLOCATION_ERROR:
ret = XML_ENC_ERR_MEMORY;
break;
default:
ret = XML_ENC_ERR_INTERNAL;
break;
}
}
return ret;
}
static xmlParserErrors
icuOpen(const char* name, int isInput, myConvCtxt **out)
{
UErrorCode status;
myConvCtxt *cd;
*out = NULL;
cd = xmlMalloc(sizeof(myConvCtxt));
if (cd == NULL)
return XML_ERR_NO_MEMORY;
cd->isInput = isInput;
cd->pivot_source = cd->pivot_buf;
cd->pivot_target = cd->pivot_buf;
status = U_ZERO_ERROR;
cd->uconv = ucnv_open(name, &status);
if (U_FAILURE(status))
goto error;
status = U_ZERO_ERROR;
if (isInput) {
ucnv_setToUCallBack(cd->uconv, UCNV_TO_U_CALLBACK_STOP,
NULL, NULL, NULL, &status);
}
else {
ucnv_setFromUCallBack(cd->uconv, UCNV_FROM_U_CALLBACK_STOP,
NULL, NULL, NULL, &status);
}
if (U_FAILURE(status))
goto error;
status = U_ZERO_ERROR;
cd->utf8 = ucnv_open("UTF-8", &status);
if (U_FAILURE(status))
goto error;
*out = cd;
return 0;
error:
if (cd->uconv)
ucnv_close(cd->uconv);
xmlFree(cd);
if (status == U_FILE_ACCESS_ERROR)
return XML_ERR_UNSUPPORTED_ENCODING;
if (status == U_MEMORY_ALLOCATION_ERROR)
return XML_ERR_NO_MEMORY;
return XML_ERR_SYSTEM;
}
static void
icuClose(myConvCtxt *cd)
{
if (cd == NULL)
return;
ucnv_close(cd->uconv);
ucnv_close(cd->utf8);
xmlFree(cd);
}
static void
icuConvCtxtDtor(void *vctxt) {
icuClose(vctxt);
}
static xmlParserErrors
icuConvImpl(void *vctxt, const char *name, xmlCharEncFlags flags,
xmlCharEncodingHandler **result) {
xmlCharEncConvFunc inFunc = NULL, outFunc = NULL;
myConvCtxt *inputCtxt = NULL;
myConvCtxt *outputCtxt = NULL;
xmlParserErrors ret;
if (flags & XML_ENC_INPUT) {
ret = icuOpen(name, 1, &inputCtxt);
if (ret != 0)
goto error;
inFunc = icuConvert;
}
if (flags & XML_ENC_OUTPUT) {
ret = icuOpen(name, 0, &outputCtxt);
if (ret != 0)
goto error;
outFunc = icuConvert;
}
return xmlCharEncNewCustomHandler(name, inFunc, outFunc, icuConvCtxtDtor,
inputCtxt, outputCtxt, result);
error:
if (inputCtxt != NULL)
icuClose(inputCtxt);
if (outputCtxt != NULL)
icuClose(outputCtxt);
return ret;
}
int
main(void) {
xmlParserCtxtPtr ctxt;
xmlDocPtr doc;
const char *xml;
xmlChar *content;
int ret = 0;
/*
* We use IBM-1051, an alias for HP Roman, as a simple example that
* ICU supports, but iconv (typically) doesn't.
*
* Character code 0xDE is U+00DF Latin Small Letter Sharp S.
*/
xml = "<doc>\xDE</doc>";
ctxt = xmlNewParserCtxt();
xmlCtxtSetCharEncConvImpl(ctxt, icuConvImpl, NULL);
doc = xmlCtxtReadDoc(ctxt, BAD_CAST xml, NULL, "IBM-1051", 0);
xmlFreeParserCtxt(ctxt);
content = xmlNodeGetContent((xmlNodePtr) doc);
printf("content: %s\n", content);
if (!xmlStrEqual(content, BAD_CAST "\xC3\x9F")) {
fprintf(stderr, "conversion failed\n");
ret = 1;
}
xmlFree(content);
xmlFreeDoc(doc);
return ret;
}
+159
View File
@@ -0,0 +1,159 @@
/**
* section: InputOutput
* synopsis: Example of custom Input/Output
* purpose: Demonstrate the use of xmlRegisterInputCallbacks
* to build a custom I/O layer, this is used in an
* XInclude method context to show how dynamic document can
* be built in a clean way.
* usage: io1
* test: io1 > io1.tmp && diff io1.tmp $(srcdir)/io1.res
* author: Daniel Veillard
* copy: see Copyright for the status of this software.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xinclude.h>
#include <libxml/xmlIO.h>
#ifdef LIBXML_XINCLUDE_ENABLED
static const char *result = "<list><people>a</people><people>b</people></list>";
static const char *cur = NULL;
static int rlen;
/**
* sqlMatch:
* @URI: an URI to test
*
* Check for an sql: query
*
* Returns 1 if yes and 0 if another Input module should be used
*/
static int
sqlMatch(const char * URI) {
if ((URI != NULL) && (!strncmp(URI, "sql:", 4)))
return(1);
return(0);
}
/**
* sqlOpen:
* @URI: an URI to test
*
* Return a pointer to the sql: query handler, in this example simply
* the current pointer...
*
* Returns an Input context or NULL in case or error
*/
static void *
sqlOpen(const char * URI) {
if ((URI == NULL) || (strncmp(URI, "sql:", 4)))
return(NULL);
cur = result;
rlen = strlen(result);
return((void *) cur);
}
/**
* sqlClose:
* @context: the read context
*
* Close the sql: query handler
*
* Returns 0 or -1 in case of error
*/
static int
sqlClose(void * context) {
if (context == NULL) return(-1);
cur = NULL;
rlen = 0;
return(0);
}
/**
* sqlRead:
* @context: the read context
* @buffer: where to store data
* @len: number of bytes to read
*
* Implement an sql: query read.
*
* Returns the number of bytes read or -1 in case of error
*/
static int
sqlRead(void * context, char * buffer, int len) {
const char *ptr = (const char *) context;
if ((context == NULL) || (buffer == NULL) || (len < 0))
return(-1);
if (len > rlen) len = rlen;
memcpy(buffer, ptr, len);
rlen -= len;
return(len);
}
static const char *const include = "<?xml version='1.0'?>\n\
<document xmlns:xi=\"http://www.w3.org/2003/XInclude\">\n\
<p>List of people:</p>\n\
<xi:include href=\"sql:select_name_from_people\"/>\n\
</document>\n";
int main(void) {
xmlDocPtr doc;
/*
* this initialize the library and check potential ABI mismatches
* between the version it was compiled for and the actual shared
* library used.
*/
LIBXML_TEST_VERSION
/*
* register the new I/O handlers
*/
if (xmlRegisterInputCallbacks(sqlMatch, sqlOpen, sqlRead, sqlClose) < 0) {
fprintf(stderr, "failed to register SQL handler\n");
exit(1);
}
/*
* parse include into a document
*/
doc = xmlReadMemory(include, strlen(include), "include.xml", NULL, 0);
if (doc == NULL) {
fprintf(stderr, "failed to parse the including file\n");
exit(1);
}
/*
* apply the XInclude process, this should trigger the I/O just
* registered.
*/
if (xmlXIncludeProcess(doc) <= 0) {
fprintf(stderr, "XInclude processing failed\n");
exit(1);
}
#ifdef LIBXML_OUTPUT_ENABLED
/*
* save the output for checking to stdout
*/
xmlDocDump(stdout, doc);
#endif
/*
* Free the document
*/
xmlFreeDoc(doc);
return(0);
}
#else
int main(void) {
fprintf(stderr, "XInclude support not compiled in\n");
return(0);
}
#endif

Some files were not shown because too many files have changed in this diff Show More