diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.am | 45 | ||||
-rw-r--r-- | scripts/Makefile.in | 671 | ||||
-rw-r--r-- | scripts/build-formats.c | 588 | ||||
-rwxr-xr-x | scripts/fix-bison.pl | 107 | ||||
-rwxr-xr-x | scripts/fix-flex.pl | 154 | ||||
-rwxr-xr-x | scripts/fix-groff-xhtml.pl | 64 | ||||
-rwxr-xr-x | scripts/fix-gtkdoc-header.pl | 38 | ||||
-rwxr-xr-x | scripts/process-changes.pl | 844 | ||||
-rwxr-xr-x | scripts/rdfcompare | 55 |
9 files changed, 2566 insertions, 0 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am new file mode 100644 index 0000000..5591adb --- /dev/null +++ b/scripts/Makefile.am @@ -0,0 +1,45 @@ +# -*- Mode: Makefile -*- +# +# Makefile.am - automake file for Raptor libraptor +# +# Copyright (C) 2010, David Beckett http://www.dajobe.org/ +# +# This package is Free Software and part of Redland http://librdf.org/ +# +# It is licensed under the following three licenses as alternatives: +# 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version +# 2. GNU General Public License (GPL) V2 or any newer version +# 3. Apache License, V2.0 or any newer version +# +# You may not use this file except in compliance with at least one of +# the above three licenses. +# +# See LICENSE.html or LICENSE.txt at the top of this package for the +# complete terms and further detail along with the license texts for +# the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. +# + +EXTRA_DIST= \ +fix-bison.pl \ +fix-flex.pl \ +fix-groff-xhtml.pl \ +fix-gtkdoc-header.pl \ +process-changes.pl \ +rdfcompare + +CLEANFILES = + +AM_CPPFLAGS= -I$(top_srcdir)/src + +if MAINTAINER_MODE +EXTRA_PROGRAMS = build-formats + +CLEANFILES += build-formats + +build_formats_SOURCES = build-formats.c +build_formats_LDADD= $(top_builddir)/src/libraptor2.la + +endif + +$(top_builddir)/src/libraptor2.la: + cd $(top_builddir)/src && $(MAKE) libraptor2.la diff --git a/scripts/Makefile.in b/scripts/Makefile.in new file mode 100644 index 0000000..d285b34 --- /dev/null +++ b/scripts/Makefile.in @@ -0,0 +1,671 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2021 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# -*- Mode: Makefile -*- +# +# Makefile.am - automake file for Raptor libraptor +# +# Copyright (C) 2010, David Beckett http://www.dajobe.org/ +# +# This package is Free Software and part of Redland http://librdf.org/ +# +# It is licensed under the following three licenses as alternatives: +# 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version +# 2. GNU General Public License (GPL) V2 or any newer version +# 3. Apache License, V2.0 or any newer version +# +# You may not use this file except in compliance with at least one of +# the above three licenses. +# +# See LICENSE.html or LICENSE.txt at the top of this package for the +# complete terms and further detail along with the license texts for +# the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. +# +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@MAINTAINER_MODE_TRUE@EXTRA_PROGRAMS = build-formats$(EXEEXT) +@MAINTAINER_MODE_TRUE@am__append_1 = build-formats +subdir = scripts +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/build/gtk-doc.m4 \ + $(top_srcdir)/build/libtool.m4 \ + $(top_srcdir)/build/ltoptions.m4 \ + $(top_srcdir)/build/ltsugar.m4 \ + $(top_srcdir)/build/ltversion.m4 \ + $(top_srcdir)/build/lt~obsolete.m4 $(top_srcdir)/build/pkg.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/src/raptor_config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__build_formats_SOURCES_DIST = build-formats.c +@MAINTAINER_MODE_TRUE@am_build_formats_OBJECTS = \ +@MAINTAINER_MODE_TRUE@ build-formats.$(OBJEXT) +build_formats_OBJECTS = $(am_build_formats_OBJECTS) +@MAINTAINER_MODE_TRUE@build_formats_DEPENDENCIES = \ +@MAINTAINER_MODE_TRUE@ $(top_builddir)/src/libraptor2.la +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src +depcomp = $(SHELL) $(top_srcdir)/build/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/build-formats.Po +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(build_formats_SOURCES) +DIST_SOURCES = $(am__build_formats_SOURCES_DIST) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/build/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BISON = @BISON@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ +CURL_CONFIG = @CURL_CONFIG@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ETAGS = @ETAGS@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FILECMD = @FILECMD@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +HTML_DIR = @HTML_DIR@ +ICU_CFLAGS = @ICU_CFLAGS@ +ICU_LIBS = @ICU_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +JING = @JING@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBCURL_CFLAGS = @LIBCURL_CFLAGS@ +LIBCURL_LIBS = @LIBCURL_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBXML_CFLAGS = @LIBXML_CFLAGS@ +LIBXML_LIBS = @LIBXML_LIBS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MEM = @MEM@ +MEM_LIBS = @MEM_LIBS@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PKG_CONFIG_REQUIRES = @PKG_CONFIG_REQUIRES@ +RANLIB = @RANLIB@ +RAPTOR_LDFLAGS = @RAPTOR_LDFLAGS@ +RAPTOR_LIBTOOLLIBS = @RAPTOR_LIBTOOLLIBS@ +RAPTOR_LIBTOOL_VERSION = @RAPTOR_LIBTOOL_VERSION@ +RAPTOR_PARSERS = @RAPTOR_PARSERS@ +RAPTOR_SERIALIZERS = @RAPTOR_SERIALIZERS@ +RAPTOR_VERSION = @RAPTOR_VERSION@ +RAPTOR_VERSION_DECIMAL = @RAPTOR_VERSION_DECIMAL@ +RAPTOR_VERSION_MAJOR = @RAPTOR_VERSION_MAJOR@ +RAPTOR_VERSION_MINOR = @RAPTOR_VERSION_MINOR@ +RAPTOR_VERSION_RELEASE = @RAPTOR_VERSION_RELEASE@ +RAPTOR_WWW_LIBRARY = @RAPTOR_WWW_LIBRARY@ +RAPTOR_XML_PARSER = @RAPTOR_XML_PARSER@ +RECHO = @RECHO@ +RECHO_C = @RECHO_C@ +RECHO_N = @RECHO_N@ +RPM_RELEASE = @RPM_RELEASE@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TAR = @TAR@ +VERSION = @VERSION@ +XML_CONFIG = @XML_CONFIG@ +XSLT_CFLAGS = @XSLT_CFLAGS@ +XSLT_CONFIG = @XSLT_CONFIG@ +XSLT_LIBS = @XSLT_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +EXTRA_DIST = \ +fix-bison.pl \ +fix-flex.pl \ +fix-groff-xhtml.pl \ +fix-gtkdoc-header.pl \ +process-changes.pl \ +rdfcompare + +CLEANFILES = $(am__append_1) +AM_CPPFLAGS = -I$(top_srcdir)/src +@MAINTAINER_MODE_TRUE@build_formats_SOURCES = build-formats.c +@MAINTAINER_MODE_TRUE@build_formats_LDADD = $(top_builddir)/src/libraptor2.la +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu scripts/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +build-formats$(EXEEXT): $(build_formats_OBJECTS) $(build_formats_DEPENDENCIES) $(EXTRA_build_formats_DEPENDENCIES) + @rm -f build-formats$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(build_formats_OBJECTS) $(build_formats_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/build-formats.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/build-formats.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/build-formats.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libtool cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +$(top_builddir)/src/libraptor2.la: + cd $(top_builddir)/src && $(MAKE) libraptor2.la + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/scripts/build-formats.c b/scripts/build-formats.c new file mode 100644 index 0000000..827f8ae --- /dev/null +++ b/scripts/build-formats.c @@ -0,0 +1,588 @@ +/* -*- Mode: c; c-basic-offset: 2 -*- + * + * build-formats.c - Helper to print raptor syntaxes into docbook xml + * + * Copyright (C) 2010, David Beckett http://www.dajobe.org/ + * + * This package is Free Software and part of Redland http://librdf.org/ + * + * It is licensed under the following three licenses as alternatives: + * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version + * 2. GNU General Public License (GPL) V2 or any newer version + * 3. Apache License, V2.0 or any newer version + * + * You may not use this file except in compliance with at least one of + * the above three licenses. + * + * See LICENSE.html or LICENSE.txt at the top of this package for the + * complete terms and further detail along with the license texts for + * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. + * + * + */ + + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include <raptor2.h> + +static const char * const program = "build-formats"; + +static raptor_world* world = NULL; + + + +static void +emit_literal(const char* literal, raptor_iostream* iostr) +{ + raptor_iostream_string_write("<literal>", iostr); + raptor_iostream_string_write(literal, iostr); + raptor_iostream_string_write("</literal>", iostr); +} + + +#if 0 +static void +emit_function(const char* name, raptor_iostream* iostr) +{ + int i; + char c; + + raptor_iostream_string_write("<link linkend=\">", iostr); + for(i = 0; (c = name[i]); i++) { + if(c == '_') + c = '-'; + raptor_iostream_write_byte(c, iostr); + } + raptor_iostream_string_write("\"><function>", iostr); + raptor_iostream_string_write(name, iostr); + raptor_iostream_string_write("()</function></link>", iostr); +} +#endif + + +static void +emit_header(const char* id, raptor_iostream* iostr) +{ + raptor_iostream_string_write( +"<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.3//EN\" \n" +" \"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd\">\n" +"<chapter id=\"", + iostr); + raptor_iostream_string_write(id, iostr); + raptor_iostream_string_write( +"\">\n" +"<title>Syntax Formats supported in Raptor</title>\n" +"\n" +"<para>This chapter describes the syntax formats supported\n" +"by parsers and serializers in Raptor.\n" +"</para>\n" +"\n", + iostr); +} + + +static void +emit_footer(raptor_iostream *iostr) +{ + raptor_iostream_string_write( +"</chapter>\n" +"\n" +"<!--\n" +"Local variables:\n" +"mode: sgml\n" +"sgml-parent-document: (\"raptor-docs.xml\" \"book\" \"part\")\n" +"End:\n" +"-->\n" +"\n", + iostr); +} + + +static void +emit_start_section(const char* id, const char* title, raptor_iostream* iostr) +{ + raptor_iostream_string_write("<section id=\"", iostr); + raptor_iostream_string_write(id, iostr); + raptor_iostream_string_write( +"\">\n" +"<title>", + iostr); + raptor_xml_escape_string_write((const unsigned char*)title, strlen(title), + '\0', iostr); + raptor_iostream_string_write("</title>\n", iostr); +} + + +static void +emit_end_section(raptor_iostream *iostr) +{ + raptor_iostream_string_write( +"</section>\n" +"\n", + iostr); +} + + +static void +emit_start_list(raptor_iostream *iostr) +{ + raptor_iostream_string_write(" <itemizedlist>\n", iostr); +} + + +static void +emit_start_list_item(raptor_iostream *iostr) +{ + raptor_iostream_string_write(" <listitem><para>", iostr); +} + + +static void +emit_end_list_item(raptor_iostream *iostr) +{ + raptor_iostream_string_write("</para></listitem>\n", iostr); +} + + +static void +emit_end_list(raptor_iostream *iostr) +{ + raptor_iostream_string_write(" </itemizedlist>\n", iostr); +} + + +static void +emit_start_desc_list(const char* title, raptor_iostream *iostr) +{ + raptor_iostream_string_write( + " <variablelist>\n", + iostr); + if(title) { + raptor_iostream_string_write( +" <title>", + iostr); + raptor_iostream_string_write(title, iostr); + raptor_iostream_string_write("</title>\n", iostr); + } + raptor_iostream_write_byte('\n', iostr); +} + + +static void +emit_start_desc_list_term(raptor_iostream *iostr) +{ + raptor_iostream_string_write( +" <varlistentry><term>", + iostr); +} + + +static void +emit_start_desc_list_defn(raptor_iostream *iostr) +{ + raptor_iostream_string_write( +"</term>\n" +" <listitem>", + iostr); +} + + +static void +emit_end_desc_list_item(raptor_iostream *iostr) +{ + raptor_iostream_string_write( +" </listitem>\n" +" </varlistentry>\n" +"\n", + iostr); +} + + +static void +emit_end_desc_list(raptor_iostream *iostr) +{ + raptor_iostream_string_write(" </variablelist>\n", iostr); +} + + +static void +emit_mime_type_name(const char *name, raptor_iostream* iostr) +{ + emit_literal(name, iostr); +} + +static void +emit_mime_type_q(unsigned char q, raptor_iostream* iostr) +{ + if(q < 10) { + raptor_iostream_string_write("q 0.", iostr); + raptor_iostream_decimal_write((int)q, iostr); + } else + raptor_iostream_string_write("q 1.0", iostr); +} + +static void +emit_mime_type(const raptor_type_q* mt, raptor_iostream* iostr) +{ + emit_mime_type_name(mt->mime_type, iostr); + raptor_iostream_string_write(" with ", iostr); + emit_mime_type_q(mt->q, iostr); +} + + +static void +emit_format_description_name(const char* type_name, + const raptor_syntax_description* sd, + raptor_iostream* iostr) +{ + raptor_xml_escape_string_write((const unsigned char*)sd->label, + strlen(sd->label), + '\0', iostr); + if(type_name) { + raptor_iostream_write_byte(' ', iostr); + raptor_iostream_string_write(type_name, iostr); + } + raptor_iostream_string_write(" (", iostr); + emit_literal(sd->names[0], iostr); + raptor_iostream_write_byte(')', iostr); +} + + +static void +emit_format_description(const char* type_name, + const raptor_syntax_description* sd, + raptor_iostream* iostr) +{ + unsigned int i; + + if(!sd->mime_types_count) + return; + + /* term */ + emit_start_desc_list_term(iostr); + emit_format_description_name(type_name, sd, iostr); + + /* definition */ + emit_start_desc_list_defn(iostr); + raptor_iostream_string_write("\n ", iostr); + + emit_start_list(iostr); + for(i = 0; i < sd->mime_types_count; i++) { + const raptor_type_q* mime_type = &sd->mime_types[i]; + if(!sd) + break; + raptor_iostream_string_write(" ", iostr); + emit_start_list_item(iostr); + emit_mime_type(mime_type, iostr); + emit_end_list_item(iostr); + } + raptor_iostream_string_write(" ", iostr); + emit_end_list(iostr); + + emit_end_desc_list_item(iostr); +} + + +static int +sort_sd_by_name(const void *a, const void *b) +{ + raptor_syntax_description* sd_a = *(raptor_syntax_description**)a; + raptor_syntax_description* sd_b = *(raptor_syntax_description**)b; + + return strcmp(sd_a->label, sd_b->label); +} + + +typedef struct +{ + const char *mime_type; + unsigned char q; + raptor_syntax_description* parser_sd; + raptor_syntax_description* serializer_sd; +} type_syntax; + + +static int +sort_type_syntax_by_mime_type(const void *a, const void *b) +{ + int rc; + + const char* mime_type_a = ((type_syntax*)a)->mime_type; + const char* mime_type_b = ((type_syntax*)b)->mime_type; + + if(!mime_type_a || !mime_type_b) { + if(!mime_type_a && !mime_type_b) + return (int)(mime_type_b - mime_type_a); + return (mime_type_a) ? 1 : -1; + } + + rc = strcmp(mime_type_a, mime_type_b); + if(rc) + return rc; + return ((type_syntax*)b)->q - ((type_syntax*)a)->q; +} + + + +static void +emit_format_to_syntax_list(raptor_iostream* iostr, + type_syntax* type_syntaxes, + const char* mime_type, + int start, int end) +{ + int i; + int parser_seen = 0; + int serializer_seen = 0; + + /* term */ + emit_start_desc_list_term(iostr); + emit_mime_type_name(mime_type, iostr); + + /* definition */ + emit_start_desc_list_defn(iostr); + raptor_iostream_string_write("\n ", iostr); + + emit_start_list(iostr); + for(i = start; i <= end; i++) { + raptor_iostream_string_write(" ", iostr); + emit_start_list_item(iostr); + if(type_syntaxes[i].parser_sd) { + emit_format_description_name("Parser", + type_syntaxes[i].parser_sd, + iostr); + parser_seen++; + } else { + emit_format_description_name("Serializer", + type_syntaxes[i].serializer_sd, + iostr); + serializer_seen++; + } + raptor_iostream_string_write(" with ", iostr); + emit_mime_type_q(type_syntaxes[i].q, iostr); + emit_end_list_item(iostr); + } + if(!parser_seen || !serializer_seen) { + emit_start_list_item(iostr); + if(!parser_seen) + raptor_iostream_string_write("No parser.", iostr); + else + raptor_iostream_string_write("No serializer.", iostr); + emit_end_list_item(iostr); + } + raptor_iostream_string_write(" ", iostr); + emit_end_list(iostr); + + emit_end_desc_list_item(iostr); +} + + +int +main(int argc, char *argv[]) +{ + int rc = 1; + int i; + int parsers_count = 0; + int serializers_count = 0; + int mime_types_count = 0; + raptor_syntax_description** parsers = NULL; + raptor_syntax_description** serializers = NULL; + raptor_iostream* iostr = NULL; + type_syntax* type_syntaxes = NULL; + int type_syntaxes_count = 0; + + if(argc != 1) { + fprintf(stderr, "%s: USAGE: %s\n", program, program); + return 1; + } + + world = raptor_new_world(); + if(!world) + goto tidy; + + + for(i = 0; 1; i++) { + raptor_syntax_description* sd; + sd = (raptor_syntax_description*)raptor_world_get_parser_description(world, i); + if(!sd) + break; + parsers_count++; + mime_types_count += sd->mime_types_count; + } + for(i = 0; 1; i++) { + raptor_syntax_description* sd; + sd = (raptor_syntax_description*)raptor_world_get_serializer_description(world, i); + if(!sd) + break; + serializers_count++; + mime_types_count += sd->mime_types_count; + } + + parsers = (raptor_syntax_description**)calloc(parsers_count, + sizeof(raptor_syntax_description*)); + if(!parsers) + goto tidy; + + serializers = (raptor_syntax_description**)calloc(serializers_count, + sizeof(raptor_syntax_description*)); + if(!serializers) + goto tidy; + + type_syntaxes = (type_syntax*)calloc(mime_types_count, + sizeof(type_syntax)); + if(!type_syntaxes) + goto tidy; + + type_syntaxes_count = 0; + + for(i = 0; 1; i++) { + raptor_syntax_description* sd; + unsigned int m; + + sd = (raptor_syntax_description*)raptor_world_get_parser_description(world, i); + if(!sd) + break; + parsers[i] = sd; + + for(m = 0; m < sd->mime_types_count; m++) { + type_syntaxes[type_syntaxes_count].mime_type = sd->mime_types[m].mime_type; + type_syntaxes[type_syntaxes_count].q = sd->mime_types[m].q; + type_syntaxes[type_syntaxes_count].parser_sd = sd; + type_syntaxes_count++; + } + } + + qsort(parsers, parsers_count, sizeof(raptor_syntax_description*), + sort_sd_by_name); + + for(i = 0; 1; i++) { + raptor_syntax_description* sd; + unsigned int m; + + sd = (raptor_syntax_description*)raptor_world_get_serializer_description(world, i); + if(!sd) + break; + serializers[i] = sd; + + for(m = 0; m < sd->mime_types_count; m++) { + type_syntaxes[type_syntaxes_count].mime_type = sd->mime_types[m].mime_type; + type_syntaxes[type_syntaxes_count].q = sd->mime_types[m].q; + type_syntaxes[type_syntaxes_count].serializer_sd = sd; + type_syntaxes_count++; + } + } + + qsort(serializers, serializers_count, sizeof(raptor_syntax_description*), + sort_sd_by_name); + + + iostr = raptor_new_iostream_to_file_handle(world, stdout); + if(!iostr) + goto tidy; + + + /* MIME Types by parser */ + emit_header("raptor-formats", iostr); + + emit_start_section("raptor-formats-intro", + "Introduction", + iostr); + raptor_iostream_string_write( +"<para>\n" +"The parsers and serializers in raptor can handle different MIME Types with different levels of quality (Q). A Q of 1.0 indicates that the parser or serializer will be able to read or write the full format with high quality, and it should be the prefered parser or serializer for that mime type. Lower Q values indicate either additional mime type support (for parsing) or less-preferred mime types (for serializing). A serializer typically has just 1 mime type of Q 1.0; the preferred type." +"</para>\n" +, + iostr); + emit_end_section(iostr); + + emit_start_section("raptor-formats-types-by-parser", + "MIME Types by Parser", + iostr); + emit_start_desc_list(NULL, iostr); + for(i = 0; i < parsers_count; i++) { + emit_format_description(NULL, parsers[i], + iostr); + } + emit_end_desc_list(iostr); + emit_end_section(iostr); + + + /* MIME Types by serializer */ + emit_start_section("raptor-formats-types-by-serializer", + "MIME Types by Serializer", + iostr); + emit_start_desc_list(NULL, iostr); + for(i = 0; i < serializers_count; i++) { + emit_format_description(NULL, serializers[i], + iostr); + } + emit_end_desc_list(iostr); + emit_end_section(iostr); + + + /* MIME Types index */ + qsort(type_syntaxes, type_syntaxes_count, sizeof(type_syntax), + sort_type_syntax_by_mime_type); + + emit_start_section("raptor-formats-types-index", + "MIME Types Index", + iostr); + emit_start_desc_list(NULL, iostr); + if(1) { + const char* last_mime_type = NULL; + int last_start_index = -1; + for(i = 0; i < type_syntaxes_count; i++) { + const char *this_mime_type = type_syntaxes[i].mime_type; + + if(last_start_index < 0) { + last_mime_type = this_mime_type; + last_start_index = i; + continue; + } + /* continue if same mime type */ + if(!strcmp(last_mime_type, this_mime_type)) + continue; + + emit_format_to_syntax_list(iostr, type_syntaxes, + last_mime_type, last_start_index, i-1); + + last_mime_type = type_syntaxes[i].mime_type; + last_start_index = i; + } + + emit_format_to_syntax_list(iostr, type_syntaxes, + last_mime_type, last_start_index, i-1); + } + emit_end_desc_list(iostr); + emit_end_section(iostr); + + + + emit_footer(iostr); + + raptor_free_iostream(iostr); + iostr = NULL; + + /* success */ + rc = 0; + + tidy: + if(iostr) + raptor_free_iostream(iostr); + + if(parsers) + free(parsers); + + if(serializers) + free(serializers); + + if(type_syntaxes) + free(type_syntaxes); + + if(world) + raptor_free_world(world); + + return rc; +} diff --git a/scripts/fix-bison.pl b/scripts/fix-bison.pl new file mode 100755 index 0000000..2327a7a --- /dev/null +++ b/scripts/fix-bison.pl @@ -0,0 +1,107 @@ +#!/usr/bin/perl +# +# Format output code generated by bison +# +# Usage: +# bison -b foo_parser -p foo_parser_ -d -v foo_parser.y +# perl fix-bison.pl foo_parser.tab.c +# +# Copyright (C) 2004-2014, David Beckett http://www.dajobe.org/ +# Copyright (C) 2004, University of Bristol, UK http://www.bristol.ac.uk/ +# + +my $seen_yyerrlab1=0; +my $syntax_error_has_default=0; +my $line_offset=1; # #line directives always refer to the NEXT line + +my $extension = '.bak'; + +sub fix($) +{ + my ($file) = @_; + my $backup = $file . $extension; + rename($file, $backup); + open(IN, "$backup"); + open(OUT, ">$file"); + + while(<IN>) { + # Remove code that causes a warning + if(/Suppress GCC warning that yyerrlab1/) { + do { + $_ = <IN>; + $line_offset--; # skipped a line + } while (!/^\#endif/); + $line_offset--; # skipped a line + next; + } + + $seen_yyerrlab1=1 if /goto yyerrlab1/; + + s/^yyerrlab1:// unless $seen_yyerrlab1; + + # Do not use macro name for a temporary variable + s/unsigned int yylineno = /unsigned int yylineno_tmp = /; + s/yyrule - 1, yylineno\)/yyrule - 1, yylineno_tmp\)/; + + # Do not (re)define prototypes that the system did better + if(m%^void \*malloc\s*\(%) { + $line_offset--; # skipped a line + next; + } + if(m%^void free\s*\(%) { + $line_offset--; # skipped a line + next; + } + + # syntax error handler will have a default case already in Bison 3.0.5+ + $syntax_error_has_default=1 if /default: \/\* Avoid compiler warnings. \*\//; + + if(m%^\# undef YYCASE_$% and $syntax_error_has_default==0) { + # Add a default value for yyformat on Bison <3.0.5, for coverity CID 10838 + my $line=$_; + print OUT qq{ default: yyformat = YY_("syntax error");\n}; + $line_offset++; # extra line + print OUT $line; + next; + } + + if(m%yysyntax_error_status = YYSYNTAX_ERROR%) { + # Set yytoken to non-negative value for coverity CID 29259 + my $line=$_; + print OUT qq{if(yytoken < 0) yytoken = YYUNDEFTOK;\n}; + $line_offset++; # extra line + print OUT $line; + next; + } + + # Suppress warnings about empty declarations + s/(^static int .*_init_globals.*);$/$1/; + + # Remove always false condition + if(m%if \(/\*CONSTCOND\*/ 0\)%) { + $line_offset--; # skipped a line + $_ = <IN>; + $line_offset--; # skipped a line + next; + } + + # Remove always false condition; this macro is #defined to 0 + if(m%if \(yytable_value_is_error \(yyn\)\)%) { + $line_offset--; # skipped a line + $_ = <IN>; + $line_offset--; # skipped a line + next; + } + + # Fixup pending filename renaming, see above. + # Fix line numbers. + my $line=$. +$line_offset; + s/^(\#line) \d+ (.*\.c)/$1 $line $2/; + + print OUT; + } +} + +for my $file (@ARGV) { + fix $file; +} diff --git a/scripts/fix-flex.pl b/scripts/fix-flex.pl new file mode 100755 index 0000000..785864e --- /dev/null +++ b/scripts/fix-flex.pl @@ -0,0 +1,154 @@ +#!/usr/bin/perl +# +# Format output generated by flex 2.5.31 +# +# Usage: +# flex -o$output $input +# perl fix-flex $output > $tmp +# mv $tmp $output +# +# (C) Copyright 2004-2014 Dave Beckett http://www.dajobe.org/ +# (C) Copyright 2004 University of Bristol +# + +my $line_offset = 1; # #line directives always refer to the NEXT line + +print <<'EOT'; +#ifdef HAVE_CONFIG_H +#include <raptor_config.h> +#endif + +EOT +$line_offset += 4; # added 4 lines above to output + +my $debug = 0; + +# Lexer symbol prefix such as 'turtle_lexer_' +my $prefix = undef; +# Current function or undef if out of function +my $cur_function = undef; +# State for current function for rules to use. +my(%fn_state); + +while(<>) { + # find lexer prefix + if(!defined($prefix) && /^void\s*(.+?)restart\s*\(.*;$/) { + $prefix = $1; + warn "$.: Lexer prefix $prefix\n" + if $debug > 0; + } + + # Remove generated yy_fatal_error declaration and definition to avoid warnings about unused/non-defined static function + # declaration + if(/^static void( yynoreturn)? yy_fatal_error\s*\(.*\)\s*\;\s*$/) { + $line_offset--; # skipped 1 line + next; + } + # definition + if(/^static void( yynoreturn)? yy_fatal_error\s*\(.*\)\s*[^\;]\s*$/) { + do { + $_=<>; + $line_offset--; # skipped 1 line + } while(!/^}/); + $line_offset--; # skipped 1 line + next; + } + + # Replace calls to yy_fatal_error("msg", yyscanner) to YY_FATAL_ERROR("msg") macro + s/(^\s*)yy_fatal_error\s*\(\s*(\".*\")\s*,\s*yyscanner\s*\)/$1YY_FATAL_ERROR($2)/; + + # flex has %option nounistd however it does not work in 2.5.31 + # It is safe to add yet another wrapper. + if(m%^(\#include \<unistd.h\>)$%) { + $_=<<"EOT"; +#ifndef YY_NO_UNISTD_H +$1 +#endif +EOT + $line_offset += 2; # added 2 lines to output + } + + # Fix .[ch] line references because we have added lines to it + my $line = $. + $line_offset; + s/^#line \d+ (\".*\.[ch]\")/#line $line $1/; + + # Fix signed / unsigned comparison gcc 4.x warning: + # int n : in the macro YY_INPUT definition + # (size_t)num_to_read : which is silly since num_to_read is an int! + s/yyg->yy_n_chars, \(size_t\) num_to_read \)/yyg->yy_n_chars, num_to_read \)/; + + + # Match prefixed functions and a couple of static ones starting yy_ + if(!defined($cur_function) && /^.*?((?:${prefix}|yy_)\w+)\s+\((.*)$/) { + my($f,$rest)=($1,$2); + if($rest !~ /;$/) { + $cur_function=$1; + warn "$.: Now in $cur_function: $_\n" + if $debug > 1; + %fn_state=(); + } + } elsif(defined($cur_function) && /^\}/) { + warn "$.: End of $cur_function\n" + if $debug > 1; + $cur_function = undef; + %fn_state=(); + } + + # Fix declaration of signed 'i' operating over range of yy_size_t + if($cur_function eq $prefix."_scan_bytes") { + s/int i;/yy_size_t i;/; + } + + # Add $prefix_cleanup() call at the end of $prefix_lex_destroy() + # find the start of lex_destroy function definition and capture prefix + # look for lexer_free(yyscanner, yyscanner) statement within the function and place the cleanup call before it + if($cur_function eq $prefix."lex_destroy") { + if(/(^\s*)(${prefix}free\s*\(\s*yyscanner\s*,\s*yyscanner\s*\)\s*\;)\s*$/) { + $_=<<"EOT"; +$1/* clean up leaks if any before freeing yyscanner */ +$1${prefix}cleanup(yyscanner); +$1$2 +EOT + $line_offset += 2; # added 2 lines to output + } + } + + # Fix ${prefix}_scan_bytes to take a yy_size_t len arg, not int. + # declaration + s/(${prefix}_scan_bytes|yy_scan_bytes)\s+\( const char \*bytes, int len , yyscan_t yyscanner \);/\1 \( const char \*bytes, yy_size_t len , yyscan_t yyscanner \);/; + # definition + s/^YY_BUFFER_STATE (${prefix}_scan_bytes|yy_scan_bytes)\s+\(const char \* yybytes, int _yybytes_len , yyscan_t yyscanner\)/YY_BUFFER_STATE \1 \(const char \* yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner\)/; + + if($cur_function eq $prefix."_switch_to_buffer" || + $cur_function eq $prefix."restart" || + $cur_function eq $prefix."push_buffer_state") { + if(!exists($fn_state{'seen_ensure'})) { + s%(^\s*if\s*\(\s*!\s*)YY_CURRENT_BUFFER(\s*\)\s*\{.*$)%${1}yyg->yy_buffer_stack${2}%; + if(m%^\s*${prefix}ensure_buffer_stack\s*\(%) { + $fn_state{'seen_ensure'} = 1; + } + } else { + # In condition with whitespace + s%(\s+)YY_CURRENT_BUFFER(\s+)%${1}YY_CURRENT_BUFFER_LVALUE${2}%; + # In parameter or condition + s%([,\(])YY_CURRENT_BUFFER([,\)])%${1}YY_CURRENT_BUFFER_LVALUE${2}%; + } + } + + if($cur_function eq 'yy_get_next_buffer') { + if(!exists($fn_state{'seen_yyinput'}) && + m%^\s*YY_INPUT\(%) { + $fn_state{'seen_yyinput'} = 1; + } elsif(exists($fn_state{'seen_yyinput'})) { + # Remove dead code after YY_INPUT - which is a return NULL + s%^\s*YY_CURRENT_BUFFER_LVALUE->yy_n_chars\s*=\s*yyg->yy_n_chars;%%; + } + } + + if($cur_function eq $prefix.'pop_buffer_state') { + # Change last if use of YY_CURRENT_BUFFER macro to unconditional value + s%^(\s*if \(\s*)YY_CURRENT_BUFFER(\s*\)\s*\{.*)$%${1}YY_CURRENT_BUFFER_LVALUE${2}%; + } + + print; +} diff --git a/scripts/fix-groff-xhtml.pl b/scripts/fix-groff-xhtml.pl new file mode 100755 index 0000000..00d587a --- /dev/null +++ b/scripts/fix-groff-xhtml.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl +# +# Format XHTML generated by groff -Thtml (via tidy) for websites +# +# Usage: groff -Thtml -P-l something.man | tidy -asxml ... | perl fix-groff-xhtml.pl OUTPUT-FILE +# +# (C) Copyright 2003-2014 Dave Beckett +# + +use strict; +use File::Basename; + +my $progname=basename $0; + +my $raptor_title="Raptor RDF Parser Toolkit"; +my $redland_title="Redland RDF Application Framework"; +my $rasqal_title="Rasqal RDF Query Library"; + +die "USAGE: $progname OUTPUT-FILE\n" if @ARGV < 1; + +my $doc_title; + +my($file)=@ARGV; + +open(OUT, ">$file") or die "$progname: Cannot create $file - $!\n"; +open(IN, "-"); +while(<IN>) { + + s%<title>libraptor</title>%<title>$raptor_title - Raptor API</title>%; + s%<h1 align="center">libraptor</h1>%<h1>$raptor_title - Raptor API</h1>%; + + s%<title>rapper</title>%<title>$raptor_title - Raptor RDF parser utility</title>%; + s%<h1 align="center">rapper</h1>%<h1>$raptor_title - Raptor RDF parser utility</h1>%; + + s%<title>rdfproc</title>%<title>$redland_title - Redland RDF processor utility</title>%; + s%<h1 align="center">rdfproc</h1>%<h1>$redland_title - Redland RDF processor utility</h1>%; + + s%<title>librasqal</title>%<title>$rasqal_title - Rasqal API</title>%; + s%<h1 align="center">librasqal</h1>%<h1>$rasqal_title - Rasqal API</h1>%; + + s%<title>roqet</title>%<title>$rasqal_title - Rasqal RDF parser utility</title>%; + s%<h1 align="center">roqet</h1>%<h1>$rasqal_title - Rasqal RDF parser utility</h1>%; + + next if /^<link|meta/i; + + s%^<body[^>]*>%<body>%; + + # This is not xhtml + s% cols="\d+" % %; + + s%(name|id)="([^"]+)"%my($at,$val)=($1,$2); $val =~ s/ /_/g; qq{$at="$val"};%eg; + + s%(Dave Beckett|Institute for Learning and Research Technology .ILRT.|University of Bristol) (?:- |)(http://[^<]+)%<a href="$2">$1</a>%; + + my $year=1900+(localtime)[5]; + print OUT <<"EOT" if m%^</body>%; + +<p>Copyright 2002-$year <a href="http://www.dajobe.org/">Dave Beckett</a><br />2002-2005 <a href="http://www.bristol.ac.uk/">University of Bristol</a></p> + +EOT + print OUT; +} +close(IN); +close(OUT); diff --git a/scripts/fix-gtkdoc-header.pl b/scripts/fix-gtkdoc-header.pl new file mode 100755 index 0000000..df73ccc --- /dev/null +++ b/scripts/fix-gtkdoc-header.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl -w +# +# Edit main header so that gtk-doc is happy about it +# +# USAGE: +# perl fix-gtkc-header.pl < header.h > header.i +# +# Copyright (C) 2010-2014, David Beckett http://www.dajobe.org/ +# +# This package is Free Software and part of Redland http://librdf.org/ +# +# It is licensed under the following three licenses as alternatives: +# 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version +# 2. GNU General Public License (GPL) V2 or any newer version +# 3. Apache License, V2.0 or any newer version +# +# You may not use this file except in compliance with at least one of +# the above three licenses. +# +# See LICENSE.html or LICENSE.txt at the top of this package for the +# complete terms and further detail along with the license texts for +# the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. + +while(<>) { + # Remove trailing macros + s{RAPTOR_PRINTF_FORMAT\(\d+, \d+\);}{;}; + + # gtk-doc hates const in some places + s/const char\* const\* (\w+)/const char\* $1/; + + # and unsigned char + s/const unsigned char \*(\w+)/const char \* $1/; + + # and unsigned char in a handler typedef + s/typedef unsigned char\s*\*/typedef char \*/; + + print; +} diff --git a/scripts/process-changes.pl b/scripts/process-changes.pl new file mode 100755 index 0000000..3c4dbbc --- /dev/null +++ b/scripts/process-changes.pl @@ -0,0 +1,844 @@ +#!/usr/bin/perl -w +# +# Format changes TSV file +# +# USAGE: +# process-changes.pl [OPTIONS] CHANGES-TSV-FILE +# +# Copyright (C) 2010-2011, David Beckett http://www.dajobe.org/ +# +# This package is Free Software and part of Redland http://librdf.org/ +# +# It is licensed under the following three licenses as alternatives: +# 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version +# 2. GNU General Public License (GPL) V2 or any newer version +# 3. Apache License, V2.0 or any newer version +# +# You may not use this file except in compliance with at least one of +# the above three licenses. +# +# See LICENSE.html or LICENSE.txt at the top of this package for the +# complete terms and further detail along with the license texts for +# the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. +# +# +# Example of Format (9 fields): +# OLD VERSION<tab>type | enum | OLD RETURN<tab>OLD NAME<tab>OLD ARGS<tab>NEW VERSION<tab>type | enum | NEW RETURN<tab>NEW NAME<tab>NEW ARGS<tab>NOTES +# +# Functions +# 0.9.21<tab>void<tab>oldfunctionor-<tab>(args)<tab>0.9.22<tab>void<tab>newfunctionor-<tab>(args)<tab>NOTES +# Types +# 0.9.21<tab>type<tab>oldtypenameor-<tab>-<tab>0.9.22<tab>type<tab>newtypeor-<tab>-<tab>NOTES +# Enums +# 0.9.21<tab>enum<tab>oldenumvalueor-<tab>-<tab>0.9.22<tab>enum<tab>newenumvalueor-<tab>-<tab>NOTES +# + +use strict; +use File::Basename; +use IO::File; +use Getopt::Long; +use Pod::Usage; + +our $program = basename $0; + +our $nbsp = ' '; + +our $id_prefix = undef; + +our $raptor_v1_version = '1.4.21'; + +sub print_start_chapter_as_docbook_xml($$$$) { + my($fh, $id, $title, $intro_para)=@_; + + print $fh <<"EOT"; +<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> +<chapter id="$id"> +<title>$title</title> + +<para>$intro_para</para> +EOT + +} + +sub print_end_chapter_as_docbook_xml($) +{ + my($fh)=@_; + print $fh <<"EOT"; + +</chapter> +EOT +} + + + +sub print_docbook_xml($$$@) { + my($fh, $id, $title, @list)=@_; + + print $fh <<"EOT"; +<section id="$id"> +<title>$title</title> +EOT + + print $fh <<"EOT"; +</section> +EOT +} + +sub print_start_section_as_docbook_xml($$$) { + my($fh, $id, $title)=@_; + + print $fh <<"EOT"; +<section id="$id"> +<title>$title</title> + +EOT +} + + +sub format_function_name_as_docbook_xml($) { + my($name)=@_; + + my $escaped_name = $name; $escaped_name =~ s/_/-/g; + return qq{<link linkend="$escaped_name"><function>$name</function></link>}; +} + +sub format_type_name_as_docbook_xml($) { + my($name)=@_; + + my $escaped_name = $name; $escaped_name =~ s/_/-/g; + if($escaped_name =~ /^[-A-Z0-9]+$/) { + $escaped_name .= ":CAPS"; + } + return qq{<link linkend="$escaped_name"><type>$name</type></link>}; +} + +sub format_enum_name_as_docbook_xml($) { + my($name)=@_; + + my $escaped_name = $name; $escaped_name =~ s/_/-/g; + if($escaped_name =~ /^[-A-Z0-9]+$/) { + $escaped_name .= ":CAPS"; + } + return qq{<link linkend="$escaped_name"><literal>$name</literal></link>}; +} + + +sub format_fn_sig($$$$$) { + my($format_name, $show_sig, $fn_return, $fn_name, $fn_args)=@_; + my $formatted_name = $format_name ? format_function_name_as_docbook_xml($fn_name) : $fn_name; + + return $show_sig ? $fn_return . " " . $formatted_name . $fn_args + : $formatted_name; +} + +sub format_notes($$) { + my($is_inline,$notes)=@_; + + if ($notes eq '') { + return $is_inline ? '' : $nbsp; + } + + $notes =~ s{#((?:raptor|librdf|rasqal)\w+)}{format_type_name_as_docbook_xml($1)}ge; + $notes =~ s{#?((?:RAPTOR|LIBRDF|RASQAL)_\w+)}{format_enum_name_as_docbook_xml($1)}ge; + $notes =~ s{((?:raptor|librdf|rasqal)_\w+?)\(}{format_function_name_as_docbook_xml($1)."("}ge; + + return $is_inline ? "- " . $notes : $notes; +} + +sub print_functions_list_as_docbook_xml($$$$@) { + my($fh, $title, $format_name, $show_sig, @list)=@_; + + return if !@list; + + print $fh <<"EOT"; + <itemizedlist> + <title>Functions</title> +EOT + + print $fh " <caption>$title</caption>\n" + if defined $title; + + # Sort by fn_name name + @list = sort { $a->[1] cmp $b->[1] } @list; + + for my $item (@list) { + my($fn_return, $fn_name, $fn_args, $notes) = @$item; + my $formatted_fn = format_fn_sig($format_name, $show_sig, + $fn_return, $fn_name, $fn_args); + $notes = format_notes(1, $notes); + print $fh " <listitem><para>$formatted_fn $notes</para></listitem>\n"; + } + print $fh <<"EOT"; + </itemizedlist> +EOT +} + + +sub format_type_sig($$) { + my($format_name, $type_name)=@_; + return $format_name ? format_type_name_as_docbook_xml($type_name) : $type_name; +} + +sub format_enum_sig($$) { + my($format_name, $enum_name)=@_; + return $format_name ? format_enum_name_as_docbook_xml($enum_name) : $enum_name; +} + + +sub print_types_list_as_docbook_xml($$$$@) { + my($fh, $title, $format_name, $show_sig, @list)=@_; + + return if !@list; + + print $fh <<"EOT"; + <itemizedlist> + <title>Types</title> +EOT + + print $fh " <caption>$title</caption>\n" + if defined $title; + + # Sort by type name + @list = sort { $a->[0] cmp $b->[0] } @list; + + for my $item (@list) { + my($type_name, $notes) = @$item; + my $formatted_fn = format_type_sig($format_name, $type_name); + $notes = format_notes(1, $notes); + print $fh " <listitem><para>$formatted_fn $notes</para></listitem>\n"; + } + print $fh <<"EOT"; + </itemizedlist> +EOT +} + + +sub print_enums_list_as_docbook_xml($$$$@) { + my($fh, $title, $format_name, $show_sig, @list)=@_; + + return if !@list; + + print $fh <<"EOT"; + <itemizedlist> + <title>Enums and Constants</title> +EOT + + print $fh " <caption>$title</caption>\n" + if defined $title; + + # Sort by format name + @list = sort { $a->[0] cmp $b->[0] } @list; + + for my $item (@list) { + my($enum_name, $notes) = @$item; + my $formatted_fn = format_enum_sig($format_name, $enum_name); + $notes = format_notes(1, $notes); + print $fh " <listitem><para>$formatted_fn $notes</para></listitem>\n"; + } + print $fh <<"EOT"; + </itemizedlist> +EOT +} + + +sub print_renamed_functions_as_docbook_xml($$$$@) { + my($fh, $title, $old_function_header, $new_function_header, @list)=@_; + + return if !@list; + + print $fh <<"EOT"; +<table border='1'> +EOT + + print $fh " <caption>$title</caption>\n" + if defined $title; + + # Sort by from name + @list = sort { $a->[0] cmp $b->[0] } @list; + + print $fh <<"EOT"; + <thead> + </thead> + <tbody> + <tr> + <th>$old_function_header</th> + <th>$new_function_header</th> + <th>Notes</th> + </tr> +EOT + for my $item (@list) { + my($from, $to, $notes) = @$item; + my $formatted_name = format_function_name_as_docbook_xml($to); + + $notes = format_notes(0, $notes); + print $fh " <tr valign='top'>\n <td>$from</td> <td>$formatted_name</td> <td>$notes</td>\n </tr>\n"; + } + print $fh <<"EOT"; + </tbody> +</table> +EOT + +} + +sub print_changed_functions_as_docbook_xml($$$$@) { + my($fh, $title, $old_function_header, $new_function_header, @list)=@_; + + return if !@list; + + print $fh <<"EOT"; +<table border='1'> +EOT + + print $fh " <caption>$title</caption>\n" + if defined $title; + + print $fh <<"EOT"; + <thead> + </thead> + <tbody> + <tr> + <th>$old_function_header</th> + <th>$new_function_header</th> + <th>Notes</th> + </tr> +EOT + for my $item (@list) { + my($old_fn_return, $old_fn_name, $old_fn_args, + $new_fn_return, $new_fn_name, $new_fn_args, $notes) = @$item; + + my $old_formatted_fn = format_fn_sig(0, 1, + $old_fn_return, $old_fn_name, $old_fn_args); + + my $new_formatted_fn = format_fn_sig(1, 1, + $new_fn_return, $new_fn_name, $new_fn_args); + + $notes = format_notes(0, $notes); + print $fh " <tr valign='top'>\n <td>$old_formatted_fn</td> <td>$new_formatted_fn</td> <td>$notes</td>\n </tr>\n"; + } + print $fh <<"EOT"; + </tbody> +</table> +EOT + +} + +sub print_end_section_as_docbook_xml($) +{ + my($fh)=@_; + print $fh <<"EOT"; + +</section> +EOT +} + + +sub print_changed_types_as_docbook_xml($$$$@) { + my($fh, $title, $old_type_header, $new_type_header, @list)=@_; + + return if !@list; + + print $fh <<"EOT"; +<table border='1'> +EOT + + print $fh " <caption>$title</caption>\n" + if defined $title; + + # Sort by old type name + @list = sort { $a->[0] cmp $b->[0] } @list; + + print $fh <<"EOT"; + <thead> + </thead> + <tbody> + <tr> + <th>$old_type_header</th> + <th>$new_type_header</th> + <th>Notes</th> + </tr> +EOT + for my $item (@list) { + my($old_type_name, $new_type_name, $notes) = @$item; + + my $old_formatted_type = format_type_sig(0, $old_type_name); + my $new_formatted_type = format_type_sig(1, $new_type_name); + + $notes = format_notes(0, $notes); + print $fh " <tr valign='top'>\n <td>$old_formatted_type</td> <td>$new_formatted_type</td> <td>$notes</td>\n </tr>\n"; + } + print $fh <<"EOT"; + </tbody> +</table> +EOT + +} + + +sub print_renamed_enums_as_docbook_xml($$$$@) { + my($fh, $title, $old_enum_header, $new_enum_header, @list)=@_; + + return if !@list; + + print $fh <<"EOT"; +<table border='1'> +EOT + + print $fh " <caption>$title</caption>\n" + if defined $title; + + # Sort by from name + @list = sort { $a->[0] cmp $b->[0] } @list; + + print $fh <<"EOT"; + <thead> + </thead> + <tbody> + <tr> + <th>$old_enum_header</th> + <th>$new_enum_header</th> + <th>Notes</th> + </tr> +EOT + for my $item (@list) { + my($from, $to, $notes) = @$item; + my $formatted_name = format_enum_name_as_docbook_xml($to); + + $notes = format_notes(0, $notes); + print $fh " <tr valign='top'>\n <td>$from</td> <td>$formatted_name</td> <td>$notes</td>\n </tr>\n"; + } + print $fh <<"EOT"; + </tbody> +</table> +EOT + +} + + +sub print_deletes_as_perl_script($$@) { + my($out_fh, $title, @names) = @_; + + print $out_fh "\n# $title\n"; + + for my $entry (@names) { + my($name,$note)=@$entry; + $note ||= ''; + print $out_fh qq{s|^(.*$name.*)\$|/\\* WARNING: $name - deleted. $note \\*/ \$1|g;\n}; + } +} + + +sub print_renames_as_perl_script($$$@) { + my($out_fh, $title, $is_function, @names) = @_; + + print $out_fh "\n# $title\n"; + + for my $entry (@names) { + my($from, $to, $note)=@$entry; + $note ||= ''; + my $suffix = ($is_function ? '\\(' : ''); + print $out_fh qq{s|$from$suffix|$to$suffix|g;\n}; + } +} + + +sub print_changes_as_perl_script($$@) { + my($out_fh, $title, @names) = @_; + + print $out_fh "\n# $title\n"; + + for my $entry (@names) { + my($from, $to, $note)=@$entry; + $note ||= ''; + print $out_fh qq{s|^(.*)($from)(.*)\$|/\\* WARNING: $from. $note \\*/ \$\{1\}$to\$\{3\}|g;\n}; + } +} + + +sub print_statement_field_renames_as_perl_script($) { + my($out_fh)=@_; + # These are tricky / tedious to deal with entirely by hand but + # the replacement for subject and object can only be determined by a person + my(%statement_field_maps) = ( + 'subject' => 'subject.value.uri or subject.value.blank.string /* WARNING: must choose one */', + 'subject_type' => 'subject.type', + 'predicate' => 'predicate.value.uri', + 'predicate_type' => 'predicate.type', + 'object' => 'object.value.uri or object.value.literal.string or object.value.blank.string /* WARNING: must choose one */', + 'object_type' => 'object.type', + 'object_literal_datatype' => 'object.value.literal.datatype', + 'object_literal_language' => 'object.value.literal.language' + ); + print $out_fh "\n# Replace statement fields with term fields.\n"; + while(my($old,$new) = each %statement_field_maps) { + print $out_fh qq{s|->$old|->$new|g;\n}; + } + print $out_fh "\n"; +} + + +sub to_id($) { + my $id=shift; + + $id =~ s/\W/-/g; + $id =~ s/\-+/-/g; + $id =~ s/^\-//; + $id =~ s/\-$//; + + return $id; +} + + +# main + +my $docbook_xml_file = undef; +my $upgrade_script_file = undef; +my $usage = undef; + +GetOptions( + 'docbook-xml=s' => \$docbook_xml_file, + 'upgrade-script=s' => \$upgrade_script_file, + 'package=s' => \$id_prefix, + 'help|h|?' => \$usage +) || pod2usage(2); + +pod2usage(-verbose => 2) + if $usage; + +# Arguments +our($package, $file) = @ARGV; + +$id_prefix ||= $package; + +# Read in data + +our $expected_n_fields = 9; + +# "$old-$new" versions in order +our(@version_pairs); +# and seen +our(%version_pairs_seen); + +# Hashes keyed by $version_pair. Value is array of descriptive +# arrays specific to each type +my(%new_functions); +my(%deleted_functions); +my(%renamed_functions); +my(%changed_functions); + +my(%new_types); +my(%deleted_types); +my(%changed_types); + +my(%new_enums); +my(%deleted_enums); +my(%renamed_enums); + +open(IN, "<$file") or die "$program: Cannot read $file - $!\n"; +while(<IN>) { + chomp; + + next if /^#/; + + my(@fields)=split(/\t/); + my $actual_n_fields=scalar(@fields); + die "$program: Bad line has $actual_n_fields fields expected $expected_n_fields $.: $_\n" + unless $actual_n_fields == $expected_n_fields; + + if($fields[1] eq 'type') { + my($old_ver, $dummy1, $old_name, $old_args, $new_ver, $dummy2, $new_name, $new_args,$notes)=@fields; + + my $version_pair = $old_ver."-".$new_ver; + if(!$version_pairs_seen{$version_pair}) { + push(@version_pairs, [$old_ver, $new_ver]); + $version_pairs_seen{$version_pair} = 1; + } + + $notes = '' if $notes eq '-'; + + if($old_name eq '-') { + push(@{$new_types{$version_pair}}, [$new_name, $notes]); + } elsif($new_name eq '-') { + push(@{$deleted_types{$version_pair}}, [$old_name, $notes]); + } elsif(($old_name eq $new_name) && $notes eq '') { + # same + } else { + # renamed and maybe something else changed - in the notes + push(@{$changed_types{$version_pair}}, [$old_name, $new_name, $notes]); + } + + } elsif($fields[1] eq 'enum') { + my($old_ver, $dummy1, $old_name, $old_args, $new_ver, $dummy2, $new_name, $new_args,$notes)=@fields; + + my $version_pair = $old_ver."-".$new_ver; + if(!$version_pairs_seen{$version_pair}) { + push(@version_pairs, [$old_ver, $new_ver]); + $version_pairs_seen{$version_pair} = 1; + } + + $notes = '' if $notes eq '-'; + + if($old_name eq '-') { + push(@{$new_enums{$version_pair}}, [$new_name, $notes]); + } elsif($new_name eq '-') { + push(@{$deleted_enums{$version_pair}}, [$old_name, $notes]); + } elsif(($old_name eq $new_name) && $notes eq '') { + # same + } else { + push(@{$renamed_enums{$version_pair}}, [$old_name, $new_name, $notes]); + } + + } else { + my($old_ver, $old_return, $old_name, $old_args, $new_ver, $new_return, $new_name, $new_args,$notes)=@fields; + + my $version_pair = $old_ver."-".$new_ver; + if(!$version_pairs_seen{$version_pair}) { + push(@version_pairs, [$old_ver, $new_ver]); + $version_pairs_seen{$version_pair} = 1; + } + + $notes = '' if $notes eq '-'; + + if($old_name eq '-') { + push(@{$new_functions{$version_pair}}, [$new_return, $new_name, $new_args, $notes]); + } elsif($new_name eq '-') { + push(@{$deleted_functions{$version_pair}}, [$old_return, $old_name, $old_args, $notes]); + } elsif($old_return eq $new_return && $old_name eq $new_name && + $old_args eq $new_args) { + # same + warn "$program: Line records no function change old: $old_return $old_name $old_args to new: $new_return $new_name $new_args\n$.: $_\n" + if $old_ver ne $raptor_v1_version; + } elsif($old_return eq $new_return && $old_name ne $new_name && + $old_args eq $new_args) { + # renamed but nothing else changed + push(@{$renamed_functions{$version_pair}}, [$old_name, $new_name, $notes]); + } else { + # something changed - args and/or return + push(@{$changed_functions{$version_pair}}, [$old_return, $old_name, $old_args, $new_return, $new_name, $new_args, $notes]); + } + } +} +close(IN); + + + +sub version_for_sort($) { + map { sprintf("%02d", $_) } split(/\./, $_[0]); +} + +# Write Docbook XML output + +if(defined $docbook_xml_file) { + my $out_fh = new IO::File; + $out_fh->open(">$docbook_xml_file"); + + our $intro_title = "API Changes"; + our $intro_para = <<"EOT"; +This chapter describes the API changes for $package. +EOT + + print_start_chapter_as_docbook_xml($out_fh, + $id_prefix.'-changes', + $intro_title, + $intro_para); + + + print_start_section_as_docbook_xml($out_fh, + $id_prefix.'-changes-intro', + "Introduction"); + print $out_fh <<"EOT"; +<para> +The following sections describe the changes in the API between +versions including additions, deletions, renames (retaining the same +number of parameters, types and return value type) and more complex +changes to functions, types, enums and constants. +</para> +EOT + + print_end_section_as_docbook_xml($out_fh); + + # Sort by new version, newest first + for my $vp (sort { version_for_sort($b->[1]) cmp version_for_sort($a->[1]) } @version_pairs) { + my($old_version, $new_version)= @$vp; + my $id = to_id($old_version) . "-to-" . to_id($new_version); + + my $version_pair = $old_version."-".$new_version; + + print_start_section_as_docbook_xml($out_fh, + $id_prefix.'-changes-'.$id, + "Changes between $package $old_version and $new_version"); + + my(@f, @t, @e); + @f = @{$new_functions{$version_pair} || []}; + @t = @{$new_types{$version_pair} || []}; + @e = @{$new_enums{$version_pair} || []}; + + if(@f || @t || @e) { + print_start_section_as_docbook_xml($out_fh, + $id_prefix.'-changes-new-'.$id, + "New functions, types, enums and constants"); + print_functions_list_as_docbook_xml($out_fh, + undef, 1, 1, @f); + print_types_list_as_docbook_xml($out_fh, + undef, 1, 1, @t); + print_enums_list_as_docbook_xml($out_fh, + undef, 1, 1, @e); + print_end_section_as_docbook_xml($out_fh); + } + + @f = @{$deleted_functions{$version_pair} || []}; + @t = @{$deleted_types{$version_pair} || []}; + @e = @{$deleted_enums{$version_pair} || []}; + if(@f || @t || @e) { + print_start_section_as_docbook_xml($out_fh, + $id_prefix.'-changes-deleted-'.$id, + "Deleted functions, types, enums and constants"); + print_functions_list_as_docbook_xml($out_fh, + undef, 0, 0, @f); + print_types_list_as_docbook_xml($out_fh, + undef, 0, 1, @t); + print_enums_list_as_docbook_xml($out_fh, + undef, 0, 1, @e); + print_end_section_as_docbook_xml($out_fh); + } + + + @f = @{$renamed_functions{$version_pair} || []}; + @e = @{$renamed_enums{$version_pair} || []}; + if(@f || @e) { + print_start_section_as_docbook_xml($out_fh, + $id_prefix.'-changes-renamed-'.$id, + "Renamed functions, enums and constants"); + print_renamed_functions_as_docbook_xml($out_fh, + undef, + "$old_version function", + "$new_version function", + @f); + print_renamed_enums_as_docbook_xml($out_fh, + undef, + "$old_version enum / constant", + "$new_version enum / constant", + @e); + print_end_section_as_docbook_xml($out_fh); + } + + @f = @{$changed_functions{$version_pair} || []}; + @t = @{$changed_types{$version_pair} || []}; + if(@f || @t) { + print_start_section_as_docbook_xml($out_fh, + $id_prefix.'-changes-changed-'.$id, + "Changed functions and types"); + print_changed_functions_as_docbook_xml($out_fh, + undef, + "$old_version function", + "$new_version function", + @f); + print_changed_types_as_docbook_xml($out_fh, + undef, + "$old_version type", + "$new_version type", + @t); + print_end_section_as_docbook_xml($out_fh); + } + + print_end_section_as_docbook_xml($out_fh); + + } # end pair of old/new versions + + print_end_chapter_as_docbook_xml($out_fh); + + $out_fh->close; +} + + +# Write Upgrade script output + +if(defined $upgrade_script_file) { + my $out_fh = new IO::File; + $out_fh->open(">$upgrade_script_file"); + + print $out_fh "#!/usr/bin/perl -pi~\n"; + + for my $vp (@version_pairs) { + my($old_version, $new_version)= @$vp; + + my $version_pair = $old_version."-".$new_version; + + print $out_fh "# Perl script to upgrade $package $old_version to $new_version\n\n"; + + print_statement_field_renames_as_perl_script($out_fh); + + my(@f, @t, @e); + + @f = @{$deleted_functions{$version_pair} || []}; + @t = @{$deleted_types{$version_pair} || []}; + @e = @{$deleted_enums{$version_pair} || []}; + + print_deletes_as_perl_script($out_fh, 'Deleted functions', + (map { [ $_->[1], $_->[3] ] } @f)); + + print_deletes_as_perl_script($out_fh, 'Deleted types', + @t); + + print_deletes_as_perl_script($out_fh, 'Deleted enums and constants', + @e); + + @f = @{$renamed_functions{$version_pair} || []}; + @e = @{$renamed_enums{$version_pair} || []}; + print_renames_as_perl_script($out_fh, 'Renamed functions', 1, + @f); + + print_renames_as_perl_script($out_fh, 'Renamed enums and constants', 0, + @e); + + @f = @{$changed_functions{$version_pair} || []}; + @t = @{$changed_types{$version_pair} || []}; + print_changes_as_perl_script($out_fh, 'Changed functions', + (map { [ $_->[1], $_->[4], $_->[6] ] } @f)); + + print_changes_as_perl_script($out_fh, 'Changed types', + @t); + + } # end of version pair loop + + $out_fh->close; +} + + +exit 0; + + +__END__ + +=head1 NAME + +process-changes - turn changes TSV into files + +=head1 SYNOPSIS + +process-changes [options] PACKAGE-NAME TSV-FILE + +=head1 OPTIONS + +=over 8 + +=item B<--help> + +Give command help summary. + +=item B<--docbook-xml> DOCBOOK-XML + +Set the output docbook XML file + +=item B<--upgrade-script> UPGRADE-SCRIPT-PL + +Set the output perl script to upgrade the function and type names +where possible. + +=back + +=head1 DESCRIPTION + +Turn a package's changes TSV file into docbook XML. + +=cut diff --git a/scripts/rdfcompare b/scripts/rdfcompare new file mode 100755 index 0000000..6430bf4 --- /dev/null +++ b/scripts/rdfcompare @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Compare two RDF graphs +# +# Needs an external utility to do a true graph compare. +# + + +PROGRAM=`basename $0` + +CMP=cmp +DIFF=diff + +tmpdiff=/tmp/rdfcompare$$ + +if [ $# -lt 1 ] ; then + echo "$PROGRAM: compare two RDF graphs for isomorphism" 1>&2 + echo "USAGE: $PROGRAM RDF-FILE-1 RDF-FILE-2" 1>&2 + echo "where both files are RDF graphs serialized as N-Triples" 1>&2 + exit 0 +fi + +# Try a simple compare first +$CMP $1 $2 2>&1 +status=$? +if test $status -eq 0; then + exit 0 +fi + +echo "$program: Doing an RDF graph compare" 1>&2 + +if test "X$NTC" != X; then + $NTC $1 $2 > $tmpdiff 2>&1 + status=$? + if test $status != 0; then + $DIFF -u $1 $2 + fi +elif test "X$JENAROOT" != X; then + RDFCOMPARE="$JENAROOT/bin/rdfcompare" + + $RDFCOMPARE $1 $2 N-TRIPLE N-TRIPLE + status=$? + if test $status != 0; then + $DIFF -u $1 $2 + fi +else + $DIFF -u $1 $2 > $tmpdiff + status=$? + if test $status != 0; then + cat $tmpdiff + rm $tmpdiff + fi +fi + +exit $status |