From 1f05b9a1a093accaee5ff20433d86876125c4671 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Thu, 3 Dec 2020 01:16:58 -0800 Subject: bc: Switch back to GNU bc The 1.07 release means we don't have to apply a bunch of patches, and it is a smaller binary anyway. --- .gitmodules | 3 --- README.md | 1 - pkg/bc/.gitignore | 3 ++- pkg/bc/config.h | 64 ++++++++++++++++++++++++++++++++++++++++++------- pkg/bc/gen.lua | 69 +++++++---------------------------------------------- pkg/bc/libmath.h | 46 +++++++++++++++++++++++++++++++++++ pkg/bc/sha256 | 1 + pkg/bc/src | 1 - pkg/bc/url | 1 + pkg/bc/ver | 2 +- scripts/outdated.py | 1 - 11 files changed, 116 insertions(+), 76 deletions(-) create mode 100644 pkg/bc/libmath.h create mode 100644 pkg/bc/sha256 delete mode 160000 pkg/bc/src create mode 100644 pkg/bc/url diff --git a/.gitmodules b/.gitmodules index 244a8ff1..db43122c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,9 +19,6 @@ [submodule "pkg/b3sum/src"] path = pkg/b3sum/src url = https://git.sr.ht/~mcf/b3sum -[submodule "pkg/bc/src"] - path = pkg/bc/src - url = https://git.yzena.com/gavin/bc.git [submodule "pkg/bearssl/src"] path = pkg/bearssl/src url = https://www.bearssl.org/git/BearSSL diff --git a/README.md b/README.md index 5f00c2e1..474d6ea4 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,6 @@ tools whenever possible: - oksh instead of bash - sdhcp instead of dhclient or dhcpcd - vis instead of vim or emacs -- bc-gh instead of GNU bc - byacc instead of bison - perp and sinit instead of sysvinit or systemd - netsurf instead of chromium or firefox diff --git a/pkg/bc/.gitignore b/pkg/bc/.gitignore index 012dc66e..c4a9879d 100644 --- a/pkg/bc/.gitignore +++ b/pkg/bc/.gitignore @@ -1 +1,2 @@ -/tools.ninja +/bc-1.07.1.tar.gz +/src diff --git a/pkg/bc/config.h b/pkg/bc/config.h index ae9157f7..b69b1bc5 100644 --- a/pkg/bc/config.h +++ b/pkg/bc/config.h @@ -1,8 +1,56 @@ -#define BC_ENABLED 1 -#define DC_ENABLED 0 - -#define BC_ENABLE_EXTRA_MATH 1 -#define BC_ENABLE_HISTORY 1 -#define BC_ENABLE_NLS 0 -#define BC_ENABLE_PROMPT 1 -#define BC_NUM_KARATSUBA_LEN 32 +#define BC_COPYRIGHT "Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc." +#define DC_COPYRIGHT "Copyright 1994, 1997, 1998, 2000, 2001, 2003-2006, 2008, 2010, 2012-2017 Free Software Foundation, Inc." +#define DC_VERSION "1.4.1" +/* #undef HAVE_DOPRNT */ +#define HAVE_ERRNO_H 1 +#define HAVE_FSTAT 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_ISGRAPH 1 +/* #undef HAVE_LIB_H */ +#define HAVE_LIMITS_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_SETVBUF 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRTOL 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_VPRINTF 1 +/* #undef LIBEDIT */ +#define PACKAGE "bc" +#define PACKAGE_BUGREPORT "" +#define PACKAGE_NAME "bc" +#define PACKAGE_STRING "bc 1.07.1" +#define PACKAGE_TARNAME "bc" +#define PACKAGE_URL "" +#define PACKAGE_VERSION "1.07.1" +/* #undef READLINE */ +#define STDC_HEADERS 1 +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif +#define VERSION "1.07.1" +/* #undef YYTEXT_POINTER */ +/* #undef _MINIX */ +/* #undef _POSIX_1_SOURCE */ +/* #undef _POSIX_SOURCE */ +/* #undef const */ +/* #undef ptrdiff_t */ +/* #undef size_t */ diff --git a/pkg/bc/gen.lua b/pkg/bc/gen.lua index f02abc76..a7956d8c 100644 --- a/pkg/bc/gen.lua +++ b/pkg/bc/gen.lua @@ -1,69 +1,18 @@ cflags{ - '-D NDEBUG', - '-D VERSION=3.1.6', + '-std=c99', '-Wall', '-Wpedantic', '-D _POSIX_C_SOURCE=200809L', - '-I $srcdir/include', - '-include $dir/config.h', + '-I $dir', + '-I $srcdir/h', } -sub('tools.ninja', function() - toolchain(config.host) - exe('strgen', {'gen/strgen.c'}) - rule('strgen', [[$outdir/strgen $in $out $name $header '$label' '$define' $removetabs]]) - build('strgen', '$outdir/bc_help.c', {'$srcdir/gen/bc_help.txt', '|', '$outdir/strgen'}, { - name='bc_help', header='bc.h', label='', define='BC_ENABLED', removetabs='', - }) - build('strgen', '$outdir/dc_help.c', {'$srcdir/gen/dc_help.txt', '|', '$outdir/strgen'}, { - name='dc_help', header='dc.h', label='', define='DC_ENABLED', removetabs='', - }) - build('strgen', '$outdir/lib.c', {'$srcdir/gen/lib.bc', '|', '$outdir/strgen'}, { - name='bc_lib', header='bc.h', label='bc_lib_name', define='BC_ENABLED', removetabs='1', - }) - build('strgen', '$outdir/lib2.c', {'$srcdir/gen/lib2.bc', '|', '$outdir/strgen'}, { - name='bc_lib2', header='bc.h', label='bc_lib2_name', define='BC_ENABLED && BC_ENABLE_EXTRA_MATH', removetabs='1', - }) -end) - exe('bin/bc', [[ - src/( - args.c - data.c - file.c - lang.c - lex.c - main.c - num.c - opt.c - parse.c - program.c - read.c - vector.c - vm.c - bc/(bc.c lex.c parse.c) - dc/(dc.c lex.c parse.c) - history/history.c - rand/rand.c + bc/( + main.c bc.c scan.c execute.c load.c storage.c util.c global.c + warranty.c ) - $outdir/(bc_help.c dc_help.c lib.c lib2.c) + lib/number.c ]]) file('bin/bc', '755', '$outdir/bin/bc') +man{'doc/bc.1'} -local opts = {} -for line in iterlines('config.h', 1) do - local var, val = line:match('^define ([^ ]+) ([^ ]+)') - if var and val == '1' then - opts[var] = true - end -end - -local manfile = '' -if not opts.BC_ENABLE_EXTRA_MATH then manfile = manfile..'E' end -if not opts.BC_ENABLE_HISTORY then manfile = manfile..'H' end -if not opts.BC_ENABLE_NLS then manfile = manfile..'N' end -if not opts.BC_ENABLE_PROMPT then manfile = manfile..'P' end -if manfile == '' then manfile = 'A' end - -build('copy', '$outdir/bc.1', '$srcdir/manuals/bc/'..manfile..'.1') -man{'$outdir/bc.1'} - -fetch 'git' +fetch 'curl' diff --git a/pkg/bc/libmath.h b/pkg/bc/libmath.h new file mode 100644 index 00000000..63e1acb9 --- /dev/null +++ b/pkg/bc/libmath.h @@ -0,0 +1,46 @@ +{"@iK20:s2:p@r", +"@iF1,5.6,7,8,9,10,11,12,13,14,15[l0:KA:#Z1:l0:s7:pKA:s0:pl5:C1,0:", +"s14:pl7:s0:pl14:RN1:l5:0Z4:l10:1+s10:pl5:K2:/s5:pl2:", +"1+s2:pJ3:N4:l13:s2:p1l5:+s14:pl5:s6:p1s8:pK2:s11:pN6:1B7:J5:N8:", +"l11:i11:pJ6:N7:l6:l5:*s6:l8:l11:*s8:/s9:pl9:0=Z9:l10:0>Z10:N11:", +"l10:d10:Z12:l14:l14:*s14:pJ11:N12:N10:l15:s2:pl12:Z13:1l14:/R", +"N13:l14:1/RN9:l14:l9:+s14:pJ8:N5:0R]@r", +"@iF2,5.7,9,10,11,12,13,14,15[l0:KA:#Z1:l0:s7:pKA:s0:pl5:C2,0:", +"s14:pl7:s0:pl14:RN1:l5:0{Z2:1K10:l2:^-1/RN2:l2:s15:pK6:l2:+s2:", +"pK2:s10:p0s11:pN3:l5:K2:}Z4:l10:K2:*s10:pl5:cRs5:pJ3:N4:N5:l5:", +"K.5:{Z6:l10:K2:*s10:pl5:cRs5:pJ5:N6:l5:1-l5:1+/s13:s14:pl13:l13:", +"*s12:pK3:s11:pN8:1B9:J7:N10:l11:K2:+s11:pJ8:N9:l13:l12:*s13:l11:", +"/s9:pl9:0=Z11:l10:l14:*s14:pl15:s2:pl14:1/RN11:l14:l9:+s14:pJ10:N7:", +"0R]@r", +"@iF3,5.7,9,11,12,13,16,14,15[l0:KA:#Z1:l0:s7:pKA:s0:pl5:C3,0:", +"s14:pl7:s0:pl14:RN1:l2:s15:pK1.1:l15:*K2:+s2:p1C4,0:s14:pl5:0", +"Z11:l15:K5:+s2:pK.2:C4,0:s6:pN11:", +"l15:K3:+s2:pN12:l5:K.2:>Z13:l10:1+s10:pl5:K.2:-1l5:K.2:*+/s5:", +"pJ12:N13:l5:s13:s14:pl5:nl5:*s16:pK3:s11:pN15:1B16:J14:N17:l11:", +"K2:+s11:pJ15:N16:l13:l16:*s13:l11:/s9:pl9:0=Z18:l15:s2:pl10:l6:", +"*l14:+l12:/RN18:l14:l9:+s14:pJ17:N14:0R]@r", +"@iF6,13,5.6,7,8,9,10,11,12,16,14,15[l0:KA:#Z1:l0:s7:pKA:s0:pl13:", +"l5:C6,00:s14:pl7:s0:pl14:RN1:l2:s15:p0s2:pl13:1/s13:pl13:0