diff options
Diffstat (limited to 'assorted')
-rw-r--r-- | assorted/.gitignore | 1 | ||||
-rw-r--r-- | assorted/Makefile.am | 7 | ||||
-rw-r--r-- | assorted/Makefile.in | 589 | ||||
-rw-r--r-- | assorted/deque2.c | 119 | ||||
-rw-r--r-- | assorted/pack.c | 103 | ||||
-rw-r--r-- | assorted/tofrac.c | 71 | ||||
-rw-r--r-- | assorted/unit2any.c | 49 |
7 files changed, 939 insertions, 0 deletions
diff --git a/assorted/.gitignore b/assorted/.gitignore new file mode 100644 index 0000000..7c16b0a --- /dev/null +++ b/assorted/.gitignore @@ -0,0 +1 @@ +/unit2any diff --git a/assorted/Makefile.am b/assorted/Makefile.am new file mode 100644 index 0000000..fc3c7f1 --- /dev/null +++ b/assorted/Makefile.am @@ -0,0 +1,7 @@ +# -*- Makefile -*- + +AM_CPPFLAGS = -I${top_srcdir}/include + +noinst_PROGRAMS = unit2any + +unit2any_LDADD = ../src/libHX.la diff --git a/assorted/Makefile.in b/assorted/Makefile.in new file mode 100644 index 0000000..f464ec6 --- /dev/null +++ b/assorted/Makefile.in @@ -0,0 +1,589 @@ +# Makefile.in generated by automake 1.13.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 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@ + +# -*- Makefile -*- + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +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@ +noinst_PROGRAMS = unit2any$(EXEEXT) +subdir = assorted +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/build-aux/depcomp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gcc4_visibility.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +PROGRAMS = $(noinst_PROGRAMS) +unit2any_SOURCES = unit2any.c +unit2any_OBJECTS = unit2any.$(OBJEXT) +unit2any_DEPENDENCIES = ../src/libHX.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) +depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp +am__depfiles_maybe = depfiles +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 = unit2any.c +DIST_SOURCES = unit2any.c +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)` +ETAGS = etags +CTAGS = ctags +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@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +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@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LYX = @LYX@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +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@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +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_CXX = @ac_ct_CXX@ +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@ +libdl_LIBS = @libdl_LIBS@ +libexecdir = @libexecdir@ +libpthread_LIBS = @libpthread_LIBS@ +librt_LIBS = @librt_LIBS@ +libsocket_LIBS = @libsocket_LIBS@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfigdir = @pkgconfigdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +regular_CFLAGS = @regular_CFLAGS@ +regular_CPPFLAGS = @regular_CPPFLAGS@ +regular_CXXFLAGS = @regular_CXXFLAGS@ +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@ +AM_CPPFLAGS = -I${top_srcdir}/include +unit2any_LDADD = ../src/libHX.la +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(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) --foreign assorted/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign assorted/Makefile +.PRECIOUS: 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__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +unit2any$(EXEEXT): $(unit2any_OBJECTS) $(unit2any_DEPENDENCIES) $(EXTRA_unit2any_DEPENDENCIES) + @rm -f unit2any$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(unit2any_OBJECTS) $(unit2any_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unit2any.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.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)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.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)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.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: $(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 $(PROGRAMS) +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: + +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 clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -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 -rf ./$(DEPDIR) + -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 check check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS 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 + + +# 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/assorted/deque2.c b/assorted/deque2.c new file mode 100644 index 0000000..e5c4798 --- /dev/null +++ b/assorted/deque2.c @@ -0,0 +1,119 @@ +/* + * libHX/assorted/deque2.c + * Copyright Jan Engelhardt, 2002-2007 + * + * This file is part of libHX. libHX is free software; you can + * redistribute it and/or modify it under the terms of the GNU Lesser + * General Public License as published by the Free Software Foundation; + * either version 2.1 or (at your option) any later version. + * + * deque2.c: + * Assorted DEQUE functions that are not deemed to be useful in the + * (compiled) library at this time. + */ +#include <stdio.h> +#include <libHX.h> + +EXPORT_SYMBOL struct HXdeque_node *HXdeque_rfind(struct HXdeque *dq, + const void *ptr) +{ + struct HXdeque_node *trav; + for (trav = dq->last; trav != NULL; trav = trav->prev) + if (trav->ptr == ptr) + return trav; + return NULL; +} + +EXPORT_SYMBOL void *HXdeque_rget(struct HXdeque *dq, const void *ptr) +{ + struct HXdeque_node *trav; + for (trav = dq->last; trav != NULL; trav = trav->prev) + if (trav->ptr == ptr) + return trav->ptr; + return NULL; +} + +EXPORT_SYMBOL void *HXdeque_sget(struct HXdeque *dq, const char *s) +{ + struct HXdeque_node *trav; + for (trav = dq->first; trav != NULL; trav = trav->next) + if (strcmp(trav->ptr, s) == 0) + return trav->ptr; + return NULL; +} + +EXPORT_SYMBOL struct HXdeque_node *HXdeque_dup(struct HXdeque *dq) +{ + /* + * Duplicate the object on top of the stack by popping it off and + * adding it again, twice. + */ + if (dq->last == NULL) + return NULL; + + /* + * The mathematical axiomatic definition is that the last element is + * popped off and pushed twice. We optimize by simply "looking" at the + * last and push it again. + */ + return HXdeque_push(dq, dq->last->ptr); +} + +EXPORT_SYMBOL struct HXdeque_node *HXdeque_rdup(struct HXdeque *dq) +{ + /* Same as HXdeque_dup(), but works on the bottom of the stack */ + if (dq->first == NULL) + return NULL; + return HXdeque_unshift(dq, dq->first->ptr); +} + +EXPORT_SYMBOL struct HXdeque_node *HXdeque_toprr(struct HXdeque *dq) +{ + /* + * Rotates the topmost three items right ([bottom]...CBA[top] => + * [bottom]...ACB[top]). Also works if there are only two items in the + * stack. + */ + struct HXdeque_node *p = dq->last; + if (p == NULL) + return NULL; + HXdeque_down(p); + HXdeque_down(p); + return p; +} + +EXPORT_SYMBOL struct HXdeque_node *HXdeque_toprl(struct HXdeque *dq) +{ + /* Rotates the topmost three items left (...CBA => ...BAC) */ + struct HXdeque_node *p = dq->last; + if (p == NULL) + return NULL; + if (p->Prev != NULL) p = p->Prev; + if (p->Prev != NULL) p = p->Prev; + HXdeque_up(p); + HXdeque_up(p); + return p; +} + +EXPORT_SYMBOL struct HXdeque_node *HXdeque_botrr(struct HXdeque *dq) +{ + /* (CBA... => ...ACB) */ + struct HXdeque_node *p = dq->first; + if (p == NULL) + return NULL; + if (p->Prev != NULL) p = p->Prev; + if (p->Prev != NULL) p = p->Prev; + HXdeque_down(p); + HXdeque_down(p); + return p; +} + +EXPORT_SYMBOL struct HXdeque_node *HXdeque_botrl(struct HXdeque *dq) +{ + struct HXdeque_node *p = dq->first; + if (p == NULL) + return NULL; + HXdeque_up(p); + HXdeque_up(p); + return p; +} diff --git a/assorted/pack.c b/assorted/pack.c new file mode 100644 index 0000000..9eec65e --- /dev/null +++ b/assorted/pack.c @@ -0,0 +1,103 @@ +/* + * libHX/assorted/pack.c + * Copyright Jan Engelhardt, 1999-2005 + * + * This file is part of libHX. libHX is free software; you can + * redistribute it and/or modify it under the terms of the GNU Lesser + * General Public License as published by the Free Software Foundation; + * either version 2.1 or (at your option) any later version. + */ +#include <sys/types.h> +#include <stdarg.h> +#include <stdint.h> +#include <string.h> + +size_t HX_pack(char *buf, size_t buflen, const char *fmt, ...) +{ + char *obp = buf; + int run = 1; + va_list ap; + va_start(ap, fmt); + + while (run && *fmt != '\0') { + switch (*fmt++) { + case 'A': /* string with up to 255 chars */ + case 'a': { + const char *src = va_arg(ap, const char *); + size_t slen = strlen(src) & 0xFF; + if (buflen < slen + 1) { + run = 0; + break; + } + *buf++ = slen; + memcpy(buf, src, slen); + buf += slen; + buflen -= slen + 1; + break; + } + case 'C': /* unsigned char */ + case 'c': + if (buflen-- < 1) { + run = 0; + break; + } + /* + * Minimum object's size being pushed on the stack is 2 + * bytes since short int is promoted to int when passed + * thru va_arg and stays uncasted. (FIXME) + */ + *buf++ = va_arg(ap, unsigned int); + break; + case 'H': /* unsigned short */ + case 'h': + if (buflen < sizeof(uint16_t)) { + run = 0; + break; + } + *((uint16_t *)buf) = va_arg(ap, uint16_t); + buf += sizeof(uint16_t); + buflen -= sizeof(uint16_t); + break; + case 'L': /* unsigned long */ + case 'l': + if (buflen < sizeof(uint32_t)) { + run = 0; + break; + } + *((uint32_t *)buf) = va_arg(ap, uint32_t); + buf += sizeof(uint32_t); + buflen -= sizeof(uint32_t); + break; + case 'S': /* string with up to 65535 chars */ + case 's': { + const char *src = va_arg(ap, const char *); + size_t slen = strlen(src) & 0xFFFF; + if (buflen < slen + 2) { + run = 0; + break; + } + *((unsigned short *)buf) = slen; + memcpy(buf += 2, src, slen); + buf += slen; + buflen -= slen + 2; + break; + } + case 'V': /* fixed size string */ + case 'v': { + void *src = va_arg(ap, void *); + size_t slen = va_arg(ap, size_t); + if (buflen < slen) { + run = 0; + break; + } + memcpy(buf, src, slen); + buf += slen; + buflen -= slen; + break; + } + } /* switch */ + } + + va_end(ap); + return buf - obp; +} diff --git a/assorted/tofrac.c b/assorted/tofrac.c new file mode 100644 index 0000000..e4c1480 --- /dev/null +++ b/assorted/tofrac.c @@ -0,0 +1,71 @@ +/* + * libHX/assorted/tofrac.c + * Copyright Jan Engelhardt, 1999-2010 + * + * This file is part of libHX. libHX is free software; you can + * redistribute it and/or modify it under the terms of the GNU Lesser + * General Public License as published by the Free Software Foundation; + * either version 2.1 or (at your option) any later version. + */ +/* + * Calculates a readable fraction (i.e. 1/3) from arg and puts the + * *numerator into num, the denominator into *denom. Since the fraction + * is found out by an iterative loop, you can specify the minimum value + * of the denominator in *num and the maximum value of the denominator + * into *denom before calling the function. + * + * If a suitable fraction has been found (within the range of the + * minimum / maximum denominator, *num and *denom will be overwritten + * with the results and true is returned; false for no success. + * + * You need to re-put your min/max denom values into *num and *denom + * then. + */ +#include <sys/types.h> +#include <limits.h> +#include <math.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> + +/* This simplistic version does not deal with negative numbers. */ + +static bool HX_tofrac(double arg, unsigned long *num, unsigned long *denom) +{ + unsigned long i, min_denom = *num, max_denom = *denom; + double j, s; + + /* + * This tries all possible denominators until @arg multiplied by @i + * gives a number that has a fractional part of 0, which is when we + * found the optimal fraction. + */ + for (i = min_denom; i < max_denom; ++i) { + s = arg * i; + modf(s, &j); + if (s == j) { + *num = j; + *denom = i; + return true; + } + } + return false; +} + +int main(int argc, const char **argv) +{ + unsigned long d = 1, n = ULONG_MAX; + + if (argc < 2) { + fprintf(stderr, "Usage: %s 3.141592\n", *argv); + return EXIT_FAILURE; + } + + if (!HX_tofrac(strtod(argv[1], NULL), &d, &n)) { + fprintf(stderr, "Our algorithm was too weak :-)\n"); + return EXIT_FAILURE; + } + + printf("%lu/%lu\n", d, n); + return EXIT_SUCCESS; +} diff --git a/assorted/unit2any.c b/assorted/unit2any.c new file mode 100644 index 0000000..74e87d3 --- /dev/null +++ b/assorted/unit2any.c @@ -0,0 +1,49 @@ +#include <stdbool.h> +#include <stdlib.h> +#include <libHX/option.h> + +static double dpi = 96; + +static void px2any(const struct HXoptcb *cbi) +{ + double px = cbi->data_dbl; + + printf("%f px are (at %f DPI) equal to:\n", px, dpi); + printf("\t%f inch\n", px / dpi); + printf("\t%f pt\n", px * 72 / dpi); + printf("\t%f cm\n", px * 2.54 / dpi); +} + +static void pt2any(const struct HXoptcb *cbi) +{ + double pt = cbi->data_dbl; + + printf("%f pt are equal to:\n", pt); + printf("\t%f inch\n", pt / 72); + printf("\t%f px (at %f DPI)\n", dpi * pt / 72, dpi); + printf("\t%f cm\n", pt * 2.54 / 72); +} + +static const struct HXoption option_table[] = { + {.sh = 'D', .ln = "dpi", .type = HXTYPE_DOUBLE, .ptr = &dpi, + .help = "Resolution (default: 96 dpi)"}, + {.sh = 'P', .ln = "px", .type = HXTYPE_DOUBLE, .cb = px2any}, + {.sh = 'p', .ln = "pt", .type = HXTYPE_DOUBLE, .cb = pt2any}, + HXOPT_AUTOHELP, + HXOPT_TABLEEND, +}; + +static bool get_options(int *argc, const char ***argv) +{ +} + +int main(int argc, const char **argv) +{ + int ret; + + ret = HX_getopt(option_table, &argc, &argv, HXOPT_USAGEONERR); + if (ret != HXOPT_ERR_SUCCESS) + return EXIT_FAILURE; + + +} |