mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-05 12:00:32 -08:00
Removed printf and scanf files
This commit is contained in:
parent
1be07164d0
commit
8aee6be77b
34 changed files with 0 additions and 5037 deletions
|
|
@ -1,32 +0,0 @@
|
|||
## Process this file with automake to generate Makefile.in
|
||||
|
||||
# Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of the GNU MP Library.
|
||||
#
|
||||
# The GNU MP Library 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 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
# License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301, USA.
|
||||
|
||||
|
||||
INCLUDES = -D__GMP_WITHIN_GMP -I$(top_srcdir)
|
||||
|
||||
noinst_LTLIBRARIES = libprintf.la
|
||||
|
||||
libprintf_la_SOURCES = \
|
||||
asprintf.c asprntffuns.c doprnt.c doprntf.c doprnti.c \
|
||||
fprintf.c obprintf.c obvprintf.c obprntffuns.c \
|
||||
printf.c printffuns.c snprintf.c snprntffuns.c sprintf.c sprintffuns.c \
|
||||
vasprintf.c vfprintf.c vprintf.c vsnprintf.c vsprintf.c \
|
||||
repl-vsnprintf.c
|
||||
|
|
@ -1,538 +0,0 @@
|
|||
# Makefile.in generated by automake 1.9.6 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005 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@
|
||||
|
||||
# Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of the GNU MP Library.
|
||||
#
|
||||
# The GNU MP Library 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 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
# License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301, USA.
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
top_builddir = ..
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
INSTALL = @INSTALL@
|
||||
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@
|
||||
ANSI2KNR = $(top_builddir)/ansi2knr
|
||||
LIBOBJDIR =
|
||||
subdir = printf
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
|
||||
$(top_srcdir)/configure.in
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
libprintf_la_LIBADD =
|
||||
am_libprintf_la_OBJECTS = asprintf$U.lo asprntffuns$U.lo doprnt$U.lo \
|
||||
doprntf$U.lo doprnti$U.lo fprintf$U.lo obprintf$U.lo \
|
||||
obvprintf$U.lo obprntffuns$U.lo printf$U.lo printffuns$U.lo \
|
||||
snprintf$U.lo snprntffuns$U.lo sprintf$U.lo sprintffuns$U.lo \
|
||||
vasprintf$U.lo vfprintf$U.lo vprintf$U.lo vsnprintf$U.lo \
|
||||
vsprintf$U.lo repl-vsnprintf$U.lo
|
||||
libprintf_la_OBJECTS = $(am_libprintf_la_OBJECTS)
|
||||
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
|
||||
depcomp =
|
||||
am__depfiles_maybe =
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
SOURCES = $(libprintf_la_SOURCES)
|
||||
DIST_SOURCES = $(libprintf_la_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ABI = @ABI@
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
BITS_PER_MP_LIMB = @BITS_PER_MP_LIMB@
|
||||
CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@
|
||||
CC = @CC@
|
||||
CCAS = @CCAS@
|
||||
CC_FOR_BUILD = @CC_FOR_BUILD@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CPP_FOR_BUILD = @CPP_FOR_BUILD@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFN_LONG_LONG_LIMB = @DEFN_LONG_LONG_LIMB@
|
||||
DEFS = @DEFS@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
ENABLE_STATIC_FALSE = @ENABLE_STATIC_FALSE@
|
||||
ENABLE_STATIC_TRUE = @ENABLE_STATIC_TRUE@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
|
||||
FGREP = @FGREP@
|
||||
GMP_LDFLAGS = @GMP_LDFLAGS@
|
||||
GMP_NAIL_BITS = @GMP_NAIL_BITS@
|
||||
GREP = @GREP@
|
||||
HAVE_HOST_CPU_FAMILY_power = @HAVE_HOST_CPU_FAMILY_power@
|
||||
HAVE_HOST_CPU_FAMILY_powerpc = @HAVE_HOST_CPU_FAMILY_powerpc@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBGMPXX_LDFLAGS = @LIBGMPXX_LDFLAGS@
|
||||
LIBGMP_DLL = @LIBGMP_DLL@
|
||||
LIBGMP_LDFLAGS = @LIBGMP_LDFLAGS@
|
||||
LIBM = @LIBM@
|
||||
LIBM_FOR_BUILD = @LIBM_FOR_BUILD@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
M4 = @M4@
|
||||
MAINT = @MAINT@
|
||||
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
|
||||
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
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@
|
||||
SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@
|
||||
STRIP = @STRIP@
|
||||
TAL_OBJECT = @TAL_OBJECT@
|
||||
TUNE_SQR_OBJ = @TUNE_SQR_OBJ@
|
||||
U = @U@
|
||||
U_FOR_BUILD = @U_FOR_BUILD@
|
||||
VERSION = @VERSION@
|
||||
WANT_CXX_FALSE = @WANT_CXX_FALSE@
|
||||
WANT_CXX_TRUE = @WANT_CXX_TRUE@
|
||||
WANT_MPBSD_FALSE = @WANT_MPBSD_FALSE@
|
||||
WANT_MPBSD_TRUE = @WANT_MPBSD_TRUE@
|
||||
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__leading_dot = @am__leading_dot@
|
||||
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@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
gmp_srclinks = @gmp_srclinks@
|
||||
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@
|
||||
mpn_objects = @mpn_objects@
|
||||
mpn_objs_in_libgmp = @mpn_objs_in_libgmp@
|
||||
mpn_objs_in_libmp = @mpn_objs_in_libmp@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
INCLUDES = -D__GMP_WITHIN_GMP -I$(top_srcdir)
|
||||
noinst_LTLIBRARIES = libprintf.la
|
||||
libprintf_la_SOURCES = \
|
||||
asprintf.c asprntffuns.c doprnt.c doprntf.c doprnti.c \
|
||||
fprintf.c obprintf.c obvprintf.c obprntffuns.c \
|
||||
printf.c printffuns.c snprintf.c snprntffuns.c sprintf.c sprintffuns.c \
|
||||
vasprintf.c vfprintf.c vprintf.c vsnprintf.c vsprintf.c \
|
||||
repl-vsnprintf.c
|
||||
|
||||
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 \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps printf/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu --ignore-deps printf/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: @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
|
||||
|
||||
clean-noinstLTLIBRARIES:
|
||||
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
|
||||
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
|
||||
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||
test "$$dir" != "$$p" || dir=.; \
|
||||
echo "rm -f \"$${dir}/so_locations\""; \
|
||||
rm -f "$${dir}/so_locations"; \
|
||||
done
|
||||
libprintf.la: $(libprintf_la_OBJECTS) $(libprintf_la_DEPENDENCIES)
|
||||
$(LINK) $(libprintf_la_LDFLAGS) $(libprintf_la_OBJECTS) $(libprintf_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
$(top_builddir)/ansi2knr:
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) ansi2knr
|
||||
|
||||
mostlyclean-kr:
|
||||
-test "$U" = "" || rm -f *_.c
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
$(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
$(LTCOMPILE) -c -o $@ $<
|
||||
asprintf_.c: asprintf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/asprintf.c; then echo $(srcdir)/asprintf.c; else echo asprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
asprntffuns_.c: asprntffuns.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/asprntffuns.c; then echo $(srcdir)/asprntffuns.c; else echo asprntffuns.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
doprnt_.c: doprnt.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/doprnt.c; then echo $(srcdir)/doprnt.c; else echo doprnt.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
doprntf_.c: doprntf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/doprntf.c; then echo $(srcdir)/doprntf.c; else echo doprntf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
doprnti_.c: doprnti.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/doprnti.c; then echo $(srcdir)/doprnti.c; else echo doprnti.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
fprintf_.c: fprintf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/fprintf.c; then echo $(srcdir)/fprintf.c; else echo fprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
obprintf_.c: obprintf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/obprintf.c; then echo $(srcdir)/obprintf.c; else echo obprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
obprntffuns_.c: obprntffuns.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/obprntffuns.c; then echo $(srcdir)/obprntffuns.c; else echo obprntffuns.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
obvprintf_.c: obvprintf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/obvprintf.c; then echo $(srcdir)/obvprintf.c; else echo obvprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
printf_.c: printf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/printf.c; then echo $(srcdir)/printf.c; else echo printf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
printffuns_.c: printffuns.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/printffuns.c; then echo $(srcdir)/printffuns.c; else echo printffuns.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
repl-vsnprintf_.c: repl-vsnprintf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/repl-vsnprintf.c; then echo $(srcdir)/repl-vsnprintf.c; else echo repl-vsnprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
snprintf_.c: snprintf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/snprintf.c; then echo $(srcdir)/snprintf.c; else echo snprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
snprntffuns_.c: snprntffuns.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/snprntffuns.c; then echo $(srcdir)/snprntffuns.c; else echo snprntffuns.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
sprintf_.c: sprintf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/sprintf.c; then echo $(srcdir)/sprintf.c; else echo sprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
sprintffuns_.c: sprintffuns.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/sprintffuns.c; then echo $(srcdir)/sprintffuns.c; else echo sprintffuns.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
vasprintf_.c: vasprintf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/vasprintf.c; then echo $(srcdir)/vasprintf.c; else echo vasprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
vfprintf_.c: vfprintf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/vfprintf.c; then echo $(srcdir)/vfprintf.c; else echo vfprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
vprintf_.c: vprintf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/vprintf.c; then echo $(srcdir)/vprintf.c; else echo vprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
vsnprintf_.c: vsnprintf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/vsnprintf.c; then echo $(srcdir)/vsnprintf.c; else echo vsnprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
vsprintf_.c: vsprintf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/vsprintf.c; then echo $(srcdir)/vsprintf.c; else echo vsprintf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
asprintf_.$(OBJEXT) asprintf_.lo asprntffuns_.$(OBJEXT) \
|
||||
asprntffuns_.lo doprnt_.$(OBJEXT) doprnt_.lo doprntf_.$(OBJEXT) \
|
||||
doprntf_.lo doprnti_.$(OBJEXT) doprnti_.lo fprintf_.$(OBJEXT) \
|
||||
fprintf_.lo obprintf_.$(OBJEXT) obprintf_.lo obprntffuns_.$(OBJEXT) \
|
||||
obprntffuns_.lo obvprintf_.$(OBJEXT) obvprintf_.lo printf_.$(OBJEXT) \
|
||||
printf_.lo printffuns_.$(OBJEXT) printffuns_.lo \
|
||||
repl-vsnprintf_.$(OBJEXT) repl-vsnprintf_.lo snprintf_.$(OBJEXT) \
|
||||
snprintf_.lo snprntffuns_.$(OBJEXT) snprntffuns_.lo sprintf_.$(OBJEXT) \
|
||||
sprintf_.lo sprintffuns_.$(OBJEXT) sprintffuns_.lo \
|
||||
vasprintf_.$(OBJEXT) vasprintf_.lo vfprintf_.$(OBJEXT) vfprintf_.lo \
|
||||
vprintf_.$(OBJEXT) vprintf_.lo vsnprintf_.$(OBJEXT) vsnprintf_.lo \
|
||||
vsprintf_.$(OBJEXT) vsprintf_.lo : $(ANSI2KNR)
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool config.lt
|
||||
uninstall-info-am:
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$tags $$unique; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& cd $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) $$here
|
||||
|
||||
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)'; for file in $$list; do \
|
||||
case $$file in \
|
||||
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
|
||||
esac; \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
|
||||
dir="/$$dir"; \
|
||||
$(mkdir_p) "$(distdir)$$dir"; \
|
||||
else \
|
||||
dir=''; \
|
||||
fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
fi; \
|
||||
cp -pR $$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 $(LTLIBRARIES)
|
||||
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:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_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-noinstLTLIBRARIES \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-man:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-info-am
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-noinstLTLIBRARIES ctags 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-exec \
|
||||
install-exec-am install-info install-info-am install-man \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-compile mostlyclean-generic mostlyclean-kr \
|
||||
mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
|
||||
uninstall-am uninstall-info-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:
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/* gmp_asprintf -- formatted output to an allocated space.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
#if HAVE_STDARG
|
||||
gmp_asprintf (char **result, const char *fmt, ...)
|
||||
#else
|
||||
gmp_asprintf (va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
#if HAVE_STDARG
|
||||
va_start (ap, fmt);
|
||||
#else
|
||||
char **result;
|
||||
const char *fmt;
|
||||
va_start (ap);
|
||||
result = va_arg (ap, char **);
|
||||
fmt = va_arg (ap, const char *);
|
||||
#endif
|
||||
|
||||
ret = gmp_vasprintf (result, fmt, ap);
|
||||
va_end (ap);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
/* __gmp_asprintf_memory etc -- formatted output to allocated space.
|
||||
|
||||
Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
|
||||
/* These routines are in a separate file so that the mpz_t, mpq_t and mpf_t
|
||||
operator<< routines can avoid dragging vsnprintf into the link (via
|
||||
__gmp_asprintf_format). */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
__gmp_asprintf_memory (struct gmp_asprintf_t *d, const char *str, size_t len)
|
||||
{
|
||||
GMP_ASPRINTF_T_NEED (d, len);
|
||||
memcpy (d->buf + d->size, str, len);
|
||||
d->size += len;
|
||||
return len;
|
||||
}
|
||||
|
||||
int
|
||||
__gmp_asprintf_reps (struct gmp_asprintf_t *d, int c, int reps)
|
||||
{
|
||||
GMP_ASPRINTF_T_NEED (d, reps);
|
||||
memset (d->buf + d->size, c, reps);
|
||||
d->size += reps;
|
||||
return reps;
|
||||
}
|
||||
|
||||
int
|
||||
__gmp_asprintf_final (struct gmp_asprintf_t *d)
|
||||
{
|
||||
char *buf = d->buf;
|
||||
ASSERT (d->alloc >= d->size + 1);
|
||||
buf[d->size] = '\0';
|
||||
__GMP_REALLOCATE_FUNC_MAYBE_TYPE (buf, d->alloc, d->size+1, char);
|
||||
*d->result = buf;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,623 +0,0 @@
|
|||
/* __gmp_doprnt -- printf style formatted output.
|
||||
|
||||
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
|
||||
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
|
||||
FUTURE GNU MP RELEASES.
|
||||
|
||||
Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#define _GNU_SOURCE /* for DECIMAL_POINT in glibc langinfo.h */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h> /* for isdigit */
|
||||
#include <stddef.h> /* for ptrdiff_t */
|
||||
#include <string.h>
|
||||
#include <stdio.h> /* for NULL */
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h> /* for intmax_t */
|
||||
#else
|
||||
# if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if HAVE_LANGINFO_H
|
||||
#include <langinfo.h> /* for nl_langinfo */
|
||||
#endif
|
||||
|
||||
#if HAVE_LOCALE_H
|
||||
#include <locale.h> /* for localeconv */
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h> /* for quad_t */
|
||||
#endif
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
/* change this to "#define TRACE(x) x" for diagnostics */
|
||||
#define TRACE(x)
|
||||
|
||||
|
||||
/* Should be portable, but in any case this is only used under some ASSERTs. */
|
||||
#define va_equal(x, y) \
|
||||
(memcmp (&(x), &(y), sizeof(va_list)) == 0)
|
||||
|
||||
|
||||
/* printf is convenient because it allows various types to be printed in one
|
||||
fairly compact call, so having gmp_printf support the standard types as
|
||||
well as the gmp ones is important. This ends up meaning all the standard
|
||||
parsing must be duplicated, to get a new routine recognising the gmp
|
||||
extras.
|
||||
|
||||
With the currently favoured handling of mpz etc as Z, Q and F type
|
||||
markers, it's not possible to use glibc register_printf_function since
|
||||
that only accepts new conversion characters, not new types. If Z was a
|
||||
conversion there'd be no way to specify hex, decimal or octal, or
|
||||
similarly with F no way to specify fixed point or scientific format.
|
||||
|
||||
It seems wisest to pass conversions %f, %e and %g of float, double and
|
||||
long double over to the standard printf. It'd be hard to be sure of
|
||||
getting the right handling for NaNs, rounding, etc. Integer conversions
|
||||
%d etc and string conversions %s on the other hand could be easily enough
|
||||
handled within gmp_doprnt, but if floats are going to libc then it's just
|
||||
as easy to send all non-gmp types there.
|
||||
|
||||
"Z" was a type marker for size_t in old glibc, but there seems no need to
|
||||
provide access to that now "z" is standard.
|
||||
|
||||
In GMP 4.1.1 we documented "ll" and "L" as being equivalent, but in C99
|
||||
in fact "ll" is just for long long and "L" just for long double.
|
||||
Apparentely GLIBC allows "L" for long long though. This doesn't affect
|
||||
us as such, since both are passed through to the C library. To be
|
||||
consistent with what we said before, the two are treated equivalently
|
||||
here, and it's left to the C library to do what it thinks with them.
|
||||
|
||||
Possibilities:
|
||||
|
||||
"b" might be nice for binary output, and could even be supported for the
|
||||
standard C types too if desired.
|
||||
|
||||
POSIX style "%n$" parameter numbering would be possible, but would need
|
||||
to be handled completely within gmp_doprnt, since the numbering will be
|
||||
all different once the format string it cut into pieces.
|
||||
|
||||
Some options for mpq formatting would be good. Perhaps a non-zero
|
||||
precision field could give a width for the denominator and mean always
|
||||
put a "/". A form "n+p/q" might interesting too, though perhaps that's
|
||||
better left to applications.
|
||||
|
||||
Right now there's no way for an application to know whether types like
|
||||
intmax_t are supported here. If configure is doing its job and the same
|
||||
compiler is used for gmp as for the application then there shouldn't be
|
||||
any problem, but perhaps gmp.h should have some preprocessor symbols to
|
||||
say what libgmp can do. */
|
||||
|
||||
|
||||
|
||||
/* If a gmp format is the very first thing or there are two gmp formats with
|
||||
nothing in between then we'll reach here with this_fmt == last_fmt and we
|
||||
can do nothing in that case.
|
||||
|
||||
last_ap is always replaced after a FLUSH, so it doesn't matter if va_list
|
||||
is a call-by-reference and the funs->format routine modifies it. */
|
||||
|
||||
#define FLUSH() \
|
||||
do { \
|
||||
if (this_fmt == last_fmt) \
|
||||
{ \
|
||||
TRACE (printf ("nothing to flush\n")); \
|
||||
ASSERT (va_equal (this_ap, last_ap)); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ASSERT (*this_fmt == '%'); \
|
||||
*this_fmt = '\0'; \
|
||||
TRACE (printf ("flush \"%s\"\n", last_fmt)); \
|
||||
DOPRNT_FORMAT (last_fmt, last_ap); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Parse up the given format string and do the appropriate output using the
|
||||
given "funs" routines. The data parameter is passed through to those
|
||||
routines. */
|
||||
|
||||
int
|
||||
__gmp_doprnt (const struct doprnt_funs_t *funs, void *data,
|
||||
const char *orig_fmt, va_list orig_ap)
|
||||
{
|
||||
va_list ap, this_ap, last_ap;
|
||||
size_t alloc_fmt_size;
|
||||
char *fmt, *alloc_fmt, *last_fmt, *this_fmt, *gmp_str;
|
||||
int retval = 0;
|
||||
int type, fchar, *value, seen_precision;
|
||||
struct doprnt_params_t param;
|
||||
|
||||
TRACE (printf ("gmp_doprnt \"%s\"\n", orig_fmt));
|
||||
|
||||
/* Don't modify orig_ap, if va_list is actually an array and hence call by
|
||||
reference. It could be argued that it'd be more efficient to leave the
|
||||
caller to make a copy if it cared, but doing so here is going to be a
|
||||
very small part of the total work, and we may as well keep applications
|
||||
out of trouble. */
|
||||
va_copy (ap, orig_ap);
|
||||
|
||||
/* The format string is chopped up into pieces to be passed to
|
||||
funs->format. Unfortunately that means it has to be copied so each
|
||||
piece can be null-terminated. We're not going to be very fast here, so
|
||||
use __gmp_allocate_func rather than TMP_ALLOC, to avoid overflowing the
|
||||
stack if a long output string is given. */
|
||||
alloc_fmt_size = strlen (orig_fmt) + 1;
|
||||
#if _LONG_LONG_LIMB
|
||||
/* for a long long limb we change %Mx to %llx, so could need an extra 1
|
||||
char for every 3 existing */
|
||||
alloc_fmt_size += alloc_fmt_size / 3;
|
||||
#endif
|
||||
alloc_fmt = __GMP_ALLOCATE_FUNC_TYPE (alloc_fmt_size, char);
|
||||
fmt = alloc_fmt;
|
||||
strcpy (fmt, orig_fmt);
|
||||
|
||||
/* last_fmt and last_ap are just after the last output, and hence where
|
||||
the next output will begin, when that's done */
|
||||
last_fmt = fmt;
|
||||
va_copy (last_ap, ap);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
TRACE (printf ("next: \"%s\"\n", fmt));
|
||||
|
||||
fmt = strchr (fmt, '%');
|
||||
if (fmt == NULL)
|
||||
break;
|
||||
|
||||
/* this_fmt and this_ap are the current '%' sequence being considered */
|
||||
this_fmt = fmt;
|
||||
va_copy (this_ap, ap);
|
||||
fmt++; /* skip the '%' */
|
||||
|
||||
TRACE (printf ("considering\n");
|
||||
printf (" last: \"%s\"\n", last_fmt);
|
||||
printf (" this: \"%s\"\n", this_fmt));
|
||||
|
||||
type = '\0';
|
||||
value = ¶m.width;
|
||||
|
||||
param.base = 10;
|
||||
param.conv = 0;
|
||||
param.expfmt = "e%c%02d";
|
||||
param.exptimes4 = 0;
|
||||
param.fill = ' ';
|
||||
param.justify = DOPRNT_JUSTIFY_RIGHT;
|
||||
param.prec = 6;
|
||||
param.showbase = DOPRNT_SHOWBASE_NO;
|
||||
param.showpoint = 0;
|
||||
param.showtrailing = 1;
|
||||
param.sign = '\0';
|
||||
param.width = 0;
|
||||
seen_precision = 0;
|
||||
|
||||
/* This loop parses a single % sequence. "break" from the switch
|
||||
means continue with this %, "goto next" means the conversion
|
||||
character has been seen and a new % should be sought. */
|
||||
for (;;)
|
||||
{
|
||||
fchar = *fmt++;
|
||||
if (fchar == '\0')
|
||||
break;
|
||||
|
||||
switch (fchar) {
|
||||
|
||||
case 'a':
|
||||
/* %a behaves like %e, but defaults to all significant digits,
|
||||
and there's no leading zeros on the exponent (which is in
|
||||
fact bit-based) */
|
||||
param.base = 16;
|
||||
param.expfmt = "p%c%d";
|
||||
goto conv_a;
|
||||
case 'A':
|
||||
param.base = -16;
|
||||
param.expfmt = "P%c%d";
|
||||
conv_a:
|
||||
param.conv = DOPRNT_CONV_SCIENTIFIC;
|
||||
param.exptimes4 = 1;
|
||||
if (! seen_precision)
|
||||
param.prec = -1; /* default to all digits */
|
||||
param.showbase = DOPRNT_SHOWBASE_YES;
|
||||
param.showtrailing = 1;
|
||||
goto floating_a;
|
||||
|
||||
case 'c':
|
||||
/* Let's assume wchar_t will be promoted to "int" in the call,
|
||||
the same as char will be. */
|
||||
(void) va_arg (ap, int);
|
||||
goto next;
|
||||
|
||||
case 'd':
|
||||
case 'i':
|
||||
case 'u':
|
||||
integer:
|
||||
TRACE (printf ("integer, base=%d\n", param.base));
|
||||
if (! seen_precision)
|
||||
param.prec = -1;
|
||||
switch (type) {
|
||||
case 'j':
|
||||
/* Let's assume uintmax_t is the same size as intmax_t. */
|
||||
#if HAVE_INTMAX_T
|
||||
(void) va_arg (ap, intmax_t);
|
||||
#else
|
||||
ASSERT_FAIL (intmax_t not available);
|
||||
#endif
|
||||
break;
|
||||
case 'l':
|
||||
(void) va_arg (ap, long);
|
||||
break;
|
||||
case 'L':
|
||||
#if HAVE_LONG_LONG
|
||||
(void) va_arg (ap, long long);
|
||||
#else
|
||||
ASSERT_FAIL (long long not available);
|
||||
#endif
|
||||
break;
|
||||
case 'N':
|
||||
{
|
||||
mp_ptr xp;
|
||||
mp_size_t xsize, abs_xsize;
|
||||
mpz_t z;
|
||||
FLUSH ();
|
||||
xp = va_arg (ap, mp_ptr);
|
||||
PTR(z) = xp;
|
||||
xsize = (int) va_arg (ap, mp_size_t);
|
||||
abs_xsize = ABS (xsize);
|
||||
MPN_NORMALIZE (xp, abs_xsize);
|
||||
SIZ(z) = (xsize >= 0 ? abs_xsize : -abs_xsize);
|
||||
ASSERT_CODE (ALLOC(z) = abs_xsize);
|
||||
gmp_str = mpz_get_str (NULL, param.base, z);
|
||||
goto gmp_integer;
|
||||
}
|
||||
/* break; */
|
||||
case 'q':
|
||||
/* quad_t is probably the same as long long, but let's treat
|
||||
it separately just to be sure. Also let's assume u_quad_t
|
||||
will be the same size as quad_t. */
|
||||
#if HAVE_QUAD_T
|
||||
(void) va_arg (ap, quad_t);
|
||||
#else
|
||||
ASSERT_FAIL (quad_t not available);
|
||||
#endif
|
||||
break;
|
||||
case 'Q':
|
||||
FLUSH ();
|
||||
gmp_str = mpq_get_str (NULL, param.base, va_arg(ap, mpq_srcptr));
|
||||
goto gmp_integer;
|
||||
case 't':
|
||||
#if HAVE_PTRDIFF_T
|
||||
(void) va_arg (ap, ptrdiff_t);
|
||||
#else
|
||||
ASSERT_FAIL (ptrdiff_t not available);
|
||||
#endif
|
||||
break;
|
||||
case 'z':
|
||||
(void) va_arg (ap, size_t);
|
||||
break;
|
||||
case 'Z':
|
||||
{
|
||||
int ret;
|
||||
FLUSH ();
|
||||
gmp_str = mpz_get_str (NULL, param.base,
|
||||
va_arg (ap, mpz_srcptr));
|
||||
gmp_integer:
|
||||
ret = __gmp_doprnt_integer (funs, data, ¶m, gmp_str);
|
||||
(*__gmp_free_func) (gmp_str, strlen(gmp_str)+1);
|
||||
DOPRNT_ACCUMULATE (ret);
|
||||
va_copy (last_ap, ap);
|
||||
last_fmt = fmt;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* default is an "int", and this includes h=short and hh=char
|
||||
since they're promoted to int in a function call */
|
||||
(void) va_arg (ap, int);
|
||||
break;
|
||||
}
|
||||
goto next;
|
||||
|
||||
case 'E':
|
||||
param.base = -10;
|
||||
param.expfmt = "E%c%02d";
|
||||
/*FALLTHRU*/
|
||||
case 'e':
|
||||
param.conv = DOPRNT_CONV_SCIENTIFIC;
|
||||
floating:
|
||||
if (param.showbase == DOPRNT_SHOWBASE_NONZERO)
|
||||
{
|
||||
/* # in %e, %f and %g */
|
||||
param.showpoint = 1;
|
||||
param.showtrailing = 1;
|
||||
}
|
||||
floating_a:
|
||||
switch (type) {
|
||||
case 'F':
|
||||
FLUSH ();
|
||||
DOPRNT_ACCUMULATE (__gmp_doprnt_mpf (funs, data, ¶m,
|
||||
GMP_DECIMAL_POINT,
|
||||
va_arg (ap, mpf_srcptr)));
|
||||
va_copy (last_ap, ap);
|
||||
last_fmt = fmt;
|
||||
break;
|
||||
case 'L':
|
||||
#if HAVE_LONG_DOUBLE
|
||||
(void) va_arg (ap, long double);
|
||||
#else
|
||||
ASSERT_FAIL (long double not available);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
(void) va_arg (ap, double);
|
||||
break;
|
||||
}
|
||||
goto next;
|
||||
|
||||
case 'f':
|
||||
param.conv = DOPRNT_CONV_FIXED;
|
||||
goto floating;
|
||||
|
||||
case 'F': /* mpf_t */
|
||||
case 'j': /* intmax_t */
|
||||
case 'L': /* long long */
|
||||
case 'N': /* mpn */
|
||||
case 'q': /* quad_t */
|
||||
case 'Q': /* mpq_t */
|
||||
case 't': /* ptrdiff_t */
|
||||
case 'z': /* size_t */
|
||||
case 'Z': /* mpz_t */
|
||||
set_type:
|
||||
type = fchar;
|
||||
break;
|
||||
|
||||
case 'G':
|
||||
param.base = -10;
|
||||
param.expfmt = "E%c%02d";
|
||||
/*FALLTHRU*/
|
||||
case 'g':
|
||||
param.conv = DOPRNT_CONV_GENERAL;
|
||||
param.showtrailing = 0;
|
||||
goto floating;
|
||||
|
||||
case 'h':
|
||||
if (type != 'h')
|
||||
goto set_type;
|
||||
type = 'H'; /* internal code for "hh" */
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
if (type != 'l')
|
||||
goto set_type;
|
||||
type = 'L'; /* "ll" means "L" */
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
/* glibc strerror(errno), no argument */
|
||||
goto next;
|
||||
|
||||
case 'M': /* mp_limb_t */
|
||||
/* mung format string to l or ll and let plain printf handle it */
|
||||
#if _LONG_LONG_LIMB
|
||||
memmove (fmt+1, fmt, strlen (fmt)+1);
|
||||
fmt[-1] = 'l';
|
||||
fmt[0] = 'l';
|
||||
fmt++;
|
||||
type = 'L';
|
||||
#else
|
||||
fmt[-1] = 'l';
|
||||
type = 'l';
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
{
|
||||
void *p;
|
||||
FLUSH ();
|
||||
p = va_arg (ap, void *);
|
||||
switch (type) {
|
||||
case '\0': * (int *) p = retval; break;
|
||||
case 'F': mpf_set_si ((mpf_ptr) p, (long) retval); break;
|
||||
case 'H': * (char *) p = retval; break;
|
||||
case 'h': * (short *) p = retval; break;
|
||||
#if HAVE_INTMAX_T
|
||||
case 'j': * (intmax_t *) p = retval; break;
|
||||
#else
|
||||
case 'j': ASSERT_FAIL (intmax_t not available); break;
|
||||
#endif
|
||||
case 'l': * (long *) p = retval; break;
|
||||
#if HAVE_QUAD_T && HAVE_LONG_LONG
|
||||
case 'q':
|
||||
ASSERT_ALWAYS (sizeof (quad_t) == sizeof (long long));
|
||||
/*FALLTHRU*/
|
||||
#else
|
||||
case 'q': ASSERT_FAIL (quad_t not available); break;
|
||||
#endif
|
||||
#if HAVE_LONG_LONG
|
||||
case 'L': * (long long *) p = retval; break;
|
||||
#else
|
||||
case 'L': ASSERT_FAIL (long long not available); break;
|
||||
#endif
|
||||
case 'N':
|
||||
{
|
||||
mp_size_t n;
|
||||
n = va_arg (ap, mp_size_t);
|
||||
n = ABS (n);
|
||||
if (n != 0)
|
||||
{
|
||||
* (mp_ptr) p = retval;
|
||||
MPN_ZERO ((mp_ptr) p + 1, n - 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Q': mpq_set_si ((mpq_ptr) p, (long) retval, 1L); break;
|
||||
#if HAVE_PTRDIFF_T
|
||||
case 't': * (ptrdiff_t *) p = retval; break;
|
||||
#else
|
||||
case 't': ASSERT_FAIL (ptrdiff_t not available); break;
|
||||
#endif
|
||||
case 'z': * (size_t *) p = retval; break;
|
||||
case 'Z': mpz_set_si ((mpz_ptr) p, (long) retval); break;
|
||||
}
|
||||
}
|
||||
va_copy (last_ap, ap);
|
||||
last_fmt = fmt;
|
||||
goto next;
|
||||
|
||||
case 'o':
|
||||
param.base = 8;
|
||||
goto integer;
|
||||
|
||||
case 'p':
|
||||
case 's':
|
||||
/* "void *" will be good enough for "char *" or "wchar_t *", no
|
||||
need for separate code. */
|
||||
(void) va_arg (ap, const void *);
|
||||
goto next;
|
||||
|
||||
case 'x':
|
||||
param.base = 16;
|
||||
goto integer;
|
||||
case 'X':
|
||||
param.base = -16;
|
||||
goto integer;
|
||||
|
||||
case '%':
|
||||
goto next;
|
||||
|
||||
case '#':
|
||||
param.showbase = DOPRNT_SHOWBASE_NONZERO;
|
||||
break;
|
||||
|
||||
case '\'':
|
||||
/* glibc digit grouping, just pass it through, no support for it
|
||||
on gmp types */
|
||||
break;
|
||||
|
||||
case '+':
|
||||
case ' ':
|
||||
param.sign = fchar;
|
||||
break;
|
||||
|
||||
case '-':
|
||||
param.justify = DOPRNT_JUSTIFY_LEFT;
|
||||
break;
|
||||
case '.':
|
||||
seen_precision = 1;
|
||||
param.prec = -1; /* "." alone means all necessary digits */
|
||||
value = ¶m.prec;
|
||||
break;
|
||||
|
||||
case '*':
|
||||
{
|
||||
int n = va_arg (ap, int);
|
||||
|
||||
if (value == ¶m.width)
|
||||
{
|
||||
/* negative width means left justify */
|
||||
if (n < 0)
|
||||
{
|
||||
param.justify = DOPRNT_JUSTIFY_LEFT;
|
||||
n = -n;
|
||||
}
|
||||
param.width = n;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* don't allow negative precision */
|
||||
param.prec = MAX (0, n);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case '0':
|
||||
if (value == ¶m.width)
|
||||
{
|
||||
/* in width field, set fill */
|
||||
param.fill = '0';
|
||||
|
||||
/* for right justify, put the fill after any minus sign */
|
||||
if (param.justify == DOPRNT_JUSTIFY_RIGHT)
|
||||
param.justify = DOPRNT_JUSTIFY_INTERNAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* in precision field, set value */
|
||||
*value = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9':
|
||||
/* process all digits to form a value */
|
||||
{
|
||||
int n = 0;
|
||||
do {
|
||||
n = n * 10 + (fchar-'0');
|
||||
fchar = *fmt++;
|
||||
} while (isascii (fchar) && isdigit (fchar));
|
||||
fmt--; /* unget the non-digit */
|
||||
*value = n;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* something invalid */
|
||||
ASSERT (0);
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
|
||||
next:
|
||||
/* Stop parsing the current "%" format, look for a new one. */
|
||||
;
|
||||
}
|
||||
|
||||
TRACE (printf ("remainder: \"%s\"\n", last_fmt));
|
||||
if (*last_fmt != '\0')
|
||||
DOPRNT_FORMAT (last_fmt, last_ap);
|
||||
|
||||
if (funs->final != NULL)
|
||||
if ((*funs->final) (data) == -1)
|
||||
goto error;
|
||||
|
||||
done:
|
||||
(*__gmp_free_func) (alloc_fmt, alloc_fmt_size);
|
||||
return retval;
|
||||
|
||||
error:
|
||||
retval = -1;
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -1,385 +0,0 @@
|
|||
/* __gmp_doprnt_mpf -- mpf formatted output.
|
||||
|
||||
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
|
||||
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
|
||||
FUTURE GNU MP RELEASES.
|
||||
|
||||
Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h> /* for va_list and hence doprnt_funs_t */
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
/* change this to "#define TRACE(x) x" for diagnostics */
|
||||
#define TRACE(x)
|
||||
|
||||
|
||||
/* The separate of __gmp_doprnt_float_digits and __gmp_doprnt_float is so
|
||||
some C++ can do the mpf_get_str and release it in case of an exception */
|
||||
|
||||
#define DIGIT_VALUE(c) \
|
||||
(isdigit (c) ? (c) - '0' \
|
||||
: islower (c) ? (c) - 'a' + 10 \
|
||||
: (c) - 'A' + 10)
|
||||
|
||||
int
|
||||
__gmp_doprnt_mpf (const struct doprnt_funs_t *funs,
|
||||
void *data,
|
||||
const struct doprnt_params_t *p,
|
||||
const char *point,
|
||||
mpf_srcptr f)
|
||||
{
|
||||
int prec, ndigits, free_size, len, newlen, justify, justlen, explen;
|
||||
int showbaselen, sign, signlen, intlen, intzeros, pointlen;
|
||||
int fraczeros, fraclen, preczeros;
|
||||
char *s, *free_ptr;
|
||||
mp_exp_t exp;
|
||||
char exponent[BITS_PER_MP_LIMB + 10];
|
||||
const char *showbase;
|
||||
int retval = 0;
|
||||
|
||||
TRACE (printf ("__gmp_doprnt_float\n");
|
||||
printf (" conv=%d prec=%d\n", p->conv, p->prec));
|
||||
|
||||
prec = p->prec;
|
||||
if (prec <= -1)
|
||||
{
|
||||
/* all digits */
|
||||
ndigits = 0;
|
||||
|
||||
/* arrange the fixed/scientific decision on a "prec" implied by how
|
||||
many significant digits there are */
|
||||
if (p->conv == DOPRNT_CONV_GENERAL)
|
||||
MPF_SIGNIFICANT_DIGITS (prec, PREC(f), ABS(p->base));
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (p->conv) {
|
||||
case DOPRNT_CONV_FIXED:
|
||||
/* Precision is digits after the radix point. Try not to generate
|
||||
too many more than will actually be required. If f>=1 then
|
||||
overestimate the integer part, and add prec. If f<1 then
|
||||
underestimate the zeros between the radix point and the first
|
||||
digit and subtract that from prec. In either case add 2 so the
|
||||
round to nearest can be applied accurately. */
|
||||
ndigits = prec + 2
|
||||
+ EXP(f) * (__mp_bases[ABS(p->base)].chars_per_limb + (EXP(f)>=0));
|
||||
ndigits = MAX (ndigits, 1);
|
||||
break;
|
||||
|
||||
case DOPRNT_CONV_SCIENTIFIC:
|
||||
/* precision is digits after the radix point, and there's one digit
|
||||
before */
|
||||
ndigits = prec + 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT (0);
|
||||
/*FALLTHRU*/
|
||||
|
||||
case DOPRNT_CONV_GENERAL:
|
||||
/* precision is total digits, but be sure to ask mpf_get_str for at
|
||||
least 1, not 0 */
|
||||
ndigits = MAX (prec, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
TRACE (printf (" ndigits %d\n", ndigits));
|
||||
|
||||
s = mpf_get_str (NULL, &exp, p->base, ndigits, f);
|
||||
len = strlen (s);
|
||||
free_ptr = s;
|
||||
free_size = len + 1;
|
||||
TRACE (printf (" s %s\n", s);
|
||||
printf (" exp %ld\n", exp);
|
||||
printf (" len %d\n", len));
|
||||
|
||||
/* For fixed mode check the ndigits formed above was in fact enough for
|
||||
the integer part plus p->prec after the radix point. */
|
||||
ASSERT ((p->conv == DOPRNT_CONV_FIXED && p->prec > -1)
|
||||
? ndigits >= MAX (1, exp + p->prec + 2) : 1);
|
||||
|
||||
sign = p->sign;
|
||||
if (s[0] == '-')
|
||||
{
|
||||
sign = s[0];
|
||||
s++, len--;
|
||||
}
|
||||
signlen = (sign != '\0');
|
||||
TRACE (printf (" sign %c signlen %d\n", sign, signlen));
|
||||
|
||||
switch (p->conv) {
|
||||
case DOPRNT_CONV_FIXED:
|
||||
if (prec <= -1)
|
||||
prec = MAX (0, len-exp); /* retain all digits */
|
||||
|
||||
/* Truncate if necessary so fraction will be at most prec digits. */
|
||||
ASSERT (prec >= 0);
|
||||
newlen = exp + prec;
|
||||
if (newlen < 0)
|
||||
{
|
||||
/* first non-zero digit is below target prec, and at least one zero
|
||||
digit in between, so print zero */
|
||||
len = 0;
|
||||
exp = 0;
|
||||
}
|
||||
else if (len <= newlen)
|
||||
{
|
||||
/* already got few enough digits */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* discard excess digits and round to nearest */
|
||||
|
||||
const char *num_to_text = (p->base >= 0
|
||||
? "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||
: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
int base = ABS(p->base);
|
||||
int n;
|
||||
|
||||
ASSERT (base <= 36);
|
||||
|
||||
len = newlen;
|
||||
n = DIGIT_VALUE (s[len]);
|
||||
TRACE (printf (" rounding with %d\n", n));
|
||||
if (n >= (base + 1) / 2)
|
||||
{
|
||||
/* propagate a carry */
|
||||
for (;;)
|
||||
{
|
||||
if (len == 0)
|
||||
{
|
||||
s[0] = '1';
|
||||
len = 1;
|
||||
exp++;
|
||||
break;
|
||||
}
|
||||
n = DIGIT_VALUE (s[len-1]);
|
||||
ASSERT (n >= 0 && n < base);
|
||||
n++;
|
||||
if (n != base)
|
||||
{
|
||||
TRACE (printf (" storing now %d\n", n));
|
||||
s[len-1] = num_to_text[n];
|
||||
break;
|
||||
}
|
||||
len--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* truncate only, strip any trailing zeros now exposed */
|
||||
while (len > 0 && s[len-1] == '0')
|
||||
len--;
|
||||
}
|
||||
|
||||
/* Can have newlen==0, in which case the truncate was just to check
|
||||
for a carry turning it into "1". If we're left with len==0 then
|
||||
adjust exp to match. */
|
||||
if (len == 0)
|
||||
exp = 0;
|
||||
}
|
||||
|
||||
fixed:
|
||||
ASSERT (len == 0 ? exp == 0 : 1);
|
||||
if (exp <= 0)
|
||||
{
|
||||
TRACE (printf (" fixed 0.000sss\n"));
|
||||
intlen = 0;
|
||||
intzeros = 1;
|
||||
fraczeros = -exp;
|
||||
fraclen = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE (printf (" fixed sss.sss or sss000\n"));
|
||||
intlen = MIN (len, exp);
|
||||
intzeros = exp - intlen;
|
||||
fraczeros = 0;
|
||||
fraclen = len - intlen;
|
||||
}
|
||||
explen = 0;
|
||||
break;
|
||||
|
||||
case DOPRNT_CONV_SCIENTIFIC:
|
||||
{
|
||||
int expval;
|
||||
char expsign;
|
||||
|
||||
if (prec <= -1)
|
||||
prec = MAX (0, len-1); /* retain all digits */
|
||||
|
||||
scientific:
|
||||
TRACE (printf (" scientific s.sss\n"));
|
||||
|
||||
intlen = MIN (1, len);
|
||||
intzeros = (intlen == 0 ? 1 : 0);
|
||||
fraczeros = 0;
|
||||
fraclen = len - intlen;
|
||||
|
||||
expval = (exp-intlen);
|
||||
if (p->exptimes4)
|
||||
expval <<= 2;
|
||||
|
||||
/* Split out the sign since %o or %x in expfmt give negatives as twos
|
||||
complement, not with a sign. */
|
||||
expsign = (expval >= 0 ? '+' : '-');
|
||||
expval = ABS (expval);
|
||||
|
||||
#if HAVE_VSNPRINTF
|
||||
explen = snprintf (exponent, sizeof(exponent),
|
||||
p->expfmt, expsign, expval);
|
||||
/* test for < sizeof-1 since a glibc 2.0.x return of sizeof-1 might
|
||||
mean truncation */
|
||||
ASSERT (explen >= 0 && explen < sizeof(exponent)-1);
|
||||
#else
|
||||
sprintf (exponent, p->expfmt, expsign, expval);
|
||||
explen = strlen (exponent);
|
||||
ASSERT (explen < sizeof(exponent));
|
||||
#endif
|
||||
TRACE (printf (" expfmt %s gives %s\n", p->expfmt, exponent));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT (0);
|
||||
/*FALLTHRU*/ /* to stop variables looking uninitialized */
|
||||
|
||||
case DOPRNT_CONV_GENERAL:
|
||||
/* The exponent for "scientific" will be exp-1, choose scientific if
|
||||
this is < -4 or >= prec (and minimum 1 for prec). For f==0 will have
|
||||
exp==0 and get the desired "fixed". This rule follows glibc. For
|
||||
fixed there's no need to truncate, the desired ndigits will already
|
||||
be as required. */
|
||||
if (exp-1 < -4 || exp-1 >= MAX (1, prec))
|
||||
goto scientific;
|
||||
else
|
||||
goto fixed;
|
||||
}
|
||||
|
||||
TRACE (printf (" intlen %d intzeros %d fraczeros %d fraclen %d\n",
|
||||
intlen, intzeros, fraczeros, fraclen));
|
||||
ASSERT (p->prec <= -1
|
||||
? intlen + fraclen == strlen (s)
|
||||
: intlen + fraclen <= strlen (s));
|
||||
|
||||
if (p->showtrailing)
|
||||
{
|
||||
/* Pad to requested precision with trailing zeros, for general this is
|
||||
all digits, for fixed and scientific just the fraction. */
|
||||
preczeros = prec - (fraczeros + fraclen
|
||||
+ (p->conv == DOPRNT_CONV_GENERAL
|
||||
? intlen + intzeros : 0));
|
||||
preczeros = MAX (0, preczeros);
|
||||
}
|
||||
else
|
||||
preczeros = 0;
|
||||
TRACE (printf (" prec=%d showtrailing=%d, pad with preczeros %d\n",
|
||||
prec, p->showtrailing, preczeros));
|
||||
|
||||
/* radix point if needed, or if forced */
|
||||
pointlen = ((fraczeros + fraclen + preczeros) != 0 || p->showpoint != 0)
|
||||
? strlen (point) : 0;
|
||||
TRACE (printf (" point |%s| pointlen %d\n", point, pointlen));
|
||||
|
||||
/* Notice the test for a non-zero value is done after any truncation for
|
||||
DOPRNT_CONV_FIXED. */
|
||||
showbase = NULL;
|
||||
showbaselen = 0;
|
||||
switch (p->showbase) {
|
||||
default:
|
||||
ASSERT (0);
|
||||
/*FALLTHRU*/
|
||||
case DOPRNT_SHOWBASE_NO:
|
||||
break;
|
||||
case DOPRNT_SHOWBASE_NONZERO:
|
||||
if (intlen == 0 && fraclen == 0)
|
||||
break;
|
||||
/*FALLTHRU*/
|
||||
case DOPRNT_SHOWBASE_YES:
|
||||
switch (p->base) {
|
||||
case 16: showbase = "0x"; showbaselen = 2; break;
|
||||
case -16: showbase = "0X"; showbaselen = 2; break;
|
||||
case 8: showbase = "0"; showbaselen = 1; break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
TRACE (printf (" showbase %s showbaselen %d\n",
|
||||
showbase == NULL ? "" : showbase, showbaselen));
|
||||
|
||||
/* left over field width */
|
||||
justlen = p->width - (signlen + showbaselen + intlen + intzeros + pointlen
|
||||
+ fraczeros + fraclen + preczeros + explen);
|
||||
TRACE (printf (" justlen %d fill 0x%X\n", justlen, p->fill));
|
||||
|
||||
justify = p->justify;
|
||||
if (justlen <= 0) /* no justifying if exceed width */
|
||||
justify = DOPRNT_JUSTIFY_NONE;
|
||||
|
||||
TRACE (printf (" justify type %d intlen %d pointlen %d fraclen %d\n",
|
||||
justify, intlen, pointlen, fraclen));
|
||||
|
||||
if (justify == DOPRNT_JUSTIFY_RIGHT) /* pad for right */
|
||||
DOPRNT_REPS (p->fill, justlen);
|
||||
|
||||
if (signlen) /* sign */
|
||||
DOPRNT_REPS (sign, 1);
|
||||
|
||||
DOPRNT_MEMORY_MAYBE (showbase, showbaselen); /* base */
|
||||
|
||||
if (justify == DOPRNT_JUSTIFY_INTERNAL) /* pad for internal */
|
||||
DOPRNT_REPS (p->fill, justlen);
|
||||
|
||||
DOPRNT_MEMORY (s, intlen); /* integer */
|
||||
DOPRNT_REPS_MAYBE ('0', intzeros);
|
||||
|
||||
DOPRNT_MEMORY_MAYBE (point, pointlen); /* point */
|
||||
|
||||
DOPRNT_REPS_MAYBE ('0', fraczeros); /* frac */
|
||||
DOPRNT_MEMORY_MAYBE (s+intlen, fraclen);
|
||||
|
||||
DOPRNT_REPS_MAYBE ('0', preczeros); /* prec */
|
||||
|
||||
DOPRNT_MEMORY_MAYBE (exponent, explen); /* exp */
|
||||
|
||||
if (justify == DOPRNT_JUSTIFY_LEFT) /* pad for left */
|
||||
DOPRNT_REPS (p->fill, justlen);
|
||||
|
||||
done:
|
||||
(*__gmp_free_func) (free_ptr, free_size);
|
||||
return retval;
|
||||
|
||||
error:
|
||||
retval = -1;
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
/* __gmp_doprnt_integer -- integer style formatted output.
|
||||
|
||||
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
|
||||
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
|
||||
FUTURE GNU MP RELEASES.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h> /* for va_list and hence doprnt_funs_t */
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
__gmp_doprnt_integer (const struct doprnt_funs_t *funs,
|
||||
void *data,
|
||||
const struct doprnt_params_t *p,
|
||||
const char *s)
|
||||
{
|
||||
int retval = 0;
|
||||
int slen, justlen, showbaselen, sign, signlen, slashlen, zeros;
|
||||
int justify, den_showbaselen;
|
||||
const char *slash, *showbase;
|
||||
|
||||
/* '+' or ' ' if wanted, and don't already have '-' */
|
||||
sign = p->sign;
|
||||
if (s[0] == '-')
|
||||
{
|
||||
sign = s[0];
|
||||
s++;
|
||||
}
|
||||
signlen = (sign != '\0');
|
||||
|
||||
/* if the precision was explicitly 0, print nothing for a 0 value */
|
||||
if (*s == '0' && p->prec == 0)
|
||||
s++;
|
||||
|
||||
slen = strlen (s);
|
||||
slash = strchr (s, '/');
|
||||
|
||||
showbase = NULL;
|
||||
showbaselen = 0;
|
||||
|
||||
if (p->showbase != DOPRNT_SHOWBASE_NO)
|
||||
{
|
||||
switch (p->base) {
|
||||
case 16: showbase = "0x"; showbaselen = 2; break;
|
||||
case -16: showbase = "0X"; showbaselen = 2; break;
|
||||
case 8: showbase = "0"; showbaselen = 1; break;
|
||||
}
|
||||
}
|
||||
|
||||
den_showbaselen = showbaselen;
|
||||
if (slash == NULL
|
||||
|| (p->showbase == DOPRNT_SHOWBASE_NONZERO && slash[1] == '0'))
|
||||
den_showbaselen = 0;
|
||||
|
||||
if (p->showbase == DOPRNT_SHOWBASE_NONZERO && s[0] == '0')
|
||||
showbaselen = 0;
|
||||
|
||||
/* the influence of p->prec on mpq is currently undefined */
|
||||
zeros = MAX (0, p->prec - slen);
|
||||
|
||||
/* space left over after actual output length */
|
||||
justlen = p->width
|
||||
- (strlen(s) + signlen + showbaselen + den_showbaselen + zeros);
|
||||
|
||||
justify = p->justify;
|
||||
if (justlen <= 0) /* no justifying if exceed width */
|
||||
justify = DOPRNT_JUSTIFY_NONE;
|
||||
|
||||
if (justify == DOPRNT_JUSTIFY_RIGHT) /* pad right */
|
||||
DOPRNT_REPS (p->fill, justlen);
|
||||
|
||||
DOPRNT_REPS_MAYBE (sign, signlen); /* sign */
|
||||
|
||||
DOPRNT_MEMORY_MAYBE (showbase, showbaselen); /* base */
|
||||
|
||||
DOPRNT_REPS_MAYBE ('0', zeros); /* zeros */
|
||||
|
||||
if (justify == DOPRNT_JUSTIFY_INTERNAL) /* pad internal */
|
||||
DOPRNT_REPS (p->fill, justlen);
|
||||
|
||||
/* if there's a showbase on the denominator, then print the numerator
|
||||
separately so it can be inserted */
|
||||
if (den_showbaselen != 0)
|
||||
{
|
||||
ASSERT (slash != NULL);
|
||||
slashlen = slash+1 - s;
|
||||
DOPRNT_MEMORY (s, slashlen); /* numerator and slash */
|
||||
slen -= slashlen;
|
||||
s += slashlen;
|
||||
DOPRNT_MEMORY (showbase, den_showbaselen);
|
||||
}
|
||||
|
||||
DOPRNT_MEMORY (s, slen); /* number, or denominator */
|
||||
|
||||
if (justify == DOPRNT_JUSTIFY_LEFT) /* pad left */
|
||||
DOPRNT_REPS (p->fill, justlen);
|
||||
|
||||
done:
|
||||
return retval;
|
||||
|
||||
error:
|
||||
retval = -1;
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/* gmp_fprintf -- formatted output.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
#if HAVE_STDARG
|
||||
gmp_fprintf (FILE *fp, const char *fmt, ...)
|
||||
#else
|
||||
gmp_fprintf (va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
#if HAVE_STDARG
|
||||
va_start (ap, fmt);
|
||||
#else
|
||||
FILE *fp;
|
||||
const char *fmt;
|
||||
va_start (ap);
|
||||
fp = va_arg (ap, FILE *);
|
||||
fmt = va_arg (ap, const char *);
|
||||
#endif
|
||||
|
||||
ret = __gmp_doprnt (&__gmp_fprintf_funs, fp, fmt, ap);
|
||||
va_end (ap);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
/* gmp_obstack_printf -- formatted output to an obstack.
|
||||
|
||||
Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_OBSTACK_VPRINTF
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <obstack.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
#if HAVE_STDARG
|
||||
gmp_obstack_printf (struct obstack *ob, const char *fmt, ...)
|
||||
#else
|
||||
gmp_obstack_printf (va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
#if HAVE_STDARG
|
||||
va_start (ap, fmt);
|
||||
#else
|
||||
struct obstack *ob;
|
||||
const char *fmt;
|
||||
va_start (ap);
|
||||
ob = va_arg (ap, struct obstack *);
|
||||
fmt = va_arg (ap, const char *);
|
||||
#endif
|
||||
|
||||
ASSERT (! MEM_OVERLAP_P (obstack_base(ob), obstack_object_size(ob),
|
||||
fmt, strlen(fmt)+1));
|
||||
|
||||
ret = __gmp_doprnt (&__gmp_obstack_printf_funs, ob, fmt, ap);
|
||||
va_end (ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_OBSTACK_VPRINTF */
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
/* __gmp_obstack_printf_funs -- support for gmp_obstack_printf and
|
||||
gmp_obstack_vprintf.
|
||||
|
||||
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
|
||||
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
|
||||
FUTURE GNU MP RELEASES.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_OBSTACK_VPRINTF
|
||||
|
||||
#define _GNU_SOURCE /* ask glibc <stdio.h> for obstack_vprintf */
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h> /* for obstack_vprintf */
|
||||
#include <string.h>
|
||||
#include <obstack.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
static int
|
||||
gmp_obstack_memory (struct obstack *ob, const char *ptr, size_t len)
|
||||
{
|
||||
obstack_grow (ob, ptr, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
static int
|
||||
gmp_obstack_reps (struct obstack *ob, int c, int reps)
|
||||
{
|
||||
obstack_blank (ob, reps);
|
||||
memset ((char *) obstack_next_free(ob) - reps, c, reps);
|
||||
return reps;
|
||||
}
|
||||
|
||||
const struct doprnt_funs_t __gmp_obstack_printf_funs = {
|
||||
(doprnt_format_t) obstack_vprintf,
|
||||
(doprnt_memory_t) gmp_obstack_memory,
|
||||
(doprnt_reps_t) gmp_obstack_reps
|
||||
};
|
||||
|
||||
#endif /* HAVE_OBSTACK_VPRINTF */
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/* gmp_obstack_vprintf -- formatted output to an obstack.
|
||||
|
||||
Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_OBSTACK_VPRINTF
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <obstack.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
gmp_obstack_vprintf (struct obstack *ob, const char *fmt, va_list ap)
|
||||
{
|
||||
ASSERT (! MEM_OVERLAP_P (obstack_base(ob), obstack_object_size(ob),
|
||||
fmt, strlen(fmt)+1));
|
||||
|
||||
return __gmp_doprnt (&__gmp_obstack_printf_funs, ob, fmt, ap);
|
||||
}
|
||||
|
||||
#endif /* HAVE_OBSTACK_VPRINTF */
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/* gmp_printf -- formatted output.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
#if HAVE_STDARG
|
||||
gmp_printf (const char *fmt, ...)
|
||||
#else
|
||||
gmp_printf (va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
#if HAVE_STDARG
|
||||
va_start (ap, fmt);
|
||||
#else
|
||||
const char *fmt;
|
||||
va_start (ap);
|
||||
fmt = va_arg (ap, const char *);
|
||||
#endif
|
||||
|
||||
ret = __gmp_doprnt (&__gmp_fprintf_funs, stdout, fmt, ap);
|
||||
va_end (ap);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
/* __gmp_fprintf_funs -- support for formatted output to FILEs.
|
||||
|
||||
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
|
||||
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
|
||||
FUTURE GNU MP RELEASES.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
/* SunOS 4 stdio.h doesn't provide a prototype for this */
|
||||
#if ! HAVE_DECL_VFPRINTF
|
||||
int vfprintf _PROTO ((FILE *fp, const char *fmt, va_list ap));
|
||||
#endif
|
||||
|
||||
|
||||
static int
|
||||
gmp_fprintf_memory (FILE *fp, const char *str, size_t len)
|
||||
{
|
||||
return fwrite (str, 1, len, fp);
|
||||
}
|
||||
|
||||
/* glibc putc is a function, at least when it's in multi-threaded mode or
|
||||
some such, so fwrite chunks instead of making many calls. */
|
||||
static int
|
||||
gmp_fprintf_reps (FILE *fp, int c, int reps)
|
||||
{
|
||||
char buf[256];
|
||||
int i, piece, ret;
|
||||
ASSERT (reps >= 0);
|
||||
|
||||
memset (buf, c, MIN (reps, sizeof (buf)));
|
||||
for (i = reps; i > 0; i -= sizeof (buf))
|
||||
{
|
||||
piece = MIN (i, sizeof (buf));
|
||||
ret = fwrite (buf, 1, piece, fp);
|
||||
if (ret == -1)
|
||||
return ret;
|
||||
ASSERT (ret == piece);
|
||||
}
|
||||
|
||||
return reps;
|
||||
}
|
||||
|
||||
const struct doprnt_funs_t __gmp_fprintf_funs = {
|
||||
(doprnt_format_t) vfprintf,
|
||||
(doprnt_memory_t) gmp_fprintf_memory,
|
||||
(doprnt_reps_t) gmp_fprintf_reps,
|
||||
};
|
||||
|
|
@ -1,391 +0,0 @@
|
|||
/* __gmp_replacement_vsnprintf -- for systems which don't have vsnprintf, or
|
||||
only have a broken one.
|
||||
|
||||
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
|
||||
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
|
||||
FUTURE GNU MP RELEASES.
|
||||
|
||||
Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if ! HAVE_VSNPRINTF /* only need this file if we don't have vsnprintf */
|
||||
|
||||
|
||||
#define _GNU_SOURCE /* for strnlen prototype */
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h> /* for isdigit */
|
||||
#include <stddef.h> /* for ptrdiff_t */
|
||||
#include <string.h>
|
||||
#include <stdio.h> /* for NULL */
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_FLOAT_H
|
||||
#include <float.h> /* for DBL_MAX_10_EXP etc */
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h> /* for intmax_t */
|
||||
#else
|
||||
# if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h> /* for quad_t */
|
||||
#endif
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
/* Autoconf notes that AIX 4.3 has a broken strnlen, but fortunately it
|
||||
doesn't affect us since __gmp_replacement_vsnprintf is not required on
|
||||
that system. */
|
||||
#if ! HAVE_STRNLEN
|
||||
static size_t
|
||||
strnlen (const char *s, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < n; i++)
|
||||
if (s[i] == '\0')
|
||||
break;
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* The approach here is to parse the fmt string, and decide how much space
|
||||
it requires, then use vsprintf into a big enough buffer. The space
|
||||
calculated isn't an exact amount, but it's certainly no less than
|
||||
required.
|
||||
|
||||
This code was inspired by GNU libiberty/vasprintf.c but we support more
|
||||
datatypes, when available.
|
||||
|
||||
mingw32 - doesn't have vsnprintf, it seems. Because gcc is used a full
|
||||
set of types are available, but "long double" is just a plain IEEE
|
||||
64-bit "double" and LDBL_MAX_EXP_10 is correspondingly defined, so we
|
||||
avoid the big 15-bit exponent estimate. */
|
||||
|
||||
int
|
||||
__gmp_replacement_vsnprintf (char *buf, size_t buf_size,
|
||||
const char *orig_fmt, va_list orig_ap)
|
||||
{
|
||||
va_list ap;
|
||||
const char *fmt;
|
||||
size_t total_width, integer_sizeof, floating_sizeof, len;
|
||||
char fchar, type;
|
||||
int width, prec, seen_prec, double_digits, long_double_digits;
|
||||
int *value;
|
||||
|
||||
/* preserve orig_ap for use after size estimation */
|
||||
va_copy (ap, orig_ap);
|
||||
|
||||
fmt = orig_fmt;
|
||||
total_width = strlen (fmt) + 1; /* 1 extra for the '\0' */
|
||||
|
||||
integer_sizeof = sizeof (long);
|
||||
#if HAVE_LONG_LONG
|
||||
integer_sizeof = MAX (integer_sizeof, sizeof (long long));
|
||||
#endif
|
||||
#if HAVE_QUAD_T
|
||||
integer_sizeof = MAX (integer_sizeof, sizeof (quad_t));
|
||||
#endif
|
||||
|
||||
floating_sizeof = sizeof (double);
|
||||
#if HAVE_LONG_DOUBLE
|
||||
floating_sizeof = MAX (floating_sizeof, sizeof (long double));
|
||||
#endif
|
||||
|
||||
/* IEEE double or VAX G floats have an 11 bit exponent, so the default is
|
||||
a maximum 308 decimal digits. VAX D floats have only an 8 bit
|
||||
exponent, but we don't bother trying to detect that directly. */
|
||||
double_digits = 308;
|
||||
#ifdef DBL_MAX_10_EXP
|
||||
/* but in any case prefer a value the compiler says */
|
||||
double_digits = DBL_MAX_10_EXP;
|
||||
#endif
|
||||
|
||||
/* IEEE 128-bit quad, Intel 80-bit temporary, or VAX H floats all have 15
|
||||
bit exponents, so the default is a maximum 4932 decimal digits. */
|
||||
long_double_digits = 4932;
|
||||
/* but if double == long double, then go with that size */
|
||||
#if HAVE_LONG_DOUBLE
|
||||
if (sizeof (double) == sizeof (long double))
|
||||
long_double_digits = double_digits;
|
||||
#endif
|
||||
#ifdef LDBL_MAX_10_EXP
|
||||
/* but in any case prefer a value the compiler says */
|
||||
long_double_digits = LDBL_MAX_10_EXP;
|
||||
#endif
|
||||
|
||||
for (;;)
|
||||
{
|
||||
fmt = strchr (fmt, '%');
|
||||
if (fmt == NULL)
|
||||
break;
|
||||
fmt++;
|
||||
|
||||
type = '\0';
|
||||
width = 0;
|
||||
prec = 6;
|
||||
seen_prec = 0;
|
||||
value = &width;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
fchar = *fmt++;
|
||||
switch (fchar) {
|
||||
|
||||
case 'c':
|
||||
/* char, already accounted for by strlen(fmt) */
|
||||
goto next;
|
||||
|
||||
case 'd':
|
||||
case 'i':
|
||||
case 'o':
|
||||
case 'x':
|
||||
case 'X':
|
||||
case 'u':
|
||||
/* at most 3 digits per byte in hex, dec or octal, plus a sign */
|
||||
total_width += 3 * integer_sizeof + 1;
|
||||
|
||||
switch (type) {
|
||||
case 'j':
|
||||
/* Let's assume uintmax_t is the same size as intmax_t. */
|
||||
#if HAVE_INTMAX_T
|
||||
(void) va_arg (ap, intmax_t);
|
||||
#else
|
||||
ASSERT_FAIL (intmax_t not available);
|
||||
#endif
|
||||
break;
|
||||
case 'l':
|
||||
(void) va_arg (ap, long);
|
||||
break;
|
||||
case 'L':
|
||||
#if HAVE_LONG_LONG
|
||||
(void) va_arg (ap, long long);
|
||||
#else
|
||||
ASSERT_FAIL (long long not available);
|
||||
#endif
|
||||
break;
|
||||
case 'q':
|
||||
/* quad_t is probably the same as long long, but let's treat
|
||||
it separately just to be sure. Also let's assume u_quad_t
|
||||
will be the same size as quad_t. */
|
||||
#if HAVE_QUAD_T
|
||||
(void) va_arg (ap, quad_t);
|
||||
#else
|
||||
ASSERT_FAIL (quad_t not available);
|
||||
#endif
|
||||
break;
|
||||
case 't':
|
||||
#if HAVE_PTRDIFF_T
|
||||
(void) va_arg (ap, ptrdiff_t);
|
||||
#else
|
||||
ASSERT_FAIL (ptrdiff_t not available);
|
||||
#endif
|
||||
break;
|
||||
case 'z':
|
||||
(void) va_arg (ap, size_t);
|
||||
break;
|
||||
default:
|
||||
/* default is an "int", and this includes h=short and hh=char
|
||||
since they're promoted to int in a function call */
|
||||
(void) va_arg (ap, int);
|
||||
break;
|
||||
}
|
||||
goto next;
|
||||
|
||||
case 'E':
|
||||
case 'e':
|
||||
case 'G':
|
||||
case 'g':
|
||||
/* Requested decimals, sign, point and e, plus an overestimate
|
||||
of exponent digits (the assumption is all the float is
|
||||
exponent!). */
|
||||
total_width += prec + 3 + floating_sizeof * 3;
|
||||
if (type == 'L')
|
||||
{
|
||||
#if HAVE_LONG_DOUBLE
|
||||
(void) va_arg (ap, long double);
|
||||
#else
|
||||
ASSERT_FAIL (long double not available);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
(void) va_arg (ap, double);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
/* Requested decimals, sign and point, and a margin for error,
|
||||
then add the maximum digits that can be in the integer part,
|
||||
based on the maximum exponent value. */
|
||||
total_width += prec + 2 + 10;
|
||||
if (type == 'L')
|
||||
{
|
||||
#if HAVE_LONG_DOUBLE
|
||||
(void) va_arg (ap, long double);
|
||||
total_width += long_double_digits;
|
||||
#else
|
||||
ASSERT_FAIL (long double not available);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
(void) va_arg (ap, double);
|
||||
total_width += double_digits;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'h': /* short or char */
|
||||
case 'j': /* intmax_t */
|
||||
case 'L': /* long long or long double */
|
||||
case 'q': /* quad_t */
|
||||
case 't': /* ptrdiff_t */
|
||||
set_type:
|
||||
type = fchar;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
/* long or long long */
|
||||
if (type != 'l')
|
||||
goto set_type;
|
||||
type = 'L'; /* "ll" means "L" */
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
/* bytes written, no output as such */
|
||||
(void) va_arg (ap, void *);
|
||||
goto next;
|
||||
|
||||
case 's':
|
||||
/* If no precision was given, then determine the string length
|
||||
and put it there, to be added to the total under "next". If
|
||||
a precision was given then that's already the maximum from
|
||||
this field, but see whether the string is shorter than that,
|
||||
in case the limit was very big. */
|
||||
{
|
||||
const char *s = va_arg (ap, const char *);
|
||||
prec = (seen_prec ? strnlen (s, prec) : strlen (s));
|
||||
}
|
||||
goto next;
|
||||
|
||||
case 'p':
|
||||
/* pointer, let's assume at worst it's octal with some padding */
|
||||
(void) va_arg (ap, const void *);
|
||||
total_width += 3 * sizeof (void *) + 16;
|
||||
goto next;
|
||||
|
||||
case '%':
|
||||
/* literal %, already accounted for by strlen(fmt) */
|
||||
goto next;
|
||||
|
||||
case '#':
|
||||
/* showbase, at most 2 for "0x" */
|
||||
total_width += 2;
|
||||
break;
|
||||
|
||||
case '+':
|
||||
case ' ':
|
||||
/* sign, already accounted for under numerics */
|
||||
break;
|
||||
|
||||
case '-':
|
||||
/* left justify, no effect on total width */
|
||||
break;
|
||||
|
||||
case '.':
|
||||
seen_prec = 1;
|
||||
value = ≺
|
||||
break;
|
||||
|
||||
case '*':
|
||||
{
|
||||
/* negative width means left justify which can be ignored,
|
||||
negative prec would be invalid, just use absolute value */
|
||||
int n = va_arg (ap, int);
|
||||
*value = ABS (n);
|
||||
}
|
||||
break;
|
||||
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
/* process all digits to form a value */
|
||||
{
|
||||
int n = 0;
|
||||
do {
|
||||
n = n * 10 + (fchar-'0');
|
||||
fchar = *fmt++;
|
||||
} while (isascii (fchar) && isdigit (fchar));
|
||||
fmt--; /* unget the non-digit */
|
||||
*value = n;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* incomplete or invalid % sequence */
|
||||
ASSERT (0);
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
|
||||
next:
|
||||
total_width += width;
|
||||
total_width += prec;
|
||||
}
|
||||
|
||||
if (total_width <= buf_size)
|
||||
{
|
||||
vsprintf (buf, orig_fmt, orig_ap);
|
||||
len = strlen (buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = __GMP_ALLOCATE_FUNC_TYPE (total_width, char);
|
||||
vsprintf (s, orig_fmt, orig_ap);
|
||||
len = strlen (s);
|
||||
if (buf_size != 0)
|
||||
{
|
||||
size_t copylen = MIN (len, buf_size-1);
|
||||
memcpy (buf, s, copylen);
|
||||
buf[copylen] = '\0';
|
||||
}
|
||||
(*__gmp_free_func) (s, total_width);
|
||||
}
|
||||
|
||||
/* If total_width was somehow wrong then chances are we've already
|
||||
clobbered memory, but maybe this check will still work. */
|
||||
ASSERT_ALWAYS (len < total_width);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
#endif /* ! HAVE_VSNPRINTF */
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/* gmp_snprintf -- formatted output to an fixed size buffer.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <string.h> /* for strlen */
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
#if HAVE_STDARG
|
||||
gmp_snprintf (char *buf, size_t size, const char *fmt, ...)
|
||||
#else
|
||||
gmp_snprintf (va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
struct gmp_snprintf_t d;
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
#if HAVE_STDARG
|
||||
va_start (ap, fmt);
|
||||
d.buf = buf;
|
||||
d.size = size;
|
||||
|
||||
#else
|
||||
const char *fmt;
|
||||
va_start (ap);
|
||||
d.buf = va_arg (ap, char *);
|
||||
d.size = va_arg (ap, size_t);
|
||||
fmt = va_arg (ap, const char *);
|
||||
#endif
|
||||
|
||||
ASSERT (! MEM_OVERLAP_P (buf, size, fmt, strlen(fmt)+1));
|
||||
|
||||
ret = __gmp_doprnt (&__gmp_snprintf_funs, &d, fmt, ap);
|
||||
va_end (ap);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,158 +0,0 @@
|
|||
/* __gmp_snprintf_funs -- support for gmp_snprintf and gmp_vsnprintf.
|
||||
|
||||
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
|
||||
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
|
||||
FUTURE GNU MP RELEASES.
|
||||
|
||||
Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
#if ! HAVE_VSNPRINTF
|
||||
#define vsnprintf __gmp_replacement_vsnprintf
|
||||
#endif
|
||||
|
||||
|
||||
/* glibc 2.0.x vsnprintf returns either -1 or size-1 for an overflow, with
|
||||
no indication how big the output would have been. It's necessary to
|
||||
re-run to determine that size.
|
||||
|
||||
"size-1" would mean sucess from a C99 vsnprintf, and the re-run is
|
||||
unnecessary in this case, but we don't bother to try to detect what sort
|
||||
of vsnprintf we've got. size-1 should occur rarely in normal
|
||||
circumstances.
|
||||
|
||||
vsnprintf might trash it's given ap (it does for instance in glibc 2.1.3
|
||||
on powerpc), so copy it in case we need to use it to probe for the size
|
||||
output that would have been produced. Note there's no need to preserve
|
||||
it for our callers, just for ourselves. */
|
||||
|
||||
static int
|
||||
gmp_snprintf_format (struct gmp_snprintf_t *d, const char *fmt,
|
||||
va_list orig_ap)
|
||||
{
|
||||
int ret, step, alloc, avail;
|
||||
va_list ap;
|
||||
char *p;
|
||||
|
||||
ASSERT (d->size >= 0);
|
||||
|
||||
avail = d->size;
|
||||
if (avail > 1)
|
||||
{
|
||||
va_copy (ap, orig_ap);
|
||||
ret = vsnprintf (d->buf, avail, fmt, ap);
|
||||
if (ret == -1)
|
||||
{
|
||||
ASSERT (strlen (d->buf) == avail-1);
|
||||
ret = avail-1;
|
||||
}
|
||||
|
||||
step = MIN (ret, avail-1);
|
||||
d->size -= step;
|
||||
d->buf += step;
|
||||
|
||||
if (ret != avail-1)
|
||||
return ret;
|
||||
|
||||
/* probably glibc 2.0.x truncated output, probe for actual size */
|
||||
alloc = MAX (128, ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no space to write anything, just probe for size */
|
||||
alloc = 128;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
alloc *= 2;
|
||||
p = __GMP_ALLOCATE_FUNC_TYPE (alloc, char);
|
||||
va_copy (ap, orig_ap);
|
||||
ret = vsnprintf (p, alloc, fmt, ap);
|
||||
(*__gmp_free_func) (p, alloc);
|
||||
}
|
||||
while (ret == alloc-1 || ret == -1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
gmp_snprintf_memory (struct gmp_snprintf_t *d, const char *str, size_t len)
|
||||
{
|
||||
size_t n;
|
||||
|
||||
ASSERT (d->size >= 0);
|
||||
|
||||
if (d->size > 1)
|
||||
{
|
||||
n = MIN (d->size-1, len);
|
||||
memcpy (d->buf, str, n);
|
||||
d->buf += n;
|
||||
d->size -= n;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
static int
|
||||
gmp_snprintf_reps (struct gmp_snprintf_t *d, int c, int reps)
|
||||
{
|
||||
size_t n;
|
||||
|
||||
ASSERT (reps >= 0);
|
||||
ASSERT (d->size >= 0);
|
||||
|
||||
if (d->size > 1)
|
||||
{
|
||||
n = MIN (d->size-1, reps);
|
||||
memset (d->buf, c, n);
|
||||
d->buf += n;
|
||||
d->size -= n;
|
||||
}
|
||||
return reps;
|
||||
}
|
||||
|
||||
static int
|
||||
gmp_snprintf_final (struct gmp_snprintf_t *d)
|
||||
{
|
||||
if (d->size >= 1)
|
||||
d->buf[0] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct doprnt_funs_t __gmp_snprintf_funs = {
|
||||
(doprnt_format_t) gmp_snprintf_format,
|
||||
(doprnt_memory_t) gmp_snprintf_memory,
|
||||
(doprnt_reps_t) gmp_snprintf_reps,
|
||||
(doprnt_final_t) gmp_snprintf_final
|
||||
};
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/* gmp_sprintf -- formatted output to an unrestricted string.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <string.h> /* for strlen */
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
#if HAVE_STDARG
|
||||
gmp_sprintf (char *buf, const char *fmt, ...)
|
||||
#else
|
||||
gmp_sprintf (va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#if WANT_ASSERT
|
||||
int fmtlen = strlen(fmt);
|
||||
#endif
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
#if HAVE_STDARG
|
||||
va_start (ap, fmt);
|
||||
#else
|
||||
char *buf;
|
||||
const char *fmt;
|
||||
va_start (ap);
|
||||
buf = va_arg (ap, char *);
|
||||
fmt = va_arg (ap, const char *);
|
||||
#endif
|
||||
|
||||
ret = __gmp_doprnt (&__gmp_sprintf_funs, &buf, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
ASSERT (! MEM_OVERLAP_P (buf, strlen(buf)+1, fmt, fmtlen+1));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/* __gmp_sprintf_funs -- support for gmp_sprintf and gmp_vsprintf.
|
||||
|
||||
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
|
||||
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
|
||||
FUTURE GNU MP RELEASES.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
/* The data parameter "bufp" points to a "char *buf" which is the next
|
||||
character to be written, having started as the destination from the
|
||||
application. This is then increased each time output is produced. */
|
||||
|
||||
|
||||
/* If vsprintf returns -1 then pass it upwards. It doesn't matter that
|
||||
"*bufp" is ruined in this case, since gmp_doprint will bail out
|
||||
immediately anyway. */
|
||||
static int
|
||||
gmp_sprintf_format (char **bufp, const char *fmt, va_list ap)
|
||||
{
|
||||
char *buf = *bufp;
|
||||
int ret;
|
||||
vsprintf (buf, fmt, ap);
|
||||
ret = strlen (buf);
|
||||
*bufp = buf + ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
gmp_sprintf_memory (char **bufp, const char *str, size_t len)
|
||||
{
|
||||
char *buf = *bufp;
|
||||
*bufp = buf + len;
|
||||
memcpy (buf, str, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
static int
|
||||
gmp_sprintf_reps (char **bufp, int c, int reps)
|
||||
{
|
||||
char *buf = *bufp;
|
||||
ASSERT (reps >= 0);
|
||||
*bufp = buf + reps;
|
||||
memset (buf, c, reps);
|
||||
return reps;
|
||||
}
|
||||
|
||||
static int
|
||||
gmp_sprintf_final (char **bufp, int c, int reps)
|
||||
{
|
||||
char *buf = *bufp;
|
||||
*buf = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct doprnt_funs_t __gmp_sprintf_funs = {
|
||||
(doprnt_format_t) gmp_sprintf_format,
|
||||
(doprnt_memory_t) gmp_sprintf_memory,
|
||||
(doprnt_reps_t) gmp_sprintf_reps,
|
||||
(doprnt_final_t) gmp_sprintf_final
|
||||
};
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
/* gmp_vasprintf -- formatted output to an allocated space.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
#if ! HAVE_VSNPRINTF
|
||||
#define vsnprintf __gmp_replacement_vsnprintf
|
||||
#endif
|
||||
|
||||
|
||||
/* vasprintf isn't used since we prefer all GMP allocs to go through
|
||||
__gmp_allocate_func, and in particular we don't want the -1 return from
|
||||
vasprintf for out-of-memory, instead __gmp_allocate_func should handle
|
||||
that. Using vsnprintf unfortunately means we might have to re-run it if
|
||||
our current space is insufficient.
|
||||
|
||||
The initial guess for the needed space is an arbitrary 256 bytes. If
|
||||
that (and any extra GMP_ASPRINTF_T_NEED might give) isn't enough then an
|
||||
ISO C99 standard vsnprintf will tell us what we really need.
|
||||
|
||||
GLIBC 2.0.x vsnprintf returns either -1 or space-1 to indicate overflow,
|
||||
without giving any indication how much is really needed. In this case
|
||||
keep trying with double the space each time.
|
||||
|
||||
A return of space-1 is success on a C99 vsnprintf, but we're not
|
||||
bothering to identify which style vsnprintf we've got, so just take the
|
||||
pessimistic option and assume it's glibc 2.0.x.
|
||||
|
||||
Notice the use of ret+2 for the new space in the C99 case. This ensures
|
||||
the next vsnprintf return value will be space-2, which is unambiguously
|
||||
successful. But actually GMP_ASPRINTF_T_NEED() will realloc to even
|
||||
bigger than that ret+2.
|
||||
|
||||
vsnprintf might trash it's given ap, so copy it in case we need to use it
|
||||
more than once. See comments with gmp_snprintf_format. */
|
||||
|
||||
static int
|
||||
gmp_asprintf_format (struct gmp_asprintf_t *d, const char *fmt,
|
||||
va_list orig_ap)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
size_t space = 256;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
GMP_ASPRINTF_T_NEED (d, space);
|
||||
space = d->alloc - d->size;
|
||||
va_copy (ap, orig_ap);
|
||||
ret = vsnprintf (d->buf + d->size, space, fmt, ap);
|
||||
if (ret == -1)
|
||||
{
|
||||
ASSERT (strlen (d->buf + d->size) == space-1);
|
||||
ret = space-1;
|
||||
}
|
||||
|
||||
/* done if output fits in our space */
|
||||
if (ret < space-1)
|
||||
break;
|
||||
|
||||
if (ret == space-1)
|
||||
space *= 2; /* possible glibc 2.0.x, so double */
|
||||
else
|
||||
space = ret+2; /* C99, so now know space required */
|
||||
}
|
||||
|
||||
d->size += ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
const struct doprnt_funs_t __gmp_asprintf_funs = {
|
||||
(doprnt_format_t) gmp_asprintf_format,
|
||||
(doprnt_memory_t) __gmp_asprintf_memory,
|
||||
(doprnt_reps_t) __gmp_asprintf_reps,
|
||||
(doprnt_final_t) __gmp_asprintf_final
|
||||
};
|
||||
|
||||
int
|
||||
gmp_vasprintf (char **result, const char *fmt, va_list ap)
|
||||
{
|
||||
struct gmp_asprintf_t d;
|
||||
GMP_ASPRINTF_T_INIT (d, result);
|
||||
return __gmp_doprnt (&__gmp_asprintf_funs, &d, fmt, ap);
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/* gmp_vfprintf -- formatted output.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
gmp_vfprintf (FILE *fp, const char *fmt, va_list ap)
|
||||
{
|
||||
return __gmp_doprnt (&__gmp_fprintf_funs, fp, fmt, ap);
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/* gmp_vprintf -- formatted output.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
gmp_vprintf (const char *fmt, va_list ap)
|
||||
{
|
||||
return __gmp_doprnt (&__gmp_fprintf_funs, stdout, fmt, ap);
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/* gmp_vsnprintf -- formatted output to an fixed size buffer.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <string.h> /* for strlen */
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
gmp_vsnprintf (char *buf, size_t size, const char *fmt, va_list ap)
|
||||
{
|
||||
struct gmp_snprintf_t d;
|
||||
|
||||
ASSERT (! MEM_OVERLAP_P (buf, size, fmt, strlen(fmt)+1));
|
||||
|
||||
d.buf = buf;
|
||||
d.size = size;
|
||||
return __gmp_doprnt (&__gmp_snprintf_funs, &d, fmt, ap);
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/* gmp_vsprintf -- formatted output to an unrestricted string.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <string.h> /* for strlen */
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
gmp_vsprintf (char *buf, const char *fmt, va_list ap)
|
||||
{
|
||||
#if WANT_ASSERT
|
||||
int fmtlen = strlen(fmt);
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
ret = __gmp_doprnt (&__gmp_sprintf_funs, &buf, fmt, ap);
|
||||
|
||||
ASSERT (! MEM_OVERLAP_P (buf, strlen(buf)+1, fmt, fmtlen+1));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
## Process this file with automake to generate Makefile.in
|
||||
|
||||
# Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of the GNU MP Library.
|
||||
#
|
||||
# The GNU MP Library 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 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
# License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301, USA.
|
||||
|
||||
|
||||
INCLUDES = -D__GMP_WITHIN_GMP -I$(top_srcdir)
|
||||
|
||||
noinst_LTLIBRARIES = libscanf.la
|
||||
|
||||
libscanf_la_SOURCES = \
|
||||
doscan.c fscanf.c fscanffuns.c scanf.c sscanf.c sscanffuns.c \
|
||||
vfscanf.c vscanf.c vsscanf.c
|
||||
|
|
@ -1,501 +0,0 @@
|
|||
# Makefile.in generated by automake 1.9.6 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005 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@
|
||||
|
||||
# Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of the GNU MP Library.
|
||||
#
|
||||
# The GNU MP Library 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 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
# License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301, USA.
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
top_builddir = ..
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
INSTALL = @INSTALL@
|
||||
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@
|
||||
ANSI2KNR = $(top_builddir)/ansi2knr
|
||||
LIBOBJDIR =
|
||||
subdir = scanf
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
|
||||
$(top_srcdir)/configure.in
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
libscanf_la_LIBADD =
|
||||
am_libscanf_la_OBJECTS = doscan$U.lo fscanf$U.lo fscanffuns$U.lo \
|
||||
scanf$U.lo sscanf$U.lo sscanffuns$U.lo vfscanf$U.lo \
|
||||
vscanf$U.lo vsscanf$U.lo
|
||||
libscanf_la_OBJECTS = $(am_libscanf_la_OBJECTS)
|
||||
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
|
||||
depcomp =
|
||||
am__depfiles_maybe =
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
SOURCES = $(libscanf_la_SOURCES)
|
||||
DIST_SOURCES = $(libscanf_la_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ABI = @ABI@
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
BITS_PER_MP_LIMB = @BITS_PER_MP_LIMB@
|
||||
CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@
|
||||
CC = @CC@
|
||||
CCAS = @CCAS@
|
||||
CC_FOR_BUILD = @CC_FOR_BUILD@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CPP_FOR_BUILD = @CPP_FOR_BUILD@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFN_LONG_LONG_LIMB = @DEFN_LONG_LONG_LIMB@
|
||||
DEFS = @DEFS@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
ENABLE_STATIC_FALSE = @ENABLE_STATIC_FALSE@
|
||||
ENABLE_STATIC_TRUE = @ENABLE_STATIC_TRUE@
|
||||
EXEEXT = @EXEEXT@
|
||||
EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
|
||||
FGREP = @FGREP@
|
||||
GMP_LDFLAGS = @GMP_LDFLAGS@
|
||||
GMP_NAIL_BITS = @GMP_NAIL_BITS@
|
||||
GREP = @GREP@
|
||||
HAVE_HOST_CPU_FAMILY_power = @HAVE_HOST_CPU_FAMILY_power@
|
||||
HAVE_HOST_CPU_FAMILY_powerpc = @HAVE_HOST_CPU_FAMILY_powerpc@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBGMPXX_LDFLAGS = @LIBGMPXX_LDFLAGS@
|
||||
LIBGMP_DLL = @LIBGMP_DLL@
|
||||
LIBGMP_LDFLAGS = @LIBGMP_LDFLAGS@
|
||||
LIBM = @LIBM@
|
||||
LIBM_FOR_BUILD = @LIBM_FOR_BUILD@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
M4 = @M4@
|
||||
MAINT = @MAINT@
|
||||
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
|
||||
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
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@
|
||||
SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@
|
||||
STRIP = @STRIP@
|
||||
TAL_OBJECT = @TAL_OBJECT@
|
||||
TUNE_SQR_OBJ = @TUNE_SQR_OBJ@
|
||||
U = @U@
|
||||
U_FOR_BUILD = @U_FOR_BUILD@
|
||||
VERSION = @VERSION@
|
||||
WANT_CXX_FALSE = @WANT_CXX_FALSE@
|
||||
WANT_CXX_TRUE = @WANT_CXX_TRUE@
|
||||
WANT_MPBSD_FALSE = @WANT_MPBSD_FALSE@
|
||||
WANT_MPBSD_TRUE = @WANT_MPBSD_TRUE@
|
||||
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__leading_dot = @am__leading_dot@
|
||||
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@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
gmp_srclinks = @gmp_srclinks@
|
||||
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@
|
||||
mpn_objects = @mpn_objects@
|
||||
mpn_objs_in_libgmp = @mpn_objs_in_libgmp@
|
||||
mpn_objs_in_libmp = @mpn_objs_in_libmp@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
INCLUDES = -D__GMP_WITHIN_GMP -I$(top_srcdir)
|
||||
noinst_LTLIBRARIES = libscanf.la
|
||||
libscanf_la_SOURCES = \
|
||||
doscan.c fscanf.c fscanffuns.c scanf.c sscanf.c sscanffuns.c \
|
||||
vfscanf.c vscanf.c vsscanf.c
|
||||
|
||||
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 \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps scanf/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu --ignore-deps scanf/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: @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
|
||||
|
||||
clean-noinstLTLIBRARIES:
|
||||
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
|
||||
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
|
||||
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||
test "$$dir" != "$$p" || dir=.; \
|
||||
echo "rm -f \"$${dir}/so_locations\""; \
|
||||
rm -f "$${dir}/so_locations"; \
|
||||
done
|
||||
libscanf.la: $(libscanf_la_OBJECTS) $(libscanf_la_DEPENDENCIES)
|
||||
$(LINK) $(libscanf_la_LDFLAGS) $(libscanf_la_OBJECTS) $(libscanf_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
$(top_builddir)/ansi2knr:
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) ansi2knr
|
||||
|
||||
mostlyclean-kr:
|
||||
-test "$U" = "" || rm -f *_.c
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
$(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
$(LTCOMPILE) -c -o $@ $<
|
||||
doscan_.c: doscan.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/doscan.c; then echo $(srcdir)/doscan.c; else echo doscan.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
fscanf_.c: fscanf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/fscanf.c; then echo $(srcdir)/fscanf.c; else echo fscanf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
fscanffuns_.c: fscanffuns.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/fscanffuns.c; then echo $(srcdir)/fscanffuns.c; else echo fscanffuns.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
scanf_.c: scanf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/scanf.c; then echo $(srcdir)/scanf.c; else echo scanf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
sscanf_.c: sscanf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/sscanf.c; then echo $(srcdir)/sscanf.c; else echo sscanf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
sscanffuns_.c: sscanffuns.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/sscanffuns.c; then echo $(srcdir)/sscanffuns.c; else echo sscanffuns.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
vfscanf_.c: vfscanf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/vfscanf.c; then echo $(srcdir)/vfscanf.c; else echo vfscanf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
vscanf_.c: vscanf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/vscanf.c; then echo $(srcdir)/vscanf.c; else echo vscanf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
vsscanf_.c: vsscanf.c $(ANSI2KNR)
|
||||
$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/vsscanf.c; then echo $(srcdir)/vsscanf.c; else echo vsscanf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
|
||||
doscan_.$(OBJEXT) doscan_.lo fscanf_.$(OBJEXT) fscanf_.lo \
|
||||
fscanffuns_.$(OBJEXT) fscanffuns_.lo scanf_.$(OBJEXT) scanf_.lo \
|
||||
sscanf_.$(OBJEXT) sscanf_.lo sscanffuns_.$(OBJEXT) sscanffuns_.lo \
|
||||
vfscanf_.$(OBJEXT) vfscanf_.lo vscanf_.$(OBJEXT) vscanf_.lo \
|
||||
vsscanf_.$(OBJEXT) vsscanf_.lo : $(ANSI2KNR)
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool config.lt
|
||||
uninstall-info-am:
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$tags $$unique; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& cd $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) $$here
|
||||
|
||||
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)'; for file in $$list; do \
|
||||
case $$file in \
|
||||
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
|
||||
esac; \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
|
||||
dir="/$$dir"; \
|
||||
$(mkdir_p) "$(distdir)$$dir"; \
|
||||
else \
|
||||
dir=''; \
|
||||
fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
fi; \
|
||||
cp -pR $$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 $(LTLIBRARIES)
|
||||
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:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_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-noinstLTLIBRARIES \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-man:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-info-am
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-noinstLTLIBRARIES ctags 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-exec \
|
||||
install-exec-am install-info install-info-am install-man \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-compile mostlyclean-generic mostlyclean-kr \
|
||||
mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
|
||||
uninstall-am uninstall-info-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:
|
||||
|
|
@ -1,764 +0,0 @@
|
|||
/* __gmp_doscan -- formatted input internals.
|
||||
|
||||
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
|
||||
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
|
||||
FUTURE GNU MP RELEASES.
|
||||
|
||||
Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#define _GNU_SOURCE /* for DECIMAL_POINT in langinfo.h */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stddef.h> /* for ptrdiff_t */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* for strtol */
|
||||
#include <string.h>
|
||||
|
||||
#if HAVE_LANGINFO_H
|
||||
#include <langinfo.h> /* for nl_langinfo */
|
||||
#endif
|
||||
|
||||
#if HAVE_LOCALE_H
|
||||
#include <locale.h> /* for localeconv */
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h> /* for intmax_t */
|
||||
#else
|
||||
# if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h> /* for quad_t */
|
||||
#endif
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
/* Change this to "#define TRACE(x) x" for some traces. */
|
||||
#define TRACE(x)
|
||||
|
||||
|
||||
/* General:
|
||||
|
||||
It's necessary to parse up the format string to recognise the GMP
|
||||
extra types F, Q and Z. Other types and conversions are passed
|
||||
across to the standard sscanf or fscanf via funs->scan, for ease of
|
||||
implemenation. This is essential in the case of something like glibc
|
||||
%p where the pointer format isn't actually documented.
|
||||
|
||||
Because funs->scan doesn't get the whole input it can't put the right
|
||||
values in for %n, so that's handled in __gmp_doscan. Neither sscanf
|
||||
nor fscanf directly indicate how many characters were read, so an
|
||||
extra %n is appended to each run for that. For fscanf this merely
|
||||
supports our %n output, but for sscanf it lets funs->step move us
|
||||
along the input string.
|
||||
|
||||
Whitespace and literal matches in the format string, including %%,
|
||||
are handled directly within __gmp_doscan. This is reasonably
|
||||
efficient, and avoids some suspicious behaviour observed in various
|
||||
system libc's. GLIBC 2.2.4 for instance returns 0 on
|
||||
|
||||
sscanf(" ", " x")
|
||||
or
|
||||
sscanf(" ", " x%d",&n)
|
||||
|
||||
whereas we think they should return EOF, since end-of-string is
|
||||
reached when a match of "x" is required.
|
||||
|
||||
For standard % conversions, funs->scan is called once for each
|
||||
conversion. If we had vfscanf and vsscanf and could rely on their
|
||||
fixed text matching behaviour then we could call them with multiple
|
||||
consecutive standard conversions. But plain fscanf and sscanf work
|
||||
fine, and parsing one field at a time shouldn't be too much of a
|
||||
slowdown.
|
||||
|
||||
gmpscan:
|
||||
|
||||
gmpscan reads a gmp type. It's only used from one place, but is a
|
||||
separate subroutine to avoid a big chunk of complicated code in the
|
||||
middle of __gmp_doscan. Within gmpscan a couple of loopbacks make it
|
||||
possible to share code for parsing integers, rationals and floats.
|
||||
|
||||
In gmpscan normally one char of lookahead is maintained, but when width
|
||||
is reached that stops, on the principle that an fgetc/ungetc of a char
|
||||
past where we're told to stop would be undesirable. "chars" is how many
|
||||
characters have been read so far, including the current c. When
|
||||
chars==width and another character is desired then a jump is done to the
|
||||
"convert" stage. c is invalid and mustn't be unget'ed in this case;
|
||||
chars is set to width+1 to indicate that.
|
||||
|
||||
gmpscan normally returns the number of characters read. -1 means an
|
||||
invalid field, -2 means EOF reached before any matching characters
|
||||
were read.
|
||||
|
||||
For hex floats, the mantissa part is passed to mpf_set_str, then the
|
||||
exponent is applied with mpf_mul_exp or mpf_div_2exp. This is easier
|
||||
than teaching mpf_set_str about an exponent factor (ie. 2) differing
|
||||
from the mantissa radix point factor (ie. 16). mpf_mul_exp and
|
||||
mpf_div_2exp will preserve the application requested precision, so
|
||||
nothing in that respect is lost by making this a two-step process.
|
||||
|
||||
Matching and errors:
|
||||
|
||||
C99 7.19.6.2 paras 9 and 10 say an input item is read as the longest
|
||||
string which is a match for the appropriate type, or a prefix of a
|
||||
match. With that done, if it's only a prefix then the result is a
|
||||
matching failure, ie. invalid input.
|
||||
|
||||
This rule seems fairly clear, but doesn't seem to be universally
|
||||
applied in system C libraries. Even GLIBC doesn't seem to get it
|
||||
right, insofar as it seems to accept some apparently invalid forms.
|
||||
Eg. glibc 2.3.1 accepts "0x" for a "%i", where a reading of the
|
||||
standard would suggest a non-empty sequence of digits should be
|
||||
required after an "0x".
|
||||
|
||||
A footnote to 7.19.6.2 para 17 notes how this input item reading can
|
||||
mean inputs acceptable to strtol are not acceptable to fscanf. We
|
||||
think this confirms our reading of "0x" as invalid.
|
||||
|
||||
Clearly gmp_sscanf could backtrack to a longest input which was a
|
||||
valid match for a given item, but this is not done, since C99 says
|
||||
sscanf is identical to fscanf, so we make gmp_sscanf identical to
|
||||
gmp_fscanf.
|
||||
|
||||
Types:
|
||||
|
||||
C99 says "ll" is for long long, and "L" is for long double floats.
|
||||
Unfortunately in GMP 4.1.1 we documented the two as equivalent. This
|
||||
doesn't affect us directly, since both are passed through to plain
|
||||
scanf. It seems wisest not to try to enforce the C99 rule. This is
|
||||
consistent with what we said before, though whether it actually
|
||||
worked was always up to the C library.
|
||||
|
||||
Alternatives:
|
||||
|
||||
Consideration was given to using separate code for gmp_fscanf and
|
||||
gmp_sscanf. The sscanf case could zip across a string doing literal
|
||||
matches or recognising digits in gmpscan, rather than making a
|
||||
function call fun->get per character. The fscanf could use getc
|
||||
rather than fgetc too, which might help those systems where getc is a
|
||||
macro or otherwise inlined. But none of this scanning and converting
|
||||
will be particularly fast, so the two are done together to keep it a
|
||||
little simpler for now.
|
||||
|
||||
Various multibyte string issues are not addressed, for a start C99
|
||||
scanf says the format string is multibyte. Since we pass %c, %s and
|
||||
%[ to the system scanf, they might do multibyte reads already, but
|
||||
it's another matter whether or not that can be used, since our digit
|
||||
and whitespace parsing is only unibyte. The plan is to quietly
|
||||
ignore multibyte locales for now. This is not as bad as it sounds,
|
||||
since GMP is presumably used mostly on numbers, which can be
|
||||
perfectly adequately treated in plain ASCII.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
struct gmp_doscan_params_t {
|
||||
int base;
|
||||
int ignore;
|
||||
char type;
|
||||
int width;
|
||||
};
|
||||
|
||||
|
||||
#define GET(c) \
|
||||
do { \
|
||||
ASSERT (chars <= width); \
|
||||
chars++; \
|
||||
if (chars > width) \
|
||||
goto convert; \
|
||||
(c) = (*funs->get) (data); \
|
||||
} while (0)
|
||||
|
||||
/* store into "s", extending if necessary */
|
||||
#define STORE(c) \
|
||||
do { \
|
||||
ASSERT (s_upto <= s_alloc); \
|
||||
if (s_upto >= s_alloc) \
|
||||
{ \
|
||||
size_t s_alloc_new = s_alloc + S_ALLOC_STEP; \
|
||||
s = __GMP_REALLOCATE_FUNC_TYPE (s, s_alloc, s_alloc_new, char); \
|
||||
s_alloc = s_alloc_new; \
|
||||
} \
|
||||
s[s_upto++] = c; \
|
||||
} while (0)
|
||||
|
||||
#define S_ALLOC_STEP 512
|
||||
|
||||
static int
|
||||
gmpscan (const struct gmp_doscan_funs_t *funs, void *data,
|
||||
const struct gmp_doscan_params_t *p, void *dst)
|
||||
{
|
||||
int chars, c, base, first, width, seen_point, seen_digit, hexfloat;
|
||||
size_t s_upto, s_alloc, hexexp;
|
||||
char *s;
|
||||
int invalid = 0;
|
||||
|
||||
TRACE (printf ("gmpscan\n"));
|
||||
|
||||
ASSERT (p->type == 'F' || p->type == 'Q' || p->type == 'Z');
|
||||
|
||||
c = (*funs->get) (data);
|
||||
if (c == EOF)
|
||||
return -2;
|
||||
|
||||
chars = 1;
|
||||
first = 1;
|
||||
seen_point = 0;
|
||||
width = (p->width == 0 ? INT_MAX-1 : p->width);
|
||||
base = p->base;
|
||||
s_alloc = S_ALLOC_STEP;
|
||||
s = __GMP_ALLOCATE_FUNC_TYPE (s_alloc, char);
|
||||
s_upto = 0;
|
||||
hexfloat = 0;
|
||||
hexexp = 0;
|
||||
|
||||
another:
|
||||
seen_digit = 0;
|
||||
if (c == '-')
|
||||
{
|
||||
STORE (c);
|
||||
goto get_for_sign;
|
||||
}
|
||||
else if (c == '+')
|
||||
{
|
||||
/* don't store '+', it's not accepted by mpz_set_str etc */
|
||||
get_for_sign:
|
||||
GET (c);
|
||||
}
|
||||
|
||||
if (base == 0)
|
||||
{
|
||||
base = 10; /* decimal if no base indicator */
|
||||
if (c == '0')
|
||||
{
|
||||
seen_digit = 1; /* 0 alone is a valid number */
|
||||
if (p->type != 'F')
|
||||
base = 8; /* leading 0 is octal, for non-floats */
|
||||
STORE (c);
|
||||
GET (c);
|
||||
if (c == 'x' || c == 'X')
|
||||
{
|
||||
base = 16;
|
||||
seen_digit = 0; /* must have digits after an 0x */
|
||||
if (p->type == 'F') /* don't pass 'x' to mpf_set_str_point */
|
||||
hexfloat = 1;
|
||||
else
|
||||
STORE (c);
|
||||
GET (c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
digits:
|
||||
for (;;)
|
||||
{
|
||||
if (base == 16)
|
||||
{
|
||||
if (! isxdigit (c))
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! isdigit (c))
|
||||
break;
|
||||
if (base == 8 && (c == '8' || c == '9'))
|
||||
break;
|
||||
}
|
||||
|
||||
seen_digit = 1;
|
||||
STORE (c);
|
||||
GET (c);
|
||||
}
|
||||
|
||||
if (first)
|
||||
{
|
||||
/* decimal point */
|
||||
if (p->type == 'F' && ! seen_point)
|
||||
{
|
||||
/* For a multi-character decimal point, if the first character is
|
||||
present then all of it must be, otherwise the input is
|
||||
considered invalid. */
|
||||
const char *point = GMP_DECIMAL_POINT;
|
||||
int pc = (unsigned char) *point++;
|
||||
if (c == pc)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
STORE (c);
|
||||
GET (c);
|
||||
pc = (unsigned char) *point++;
|
||||
if (pc == '\0')
|
||||
break;
|
||||
if (c != pc)
|
||||
goto set_invalid;
|
||||
}
|
||||
seen_point = 1;
|
||||
goto digits;
|
||||
}
|
||||
}
|
||||
|
||||
/* exponent */
|
||||
if (p->type == 'F')
|
||||
{
|
||||
if (hexfloat && (c == 'p' || c == 'P'))
|
||||
{
|
||||
hexexp = s_upto; /* exponent location */
|
||||
base = 10; /* exponent in decimal */
|
||||
goto exponent;
|
||||
}
|
||||
else if (! hexfloat && (c == 'e' || c == 'E'))
|
||||
{
|
||||
exponent:
|
||||
/* must have at least one digit in the mantissa, just an exponent
|
||||
is not good enough */
|
||||
if (! seen_digit)
|
||||
goto set_invalid;
|
||||
|
||||
do_second:
|
||||
first = 0;
|
||||
STORE (c);
|
||||
GET (c);
|
||||
goto another;
|
||||
}
|
||||
}
|
||||
|
||||
/* denominator */
|
||||
if (p->type == 'Q' && c == '/')
|
||||
{
|
||||
/* must have at least one digit in the numerator */
|
||||
if (! seen_digit)
|
||||
goto set_invalid;
|
||||
|
||||
/* now look for at least one digit in the denominator */
|
||||
seen_digit = 0;
|
||||
|
||||
/* allow the base to be redetermined for "%i" */
|
||||
base = p->base;
|
||||
goto do_second;
|
||||
}
|
||||
}
|
||||
|
||||
convert:
|
||||
if (! seen_digit)
|
||||
{
|
||||
set_invalid:
|
||||
invalid = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (! p->ignore)
|
||||
{
|
||||
STORE ('\0');
|
||||
TRACE (printf (" convert \"%s\"\n", s));
|
||||
|
||||
/* We ought to have parsed out a valid string above, so just test
|
||||
mpz_set_str etc with an ASSERT. */
|
||||
switch (p->type) {
|
||||
case 'F':
|
||||
{
|
||||
mpf_ptr f = (mpf_ptr) dst;
|
||||
if (hexexp != 0)
|
||||
s[hexexp] = '\0';
|
||||
ASSERT_NOCARRY (mpf_set_str (f, s, hexfloat ? 16 : 10));
|
||||
if (hexexp != 0)
|
||||
{
|
||||
char *dummy;
|
||||
long exp;
|
||||
exp = strtol (s + hexexp + 1, &dummy, 10);
|
||||
if (exp >= 0)
|
||||
mpf_mul_2exp (f, f, (unsigned long) exp);
|
||||
else
|
||||
mpf_div_2exp (f, f, - (unsigned long) exp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Q':
|
||||
ASSERT_NOCARRY (mpq_set_str ((mpq_ptr) dst, s, p->base));
|
||||
break;
|
||||
case 'Z':
|
||||
ASSERT_NOCARRY (mpz_set_str ((mpz_ptr) dst, s, p->base));
|
||||
break;
|
||||
default:
|
||||
ASSERT (0);
|
||||
/*FALLTHRU*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
ASSERT (chars <= width+1);
|
||||
if (chars != width+1)
|
||||
{
|
||||
(*funs->unget) (c, data);
|
||||
TRACE (printf (" ungetc %d, to give %d chars\n", c, chars-1));
|
||||
}
|
||||
chars--;
|
||||
|
||||
(*__gmp_free_func) (s, s_alloc);
|
||||
|
||||
if (invalid)
|
||||
{
|
||||
TRACE (printf (" invalid\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
TRACE (printf (" return %d chars (cf width %d)\n", chars, width));
|
||||
return chars;
|
||||
}
|
||||
|
||||
|
||||
/* Read and discard whitespace, if any. Return number of chars skipped.
|
||||
Whitespace skipping never provokes the EOF return from __gmp_doscan, so
|
||||
it's not necessary to watch for EOF from funs->get, */
|
||||
static int
|
||||
skip_white (const struct gmp_doscan_funs_t *funs, void *data)
|
||||
{
|
||||
int c;
|
||||
int ret = 0;
|
||||
|
||||
do
|
||||
{
|
||||
c = (funs->get) (data);
|
||||
ret++;
|
||||
}
|
||||
while (isspace (c));
|
||||
|
||||
(funs->unget) (c, data);
|
||||
ret--;
|
||||
|
||||
TRACE (printf (" skip white %d\n", ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
__gmp_doscan (const struct gmp_doscan_funs_t *funs, void *data,
|
||||
const char *orig_fmt, va_list orig_ap)
|
||||
{
|
||||
struct gmp_doscan_params_t param;
|
||||
va_list ap;
|
||||
char *alloc_fmt;
|
||||
const char *fmt, *this_fmt, *end_fmt;
|
||||
size_t orig_fmt_len, alloc_fmt_size, len;
|
||||
int new_fields, new_chars;
|
||||
char fchar;
|
||||
int fields = 0;
|
||||
int chars = 0;
|
||||
|
||||
TRACE (printf ("__gmp_doscan \"%s\"\n", orig_fmt);
|
||||
if (funs->scan == (gmp_doscan_scan_t) sscanf)
|
||||
printf (" s=\"%s\"\n", * (const char **) data));
|
||||
|
||||
/* Don't modify orig_ap, if va_list is actually an array and hence call by
|
||||
reference. It could be argued that it'd be more efficient to leave
|
||||
callers to make a copy if they care, but doing so here is going to be a
|
||||
very small part of the total work, and we may as well keep applications
|
||||
out of trouble. */
|
||||
va_copy (ap, orig_ap);
|
||||
|
||||
/* Parts of the format string are going to be copied so that a " %n" can
|
||||
be appended. alloc_fmt is some space for that. orig_fmt_len+4 will be
|
||||
needed if fmt consists of a single "%" specifier, but otherwise is an
|
||||
overestimate. We're not going to be very fast here, so use
|
||||
__gmp_allocate_func rather than TMP_ALLOC. */
|
||||
orig_fmt_len = strlen (orig_fmt);
|
||||
alloc_fmt_size = orig_fmt_len + 4;
|
||||
alloc_fmt = __GMP_ALLOCATE_FUNC_TYPE (alloc_fmt_size, char);
|
||||
|
||||
fmt = orig_fmt;
|
||||
end_fmt = orig_fmt + orig_fmt_len;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
next:
|
||||
fchar = *fmt++;
|
||||
|
||||
if (fchar == '\0')
|
||||
break;
|
||||
|
||||
if (isspace (fchar))
|
||||
{
|
||||
chars += skip_white (funs, data);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fchar != '%')
|
||||
{
|
||||
int c;
|
||||
literal:
|
||||
c = (funs->get) (data);
|
||||
if (c != fchar)
|
||||
{
|
||||
(funs->unget) (c, data);
|
||||
if (c == EOF)
|
||||
{
|
||||
eof_no_match:
|
||||
if (fields == 0)
|
||||
fields = EOF;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
chars++;
|
||||
continue;
|
||||
}
|
||||
|
||||
param.type = '\0';
|
||||
param.base = 0; /* for e,f,g,i */
|
||||
param.ignore = 0;
|
||||
param.width = 0;
|
||||
|
||||
this_fmt = fmt-1;
|
||||
TRACE (printf (" this_fmt \"%s\"\n", this_fmt));
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ASSERT (fmt <= end_fmt);
|
||||
|
||||
fchar = *fmt++;
|
||||
switch (fchar) {
|
||||
|
||||
case '\0': /* unterminated % sequence */
|
||||
ASSERT (0);
|
||||
goto done;
|
||||
|
||||
case '%': /* literal % */
|
||||
goto literal;
|
||||
|
||||
case '[': /* character range */
|
||||
fchar = *fmt++;
|
||||
if (fchar == '^')
|
||||
fchar = *fmt++;
|
||||
/* ']' allowed as the first char (possibly after '^') */
|
||||
if (fchar == ']')
|
||||
fchar = *fmt++;
|
||||
for (;;)
|
||||
{
|
||||
ASSERT (fmt <= end_fmt);
|
||||
if (fchar == '\0')
|
||||
{
|
||||
/* unterminated % sequence */
|
||||
ASSERT (0);
|
||||
goto done;
|
||||
}
|
||||
if (fchar == ']')
|
||||
break;
|
||||
fchar = *fmt++;
|
||||
}
|
||||
/*FALLTHRU*/
|
||||
case 'c': /* characters */
|
||||
case 's': /* string of non-whitespace */
|
||||
case 'p': /* pointer */
|
||||
libc_type:
|
||||
len = fmt - this_fmt;
|
||||
memcpy (alloc_fmt, this_fmt, len);
|
||||
alloc_fmt[len++] = '%';
|
||||
alloc_fmt[len++] = 'n';
|
||||
alloc_fmt[len] = '\0';
|
||||
|
||||
TRACE (printf (" scan \"%s\"\n", alloc_fmt);
|
||||
if (funs->scan == (gmp_doscan_scan_t) sscanf)
|
||||
printf (" s=\"%s\"\n", * (const char **) data));
|
||||
|
||||
new_chars = -1;
|
||||
if (param.ignore)
|
||||
{
|
||||
new_fields = (*funs->scan) (data, alloc_fmt, &new_chars);
|
||||
ASSERT (new_fields == 0 || new_fields == EOF);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_fields = (*funs->scan) (data, alloc_fmt,
|
||||
va_arg (ap, void *), &new_chars);
|
||||
ASSERT (new_fields==0 || new_fields==1 || new_fields==EOF);
|
||||
|
||||
if (new_fields == 0)
|
||||
goto done; /* invalid input */
|
||||
|
||||
if (new_fields == 1)
|
||||
ASSERT (new_chars != -1);
|
||||
}
|
||||
TRACE (printf (" new_fields %d new_chars %d\n",
|
||||
new_fields, new_chars));
|
||||
|
||||
if (new_fields == -1)
|
||||
goto eof_no_match; /* EOF before anything matched */
|
||||
|
||||
/* Wnder param.ignore, when new_fields==0 we don't know if
|
||||
it's a successful match or an invalid field. new_chars
|
||||
won't have been assigned if it was an invalid field. */
|
||||
if (new_chars == -1)
|
||||
goto done; /* invalid input */
|
||||
|
||||
chars += new_chars;
|
||||
(*funs->step) (data, new_chars);
|
||||
|
||||
increment_fields:
|
||||
if (! param.ignore)
|
||||
fields++;
|
||||
goto next;
|
||||
|
||||
case 'd': /* decimal */
|
||||
case 'u': /* decimal */
|
||||
param.base = 10;
|
||||
goto numeric;
|
||||
|
||||
case 'e': /* float */
|
||||
case 'E': /* float */
|
||||
case 'f': /* float */
|
||||
case 'g': /* float */
|
||||
case 'G': /* float */
|
||||
case 'i': /* integer with base marker */
|
||||
numeric:
|
||||
if (param.type != 'F' && param.type != 'Q' && param.type != 'Z')
|
||||
goto libc_type;
|
||||
|
||||
chars += skip_white (funs, data);
|
||||
|
||||
new_chars = gmpscan (funs, data, ¶m,
|
||||
param.ignore ? NULL : va_arg (ap, void*));
|
||||
if (new_chars == -2)
|
||||
goto eof_no_match;
|
||||
if (new_chars == -1)
|
||||
goto done;
|
||||
|
||||
ASSERT (new_chars >= 0);
|
||||
chars += new_chars;
|
||||
goto increment_fields;
|
||||
|
||||
case 'a': /* glibc allocate string */
|
||||
case '\'': /* glibc digit groupings */
|
||||
break;
|
||||
|
||||
case 'F': /* mpf_t */
|
||||
case 'j': /* intmax_t */
|
||||
case 'L': /* long long */
|
||||
case 'q': /* quad_t */
|
||||
case 'Q': /* mpq_t */
|
||||
case 't': /* ptrdiff_t */
|
||||
case 'z': /* size_t */
|
||||
case 'Z': /* mpz_t */
|
||||
set_type:
|
||||
param.type = fchar;
|
||||
break;
|
||||
|
||||
case 'h': /* short or char */
|
||||
if (param.type != 'h')
|
||||
goto set_type;
|
||||
param.type = 'H'; /* internal code for "hh" */
|
||||
break;
|
||||
|
||||
goto numeric;
|
||||
|
||||
case 'l': /* long, long long, double or long double */
|
||||
if (param.type != 'l')
|
||||
goto set_type;
|
||||
param.type = 'L'; /* "ll" means "L" */
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
if (! param.ignore)
|
||||
{
|
||||
void *p;
|
||||
p = va_arg (ap, void *);
|
||||
TRACE (printf (" store %%n to %p\n", p));
|
||||
switch (param.type) {
|
||||
case '\0': * (int *) p = chars; break;
|
||||
case 'F': mpf_set_si ((mpf_ptr) p, (long) chars); break;
|
||||
case 'H': * (char *) p = chars; break;
|
||||
case 'h': * (short *) p = chars; break;
|
||||
#if HAVE_INTMAX_T
|
||||
case 'j': * (intmax_t *) p = chars; break;
|
||||
#else
|
||||
case 'j': ASSERT_FAIL (intmax_t not available); break;
|
||||
#endif
|
||||
case 'l': * (long *) p = chars; break;
|
||||
#if HAVE_QUAD_T && HAVE_LONG_LONG
|
||||
case 'q':
|
||||
ASSERT_ALWAYS (sizeof (quad_t) == sizeof (long long));
|
||||
/*FALLTHRU*/
|
||||
#else
|
||||
case 'q': ASSERT_FAIL (quad_t not available); break;
|
||||
#endif
|
||||
#if HAVE_LONG_LONG
|
||||
case 'L': * (long long *) p = chars; break;
|
||||
#else
|
||||
case 'L': ASSERT_FAIL (long long not available); break;
|
||||
#endif
|
||||
case 'Q': mpq_set_si ((mpq_ptr) p, (long) chars, 1L); break;
|
||||
#if HAVE_PTRDIFF_T
|
||||
case 't': * (ptrdiff_t *) p = chars; break;
|
||||
#else
|
||||
case 't': ASSERT_FAIL (ptrdiff_t not available); break;
|
||||
#endif
|
||||
case 'z': * (size_t *) p = chars; break;
|
||||
case 'Z': mpz_set_si ((mpz_ptr) p, (long) chars); break;
|
||||
default: ASSERT (0); break;
|
||||
}
|
||||
}
|
||||
goto next;
|
||||
|
||||
case 'o':
|
||||
param.base = 8;
|
||||
goto numeric;
|
||||
|
||||
case 'x':
|
||||
case 'X':
|
||||
param.base = 16;
|
||||
goto numeric;
|
||||
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
param.width = 0;
|
||||
do {
|
||||
param.width = param.width * 10 + (fchar-'0');
|
||||
fchar = *fmt++;
|
||||
} while (isdigit (fchar));
|
||||
fmt--; /* unget the non-digit */
|
||||
break;
|
||||
|
||||
case '*':
|
||||
param.ignore = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* something invalid in a % sequence */
|
||||
ASSERT (0);
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
(*__gmp_free_func) (alloc_fmt, alloc_fmt_size);
|
||||
return fields;
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/* gmp_fscanf -- formatted input from a FILE.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
#if HAVE_STDARG
|
||||
gmp_fscanf (FILE *fp, const char *fmt, ...)
|
||||
#else
|
||||
gmp_fscanf (va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
#if HAVE_STDARG
|
||||
va_start (ap, fmt);
|
||||
#else
|
||||
FILE *fp;
|
||||
const char *fmt;
|
||||
va_start (ap);
|
||||
fp = va_arg (ap, FILE *);
|
||||
fmt = va_arg (ap, const char *);
|
||||
#endif
|
||||
|
||||
ret = __gmp_doscan (&__gmp_fscanf_funs, fp, fmt, ap);
|
||||
va_end (ap);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/* __gmp_fscanf_funs -- support for formatted input from a FILE.
|
||||
|
||||
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
|
||||
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
|
||||
FUTURE GNU MP RELEASES.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
/* SunOS 4 stdio.h doesn't provide prototypes for these */
|
||||
#if ! HAVE_DECL_FGETC
|
||||
int fgetc _PROTO ((FILE *fp));
|
||||
#endif
|
||||
#if ! HAVE_DECL_FSCANF
|
||||
int fscanf _PROTO ((FILE *fp, const char *fmt, ...));
|
||||
#endif
|
||||
#if ! HAVE_DECL_UNGETC
|
||||
int ungetc _PROTO ((int c, FILE *fp));
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
step (FILE *fp, int n)
|
||||
{
|
||||
}
|
||||
|
||||
const struct gmp_doscan_funs_t __gmp_fscanf_funs = {
|
||||
(gmp_doscan_scan_t) fscanf,
|
||||
(gmp_doscan_step_t) step,
|
||||
(gmp_doscan_get_t) fgetc,
|
||||
(gmp_doscan_unget_t) ungetc,
|
||||
};
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
/* gmp_scanf -- formatted input from stdin.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
#if HAVE_STDARG
|
||||
gmp_scanf (const char *fmt, ...)
|
||||
#else
|
||||
gmp_scanf (va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
#if HAVE_STDARG
|
||||
va_start (ap, fmt);
|
||||
#else
|
||||
const char *fmt;
|
||||
va_start (ap);
|
||||
fmt = va_arg (ap, const char *);
|
||||
#endif
|
||||
|
||||
ret = __gmp_doscan (&__gmp_fscanf_funs, stdin, fmt, ap);
|
||||
va_end (ap);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/* gmp_sscanf -- formatted input from a string.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
#if HAVE_STDARG
|
||||
gmp_sscanf (const char *s, const char *fmt, ...)
|
||||
#else
|
||||
gmp_sscanf (va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
#if HAVE_STDARG
|
||||
va_start (ap, fmt);
|
||||
#else
|
||||
const char *s;
|
||||
const char *fmt;
|
||||
va_start (ap);
|
||||
s = va_arg (ap, const char *);
|
||||
fmt = va_arg (ap, const char *);
|
||||
#endif
|
||||
|
||||
#if SSCANF_WRITABLE_INPUT
|
||||
/* let gmp_vsscanf handle the copying */
|
||||
ret = gmp_vsscanf (s, fmt, ap);
|
||||
#else
|
||||
ret = __gmp_doscan (&__gmp_sscanf_funs, (void *) &s, fmt, ap);
|
||||
#endif
|
||||
va_end (ap);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
/* __gmp_sscanf_funs -- support for formatted input from a string.
|
||||
|
||||
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
|
||||
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
|
||||
FUTURE GNU MP RELEASES.
|
||||
|
||||
Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
static int
|
||||
scan (const char **sp, const char *fmt, void *p1, void *p2)
|
||||
{
|
||||
return sscanf (*sp, fmt, p1, p2);
|
||||
}
|
||||
|
||||
static void
|
||||
step (const char **sp, int n)
|
||||
{
|
||||
ASSERT (n >= 0);
|
||||
|
||||
/* shouldn't push us past the the end of the string */
|
||||
#if WANT_ASSERT
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
ASSERT ((*sp)[i] != '\0');
|
||||
}
|
||||
#endif
|
||||
|
||||
(*sp) += n;
|
||||
}
|
||||
|
||||
static int
|
||||
get (const char **sp)
|
||||
{
|
||||
const char *s;
|
||||
int c;
|
||||
s = *sp;
|
||||
c = (unsigned char) *s++;
|
||||
if (c == '\0')
|
||||
return EOF;
|
||||
*sp = s;
|
||||
return c;
|
||||
}
|
||||
|
||||
static void
|
||||
unget (int c, const char **sp)
|
||||
{
|
||||
const char *s;
|
||||
s = *sp;
|
||||
if (c == EOF)
|
||||
{
|
||||
ASSERT (*s == '\0');
|
||||
return;
|
||||
}
|
||||
s--;
|
||||
ASSERT ((unsigned char) *s == c);
|
||||
*sp = s;
|
||||
}
|
||||
|
||||
const struct gmp_doscan_funs_t __gmp_sscanf_funs = {
|
||||
(gmp_doscan_scan_t) scan,
|
||||
(gmp_doscan_step_t) step,
|
||||
(gmp_doscan_get_t) get,
|
||||
(gmp_doscan_unget_t) unget,
|
||||
};
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/* gmp_vfscanf -- formatted input from a FILE.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
gmp_vfscanf (FILE *fp, const char *fmt, va_list ap)
|
||||
{
|
||||
return __gmp_doscan (&__gmp_fscanf_funs, fp, fmt, ap);
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/* gmp_vscanf -- formatted input from stdin.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
gmp_vscanf (const char *fmt, va_list ap)
|
||||
{
|
||||
return __gmp_doscan (&__gmp_fscanf_funs, stdin, fmt, ap);
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/* gmp_vsscanf -- formatted input from a string.
|
||||
|
||||
Copyright 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU MP Library.
|
||||
|
||||
The GNU MP Library 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 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The GNU MP Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "gmp.h"
|
||||
#include "gmp-impl.h"
|
||||
|
||||
|
||||
int
|
||||
gmp_vsscanf (const char *s, const char *fmt, va_list ap)
|
||||
{
|
||||
#if SSCANF_WRITABLE_INPUT
|
||||
/* We only actually need this if there's standard C types in fmt, and if
|
||||
"s" is not already writable, but it's too much trouble to check that,
|
||||
and in any case this writable sscanf input business is only for a few
|
||||
old systems. */
|
||||
size_t size;
|
||||
char *alloc;
|
||||
int ret;
|
||||
size = strlen (s) + 1;
|
||||
alloc = (char *) (*__gmp_allocate_func) (size);
|
||||
memcpy (alloc, s, size);
|
||||
s = alloc;
|
||||
ret = __gmp_doscan (&__gmp_sscanf_funs, (void *) &s, fmt, ap);
|
||||
(*__gmp_free_func) (alloc, size);
|
||||
return ret;
|
||||
|
||||
#else
|
||||
return __gmp_doscan (&__gmp_sscanf_funs, (void *) &s, fmt, ap);
|
||||
#endif
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue