From 16290661891a725c369c6b895cabacd37975afb1 Mon Sep 17 00:00:00 2001 From: JWu <j.wuttke@fz-juelich.de> Date: Fri, 26 Oct 2012 20:24:19 +0200 Subject: [PATCH] This is frida2.1.6a: Refactored; basics moved to libtrivia --- pub/CHANGELOG | 6 +- pub/config.h.in | 3 + pub/configure | 83 +++++++---- pub/configure.ac | 13 +- pub/src/Makefile.am | 12 -- pub/src/Makefile.in | 28 +--- pub/src/STYLE | 11 ++ pub/src/axis.cpp | 8 +- pub/src/calc.cpp | 1 + pub/src/commands.cpp | 10 +- pub/src/coord.cpp | 7 +- pub/src/curve.cpp | 13 +- pub/src/defs.h | 2 - pub/src/dualplot.cpp | 7 +- pub/src/edif.cpp | 10 +- pub/src/expr.cpp | 6 +- pub/src/file_in.cpp | 12 +- pub/src/file_ops.cpp | 177 ----------------------- pub/src/file_ops.h | 23 --- pub/src/file_out.cpp | 9 +- pub/src/frida2.cpp | 10 +- pub/src/func.cpp | 4 +- pub/src/integrate.cpp | 60 -------- pub/src/integrate.h | 10 -- pub/src/list.cpp | 3 +- pub/src/manip.cpp | 7 +- pub/src/mem.cpp | 5 +- pub/src/mystd.cpp | 327 ------------------------------------------ pub/src/mystd.h | 35 ----- pub/src/node.cpp | 4 +- pub/src/olf.cpp | 5 +- pub/src/opr.cpp | 11 +- pub/src/plot.cpp | 5 +- pub/src/reg.cpp | 2 + pub/src/rng.cpp | 41 ------ pub/src/rng.h | 13 -- pub/src/rssm.cpp | 12 +- pub/src/special1.cpp | 18 +-- pub/src/special2.cpp | 5 +- pub/src/strg.cpp | 46 ------ pub/src/strg.h | 14 -- pub/src/var.cpp | 6 +- pub/src/xax_lex.lpp | 3 +- pub/src/xax_yacc.ypp | 3 +- pub/src/yaml_out.cpp | 44 ------ pub/src/yaml_out.h | 9 -- pub/src/zentry.cpp | 4 +- 47 files changed, 197 insertions(+), 950 deletions(-) delete mode 100644 pub/src/file_ops.cpp delete mode 100644 pub/src/file_ops.h delete mode 100644 pub/src/integrate.cpp delete mode 100644 pub/src/integrate.h delete mode 100644 pub/src/mystd.cpp delete mode 100644 pub/src/mystd.h delete mode 100644 pub/src/rng.cpp delete mode 100644 pub/src/rng.h delete mode 100644 pub/src/strg.cpp delete mode 100644 pub/src/strg.h delete mode 100644 pub/src/yaml_out.cpp delete mode 100644 pub/src/yaml_out.h diff --git a/pub/CHANGELOG b/pub/CHANGELOG index c51c3746..92af3d67 100644 --- a/pub/CHANGELOG +++ b/pub/CHANGELOG @@ -1,7 +1,9 @@ -Release 2.1.5b +Release 2.1.6a of 26oct12, comes with fridalibs-121026: - code refactored: - - from now on, std=C++0x is required + - from now on, std=C++11 (temporarily 0x) is required + - new library libtrivia in fridalibs + - include's thoroughly revised -bugfixes: - constant curve now plotted correctly diff --git a/pub/config.h.in b/pub/config.h.in index fd42a2ce..0ea3561f 100644 --- a/pub/config.h.in +++ b/pub/config.h.in @@ -66,6 +66,9 @@ /* Define to 1 if you have the `read-plus' library (-lread-plus). */ #undef HAVE_LIBREAD_PLUS +/* Define to 1 if you have the `trivia' library (-ltrivia). */ +#undef HAVE_LIBTRIVIA + /* Define to 1 if you have the `yaml-cpp' library (-lyaml-cpp). */ #undef HAVE_LIBYAML_CPP diff --git a/pub/configure b/pub/configure index 1192408d..747100ea 100755 --- a/pub/configure +++ b/pub/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for frida post-2.1.5a. +# Generated by GNU Autoconf 2.69 for frida 2.1.6a. # # Report bugs to <j.wuttke@fz-juelich.de>. # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='frida' PACKAGE_TARNAME='frida' -PACKAGE_VERSION='post-2.1.5a' -PACKAGE_STRING='frida post-2.1.5a' +PACKAGE_VERSION='2.1.6a' +PACKAGE_STRING='frida 2.1.6a' PACKAGE_BUGREPORT='j.wuttke@fz-juelich.de' PACKAGE_URL='' @@ -1284,7 +1284,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures frida post-2.1.5a to adapt to many kinds of systems. +\`configure' configures frida 2.1.6a to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1350,7 +1350,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of frida post-2.1.5a:";; + short | recursive ) echo "Configuration of frida 2.1.6a:";; esac cat <<\_ACEOF @@ -1446,7 +1446,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -frida configure post-2.1.5a +frida configure 2.1.6a generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2120,7 +2120,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by frida $as_me post-2.1.5a, which was +It was created by frida $as_me 2.1.6a, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2945,7 +2945,7 @@ fi # Define the identity of the package. PACKAGE='frida' - VERSION='post-2.1.5a' + VERSION='2.1.6a' cat >>confdefs.h <<_ACEOF @@ -5444,20 +5444,6 @@ fi done -for ac_header in sys/time.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_time_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SYS_TIME_H 1 -_ACEOF - -else - as_fn_error $? "Cannot find sys/time.h." "$LINENO" 5 -fi - -done - for ac_header in unistd.h do : ac_fn_c_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" @@ -6917,22 +6903,22 @@ fi rm -f conftest.err conftest.i conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include<readln.h> +#include<read-plus/readln.hpp> _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else - as_fn_error $? "Cannot find readln.h." "$LINENO" 5 + as_fn_error $? "Cannot find readln.hpp." "$LINENO" 5 fi rm -f conftest.err conftest.i conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include<yaml-cpp/yaml.h> +#include<yaml-cpp/yaml.hpp> _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else - as_fn_error $? "Cannot find yaml-cpp/yaml.h." "$LINENO" 5 + as_fn_error $? "Cannot find yaml-cpp/yaml.hpp." "$LINENO" 5 fi rm -f conftest.err conftest.i conftest.$ac_ext @@ -7019,6 +7005,47 @@ else as_fn_error $? "library read-plus not found" "$LINENO" 5 fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ltrivia" >&5 +$as_echo_n "checking for main in -ltrivia... " >&6; } +if ${ac_cv_lib_trivia_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ltrivia $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_trivia_main=yes +else + ac_cv_lib_trivia_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_trivia_main" >&5 +$as_echo "$ac_cv_lib_trivia_main" >&6; } +if test "x$ac_cv_lib_trivia_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBTRIVIA 1 +_ACEOF + + LIBS="-ltrivia $LIBS" + +else + as_fn_error $? "libtrivia not found or out of sync" "$LINENO" 5 +fi + ############################################################################### ## Execute ## @@ -7552,7 +7579,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by frida $as_me post-2.1.5a, which was +This file was extended by frida $as_me 2.1.6a, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7618,7 +7645,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -frida config.status post-2.1.5a +frida config.status 2.1.6a configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/pub/configure.ac b/pub/configure.ac index fe02deeb..7471ad97 100644 --- a/pub/configure.ac +++ b/pub/configure.ac @@ -9,7 +9,7 @@ ## Generic initialization ## ############################################################################### -AC_INIT([frida],[post-2.1.5a],[j.wuttke@fz-juelich.de]) +AC_INIT([frida],[2.1.6a],[j.wuttke@fz-juelich.de]) # ^^^^^ delete "post-" for public releases # project name must be "frida"; this determines the installation directories @@ -64,7 +64,6 @@ AC_HEADER_STDBOOL AC_HEADER_STDC AC_CHECK_HEADERS([fcntl.h], ,AC_MSG_ERROR([Cannot find fcntl.h.])) -AC_CHECK_HEADERS([sys/time.h], ,AC_MSG_ERROR([Cannot find sys/time.h.])) AC_CHECK_HEADERS([unistd.h], ,AC_MSG_ERROR([Cannot find unistd.h.])) AC_CHECK_HEADERS([inttypes.h], ,AC_MSG_ERROR([Cannot find inttypes.h.])) AC_CHECK_HEADERS([libintl.h], ,AC_MSG_ERROR([Cannot find libintl.h.])) @@ -131,16 +130,18 @@ AC_TRY_CPP([#include<boost/format.hpp>],, AC_MSG_ERROR([Cannot find boost/format.hpp.])) AC_TRY_CPP([#include<boost/shared_ptr.hpp>],, AC_MSG_ERROR([Cannot find boost/shared_ptr.hpp.])) -AC_TRY_CPP([#include<readln.h>],, - AC_MSG_ERROR([Cannot find readln.h.])) -AC_TRY_CPP([#include<yaml-cpp/yaml.h>],, - AC_MSG_ERROR([Cannot find yaml-cpp/yaml.h.])) +AC_TRY_CPP([#include<read-plus/readln.hpp>],, + AC_MSG_ERROR([Cannot find readln.hpp.])) +AC_TRY_CPP([#include<yaml-cpp/yaml.hpp>],, + AC_MSG_ERROR([Cannot find yaml-cpp/yaml.hpp.])) # no idea how to check for cpp libraries AC_CHECK_LIB([yaml-cpp], [main],, [AC_MSG_ERROR(library yaml-cpp not found)]) AC_CHECK_LIB([read-plus], [main],, [AC_MSG_ERROR(library read-plus not found)]) +AC_CHECK_LIB([trivia], [main], , + [AC_MSG_ERROR(libtrivia not found or out of sync)]) ############################################################################### ## Execute ## diff --git a/pub/src/Makefile.am b/pub/src/Makefile.am index 08c340a7..186fcb21 100644 --- a/pub/src/Makefile.am +++ b/pub/src/Makefile.am @@ -51,23 +51,17 @@ expr.cpp \ expr.h \ file_in.cpp \ file_in.h \ -file_ops.cpp \ -file_ops.h \ file_out.cpp \ file_out.h \ frida2.cpp \ func.cpp \ func.h \ -integrate.cpp \ -integrate.h \ list.cpp \ list.h \ manip.cpp \ manip.h \ mem.cpp \ mem.h \ -mystd.cpp \ -mystd.h \ node.cpp \ node.h \ olf.cpp \ @@ -78,22 +72,16 @@ plot.cpp \ plot.h \ reg.cpp \ reg.h \ -rng.cpp \ -rng.h \ rssm.cpp \ rssm.h \ special1.cpp \ special2.cpp \ special.h \ -strg.h \ -strg.cpp \ xax_lex.h \ xax_lex.lpp \ xax_yacc.ypp \ var.h \ var.cpp \ -yaml_out.h \ -yaml_out.cpp \ zentry.h \ zentry.cpp # AM_LDFLAGS = -l.. no longer needed, all is done by configure.ac diff --git a/pub/src/Makefile.in b/pub/src/Makefile.in index 28d40e73..05f2dc6e 100644 --- a/pub/src/Makefile.in +++ b/pub/src/Makefile.in @@ -66,13 +66,11 @@ PROGRAMS = $(bin_PROGRAMS) am_frida_OBJECTS = axis.$(OBJEXT) calc.$(OBJEXT) commands.$(OBJEXT) \ coord.$(OBJEXT) curve.$(OBJEXT) dualplot.$(OBJEXT) \ edif.$(OBJEXT) expr.$(OBJEXT) file_in.$(OBJEXT) \ - file_ops.$(OBJEXT) file_out.$(OBJEXT) frida2.$(OBJEXT) \ - func.$(OBJEXT) integrate.$(OBJEXT) list.$(OBJEXT) \ - manip.$(OBJEXT) mem.$(OBJEXT) mystd.$(OBJEXT) node.$(OBJEXT) \ + file_out.$(OBJEXT) frida2.$(OBJEXT) func.$(OBJEXT) \ + list.$(OBJEXT) manip.$(OBJEXT) mem.$(OBJEXT) node.$(OBJEXT) \ olf.$(OBJEXT) opr.$(OBJEXT) plot.$(OBJEXT) reg.$(OBJEXT) \ - rng.$(OBJEXT) rssm.$(OBJEXT) special1.$(OBJEXT) \ - special2.$(OBJEXT) strg.$(OBJEXT) xax_lex.$(OBJEXT) \ - xax_yacc.$(OBJEXT) var.$(OBJEXT) yaml_out.$(OBJEXT) \ + rssm.$(OBJEXT) special1.$(OBJEXT) special2.$(OBJEXT) \ + xax_lex.$(OBJEXT) xax_yacc.$(OBJEXT) var.$(OBJEXT) \ zentry.$(OBJEXT) frida_OBJECTS = $(am_frida_OBJECTS) frida_LDADD = $(LDADD) @@ -252,23 +250,17 @@ expr.cpp \ expr.h \ file_in.cpp \ file_in.h \ -file_ops.cpp \ -file_ops.h \ file_out.cpp \ file_out.h \ frida2.cpp \ func.cpp \ func.h \ -integrate.cpp \ -integrate.h \ list.cpp \ list.h \ manip.cpp \ manip.h \ mem.cpp \ mem.h \ -mystd.cpp \ -mystd.h \ node.cpp \ node.h \ olf.cpp \ @@ -279,22 +271,16 @@ plot.cpp \ plot.h \ reg.cpp \ reg.h \ -rng.cpp \ -rng.h \ rssm.cpp \ rssm.h \ special1.cpp \ special2.cpp \ special.h \ -strg.h \ -strg.cpp \ xax_lex.h \ xax_lex.lpp \ xax_yacc.ypp \ var.h \ var.cpp \ -yaml_out.h \ -yaml_out.cpp \ zentry.h \ zentry.cpp @@ -395,29 +381,23 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edif.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_in.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_ops.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_out.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frida2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/func.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/integrate.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/manip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mystd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/node.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/olf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plot.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reg.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rng.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rssm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/special1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/special2.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/var.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xax_lex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xax_yacc.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yaml_out.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zentry.Po@am__quote@ .cpp.o: diff --git a/pub/src/STYLE b/pub/src/STYLE index 97c762e7..eb7f50bf 100644 --- a/pub/src/STYLE +++ b/pub/src/STYLE @@ -1,3 +1,14 @@ +== include's == + +- Block 1: Standard software + - C standard library: cstdlib cstdio cstring cmath *.h sys/*.h + - C++ standard library: iostream fstream string vector map algorithm + - boost + - GSL +- Block 2: Our own libs + - trivia read-plus yaml_out lmfit kww +- Block 3: Current project + == function arguments and "const" qualifier == - never use "const" with simple data types diff --git a/pub/src/axis.cpp b/pub/src/axis.cpp index 2c61ac88..fc8d13e4 100644 --- a/pub/src/axis.cpp +++ b/pub/src/axis.cpp @@ -10,13 +10,15 @@ #include <cmath> #include <fcntl.h> #include <iostream> +#include <string> +#include <vector> #include <boost/format.hpp> -#include <readln.h> +#include <trivia/strg.hpp> +#include <trivia/mystd.hpp> +#include <read-plus/readln.hpp> #include "defs.h" -#include "strg.h" -#include "mystd.h" #include "axis.h" using boost::format; diff --git a/pub/src/calc.cpp b/pub/src/calc.cpp index d56b3a91..deca7fda 100644 --- a/pub/src/calc.cpp +++ b/pub/src/calc.cpp @@ -5,6 +5,7 @@ //* http://apps.jcns.fz-juelich.de *// //**************************************************************************// +#include <string> #include <vector> #include "defs.h" diff --git a/pub/src/commands.cpp b/pub/src/commands.cpp index 2e3e57d7..1633a733 100644 --- a/pub/src/commands.cpp +++ b/pub/src/commands.cpp @@ -5,18 +5,18 @@ //* http://apps.jcns.fz-juelich.de *// //**************************************************************************// -#include <cstring> #include <cstdlib> +#include <cstring> #include <iostream> +#include <string> #include <vector> -#include <ask_simple_value.h> -#include <readln.h> +#include <trivia/file_ops.hpp> +#include <read-plus/ask.hpp> +#include <read-plus/readln.hpp> #include "../config.h" - #include "defs.h" -#include "file_ops.h" #include "olf.h" #include "mem.h" #include "edif.h" diff --git a/pub/src/coord.cpp b/pub/src/coord.cpp index 18a7b254..39e0187c 100644 --- a/pub/src/coord.cpp +++ b/pub/src/coord.cpp @@ -9,14 +9,15 @@ #include <cstring> #include <cmath> #include <iostream> +#include <string> #include <vector> -#include <ask_simple_value.h> // for ASK flags -#include <readln.h> +#include <read-plus/ask.hpp> // for ASK flags +#include <read-plus/readln.hpp> +#include <trivia/mystd.hpp> using namespace std; -#include "mystd.h" #include "coord.h" //**************************************************************************// diff --git a/pub/src/curve.cpp b/pub/src/curve.cpp index 1c2cd3a0..43ed95bb 100644 --- a/pub/src/curve.cpp +++ b/pub/src/curve.cpp @@ -11,20 +11,21 @@ #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> - #include <iostream> +#include <string> +#include <vector> #include <boost/format.hpp> +#include <trivia/strg.hpp> +#include <trivia/file_ops.hpp> +#include <trivia/integrate.hpp> +#include <read-plus/ask.hpp> +#include <read-plus/readln.hpp> #include <lmmin.h> -#include <ask_simple_value.h> -#include <readln.h> using boost::format; #include "defs.h" -#include "strg.h" -#include "file_ops.h" -#include "integrate.h" #include "olf.h" #include "mem.h" #include "zentry.h" diff --git a/pub/src/defs.h b/pub/src/defs.h index f1f4b536..4ae8a354 100644 --- a/pub/src/defs.h +++ b/pub/src/defs.h @@ -5,8 +5,6 @@ //* http://apps.jcns.fz-juelich.de *// //**************************************************************************// -#include <string> - #define SQR(a) ((a)*(a)) #define uint unsigned int diff --git a/pub/src/dualplot.cpp b/pub/src/dualplot.cpp index 1f4c57e2..ed6ba570 100644 --- a/pub/src/dualplot.cpp +++ b/pub/src/dualplot.cpp @@ -10,14 +10,17 @@ #include <cstring> #include <cmath> #include <iostream> +#include <string> +#include <vector> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <boost/format.hpp> +#include <trivia/strg.hpp> +#include <trivia/file_ops.hpp> + #include "defs.h" -#include "strg.h" -#include "file_ops.h" #include "dualplot.h" using boost::format; diff --git a/pub/src/edif.cpp b/pub/src/edif.cpp index aca4980c..86f0934e 100644 --- a/pub/src/edif.cpp +++ b/pub/src/edif.cpp @@ -9,14 +9,16 @@ #include <cstdio> #include <iostream> #include <fstream> +#include <string> +#include <vector> #include <boost/format.hpp> -#include <ask_simple_value.h> +#include <trivia/strg.hpp> +#include <trivia/mystd.hpp> +#include <trivia/file_ops.hpp> +#include <read-plus/ask.hpp> #include "defs.h" -#include "strg.h" -#include "mystd.h" -#include "file_ops.h" #include "olf.h" #include "mem.h" #include "zentry.h" diff --git a/pub/src/expr.cpp b/pub/src/expr.cpp index 7fee6eac..c43b2fc5 100644 --- a/pub/src/expr.cpp +++ b/pub/src/expr.cpp @@ -6,11 +6,13 @@ //**************************************************************************// #include <iostream> +#include <string> #include <vector> +#include <trivia/strg.hpp> +#include <trivia/mystd.hpp> + #include "defs.h" -#include "strg.h" -#include "mystd.h" #include "olf.h" #include "mem.h" #include "zentry.h" diff --git a/pub/src/file_in.cpp b/pub/src/file_in.cpp index c40daf5d..55a2e8cc 100644 --- a/pub/src/file_in.cpp +++ b/pub/src/file_in.cpp @@ -9,15 +9,17 @@ #include <cstring> #include <iostream> #include <fstream> +#include <string> +#include <vector> #include <map> -#include <ask_simple_value.h> -#include <yaml-cpp/yaml.h> +#include <trivia/strg.hpp> +#include <trivia/mystd.hpp> +#include <trivia/file_ops.hpp> +#include <read-plus/ask.hpp> +#include <yaml-cpp/yaml.hpp> #include "defs.h" -#include "strg.h" -#include "mystd.h" -#include "file_ops.h" #include "olf.h" #include "mem.h" #include "var.h" diff --git a/pub/src/file_ops.cpp b/pub/src/file_ops.cpp deleted file mode 100644 index 88899b84..00000000 --- a/pub/src/file_ops.cpp +++ /dev/null @@ -1,177 +0,0 @@ -//**************************************************************************// -//* FRIDA: flexible rapid interactive data analysis *// -//* file_ops: file operations *// -//* (C) Joachim Wuttke 2001- *// -//* http://apps.jcns.fz-juelich.de *// -//**************************************************************************// - -#include <sys/stat.h> -#include <wordexp.h> -#include <glob.h> -#include <iostream> -#include <vector> -#include <boost/format.hpp> - -using boost::format; - -#include "defs.h" -#include "strg.h" -#include "mystd.h" -#include "file_ops.h" - - -//**************************************************************************// -//* improved libc calls *// -//**************************************************************************// - -void mystd::system( string cmd ) -{ - int ret = ::system( cmd.c_str() ); - if( ret ) - throw "Command '" + cmd + "' returned error code " + strg(ret); -} - - -//**************************************************************************// -//* file names, globbing *// -//**************************************************************************// - - -//! Test whether file exists. - -bool mystd::file_exists( const string& fname ) -{ - struct stat fileInfo; - int iStat = stat( fname.c_str(), &fileInfo ); - if ( iStat == 0 ) // we got attributes, so the file obviously exists - return true; - else - return false; // either file doesn't exist or we lack permissions -} - - -//! Analyse file name: divide "dir/short.ext" into "dir", "short", "ext". - -void mystd::fname_divide( const string& fname, - string *fdir, string *fshort, string *fext ) -// if some of the three return values are not needed, the user may supply 0 -// instead of a pointer to a string. -{ - uint idir = fname.rfind("/") + 1; - if( fdir ) *fdir = fname.substr( 0, idir ); - - uint iext = fname.rfind(string(".")) + 1; - if( iext<=idir ){ - if( fext ) *fext = ""; - if( fshort ) *fshort = fname.substr( idir ); - } else { - if( fext ) *fext = fname.substr( iext ); - if( fshort ) *fshort = fname.substr( idir, iext-idir-1 ); - } -} - - -//! Bash expansion of file name. - -string mystd::wordexp_unique( const string& s ) -{ - wordexp_t p; - if( wordexp( s.c_str(), &p, 0 ) ) - throw "cannot expand " + s; - if( p.we_wordc!=1 ) - throw "expansion of " + s + " not unique"; - string ret = p.we_wordv[0]; - wordfree( &p ); - return ret; -} - - -//! Construct tmp file name that is not currently in use. - -string mystd::next_tmp_file( const string& path_format ) -{ - const int tmpmax=1024; - for( int i=0; i<tmpmax; ++i ){ - string fname = str( format( path_format ) % i ); - if ( !mystd::file_exists( fname ) ) - return fname; - if( i==tmpmax/2 ) - cerr << "WARNING: there more than " << i << - " temporay files of form " << path_format << - "; please clean up soon\n"; - } - throw "Too many temporary files in use"; -} - - -//! Expansion of file list. - -void mystd::glob_file_list( - const string& pattern, const string& extension, vector<string> *fnames ) -{ - // add extension to input pattern: - string extended_pattern = ""; - vector<string> words; - string2words( pattern, words ); - if ( !words.size() ) - throw string( "empty file list" ); - for ( int i=0; ; ) { - string fmain, fext; - fname_divide( words[i], 0, &fmain, &fext ); - extended_pattern += words[i]; - if ( fext=="" && extension!="" ) - extended_pattern += "." + extension; - if ( ++i>=words.size() ) - break; - extended_pattern += " "; - } - - wordexp_t p; - if( wordexp( extended_pattern.c_str(), &p, 0 ) ) - throw "cannot expand " + extended_pattern; - if( p.we_wordc==0 ) - throw "expansion of " + extended_pattern + " is empty"; - for ( int i=0; i<p.we_wordc; ++i ) - fnames->push_back( p.we_wordv[i] ); - wordfree( &p ); -} - - -//**************************************************************************// -//* file read *// -//**************************************************************************// - - -//! Read one line from file. - -// ... could be reimplemented using the simpler version from read-plus - -int mystd::freadln( FILE *fd, string *s ) -{ - char c = (char) fgetc(fd); - if( c==EOF ) - return -1; - if( c=='\n' ){ - *s = ""; - return 0; - } else if ( c=='\r' ) { - if( fgetc(fd)=='\n' ){ - *s = ""; - return 0; - } else - throw string( "CR not followed by LF" ); - } - *s = c; - while ( 1 ) { - c = (char) fgetc(fd); - if ( c=='\n' || c==EOF ) - return s->size(); - else if ( c=='\r' ){ - if( fgetc(fd)=='\n' ) - return s->size(); - else - throw string( "CR not followed by LF" ); - } - *s += c; - } -} diff --git a/pub/src/file_ops.h b/pub/src/file_ops.h deleted file mode 100644 index 4a1db54d..00000000 --- a/pub/src/file_ops.h +++ /dev/null @@ -1,23 +0,0 @@ -//**************************************************************************// -//* FRIDA: flexible rapid interactive data analysis *// -//* file_ops: file operations *// -//* (C) Joachim Wuttke 2001- *// -//* http://apps.jcns.fz-juelich.de *// -//**************************************************************************// - -namespace mystd { - //! improved libc calls - void system( string cmd ); - - //! file names, globbing - bool file_exists( const string& fname ); - void fname_divide( const string& fname, string *fdir, - string *fshort, string *fext); - void glob_file_list( const string& pattern, const string& extension, - vector<string> *fnames ); - string wordexp_unique( const string& s ); - string next_tmp_file( const string& path_format ); - - //! file read - int freadln( FILE *fd, string *s ); -} diff --git a/pub/src/file_out.cpp b/pub/src/file_out.cpp index 31595eaa..e9a6159e 100644 --- a/pub/src/file_out.cpp +++ b/pub/src/file_out.cpp @@ -8,14 +8,15 @@ #include <cstdlib> #include <cstdio> #include <iostream> -#include <map> +#include <string> #include <vector> +#include <map> -#include <ask_simple_value.h> +#include <trivia/mystd.hpp> +#include <trivia/yaml_out.hpp> +#include <read-plus/ask.hpp> #include "defs.h" -#include "mystd.h" -#include "yaml_out.h" #include "olf.h" #include "mem.h" #include "zentry.h" diff --git a/pub/src/frida2.cpp b/pub/src/frida2.cpp index 78d388a9..2b3a114d 100644 --- a/pub/src/frida2.cpp +++ b/pub/src/frida2.cpp @@ -7,18 +7,18 @@ #include <cstdlib> #include <iostream> +#include <string> #include <vector> - #include <gsl/gsl_errno.h> -#include <ask_simple_value.h> -#include <readln.h> +#include <trivia/strg.hpp> +#include <trivia/rng.hpp> +#include <read-plus/ask.hpp> +#include <read-plus/readln.hpp> #include "defs.h" -#include "strg.h" #include "olf.h" #include "mem.h" -#include "rng.h" #include "func.h" #include "dualplot.h" #include "commands.h" diff --git a/pub/src/func.cpp b/pub/src/func.cpp index 7969a6f9..3063aae5 100644 --- a/pub/src/func.cpp +++ b/pub/src/func.cpp @@ -7,13 +7,15 @@ #include <cmath> #include <iostream> +#include <string> #include <vector> #include <map> #include <gsl/gsl_sf.h> + +#include <trivia/rng.hpp> #include <kww.h> #include "defs.h" -#include "rng.h" #include "func.h" #include "coord.h" diff --git a/pub/src/integrate.cpp b/pub/src/integrate.cpp deleted file mode 100644 index 9a9dde99..00000000 --- a/pub/src/integrate.cpp +++ /dev/null @@ -1,60 +0,0 @@ -//**************************************************************************// -//* FRIDA: flexible rapid interactive data analysis *// -//* integrate: wrapper for GSL integration routines *// -//* (C) Joachim Wuttke 1990-, v2(C++) 2001- *// -//* http://apps.jcns.fz-juelich.de *// -//**************************************************************************// - -#include <gsl/gsl_integration.h> -#include "integrate.h" -using namespace std; - -double my_integrate( double (*func_) (double, void*), void *data_, - double low, double hig, uint mode, - double epsabs, double epsrel ) -{ - gsl_function F; - F.function = func_; - F.params = data_; -#define nwork 20000 - gsl_integration_workspace *work = gsl_integration_workspace_alloc( nwork ); - double val, err; - size_t neval; - - if ( isinf(low)==-1 && isinf(hig)==+1 ) - gsl_integration_qagi( &F, epsabs, epsrel, nwork, work, - &val, &err ); - else if ( isinf(low)==-1 ) - gsl_integration_qagil( &F, hig, epsabs, epsrel, nwork, work, - &val, &err ); - else if ( isinf(hig)==+1 ) - gsl_integration_qagiu( &F, low, epsabs, epsrel, nwork, work, - &val, &err ); - else if ( mode==0 ) - // QNG non-adaptive Gauss-Kronrod integration - gsl_integration_qng( &F, low, hig, epsabs, epsrel, - &val, &err, &neval ); - else if ( mode>0 && mode<7 ){ - int rule; - switch( mode ){ - case 1: rule = GSL_INTEG_GAUSS61; break; - case 2: rule = GSL_INTEG_GAUSS51; break; - case 3: rule = GSL_INTEG_GAUSS41; break; - case 4: rule = GSL_INTEG_GAUSS31; break; - case 5: rule = GSL_INTEG_GAUSS21; break; - case 6: rule = GSL_INTEG_GAUSS15; break; - } - // QAG adaptive integration - gsl_integration_qag( &F, low, hig, epsabs, epsrel, nwork, - rule, work, &val, &err ); - } - else if ( mode==7 ) - // QAGS adaptive integration with singularities - gsl_integration_qags( &F, low, hig, epsabs, epsrel, nwork, - work, &val, &err ); - else - throw "invalid mode in mystd::Integrate"; - - gsl_integration_workspace_free( work ); - return val; -} diff --git a/pub/src/integrate.h b/pub/src/integrate.h deleted file mode 100644 index 97f6416e..00000000 --- a/pub/src/integrate.h +++ /dev/null @@ -1,10 +0,0 @@ -//**************************************************************************// -//* FRIDA: flexible rapid interactive data analysis *// -//* integrate: wrapper for GSL integration routines *// -//* (C) Joachim Wuttke 1990-, v2(C++) 2001- *// -//* http://apps.jcns.fz-juelich.de *// -//**************************************************************************// - -double my_integrate( double (*func_) (double, void*), void *data_, - double low, double hig, - uint mode, double epsabs, double epsrel ); diff --git a/pub/src/list.cpp b/pub/src/list.cpp index ba9c9e26..fdc57171 100644 --- a/pub/src/list.cpp +++ b/pub/src/list.cpp @@ -9,8 +9,9 @@ #include <vector> #include <algorithm> +#include <trivia/strg.hpp> + #include "defs.h" -#include "strg.h" #include "list.h" diff --git a/pub/src/manip.cpp b/pub/src/manip.cpp index 4cbe1b60..a6279867 100644 --- a/pub/src/manip.cpp +++ b/pub/src/manip.cpp @@ -9,16 +9,17 @@ #include <cstdio> #include <cmath> #include <iostream> +#include <string> #include <vector> #include <algorithm> #include <boost/format.hpp> #include <gsl/gsl_sort.h> -#include <ask_simple_value.h> +#include <trivia/strg.hpp> +#include <trivia/mystd.hpp> +#include <read-plus/ask.hpp> #include "defs.h" -#include "strg.h" -#include "mystd.h" #include "olf.h" #include "mem.h" #include "var.h" diff --git a/pub/src/mem.cpp b/pub/src/mem.cpp index aee0213d..885628f6 100644 --- a/pub/src/mem.cpp +++ b/pub/src/mem.cpp @@ -6,14 +6,15 @@ //**************************************************************************// #include <iostream> +#include <string> #include <vector> #include <algorithm> -#include <ask_simple_value.h> +#include <trivia/mystd.hpp> +#include <read-plus/ask.hpp> using namespace std; -#include "mystd.h" #include "olf.h" #include "mem.h" diff --git a/pub/src/mystd.cpp b/pub/src/mystd.cpp deleted file mode 100644 index 5fb5e1ac..00000000 --- a/pub/src/mystd.cpp +++ /dev/null @@ -1,327 +0,0 @@ -//**************************************************************************// -//* FRIDA: flexible rapid interactive data analysis *// -//* mystd: various auxilary routines *// -//* (C) Joachim Wuttke 2001- *// -//* http://apps.jcns.fz-juelich.de *// -//**************************************************************************// - -#include <cstring> -#include <cmath> -#include <sys/time.h> -#include <iostream> -#include <vector> - -#include "defs.h" -#include "strg.h" -#include "mystd.h" - - -//**************************************************************************// -//* convert from string *// -//**************************************************************************// - - -// ------ should be converted to void, throwing errors ------- - - -bool mystd::str2vec( string inp, vector<double> *V, uint nmax, bool force ) -{ - using namespace std; - - // cout << "DEBUG mystd [" << inp << "]\n"; - V->clear(); - - while(inp.size() && isspace(inp[0])) inp.erase(inp.begin()); - // while(inp.size() && strchr(" \t.\n",inp[inp.size()-1])) - // inp.erase(inp.end()-1); - - // cout << "DEBUG core [" << inp << "]\n"; - if (inp==string("")) { - // cout << "DEBUG empty\n"; - return true; - } - // cout << "DEBUG nonempty\n"; - - string::size_type ji=0, jf; - double val; - char dummy; - while (ji<inp.size()) { - if ((jf=inp.find_first_of(", \t\n", ji)) == string::npos) - jf = inp.size(); - // cout << " look until " << jf << "\n"; - if (sscanf(inp.substr(ji,jf-ji).c_str(), "%lg%c", &val, &dummy) - ==1) { - V->push_back(val); - } else if ( force ) { - cout << "! str2vec: invalid value [" - << inp.substr(ji,jf-ji) << "] at pos " << ji - << " in [" << inp << "]\n"; - return false; - } - if (nmax && V->size()>=nmax) break; // do not decode the tail - // cout << " found "<<ji<<":"<<jf<<" value "<<val<<"\n"; - ji = inp.find_first_not_of(", \t\n", jf); - // cout << " continue at " << ji << "\n"; - } - - return true; -} - -bool mystd::any2dbl( const string& inp, double *val ) -{ - if(!inp.size()) { - cout << "expecting double, found empty input\n"; - return false; - } - if( inp=="-inf" || inp=="-oo" ){ - *val = -INFINITY; - return true; - } - if( inp=="inf" || inp=="oo" || inp=="+inf" || inp=="+oo" ){ - *val = INFINITY; - return true; - } - if(!strchr("+-0123456789.", inp[0])) { - cout << "expecting double, found bad char[0] in [" - << inp << "]\n"; - return false; - } - double mant; int expt; - if (sscanf(inp.c_str(), "%lgm%d", &mant, &expt)==2) { - *val = mant * pow(10.e0, (double)(-expt)); - return true; - } - if (sscanf(inp.c_str(), "%lg", val)==1) - return true; - cout << "expecting double, sscanf failed\n"; - return false; -} - -bool mystd::any2int( const string& inp, int *val ) -{ - if(!inp.size()) { - cout << "expecting integer, found empty input\n"; - return false; - } - if(!strchr("+-0123456789", inp[0])) { - cout << "expecting integer, found bad char[0] in [" - << inp << "]\n"; - return false; - } - if (sscanf(inp.c_str(), "%d", val)==1) return true; - cout << "expecting integer, sscanf failed\n"; - return false; -} - -bool mystd::any2uint( const string& inp, uint *val ) -{ - if(!inp.size()) { - cout << "expecting integer, found empty input\n"; - return false; - } - if(!strchr("0123456789", inp[0])) { - cout << "expecting integer, found bad char[0] in [" - << inp << "]\n"; - return false; - } - if (sscanf(inp.c_str(), "%u", val)==1) return true; - cout << "expecting integer, sscanf failed\n"; - return false; -} - -//**************************************************************************// -//* string operations *// -//**************************************************************************// - -string mystd::strip( - string const& str, ///< the original string - char const* sepSet ///< C string with characters to be dropped -) -{ - string::size_type const first = str.find_first_not_of(sepSet); - return ( first==std::string::npos ) - ? std::string() - : str.substr(first, str.find_last_not_of(sepSet)-first+1); -} - -void mystd::string_extract_word( const string& in, string *out1, string *out2 ) -{ - // one word (*out1) is extracted; leading " \t" are retained. - // in the tail (*out2) leading " \t" are deleted. - // "\n" starts always a new word. - // leading "`" makes *out1 go to next "`" or to end of line. - - string::size_type j0=0, j1, j2, jf=in.size(); - - // handle special case "`" - if (in[0]=='`') { - j1 = in.find_first_of('`', 1); - if (j1==string::npos) { - *out1 = in.substr(1); - *out2 = ""; - } else { - *out1 = in.substr(1,j1-1); - j2 = in.find_first_not_of(" \t", j1+1); - if (j2!=string::npos) - *out2 = in.substr(j2); - else - *out2 = ""; - } - return; - } - - while (j0<jf && strchr(" \t",in[j0])) j0++; - j1=j0+1; - while (j1<jf && !strchr(" \t\n",in[j1])) j1++; - j2=j1; - while (j2<jf && strchr(" \t",in[j2])) j2++; - *out1 = in.substr(0,j1); - if (j2<jf) - *out2 = in.substr(j2); - else - *out2 = string(""); - //cout << "from ["<<in<<"] word ["<<*out1<<"] and tail ["<<*out2<<"]\n"; -} - -void mystd::string_extract_line( const string& in, string *out1, string *out2 ) -{ - string line; - string::size_type i = in.find('\n'); - if (i==string::npos) { - *out1 = in; - *out2 = string(""); - } else { - *out1 = in.substr(0,i); - *out2 = in.substr(i+1); - } - //cout << "from ["<<in<<"] line ["<<*out1<<"] and tail ["<<*out2<<"]\n"; -} - - -//! Split string at whitespaces, set vector of words. - -void mystd::string2words( const string& in, vector<string>& out ) -{ - const string delimiters = " \t"; - // skip delimiters at beginning: - string::size_type lastPos = in.find_first_not_of( delimiters, 0 ); - // find first non-delimiter: - string::size_type pos = in.find_first_of( delimiters, lastPos ); - while ( pos!=string::npos || lastPos!=string::npos ) { - // found a token, add it to the vector: - out.push_back( in.substr(lastPos, pos-lastPos) ); - // skip delimiters: - lastPos = in.find_first_not_of( delimiters, pos ); - // find next non-delimiter: - pos = in.find_first_of( delimiters, lastPos ); - } -} - - -//**************************************************************************// -//* time *// -//**************************************************************************// - -//! Seconds since the epoch. Return them as double (WHY??) -// only used for calls to myasctime => OBSOLETE - -double mystd::justnow() -{ - struct timeval exactlynow; - gettimeofday(&exactlynow, NULL); - return (double) exactlynow.tv_sec; -} - -//! Return time as string in ctime/asctime standard format. -// OBSOLETE: better use strftime - -string mystd::myasctime( double time, int offs ) -{ - long timin = (long) time; - char buf[40]; - sprintf(buf, "%.24s", asctime(localtime(&timin))); - return string(buf+offs); -} - - -//**************************************************************************// -//* rounding *// -//**************************************************************************// - -//! Round given value to given number of digits. - -double mystd::round_decimal( double val, double digits ) -{ - if (val==0 || digits<=0) return 0; - double v = fabs(val); - int n = (int) floor ( digits - log10(v)); - // cout << " n=" << n; - double p = pow(10., n); - double r = round(v*p) / p; - return (val<0 ? -1 : +1) * r; -} - - -//**************************************************************************// -//* vector operations *// -//**************************************************************************// - -//! insert val into vector *V, presuming the latter is sorted - -void mystd::merge( vector<double> *V, double val ) -{ - for (uint i=0; i<V->size(); ++i) { - if (val>(*V)[i]) continue; - if (val==(*V)[i]) return; - V->insert(V->begin()+i, val); - return; - } - V->push_back(val); -} - -void mystd::unique( vector<double> *V, double tolabs, double tolrel ) -{ - // tolrel z.Zt. nicht benutzt - vector<double> aux; - double diff; - if (!V->size()) return; - aux.push_back((*V)[0]); - for (uint ii=1; ii<V->size(); ++ii) - if((diff=fabs((*V)[ii]-aux.back()))>tolabs) - aux.push_back((*V)[ii]); - *V = aux; -} - -//! detect sorting (strictly de- or increasing: -1 or1; else: 0). - -int mystd::sorted( const vector<double>& V ) -{ - uint n = V.size(); - if( n < 2 ) - throw string( "vector too short to determine sorting" ); - int ret; - if ( V[n-1] > V[0] ) - ret = 1; - else if ( V[n-1] < V[0] ) - ret = -1; - else - return 0; - for( uint i=2; i<n; ++i ) - if ( ret*(V[i]-V[i-1]) <= 0 ) - return 0; - return ret; -} - -//! detect equidistant grid, set *step. - -bool mystd::is_equidist( double *step, const vector<double>& V ) -{ - uint n = V.size(); - if( n < 2 ) - return false; // vector too short to determine equidistance - *step = ( V[n-1] - V[0] ) / (n-1); - for( uint i=1; i<n-1; ++i ) - if( fabs( V[i] - (V[0]+i*(*step)) ) > 1e-12*fabs(*step)+1e-200 ) - return false; - return true; -} diff --git a/pub/src/mystd.h b/pub/src/mystd.h deleted file mode 100644 index c0d329c7..00000000 --- a/pub/src/mystd.h +++ /dev/null @@ -1,35 +0,0 @@ -//**************************************************************************// -//* FRIDA: flexible rapid interactive data analysis *// -//* mystd: various auxilary routines *// -//* (C) Joachim Wuttke 2001- *// -//* http://apps.jcns.fz-juelich.de *// -//**************************************************************************// - -namespace mystd { - - //! convert from string - bool str2vec( string inp, vector<double> *V, uint nmax=0, bool force=true ); - bool any2dbl( const string& inp, double *val ); - bool any2int( const string& inp, int *val ); - bool any2uint( const string& inp, uint *val ); - - //! string operations - void string_extract_word( const string& in, string *out1, string *out2 ); - void string_extract_line( const string& in, string *out1, string *out2 ); - void string2words( const string& in, vector<string>& out ); - string strip( const string& str, const char* sepSet=" \n" ); - - //! time - double justnow(); - string myasctime( double time, int offs ); - - //! rounding - double round_decimal( double val, double digits ); - - //! vector operations - void merge( vector<double> *V, double val ); - void unique( vector<double> *V, - double tolabs=1e-100, double tolrel=1e-10 ); - int sorted( const vector<double>& V ); - bool is_equidist( double *step, const vector<double>& V ); -} diff --git a/pub/src/node.cpp b/pub/src/node.cpp index 48780e3f..fd0fc239 100644 --- a/pub/src/node.cpp +++ b/pub/src/node.cpp @@ -6,10 +6,12 @@ //**************************************************************************// #include <iostream> +#include <string> #include <vector> +#include <trivia/strg.hpp> + #include "defs.h" -#include "strg.h" #include "olf.h" #include "mem.h" #include "zentry.h" diff --git a/pub/src/olf.cpp b/pub/src/olf.cpp index ee4f2920..f6ff0f71 100644 --- a/pub/src/olf.cpp +++ b/pub/src/olf.cpp @@ -8,13 +8,14 @@ #include <cstdlib> #include <cstdio> #include <iostream> +#include <string> #include <vector> #include <algorithm> -#include <ask_simple_value.h> +#include <trivia/strg.hpp> +#include <read-plus/ask.hpp> #include "defs.h" -#include "strg.h" #include "olf.h" #include "zentry.h" #include "var.h" diff --git a/pub/src/opr.cpp b/pub/src/opr.cpp index bbe43fd6..232783ed 100644 --- a/pub/src/opr.cpp +++ b/pub/src/opr.cpp @@ -7,15 +7,15 @@ #include <cmath> #include <iostream> +#include <string> +#include <vector> #include <boost/format.hpp> -#include <ask_simple_value.h> -#include <readln.h> - -using boost::format; +#include <trivia/strg.hpp> +#include <read-plus/ask.hpp> +#include <read-plus/readln.hpp> #include "defs.h" -#include "strg.h" #include "olf.h" #include "mem.h" #include "zentry.h" @@ -25,6 +25,7 @@ using boost::format; #include "opr.h" #include "xax_lex.h" +using boost::format; //***************************************************************************// //* operate via generic expressions *// diff --git a/pub/src/plot.cpp b/pub/src/plot.cpp index 2a20edec..5959beb1 100644 --- a/pub/src/plot.cpp +++ b/pub/src/plot.cpp @@ -7,11 +7,12 @@ #include <iostream> #include <vector> +#include <string> -#include <readln.h> +#include <trivia/strg.hpp> +#include <read-plus/readln.hpp> #include "defs.h" -#include "strg.h" #include "olf.h" #include "mem.h" #include "zentry.h" diff --git a/pub/src/reg.cpp b/pub/src/reg.cpp index c5ffe2a0..7342a613 100644 --- a/pub/src/reg.cpp +++ b/pub/src/reg.cpp @@ -5,6 +5,8 @@ //* http://apps.jcns.fz-juelich.de/frida *// //**************************************************************************// +#include <string> + #include "defs.h" #include "reg.h" diff --git a/pub/src/rng.cpp b/pub/src/rng.cpp deleted file mode 100644 index 968e3589..00000000 --- a/pub/src/rng.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//**************************************************************************// -//* FRIDA: flexible rapid interactive data analysis *// -//* rng: random number generator wrapper *// -//* (C) Joachim Wuttke 1990-, v2(C++) 2001- *// -//* http://apps.jcns.fz-juelich.de *// -//**************************************************************************// - -#include <gsl/gsl_rng.h> -#include <gsl/gsl_randist.h> -#include <math.h> - -#include "rng.h" - -namespace NRNG { // local declarations (global declarations are in rng.h) - gsl_rng *r; // static variable -} - -void NRNG::init() -{ - gsl_rng_env_setup(); - NRNG::r = gsl_rng_alloc( gsl_rng_default ); -} - -double NRNG::uniform() -{ - return gsl_rng_uniform( NRNG::r ); -} - -double NRNG::uniform( const double rmin, const double rmax ) -{ - return rmin + (rmax-rmin)*gsl_rng_uniform( NRNG::r ); -} - -double NRNG::gaussian( const double stdv, const double cutoff ) -{ - double ret; - do { - ret = gsl_ran_gaussian ( NRNG::r, stdv ); - } while( fabs(ret)>cutoff ); - return ret; -} diff --git a/pub/src/rng.h b/pub/src/rng.h deleted file mode 100644 index 72a168af..00000000 --- a/pub/src/rng.h +++ /dev/null @@ -1,13 +0,0 @@ -//**************************************************************************// -//* FRIDA: flexible rapid interactive data analysis *// -//* rng: random number generator wrapper *// -//* (C) Joachim Wuttke 1990-, v2(C++) 2001- *// -//* http://apps.jcns.fz-juelich.de *// -//**************************************************************************// - -namespace NRNG { - void init(); - double uniform(); - double uniform( const double rmin, const double rmax ); - double gaussian( const double stdv, const double cutoff ); -} diff --git a/pub/src/rssm.cpp b/pub/src/rssm.cpp index 7f382927..e6c8687b 100644 --- a/pub/src/rssm.cpp +++ b/pub/src/rssm.cpp @@ -8,14 +8,16 @@ #include <cstring> #include <iostream> #include <fstream> +#include <string> +#include <vector> -#include <yaml-cpp/yaml.h> -#include <ask_simple_value.h> +#include <trivia/strg.hpp> +#include <trivia/mystd.hpp> +#include <trivia/file_ops.hpp> +#include <read-plus/ask.hpp> +#include <yaml-cpp/yaml.hpp> #include "defs.h" -#include "strg.h" -#include "mystd.h" -#include "file_ops.h" #include "olf.h" #include "mem.h" #include "zentry.h" diff --git a/pub/src/special1.cpp b/pub/src/special1.cpp index 1a030454..1043d03b 100644 --- a/pub/src/special1.cpp +++ b/pub/src/special1.cpp @@ -5,23 +5,23 @@ //* http://apps.jcns.fz-juelich.de *// //**************************************************************************// -#include <math.h> -#include <stdlib.h> -#include <stdio.h> +#include <cstdlib> +#include <cstdio> +#include <cmath> #include <iostream> #include <boost/format.hpp> -#include<gsl/gsl_eigen.h> +#include <gsl/gsl_eigen.h> -#include <ask_simple_value.h> +#include <trivia/mystd.hpp> +#include <read-plus/ask.hpp> -using boost::format; -using namespace std; - -#include "mystd.h" +#include "defs.h" #include "olf.h" #include "mem.h" #include "special.h" +using boost::format; + //! Determine eigenvalue and eigenvectors of quadratic data set. void NSpecial::Eigen() diff --git a/pub/src/special2.cpp b/pub/src/special2.cpp index 3220f49b..942a0fb6 100644 --- a/pub/src/special2.cpp +++ b/pub/src/special2.cpp @@ -2,12 +2,13 @@ #include <cmath> #include <fftw3.h> #include <iostream> +#include <string> #include <vector> -#include <ask_simple_value.h> +#include <trivia/strg.hpp> +#include <read-plus/ask.hpp> #include "defs.h" -#include "strg.h" #include "olf.h" #include "mem.h" #include "zentry.h" diff --git a/pub/src/strg.cpp b/pub/src/strg.cpp deleted file mode 100644 index de2e7a30..00000000 --- a/pub/src/strg.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//**************************************************************************// -//* FRIDA: flexible rapid interactive data analysis *// -//* strg: convert to string *// -//* (C) Joachim Wuttke 2001- *// -//* http://apps.jcns.fz-juelich.de *// -//**************************************************************************// - -#include<string> -#include <boost/format.hpp> - -using namespace std; -using boost::format; - -string strg( const string& val ) -{ - return val; -} - -string strg( bool val) { - return val ? "y" : "n"; -} - -string strg( double val ) -{ - return str( format( "%g" ) % val ); -} - -string strg( int val ) -{ - return str( format( "%d" ) % val ); -} - -string strg( unsigned int val ) -{ - return str( format( "%u" ) % val ); -} - -string strg( unsigned long val) // needed for size_t on 64 bit machine -{ - return str( format( "%lu" ) % val ); -} - -string strg( char val ) -{ - return string(1, val); -} diff --git a/pub/src/strg.h b/pub/src/strg.h deleted file mode 100644 index cf3cd852..00000000 --- a/pub/src/strg.h +++ /dev/null @@ -1,14 +0,0 @@ -//**************************************************************************// -//* FRIDA: flexible rapid interactive data analysis *// -//* strg: convert to string *// -//* (C) Joachim Wuttke 2001- *// -//* http://apps.jcns.fz-juelich.de *// -//**************************************************************************// - -string strg( const string& val ); -string strg( bool val ); -string strg( int val ); -string strg( unsigned int val ); -string strg( unsigned long val ); -string strg( char val ); -string strg( double val ); diff --git a/pub/src/var.cpp b/pub/src/var.cpp index 2e073bc9..7c15e5b5 100644 --- a/pub/src/var.cpp +++ b/pub/src/var.cpp @@ -5,11 +5,13 @@ //* http://apps.jcns.fz-juelich.de *// //**************************************************************************// +#include <string> #include <vector> +#include <trivia/strg.hpp> +#include <trivia/mystd.hpp> + #include "defs.h" -#include "strg.h" -#include "mystd.h" #include "var.h" //***************************************************************************// diff --git a/pub/src/xax_lex.lpp b/pub/src/xax_lex.lpp index 81f2249b..2e3e3d60 100644 --- a/pub/src/xax_lex.lpp +++ b/pub/src/xax_lex.lpp @@ -10,10 +10,11 @@ %option noyywrap %{ +#include <string> #include <vector> #include <cmath> +#include <trivia/strg.h> #include "defs.h" -#include "strg.h" #include "func.h" #include "reg.h" #include "var.h" diff --git a/pub/src/xax_yacc.ypp b/pub/src/xax_yacc.ypp index ea0ba5b1..0cc0fc80 100644 --- a/pub/src/xax_yacc.ypp +++ b/pub/src/xax_yacc.ypp @@ -6,7 +6,8 @@ //**************************************************************************// %{ -#include <vector> // for expr.h +#include <string> +#include <vector> #include "defs.h" #include "ptr.h" #include "func.h" diff --git a/pub/src/yaml_out.cpp b/pub/src/yaml_out.cpp deleted file mode 100644 index 974b8bac..00000000 --- a/pub/src/yaml_out.cpp +++ /dev/null @@ -1,44 +0,0 @@ -//**************************************************************************// -//* FRIDA: flexible rapid interactive data analysis *// -//* yaml_out: workaround for YAML output *// -//* (C) Joachim Wuttke 2001- *// -//* http://apps.jcns.fz-juelich.de *// -//**************************************************************************// - -#include <string> -using namespace std; - -//! refine string for yaml output. - -string yaml( const string s ) -// string -> yaml-output-string -{ - if ( s=="" ) - return "\"\""; - string out = s; - uint i = 0; - // escape " - while( i < out.size() ){ - if( ( out[i]=='"' || out[i]=='\'' ) && (i==0 || out[i-1]!='\\') ) - out.insert( i, "\\" ); - ++i; - } - // if there are special characters, put "" around - if( s.find( '"' )!=string::npos || - s.find( '\'' )!=string::npos || - s.find( '\\' )!=string::npos || - s.find( ':' )!=string::npos || - s.find( '*' )!=string::npos || - s.find( '&' )!=string::npos || - s.find( '#' )!=string::npos || - s.find( '>' )!=string::npos || - s.find( '<' )!=string::npos || - s.find( '[' )!=string::npos || - s.find( ']' )!=string::npos || - s.find( '{' )!=string::npos || - s.find( '}' )!=string::npos - ) - out = '"' + out + '"'; - return out; -} - diff --git a/pub/src/yaml_out.h b/pub/src/yaml_out.h deleted file mode 100644 index ae2345c6..00000000 --- a/pub/src/yaml_out.h +++ /dev/null @@ -1,9 +0,0 @@ -//**************************************************************************// -//* FRIDA: flexible rapid interactive data analysis *// -//* yaml_out: workaround for YAML output *// -//* (C) Joachim Wuttke 2001- *// -//* http://apps.jcns.fz-juelich.de *// -//**************************************************************************// - -string yaml( const string ); - diff --git a/pub/src/zentry.cpp b/pub/src/zentry.cpp index ad4fc66e..66fb90f4 100644 --- a/pub/src/zentry.cpp +++ b/pub/src/zentry.cpp @@ -7,9 +7,11 @@ #include <cmath> #include <vector> +#include <string> + +#include <trivia/strg.hpp> #include "defs.h" -#include "strg.h" #include "ptr.h" #include "zentry.h" -- GitLab